LCL: TBitBtn: fix GlyphShowMode handling when image list is assigned. Issue #33645

git-svn-id: trunk@57714 -
This commit is contained in:
ondrej 2018-04-26 05:38:10 +00:00
parent 8e4a25abdb
commit 733714a9cb
2 changed files with 25 additions and 25 deletions

View File

@ -101,6 +101,7 @@ type
procedure CacheSetImageList(AImageList: TCustomImageList);
procedure CacheSetImageIndex(AIndex, AImageIndex: Integer);
protected
function CanShow: Boolean;
procedure DoChange; virtual;
procedure GlyphChanged(Sender: TObject);
procedure SetTransparentMode(AValue: TGlyphTransparencyMode);

View File

@ -105,7 +105,7 @@ const
(gdeNormal, gdeDisabled, gdeShadowed, gdeNormal, gdeHighlighted));
begin
AUseAutoEffects := ThemeServices.GetOption(toUseGlyphEffects);
if Assigned(FExternalImages) then
if Assigned(FExternalImages) and CanShow then
begin
AImages := FExternalImages;
AIndex := FExternalImageIndex;
@ -222,30 +222,6 @@ begin
end;
procedure TButtonGlyph.GlyphChanged(Sender: TObject);
function CanShow: Boolean;
begin
Result := True;
if IsDesigning then
Exit;
case ShowMode of
gsmAlways:
Result := True;
gsmNever:
Result := False;
gsmApplication:
begin
case Application.ShowButtonGlyphs of
sbgAlways: Result := True;
sbgNever: Result := False;
sbgSystem: Result := SystemShowButtonGlyphs;
end;
end;
gsmSystem:
Result := SystemShowButtonGlyphs;
end;
end;
begin
if FImagesCache <> nil then
begin
@ -381,6 +357,29 @@ begin
FImages := AImageList;
end;
function TButtonGlyph.CanShow: Boolean;
begin
Result := True;
if IsDesigning then
Exit;
case ShowMode of
gsmAlways:
Result := True;
gsmNever:
Result := False;
gsmApplication:
begin
case Application.ShowButtonGlyphs of
sbgAlways: Result := True;
sbgNever: Result := False;
sbgSystem: Result := SystemShowButtonGlyphs;
end;
end;
gsmSystem:
Result := SystemShowButtonGlyphs;
end;
end;
procedure TButtonGlyph.CacheSetImageIndex(AIndex, AImageIndex: Integer);
begin
if (AIndex >= ord(Low(TButtonState))) and (AIndex <= Ord(High(TButtonState))) then