mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 05:19:14 +02:00
implemented AutoSize for TToolButton
git-svn-id: trunk@9433 -
This commit is contained in:
parent
d8ed79aac8
commit
5b814f9fcb
@ -302,6 +302,9 @@ begin
|
|||||||
Tool.EnvironmentOverrides.Values['LCL_PLATFORM']:=
|
Tool.EnvironmentOverrides.Values['LCL_PLATFORM']:=
|
||||||
LCLPlatformNames[Options.LCLPlatform];
|
LCLPlatformNames[Options.LCLPlatform];
|
||||||
Tool.EnvironmentOverrides.Values['LANG']:= 'en_US';
|
Tool.EnvironmentOverrides.Values['LANG']:= 'en_US';
|
||||||
|
Tool.EnvironmentOverrides.Values['LANG']:= 'en_US';
|
||||||
|
if blfOnlyIDE in Flags then
|
||||||
|
Tool.EnvironmentOverrides.Values['USESVN2REVISIONINC']:= '0';
|
||||||
if CompilerPath<>'' then
|
if CompilerPath<>'' then
|
||||||
Tool.EnvironmentOverrides.Values['PP']:=CompilerPath;
|
Tool.EnvironmentOverrides.Values['PP']:=CompilerPath;
|
||||||
if not FileExists(Tool.Filename) then begin
|
if not FileExists(Tool.Filename) then begin
|
||||||
|
@ -1270,6 +1270,9 @@ type
|
|||||||
function GroupAllUpAllowed: boolean;
|
function GroupAllUpAllowed: boolean;
|
||||||
procedure DoSetBounds(ALeft, ATop, AWidth, AHeight: integer); override;
|
procedure DoSetBounds(ALeft, ATop, AWidth, AHeight: integer); override;
|
||||||
function DialogChar(var Message: TLMKey): boolean; override;
|
function DialogChar(var Message: TLMKey): boolean; override;
|
||||||
|
procedure CalculatePreferredSize(
|
||||||
|
var PreferredWidth, PreferredHeight: integer;
|
||||||
|
WithThemeSpace: Boolean); override;
|
||||||
public
|
public
|
||||||
constructor Create(TheOwner: TComponent); override;
|
constructor Create(TheOwner: TComponent); override;
|
||||||
function CheckMenuDropdown: Boolean; dynamic;
|
function CheckMenuDropdown: Boolean; dynamic;
|
||||||
|
@ -465,6 +465,7 @@ var
|
|||||||
begin
|
begin
|
||||||
if (CurControl is TToolButton)
|
if (CurControl is TToolButton)
|
||||||
and (TToolButton(CurControl).Style in [tbsButton,tbsDropDown,tbsCheck])
|
and (TToolButton(CurControl).Style in [tbsButton,tbsDropDown,tbsCheck])
|
||||||
|
and (not CurControl.AutoSize)
|
||||||
then
|
then
|
||||||
NewControlWidth:=ButtonWidth
|
NewControlWidth:=ButtonWidth
|
||||||
else
|
else
|
||||||
|
@ -229,7 +229,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// draw button
|
// draw button
|
||||||
if (Style in [tbsButton,tbsDropDown,tbsCheck]) and (FLastButtonDrawFlags and DFCS_FLAT = 0) then begin
|
if (Style in [tbsButton,tbsDropDown,tbsCheck])
|
||||||
|
and (FLastButtonDrawFlags and DFCS_FLAT = 0) then begin
|
||||||
DrawFrameControl(Canvas.GetUpdatedHandle([csBrushValid,csPenValid]),
|
DrawFrameControl(Canvas.GetUpdatedHandle([csBrushValid,csPenValid]),
|
||||||
PaintRect{ButtonRect}, DFC_BUTTON, FLastButtonDrawFlags);
|
PaintRect{ButtonRect}, DFC_BUTTON, FLastButtonDrawFlags);
|
||||||
InflateRect(PaintRect, -1, -1);
|
InflateRect(PaintRect, -1, -1);
|
||||||
@ -753,6 +754,73 @@ begin
|
|||||||
Result := inherited;
|
Result := inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TToolButton.CalculatePreferredSize(var PreferredWidth,
|
||||||
|
PreferredHeight: integer; WithThemeSpace: Boolean);
|
||||||
|
var
|
||||||
|
IconSize: TPoint;
|
||||||
|
TextSize: TSize;
|
||||||
|
TextPos: TPoint;
|
||||||
|
IconPos: TPoint;
|
||||||
|
ImgList: TCustomImageList;
|
||||||
|
ImgIndex: integer;
|
||||||
|
begin
|
||||||
|
if (FToolBar<>nil) then begin
|
||||||
|
PreferredWidth:=0;
|
||||||
|
PreferredHeight:=0;
|
||||||
|
|
||||||
|
// calculate text size
|
||||||
|
TextSize.cx:=0;
|
||||||
|
TextSize.cy:=0;
|
||||||
|
if (Style in [tbsButton,tbsDropDown,tbsCheck])
|
||||||
|
and (FToolBar.ShowCaptions) then begin
|
||||||
|
if (Caption<>'') then begin
|
||||||
|
if HandleAllocated then
|
||||||
|
TextSize:=Canvas.TextExtent(Caption);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// calculate icon size
|
||||||
|
IconSize:=Point(0,0);
|
||||||
|
GetCurrentIcon(ImgList,ImgIndex);
|
||||||
|
if (ImgList<>nil) then begin
|
||||||
|
IconSize:=Point(ImgList.Width,ImgList.Height);
|
||||||
|
if IconSize.y<=0 then IconSize.X:=0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// calculate text and icon position
|
||||||
|
TextPos:=Point(0,0);
|
||||||
|
IconPos:=Point(0,0);
|
||||||
|
if TextSize.cx>0 then begin
|
||||||
|
if IconSize.X>0 then begin
|
||||||
|
if FToolBar.List then begin
|
||||||
|
// icon left of text
|
||||||
|
TextPos.X:=IconPos.X+IconSize.X+2;
|
||||||
|
end else begin
|
||||||
|
// icon above text
|
||||||
|
TextPos.Y:=IconPos.Y+IconSize.Y+2;
|
||||||
|
end;
|
||||||
|
end else begin
|
||||||
|
// only text
|
||||||
|
end;
|
||||||
|
end else if IconSize.x>0 then begin
|
||||||
|
// only icon
|
||||||
|
end;
|
||||||
|
|
||||||
|
PreferredWidth:=Max(IconPos.X+IconSize.X,TextPos.X+TextSize.cx);
|
||||||
|
PreferredHeight:=Max(IconPos.Y+IconSize.Y,TextPos.Y+TextSize.cy);
|
||||||
|
|
||||||
|
// add button frame
|
||||||
|
FLastButtonDrawFlags:=GetButtonDrawFlags;
|
||||||
|
if (FLastButtonDrawFlags and DFCS_PUSHED) <> 0 then begin
|
||||||
|
inc(PreferredWidth,2);
|
||||||
|
inc(PreferredHeight,2);
|
||||||
|
end;
|
||||||
|
if Style=tbsDropDown then begin
|
||||||
|
inc(PreferredWidth,FToolBar.FDropDownWidth);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
// included by comctrls.pp
|
// included by comctrls.pp
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ tools/svn2revisioninc $LAZSOURCEDIR $LAZBUILDDIR/ide/revision.inc
|
|||||||
|
|
||||||
cd $LAZBUILDDIR
|
cd $LAZBUILDDIR
|
||||||
|
|
||||||
make bigide PP=$COMPILER
|
make bigide PP=$COMPILER USESVN2REVISIONINC=0
|
||||||
make lcl LCL_PLATFORM=carbon PP=$COMPILER
|
make lcl LCL_PLATFORM=carbon PP=$COMPILER
|
||||||
strip lazarus
|
strip lazarus
|
||||||
strip startlazarus
|
strip startlazarus
|
||||||
|
Loading…
Reference in New Issue
Block a user