mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-08 07:55:59 +02:00
LCL: TToolBar: implemented simple heuristic for preferredheight from Paul, and calculating NewWidth,NewHeight of WrapButtons
git-svn-id: trunk@12774 -
This commit is contained in:
parent
9e4a77e06f
commit
5af932d6f0
@ -1491,6 +1491,8 @@ type
|
|||||||
procedure AdjustClientRect(var ARect: TRect); override;
|
procedure AdjustClientRect(var ARect: TRect); override;
|
||||||
class function GetControlClassDefaultSize: TPoint; override;
|
class function GetControlClassDefaultSize: TPoint; override;
|
||||||
function CanAutoSize(var NewWidth, NewHeight: Integer): Boolean; override;
|
function CanAutoSize(var NewWidth, NewHeight: Integer): Boolean; override;
|
||||||
|
procedure CalculatePreferredSize(var PreferredWidth,
|
||||||
|
PreferredHeight: integer; WithThemeSpace: Boolean); override;
|
||||||
function CheckMenuDropdown(Button: TToolButton): Boolean; dynamic;
|
function CheckMenuDropdown(Button: TToolButton): Boolean; dynamic;
|
||||||
procedure ClickButton(Button: TToolButton); dynamic;
|
procedure ClickButton(Button: TToolButton); dynamic;
|
||||||
procedure CreateParams(var Params: TCreateParams); override;
|
procedure CreateParams(var Params: TCreateParams); override;
|
||||||
|
@ -394,6 +394,19 @@ begin
|
|||||||
Result := WrapButtons(NewWidth, NewHeight);
|
Result := WrapButtons(NewWidth, NewHeight);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TToolBar.CalculatePreferredSize(var PreferredWidth,
|
||||||
|
PreferredHeight: integer; WithThemeSpace: Boolean);
|
||||||
|
var
|
||||||
|
ARect, Adjusted: TRect;
|
||||||
|
begin
|
||||||
|
PreferredWidth := 0;
|
||||||
|
PreferredHeight := ButtonHeight;
|
||||||
|
ARect := ClientRect;
|
||||||
|
Adjusted := ARect;
|
||||||
|
AdjustClientRect(Adjusted);
|
||||||
|
inc(PreferredHeight, (Adjusted.Top - ARect.Top) - (Adjusted.Bottom - ARect.Bottom));
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
function TToolBar.WrapButtons(var NewWidth, NewHeight: Integer): Boolean;
|
function TToolBar.WrapButtons(var NewWidth, NewHeight: Integer): Boolean;
|
||||||
|
|
||||||
@ -406,7 +419,6 @@ end;
|
|||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
function TToolBar.WrapButtons(var NewWidth, NewHeight: Integer): Boolean;
|
function TToolBar.WrapButtons(var NewWidth, NewHeight: Integer): Boolean;
|
||||||
var
|
var
|
||||||
i: Integer;
|
|
||||||
ARect: TRect;
|
ARect: TRect;
|
||||||
x: Integer;
|
x: Integer;
|
||||||
y: Integer;
|
y: Integer;
|
||||||
@ -471,6 +483,10 @@ var
|
|||||||
until false;
|
until false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
CurClientRect: TRect;
|
||||||
|
AdjustClientFrame: TRect;
|
||||||
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
//DebugLn('WrapButtons ');
|
//DebugLn('WrapButtons ');
|
||||||
Result:=true;
|
Result:=true;
|
||||||
@ -493,11 +509,16 @@ begin
|
|||||||
OrderedControls.Sort(TListSortCompare(@CompareToolBarControl));
|
OrderedControls.Sort(TListSortCompare(@CompareToolBarControl));
|
||||||
|
|
||||||
// position OrderedControls
|
// position OrderedControls
|
||||||
ARect:=ClientRect;
|
CurClientRect:=ClientRect;
|
||||||
|
ARect:=CurClientRect;
|
||||||
AdjustClientRect(ARect);
|
AdjustClientRect(ARect);
|
||||||
|
AdjustClientFrame.Left:=ARect.Left-CurClientRect.Left;
|
||||||
|
AdjustClientFrame.Top:=ARect.Top-CurClientRect.Top;
|
||||||
|
AdjustClientFrame.Right:=CurClientRect.Right-ARect.Right;
|
||||||
|
AdjustClientFrame.Bottom:=CurClientRect.Bottom-ARect.Bottom;
|
||||||
//DebugLn(['TToolBar.WrapButtons ',DbgSName(Self),' ARect=',dbgs(ARect)]);
|
//DebugLn(['TToolBar.WrapButtons ',DbgSName(Self),' ARect=',dbgs(ARect)]);
|
||||||
// important: top, left button must start in the AdjustClientRect top, left
|
// important: top, left button must start in the AdjustClientRect top, left
|
||||||
// other Toolbar.AutoSize=true will create an endless loop
|
// otherwise Toolbar.AutoSize=true will create an endless loop
|
||||||
StartX:=ARect.Left;
|
StartX:=ARect.Left;
|
||||||
x:=StartX;
|
x:=StartX;
|
||||||
y:=ARect.Top;
|
y:=ARect.Top;
|
||||||
@ -516,13 +537,22 @@ begin
|
|||||||
w:=NewControlWidth;
|
w:=NewControlWidth;
|
||||||
h:=ButtonHeight;
|
h:=ButtonHeight;
|
||||||
end;
|
end;
|
||||||
|
w:=CurControl.Constraints.MinMaxWidth(w);
|
||||||
|
h:=CurControl.Constraints.MinMaxWidth(h);
|
||||||
if (CurControl.Left<>x) or (CurControl.Top<>y)
|
if (CurControl.Left<>x) or (CurControl.Top<>y)
|
||||||
or (CurControl.Width<>w) or (CurControl.Height<>h) then begin
|
or (CurControl.Width<>w) or (CurControl.Height<>h) then begin
|
||||||
//DebugLn(['TToolBar.WrapButtons moving child: ',DbgSName(CurControl),' Old=',dbgs(CurControl.BoundsRect),' New=',dbgs(Bounds(x,y,w,h))]);
|
//DebugLn(['TToolBar.WrapButtons moving child: ',DbgSName(CurControl),' Old=',dbgs(CurControl.BoundsRect),' New=',dbgs(Bounds(x,y,w,h))]);
|
||||||
CurControl.SetBoundsKeepBase(x,y,w,h);
|
CurControl.SetBoundsKeepBase(x,y,w,h);
|
||||||
end;
|
end;
|
||||||
inc(x,CurControl.Width);
|
|
||||||
|
|
||||||
|
// adjust NewWidth, NewHeight
|
||||||
|
NewWidth:=Max(NewWidth,
|
||||||
|
CurControl.Left+CurControl.Width+AdjustClientFrame.Right);
|
||||||
|
NewHeight:=Max(NewHeight,
|
||||||
|
CurControl.Top+CurControl.Height+AdjustClientFrame.Bottom);
|
||||||
|
|
||||||
|
// step to next position
|
||||||
|
inc(x,w);
|
||||||
if (not Wrapable) and (CurControl is TToolButton)
|
if (not Wrapable) and (CurControl is TToolButton)
|
||||||
and (TToolButton(CurControl).Wrap) then begin
|
and (TToolButton(CurControl).Wrap) then begin
|
||||||
// user forced wrap -> start new line
|
// user forced wrap -> start new line
|
||||||
|
@ -78,7 +78,7 @@ var
|
|||||||
ARect: TRect;
|
ARect: TRect;
|
||||||
begin
|
begin
|
||||||
FEdgeBorderType := 0;
|
FEdgeBorderType := 0;
|
||||||
if (ebTOP in FEdgeBorders) then
|
if (ebTop in FEdgeBorders) then
|
||||||
FEdgeBorderType := FEdgeBorderType or longint(BF_TOP);
|
FEdgeBorderType := FEdgeBorderType or longint(BF_TOP);
|
||||||
if (ebBottom in FEdgeBorders) then
|
if (ebBottom in FEdgeBorders) then
|
||||||
FEdgeBorderType := FEdgeBorderType or longint(BF_BOTTOM);
|
FEdgeBorderType := FEdgeBorderType or longint(BF_BOTTOM);
|
||||||
|
@ -67,9 +67,7 @@ CompilerRelease=`cat $VersionFile | grep ' *release_nr *=.*;' | sed -e 's/[^0-9]
|
|||||||
CompilerPatch=`cat $VersionFile | grep ' *patch_nr *=.*;' | sed -e 's/[^0-9]//g'`
|
CompilerPatch=`cat $VersionFile | grep ' *patch_nr *=.*;' | sed -e 's/[^0-9]//g'`
|
||||||
CompilerVersionStr="$CompilerVersion.$CompilerRelease.$CompilerPatch"
|
CompilerVersionStr="$CompilerVersion.$CompilerRelease.$CompilerPatch"
|
||||||
FPCVersion="$CompilerVersion.$CompilerRelease"
|
FPCVersion="$CompilerVersion.$CompilerRelease"
|
||||||
if [ "$CompilerPatch" != "0" ]; then
|
FPCVersion="$FPCVersion.$CompilerPatch"
|
||||||
FPCVersion="$FPCVersion.$CompilerPatch"
|
|
||||||
fi
|
|
||||||
echo " $CompilerVersionStr-$FPCRelease"
|
echo " $CompilerVersionStr-$FPCRelease"
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user