From c592afdcb2c5e3fa1da2df4044a48976e5a8a8f7 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Tue, 21 Feb 2012 13:13:35 +0200 Subject: 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(). --- src/gui/fpg_edit.pas | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src') 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); -- cgit v1.2.3-70-g09d2