From ece462c2a0fe7b026db0bd30971c3f757184cc83 Mon Sep 17 00:00:00 2001 From: mattias Date: Tue, 19 Jun 2012 12:07:54 +0000 Subject: [PATCH] gtk2: increased big icon size SM_CXICON,SM_CYICON to 128 git-svn-id: trunk@37691 - --- lcl/include/icon.inc | 1 + lcl/interfaces/gtk2/gtk2winapi.inc | 6 ++++- lcl/interfaces/gtk2/gtk2wsforms.pp | 42 ++++++++++++++++++++++++++++-- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/lcl/include/icon.inc b/lcl/include/icon.inc index cdfd0bb932..b899d8b398 100644 --- a/lcl/include/icon.inc +++ b/lcl/include/icon.inc @@ -1331,6 +1331,7 @@ begin end; function TIcon.ReleaseHandle: HICON; +// simply return the current handle and set to 0 without freeing handles begin HandleNeeded; Result := FSharedImage.ReleaseHandle; diff --git a/lcl/interfaces/gtk2/gtk2winapi.inc b/lcl/interfaces/gtk2/gtk2winapi.inc index 0fc3d69abc..a9afadb21d 100644 --- a/lcl/interfaces/gtk2/gtk2winapi.inc +++ b/lcl/interfaces/gtk2/gtk2winapi.inc @@ -5703,7 +5703,9 @@ begin end; SM_CXICON, SM_CYICON: - Result := 32; + // big icon size + // gtk recommends sizes 16,32,48. optional: 64 and 128 + Result := 128; SM_CXICONSPACING: begin //DebugLn('Trace:TODO: [TGtk2WidgetSet.GetSystemMetrics] --> SM_CXICONSPACING '); @@ -5826,6 +5828,8 @@ begin end; SM_CXSMICON, SM_CYSMICON: + // small icon size + // gtk recommends sizes 16,32,48. optional: 64 and 128 Result := 16; SM_CXSMSIZE: begin diff --git a/lcl/interfaces/gtk2/gtk2wsforms.pp b/lcl/interfaces/gtk2/gtk2wsforms.pp index 514399cebc..7ad2e3f66e 100644 --- a/lcl/interfaces/gtk2/gtk2wsforms.pp +++ b/lcl/interfaces/gtk2/gtk2wsforms.pp @@ -32,8 +32,8 @@ uses {$IFDEF HASX} Gdk2x, X, XLib, {$ENDIF} - Classes, LCLType, Controls, LMessages, InterfaceBase, - Graphics,Forms, Math, WSForms, WSProc, + Math, types, Classes, LazLogger, LCLType, Controls, LMessages, InterfaceBase, + Graphics, Forms, WSForms, WSProc, Gtk2Int, Gtk2Proc, Gtk2Def, Gtk2Extra, Gtk2Globals, Gtk2WSControls; type @@ -462,6 +462,15 @@ class procedure TGtk2WSCustomForm.SetIcon(const AForm: TCustomForm; const Small, Big: HICON); var List: PGList; + {$IFDEF EnableGtk2WndIconList} + Icon: TIcon; + CurSize: Integer; + i: Integer; + LastIndex: Integer; + OldChange: TNotifyEvent; + OldCurrent: Integer; + IconHnd: HICON; + {$ENDIF} begin if not WSCheckHandleAllocated(AForm, 'SetIcon') then Exit; @@ -469,10 +478,39 @@ begin if (AForm.Parent <> nil) or (AForm.ParentWindow <> 0) then Exit; List := nil; + {$IFDEF EnableGtk2WndIconList} + //debugln(['TGtk2WSCustomForm.SetIcon Form=',DbgSName(AForm)]); + Icon:=AForm.Icon; + if (Icon=nil) or Icon.Empty then + Icon:=Application.Icon; + if Assigned(Icon) and not Icon.Empty then + begin + CurSize:=16; + OldChange:=Icon.OnChange; + OldCurrent:=Icon.Current; + Icon.OnChange := nil; + LastIndex:=-1; + while CurSize<=256 do begin + i:=Icon.GetBestIndexForSize(Size(CurSize,CurSize)); + if (i>=0) and (LastIndex<>i) then begin + Icon.Current := i; + IconHnd:=Icon.ReleaseHandle; + if IconHnd <> 0 then + List := g_list_append(List, {%H-}PGdkPixbuf(IconHnd)); + //debugln(['TGtk2WSCustomForm.SetIcon adding ',CurSize]); + LastIndex:=i; + end; + CurSize:=CurSize*2; + end; + Icon.Current:=OldCurrent; + Icon.OnChange:=OldChange; + end; + {$ELSE} if Small <> 0 then List := g_list_append(List, {%H-}PGdkPixbuf(Small)); if Big <> 0 then List := g_list_append(List, {%H-}PGdkPixbuf(Big)); + {$ENDIF} gtk_window_set_icon_list({%H-}PGtkWindow(AForm.Handle), List); if List <> nil then g_list_free(List);