LCL: implemented TToolButton.AutoSize

git-svn-id: trunk@20303 -
This commit is contained in:
mattias 2009-05-30 11:17:39 +00:00
parent 124bcb7012
commit b5b3115e36
2 changed files with 26 additions and 1 deletions

View File

@ -1458,6 +1458,8 @@ type
function GroupAllUpAllowed: boolean;
function DialogChar(var Message: TLMKey): boolean; override;
procedure SetAutoSize(Value: Boolean); override;
procedure RealSetText(const AValue: TCaption); override;
procedure DoAutoSize; override;
public
constructor Create(TheOwner: TComponent); override;
function CheckMenuDropdown: Boolean; dynamic;

View File

@ -396,6 +396,26 @@ begin
RequestAlign;
end;
procedure TToolButton.RealSetText(const AValue: TCaption);
begin
if ([csLoading,csDestroying]*ComponentState=[]) then
begin
InvalidatePreferredSize;
inherited RealSetText(AValue);
AdjustSize;
end
else inherited RealSetText(AValue);
end;
procedure TToolButton.DoAutoSize;
var
PreferredWidth: integer;
PreferredHeight: integer;
begin
GetPreferredSize(PreferredWidth,PreferredHeight);
SetBounds(Left,Top,PreferredWidth,PreferredHeight);
end;
procedure TToolButton.SetToolBar(NewToolBar: TToolBar);
begin
if FToolBar = NewToolBar then exit;
@ -683,7 +703,9 @@ begin
Result := -1;
end;
procedure TToolButton.GetPreferredSize(var PreferredWidth, PreferredHeight: integer; Raw: boolean; WithThemeSpace: boolean);
procedure TToolButton.GetPreferredSize(
var PreferredWidth, PreferredHeight: integer; Raw: boolean;
WithThemeSpace: boolean);
begin
inherited GetPreferredSize(PreferredWidth, PreferredHeight, Raw, WithThemeSpace);
@ -959,6 +981,7 @@ begin
inc(PreferredWidth, FToolBar.FDropDownWidth);
end;
end;
//DebugLn(['TToolButton.CalculatePreferredSize ',DbgSName(Self),' ',PreferredWidth,',',PreferredHeight,' Caption=',Caption]);
end;
class function TToolButton.GetControlClassDefaultSize: TPoint;