mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-24 01:08:40 +02:00
ButtonGlyph:
- allow setting bigger glyphcount than 4 (limited by High(TGlyphCount)). current limit is 5 - clear imagelist and imageindexes after glyph change to prevent possible garbage drawing git-svn-id: trunk@13295 -
This commit is contained in:
parent
2665090c3d
commit
d27b65a627
@ -87,6 +87,7 @@ type
|
|||||||
function GetWidth: Integer;
|
function GetWidth: Integer;
|
||||||
procedure SetGlyph(Value: TBitmap);
|
procedure SetGlyph(Value: TBitmap);
|
||||||
procedure SetNumGlyphs(Value: TNumGlyphs);
|
procedure SetNumGlyphs(Value: TNumGlyphs);
|
||||||
|
procedure ClearImages;
|
||||||
protected
|
protected
|
||||||
// IUnknown
|
// IUnknown
|
||||||
function QueryInterface(const iid: tguid; out obj): longint; stdcall;
|
function QueryInterface(const iid: tguid; out obj): longint; stdcall;
|
||||||
|
@ -148,7 +148,7 @@ end;
|
|||||||
procedure TCustomBitBtn.SetNumGlyphs(AValue: Integer);
|
procedure TCustomBitBtn.SetNumGlyphs(AValue: Integer);
|
||||||
begin
|
begin
|
||||||
if AValue < 0 then AValue := 1;
|
if AValue < 0 then AValue := 1;
|
||||||
if AValue > 4 then AValue := 4;
|
if AValue > High(TNumGlyphs) then AValue := High(TNumGlyphs);
|
||||||
|
|
||||||
if AValue <> FButtonGlyph.NumGlyphs then
|
if AValue <> FButtonGlyph.NumGlyphs then
|
||||||
Begin
|
Begin
|
||||||
|
@ -96,8 +96,8 @@ begin
|
|||||||
if FOriginal.Width mod FOriginal.Height = 0 then
|
if FOriginal.Width mod FOriginal.Height = 0 then
|
||||||
begin
|
begin
|
||||||
GlyphCount := FOriginal.Width div FOriginal.Height;
|
GlyphCount := FOriginal.Width div FOriginal.Height;
|
||||||
if GlyphCount > 4 then
|
if GlyphCount > High(TNumGlyphs) then
|
||||||
GlyphCount:= 1;
|
GlyphCount := Low(TNumGlyphs);
|
||||||
FNumGlyphs := TNumGlyphs(GlyphCount);
|
FNumGlyphs := TNumGlyphs(GlyphCount);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -126,6 +126,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
FImagesCache.UnregisterListener(Self);
|
FImagesCache.UnregisterListener(Self);
|
||||||
FImagesCache := nil; // cache can free on unregister
|
FImagesCache := nil; // cache can free on unregister
|
||||||
|
ClearImages;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (FOriginal.Width > 0) and (FOriginal.Height > 0) then
|
if (FOriginal.Width > 0) and (FOriginal.Height > 0) then
|
||||||
@ -179,6 +180,15 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TButtonGlyph.ClearImages;
|
||||||
|
var
|
||||||
|
i: TButtonState;
|
||||||
|
begin
|
||||||
|
FImages := nil;
|
||||||
|
for i := Low(TButtonState) to High(TButtonState) do
|
||||||
|
FImageIndexes[i] := -1;
|
||||||
|
end;
|
||||||
|
|
||||||
function TButtonGlyph.QueryInterface(const iid: tguid; out obj): longint; stdcall;
|
function TButtonGlyph.QueryInterface(const iid: tguid; out obj): longint; stdcall;
|
||||||
begin
|
begin
|
||||||
if GetInterface(iid, obj) then
|
if GetInterface(iid, obj) then
|
||||||
|
@ -238,7 +238,7 @@ end;
|
|||||||
procedure TCustomSpeedButton.SetNumGlyphs(Value : integer);
|
procedure TCustomSpeedButton.SetNumGlyphs(Value : integer);
|
||||||
Begin
|
Begin
|
||||||
if Value < 0 then Value := 1;
|
if Value < 0 then Value := 1;
|
||||||
if Value > 4 then Value := 4;
|
if Value > High(TNumGlyphs) then Value := High(TNumGlyphs);
|
||||||
|
|
||||||
if Value <> TButtonGlyph(fGlyph).NumGlyphs then
|
if Value <> TButtonGlyph(fGlyph).NumGlyphs then
|
||||||
Begin
|
Begin
|
||||||
|
Loading…
Reference in New Issue
Block a user