You've already forked lazarus-ccr
ExCtrls: Split off designtime package. Add float property editor for usage in TFloatSISpinEditEx.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8586 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -3,7 +3,6 @@
|
||||
<Package Version="5">
|
||||
<PathDelim Value="\"/>
|
||||
<Name Value="ExCtrlsPkg"/>
|
||||
<Type Value="RunAndDesignTime"/>
|
||||
<Author Value="Lazarus team"/>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
@ -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"/>
|
||||
<License Value="LGPL with linking exception (like Lazarus LCL)."/>
|
||||
<Files Count="8">
|
||||
<Files Count="7">
|
||||
<Item1>
|
||||
<Filename Value="source\excheckctrls.pas"/>
|
||||
<UnitName Value="ExCheckCtrls"/>
|
||||
@ -29,30 +28,25 @@
|
||||
<UnitName Value="ExEditCtrls"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Filename Value="source\exctrlsreg.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
<UnitName Value="ExCtrlsReg"/>
|
||||
</Item3>
|
||||
<Item4>
|
||||
<Filename Value="source\exbuttons.pas"/>
|
||||
<UnitName Value="ExButtons"/>
|
||||
</Item4>
|
||||
<Item5>
|
||||
</Item3>
|
||||
<Item4>
|
||||
<Filename Value="source\excombo.pas"/>
|
||||
<UnitName Value="ExCombo"/>
|
||||
</Item5>
|
||||
<Item6>
|
||||
</Item4>
|
||||
<Item5>
|
||||
<Filename Value="source\excheckcombo.pas"/>
|
||||
<UnitName Value="ExCheckCombo"/>
|
||||
</Item6>
|
||||
<Item7>
|
||||
</Item5>
|
||||
<Item6>
|
||||
<Filename Value="source\exquestiondlg.pas"/>
|
||||
<UnitName Value="ExQuestionDlg"/>
|
||||
</Item7>
|
||||
<Item8>
|
||||
</Item6>
|
||||
<Item7>
|
||||
<Filename Value="source\exshape.pas"/>
|
||||
<UnitName Value="ExShape"/>
|
||||
</Item8>
|
||||
</Item7>
|
||||
</Files>
|
||||
<CompatibilityMode Value="True"/>
|
||||
<LazDoc Paths="fpdoc"/>
|
||||
|
@ -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.
|
||||
|
46
components/exctrls/exctrlspkg_dsgn.lpk
Normal file
46
components/exctrls/exctrlspkg_dsgn.lpk
Normal file
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<Package Version="5">
|
||||
<PathDelim Value="\"/>
|
||||
<Name Value="exctrlspkg_dsgn"/>
|
||||
<Type Value="DesignTime"/>
|
||||
<Author Value="Lazarus team"/>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="source"/>
|
||||
<OtherUnitFiles Value="source"/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
</CompilerOptions>
|
||||
<Description Value="Designtime package for the extended standard controls (ExCtrls) runtime package
|
||||
"/>
|
||||
<License Value="LGPL with linking exception (like Lazarus LCL)."/>
|
||||
<Files>
|
||||
<Item>
|
||||
<Filename Value="source\exctrlsreg.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
<UnitName Value="exctrlsreg"/>
|
||||
</Item>
|
||||
</Files>
|
||||
<RequiredPkgs>
|
||||
<Item>
|
||||
<PackageName Value="ExCtrlsPkg"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<PackageName Value="IDEIntf"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<PackageName Value="FCL"/>
|
||||
</Item>
|
||||
</RequiredPkgs>
|
||||
<UsageOptions>
|
||||
<UnitPath Value="$(PkgOutDir)"/>
|
||||
</UsageOptions>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<UseFileFilters Value="True"/>
|
||||
</PublishOptions>
|
||||
</Package>
|
||||
</CONFIG>
|
22
components/exctrls/exctrlspkg_dsgn.pas
Normal file
22
components/exctrls/exctrlspkg_dsgn.pas
Normal file
@ -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.
|
@ -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.
|
||||
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user