mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-16 03:00:30 +01:00
lcl: toolbar: add DropDownWidth property
git-svn-id: trunk@50900 -
This commit is contained in:
parent
f28fd32f87
commit
540bd3a671
@ -18804,6 +18804,8 @@ the comparision is case sensitive.
|
||||
<short>Show/Hide caption</short>
|
||||
<descr>The ToolBar.ShowCaptions has precendence. Hiding will only work if ToolBar.List is true.</descr>
|
||||
</element>
|
||||
<element name="TToolBar.DropDownWidth"><short>Width of the drop down arrow button.</short><descr>Use a negative value (-1) for theme default.</descr>
|
||||
</element>
|
||||
</module>
|
||||
<!-- ComCtrls -->
|
||||
</package>
|
||||
|
||||
@ -2138,6 +2138,7 @@ type
|
||||
FDisabledImageChangeLink: TChangeLink;
|
||||
FDisabledImages: TCustomImageList;
|
||||
FDropDownWidth: integer;
|
||||
FThemeDropDownWidth: integer;
|
||||
FDropDownButton: TToolButton;
|
||||
FFlat: Boolean;
|
||||
FHotImageChangeLink: TChangeLink;
|
||||
@ -2163,6 +2164,7 @@ type
|
||||
procedure SetButtonHeight(const AValue: Integer);
|
||||
procedure SetButtonWidth(const AValue: Integer);
|
||||
procedure SetDisabledImages(const AValue: TCustomImageList);
|
||||
procedure SetDropDownWidth(const aDropDownWidth: Integer);
|
||||
procedure SetFlat(const AValue: Boolean);
|
||||
procedure SetHotImages(const AValue: TCustomImageList);
|
||||
procedure SetImages(const AValue: TCustomImageList);
|
||||
@ -2182,6 +2184,7 @@ type
|
||||
protected const
|
||||
cDefButtonWidth = 23;
|
||||
cDefButtonHeight = 22;
|
||||
cDropDownWidth = -1;
|
||||
protected
|
||||
FPrevVertical: Boolean;
|
||||
function IsVertical: Boolean; virtual;
|
||||
@ -2214,6 +2217,7 @@ type
|
||||
function GetEnumerator: TToolBarEnumerator;
|
||||
procedure SetButtonSize(NewButtonWidth, NewButtonHeight: integer);
|
||||
function CanFocus: Boolean; override;
|
||||
function GetRealDropDownWidth: Integer;
|
||||
public
|
||||
property ButtonCount: Integer read GetButtonCount;
|
||||
property Buttons[Index: Integer]: TToolButton read GetButton;
|
||||
@ -2236,6 +2240,7 @@ type
|
||||
property DragCursor;
|
||||
property DragKind;
|
||||
property DragMode;
|
||||
property DropDownWidth: Integer read FDropDownWidth write SetDropDownWidth default cDropDownWidth;
|
||||
property EdgeBorders default [ebTop];
|
||||
property EdgeInner;
|
||||
property EdgeOuter;
|
||||
|
||||
@ -92,7 +92,8 @@ begin
|
||||
FButtonWidth := cDefButtonWidth;
|
||||
FButtonHeight := cDefButtonHeight;
|
||||
Details := ThemeServices.GetElementDetails(ttbSplitButtonDropDownNormal);
|
||||
FDropDownWidth := ThemeServices.GetDetailSize(Details).cx;
|
||||
FDropDownWidth := cDropDownWidth;
|
||||
FThemeDropDownWidth := ThemeServices.GetDetailSize(Details).cx;
|
||||
FNewStyle := True;
|
||||
FWrapable := True;
|
||||
FButtons := TList.Create;
|
||||
@ -352,6 +353,13 @@ begin
|
||||
UpdateVisibleBar;
|
||||
end;
|
||||
|
||||
procedure TToolBar.SetDropDownWidth(const aDropDownWidth: Integer);
|
||||
begin
|
||||
if FDropDownWidth = aDropDownWidth then Exit;
|
||||
FDropDownWidth := aDropDownWidth;
|
||||
UpdateVisibleBar;
|
||||
end;
|
||||
|
||||
procedure TToolBar.HotImageListChange(Sender: TObject);
|
||||
begin
|
||||
if (Sender = HotImages) then UpdateVisibleBar;
|
||||
@ -417,6 +425,14 @@ begin
|
||||
Result := TToolBarEnumerator.Create(Self);
|
||||
end;
|
||||
|
||||
function TToolBar.GetRealDropDownWidth: Integer;
|
||||
begin
|
||||
if FDropDownWidth < 0 then
|
||||
Result := FThemeDropDownWidth
|
||||
else
|
||||
Result := FDropDownWidth;
|
||||
end;
|
||||
|
||||
procedure TToolBar.Paint;
|
||||
begin
|
||||
if csDesigning in ComponentState then
|
||||
|
||||
@ -84,7 +84,7 @@ begin
|
||||
// therefore the condition is always met.
|
||||
if Enabled and not(GetTickCount64 < FLastDropDownTick + 100) then
|
||||
begin
|
||||
if (Style = tbsDropDown) and (FToolBar <> nil) and (X > ClientWidth - FToolBar.FDropDownWidth) then
|
||||
if (Style = tbsDropDown) and (FToolBar <> nil) and (X > ClientWidth - FToolBar.GetRealDropDownWidth) then
|
||||
Include(NewFlags, tbfArrowPressed)
|
||||
else
|
||||
Include(NewFlags, tbfPressed);
|
||||
@ -302,7 +302,7 @@ begin
|
||||
if Style in [tbsDropDown, tbsButtonDrop] then
|
||||
begin
|
||||
DropDownButtonRect := ButtonRect;
|
||||
DropDownButtonRect.Left := Max(0, DropDownButtonRect.Right-FToolBar.FDropDownWidth);
|
||||
DropDownButtonRect.Left := Max(0, DropDownButtonRect.Right-FToolBar.GetRealDropDownWidth);
|
||||
MainBtnRect.Right := DropDownButtonRect.Left;
|
||||
if Style = tbsDropDown then
|
||||
ButtonRect := MainBtnRect
|
||||
@ -1103,8 +1103,8 @@ begin
|
||||
PreferredWidth := Max(PreferredWidth, FToolBar.ButtonWidth);
|
||||
PreferredHeight := Max(PreferredHeight, FToolBar.ButtonHeight);
|
||||
case Style of
|
||||
tbsDropDown: inc(PreferredWidth, FToolBar.FDropDownWidth);
|
||||
tbsButtonDrop: inc(PreferredWidth, FToolBar.FDropDownWidth-cDefButtonDropDecArrowWidth);
|
||||
tbsDropDown: inc(PreferredWidth, FToolBar.GetRealDropDownWidth);
|
||||
tbsButtonDrop: inc(PreferredWidth, FToolBar.GetRealDropDownWidth-cDefButtonDropDecArrowWidth);
|
||||
end;
|
||||
end
|
||||
else
|
||||
|
||||
@ -1972,14 +1972,18 @@ end;
|
||||
procedure TThemeServices.DrawElement(DC: HDC; Details: TThemedElementDetails; const R: TRect; ClipRect: PRect = nil);
|
||||
|
||||
procedure DrawDropDownArrow(const DropDownButtonRect: TRect);
|
||||
const
|
||||
cArrowWidth = 10;
|
||||
var
|
||||
ArrowRect: TRect;
|
||||
Points: array[1..3] of TPoint;
|
||||
OldBrush, Brush: HBrush;
|
||||
begin
|
||||
ArrowRect := DropDownButtonRect;
|
||||
ArrowRect.Left := DropDownButtonRect.Left + 3;
|
||||
ArrowRect.Right := Max(DropDownButtonRect.Right - 3, ArrowRect.Left);
|
||||
ArrowRect.Left := (DropDownButtonRect.Left+DropDownButtonRect.Right-cArrowWidth-1) div 2;
|
||||
ArrowRect.Right := ArrowRect.Left+cArrowWidth;
|
||||
ArrowRect.Left := ArrowRect.Left + 3;
|
||||
ArrowRect.Right := Max(ArrowRect.Right - 3, ArrowRect.Left);
|
||||
ArrowRect.Top := (DropDownButtonRect.Top + DropDownButtonRect.Bottom +
|
||||
ArrowRect.Left - ArrowRect.Right) div 2;
|
||||
ArrowRect.Bottom := ArrowRect.Top + Min(2, ArrowRect.Right - ArrowRect.Left);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user