summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-07-14 15:55:06 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-07-14 15:55:06 +0000
commitccbce7ba60305b5438c3ac6311d39374ee2a0e55 (patch)
tree0ed2e5e12d0c2a3e2267a616156f9a07965b5b9c /src/gui
parent050d90f6aeaaeae73461851ef4c0fea1f6e69a12 (diff)
downloadfpGUI-ccbce7ba60305b5438c3ac6311d39374ee2a0e55.tar.xz
* Applied patch no:2014995 EditFload decimal setup.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui_edit.pas50
1 files changed, 38 insertions, 12 deletions
diff --git a/src/gui/gui_edit.pas b/src/gui/gui_edit.pas
index 0078f48e..4be59540 100644
--- a/src/gui/gui_edit.pas
+++ b/src/gui/gui_edit.pas
@@ -245,7 +245,7 @@ type
property OnMouseEnter;
property OnMouseExit;
end;
-
+
TfpgEditCurrency = class(TfpgBaseNumericEdit)
private
@@ -285,7 +285,7 @@ function CreateEditInteger(AOwner: TComponent; x, y, w, h: TfpgCoord;
AShowThousand: boolean= True): TfpgEditInteger;
function CreateEditFloat(AOwner: TComponent; x, y, w, h: TfpgCoord;
- AShowThousand: boolean= True): TfpgEditFloat;
+ AShowThousand: boolean= True; ADecimals: Integer= -1): TfpgEditFloat;
function CreateEditCurrency(AOwner: TComponent; x, y, w, h: TfpgCoord;
AShowThousand: boolean= True; ADecimals: Integer= 2): TfpgEditCurrency;
@@ -331,13 +331,15 @@ begin
Result.Height:= h;
end;
-function CreateEditFloat(AOwner: TComponent; x, y, w, h: TfpgCoord; AShowThousand: boolean= True): TfpgEditFloat;
+function CreateEditFloat(AOwner: TComponent; x, y, w, h: TfpgCoord; AShowThousand: boolean= True;
+ ADecimals: Integer= -1): TfpgEditFloat;
begin
Result := TfpgEditFloat.Create(AOwner);
Result.Left := x;
Result.Top := y;
Result.Width := w;
Result.ShowThousand:= AShowThousand;
+// Result.Decimals := ADecimals;
if h < TfpgEditFloat(Result).FFont.Height + 6 then
Result.Height:= TfpgEditFloat(Result).FFont.Height + 6
else
@@ -1430,6 +1432,7 @@ end;
constructor TfpgEditInteger.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
+ fShowThousand := True;
end;
{ TfpgEditFloat }
@@ -1439,9 +1442,15 @@ var
txt: string;
begin
if fDecimals > 0 then
+ begin
if Pos(DecimalSeparator, fText) > 0 then
if UTF8Length(fText)-Pos(DecimalSeparator, fText) > fDecimals then
fText := Copy(fText, 1, UTF8Length(fText) - 1);
+ end
+ else
+ if fDecimals = 0 then
+ if Pos(DecimalSeparator, fText) > 0 then
+ fText := Copy(fText, 1, UTF8Length(fText) - 1);
if ShowThousand then
begin
if Copy(fText, 1, 1) = '-' then
@@ -1502,7 +1511,21 @@ begin
decimal := UTF8Copy(fText, Succ(Pos(DecimalSeparator, fText)), UTF8Length(fText)-Pos(DecimalSeparator, fText));
end
else
- txt := fText;
+ txt := fText
+ else
+ if fDecimals = 0 then
+ if Pos(DecimalSeparator, fText) > 0 then
+ txt := UTF8Copy(fText, 1, Pred(Pos(DecimalSeparator, fText)))
+ else
+ txt := fText
+ else
+ if Pos(DecimalSeparator, fText) > 0 then
+ begin
+ txt := UTF8Copy(fText, 1, Pred(Pos(DecimalSeparator, fText)));
+ decimal := UTF8Copy(fText, Succ(Pos(DecimalSeparator, fText)), UTF8Length(fText)-Pos(DecimalSeparator, fText));
+ end
+ else
+ txt := fText;
if ShowThousand then
begin
if fText > '' then
@@ -1553,10 +1576,10 @@ end;
procedure TfpgEditFloat.SetDecimals(AValue: integer);
begin
-if AValue < 0 then
- Exit; // =>
-if fDecimals <> AValue then
- fDecimals := AValue
+ if AValue < -1 then
+ Exit; // =>
+ if fDecimals <> AValue then
+ fDecimals := AValue
end;
procedure TfpgEditFloat.Format;
@@ -1582,6 +1605,8 @@ end;
constructor TfpgEditFloat.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
+ fDecimals := -1;
+ fShowThousand := True;
end;
{ TfpgEditCurrency }
@@ -1705,10 +1730,10 @@ end;
procedure TfpgEditCurrency.SetDecimals(AValue: integer);
begin
-if (AValue < 0) or (AValue > 4) then
- Exit; // =>
-if fDecimals <> AValue then
- fDecimals := AValue
+ if (AValue < 0) or (AValue > 4) then
+ Exit; // =>
+ if fDecimals <> AValue then
+ fDecimals := AValue
end;
procedure TfpgEditCurrency.Format;
@@ -1754,6 +1779,7 @@ constructor TfpgEditCurrency.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
fDecimals := 2;
+ fShowThousand := True;
end;