mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 19:19:19 +02:00
LCL: TBitBtn: implemented NumGlyphs from Giuliano Colla
git-svn-id: trunk@12467 -
This commit is contained in:
parent
8ff0a64f6e
commit
18fa72e639
@ -103,7 +103,8 @@ type
|
|||||||
FLayout: TButtonLayout;
|
FLayout: TButtonLayout;
|
||||||
FMargin: integer;
|
FMargin: integer;
|
||||||
FSpacing: Integer;
|
FSpacing: Integer;
|
||||||
Function GetGlyph: TBitmap;
|
FMultiGlyph: TBitmap;
|
||||||
|
function GetGlyph: TBitmap;
|
||||||
function GetNumGlyphs: Integer;
|
function GetNumGlyphs: Integer;
|
||||||
Function IsGlyphStored: Boolean;
|
Function IsGlyphStored: Boolean;
|
||||||
Procedure SetGlyph(AValue: TBitmap);
|
Procedure SetGlyph(AValue: TBitmap);
|
||||||
@ -113,7 +114,7 @@ type
|
|||||||
procedure SetNumGlyphs(AValue: Integer);
|
procedure SetNumGlyphs(AValue: Integer);
|
||||||
Procedure SetSpacing(AValue: Integer);
|
Procedure SetSpacing(AValue: Integer);
|
||||||
procedure RealizeKind;
|
procedure RealizeKind;
|
||||||
|
procedure DrawGlyph;
|
||||||
//Return the caption associated with the aKind value.
|
//Return the caption associated with the aKind value.
|
||||||
function GetCaptionOfKind(aKind: TBitBtnKind): String;
|
function GetCaptionOfKind(aKind: TBitBtnKind): String;
|
||||||
protected
|
protected
|
||||||
|
@ -39,6 +39,7 @@ end;
|
|||||||
destructor TCustomBitBtn.Destroy;
|
destructor TCustomBitBtn.Destroy;
|
||||||
Begin
|
Begin
|
||||||
FreeThenNil(FButtonGlyph);
|
FreeThenNil(FButtonGlyph);
|
||||||
|
FreeThenNil(FMultiGlyph);
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -83,7 +84,14 @@ end;
|
|||||||
procedure TCustomBitBtn.GlyphChanged(Sender: TObject);
|
procedure TCustomBitBtn.GlyphChanged(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if HandleAllocated
|
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;
|
InvalidatePreferredSize;
|
||||||
AdjustSize;
|
AdjustSize;
|
||||||
end;
|
end;
|
||||||
@ -220,6 +228,34 @@ begin
|
|||||||
end;
|
end;
|
||||||
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.
|
{ Return the caption associated with the akind value.
|
||||||
This function replaces BitBtnCaption const because the localizing
|
This function replaces BitBtnCaption const because the localizing
|
||||||
dont work with an const array }
|
dont work with an const array }
|
||||||
@ -244,7 +280,12 @@ end;
|
|||||||
|
|
||||||
procedure TCustomBitBtn.InitializeWnd;
|
procedure TCustomBitBtn.InitializeWnd;
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited InitializeWnd;
|
||||||
|
if NumGlyphs > 1 then begin
|
||||||
|
DrawGlyph;
|
||||||
|
TWSBitBtnClass(WidgetSetClass).SetGlyph(Self, FMultiGlyph);
|
||||||
|
end
|
||||||
|
else
|
||||||
TWSBitBtnClass(WidgetSetClass).SetGlyph(Self, Glyph);
|
TWSBitBtnClass(WidgetSetClass).SetGlyph(Self, Glyph);
|
||||||
TWSBitBtnClass(WidgetSetClass).SetLayout(Self, FLayout);
|
TWSBitBtnClass(WidgetSetClass).SetLayout(Self, FLayout);
|
||||||
TWSBitBtnClass(WidgetSetClass).SetMargin(Self, FMargin);
|
TWSBitBtnClass(WidgetSetClass).SetMargin(Self, FMargin);
|
||||||
|
Loading…
Reference in New Issue
Block a user