mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-16 00:40:43 +01:00
gtk2: improve TGtk2ThemeServices.GetStockImage
git-svn-id: trunk@20078 -
This commit is contained in:
parent
1687773f6d
commit
7d94012801
@ -7608,15 +7608,13 @@ end;
|
||||
|
||||
function GetStyle(aStyle: TLazGtkStyle): PGTKStyle;
|
||||
begin
|
||||
if Styles=nil then exit(nil);
|
||||
if Styles = nil then Exit(nil);
|
||||
if aStyle in [lgsUserDefined] then
|
||||
RaiseGDBException('');// user styles are defined by name
|
||||
if StandardStyles[aStyle]<>nil then
|
||||
// already created
|
||||
Result:=StandardStyles[aStyle]^.Style
|
||||
else
|
||||
// create it
|
||||
Result:=GetStyleWithName(LazGtkStyleNames[aStyle]);
|
||||
RaiseGDBException(''); // user styles are defined by name
|
||||
if StandardStyles[aStyle] <> nil then // already created
|
||||
Result := StandardStyles[aStyle]^.Style
|
||||
else // create it
|
||||
Result := GetStyleWithName(LazGtkStyleNames[aStyle]);
|
||||
end;
|
||||
|
||||
procedure tooltip_window_style_set(Widget: PGtkWidget; PreviousStyle: PGtkStyle;
|
||||
|
||||
@ -136,6 +136,7 @@ function TGtk2ThemeServices.GetStockImage(StockID: LongInt; out Image, Mask: HBi
|
||||
var
|
||||
GDIObj: PGDIObject;
|
||||
StockName: PChar;
|
||||
Style: PGtkStyle;
|
||||
IconSet: PGtkIconSet;
|
||||
Pixbuf: PGDKPixbuf;
|
||||
begin
|
||||
@ -170,9 +171,17 @@ begin
|
||||
end;
|
||||
|
||||
if (StockID >= idButtonBase) and (StockID <= idDialogBase) then
|
||||
IconSet := gtk_style_lookup_icon_set(GetStyle(lgsButton), StockName)
|
||||
Style := GetStyle(lgsButton)
|
||||
else
|
||||
IconSet := gtk_style_lookup_icon_set(GetStyle(lgsWindow), StockName);
|
||||
Style := GetStyle(lgsWindow);
|
||||
|
||||
if (Style = nil) and not GTK_IS_STYLE(Style) then
|
||||
begin
|
||||
Result := inherited GetStockImage(StockID, Image, Mask);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
IconSet := gtk_style_lookup_icon_set(Style, StockName);
|
||||
|
||||
if (IconSet = nil) then
|
||||
begin
|
||||
@ -181,10 +190,10 @@ begin
|
||||
end;
|
||||
|
||||
if (StockID >= idButtonBase) and (StockID <= idDialogBase) then
|
||||
Pixbuf := gtk_icon_set_render_icon(IconSet, GetStyle(lgsbutton),
|
||||
Pixbuf := gtk_icon_set_render_icon(IconSet, Style,
|
||||
GTK_TEXT_DIR_NONE, GTK_STATE_NORMAL, GTK_ICON_SIZE_BUTTON, GetStyleWidget(lgsbutton), nil)
|
||||
else
|
||||
Pixbuf := gtk_icon_set_render_icon(IconSet, GetStyle(lgswindow),
|
||||
Pixbuf := gtk_icon_set_render_icon(IconSet, Style,
|
||||
GTK_TEXT_DIR_NONE, GTK_STATE_NORMAL, GTK_ICON_SIZE_DIALOG, GetStyleWidget(lgswindow), nil);
|
||||
|
||||
GDIObj := Gtk2Widgetset.NewGDIObject(gdiBitmap);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user