mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-02 04:00:25 +02:00
Buttons: LoadGlyphFromResource, GetButtonImageIndex
This commit is contained in:
parent
016d9d0534
commit
dc374c1447
@ -511,6 +511,7 @@ type
|
|||||||
}
|
}
|
||||||
type
|
type
|
||||||
TGetDefaultBitBtnGlyph = function(Kind: TBitBtnKind; var Handled: Boolean): TBitmap;
|
TGetDefaultBitBtnGlyph = function(Kind: TBitBtnKind; var Handled: Boolean): TBitmap;
|
||||||
|
TButtonImage = idButtonOk..idButtonNoToAll;
|
||||||
var
|
var
|
||||||
GetDefaultBitBtnGlyph: TGetDefaultBitBtnGlyph = nil;
|
GetDefaultBitBtnGlyph: TGetDefaultBitBtnGlyph = nil;
|
||||||
|
|
||||||
@ -518,11 +519,13 @@ function GetLCLDefaultBtnGlyph(Kind: TBitBtnKind): TGraphic;
|
|||||||
procedure LoadGlyphFromResourceName(AGlyph: TButtonGlyph; Instance: THandle; const AName: String);
|
procedure LoadGlyphFromResourceName(AGlyph: TButtonGlyph; Instance: THandle; const AName: String);
|
||||||
procedure LoadGlyphFromLazarusResource(AGlyph: TButtonGlyph; const AName: String);
|
procedure LoadGlyphFromLazarusResource(AGlyph: TButtonGlyph; const AName: String);
|
||||||
procedure LoadGlyphFromStock(AGlyph: TButtonGlyph; idButton: Integer);
|
procedure LoadGlyphFromStock(AGlyph: TButtonGlyph; idButton: Integer);
|
||||||
|
procedure LoadGlyphFromResource(AGlyph: TButtonGlyph; idButton: Integer); // DPI-aware
|
||||||
|
|
||||||
// helper functions (search LCLType for idButton)
|
// helper functions (search LCLType for idButton)
|
||||||
function GetButtonCaption(idButton: Integer): String;
|
function GetButtonCaption(idButton: Integer): String;
|
||||||
function GetDefaultButtonIcon(idButton: Integer; ScalePercent: Integer = 100): TCustomBitmap;
|
function GetDefaultButtonIcon(idButton: Integer; ScalePercent: Integer = 100): TCustomBitmap;
|
||||||
function GetButtonIcon(idButton: Integer): TCustomBitmap;
|
function GetButtonIcon(idButton: Integer): TCustomBitmap;
|
||||||
|
function GetButtonImageIndex(idButton: TButtonImage): Integer; // DPI-aware: image index for the LCLGlyphs image list
|
||||||
function BidiAdjustButtonLayout(IsRightToLeft: Boolean; Layout: TButtonLayout): TButtonLayout;
|
function BidiAdjustButtonLayout(IsRightToLeft: Boolean; Layout: TButtonLayout): TButtonLayout;
|
||||||
|
|
||||||
function dbgs(Kind: TBitBtnKind): string; overload;
|
function dbgs(Kind: TBitBtnKind): string; overload;
|
||||||
@ -540,7 +543,7 @@ const
|
|||||||
idButtonNo, idButtonClose, idButtonAbort, idButtonRetry, idButtonIgnore,
|
idButtonNo, idButtonClose, idButtonAbort, idButtonRetry, idButtonIgnore,
|
||||||
idButtonAll, idButtonNoToAll, idButtonYesToAll);
|
idButtonAll, idButtonNoToAll, idButtonYesToAll);
|
||||||
|
|
||||||
BitBtnResNames: array[idButtonOk..idButtonNoToAll] of String =
|
BitBtnResNames: array[TButtonImage] of String =
|
||||||
(
|
(
|
||||||
{idButtonOk } 'btn_ok',
|
{idButtonOk } 'btn_ok',
|
||||||
{idButtonCancel } 'btn_cancel',
|
{idButtonCancel } 'btn_cancel',
|
||||||
@ -625,6 +628,15 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure LoadGlyphFromResource(AGlyph: TButtonGlyph; idButton: Integer);
|
||||||
|
var
|
||||||
|
I: Integer;
|
||||||
|
begin
|
||||||
|
if not((Low(TButtonImage)<=idButton) and (idButton<=High(TButtonImage))) then
|
||||||
|
Exit;
|
||||||
|
AGlyph.LCLGlyphName := BitBtnResNames[idButton];
|
||||||
|
end;
|
||||||
|
|
||||||
function GetButtonCaption(idButton: Integer): String;
|
function GetButtonCaption(idButton: Integer): String;
|
||||||
begin
|
begin
|
||||||
case idButton of
|
case idButton of
|
||||||
@ -663,6 +675,11 @@ begin
|
|||||||
Result := GetDefaultButtonIcon(idButton);
|
Result := GetDefaultButtonIcon(idButton);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function GetButtonImageIndex(idButton: TButtonImage): Integer;
|
||||||
|
begin
|
||||||
|
Result := LCLGlyphs.GetImageIndex(BitBtnResNames[idButton]);
|
||||||
|
end;
|
||||||
|
|
||||||
const
|
const
|
||||||
BtnBidiLayout: array[Boolean, TButtonLayout] of TButtonLayout =
|
BtnBidiLayout: array[Boolean, TButtonLayout] of TButtonLayout =
|
||||||
(
|
(
|
||||||
|
Loading…
Reference in New Issue
Block a user