You've already forked lazarus-ccr
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8587 8e941d3f-bd1b-0410-a28a-d453659cc2b4
65 lines
1.4 KiB
ObjectPascal
65 lines
1.4 KiB
ObjectPascal
unit ExCtrlsReg;
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
interface
|
|
|
|
uses
|
|
Classes, SysUtils, PropEdits;
|
|
|
|
type
|
|
TFloatSIPropertyEditor = class(TFloatPropertyEditor)
|
|
public
|
|
function GetValue: ansistring; override;
|
|
procedure SetValue(const NewValue: ansistring); override;
|
|
end;
|
|
|
|
procedure Register;
|
|
|
|
|
|
implementation
|
|
|
|
{$R exctrlsreg.res}
|
|
|
|
uses
|
|
ExButtons, ExCheckCtrls, ExEditCtrls, ExCombo, ExCheckCombo, ExShape;
|
|
|
|
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', [
|
|
TButtonEx, TCheckboxEx, TRadioButtonEx, TCheckGroupEx, TRadioGroupEx,
|
|
TFloatSISpinEditEx, TCurrSpinEditEx,
|
|
TColumnComboBoxEx, TCheckComboBoxEx,
|
|
TShapeEx
|
|
]);
|
|
|
|
RegisterPropertyEditor(TypeInfo(double), TCustomFloatSISpinEditEx, '', TFloatSIPropertyEditor);
|
|
end;
|
|
|
|
end.
|
|
|