LCL: added TToolButton.ShowCaption, bug #16778

git-svn-id: trunk@26388 -
This commit is contained in:
mattias 2010-07-01 12:56:04 +00:00
parent cb894f41be
commit f4aff160db
3 changed files with 36 additions and 13 deletions

View File

@ -17422,6 +17422,10 @@ the comparision is case sensitive.
<element name="TToolBar.WSRegisterClass" link="#LCL.LCLClasses.TLCLComponent.WSRegisterClass"/>
<element name="TCustomTrackBar.WSRegisterClass" link="#LCL.LCLClasses.TLCLComponent.WSRegisterClass"/>
<element name="TCustomTreeView.WSRegisterClass" link="#LCL.LCLClasses.TLCLComponent.WSRegisterClass"/>
<element name="TToolButton.ShowCaption">
<short>Show/Hide caption</short>
<descr>The ToolBar.ShowCaptions has precendence. Hiding will only work if ToolBar.List is true.</descr>
</element>
</module>
<!-- ComCtrls -->
</package>

View File

@ -1524,6 +1524,7 @@ type
FMarked: Boolean;
FMenuItem: TMenuItem;
FMouseInControl: boolean;
FShowCaption: boolean;
FStyle: TToolButtonStyle;
FToolButtonFlags: TToolButtonFlags;
FUpdateCount: Integer;
@ -1541,6 +1542,7 @@ type
procedure SetIndeterminate(Value: Boolean);
procedure SetMarked(Value: Boolean);
procedure SetMenuItem(Value: TMenuItem);
procedure SetShowCaption(const AValue: boolean);
procedure SetStyle(Value: TToolButtonStyle);
procedure SetWrap(Value: Boolean);
procedure SetMouseInControl(NewMouseInControl: Boolean);
@ -1606,13 +1608,6 @@ type
property Indeterminate: Boolean read FIndeterminate write SetIndeterminate default False;
property Marked: Boolean read FMarked write SetMarked default False;
property MenuItem: TMenuItem read FMenuItem write SetMenuItem;
property ParentShowHint;
property PopupMenu;
property Wrap: Boolean read FWrap write SetWrap default False;
property ShowHint;
property Style: TToolButtonStyle read FStyle write SetStyle default tbsButton;
property Visible;
property Width stored IsWidthStored;
property OnClick;
property OnContextPopup;
property OnDragDrop;
@ -1624,6 +1619,14 @@ type
property OnMouseUp;
property OnStartDock;
property OnStartDrag;
property ParentShowHint;
property PopupMenu;
property ShowCaption: boolean read FShowCaption write SetShowCaption default true;
property ShowHint;
property Style: TToolButtonStyle read FStyle write SetStyle default tbsButton;
property Visible;
property Width stored IsWidthStored;
property Wrap: Boolean read FWrap write SetWrap default False;
end;
{ TToolBarEnumerator }

View File

@ -59,6 +59,7 @@ begin
inherited Create(TheOwner);
FImageIndex := -1;
FStyle := tbsButton;
FShowCaption := true;
ControlStyle := [csCaptureMouse, csSetCaption, csDesignNoSmoothResize];
with GetControlClassDefaultSize do
SetInitialBounds(0, 0, CX, CY);
@ -259,9 +260,11 @@ begin
// calculate text size
TextSize.cx:=0;
TextSize.cy:=0;
if (Style in [tbsButton, tbsDropDown, tbsCheck]) and
(FToolBar.ShowCaptions) and
(Caption <> '') then
if (Style in [tbsButton, tbsDropDown, tbsCheck]) and (FToolBar.ShowCaptions)
and ((FToolbar.List and ShowCaption) //Allow hide caption only in list mode
or not FToolBar.List)
and (Caption <> '')
then
TextSize := GetTextSize;
// calculate icon size
@ -563,7 +566,7 @@ begin
if FImageIndex = Value then exit;
//debugln('TToolButton.SetImageIndex ',Name,':',ClassName,' Old=',FImageIndex,' New=',Value);
FImageIndex := Value;
if Visible and (FToolBar <> nil) then
if IsControlVisible and (FToolBar <> nil) then
begin
RefreshControl;
Invalidate;
@ -600,12 +603,23 @@ begin
FMenuItem.FreeNotification(Self);
end;
procedure TToolButton.SetShowCaption(const AValue: boolean);
begin
if FShowCaption=AValue then exit;
FShowCaption:=AValue;
if IsControlVisible then
begin
InvalidatePreferredSize;
UpdateVisibleToolbar;
end;
end;
procedure TToolButton.SetStyle(Value: TToolButtonStyle);
begin
if FStyle = Value then exit;
FStyle := Value;
InvalidatePreferredSize;
if Visible then
if IsControlVisible then
UpdateVisibleToolbar;
end;
@ -929,7 +943,9 @@ begin
// calculate text size
TextSize.cx:=0;
TextSize.cy:=0;
if (Style in [tbsButton,tbsDropDown,tbsCheck]) and (FToolBar.ShowCaptions) then
if (Style in [tbsButton,tbsDropDown,tbsCheck]) and (FToolBar.ShowCaptions) and
//Allow hide caption only in list mode
((FToolBar.List and ShowCaption) or not FToolBar.List) then
begin
if (Caption<>'') then
begin