LCL buttonpanel: fix hiding glyphs with ShowGlyphs. issue #37455

This commit is contained in:
Ondrej Pokorny 2022-08-17 23:46:50 +02:00
parent 44a40cb0ed
commit cea0e01fd4

View File

@ -15,7 +15,7 @@ interface
uses
Math, Types, SysUtils, Classes,
// LCL
LCLType, LMessages, Controls, ExtCtrls, StdCtrls, Buttons, Forms, Graphics, Themes,
LCLType, LMessages, Controls, ExtCtrls, StdCtrls, Buttons, Forms, Graphics, Themes, Menus,
// LazUtils
GraphType;
@ -61,7 +61,6 @@ type
FShowButtons: TPanelButtons;
FShowGlyphs: TPanelButtons;
FBevel: TBevel;
FGlyphs: array[TPanelButton] of TBitmap;
FButtons: array[TPanelButton] of TPanelBitBtn;
FButtonsWidth: Integer;
FButtonsHeight: Integer;
@ -98,7 +97,6 @@ type
procedure CMShowingChanged(var Message: TLMessage); message CM_SHOWINGCHANGED;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property Align default alBottom;
property AutoSize default True;
@ -235,13 +233,10 @@ begin
begin
if FButtons[btn] = nil then Continue;
if btn in FShowGlyphs
then begin
FButtons[btn].Glyph.Assign(FGlyphs[btn]);
end
else begin
FButtons[btn].Glyph.Assign(nil);
end;
if btn in FShowGlyphs then
FButtons[btn].GlyphShowMode := gsmApplication
else
FButtons[btn].GlyphShowMode := gsmNever;
end;
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TCustomButtonPanel.DoShowGlyphs'){$ENDIF};
end;
@ -548,16 +543,10 @@ begin
AutoSize := true;
TabOrder := Ord(AButton); //initial order
Align := alCustom;
if FGlyphs[AButton] = nil
then begin
// first time
FGlyphs[AButton] := TBitmap.Create;
FGlyphs[AButton].Assign(Glyph);
end;
// (re)set the glyph if needed
if (AButton in FShowGlyphs)
then Glyph.Assign(FGlyphs[AButton])
else Glyph.Assign(nil);
if AButton in FShowGlyphs then
GlyphShowMode := gsmApplication
else
GlyphShowMode := gsmNever;
// set default
Default := AButton = FDefaultButton;
@ -690,13 +679,4 @@ begin
//debugln(['TCustomButtonPanel.CalculatePreferredSize ',DbgSName(Self),' ',PreferredWidth,'x',PreferredHeight]);
end;
destructor TCustomButtonPanel.Destroy;
var
btn: TPanelButton;
begin
for btn := Low(btn) to High(btn) do
FreeAndNil(FGlyphs[btn]);
inherited Destroy;
end;
end.