1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
uses ...,Graphics,gtk2,LCLType,glib2,Gtk2Def,gdk2pixbuf,Gtk2Int,gdk2,Gtk2Proc;
function GetStockImage(StockName:PgChar;GlyphStyle:TLazGtkStyle;Size:integer; out Image, Mask: HBitmap): Boolean;
var
GDIObj: PGDIObject;
Style: PGtkStyle;
IconSet: PGtkIconSet;
Pixbuf: PGDKPixbuf;
begin
Result := False;
Style := GetStyle(GlyphStyle);
if (Style = nil) or (not GTK_IS_STYLE(Style)) then
begin
Exit;
end;
IconSet := gtk_style_lookup_icon_set(Style, StockName);
if (IconSet = nil) then
begin
Exit;
end;
Pixbuf := gtk_icon_set_render_icon(IconSet, Style,GTK_TEXT_DIR_NONE, GTK_STATE_NORMAL, Size, GetStyleWidget(GlyphStyle), nil);
GDIObj := Gtk2Widgetset.NewGDIObject(gdiBitmap);
with GDIObj^ do
begin
GDIBitmapType := gbPixbuf;
visual := gdk_visual_get_system();
gdk_visual_ref(visual);
colormap := gdk_colormap_get_system();
gdk_colormap_ref(colormap);
GDIPixbufObject := Pixbuf;
end;
Image := HBitmap({%H-}PtrUInt(GDIObj));
Mask := 0;
Result := True;
end; |
Partager