mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-06 13:45:56 +02:00
gtk2 intf: test for gtk_window_set_icon_from_file
git-svn-id: trunk@37706 -
This commit is contained in:
parent
15bf1e966f
commit
9ea3b4e0fe
@ -460,60 +460,93 @@ end;
|
|||||||
|
|
||||||
class procedure TGtk2WSCustomForm.SetIcon(const AForm: TCustomForm;
|
class procedure TGtk2WSCustomForm.SetIcon(const AForm: TCustomForm;
|
||||||
const Small, Big: HICON);
|
const Small, Big: HICON);
|
||||||
var
|
|
||||||
List: PGList;
|
procedure SetSmallBigIcon;
|
||||||
{$IFDEF EnableGtk2WndIconList}
|
var
|
||||||
Icon: TIcon;
|
List: PGList;
|
||||||
CurSize: Integer;
|
begin
|
||||||
i: Integer;
|
List := nil;
|
||||||
LastIndex: Integer;
|
if Small <> 0 then
|
||||||
OldChange: TNotifyEvent;
|
List := g_list_append(List, {%H-}PGdkPixbuf(Small));
|
||||||
OldCurrent: Integer;
|
if Big <> 0 then
|
||||||
IconHnd: HICON;
|
List := g_list_append(List, {%H-}PGdkPixbuf(Big));
|
||||||
|
gtk_window_set_icon_list({%H-}PGtkWindow(AForm.Handle), List);
|
||||||
|
if List <> nil
|
||||||
|
then g_list_free(List);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{$IFDEF Gtk2SetIconAll}
|
||||||
|
procedure SetAllIcons;
|
||||||
|
var
|
||||||
|
List: PGList;
|
||||||
|
Icon: TIcon;
|
||||||
|
CurSize: Integer;
|
||||||
|
i: Integer;
|
||||||
|
LastIndex: Integer;
|
||||||
|
OldChange: TNotifyEvent;
|
||||||
|
OldCurrent: Integer;
|
||||||
|
IconHnd: HICON;
|
||||||
|
begin
|
||||||
|
List := nil;
|
||||||
|
//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;
|
||||||
|
gtk_window_set_icon_list({%H-}PGtkWindow(AForm.Handle), List);
|
||||||
|
if List <> nil
|
||||||
|
then g_list_free(List);
|
||||||
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
|
{$IFDEF Gtk2SetIconFile}
|
||||||
|
procedure SetIconFromFile;
|
||||||
|
var
|
||||||
|
Filename: String;
|
||||||
|
begin
|
||||||
|
Filename:='test128x128.png';
|
||||||
|
debugln(['SetIconFromFile filename=',Filename]);
|
||||||
|
gtk_window_set_icon_from_file({%H-}PGtkWindow(AForm.Handle),PGChar(Filename),null);
|
||||||
|
debugln(['SetIconFromFile prg name="',g_get_prgname,'"']);
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if not WSCheckHandleAllocated(AForm, 'SetIcon')
|
if not WSCheckHandleAllocated(AForm, 'SetIcon')
|
||||||
then Exit;
|
then Exit;
|
||||||
|
|
||||||
if (AForm.Parent <> nil) or (AForm.ParentWindow <> 0) then Exit;
|
if (AForm.Parent <> nil) or (AForm.ParentWindow <> 0) then Exit;
|
||||||
|
|
||||||
List := nil;
|
{$IFDEF Gtk2SetIconAll}
|
||||||
{$IFDEF EnableGtk2WndIconList}
|
SetAllIcons;
|
||||||
//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}
|
{$ELSE}
|
||||||
if Small <> 0 then
|
{$IFDEF Gtk2SetIconFile}
|
||||||
List := g_list_append(List, {%H-}PGdkPixbuf(Small));
|
SetIconFromFile;
|
||||||
if Big <> 0 then
|
{$ELSE}
|
||||||
List := g_list_append(List, {%H-}PGdkPixbuf(Big));
|
SetSmallBigIcon;
|
||||||
|
{$ENDIF}
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
gtk_window_set_icon_list({%H-}PGtkWindow(AForm.Handle), List);
|
|
||||||
if List <> nil
|
|
||||||
then g_list_free(List);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TGtk2WSCustomForm.SetAlphaBlend(const ACustomForm: TCustomForm;
|
class procedure TGtk2WSCustomForm.SetAlphaBlend(const ACustomForm: TCustomForm;
|
||||||
|
Loading…
Reference in New Issue
Block a user