diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-07-15 12:36:46 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-07-15 12:36:46 +0000 |
commit | 3f05644af4c92b4c483fefb00a9c7f8fe9ad552d (patch) | |
tree | 9de802aa0bba8c236f8ca0aef903373dbb58c9f0 /src | |
parent | 6cfa87f0908b4bdc71d42cd8b17ab3ee82f27b18 (diff) | |
download | fpGUI-3f05644af4c92b4c483fefb00a9c7f8fe9ad552d.tar.xz |
* Appied gui_edit patch from Jean-Marc.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/gui_edit.pas | 85 |
1 files changed, 81 insertions, 4 deletions
diff --git a/src/gui/gui_edit.pas b/src/gui/gui_edit.pas index b9c608af..24ac8ef1 100644 --- a/src/gui/gui_edit.pas +++ b/src/gui/gui_edit.pas @@ -246,7 +246,7 @@ type property OnMouseExit; end; - + TfpgEditCurrency = class(TfpgBaseNumericEdit) private fDecimals: integer; @@ -844,7 +844,7 @@ procedure TfpgBaseEdit.HandleLMouseDown(x, y: integer; shiftstate: TShiftState); cp: integer;} begin inherited HandleLMouseDown(x, y, shiftstate); - + {cp := PointToCharPos(x, y); FMouseDragPos := cp; FCursorPos := cp; @@ -887,7 +887,7 @@ var begin if (btnstate and MOUSE_LEFT) = 0 then Exit; - + {cp := PointToCharPos(x, y); //FMouseDragPos := cp; @@ -1354,7 +1354,7 @@ end; procedure TfpgEditInteger.SetValue(const AValue: integer); begin try - fText := IntToStr(AValue); + Text := IntToStr(AValue); except on E: EConvertError do Text := ''; @@ -1655,9 +1655,83 @@ begin end; procedure TfpgEditCurrency.SetValue(const AValue: Currency); +var + i,long: integer; + txt, texte, decimal: string; begin try fText := CurrToStr(AValue); + if ShowThousand then + begin + if Pos(DecimalSeparator, fText) = 0 then + txt := fText + else + begin + txt := UTF8Copy(fText, 1, Pred(Pos(DecimalSeparator, fText))); + decimal := UTF8Copy(fText, Succ(Pos(DecimalSeparator, fText)), UTF8Length(fText) - Pos(DecimalSeparator, fText)); + end; + if AValue < 0 then + txt:= UTF8Copy(txt, 2, UTF8Length(txt)-1); + long := UTF8Length(txt); + i := 0; + texte := ''; + repeat + if i > 0 then + if ((i mod 3) = 0) and (txt[UTF8Length(txt)-UTF8Length(texte)] <> ThousandSeparator) then + begin + texte := ThousandSeparator + texte; + if AValue < 0 then + begin + if Pred(FCursorPos) <= UTF8Length(texte) then + Inc(FCursorPos); + end + else + if FCursorPos <= UTF8Length(texte) then + Inc(FCursorPos); + end; + texte := Copy(txt, long - i, 1) + texte; + inc(i); + until i = long; + if Pos(DecimalSeparator, fText) = 0 then + begin + if AValue < 0 then + begin + fText := '-' + texte; + Inc(FCursorPos); + end + else + fText := texte; + end + else + begin + if AValue < 0 then + begin + fText := '-' + texte + DecimalSeparator + decimal; + Inc(FCursorPos); + end + else + fText := texte + DecimalSeparator + decimal; + FCursorPos := FCursorPos + Succ(Length(decimal)); + end; + end; + if fDecimals > 0 then + begin + if Pos(DecimalSeparator, fText) = 0 then + begin + fText := fText + DecimalSeparator; + Inc(FCursorPos); + end; + if UTF8Length(fText)-Pos(DecimalSeparator, fText) < fDecimals then + while UTF8Length(fText)-Pos(DecimalSeparator, fText) < fDecimals do + begin + fText := fText + '0'; + Inc(FCursorPos); + end; + end; + if AValue < 0 then + TextColor := NegativeColor + else + TextColor := OldColor; except on E: EConvertError do Text := ''; @@ -1749,7 +1823,10 @@ begin if fDecimals > 0 then begin if Pos(DecimalSeparator, fText) = 0 then + begin fText := fText + DecimalSeparator; + Inc(FCursorPos); + end; if UTF8Length(fText)-Pos(DecimalSeparator, fText) < fDecimals then while UTF8Length(fText)-Pos(DecimalSeparator, fText) < fDecimals do begin |