mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-18 04:29:27 +02:00
LCL: TBitBtn: implemented NumGlyphs from Giuliano Colla
git-svn-id: trunk@12467 -
This commit is contained in:
parent
8ff0a64f6e
commit
18fa72e639
lcl
@ -103,7 +103,8 @@ type
|
||||
FLayout: TButtonLayout;
|
||||
FMargin: integer;
|
||||
FSpacing: Integer;
|
||||
Function GetGlyph: TBitmap;
|
||||
FMultiGlyph: TBitmap;
|
||||
function GetGlyph: TBitmap;
|
||||
function GetNumGlyphs: Integer;
|
||||
Function IsGlyphStored: Boolean;
|
||||
Procedure SetGlyph(AValue: TBitmap);
|
||||
@ -113,7 +114,7 @@ type
|
||||
procedure SetNumGlyphs(AValue: Integer);
|
||||
Procedure SetSpacing(AValue: Integer);
|
||||
procedure RealizeKind;
|
||||
|
||||
procedure DrawGlyph;
|
||||
//Return the caption associated with the aKind value.
|
||||
function GetCaptionOfKind(aKind: TBitBtnKind): String;
|
||||
protected
|
||||
|
@ -39,6 +39,7 @@ end;
|
||||
destructor TCustomBitBtn.Destroy;
|
||||
Begin
|
||||
FreeThenNil(FButtonGlyph);
|
||||
FreeThenNil(FMultiGlyph);
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
@ -83,7 +84,14 @@ end;
|
||||
procedure TCustomBitBtn.GlyphChanged(Sender: TObject);
|
||||
begin
|
||||
if HandleAllocated
|
||||
then TWSBitBtnClass(WidgetSetClass).SetGlyph(Self, Glyph);
|
||||
then begin
|
||||
if NumGlyphs > 1 then begin
|
||||
DrawGlyph;
|
||||
TWSBitBtnClass(WidgetSetClass).SetGlyph(Self, FMultiGlyph);
|
||||
end
|
||||
else
|
||||
TWSBitBtnClass(WidgetSetClass).SetGlyph(Self, Glyph);
|
||||
end;
|
||||
InvalidatePreferredSize;
|
||||
AdjustSize;
|
||||
end;
|
||||
@ -220,6 +228,34 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomBitBtn.DrawGlyph;
|
||||
var
|
||||
AGlyphRect: TRect;
|
||||
AOffset: TPoint;
|
||||
AState :TButtonState;
|
||||
begin
|
||||
if FButtonGlyph.FOriginal = nil then exit;
|
||||
AOffset.X:= 0;
|
||||
AOffset.Y:= 0;
|
||||
AGlyphRect.Left :=0;
|
||||
AGlyphRect.Top := 0;
|
||||
AGlyphRect.Bottom:= FButtonGlyph.Glyph.Height;
|
||||
if NumGlyphs > 1 then
|
||||
AGlyphRect.Right:= FButtonGlyph.Glyph.Width div NumGlyphs
|
||||
else
|
||||
AGlyphRect.Right:= FButtonGlyph.Glyph.Width;
|
||||
if FMultiGlyph =nil then FMultiGlyph := TBitmap.Create;
|
||||
FMultiGlyph.Height:=AGlyphRect.Bottom;
|
||||
FMultiGlyph.Width:=AGlyphRect.Right;
|
||||
|
||||
FMultiGlyph.Canvas.Brush.Color:=Color;
|
||||
FMultiGlyph.Canvas.FillRect(AGlyphRect);
|
||||
|
||||
if Enabled then AState := bsUp
|
||||
else AState := bsDisabled;
|
||||
FButtonGlyph.Draw(FMultiGlyph.Canvas,AGlyphRect,AOffset,AState,True,0);
|
||||
end;
|
||||
|
||||
{ Return the caption associated with the akind value.
|
||||
This function replaces BitBtnCaption const because the localizing
|
||||
dont work with an const array }
|
||||
@ -244,9 +280,14 @@ end;
|
||||
|
||||
procedure TCustomBitBtn.InitializeWnd;
|
||||
begin
|
||||
inherited;
|
||||
TWSBitBtnClass(WidgetSetClass).SetGlyph(Self, Glyph);
|
||||
TWSBitBtnClass(WidgetSetClass).SetLayout(Self, FLayout);
|
||||
inherited InitializeWnd;
|
||||
if NumGlyphs > 1 then begin
|
||||
DrawGlyph;
|
||||
TWSBitBtnClass(WidgetSetClass).SetGlyph(Self, FMultiGlyph);
|
||||
end
|
||||
else
|
||||
TWSBitBtnClass(WidgetSetClass).SetGlyph(Self, Glyph);
|
||||
TWSBitBtnClass(WidgetSetClass).SetLayout(Self, FLayout);
|
||||
TWSBitBtnClass(WidgetSetClass).SetMargin(Self, FMargin);
|
||||
TWSBitBtnClass(WidgetSetClass).SetSpacing(Self, FSpacing);
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user