mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
ADD: TKASButtonPanel - SameWidth and SameHeight properties
(cherry picked from commit 0bcb9b1d7c)
This commit is contained in:
parent
5220e14f81
commit
075bb220bc
1 changed files with 20 additions and 5 deletions
|
|
@ -12,9 +12,17 @@ type
|
|||
{ TKASButtonPanel }
|
||||
|
||||
TKASButtonPanel = class(TPanel)
|
||||
private
|
||||
FSameWidth: Boolean;
|
||||
FSameHeight: Boolean;
|
||||
protected
|
||||
procedure ButtonsAutoSize;
|
||||
procedure DoAutoSize; override;
|
||||
public
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
published
|
||||
property SameWidth: Boolean read FSameWidth write FSameWidth default True;
|
||||
property SameHeight: Boolean read FSameHeight write FSameHeight default True;
|
||||
end;
|
||||
|
||||
procedure Register;
|
||||
|
|
@ -44,8 +52,8 @@ begin
|
|||
AControl:= Controls[Index];
|
||||
if AControl is TCustomButton then
|
||||
begin
|
||||
if AControl.Width > AMaxWidth then AMaxWidth:= AControl.Width;
|
||||
if AControl.Height > AMaxHeight then AMaxHeight:= AControl.Height;
|
||||
if FSameWidth and (AControl.Width > AMaxWidth) then AMaxWidth:= AControl.Width;
|
||||
if FSameHeight and (AControl.Height > AMaxHeight) then AMaxHeight:= AControl.Height;
|
||||
end;
|
||||
end;
|
||||
for Index:= 0 to ControlCount - 1 do
|
||||
|
|
@ -53,8 +61,8 @@ begin
|
|||
AControl:= Controls[Index];
|
||||
if AControl is TCustomButton then
|
||||
begin
|
||||
AControl.Constraints.MinWidth:= AMaxWidth;
|
||||
AControl.Constraints.MinHeight:= AMaxHeight;
|
||||
if FSameWidth then AControl.Constraints.MinWidth:= AMaxWidth;
|
||||
if FSameHeight then AControl.Constraints.MinHeight:= AMaxHeight;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
|
@ -62,7 +70,14 @@ end;
|
|||
procedure TKASButtonPanel.DoAutoSize;
|
||||
begin
|
||||
inherited DoAutoSize;
|
||||
if AutoSize then ButtonsAutosize;
|
||||
if AutoSize and (FSameWidth or FSameHeight) then ButtonsAutosize;
|
||||
end;
|
||||
|
||||
constructor TKASButtonPanel.Create(TheOwner: TComponent);
|
||||
begin
|
||||
FSameWidth:= True;
|
||||
FSameHeight:= True;
|
||||
inherited Create(TheOwner);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue