mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-09 01:48:03 +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;
|
||||
procedure SetGlyph(Value: TBitmap);
|
||||
procedure SetNumGlyphs(Value: TNumGlyphs);
|
||||
procedure ClearImages;
|
||||
protected
|
||||
// IUnknown
|
||||
function QueryInterface(const iid: tguid; out obj): longint; stdcall;
|
||||
|
@ -148,11 +148,11 @@ end;
|
||||
procedure TCustomBitBtn.SetNumGlyphs(AValue: Integer);
|
||||
begin
|
||||
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
|
||||
Begin
|
||||
FButtonGlyph.NumGlyphs := TNumGlyphs(AValue);
|
||||
FButtonGlyph.NumGlyphs := TNumGlyphs(AValue);
|
||||
Invalidate;
|
||||
end;
|
||||
end;
|
||||
|
@ -95,10 +95,10 @@ begin
|
||||
begin
|
||||
if FOriginal.Width mod FOriginal.Height = 0 then
|
||||
begin
|
||||
GlyphCount:= FOriginal.Width div FOriginal.Height;
|
||||
if GlyphCount > 4 then
|
||||
GlyphCount:= 1;
|
||||
FNumGlyphs:= TNumGlyphs(GlyphCount);
|
||||
GlyphCount := FOriginal.Width div FOriginal.Height;
|
||||
if GlyphCount > High(TNumGlyphs) then
|
||||
GlyphCount := Low(TNumGlyphs);
|
||||
FNumGlyphs := TNumGlyphs(GlyphCount);
|
||||
end;
|
||||
end;
|
||||
GlyphChanged(FOriginal);
|
||||
@ -126,6 +126,7 @@ begin
|
||||
begin
|
||||
FImagesCache.UnregisterListener(Self);
|
||||
FImagesCache := nil; // cache can free on unregister
|
||||
ClearImages;
|
||||
end;
|
||||
|
||||
if (FOriginal.Width > 0) and (FOriginal.Height > 0) then
|
||||
@ -179,6 +180,15 @@ begin
|
||||
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;
|
||||
begin
|
||||
if GetInterface(iid, obj) then
|
||||
|
@ -238,11 +238,11 @@ end;
|
||||
procedure TCustomSpeedButton.SetNumGlyphs(Value : integer);
|
||||
Begin
|
||||
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
|
||||
Begin
|
||||
TButtonGlyph(fGlyph).NumGlyphs := TNumGlyphs(Value);
|
||||
TButtonGlyph(fGlyph).NumGlyphs := TNumGlyphs(Value);
|
||||
Invalidate;
|
||||
end;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user