summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2012-02-21 13:13:35 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2012-02-21 13:13:35 +0200
commitc592afdcb2c5e3fa1da2df4044a48976e5a8a8f7 (patch)
tree564c3cc89b0da21c360b0f2b91c13fb815059245 /src
parentcf09a50a45938d9d4e6d8662d0ee73d76d6664b0 (diff)
downloadfpGUI-c592afdcb2c5e3fa1da2df4044a48976e5a8a8f7.tar.xz
fpg_edit: refactored out the TextColor change due to negative/positive values.
This allows use to reuse this bit of code without affecting the internal FText values - as is caused by SetShowThousand in FormatEdit().
Diffstat (limited to 'src')
-rw-r--r--src/gui/fpg_edit.pas16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/gui/fpg_edit.pas b/src/gui/fpg_edit.pas
index fb5c6671..e04f02eb 100644
--- a/src/gui/fpg_edit.pas
+++ b/src/gui/fpg_edit.pas
@@ -212,6 +212,7 @@ type
procedure SetNegativeColor(const AValue: TfpgColor);
procedure SetThousandSeparator(const AValue: TfpgChar);
procedure SetShowThousand;
+ procedure AdjustColorForNegativeValues;
protected
function GetMarginAdjustment: integer; override;
procedure HandlePaint; override;
@@ -1769,6 +1770,15 @@ begin
end;
end;
+procedure TfpgBaseNumericEdit.AdjustColorForNegativeValues;
+begin
+ // Colour negative number
+ if LeftStr(Text,1) = '-' then
+ TextColor := NegativeColor
+ else
+ TextColor := OldColor;
+end;
+
function TfpgBaseNumericEdit.GetMarginAdjustment: integer;
begin
// Due to numeric edits being right aligned, the margin is negative
@@ -1818,11 +1828,7 @@ end;
procedure TfpgBaseNumericEdit.FormatEdit;
begin
SetShowThousand;
- // Colour negative number
- if LeftStr(Text,1) = '-' then
- TextColor := NegativeColor
- else
- TextColor := OldColor;
+ AdjustColorForNegativeValues;
end;
constructor TfpgBaseNumericEdit.Create(AOwner: TComponent);