Files
lazarus-ccr/components/exctrls/source/design/exctrlsreg.pas

66 lines
1.5 KiB
ObjectPascal
Raw Normal View History

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, ExProgressBar;
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,
TProgressBarEx,
TShapeEx
]);
RegisterPropertyEditor(TypeInfo(double), TCustomFloatSISpinEditEx, '', TFloatSIPropertyEditor);
end;
end.