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:
mattias 2007-11-07 23:10:58 +00:00
parent 9e4a77e06f
commit 5af932d6f0
4 changed files with 38 additions and 8 deletions

View File

@ -1491,6 +1491,8 @@ type
procedure AdjustClientRect(var ARect: TRect); override;
class function GetControlClassDefaultSize: TPoint; override;
function CanAutoSize(var NewWidth, NewHeight: Integer): Boolean; override;
procedure CalculatePreferredSize(var PreferredWidth,
PreferredHeight: integer; WithThemeSpace: Boolean); override;
function CheckMenuDropdown(Button: TToolButton): Boolean; dynamic;
procedure ClickButton(Button: TToolButton); dynamic;
procedure CreateParams(var Params: TCreateParams); override;

View File

@ -394,6 +394,19 @@ begin
Result := WrapButtons(NewWidth, NewHeight);
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;
@ -406,7 +419,6 @@ end;
------------------------------------------------------------------------------}
function TToolBar.WrapButtons(var NewWidth, NewHeight: Integer): Boolean;
var
i: Integer;
ARect: TRect;
x: Integer;
y: Integer;
@ -471,6 +483,10 @@ var
until false;
end;
var
CurClientRect: TRect;
AdjustClientFrame: TRect;
i: Integer;
begin
//DebugLn('WrapButtons ');
Result:=true;
@ -493,11 +509,16 @@ begin
OrderedControls.Sort(TListSortCompare(@CompareToolBarControl));
// position OrderedControls
ARect:=ClientRect;
CurClientRect:=ClientRect;
ARect:=CurClientRect;
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)]);
// 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;
x:=StartX;
y:=ARect.Top;
@ -516,13 +537,22 @@ begin
w:=NewControlWidth;
h:=ButtonHeight;
end;
w:=CurControl.Constraints.MinMaxWidth(w);
h:=CurControl.Constraints.MinMaxWidth(h);
if (CurControl.Left<>x) or (CurControl.Top<>y)
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))]);
CurControl.SetBoundsKeepBase(x,y,w,h);
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)
and (TToolButton(CurControl).Wrap) then begin
// user forced wrap -> start new line

View File

@ -78,7 +78,7 @@ var
ARect: TRect;
begin
FEdgeBorderType := 0;
if (ebTOP in FEdgeBorders) then
if (ebTop in FEdgeBorders) then
FEdgeBorderType := FEdgeBorderType or longint(BF_TOP);
if (ebBottom in FEdgeBorders) then
FEdgeBorderType := FEdgeBorderType or longint(BF_BOTTOM);

View File

@ -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'`
CompilerVersionStr="$CompilerVersion.$CompilerRelease.$CompilerPatch"
FPCVersion="$CompilerVersion.$CompilerRelease"
if [ "$CompilerPatch" != "0" ]; then
FPCVersion="$FPCVersion.$CompilerPatch"
fi
FPCVersion="$FPCVersion.$CompilerPatch"
echo " $CompilerVersionStr-$FPCRelease"