summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2009-10-09 15:35:50 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2009-10-09 15:35:50 +0200
commit3b6721c900780b16bb032b8e59c1997c5fd12ddd (patch)
tree3a0053b6d52111c732d51cefcd516089f18ef784
parent441528ff12011732221996990d0a206e610649ed (diff)
downloadfpGUI-3b6721c900780b16bb032b8e59c1997c5fd12ddd.tar.xz
Canvas.DrawString() help.
The coordinates of DrawString is the top/left corner of the string. So the actual text appears below y.
-rw-r--r--examples/corelib/canvastest/fpgcanvas.lpi5
-rw-r--r--examples/corelib/canvastest/fpgcanvas.lpr6
-rw-r--r--src/corelib/fpg_base.pas1
3 files changed, 9 insertions, 3 deletions
diff --git a/examples/corelib/canvastest/fpgcanvas.lpi b/examples/corelib/canvastest/fpgcanvas.lpi
index 56117be1..66833b5b 100644
--- a/examples/corelib/canvastest/fpgcanvas.lpi
+++ b/examples/corelib/canvastest/fpgcanvas.lpi
@@ -1,15 +1,14 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
- <PathDelim Value="/"/>
- <Version Value="6"/>
+ <Version Value="7"/>
<General>
<Flags>
<SaveOnlyProjectUnits Value="True"/>
+ <LRSInOutputDirectory Value="False"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
- <IconPath Value="./"/>
<TargetFileExt Value=""/>
<Title Value="fpcanvas"/>
</General>
diff --git a/examples/corelib/canvastest/fpgcanvas.lpr b/examples/corelib/canvastest/fpgcanvas.lpr
index 5db95e09..c5473ba9 100644
--- a/examples/corelib/canvastest/fpgcanvas.lpr
+++ b/examples/corelib/canvastest/fpgcanvas.lpr
@@ -92,6 +92,12 @@ begin
y := 60;
Canvas.SetTextColor(clBlack);
Canvas.DrawString(5, y, 'This text must be black and default font (' + fpgApplication.DefaultFont.FontDesc + ')');
+
+ // red dot indicates top/left corner of where previous text was started
+ Canvas.Pixels[5,y] := clRed;
+// Canvas.DrawLine(5,y-4, 5,y+5);
+// Canvas.DrawLine(1,y, 10, y);
+
Canvas.SetTextColor(clRed);
y := y + Canvas.Font.Height; // fonts are different sizes on differet OS's
Canvas.DrawString(5, y, 'This text must be red.');
diff --git a/src/corelib/fpg_base.pas b/src/corelib/fpg_base.pas
index 945a2de3..2ebb3201 100644
--- a/src/corelib/fpg_base.pas
+++ b/src/corelib/fpg_base.pas
@@ -326,6 +326,7 @@ type
procedure DrawPolygon(const Points: array of TPoint);
procedure StretchDraw (x, y, w, h: TfpgCoord; ASource: TfpgImageBase);
procedure CopyRect(ADest_x, ADest_y: TfpgCoord; ASrcCanvas: TfpgCanvasBase; var ASrcRect: TfpgRect);
+ // x,y is the top/left corner of where the text output will start.
procedure DrawString(x, y: TfpgCoord; const txt: string);
procedure FillRectangle(x, y, w, h: TfpgCoord); overload;
procedure FillRectangle(r: TfpgRect); overload;