mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 11:58:12 +02:00
lcl: add TCustomBitBtn.LoadGlyphFromLazarusResource
git-svn-id: trunk@16648 -
This commit is contained in:
parent
5482e9dde7
commit
fa7ae42825
@ -163,6 +163,7 @@ type
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
procedure Click; override;
|
||||
procedure LoadGlyphFromLazarusResource(const AName: String);
|
||||
public
|
||||
property Glyph: TBitmap read GetGlyph write SetGlyph stored IsGlyphStored;
|
||||
property NumGlyphs: Integer read GetNumGlyphs write SetNumGlyphs default 1;
|
||||
@ -384,6 +385,7 @@ var
|
||||
GetDefaultBitBtnGlyph: TGetDefaultBitBtnGlyph = nil;
|
||||
|
||||
function GetLCLDefaultBtnGlyph(Kind: TBitBtnKind): TGraphic;
|
||||
procedure LoadGlyphFromLazarusResource(AGlyph: TButtonGlyph; const AName: String);
|
||||
|
||||
procedure Register;
|
||||
|
||||
@ -428,6 +430,40 @@ begin
|
||||
Result := CreateBitmapFromLazarusResource(BitBtnResNames[Kind]);
|
||||
end;
|
||||
|
||||
procedure LoadGlyphFromLazarusResource(AGlyph: TButtonGlyph; const AName: String);
|
||||
var
|
||||
C: TCustomBitmap;
|
||||
B: TBitmap;
|
||||
begin
|
||||
if AName = '' then
|
||||
C := nil
|
||||
else
|
||||
C := CreateBitmapFromLazarusResource(AName);
|
||||
|
||||
if C = nil
|
||||
then begin
|
||||
AGlyph.Glyph := nil;
|
||||
Exit;
|
||||
end;
|
||||
B := nil;
|
||||
try
|
||||
if AGlyph.Glyph <> nil
|
||||
then begin
|
||||
AGlyph.Glyph.Assign(C);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
// unfortunately a Glyph doesn't support a custom bitmap yet.
|
||||
// So we need a Bitmap helper
|
||||
B := TBitmap.Create;
|
||||
B.Assign(C);
|
||||
AGlyph.Glyph := B;
|
||||
finally
|
||||
B.Free;
|
||||
C.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure Register;
|
||||
begin
|
||||
RegisterComponents('Additional',[TBitBtn,TSpeedButton]);
|
||||
|
@ -55,6 +55,11 @@ Begin
|
||||
inherited Click;
|
||||
End;
|
||||
|
||||
procedure TCustomBitBtn.LoadGlyphFromLazarusResource(const AName: String);
|
||||
begin
|
||||
Buttons.LoadGlyphFromLazarusResource(FButtonGlyph, AName);
|
||||
end;
|
||||
|
||||
function TCustomBitBtn.GetGlyph : TBitmap;
|
||||
Begin
|
||||
Result := FButtonGlyph.Glyph;
|
||||
|
@ -16,7 +16,6 @@
|
||||
}
|
||||
|
||||
type
|
||||
|
||||
{ TGlyphBitmap }
|
||||
|
||||
TGlyphBitmap = class(TBitmap)
|
||||
|
@ -862,38 +862,8 @@ begin
|
||||
end;
|
||||
|
||||
procedure TCustomSpeedButton.LoadGlyphFromLazarusResource(const AName: String);
|
||||
var
|
||||
C: TCustomBitmap;
|
||||
B: TBitmap;
|
||||
begin
|
||||
if AName = '' then
|
||||
C := nil
|
||||
else
|
||||
C := CreateBitmapFromLazarusResource(AName);
|
||||
|
||||
if C = nil
|
||||
then begin
|
||||
SetGlyph(nil);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
try
|
||||
if FGlyph.Glyph <> nil
|
||||
then begin
|
||||
B := nil;
|
||||
FGlyph.Glyph.Assign(C);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
// unfortunately a Glyph doesn't support a custom bitmap yet.
|
||||
// So we need a Bitmap helper
|
||||
B := TBitmap.Create;
|
||||
B.Assign(C);
|
||||
SetGlyph(B);
|
||||
finally
|
||||
B.Free;
|
||||
C.Free;
|
||||
end;
|
||||
Buttons.LoadGlyphFromLazarusResource(FGlyph, AName);
|
||||
end;
|
||||
|
||||
function TCustomSpeedButton.GetGlyphSize(PaintRect: TRect): TSize;
|
||||
|
Loading…
Reference in New Issue
Block a user