T(Float)SpinEditEx: Add property Orientation for horizontal arrangement of spin buttons.

This commit is contained in:
wp_xyz 2023-01-20 22:11:06 +01:00
parent 61618c1b9f
commit 117df60bf4
2 changed files with 25 additions and 0 deletions

View File

@ -323,6 +323,11 @@ begin
Result := FNullValue;
end;
function TSpinEditExBase.GetOrientation: TUDOrientation;
begin
Result := UpDown.Orientation;
end;
function TSpinEditExBase.GetUpDown: TUpDown;
begin
Result := TUpDown(Buddy);
@ -335,6 +340,20 @@ begin
UpdateControl;
end;
procedure TSpinEditExBase.SetOrientation(AValue: TUDOrientation);
var
w: Integer;
begin
if GetOrientation = AValue then
exit;
w := UpDown.Width;
UpDown.Orientation := AValue;
case GetOrientation of
udVertical: UpDown.Width := w div 2;
udHorizontal: UpDown.Width := w * 2;
end;
end;
constructor TSpinEditExBase.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);

View File

@ -112,6 +112,7 @@ type
FMustSetModifiedToTrueInOnChange: Boolean;
FNullValue: T;
FNullValueBehaviour: TNullValueBehaviour;
FOrientation: TUDOrientation;
FValue: T;
FUpdatePending: Boolean;
FSettingValue: Boolean;
@ -119,6 +120,7 @@ type
procedure SetMinRepeatValue(AValue: Byte);
procedure SpinUpDown(Up: Boolean);
function GetNullValue: T;
function GetOrientation: TUDOrientation;
function GetUpDown: TUpDown;
function GetValue: T;
function IncrementStored: Boolean;
@ -126,6 +128,7 @@ type
function IsOutOfLimits(AValue: T): Boolean;
function MaxValueStored: Boolean;
function MinValueStored: Boolean;
procedure SetOrientation(AValue: TUDOrientation);
procedure UpdateControl;
procedure UpDownChangingEx(Sender: TObject; var {%H-}AllowChange: Boolean;
{%H-}NewValue: SmallInt; Direction: TUpDownDirection);
@ -161,6 +164,7 @@ type
property UpDown: TUpDown read GetUpDown;
property UpDownVisible: Boolean read GetBuddyVisible write SetBuddyVisible default True;
property MinRepeatValue: Byte read FMinRepeatValue write SetMinRepeatValue default DefMinRepeatValue;
property Orientation: TUDOrientation read GetOrientation write SetOrientation default udVertical;
public
constructor Create(TheOwner: TComponent); override;
function GetLimitedValue(const AValue: T): T; virtual;
@ -301,6 +305,7 @@ type
property MinRepeatValue;
property NullValue;
property NullValueBehaviour;
property Orientation;
property Spacing;
property UpDownVisible;
property Value;
@ -406,6 +411,7 @@ type
property MinRepeatValue;
property NullValue;
property NullValueBehaviour;
property Orientation;
property Spacing;
property ThousandSeparator;
property UpDownVisible;