diff --git a/components/exctrls/exctrlspkg.lpk b/components/exctrls/exctrlspkg.lpk index c2d1c9a79..18596ec56 100644 --- a/components/exctrls/exctrlspkg.lpk +++ b/components/exctrls/exctrlspkg.lpk @@ -3,7 +3,6 @@ - @@ -19,7 +18,7 @@ - TRadioButton, TCheckbox, TRadioGroup and TCheckGroup: drawn by ThemeServices/Canvas, not by widgetset, button/text layout, wordwrap, user-provided check images - TColumnComboBoxEx"/> - + @@ -29,30 +28,25 @@ - - - - - - - + + - - + + - - + + - - + + - + diff --git a/components/exctrls/exctrlspkg.pas b/components/exctrls/exctrlspkg.pas index dd71f0371..6d2ab2940 100644 --- a/components/exctrls/exctrlspkg.pas +++ b/components/exctrls/exctrlspkg.pas @@ -8,16 +8,9 @@ unit ExCtrlsPkg; interface uses - ExCheckCtrls, ExEditCtrls, ExCtrlsReg, ExButtons, ExCombo, ExCheckCombo, - ExQuestionDlg, ExShape, LazarusPackageIntf; + ExCheckCtrls, ExEditCtrls, ExButtons, ExCombo, ExCheckCombo, ExQuestionDlg, + ExShape; implementation -procedure Register; -begin - RegisterUnit('ExCtrlsReg', @ExCtrlsReg.Register); -end; - -initialization - RegisterPackage('ExCtrlsPkg', @Register); end. diff --git a/components/exctrls/exctrlspkg_dsgn.lpk b/components/exctrls/exctrlspkg_dsgn.lpk new file mode 100644 index 000000000..318d3eb73 --- /dev/null +++ b/components/exctrls/exctrlspkg_dsgn.lpk @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/exctrls/exctrlspkg_dsgn.pas b/components/exctrls/exctrlspkg_dsgn.pas new file mode 100644 index 000000000..6edeed693 --- /dev/null +++ b/components/exctrls/exctrlspkg_dsgn.pas @@ -0,0 +1,22 @@ +{ This file was automatically created by Lazarus. Do not edit! + This source is only used to compile and install the package. + } + +unit exctrlspkg_dsgn; + +{$warn 5023 off : no warning about unused units} +interface + +uses + exctrlsreg, LazarusPackageIntf; + +implementation + +procedure Register; +begin + RegisterUnit('exctrlsreg', @exctrlsreg.Register); +end; + +initialization + RegisterPackage('exctrlspkg_dsgn', @Register); +end. diff --git a/components/exctrls/source/exctrlsreg.pas b/components/exctrls/source/exctrlsreg.pas index 1ba2848df..e31a895ad 100644 --- a/components/exctrls/source/exctrlsreg.pas +++ b/components/exctrls/source/exctrlsreg.pas @@ -5,18 +5,49 @@ unit ExCtrlsReg; interface uses - Classes, SysUtils; + Classes, SysUtils, PropEdits; +type + TFloatSIPropertyEditor = class(TFloatPropertyEditor) + public + function GetValue: ansistring; override; + procedure SetValue(const NewValue: ansistring); override; + end; procedure Register; + implementation -uses - ExButtons, ExCheckCtrls, ExEditCtrls, ExCombo, ExCheckCombo, ExShape; - {$R exctrlsreg.res} +uses + ExButtons, ExCheckCtrls, ExEditCtrls, ExCombo, ExCheckCombo, ExShape; //, ExImgList; + +function TFloatSIPropertyEditor.GetValue: ansistring; +begin + Result := FormatValue(GetFloatValue); +end; + +procedure TFloatSIPropertyEditor.SetValue(const NewValue: ansistring); +var + newVal: String; + prefix: TSIPrefix; + prefixStr: String; +begin + newVal := NewValue; + if TCustomFloatSISpinEditEx.EndsWithSIPrefix(newVal, prefix) then + begin + if prefix <> ONE then + begin + prefixStr := FormatFloat('0e+00', TCustomFloatSISpinEditEx.PrefixFactor(prefix)); // e.g. 'k' --> '1E+03' + Delete(prefixStr, 1, 1); // Delete the '1' from '1E+03' ... + newVal := newVal + prefixStr; // ... and add the rest to the number string + end; + end; + inherited SetValue(newVal) +end; + procedure Register; begin RegisterComponents('ExCtrls', [ @@ -25,8 +56,9 @@ begin TColumnComboBoxEx, TCheckComboBoxEx, TShapeEx ]); -end; + RegisterPropertyEditor(TypeInfo(double), TCustomFloatSISpinEditEx, '', TFloatSIPropertyEditor); +end; end. diff --git a/components/exctrls/source/exeditctrls.pas b/components/exctrls/source/exeditctrls.pas index 509d1556c..558760054 100644 --- a/components/exctrls/source/exeditctrls.pas +++ b/components/exctrls/source/exeditctrls.pas @@ -186,7 +186,6 @@ type TCustomFloatSISpinEditEx = class(TCustomFloatSpinEditEx) private - function EndsWithSIPrefix(var S: String; out APrefix: TSIPrefix): Boolean; protected {$IF LCL_FullVersion < 2010000} procedure EditKeyPress(var Key: char); override; @@ -197,6 +196,8 @@ type {$IF LCL_FullVersion >= 2010000} function KeyAllowed({%H-}Key: Char): Boolean; override; {$endif} + class function EndsWithSIPrefix(var S: String; out APrefix: TSIPrefix): Boolean; + class function PrefixFactor(APrefix: TSIPrefix): double; end; TFloatSISpinEditEx = class(TCustomFloatSISpinEditEx) @@ -539,7 +540,7 @@ end; { TCustomFloatSISpinEditEx } -function TCustomFloatSISpinEditEx.EndsWithSIPrefix(var S: String; out APrefix: TSIPrefix): Boolean; +class function TCustomFloatSISpinEditEx.EndsWithSIPrefix(var S: String; out APrefix: TSIPrefix): Boolean; var PrefixStr: String; begin @@ -562,6 +563,11 @@ begin end; {$endif} +class function TCustomFloatSISpinEditEx.PrefixFactor(APrefix: TSIPrefix): Double; +begin + Result := SIFactors[APrefix]; +end; + function TCustomFloatSISpinEditEx.TextIsNumber(const S: String; out ANumber: Double): Boolean; var ValueStr: String;