[Lazarus] Close button bkClose as "X"
Jesus Reyes
jesusrmx at yahoo.com.mx
Mon Jul 26 02:50:22 CEST 2010
--- El dom 25-jul-10, José Mejuto <joshyfun at gmail.com> escribió:
> De: José Mejuto <joshyfun at gmail.com>
> Asunto: [Lazarus] Close button bkClose as "X"
> A: "General mailing list" <lazarus at lazarus.freepascal.org>
> Fecha: domingo, 25 de julio de 2010, 18:08
> Hello Lazarus-List,
>
> In a recent change (#26529) Dmitry changes the code in
> themes.pas to
> get a "stock icon" for close kind (a "X") which affects to
> TBitButton.
I think this is a fallback and should affect only those widgetsets that still do not implement TThemeServices.GetStockImage.
> Is this change intented ? If the answer is yes buttons in
> TBitButton
> are no more configurable via resources and btn_close.png is
> not needed
> anymore.
For a BitBtn of kind<>bkCustom a stock/themed glyph seems to be used and if you change it, it gets overriden by the stock/themed glyph.
But LCL stock images have still it own use, for example if you don't want to use the default themed glyphs or if the widgetset do not support glyphs or simply you want the same glyphs independent of the current theme/widgetset you can set a user defined function to override the themed glyphs
The way to override is by using the function GetDefaultBitBtnGlyph declared in unit buttons, something like:
[code]
function MyDefaultGlyphs(Kind: TBitBtnKind; var Handled: Boolean):TBitmap;
var
Glyph: TGraphic;
begin
case Kind of
bkClose:
begin
Glyph := GetLCLDefaultBtnGlyph(Kind);
Result := TBitmap.Create;
Result.assign(Glyph);
Glyph.Free;
end
else
result := nil;
end;
Handled := result<>nil;
end;
initialization
GetDefaultBitBtnGlyph := @MyDefaultGlyphs;
[/code]
Here we are using a LCL stock glyph thru GetLCLDefaultBtnGlyph(Kind), other way, one have to prepare it's own glyphs.
> Why only btn_close and no btn_ok and others ?
>
I think Dmitry could answer this better but I guess it's easier to programmatically paint a "X" than the others :)
Jesus Reyes A.
More information about the Lazarus
mailing list