2020-05-22 08:12:36 +00:00
|
|
|
unit ExCtrlsReg;
|
|
|
|
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
2022-11-04 16:27:49 +00:00
|
|
|
Classes, SysUtils, PropEdits;
|
2020-05-22 08:12:36 +00:00
|
|
|
|
2022-11-04 16:27:49 +00:00
|
|
|
type
|
|
|
|
TFloatSIPropertyEditor = class(TFloatPropertyEditor)
|
|
|
|
public
|
|
|
|
function GetValue: ansistring; override;
|
|
|
|
procedure SetValue(const NewValue: ansistring); override;
|
|
|
|
end;
|
2022-10-01 13:32:26 +00:00
|
|
|
|
2020-05-22 08:12:36 +00:00
|
|
|
procedure Register;
|
|
|
|
|
2022-11-04 16:27:49 +00:00
|
|
|
|
2020-05-22 08:12:36 +00:00
|
|
|
implementation
|
|
|
|
|
2022-11-04 16:27:49 +00:00
|
|
|
{$R exctrlsreg.res}
|
|
|
|
|
2020-05-22 08:12:36 +00:00
|
|
|
uses
|
2022-11-05 22:35:21 +00:00
|
|
|
ExButtons, ExCheckCtrls, ExEditCtrls, ExCombo, ExCheckCombo, ExShape;
|
2020-05-22 08:12:36 +00:00
|
|
|
|
2022-11-04 16:27:49 +00:00
|
|
|
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;
|
2020-05-22 08:12:36 +00:00
|
|
|
|
|
|
|
procedure Register;
|
|
|
|
begin
|
|
|
|
RegisterComponents('ExCtrls', [
|
2020-08-16 22:56:26 +00:00
|
|
|
TButtonEx, TCheckboxEx, TRadioButtonEx, TCheckGroupEx, TRadioGroupEx,
|
2020-12-21 15:13:59 +00:00
|
|
|
TFloatSISpinEditEx, TCurrSpinEditEx,
|
2022-09-17 17:26:39 +00:00
|
|
|
TColumnComboBoxEx, TCheckComboBoxEx,
|
|
|
|
TShapeEx
|
2020-05-22 08:12:36 +00:00
|
|
|
]);
|
|
|
|
|
2022-11-04 16:27:49 +00:00
|
|
|
RegisterPropertyEditor(TypeInfo(double), TCustomFloatSISpinEditEx, '', TFloatSIPropertyEditor);
|
|
|
|
end;
|
2020-05-22 08:12:36 +00:00
|
|
|
|
|
|
|
end.
|
|
|
|
|