diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-11-12 13:40:29 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-11-12 13:40:29 +0000 |
commit | 62d59b10e9a5ad070b602ec33f2f3b748678fc04 (patch) | |
tree | 387fef8f44715366bfa0f1d28af718dc8346726c | |
parent | 3df54aadede2a405e5d4bec05e83b7e6c33893b7 (diff) | |
download | fpGUI-62d59b10e9a5ad070b602ec33f2f3b748678fc04.tar.xz |
* new fpgCharAt() function
* Renamed EditXXX's DecimalSeparator and ThousandSeparatar properties to not conflict with the global variables in SysUtils.
* Added EditCurrency, EditFloat and EditInteger to the UI Designer palette. I still have issues with TfpgChar type, so you have to use the 'unknow' memo in Object Inspector.
* Minor changes in edits demo to compile again after the above changes.
-rw-r--r-- | examples/gui/edits/edittest.lpr | 121 | ||||
-rw-r--r-- | src/corelib/fpg_stringutils.pas | 9 | ||||
-rw-r--r-- | src/gui/fpg_edit.pas | 226 | ||||
-rw-r--r-- | uidesigner/icons.inc | 313 | ||||
-rw-r--r-- | uidesigner/images/editcurrency.bmp | bin | 0 -> 1710 bytes | |||
-rw-r--r-- | uidesigner/images/editfloat.bmp | bin | 0 -> 1710 bytes | |||
-rw-r--r-- | uidesigner/images/editinteger.bmp | bin | 0 -> 1710 bytes | |||
-rw-r--r-- | uidesigner/vfdformparser.pas | 18 | ||||
-rw-r--r-- | uidesigner/vfdprops.pas | 85 | ||||
-rw-r--r-- | uidesigner/vfdwidgets.pas | 59 |
10 files changed, 694 insertions, 137 deletions
diff --git a/examples/gui/edits/edittest.lpr b/examples/gui/edits/edittest.lpr index 937a66f4..d48c09ef 100644 --- a/examples/gui/edits/edittest.lpr +++ b/examples/gui/edits/edittest.lpr @@ -16,16 +16,6 @@ type TMainForm = class(TfpgForm) private - procedure btnQuitClicked(Sender: TObject); - procedure rbClicked(Sender: TObject); - procedure lbChange(Sender: TObject); - procedure edtIntegerChange(Sender: TObject); - procedure edtFloatChange(Sender: TObject); - procedure edtCurrencyChange(Sender: TObject); - procedure chbPasswdChanged(Sender: TObject); - procedure chbSpaceChange(Sender: TObject); - procedure chbFloatDecChange(Sender: TObject); - public {@VFD_HEAD_BEGIN: MainForm} lblName1: TfpgLabel; edtText: TfpgEdit; @@ -47,6 +37,16 @@ type lbNegativeColor: TfpgColorListBox; lblNegativeColor: TfpgLabel; {@VFD_HEAD_END: MainForm} + procedure btnQuitClicked(Sender: TObject); + procedure rbClicked(Sender: TObject); + procedure lbChange(Sender: TObject); + procedure edtIntegerChange(Sender: TObject); + procedure edtFloatChange(Sender: TObject); + procedure edtCurrencyChange(Sender: TObject); + procedure chbPasswdChanged(Sender: TObject); + procedure chbSpaceChange(Sender: TObject); + procedure chbFloatDecChange(Sender: TObject); + public procedure AfterCreate; override; end; @@ -66,36 +66,36 @@ begin case (Sender as TfpgRadioButton).tag of 0: begin - edtFloat.DecimalSeparator := '.'; - edtCurrency.DecimalSeparator := '.'; + edtFloat.CustomDecimalSeparator := '.'; + edtCurrency.CustomDecimalSeparator := '.'; if chbSpace.Checked then begin - edtInteger.ThousandSeparator := ' '; - edtFloat.ThousandSeparator := ' '; - edtCurrency.ThousandSeparator := ' '; + edtInteger.CustomThousandSeparator := ' '; + edtFloat.CustomThousandSeparator := ' '; + edtCurrency.CustomThousandSeparator := ' '; end else begin - edtInteger.ThousandSeparator := ','; - edtFloat.ThousandSeparator := ','; - edtCurrency.ThousandSeparator := ','; + edtInteger.CustomThousandSeparator := ','; + edtFloat.CustomThousandSeparator := ','; + edtCurrency.CustomThousandSeparator := ','; end; end; 1: begin - edtFloat.DecimalSeparator := ','; - edtCurrency.DecimalSeparator := ','; + edtFloat.CustomDecimalSeparator := ','; + edtCurrency.CustomDecimalSeparator := ','; if chbSpace.Checked then begin - edtInteger.ThousandSeparator := ' '; - edtFloat.ThousandSeparator := ' '; - edtCurrency.ThousandSeparator := ' '; + edtInteger.CustomThousandSeparator := ' '; + edtFloat.CustomThousandSeparator := ' '; + edtCurrency.CustomThousandSeparator := ' '; end else begin - edtInteger.ThousandSeparator := '.'; - edtFloat.ThousandSeparator := '.'; - edtCurrency.ThousandSeparator := '.'; + edtInteger.CustomThousandSeparator := '.'; + edtFloat.CustomThousandSeparator := '.'; + edtCurrency.CustomThousandSeparator := '.'; end; end; end; @@ -130,16 +130,26 @@ end; procedure TMainForm.chbSpaceChange(Sender: TObject); begin if chbSpace.Checked then - begin - edtInteger.ThousandSeparator := ' '; - edtFloat.ThousandSeparator := ' '; - edtCurrency.ThousandSeparator := ' '; - end + begin + edtInteger.CustomThousandSeparator := ' '; + edtFloat.CustomThousandSeparator := ' '; + edtCurrency.CustomThousandSeparator := ' '; + end else + begin if rbPoint.Checked then - edtInteger.ThousandSeparator := ',' + begin + edtInteger.CustomThousandSeparator := ','; + edtFloat.CustomThousandSeparator := ','; + edtCurrency.CustomThousandSeparator := ','; + end else - edtInteger.ThousandSeparator := '.'; + begin + edtInteger.CustomThousandSeparator := '.'; + edtFloat.CustomThousandSeparator := '.'; + edtCurrency.CustomThousandSeparator := '.'; + end; + end; end; procedure TMainForm.chbFloatDecChange(Sender: TObject); @@ -164,6 +174,7 @@ begin Name := 'lblName1'; SetPosition(8, 8, 196, 16); FontDesc := '#Label1'; + Hint := ''; Text := 'Text Edit'; end; @@ -185,7 +196,7 @@ begin FontDesc := '#Label1'; TabOrder := 2; Text := 'Password Mode'; - OnChange :=@chbPasswdChanged; + OnChange := @chbPasswdChanged; end; lblName2 := TfpgLabel.Create(self); @@ -194,15 +205,17 @@ begin Name := 'lblName2'; SetPosition(8, 88, 80, 16); FontDesc := '#Label1'; + Hint := ''; Text := 'Integer Edit'; end; - + l_integervalue := TfpgLabel.Create(self); with l_integervalue do begin Name := 'l_integervalue'; SetPosition(90, 88, 80, 16); FontDesc := '#Label1'; + Hint := ''; Text := ''; end; @@ -212,6 +225,7 @@ begin Name := 'lblName3'; SetPosition(8, 144, 80, 16); FontDesc := '#Label1'; + Hint := ''; Text := 'Float Edit'; end; @@ -221,6 +235,7 @@ begin Name := 'l_floatvalue'; SetPosition(90, 144, 80, 16); FontDesc := '#Label1'; + Hint := ''; Text := ''; end; @@ -230,6 +245,7 @@ begin Name := 'lblName4'; SetPosition(8, 200, 80, 16); FontDesc := '#Label1'; + Hint := ''; Text := 'Currency Edit'; end; @@ -239,6 +255,7 @@ begin Name := 'l_currvalue'; SetPosition(90, 200, 80, 16); FontDesc := '#Label1'; + Hint := ''; Text := ''; end; @@ -247,9 +264,10 @@ begin begin Name := 'edtInteger'; SetPosition(24, 108, 120, 22); - ShowThousand := True; - ThousandSeparator := ','; - onChange := @edtIntegerChange; + TabOrder := 9; + FontDesc := '#Edit1'; + Value := 12345; + OnChange := @edtIntegerChange; end; edtFloat := TfpgEditFloat.Create(self); @@ -257,9 +275,10 @@ begin begin Name := 'edtFloat'; SetPosition(24, 164, 120, 22); - ShowThousand := True; - ThousandSeparator := ','; - onChange := @edtFloatChange; + TabOrder := 10; + FontDesc := '#Edit1'; + Value := 12345.1234; + OnChange := @edtFloatChange; end; edtCurrency := TfpgEditCurrency.Create(self); @@ -267,10 +286,10 @@ begin begin Name := 'edtCurrency'; SetPosition(24, 220, 120, 22); - ShowThousand := True; - ThousandSeparator := ','; - Decimals := 2; - onChange := @edtCurrencyChange; + TabOrder := 11; + FontDesc := '#Edit1'; + Value := 12345.12; + OnChange := @edtCurrencyChange; end; btnQuit := TfpgButton.Create(self); @@ -281,6 +300,7 @@ begin Anchors := [anRight,anBottom]; Text := 'Quit'; FontDesc := '#Label1'; + Hint := ''; ImageName := ''; TabOrder := 6; OnClick := @btnQuitClicked; @@ -319,20 +339,22 @@ begin Name := 'chbSpace'; SetPosition(170, 200, 200, 20); FontDesc := '#Label1'; + TabOrder := 15; Text := 'Space as ThousandSeparator'; OnChange := @chbSpaceChange; end; - - chbFloatDec := TfpgCheckBox.Create(Self); + + chbFloatDec := TfpgCheckBox.Create(self); with chbFloatDec do begin Name := 'chbFloatDec'; SetPosition(170, 220, 200, 20); FontDesc := '#Label1'; + TabOrder := 16; Text := 'Limit EditFloat to 3 decimals'; OnChange := @chbFloatDecChange; end; - + lbNegativeColor := TfpgColorListBox.Create(self); with lbNegativeColor do begin @@ -348,12 +370,13 @@ begin Name := 'lblNegativeColor'; SetPosition(196, 8, 188, 16); FontDesc := '#Label1'; + Hint := ''; Text := 'Choose color for negative num.'; end; {@VFD_BODY_END: MainForm} - if edtFloat.DecimalSeparator = '.' then + if edtFloat.CustomDecimalSeparator = '.' then rbPoint.Checked := True else rbComma.Checked := True; diff --git a/src/corelib/fpg_stringutils.pas b/src/corelib/fpg_stringutils.pas index 30ddff14..f5e6f817 100644 --- a/src/corelib/fpg_stringutils.pas +++ b/src/corelib/fpg_stringutils.pas @@ -23,7 +23,7 @@ unit fpg_stringutils; interface uses - Classes, SysUtils; + Classes, SysUtils, fpg_base; function UTF8CharacterLength(p: PChar): integer; @@ -45,6 +45,8 @@ function Pos8(const SearchForText, SearchInText: string): integer; procedure Delete8(var S: string; Index, Size: integer); procedure Insert8(const Source: string; var S: string; Index: integer); +function fpgCharAt(const s: TfpgString; Index: integer): TfpgChar; + implementation @@ -310,6 +312,11 @@ begin UTF8Insert(Source, S, Index); end; +function fpgCharAt(const s: TfpgString; Index: integer): TfpgChar; +begin + Result := UTF8Copy(s, Index, 1); +end; + end. diff --git a/src/gui/fpg_edit.pas b/src/gui/fpg_edit.pas index f69827cb..bfb23d28 100644 --- a/src/gui/fpg_edit.pas +++ b/src/gui/fpg_edit.pas @@ -170,8 +170,8 @@ type property BorderStyle; {Someone likes to use English operating system but localized decimal and thousand separators Still to implement !!} - property DecimalSeparator: TfpgChar read FDecimalseparator write SetDecimalSeparator; - property ThousandSeparator: TfpgChar read FThousandSeparator write SetThousandSeparator; + property CustomDecimalSeparator: TfpgChar read FDecimalseparator write SetDecimalSeparator; + property CustomThousandSeparator: TfpgChar read FThousandSeparator write SetThousandSeparator; property NegativeColor: TfpgColor read FNegativeColor write SetNegativeColor; property HideSelection; // property MaxLength; { probably MaxValue and MinValue } @@ -199,6 +199,7 @@ type procedure HandleKeyChar(var AText: TfpgChar; var shiftstate: TShiftState; var consumed: Boolean); override; procedure HandleSetFocus; override; procedure HandleKillFocus; override; + procedure HandlePaint; override; public constructor Create(AOwner: TComponent); override; property Alignment; @@ -207,10 +208,12 @@ type published property NegativeColor; property Value: integer read GetValue write SetValue; - property ShowThousand; + property ParentShowHint; + property ShowHint; + property ShowThousand default True; property TabOrder; property TextColor; - property ThousandSeparator; + property CustomThousandSeparator; property OnChange; property OnEnter; property OnExit; @@ -232,16 +235,24 @@ type procedure HandleKeyChar(var AText: TfpgChar; var shiftstate: TShiftState; var consumed: Boolean); override; procedure HandleSetFocus; override; procedure HandleKillFocus; override; + procedure HandlePaint; override; public constructor Create(AOwner: TComponent); override; property Alignment; property OldColor; property Text; published - property Decimals: integer read FDecimals write SetDecimals; - property DecimalSeparator; - property FixedDecimals: boolean read FFixedDecimals write SetFixedDecimals; + property Decimals: integer read FDecimals write SetDecimals default -1; + property CustomDecimalSeparator; + property FixedDecimals: boolean read FFixedDecimals write SetFixedDecimals default False; property NegativeColor; + property ShowThousand default True; + property TabOrder; + property TextColor; + property CustomThousandSeparator; + property Value: extended read GetValue write SetValue; + property ParentShowHint; + property ShowHint; property OnChange; property OnEnter; property OnExit; @@ -249,11 +260,6 @@ type property OnMouseEnter; property OnMouseExit; property OnMouseMove; - property ShowThousand; - property TabOrder; - property TextColor; - property ThousandSeparator; - property Value: extended read GetValue write SetValue; end; @@ -266,18 +272,22 @@ type procedure HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: Boolean); override; procedure HandleSetFocus; override; procedure HandleKillFocus; override; + procedure HandlePaint; override; public constructor Create(AOwner: TComponent); override; property Alignment; property OldColor; property Text; published - property Decimals: integer read FDecimals write SetDecimals; + property Decimals: integer read FDecimals write SetDecimals default 2; property NegativeColor; - property DecimalSeparator; - property ThousandSeparator; - property ShowThousand; + property CustomDecimalSeparator; + property CustomThousandSeparator; + property ShowThousand default True; property Value: Currency read GetValue write SetValue; + property ParentShowHint; + property ShowHint; + property TabOrder; property OnChange; property OnEnter; property OnExit; @@ -1440,30 +1450,36 @@ var txt, texte, decimal: string; begin if FDecimals > 0 then - if Pos(DecimalSeparator, fText) > 0 then + begin + if Pos(FDecimalSeparator, fText) > 0 then begin - txt := UTF8Copy(fText, 1, Pred(Pos(DecimalSeparator, fText))); - if UTF8Length(fText)-Pos(DecimalSeparator, fText) > FDecimals then - decimal := UTF8Copy(fText, Succ(Pos(DecimalSeparator, fText)), FDecimals) + txt := UTF8Copy(fText, 1, Pred(UTF8Pos(FDecimalSeparator, fText))); + if UTF8Length(fText)-UTF8Pos(FDecimalSeparator, fText) > FDecimals then + decimal := UTF8Copy(fText, Succ(UTF8Pos(FDecimalSeparator, fText)), FDecimals) else - decimal := UTF8Copy(fText, Succ(Pos(DecimalSeparator, fText)), UTF8Length(fText)-Pos(DecimalSeparator, fText)); + decimal := UTF8Copy(fText, Succ(UTF8Pos(FDecimalSeparator, fText)), UTF8Length(fText)-UTF8Pos(FDecimalSeparator, fText)); end else - txt := fText + txt := fText; + end else + begin if FDecimals = 0 then - if Pos(DecimalSeparator, fText) > 0 then - txt := UTF8Copy(fText, 1, Pred(Pos(DecimalSeparator, fText))) + begin + if Pos(FDecimalSeparator, fText) > 0 then + txt := UTF8Copy(fText, 1, Pred(UTF8Pos(FDecimalSeparator, fText))) else - txt := fText + txt := fText; + end else - if Pos(DecimalSeparator, fText) > 0 then + if Pos(FDecimalSeparator, fText) > 0 then begin - txt := UTF8Copy(fText, 1, Pred(Pos(DecimalSeparator, fText))); - decimal := UTF8Copy(fText, Succ(Pos(DecimalSeparator, fText)), UTF8Length(fText)-Pos(DecimalSeparator, fText)); + txt := UTF8Copy(fText, 1, Pred(UTF8Pos(FDecimalSeparator, fText))); + decimal := UTF8Copy(fText, Succ(UTF8Pos(FDecimalSeparator, fText)), UTF8Length(fText)-UTF8Pos(FDecimalSeparator, fText)); end else txt := fText; + end; if ShowThousand then begin if fText > '' then @@ -1475,7 +1491,7 @@ begin else begin for i := 1 to UTF8Length(txt) do - if txt[i] = ThousandSeparator then + if fpgCharAt(txt, i) = FThousandSeparator then begin txt:= UTF8Copy(txt, 1, i - 1) + UTF8Copy(txt, i + 1, long - i); dec(long); @@ -1484,9 +1500,9 @@ begin texte := ''; repeat if i > 0 then - if ((i mod 3) = 0) and (txt[UTF8Length(txt)-UTF8Length(texte)] <> ThousandSeparator) then + if ((i mod 3) = 0) and (fpgCharAt(txt,UTF8Length(txt)-UTF8Length(texte)) <> FThousandSeparator) then begin - texte := ThousandSeparator + texte; + texte := FThousandSeparator + texte; UTF8Insert(texte, txt, FCursorPos + 1); if fText[1] = '-' then begin @@ -1503,13 +1519,13 @@ begin end; if fText > '' then if fText[1] = '-' then - if Pos(DecimalSeparator, fText) > 0 then - fText := '-' + texte + DecimalSeparator + decimal + if UTF8Pos(FDecimalSeparator, fText) > 0 then + fText := '-' + texte + FDecimalSeparator + decimal else fText := '-' + texte else - if Pos(DecimalSeparator, fText) > 0 then - fText := texte + DecimalSeparator + decimal + if UTF8Pos(FDecimalSeparator, fText) > 0 then + fText := texte + FDecimalSeparator + decimal else fText := texte + decimal; end; @@ -1588,8 +1604,8 @@ constructor TfpgBaseNumericEdit.Create(AOwner: TComponent); begin inherited Create(AOwner); FAlignment := taRightJustify; - DecimalSeparator := SysUtils.DecimalSeparator; - ThousandSeparator := SysUtils.ThousandSeparator; + FDecimalSeparator := DecimalSeparator; + FThousandSeparator := ThousandSeparator; NegativeColor := clRed; OldColor := TextColor; end; @@ -1606,21 +1622,24 @@ begin txt := Copy(ftext, 2, Length(fText) - 1) else txt := fText; - while Pos(ThousandSeparator, txt) > 0 do - txt := Copy(txt, 1, Pred(Pos(ThousandSeparator, txt))) - +Copy(txt, Succ(Pos(ThousandSeparator, txt)), Length(txt) - Pos(ThousandSeparator, txt)); - if Copy(fText, 1, 1) = '-' then + while UTF8Pos(FThousandSeparator, txt) > 0 do + txt := UTF8Copy(txt, 1, Pred(UTF8Pos(FThousandSeparator, txt))) + +UTF8Copy(txt, Succ(UTF8Pos(FThousandSeparator, txt)), Length(txt) - UTF8Pos(FThousandSeparator, txt)); + if UTF8Copy(fText, 1, 1) = '-' then fText := '-' + txt else fText := txt; end; + if fText = '-' then begin Result := 0; - Text:= fText; + Text := fText; end else - if Text > '' then + begin + if Text <> '' then + begin try Result := StrToInt(fText); except @@ -1630,9 +1649,11 @@ begin Text := ''; Invalidate; end; - end + end; + end else Result := 0; + end; end; procedure TfpgEditInteger.SetValue(const AValue: integer); @@ -1652,7 +1673,7 @@ var n: integer; begin n := Ord(AText[1]); - if ((n >= 48) and (n <= 57) or (n = Ord('-')) and (Pos(AText[1], Self.Text) <= 0)) then + if ((n >= 48) and (n <= 57) or (AText = '-') and (UTF8Pos(AText, Text) <= 0)) then consumed := False else consumed := True; @@ -1685,6 +1706,17 @@ begin inherited HandleKillFocus; end; +procedure TfpgEditInteger.HandlePaint; +begin + inherited HandlePaint; + // To make it more visible in the UI Designer + if csDesigning in ComponentState then + begin + Canvas.SetTextColor(clInactiveWgFrame); + Canvas.DrawString(2, 3, '<Int>'); + end; +end; + constructor TfpgEditInteger.Create(AOwner: TComponent); begin inherited Create(AOwner); @@ -1700,47 +1732,53 @@ var 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); + if UTF8Pos(FDecimalSeparator, fText) > 0 then + if UTF8Length(fText)-UTF8Pos(FDecimalSeparator, fText) > FDecimals then + fText := UTF8Copy(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 UTF8Pos(FDecimalSeparator, fText) > 0 then + fText := UTF8Copy(fText, 1, UTF8Length(fText) - 1); + if ShowThousand then begin - if Copy(fText, 1, 1) = '-' then + if Copy(fText, 1, 1) = '-' then // No need for utf8 version here txt := Copy(ftext, 2, Length(fText) - 1) else txt := fText; - while Pos(ThousandSeparator, txt) > 0 do - txt := Copy(txt, 1, Pred(Pos(ThousandSeparator, txt))) - +Copy(txt, Succ(Pos(ThousandSeparator, txt)), Length(txt) - Pos(ThousandSeparator, txt)); - if Copy(fText, 1, 1) = '-' then + while UTF8Pos(FThousandSeparator, txt) > 0 do + txt := UTF8Copy(txt, 1, Pred(UTF8Pos(FThousandSeparator, txt))) + +UTF8Copy(txt, Succ(UTF8Pos(FThousandSeparator, txt)), UTF8Length(txt) - UTF8Pos(FThousandSeparator, txt)); + if Copy(fText, 1, 1) = '-' then // No need for utf8 version here fText := '-' + txt else fText := txt; end; + if fText = '-' then begin Result := 0; - Text:= fText; + Text := fText; end else - if fText > '' then - try - Result := StrToFloat(fText); - except - on E: EConvertError do - begin - Result := 0; - Text := ''; - Invalidate; - end; + begin + if fText <> '' then + begin + try + Result := StrToFloat(fText); + except + on E: EConvertError do + begin + Result := 0; + Text := ''; + Invalidate; + end; + end; { try..except } end - else - Result := 0; + else + Result := 0; + end; end; procedure TfpgEditFloat.SetValue(const AValue: extended); @@ -1777,8 +1815,8 @@ var n: integer; begin n := Ord(AText[1]); - if ((n >= 48) and (n <= 57) or (n = Ord('-')) and (Pos(AText[1], Text) <= 0)) - or ((AText = DecimalSeparator) and (Pos(AText[1], Text) <= 0)) then + if ((n >= 48) and (n <= 57) or (AText = '-') and (UTF8Pos(AText, Text) <= 0)) + or ((AText = FDecimalSeparator) and (UTF8Pos(AText, Text) <= 0)) then consumed := False else consumed := True; @@ -1791,10 +1829,12 @@ begin if GetValue = 0 then Text := '' else + begin if FFixedDecimals then Text := FloatToStrF(GetValue, ffFixed, 18, FDecimals) else Text := FloatToStr(GetValue); + end; except on E: EConvertError do Text := ''; @@ -1817,6 +1857,17 @@ begin inherited HandleKillFocus; end; +procedure TfpgEditFloat.HandlePaint; +begin + inherited HandlePaint; + // To make it more visible in the UI Designer + if csDesigning in ComponentState then + begin + Canvas.SetTextColor(clInactiveWgFrame); + Canvas.DrawString(2, 3, '<Float>'); + end; +end; + constructor TfpgEditFloat.Create(AOwner: TComponent); begin inherited Create(AOwner); @@ -1832,18 +1883,18 @@ var txt: string; begin if FDecimals > 0 then - if Pos(DecimalSeparator, fText) > 0 then - if UTF8Length(fText)-Pos(DecimalSeparator, fText) > FDecimals then - fText := Copy(fText, 1, UTF8Length(fText) - 1); + if UTF8Pos(FDecimalSeparator, fText) > 0 then + if UTF8Length(fText)-UTF8Pos(FDecimalSeparator, fText) > FDecimals then + fText := UTF8Copy(fText, 1, UTF8Length(fText) - 1); if ShowThousand then begin if Copy(fText, 1, 1) = '-' then txt := Copy(ftext, 2, Length(fText) - 1) else txt := fText; - while Pos(ThousandSeparator, txt) > 0 do - txt := Copy(txt, 1, Pred(Pos(ThousandSeparator, txt))) - +Copy(txt, Succ(Pos(ThousandSeparator, txt)), Length(txt) - Pos(ThousandSeparator, txt)); + while UTF8Pos(FThousandSeparator, txt) > 0 do + txt := UTF8Copy(txt, 1, Pred(UTF8Pos(FThousandSeparator, txt))) + +UTF8Copy(txt, Succ(UTF8Pos(FThousandSeparator, txt)), UTF8Length(txt) - UTF8Pos(FThousandSeparator, txt)); if Copy(fText, 1, 1) = '-' then fText := '-' + txt else @@ -1895,13 +1946,13 @@ begin keyReturn, keyPEnter, keyTab: if FDecimals > 0 then begin - if Pos(DecimalSeparator, fText) = 0 then + if Pos(FDecimalSeparator, fText) = 0 then begin - fText := fText + DecimalSeparator; + fText := fText + FDecimalSeparator; Inc(FCursorPos); end; - if UTF8Length(fText)-Pos(DecimalSeparator, fText) < FDecimals then - while UTF8Length(fText)-Pos(DecimalSeparator, fText) < FDecimals do + if UTF8Length(fText)-UTF8Pos(FDecimalSeparator, fText) < FDecimals then + while UTF8Length(fText)-UTF8Pos(FDecimalSeparator, fText) < FDecimals do begin fText := fText + '0'; Inc(FCursorPos); @@ -1917,8 +1968,8 @@ var n: integer; begin n := Ord(AText[1]); - if ((n >= 48) and (n <= 57) or (n = Ord('-')) and (Pos(AText[1], Text) <= 0)) - or ((AText = DecimalSeparator) and (Pos(AText[1], Text) <= 0)) then + if ((n >= 48) and (n <= 57) or (AText = '-') and (UTF8Pos(AText, Text) <= 0)) + or ((AText = FDecimalSeparator) and (UTF8Pos(AText, Text) <= 0)) then consumed := False else consumed := True; @@ -1951,6 +2002,17 @@ begin inherited HandleKillFocus; end; +procedure TfpgEditCurrency.HandlePaint; +begin + inherited HandlePaint; + // To make it more visible in the UI Designer + if csDesigning in ComponentState then + begin + Canvas.SetTextColor(clInactiveWgFrame); + Canvas.DrawString(2, 3, '<Curr>'); + end; +end; + constructor TfpgEditCurrency.Create(AOwner: TComponent); begin inherited Create(AOwner); diff --git a/uidesigner/icons.inc b/uidesigner/icons.inc index 43b6f65f..e1b34eba 100644 --- a/uidesigner/icons.inc +++ b/uidesigner/icons.inc @@ -2190,3 +2190,316 @@ Const 255,255, 0,255,255, 0,255, 0, 0, 0); +Const + stdimg_vfd_editfloat : Array[0..1709] of byte = ( + 66, 77,174, 6, 0, 0, 0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 0, + 0, 23, 0, 0, 0, 23, 0, 0, 0, 1, 0, 24, 0, 0, 0, 0, 0, + 120, 6, 0, 0,215, 13, 0, 0,215, 13, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255, 0, 0, 0,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,255, 0,255, 0, 0, 0,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255,255, 0,255,255, 0,255, 0, 0, 0,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, 0, + 0, 0,128,128,128,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255, 0, 0, 0,128,128,128, 0, 0, 0,200,208,212,200,208, + 212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212,200, + 208,212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, + 200,208,212,200,208,212,200,208,212,200,208,212,200,208,212,200,208, + 212,200,208,212,255,255,255, 0, 0, 0,128,128,128, 0, 0, 0,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,200,208,212,255,255,255, 0, 0, 0,128,128,128, + 0, 0, 0,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, 0, 0, 0, 0, 0, 0,255,255,255, + 0, 0, 0, 0, 0, 0,255,255,255,200,208,212,255,255,255, 0, 0, + 0,128,128,128, 0, 0, 0,243,231,231,159, 63, 63,130, 5, 5,157, + 60, 60,243,231,231,255,255,255,128, 0, 0,128, 0, 0,255,255,255, + 222,190,190,147, 39, 39,130, 4, 4,157, 59, 59,238,222,222,255,255, + 255, 0, 0, 0,255,255,255,255,255,255,255,255,255,200,208,212,255, + 255,255, 0, 0, 0,128,128,128, 0, 0, 0,175, 96, 96,128, 0, 0, + 211,167,167,128, 0, 0,178,101,101,255,255,255,128, 0, 0,128, 0, + 0,255,255,255,154, 54, 54,131, 8, 8,219,183,183,128, 0, 0,159, + 63, 63,255,255,255, 0, 0, 0,255,255,255,255,255,255,255,255,255, + 200,208,212,255,255,255, 0, 0, 0,128,128,128, 0, 0, 0,142, 29, + 29,128, 0, 0,247,240,240,128, 0, 0,143, 31, 31,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,253,251,251, + 128, 0, 0,130, 5, 5,255,255,255, 0, 0, 0,255,255,255,255,255, + 255,255,255,255,200,208,212,255,255,255, 0, 0, 0,128,128,128, 0, + 0, 0,129, 4, 4,128, 0, 0,254,253,253,128, 0, 0,130, 5, 5, + 255,255,255,255,255,255,255,255,255,255,255,255,152, 50, 50,203,152, + 152,228,202,202,128, 0, 0,147, 39, 39,255,255,255, 0, 0, 0,255, + 255,255,255,255,255,255,255,255,200,208,212,255,255,255, 0, 0, 0, + 128,128,128, 0, 0, 0,130, 5, 5,128, 0, 0,254,253,253,128, 0, + 0,130, 5, 5,255,255,255,255,255,255,255,255,255,255,255,255,159, + 64, 64,128, 0, 0,134, 13, 13,138, 22, 22,221,188,188,255,255,255, + 0, 0, 0,255,255,255,255,255,255,255,255,255,200,208,212,255,255, + 255, 0, 0, 0,128,128,128, 0, 0, 0,143, 31, 31,128, 0, 0,246, + 238,238,128, 0, 0,143, 31, 31,255,255,255,255,255,255,255,255,255, + 255,255,255,186,118,118,128, 0, 0,199,144,144,255,255,255,255,255, + 255,255,255,255, 0, 0, 0,255,255,255,255,255,255,255,255,255,200, + 208,212,255,255,255, 0, 0, 0,128,128,128, 0, 0, 0,178,101,101, + 128, 0, 0,210,165,165,128, 0, 0,178,102,102,255,255,255,255,255, + 255,255,255,255,255,255,255,214,173,173,128, 0, 0,170, 85, 85,255, + 255,255,255,255,255,255,255,255, 0, 0, 0,255,255,255,255,255,255, + 255,255,255,200,208,212,255,255,255, 0, 0, 0,128,128,128, 0, 0, + 0,243,231,231,158, 61, 61,130, 6, 6,158, 62, 62,244,233,233,255, + 255,255,255,255,255,255,255,255,255,255,255,241,228,228,128, 0, 0, + 128, 0, 0,128, 0, 0,128, 0, 0,255,255,255, 0, 0, 0,255,255, + 255,255,255,255,255,255,255,200,208,212,255,255,255, 0, 0, 0,128, + 128,128, 0, 0, 0,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255, 0, 0, 0, 0, 0, 0,255, + 255,255, 0, 0, 0, 0, 0, 0,255,255,255,200,208,212,255,255,255, + 0, 0, 0,128,128,128, 0, 0, 0,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,200,208, + 212,255,255,255, 0, 0, 0,128,128,128, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0,255,255,255, 0, 0, 0,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128, 0, 0, 0,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, 0, + 0, 0,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255, 0,255, 0, 0, 0,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,255, 0,255, 0, 0, 0); + +Const + stdimg_vfd_editinteger : Array[0..1709] of byte = ( + 66, 77,174, 6, 0, 0, 0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 0, + 0, 23, 0, 0, 0, 23, 0, 0, 0, 1, 0, 24, 0, 0, 0, 0, 0, + 120, 6, 0, 0,215, 13, 0, 0,215, 13, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255, 0, 0, 0,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,255, 0,255, 0, 0, 0,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255,255, 0,255,255, 0,255, 0, 0, 0,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, 0, + 0, 0,128,128,128,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255, 0, 0, 0,128,128,128, 0, 0, 0,200,208,212,200,208, + 212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212,200, + 208,212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, + 200,208,212,200,208,212,200,208,212,200,208,212,200,208,212,200,208, + 212,200,208,212,255,255,255, 0, 0, 0,128,128,128, 0, 0, 0,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,200,208,212,255,255,255, 0, 0, 0,128,128,128, + 0, 0, 0,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, 0, 0, 0, 0, 0, 0,255,255,255, + 0, 0, 0, 0, 0, 0,255,255,255,200,208,212,255,255,255, 0, 0, + 0,128,128,128, 0, 0, 0,255,255,255,255,255,255,135, 16, 16,128, + 0, 0,128, 0, 0,128, 0, 0,191,127,127,255,255,255,223,191,191, + 148, 41, 41,129, 4, 4,158, 60, 60,239,224,224,255,255,255,255,255, + 255, 0, 0, 0,255,255,255,255,255,255,255,255,255,200,208,212,255, + 255,255, 0, 0, 0,128,128,128, 0, 0, 0,255,255,255,255,255,255, + 163, 71, 71,165, 75, 75,250,246,246,255,255,255,255,255,255,255,255, + 255,155, 56, 56,132, 9, 9,220,185,185,128, 0, 0,159, 63, 63,255, + 255,255,255,255,255, 0, 0, 0,255,255,255,255,255,255,255,255,255, + 200,208,212,255,255,255, 0, 0, 0,128,128,128, 0, 0, 0,255,255, + 255,255,255,255,228,202,202,130, 6, 6,152, 50, 50,240,226,226,255, + 255,255,255,255,255,255,255,255,255,255,255,253,251,251,128, 0, 0, + 131, 6, 6,255,255,255,255,255,255, 0, 0, 0,255,255,255,255,255, + 255,255,255,255,200,208,212,255,255,255, 0, 0, 0,128,128,128, 0, + 0, 0,255,255,255,255,255,255,255,255,255,213,172,172,128, 2, 2, + 140, 26, 26,239,224,224,255,255,255,255,255,255,255,255,255,230,205, + 205,128, 0, 0,158, 62, 62,255,255,255,255,255,255, 0, 0, 0,255, + 255,255,255,255,255,255,255,255,200,208,212,255,255,255, 0, 0, 0, + 128,128,128, 0, 0, 0,255,255,255,255,255,255,255,255,255,255,255, + 255,192,129,129,128, 0, 0,164, 73, 73,255,255,255,255,255,255,255, + 255,255,134, 14, 14,141, 27, 27,239,223,223,255,255,255,255,255,255, + 0, 0, 0,255,255,255,255,255,255,255,255,255,200,208,212,255,255, + 255, 0, 0, 0,128,128,128, 0, 0, 0,255,255,255,255,255,255,255, + 255,255,255,255,255,245,236,236,128, 0, 0,131, 7, 7,255,255,255, + 255,255,255,255,255,255,231,207,207,128, 0, 0,155, 55, 55,255,255, + 255,255,255,255, 0, 0, 0,255,255,255,255,255,255,255,255,255,200, + 208,212,255,255,255, 0, 0, 0,128,128,128, 0, 0, 0,255,255,255, + 255,255,255,152, 49, 49,131, 7, 7,227,200,200,128, 0, 0,149, 44, + 44,255,255,255,162, 70, 70,134, 13, 13,227,200,200,128, 0, 0,139, + 24, 24,255,255,255,255,255,255, 0, 0, 0,255,255,255,255,255,255, + 255,255,255,200,208,212,255,255,255, 0, 0, 0,128,128,128, 0, 0, + 0,255,255,255,255,255,255,219,183,183,150, 45, 45,130, 6, 6,149, + 44, 44,230,205,205,255,255,255,223,191,191,150, 45, 45,130, 5, 5, + 148, 41, 41,223,191,191,255,255,255,255,255,255, 0, 0, 0,255,255, + 255,255,255,255,255,255,255,200,208,212,255,255,255, 0, 0, 0,128, + 128,128, 0, 0, 0,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255, 0, 0, 0, 0, 0, 0,255, + 255,255, 0, 0, 0, 0, 0, 0,255,255,255,200,208,212,255,255,255, + 0, 0, 0,128,128,128, 0, 0, 0,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,200,208, + 212,255,255,255, 0, 0, 0,128,128,128, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0,255,255,255, 0, 0, 0,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128, 0, 0, 0,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, 0, + 0, 0,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255, 0,255, 0, 0, 0,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,255, 0,255, 0, 0, 0); + +Const + stdimg_vfd_editcurrency : Array[0..1709] of byte = ( + 66, 77,174, 6, 0, 0, 0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 0, + 0, 23, 0, 0, 0, 23, 0, 0, 0, 1, 0, 24, 0, 0, 0, 0, 0, + 120, 6, 0, 0,215, 13, 0, 0,215, 13, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255, 0, 0, 0,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,255, 0,255, 0, 0, 0,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255,255, 0,255,255, 0,255, 0, 0, 0,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, 0, + 0, 0,128,128,128,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255, 0, 0, 0,128,128,128, 0, 0, 0,200,208,212,200,208, + 212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212,200, + 208,212,200,208,212,200,208,212,200,208,212,200,208,212,200,208,212, + 200,208,212,200,208,212,200,208,212,200,208,212,200,208,212,200,208, + 212,200,208,212,255,255,255, 0, 0, 0,128,128,128, 0, 0, 0,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,200,208,212,255,255,255, 0, 0, 0,128,128,128, + 0, 0, 0,255,255,255,255,255,255,255,255,255,255,255,255,128, 0, + 0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, 0, 0, 0, 0, 0, 0,255,255,255, + 0, 0, 0, 0, 0, 0,255,255,255,200,208,212,255,255,255, 0, 0, + 0,128,128,128, 0, 0, 0,255,255,255,255,255,255,221,188,188,144, + 33, 33,128, 0, 0,144, 33, 33,223,192,192,255,255,255,223,191,191, + 148, 41, 41,129, 4, 4,158, 60, 60,239,224,224,255,255,255,255,255, + 255, 0, 0, 0,255,255,255,255,255,255,255,255,255,200,208,212,255, + 255,255, 0, 0, 0,128,128,128, 0, 0, 0,255,255,255,255,255,255, + 146, 37, 37,209,163,163,128, 0, 0,223,191,191,150, 45, 45,255,255, + 255,155, 56, 56,132, 9, 9,220,185,185,128, 0, 0,159, 63, 63,255, + 255,255,255,255,255, 0, 0, 0,255,255,255,255,255,255,255,255,255, + 200,208,212,255,255,255, 0, 0, 0,128,128,128, 0, 0, 0,255,255, + 255,255,255,255,255,255,255,255,255,255,128, 0, 0,231,208,208,131, + 8, 8,255,255,255,255,255,255,255,255,255,253,251,251,128, 0, 0, + 131, 6, 6,255,255,255,255,255,255, 0, 0, 0,255,255,255,255,255, + 255,255,255,255,200,208,212,255,255,255, 0, 0, 0,128,128,128, 0, + 0, 0,255,255,255,255,255,255,252,250,250,187,119,119,128, 0, 0, + 131, 7, 7,157, 59, 59,255,255,255,255,255,255,255,255,255,230,205, + 205,128, 0, 0,158, 62, 62,255,255,255,255,255,255, 0, 0, 0,255, + 255,255,255,255,255,255,255,255,200,208,212,255,255,255, 0, 0, 0, + 128,128,128, 0, 0, 0,255,255,255,255,255,255,180,105,105,128, 0, + 0,128, 0, 0,180,106,106,242,230,230,255,255,255,255,255,255,255, + 255,255,134, 14, 14,141, 27, 27,239,223,223,255,255,255,255,255,255, + 0, 0, 0,255,255,255,255,255,255,255,255,255,200,208,212,255,255, + 255, 0, 0, 0,128,128,128, 0, 0, 0,255,255,255,255,255,255,134, + 13, 13,209,163,163,128, 0, 0,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,231,207,207,128, 0, 0,155, 55, 55,255,255, + 255,255,255,255, 0, 0, 0,255,255,255,255,255,255,255,255,255,200, + 208,212,255,255,255, 0, 0, 0,128,128,128, 0, 0, 0,255,255,255, + 255,255,255,142, 29, 29,214,173,173,128, 0, 0,199,143,143,147, 39, + 39,255,255,255,162, 70, 70,134, 13, 13,227,200,200,128, 0, 0,139, + 24, 24,255,255,255,255,255,255, 0, 0, 0,255,255,255,255,255,255, + 255,255,255,200,208,212,255,255,255, 0, 0, 0,128,128,128, 0, 0, + 0,255,255,255,255,255,255,220,186,186,142, 30, 30,128, 0, 0,145, + 36, 36,225,195,195,255,255,255,223,191,191,150, 45, 45,130, 5, 5, + 148, 41, 41,223,191,191,255,255,255,255,255,255, 0, 0, 0,255,255, + 255,255,255,255,255,255,255,200,208,212,255,255,255, 0, 0, 0,128, + 128,128, 0, 0, 0,255,255,255,255,255,255,255,255,255,255,255,255, + 128, 0, 0,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255, 0, 0, 0, 0, 0, 0,255, + 255,255, 0, 0, 0, 0, 0, 0,255,255,255,200,208,212,255,255,255, + 0, 0, 0,128,128,128, 0, 0, 0,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,200,208, + 212,255,255,255, 0, 0, 0,128,128,128, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0,255,255,255, 0, 0, 0,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, + 128,128,128,128,128,128,128,128,128,128,128,128, 0, 0, 0,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, 0, + 0, 0,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255, 0,255, 0, 0, 0,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,255, 0,255, 0, 0, 0); + + diff --git a/uidesigner/images/editcurrency.bmp b/uidesigner/images/editcurrency.bmp Binary files differnew file mode 100644 index 00000000..7731154a --- /dev/null +++ b/uidesigner/images/editcurrency.bmp diff --git a/uidesigner/images/editfloat.bmp b/uidesigner/images/editfloat.bmp Binary files differnew file mode 100644 index 00000000..8cd3fec3 --- /dev/null +++ b/uidesigner/images/editfloat.bmp diff --git a/uidesigner/images/editinteger.bmp b/uidesigner/images/editinteger.bmp Binary files differnew file mode 100644 index 00000000..42aec49e --- /dev/null +++ b/uidesigner/images/editinteger.bmp diff --git a/uidesigner/vfdformparser.pas b/uidesigner/vfdformparser.pas index 2f41c308..172de33c 100644 --- a/uidesigner/vfdformparser.pas +++ b/uidesigner/vfdformparser.pas @@ -58,6 +58,7 @@ procedure SkipSpaces(var s: string); function CheckSymbol(var s: string; const sym: string): boolean; function GetIntValue(var s: string): integer; function GetBoolValue(var s: string): boolean; +function GetFloatValue(var s: string): extended; implementation @@ -157,6 +158,23 @@ begin Delete(s, 1, 5); end; +function GetFloatValue(var s: string): extended; +var + n: integer; + ns: string; +begin + SkipSpaces(s); + ns := ''; + n := 1; + while (n <= length(s)) and (s[n] in ['0'..'9', '-', '.']) do + begin + ns := ns + s[n]; + Inc(n); + end; + Result := StrToFloatDef(ns, 0.0); + Delete(s, 1, length(ns)); +end; + function GetStringValue(var s: string): string; var n: integer; diff --git a/uidesigner/vfdprops.pas b/uidesigner/vfdprops.pas index 93c2dff5..8d52c4d9 100644 --- a/uidesigner/vfdprops.pas +++ b/uidesigner/vfdprops.pas @@ -51,6 +51,15 @@ type end; + TPropertyFloat = class(TVFDWidgetProperty) + public + function ParseSourceLine(wg: TfpgWidget; const line: string): boolean; override; + function GetPropertySource(wg: TfpgWidget; const ident: string): string; override; + function GetValueText(wg: TfpgWidget): string; override; + function CreateEditor(AOwner: TComponent): TVFDPropertyEditor; override; + end; + + TPropertyEnum = class(TVFDWidgetProperty) public function ParseSourceLine(wg: TfpgWidget; const line: string): boolean; override; @@ -85,7 +94,7 @@ type end; - TGPEType = (gptInteger, gptString); + TGPEType = (gptInteger, gptString, gptFloat); TGeneralPropertyEditor = class(TVFDPropertyEditor) @@ -104,6 +113,8 @@ type procedure StoreIntValue(wg: TfpgWidget); procedure LoadStrValue(wg: TfpgWidget); procedure StoreStrValue(wg: TfpgWidget); + procedure LoadFloatValue(wg: TfpgWidget); + procedure StoreFloatValue(wg: TfpgWidget); end; @@ -340,9 +351,11 @@ procedure TGeneralPropertyEditor.LoadValue(wg: TfpgWidget); begin case etype of gptInteger: - LoadIntValue(wg); + LoadIntValue(wg); + gptFloat: + LoadFloatValue(wg); else - LoadStrValue(wg); + LoadStrValue(wg); end; FOrigValue := edit.Text; end; @@ -368,12 +381,32 @@ begin SetStrProp(wg, prop.Name, s); end; +procedure TGeneralPropertyEditor.LoadFloatValue(wg: TfpgWidget); +begin + edit.Text := FloatToStr(GetFloatProp(wg, prop.Name)); +end; + +procedure TGeneralPropertyEditor.StoreFloatValue(wg: TfpgWidget); +var + i: extended; +begin + try + i := StrToFloat(edit.Text); + SetFloatProp(wg, Prop.Name, i); + except + // error + end; +end; + procedure TGeneralPropertyEditor.StoreValue(wg: TfpgWidget); begin case etype of - gptInteger: StoreIntValue(wg); + gptInteger: + StoreIntValue(wg); + gptFloat: + StoreFloatValue(wg); else - StoreStrValue(wg); + StoreStrValue(wg); end; end; @@ -695,5 +728,47 @@ begin SetStrProp(wg, Name, s); end; +{ TPropertyFloat } + +function TPropertyFloat.ParseSourceLine(wg: TfpgWidget; const line: string): boolean; +var + s: string; + ival: extended; +begin + s := line; + Result := False; + if UpperCase(GetIdentifier(s)) <> UpperCase(Name) then + Exit; + + Result := CheckSymbol(s, ':='); + if Result then + begin + ival := GetFloatValue(s); + Result := CheckSymbol(s, ';'); + end + else + ival := 0.0; + + if Result then + SetFloatProp(wg, Name, ival); +end; + +function TPropertyFloat.GetPropertySource(wg: TfpgWidget; const ident: string): string; +begin + Result := ident + Name + ' := ' + FloatToStr(GetFloatProp(wg, Name)) + ';' + LineEnding +end; + +function TPropertyFloat.GetValueText(wg: TfpgWidget): string; +begin + Result := FloatToStr(GetFloatProp(wg, Name)); +end; + +function TPropertyFloat.CreateEditor(AOwner: TComponent): TVFDPropertyEditor; +begin + Result := TGeneralPropertyEditor.Create(AOwner, self); + with TGeneralPropertyEditor(Result) do + etype := gptFloat; +end; + end. diff --git a/uidesigner/vfdwidgets.pas b/uidesigner/vfdwidgets.pas index 1b20f755..692de9b6 100644 --- a/uidesigner/vfdwidgets.pas +++ b/uidesigner/vfdwidgets.pas @@ -248,6 +248,21 @@ begin sizeof(stdimg_vfd_tabsheet), 0, 0); + fpgImages.AddMaskedBMP( + 'vfd.editinteger', @stdimg_vfd_editinteger, + sizeof(stdimg_vfd_editinteger), + 0, 0); + + fpgImages.AddMaskedBMP( + 'vfd.editfloat', @stdimg_vfd_editfloat, + sizeof(stdimg_vfd_editfloat), + 0, 0); + + fpgImages.AddMaskedBMP( + 'vfd.editcurrency', @stdimg_vfd_editcurrency, + sizeof(stdimg_vfd_editcurrency), + 0, 0); + end; procedure AddWidgetPosProps(wgc: TVFDWidgetClass); @@ -522,6 +537,50 @@ begin RegisterVFDWidget(wc); + // Integer Edit + wc := TVFDWidgetClass.Create(TfpgEditInteger); + wc.NameBase := 'EditInteger'; + wc.AddProperty('TabOrder', TPropertyInteger, 'The tab order'); + wc.AddProperty('FontDesc', TPropertyFontDesc, 'The font used for displaying the text'); + wc.AddProperty('ParentShowHint', TPropertyBoolean, ''); + wc.AddProperty('ShowHint', TPropertyBoolean, ''); + wc.AddProperty('ShowThousand', TPropertyBoolean, 'Show thousand separator'); +// wc.AddProperty('CustomThousandSeparator', TPropertyString, 'Thousand separator character'); + wc.AddProperty('Value', TPropertyInteger, 'Initial value'); + wc.WidgetIconName := 'vfd.editinteger'; + RegisterVFDWidget(wc); + + // Float Edit + wc := TVFDWidgetClass.Create(TfpgEditFloat); + wc.NameBase := 'EditFloat'; + wc.AddProperty('TabOrder', TPropertyInteger, 'The tab order'); + wc.AddProperty('FontDesc', TPropertyFontDesc, 'The font used for displaying the text'); + wc.AddProperty('ParentShowHint', TPropertyBoolean, ''); + wc.AddProperty('ShowHint', TPropertyBoolean, ''); + wc.AddProperty('Value', TPropertyFloat, 'Initial value'); + wc.AddProperty('ShowThousand', TPropertyBoolean, 'Show thousand separator'); + wc.AddProperty('FixedDecimals', TPropertyBoolean, ''); + wc.Addproperty('Decimals', TPropertyInteger, ''); +// wc.AddProperty('CustomDecimalSeparator', TPropertyString, 'Decimal separator character'); +// wc.AddProperty('CustomThousandSeparator', TPropertyString, 'Thousand separator character'); + wc.WidgetIconName := 'vfd.editfloat'; + RegisterVFDWidget(wc); + + // Currency Edit + wc := TVFDWidgetClass.Create(TfpgEditCurrency); + wc.NameBase := 'EditCurrency'; + wc.AddProperty('TabOrder', TPropertyInteger, 'The tab order'); + wc.AddProperty('FontDesc', TPropertyFontDesc, 'The font used for displaying the text'); + wc.AddProperty('ParentShowHint', TPropertyBoolean, ''); + wc.AddProperty('ShowHint', TPropertyBoolean, ''); + wc.AddProperty('Value', TPropertyFloat, 'Initial value'); + wc.AddProperty('ShowThousand', TPropertyBoolean, 'Show thousand separator'); + wc.Addproperty('Decimals', TPropertyInteger, ''); +// wc.AddProperty('CustomDecimalSeparator', TPropertyString, 'Decimal separator character'); +// wc.AddProperty('CustomThousandSeparator', TPropertyString, 'Thousand separator character'); + wc.WidgetIconName := 'vfd.editcurrency'; + RegisterVFDWidget(wc); + // Other - do not delete!!! this should be the last... wc := TVFDWidgetClass.Create(TOtherWidget); wc.NameBase := 'Custom'; |