diff options
author | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2010-04-21 09:17:44 +0200 |
---|---|---|
committer | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2010-04-21 09:17:44 +0200 |
commit | 8e129e1d346f0128aea4f4efcffe0d6ab3ce9bfe (patch) | |
tree | 07fad3a8ebf4727976bc59284994a47fdfa3bd54 /src/gui/fpg_edit.pas | |
parent | bc7e3c21ee53986a53535013638ea267abca2f3d (diff) | |
download | fpGUI-8e129e1d346f0128aea4f4efcffe0d6ab3ce9bfe.tar.xz |
Edit: fixed vertical centering of text.
Before we had a hard-coded top co-ordinate for the text. This
caused problems when the TfpgEdit.Height was adjusted for some
reason. So now we rather use the Canvas.DrawText() and give it
a rectangle and text flags so text output can be calculated
correctly. This is very useful for inline editing in a StringGrid.
Internally Canvas.DrawText calls fpgStyle.DrawString, so custom
styling should still be applied.
Diffstat (limited to 'src/gui/fpg_edit.pas')
-rw-r--r-- | src/gui/fpg_edit.pas | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/gui/fpg_edit.pas b/src/gui/fpg_edit.pas index 5c46a08f..4920fe05 100644 --- a/src/gui/fpg_edit.pas +++ b/src/gui/fpg_edit.pas @@ -1390,19 +1390,25 @@ end; procedure TfpgBaseTextEdit.HandlePaint; var r: TfpgRect; + flags: TFTextFlags; begin inherited HandlePaint; r := Canvas.GetClipRect; // contains adjusted size based on borders + r.Left := -FDrawOffset + GetMarginAdjustment; if Enabled and (FVisibleText = '') and (not Focused) then begin Canvas.SetTextColor(clShadow1); - fpgStyle.DrawString(Canvas, -FDrawOffset + GetMarginAdjustment, r.Top + FHeightMargin, FExtraHint, Enabled); + flags := [txtLeft, txtVCenter]; + Canvas.DrawText(r, FExtraHint, flags); // fpgStyle.DrawString is called internally end else begin Canvas.SetTextColor(FTextColor); - fpgStyle.DrawString(Canvas, -FDrawOffset + GetMarginAdjustment, r.Top + FHeightMargin, FVisibleText, Enabled); + flags := [txtLeft, txtVCenter]; + if not Enabled then + flags += [txtDisabled]; + Canvas.DrawText(r, FVisibleText, flags); // fpgStyle.DrawString is called internally end; if Focused then |