mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-05 08:00:45 +02:00
LCL: float spin (ex): fix streaming of Increment and MaxValue properties in FPC trunk. Issue #33567
git-svn-id: trunk@57605 -
This commit is contained in:
parent
067144af2d
commit
81bee86e42
@ -192,6 +192,11 @@ begin
|
|||||||
if FUpdatePending then UpdateControl;
|
if FUpdatePending then UpdateControl;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TSpinEditExBase.MaxValueStored: Boolean;
|
||||||
|
begin
|
||||||
|
Result := not SameValue(FMaxValue, DefMaxValue);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TSpinEditExBase.EditMouseWheelUp(Shift: TShiftState;
|
procedure TSpinEditExBase.EditMouseWheelUp(Shift: TShiftState;
|
||||||
MousePos: TPoint; var Handled: Boolean);
|
MousePos: TPoint; var Handled: Boolean);
|
||||||
@ -239,6 +244,11 @@ begin
|
|||||||
Result := FValue;
|
Result := FValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TSpinEditExBase.IncrementStored: Boolean;
|
||||||
|
begin
|
||||||
|
Result := not SameValue(FIncrement, DefIncrement);
|
||||||
|
end;
|
||||||
|
|
||||||
function TSpinEditExBase.IsLimited: Boolean;
|
function TSpinEditExBase.IsLimited: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := MaxValue > MinValue;
|
Result := MaxValue > MinValue;
|
||||||
@ -307,14 +317,12 @@ begin
|
|||||||
inherited Create(TheOwner);
|
inherited Create(TheOwner);
|
||||||
|
|
||||||
FArrowKeys := True;
|
FArrowKeys := True;
|
||||||
FIncrement := 1;
|
FIncrement := DefIncrement;
|
||||||
FValue := 0;
|
FMaxValue := DefMaxValue;
|
||||||
FMinValue := 0;
|
|
||||||
FMaxValue := 100;
|
|
||||||
FUpdatePending := True;
|
FUpdatePending := True;
|
||||||
FSettingValue := False;
|
FSettingValue := False;
|
||||||
FNullValueBehaviour := nvbMinValue;
|
FNullValueBehaviour := nvbMinValue;
|
||||||
FMinRepeatValue := 100;
|
FMinRepeatValue := DefMinRepeatValue;
|
||||||
|
|
||||||
Edit.Alignment := taRightJustify;
|
Edit.Alignment := taRightJustify;
|
||||||
|
|
||||||
@ -465,8 +473,8 @@ constructor TCustomFloatSpinEditEx.Create(TheOwner: TComponent);
|
|||||||
begin
|
begin
|
||||||
inherited Create(TheOwner);
|
inherited Create(TheOwner);
|
||||||
FFS := DefaultFormatSettings;
|
FFS := DefaultFormatSettings;
|
||||||
FFS.DecimalSeparator := '.';
|
FFS.DecimalSeparator := DefDecimalSeparator;
|
||||||
FDecimals := 2;
|
FDecimals := DefDecimals;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -97,6 +97,10 @@ type
|
|||||||
{ TSpinEditExBase }
|
{ TSpinEditExBase }
|
||||||
|
|
||||||
generic TSpinEditExBase<T> = class(TCustomAbstractGroupedEdit)
|
generic TSpinEditExBase<T> = class(TCustomAbstractGroupedEdit)
|
||||||
|
private const
|
||||||
|
DefIncrement = 1;
|
||||||
|
DefMaxValue = 100;
|
||||||
|
DefMinRepeatValue = 100;
|
||||||
private
|
private
|
||||||
FArrowKeys: Boolean;
|
FArrowKeys: Boolean;
|
||||||
FIncrement: T;
|
FIncrement: T;
|
||||||
@ -121,6 +125,8 @@ type
|
|||||||
procedure UpDownChangingEx(Sender: TObject; var {%H-}AllowChange: Boolean;
|
procedure UpDownChangingEx(Sender: TObject; var {%H-}AllowChange: Boolean;
|
||||||
{%H-}NewValue: SmallInt; Direction: TUpDownDirection);
|
{%H-}NewValue: SmallInt; Direction: TUpDownDirection);
|
||||||
procedure UpDownClick(Sender: TObject; {%H-}Button: TUDBtnType);
|
procedure UpDownClick(Sender: TObject; {%H-}Button: TUDBtnType);
|
||||||
|
function IncrementStored: Boolean;
|
||||||
|
function MaxValueStored: Boolean;
|
||||||
protected
|
protected
|
||||||
function GetBuddyClassType: TControlClass; override;
|
function GetBuddyClassType: TControlClass; override;
|
||||||
procedure DoEnter; override;
|
procedure DoEnter; override;
|
||||||
@ -145,7 +151,7 @@ type
|
|||||||
property ArrowKeys: Boolean read FArrowKeys write FArrowKeys default True;
|
property ArrowKeys: Boolean read FArrowKeys write FArrowKeys default True;
|
||||||
property Edit: TGEEdit read GetEdit;
|
property Edit: TGEEdit read GetEdit;
|
||||||
property UpDown: TUpDown read GetUpDown;
|
property UpDown: TUpDown read GetUpDown;
|
||||||
property MinRepeatValue: Byte read FMinRepeatValue write SetMinRepeatValue default 100;
|
property MinRepeatValue: Byte read FMinRepeatValue write SetMinRepeatValue default DefMinRepeatValue;
|
||||||
public
|
public
|
||||||
constructor Create(TheOwner: TComponent); override;
|
constructor Create(TheOwner: TComponent); override;
|
||||||
function GetLimitedValue(const AValue: T): T; virtual;
|
function GetLimitedValue(const AValue: T): T; virtual;
|
||||||
@ -153,9 +159,9 @@ type
|
|||||||
function StrToValue(const S: String): T; virtual; abstract;
|
function StrToValue(const S: String): T; virtual; abstract;
|
||||||
procedure EditEditingDone; override;
|
procedure EditEditingDone; override;
|
||||||
public
|
public
|
||||||
property Increment: T read FIncrement write SetIncrement;
|
property Increment: T read FIncrement write SetIncrement stored IncrementStored nodefault;
|
||||||
property MinValue: T read FMinValue write SetMinValue;
|
property MinValue: T read FMinValue write SetMinValue;
|
||||||
property MaxValue: T read FMaxValue write SetMaxValue;
|
property MaxValue: T read FMaxValue write SetMaxValue stored MaxValueStored nodefault;
|
||||||
property NullValue: T read GetNullValue write SetNullValue;
|
property NullValue: T read GetNullValue write SetNullValue;
|
||||||
property NullValueBehaviour: TNullValueBehaviour read FNullValueBehaviour write FNullValueBehaviour default nvbMinValue;
|
property NullValueBehaviour: TNullValueBehaviour read FNullValueBehaviour write FNullValueBehaviour default nvbMinValue;
|
||||||
property Value: T read GetValue write SetValue;
|
property Value: T read GetValue write SetValue;
|
||||||
@ -164,6 +170,9 @@ type
|
|||||||
{ TCustomFloatSpinEditEx }
|
{ TCustomFloatSpinEditEx }
|
||||||
|
|
||||||
TCustomFloatSpinEditEx = class(specialize TSpinEditExBase<Double>)
|
TCustomFloatSpinEditEx = class(specialize TSpinEditExBase<Double>)
|
||||||
|
private const
|
||||||
|
DefDecimals = 2;
|
||||||
|
DefDecimalSeparator = '.';
|
||||||
private
|
private
|
||||||
FDecimals: Integer;
|
FDecimals: Integer;
|
||||||
FFS: TFormatSettings;
|
FFS: TFormatSettings;
|
||||||
@ -179,8 +188,8 @@ type
|
|||||||
function ValueToStr(const AValue: Double): String; override;
|
function ValueToStr(const AValue: Double): String; override;
|
||||||
function StrToValue(const S: String): Double; override;
|
function StrToValue(const S: String): Double; override;
|
||||||
constructor Create(TheOwner: TComponent); override;
|
constructor Create(TheOwner: TComponent); override;
|
||||||
property DecimalSeparator: Char read GetDecimalSeparator write SetDecimalSeparator default '.';
|
property DecimalSeparator: Char read GetDecimalSeparator write SetDecimalSeparator default DefDecimalSeparator;
|
||||||
property DecimalPlaces: Integer read FDecimals write SetDecimals default 2;
|
property DecimalPlaces: Integer read FDecimals write SetDecimals default DefDecimals;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,6 +101,11 @@ begin
|
|||||||
if FUpdatePending then UpdateControl;
|
if FUpdatePending then UpdateControl;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCustomFloatSpinEdit.MaxValueStored: Boolean;
|
||||||
|
begin
|
||||||
|
Result := not SameValue(FMaxValue, DefMaxValue);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomFloatSpinEdit.KeyPress(var Key: char);
|
procedure TCustomFloatSpinEdit.KeyPress(var Key: char);
|
||||||
{Disallow any key that is not a digit, decimalseparator, + or -
|
{Disallow any key that is not a digit, decimalseparator, + or -
|
||||||
For ease of use translate any decimalpoint or comma to DecimalSeparator
|
For ease of use translate any decimalpoint or comma to DecimalSeparator
|
||||||
@ -149,6 +154,11 @@ begin
|
|||||||
Result := FValue;
|
Result := FValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCustomFloatSpinEdit.IncrementStored: Boolean;
|
||||||
|
begin
|
||||||
|
Result := not SameValue(FIncrement, DefIncrement);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomFloatSpinEdit.SetDecimals(ADecimals: Integer);
|
procedure TCustomFloatSpinEdit.SetDecimals(ADecimals: Integer);
|
||||||
begin
|
begin
|
||||||
if FDecimals = ADecimals then Exit;
|
if FDecimals = ADecimals then Exit;
|
||||||
@ -161,11 +171,9 @@ begin
|
|||||||
inherited Create(TheOwner);
|
inherited Create(TheOwner);
|
||||||
FCompStyle := csSpinEdit;
|
FCompStyle := csSpinEdit;
|
||||||
|
|
||||||
FIncrement := 1;
|
FIncrement := DefIncrement;
|
||||||
FDecimals := 2;
|
FDecimals := DefDecimals;
|
||||||
FValue := 0;
|
FMaxValue := DefMaxValue;
|
||||||
FMinValue := 0;
|
|
||||||
FMaxValue := 100;
|
|
||||||
FUpdatePending := True;
|
FUpdatePending := True;
|
||||||
FValueChanged := True;
|
FValueChanged := True;
|
||||||
|
|
||||||
|
14
lcl/spin.pp
14
lcl/spin.pp
@ -24,12 +24,16 @@ unit Spin;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Types, Classes, Controls, SysUtils, LCLType, LCLProc, ClipBrd, StdCtrls;
|
Types, Classes, Controls, SysUtils, LCLType, LCLProc, StdCtrls, Math;
|
||||||
|
|
||||||
type
|
type
|
||||||
{ TCustomFloatSpinEdit }
|
{ TCustomFloatSpinEdit }
|
||||||
|
|
||||||
TCustomFloatSpinEdit = class(TCustomEdit)
|
TCustomFloatSpinEdit = class(TCustomEdit)
|
||||||
|
private const
|
||||||
|
DefIncrement = 1;
|
||||||
|
DefDecimals = 2;
|
||||||
|
DefMaxValue = 100;
|
||||||
private
|
private
|
||||||
FIncrement: Double;
|
FIncrement: Double;
|
||||||
FDecimals: Integer;
|
FDecimals: Integer;
|
||||||
@ -41,6 +45,8 @@ type
|
|||||||
FValueChanged: Boolean;
|
FValueChanged: Boolean;
|
||||||
function GetValue: Double;
|
function GetValue: Double;
|
||||||
procedure UpdateControl;
|
procedure UpdateControl;
|
||||||
|
function MaxValueStored: Boolean;
|
||||||
|
function IncrementStored: Boolean;
|
||||||
protected
|
protected
|
||||||
class procedure WSRegisterClass; override;
|
class procedure WSRegisterClass; override;
|
||||||
function RealGetText: TCaption; override;
|
function RealGetText: TCaption; override;
|
||||||
@ -63,10 +69,10 @@ type
|
|||||||
function ValueToStr(const AValue: Double): String; virtual;
|
function ValueToStr(const AValue: Double): String; virtual;
|
||||||
function StrToValue(const S: String): Double; virtual;
|
function StrToValue(const S: String): Double; virtual;
|
||||||
public
|
public
|
||||||
property DecimalPlaces: Integer read FDecimals write SetDecimals default 2;
|
property DecimalPlaces: Integer read FDecimals write SetDecimals default DefDecimals;
|
||||||
property Increment: Double read FIncrement write SetIncrement;
|
property Increment: Double read FIncrement write SetIncrement stored IncrementStored nodefault;
|
||||||
property MinValue: Double read FMinValue write SetMinValue;
|
property MinValue: Double read FMinValue write SetMinValue;
|
||||||
property MaxValue: Double read FMaxValue write SetMaxValue;
|
property MaxValue: Double read FMaxValue write SetMaxValue stored MaxValueStored nodefault;
|
||||||
property Value: Double read GetValue write SetValue;
|
property Value: Double read GetValue write SetValue;
|
||||||
property ValueEmpty: Boolean read FValueEmpty write SetValueEmpty default False;
|
property ValueEmpty: Boolean read FValueEmpty write SetValueEmpty default False;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user