From: Mattia Barbon Date: Tue, 26 Mar 2002 21:54:23 +0000 (+0000) Subject: wxIconBundle implementation. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/f618020a15f1647a83aaeab1fe315f90497a9876 wxIconBundle implementation. wxTLW::SetIcons() properly implemented for wxMotif, wxGTK, wxMSW, wxX11, wxUniversal Placeholders that just call SetIcon for wxOS2 and wxMac. Regenerated makefiles. Added hardwired wxSYS_ICON_X/Y = 32 for wxGTK. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14809 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/distrib/msw/tmake/Makefile b/distrib/msw/tmake/Makefile index 5711fa40b8..c01444f793 100644 --- a/distrib/msw/tmake/Makefile +++ b/distrib/msw/tmake/Makefile @@ -23,6 +23,7 @@ all: $(MSW_MAKEFILES_DIR)/makefile.vc \ $(WXDIR)/src/os2/files.lst \ $(WXDIR)/src/mgl/files.lst \ $(WXDIR)/src/microwin/files.lst \ + $(WXDIR)/src/x11/files.lst \ $(WXDIR)/src/univ/files.lst \ $(WXDIR)/src/wxBase.dsp \ $(WXDIR)/src/wxWindows.dsp \ @@ -76,6 +77,9 @@ $(WXDIR)/src/os2/files.lst: os2.t filelist.txt wxwin.pro $(WXDIR)/src/univ/files.lst: univ.t filelist.txt wxwin.pro $(TMAKE) -t univ wxwin.pro -o $@ +$(WXDIR)/src/x11/files.lst: x11.t filelist.txt wxwin.pro + $(TMAKE) -t x11 wxwin.pro -o $@ + $(WXDIR)/src/wxBase.dsp: vc6base.t filelist.txt wxwin.pro $(TMAKE) -t vc6base wxwin.pro -o $@ diff --git a/distrib/msw/tmake/filelist.txt b/distrib/msw/tmake/filelist.txt index 9b5f0fcf79..16fa71ac9f 100644 --- a/distrib/msw/tmake/filelist.txt +++ b/distrib/msw/tmake/filelist.txt @@ -176,6 +176,7 @@ hash.cpp Common Base hashmap.cpp Common Base helpbase.cpp Common http.cpp Common Socket,Base +iconbndl.cpp Common imagall.cpp Common imagbmp.cpp Common image.cpp Common @@ -370,6 +371,7 @@ mimetype.cpp Unix Base,NotMac,NotMicro snglinst.cpp Unix Base threadpsx.cpp Unix Base,NotMac utilsunx.cpp Unix Base +utilsx11.cpp Unix NotMac,NotMGL,NotMicro bmpbuttn.cpp Univ button.cpp Univ @@ -845,6 +847,7 @@ helpbase.h WXH helphtml.h WXH helpwin.h WXH icon.h WXH +iconbndl.h WXH image.h WXH imaggif.h WXH imagiff.h WXH @@ -1427,6 +1430,7 @@ execute.h UnixH fontutil.h UnixH gsockunx.h UnixH Base mimetype.h UnixH Base +utilsx11.h UnixH file.h ProtoH Base ftp.h ProtoH Base diff --git a/include/wx/gtk/mdi.h b/include/wx/gtk/mdi.h index 3dd4ca6530..5dd2ae1762 100644 --- a/include/wx/gtk/mdi.h +++ b/include/wx/gtk/mdi.h @@ -161,7 +161,8 @@ public: #endif // no icon - void SetIcon( const wxIcon &icon ) { m_icon = icon; } + void SetIcon( const wxIcon &icon ) { m_icons = wxIconBundle( icon ); } + void SetIcons( const wxIconBundle &icons ) { m_icons = icons; } // no title void SetTitle( const wxString &title ); diff --git a/include/wx/gtk/toplevel.h b/include/wx/gtk/toplevel.h index c7bf590b52..a3b842add3 100644 --- a/include/wx/gtk/toplevel.h +++ b/include/wx/gtk/toplevel.h @@ -54,6 +54,7 @@ public: virtual void Iconize(bool iconize = TRUE); virtual bool IsIconized() const; virtual void SetIcon(const wxIcon& icon); + virtual void SetIcons(const wxIconBundle& icons); virtual void Restore(); virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL); @@ -71,6 +72,9 @@ public: // from both DoSetSize() and DoSetClientSize() virtual void DoMoveWindow(int x, int y, int width, int height); + // set the icon for this window + void DoSetIcon( const wxIcon& icon ); + // GTK callbacks virtual void GtkOnSize( int x, int y, int width, int height ); virtual void OnInternalIdle(); diff --git a/include/wx/gtk1/mdi.h b/include/wx/gtk1/mdi.h index 3dd4ca6530..5dd2ae1762 100644 --- a/include/wx/gtk1/mdi.h +++ b/include/wx/gtk1/mdi.h @@ -161,7 +161,8 @@ public: #endif // no icon - void SetIcon( const wxIcon &icon ) { m_icon = icon; } + void SetIcon( const wxIcon &icon ) { m_icons = wxIconBundle( icon ); } + void SetIcons( const wxIconBundle &icons ) { m_icons = icons; } // no title void SetTitle( const wxString &title ); diff --git a/include/wx/gtk1/toplevel.h b/include/wx/gtk1/toplevel.h index c7bf590b52..a3b842add3 100644 --- a/include/wx/gtk1/toplevel.h +++ b/include/wx/gtk1/toplevel.h @@ -54,6 +54,7 @@ public: virtual void Iconize(bool iconize = TRUE); virtual bool IsIconized() const; virtual void SetIcon(const wxIcon& icon); + virtual void SetIcons(const wxIconBundle& icons); virtual void Restore(); virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL); @@ -71,6 +72,9 @@ public: // from both DoSetSize() and DoSetClientSize() virtual void DoMoveWindow(int x, int y, int width, int height); + // set the icon for this window + void DoSetIcon( const wxIcon& icon ); + // GTK callbacks virtual void GtkOnSize( int x, int y, int width, int height ); virtual void OnInternalIdle(); diff --git a/include/wx/iconbndl.h b/include/wx/iconbndl.h new file mode 100644 index 0000000000..4022624360 --- /dev/null +++ b/include/wx/iconbndl.h @@ -0,0 +1,73 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: wx/iconbndl.h +// Purpose: wxIconBundle +// Author: Mattia barbon +// Modified by: +// Created: 23.03.02 +// RCS-ID: $Id$ +// Copyright: (c) Mattia Barbon +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_ICONBNDL_H_ +#define _WX_ICONBNDL_H_ + +#ifdef __GNUG__ +#pragma interface "iconbndl.h" +#endif + +#include "dynarray.h" +// for wxSize +#include "wx/gdicmn.h" + +class WXDLLEXPORT wxIcon; +class WXDLLEXPORT wxString; + +WX_DECLARE_EXPORTED_OBJARRAY( wxIcon, wxIconArray ); + +// this class can't load bitmaps of type wxBITMAP_TYPE_ICO_RESOURCE, +// if you need them, you have to load them manually and call +// wxIconCollection::AddIcon +class WXDLLEXPORT wxIconBundle +{ +public: + // default constructor + wxIconBundle() {} + // initializes the bundle with the icon(s) found in the file + wxIconBundle( const wxString& file, long type ) + { AddIcon( file, type ); } + // initializes the bundle with a single icon + wxIconBundle( const wxIcon& icon ) + { AddIcon( icon ); } + + const wxIconBundle& operator =( const wxIconBundle& ic ); + wxIconBundle( const wxIconBundle& ic ) + { *this = ic; } + + ~wxIconBundle() { DeleteIcons(); } + + // adds all the icons contained in the file to the collection, + // if the collection already contains icons with the same + // width and height, they are replaced + void AddIcon( const wxString& file, long type ); + // adds the icon to the collection, if the collection already + // contains an icon with the same width and height, it is + // replaced + void AddIcon( const wxIcon& icon ); + + // returns the icon with the given size; if no such icon exists, + // returns the icon with size wxSYS_ICON_[XY]; if no such icon exists, + // returns the first icon in the bundle + const wxIcon& GetIcon( const wxSize& size ) const; + // equivalent to GetIcon( wxSize( size, size ) ) + const wxIcon& GetIcon( wxCoord size = -1 ) const + { return GetIcon( wxSize( size, size ) ); } +private: + // delete all icons + void DeleteIcons(); +public: + wxIconArray m_icons; +}; + +#endif + // _WX_ICONBNDL_H_ diff --git a/include/wx/mac/toplevel.h b/include/wx/mac/toplevel.h index 06b677c50a..89f8cc9580 100644 --- a/include/wx/mac/toplevel.h +++ b/include/wx/mac/toplevel.h @@ -55,6 +55,7 @@ public: virtual void Iconize(bool iconize = TRUE); virtual bool IsIconized() const; virtual void SetIcon(const wxIcon& icon); + virtual void SetIcons(const wxIconBundle& icons) { SetIcon( icons.GetIcon( -1 ) ); } virtual void Restore(); virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL) { return FALSE; } diff --git a/include/wx/motif/frame.h b/include/wx/motif/frame.h index f0493408da..638e8da237 100644 --- a/include/wx/motif/frame.h +++ b/include/wx/motif/frame.h @@ -54,7 +54,8 @@ public: // Set icon virtual void SetIcon(const wxIcon& icon); - + virtual void SetIcons(const wxIconBundle& icons); + #if wxUSE_STATUSBAR virtual void PositionStatusBar(); #endif // wxUSE_STATUSBAR @@ -107,7 +108,10 @@ public: protected: // common part of all ctors void Init(); - + + // set a single icon for the frame + void DoSetIcon( const wxIcon& icon ); + //// Motif-specific WXWidget m_frameShell; WXWidget m_frameWidget; diff --git a/include/wx/motif/mdi.h b/include/wx/motif/mdi.h index 50bcf4f5d1..ee822b515f 100644 --- a/include/wx/motif/mdi.h +++ b/include/wx/motif/mdi.h @@ -152,7 +152,8 @@ public: // Set icon virtual void SetIcon(const wxIcon& icon); - + virtual void SetIcons(const wxIconBundle& icons ); + // Override wxFrame operations void CaptureMouse(); void ReleaseMouse(); diff --git a/include/wx/msw/toplevel.h b/include/wx/msw/toplevel.h index 358f7e55da..85bf00c072 100644 --- a/include/wx/msw/toplevel.h +++ b/include/wx/msw/toplevel.h @@ -55,6 +55,7 @@ public: virtual void Iconize(bool iconize = TRUE); virtual bool IsIconized() const; virtual void SetIcon(const wxIcon& icon); + virtual void SetIcons(const wxIconBundle& icons ); virtual void Restore(); virtual bool Show(bool show = TRUE); diff --git a/include/wx/os2/toplevel.h b/include/wx/os2/toplevel.h index c52efb6642..4224ed63b7 100644 --- a/include/wx/os2/toplevel.h +++ b/include/wx/os2/toplevel.h @@ -67,6 +67,8 @@ public: virtual void Restore(void); virtual void SendSizeEvent(void); virtual void SetIcon(const wxIcon& rIcon); + inline virtual void SetIcons(const wxIconBundle& icons) { SetIcon( icons.GetIcon( -1 ) ); } + virtual bool Show(bool bShow = TRUE); virtual bool ShowFullScreen( bool bShow ,long lStyle = wxFULLSCREEN_ALL diff --git a/include/wx/toplevel.h b/include/wx/toplevel.h index ae36a9fa42..ce058932b0 100644 --- a/include/wx/toplevel.h +++ b/include/wx/toplevel.h @@ -23,7 +23,7 @@ #endif #include "wx/window.h" -#include "wx/icon.h" +#include "wx/iconbndl.h" // the default names for various classs WXDLLEXPORT_DATA(extern const wxChar*) wxFrameNameStr; @@ -83,10 +83,16 @@ public: virtual bool IsIconized() const = 0; // get the frame icon - const wxIcon& GetIcon() const { return m_icon; } + const wxIcon& GetIcon() const { return m_icons.GetIcon( -1 ); } + + // get the frame icons + const wxIconBundle& GetIcons() const { return m_icons; } // set the frame icon - virtual void SetIcon(const wxIcon& icon) { m_icon = icon; } + virtual void SetIcon(const wxIcon& icon) { m_icons = wxIconBundle( icon ); } + + // set the frame icons + virtual void SetIcons(const wxIconBundle& icons ) { m_icons = icons; } // maximize the window to cover entire screen virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL) = 0; @@ -133,7 +139,7 @@ protected: bool SendIconizeEvent(bool iconized = TRUE); // the frame icon - wxIcon m_icon; + wxIconBundle m_icons; // test whether this window makes part of the frame // (menubar, toolbar and statusbar are excluded from automatic layout) diff --git a/include/wx/univ/toplevel.h b/include/wx/univ/toplevel.h index 1c4811f37b..a02df18726 100644 --- a/include/wx/univ/toplevel.h +++ b/include/wx/univ/toplevel.h @@ -123,7 +123,8 @@ public: virtual wxPoint GetClientAreaOrigin() const; virtual void DoGetClientSize(int *width, int *height) const; virtual void DoSetClientSize(int width, int height); - virtual void SetIcon(const wxIcon& icon); + virtual void SetIcon(const wxIcon& icon) { SetIcons( wxIconBundle( icon ) ); } + virtual void SetIcons(const wxIconBundle& icons); // implementation from now on // -------------------------- diff --git a/include/wx/unix/utilsx11.h b/include/wx/unix/utilsx11.h new file mode 100644 index 0000000000..44353ef31f --- /dev/null +++ b/include/wx/unix/utilsx11.h @@ -0,0 +1,33 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: wx/unix/utilsx11.h +// Purpose: Miscellaneous X11 functions +// Author: Mattia Barbon +// Modified by: +// Created: 25.03.02 +// RCS-ID: $Id$ +// Copyright: (c) wxWindows team +// Licence: wxWindows license +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_UNIX_UTILSX11_H_ +#define _WX_UNIX_UTILSX11_H_ + +#include "wx/defs.h" + +#if defined(__WXMOTIF__) || defined(__WXGTK__) || defined(__WXX11__) + +#if defined(__WXGTK__) +typedef void WXDisplay; +typedef void* WXWindow; +#endif + +class wxIconBundle; + +void wxSetIconsX11( WXDisplay* display, WXWindow window, + const wxIconBundle& ib ); + +#endif + // __WXMOTIF__, __WXGTK__, __WXX11__ + +#endif + // _WX_UNIX_UTILSX11_H_ diff --git a/include/wx/volume.h b/include/wx/volume.h index 2c1a821fa5..87b9a27ad7 100644 --- a/include/wx/volume.h +++ b/include/wx/volume.h @@ -65,7 +65,8 @@ enum wxFSIconType wxFS_VOL_ICO_MAX }; -WX_DECLARE_EXPORTED_OBJARRAY(wxIcon, wxIconArray); +// already in wx/iconbndl.h +// WX_DECLARE_EXPORTED_OBJARRAY(wxIcon, wxIconArray); #endif // wxUSE_GUI diff --git a/include/wx/x11/toplevel.h b/include/wx/x11/toplevel.h index 4ca3ac2df1..74f7411c4f 100644 --- a/include/wx/x11/toplevel.h +++ b/include/wx/x11/toplevel.h @@ -54,7 +54,8 @@ public: virtual bool IsMaximized() const; virtual void Iconize(bool iconize = TRUE); virtual bool IsIconized() const; - virtual void SetIcon(const wxIcon& icon); + virtual void SetIcon(const wxIcon& icon) { SetIcons( wxIconBundle( icon ) ); } + virtual void SetIcons(const wxIconBundle& icons); virtual void Restore(); virtual bool Show( bool show = TRUE ); @@ -72,6 +73,9 @@ protected: // common part of all ctors void Init(); + // set the icon for the window + void DoSetIcon( const wxIcon& icon ); + // For implementation purposes - sometimes decorations make the // client area smaller virtual wxPoint GetClientAreaOrigin() const; diff --git a/src/common/iconbndl.cpp b/src/common/iconbndl.cpp new file mode 100644 index 0000000000..13a5d84d34 --- /dev/null +++ b/src/common/iconbndl.cpp @@ -0,0 +1,114 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: iconbndl.cpp +// Purpose: wxIconBundle +// Author: Mattia Barbon +// Created: 23.03.2002 +// RCS-ID: $Id$ +// Copyright: (c) Mattia barbon +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ + #pragma implementation "iconbndl.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/settings.h" + #include "wx/image.h" + #include "wx/icon.h" + #include "wx/log.h" + #include "wx/intl.h" +#endif + +#include "wx/iconbndl.h" +#include "wx/arrimpl.cpp" + +WX_DEFINE_OBJARRAY(wxIconArray) + +const wxIconBundle& wxIconBundle::operator =( const wxIconBundle& ic ) +{ + if( this == &ic ) return *this; + + size_t i, max = ic.m_icons.GetCount(); + + DeleteIcons(); + for( i = 0; i < max; ++i ) + m_icons.Add( ic.m_icons[i] ); + + return *this; +} + +void wxIconBundle::DeleteIcons() +{ + m_icons.Empty(); +} + +void wxIconBundle::AddIcon( const wxString& file, long type ) +{ + size_t count = wxImage::GetImageCount( file, type ); + size_t i; + wxImage image; + wxIcon tmp; + + for( i = 0; i < count; ++i ) + { + if( !image.LoadFile( file, type, i ) ) + { + wxLogError( _("Failed to load image %d from file '%s'."), + i, file.c_str() ); + continue; + } + + tmp.CopyFromBitmap( wxBitmap( image ) ); + AddIcon( tmp ); + } +} + +const wxIcon& wxIconBundle::GetIcon( const wxSize& size ) const +{ + size_t i, max = m_icons.GetCount(); + wxCoord sysX = wxSystemSettings::GetMetric( wxSYS_ICON_X ), + sysY = wxSystemSettings::GetMetric( wxSYS_ICON_Y ); + wxIcon* sysIcon = 0; + + for( i = 0; i < max; ++i ) + { + wxCoord sx = m_icons[i].GetWidth(), sy = m_icons[i].GetHeight(); + // requested size + if( sx == size.x && sy == size.y ) + return m_icons[i]; + // keep track if there is a system-size icon + if( sx == sysX && sy == sysY ) + sysIcon = &m_icons[i]; + } + + // return the system-sized icon if we've got one + if( sysIcon ) return *sysIcon; + // return the first icon, if we have one + return max > 0 ? m_icons[0] : wxNullIcon; +} + +void wxIconBundle::AddIcon( const wxIcon& icon ) +{ + size_t i, max = m_icons.GetCount(); + + for( i = 0; i < max; ++i ) + { + wxIcon& tmp = m_icons[i]; + if( tmp.GetWidth() == icon.GetWidth() && + tmp.GetHeight() == icon.GetHeight() ) + { + tmp = icon; + return; + } + } + + m_icons.Add( icon ); +} diff --git a/src/gtk/files.lst b/src/gtk/files.lst index 7a19cc618d..991ca2f413 100644 --- a/src/gtk/files.lst +++ b/src/gtk/files.lst @@ -104,6 +104,7 @@ ALL_SOURCES = \ common/hashmap.cpp \ common/helpbase.cpp \ common/http.cpp \ + common/iconbndl.cpp \ common/imagall.cpp \ common/imagbmp.cpp \ common/image.cpp \ @@ -244,6 +245,7 @@ ALL_SOURCES = \ unix/snglinst.cpp \ unix/threadpsx.cpp \ unix/utilsunx.cpp \ + unix/utilsx11.cpp \ html/helpctrl.cpp \ html/helpdata.cpp \ html/helpfrm.cpp \ @@ -367,6 +369,7 @@ ALL_HEADERS = \ helphtml.h \ helpwin.h \ icon.h \ + iconbndl.h \ imagbmp.h \ image.h \ imaggif.h \ @@ -604,6 +607,7 @@ ALL_HEADERS = \ unix/fontutil.h \ unix/gsockunx.h \ unix/mimetype.h \ + unix/utilsx11.h \ html/forcelnk.h \ html/helpctrl.h \ html/helpdata.h \ @@ -680,6 +684,7 @@ COMMONOBJS = \ hashmap.o \ helpbase.o \ http.o \ + iconbndl.o \ imagall.o \ imagbmp.o \ image.o \ @@ -947,7 +952,8 @@ UNIXOBJS = \ mimetype.o \ snglinst.o \ threadpsx.o \ - utilsunx.o + utilsunx.o \ + utilsx11.o HTMLOBJS = \ helpctrl.o \ diff --git a/src/gtk/settings.cpp b/src/gtk/settings.cpp index 5bcfff6c21..9aed45b5a9 100644 --- a/src/gtk/settings.cpp +++ b/src/gtk/settings.cpp @@ -349,7 +349,9 @@ int wxSystemSettingsNative::GetMetric( wxSystemMetric index ) // VZ: is there any way to get the cursor size with GDK? case wxSYS_CURSOR_X: return 16; case wxSYS_CURSOR_Y: return 16; - + // MBN: ditto for icons + case wxSYS_ICON_X: return 32; + case wxSYS_ICON_Y: return 32; default: wxFAIL_MSG( wxT("wxSystemSettings::GetMetric not fully implemented") ); return 0; diff --git a/src/gtk/toplevel.cpp b/src/gtk/toplevel.cpp index dbe2a3a928..6484fa7f00 100644 --- a/src/gtk/toplevel.cpp +++ b/src/gtk/toplevel.cpp @@ -38,6 +38,8 @@ #include "wx/gtk/win_gtk.h" +#include "wx/unix/utilsx11.h" + // ---------------------------------------------------------------------------- // idle system // ---------------------------------------------------------------------------- @@ -814,13 +816,9 @@ void wxTopLevelWindowGTK::SetTitle( const wxString &title ) gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() ); } -void wxTopLevelWindowGTK::SetIcon( const wxIcon &icon ) +void wxTopLevelWindowGTK::DoSetIcon( const wxIcon &icon ) { - wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - - wxTopLevelWindowBase::SetIcon(icon); - - if ( !m_icon.Ok() ) + if ( !icon.Ok() ) return; if (!m_widget->window) @@ -833,6 +831,24 @@ void wxTopLevelWindowGTK::SetIcon( const wxIcon &icon ) gdk_window_set_icon( m_widget->window, (GdkWindow *) NULL, icon.GetPixmap(), bm ); } +void wxTopLevelWindowGTK::SetIcon( const wxIcon &icon ) +{ + SetIcons( wxIconBundle( icon ) ); +} + +void wxTopLevelWindowGTK::SetIcons( const wxIconBundle &icons ) +{ + wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); + GdkWindow* window = m_widget->window; + wxCHECK_RET( window, _T("window not created yet - can't set icon") ); + + wxTopLevelWindowBase::SetIcons( icons ); + + DoSetIcon( icons.GetIcon( -1 ) ); + wxSetIconsX11( (WXDisplay*)GDK_WINDOW_XDISPLAY( window ), + (WXWindow)GDK_WINDOW_XWINDOW( window ), icons ); +} + // ---------------------------------------------------------------------------- // frame state: maximized/iconized/normal // ---------------------------------------------------------------------------- diff --git a/src/gtk1/files.lst b/src/gtk1/files.lst index 7a19cc618d..991ca2f413 100644 --- a/src/gtk1/files.lst +++ b/src/gtk1/files.lst @@ -104,6 +104,7 @@ ALL_SOURCES = \ common/hashmap.cpp \ common/helpbase.cpp \ common/http.cpp \ + common/iconbndl.cpp \ common/imagall.cpp \ common/imagbmp.cpp \ common/image.cpp \ @@ -244,6 +245,7 @@ ALL_SOURCES = \ unix/snglinst.cpp \ unix/threadpsx.cpp \ unix/utilsunx.cpp \ + unix/utilsx11.cpp \ html/helpctrl.cpp \ html/helpdata.cpp \ html/helpfrm.cpp \ @@ -367,6 +369,7 @@ ALL_HEADERS = \ helphtml.h \ helpwin.h \ icon.h \ + iconbndl.h \ imagbmp.h \ image.h \ imaggif.h \ @@ -604,6 +607,7 @@ ALL_HEADERS = \ unix/fontutil.h \ unix/gsockunx.h \ unix/mimetype.h \ + unix/utilsx11.h \ html/forcelnk.h \ html/helpctrl.h \ html/helpdata.h \ @@ -680,6 +684,7 @@ COMMONOBJS = \ hashmap.o \ helpbase.o \ http.o \ + iconbndl.o \ imagall.o \ imagbmp.o \ image.o \ @@ -947,7 +952,8 @@ UNIXOBJS = \ mimetype.o \ snglinst.o \ threadpsx.o \ - utilsunx.o + utilsunx.o \ + utilsx11.o HTMLOBJS = \ helpctrl.o \ diff --git a/src/gtk1/settings.cpp b/src/gtk1/settings.cpp index 5bcfff6c21..9aed45b5a9 100644 --- a/src/gtk1/settings.cpp +++ b/src/gtk1/settings.cpp @@ -349,7 +349,9 @@ int wxSystemSettingsNative::GetMetric( wxSystemMetric index ) // VZ: is there any way to get the cursor size with GDK? case wxSYS_CURSOR_X: return 16; case wxSYS_CURSOR_Y: return 16; - + // MBN: ditto for icons + case wxSYS_ICON_X: return 32; + case wxSYS_ICON_Y: return 32; default: wxFAIL_MSG( wxT("wxSystemSettings::GetMetric not fully implemented") ); return 0; diff --git a/src/gtk1/toplevel.cpp b/src/gtk1/toplevel.cpp index dbe2a3a928..6484fa7f00 100644 --- a/src/gtk1/toplevel.cpp +++ b/src/gtk1/toplevel.cpp @@ -38,6 +38,8 @@ #include "wx/gtk/win_gtk.h" +#include "wx/unix/utilsx11.h" + // ---------------------------------------------------------------------------- // idle system // ---------------------------------------------------------------------------- @@ -814,13 +816,9 @@ void wxTopLevelWindowGTK::SetTitle( const wxString &title ) gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() ); } -void wxTopLevelWindowGTK::SetIcon( const wxIcon &icon ) +void wxTopLevelWindowGTK::DoSetIcon( const wxIcon &icon ) { - wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - - wxTopLevelWindowBase::SetIcon(icon); - - if ( !m_icon.Ok() ) + if ( !icon.Ok() ) return; if (!m_widget->window) @@ -833,6 +831,24 @@ void wxTopLevelWindowGTK::SetIcon( const wxIcon &icon ) gdk_window_set_icon( m_widget->window, (GdkWindow *) NULL, icon.GetPixmap(), bm ); } +void wxTopLevelWindowGTK::SetIcon( const wxIcon &icon ) +{ + SetIcons( wxIconBundle( icon ) ); +} + +void wxTopLevelWindowGTK::SetIcons( const wxIconBundle &icons ) +{ + wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); + GdkWindow* window = m_widget->window; + wxCHECK_RET( window, _T("window not created yet - can't set icon") ); + + wxTopLevelWindowBase::SetIcons( icons ); + + DoSetIcon( icons.GetIcon( -1 ) ); + wxSetIconsX11( (WXDisplay*)GDK_WINDOW_XDISPLAY( window ), + (WXWindow)GDK_WINDOW_XWINDOW( window ), icons ); +} + // ---------------------------------------------------------------------------- // frame state: maximized/iconized/normal // ---------------------------------------------------------------------------- diff --git a/src/mac/carbon/files.lst b/src/mac/carbon/files.lst index bf5ba746c0..d02a542c82 100644 --- a/src/mac/carbon/files.lst +++ b/src/mac/carbon/files.lst @@ -101,6 +101,7 @@ ALL_SOURCES = \ common/hashmap.cpp \ common/helpbase.cpp \ common/http.cpp \ + common/iconbndl.cpp \ common/imagall.cpp \ common/imagbmp.cpp \ common/image.cpp \ @@ -374,6 +375,7 @@ ALL_HEADERS = \ helphtml.h \ helpwin.h \ icon.h \ + iconbndl.h \ imagbmp.h \ image.h \ imaggif.h \ @@ -631,6 +633,7 @@ ALL_HEADERS = \ unix/fontutil.h \ unix/gsockunx.h \ unix/mimetype.h \ + unix/utilsx11.h \ html/forcelnk.h \ html/helpctrl.h \ html/helpdata.h \ @@ -707,6 +710,7 @@ COMMONOBJS = \ hashmap.o \ helpbase.o \ http.o \ + iconbndl.o \ imagall.o \ imagbmp.o \ image.o \ diff --git a/src/mac/files.lst b/src/mac/files.lst index bf5ba746c0..d02a542c82 100644 --- a/src/mac/files.lst +++ b/src/mac/files.lst @@ -101,6 +101,7 @@ ALL_SOURCES = \ common/hashmap.cpp \ common/helpbase.cpp \ common/http.cpp \ + common/iconbndl.cpp \ common/imagall.cpp \ common/imagbmp.cpp \ common/image.cpp \ @@ -374,6 +375,7 @@ ALL_HEADERS = \ helphtml.h \ helpwin.h \ icon.h \ + iconbndl.h \ imagbmp.h \ image.h \ imaggif.h \ @@ -631,6 +633,7 @@ ALL_HEADERS = \ unix/fontutil.h \ unix/gsockunx.h \ unix/mimetype.h \ + unix/utilsx11.h \ html/forcelnk.h \ html/helpctrl.h \ html/helpdata.h \ @@ -707,6 +710,7 @@ COMMONOBJS = \ hashmap.o \ helpbase.o \ http.o \ + iconbndl.o \ imagall.o \ imagbmp.o \ image.o \ diff --git a/src/makeprog.vc b/src/makeprog.vc index 3559c1ca82..1a4c5ef2bf 100644 --- a/src/makeprog.vc +++ b/src/makeprog.vc @@ -41,7 +41,7 @@ wxUSE_GUI=1 !if "$(wxUSE_GUI)" == "1" #!if "$(WXUSINGDLL)" == "1" -#DUMMYOBJ= +DUMMYOBJ= #!endif $(PROGRAM).exe: $(WXLIB) $(OBJECTS) $(PROGRAM).res diff --git a/src/mgl/files.lst b/src/mgl/files.lst index 63dcae44fb..6cbdd7545c 100644 --- a/src/mgl/files.lst +++ b/src/mgl/files.lst @@ -104,6 +104,7 @@ ALL_SOURCES = \ common/hashmap.cpp \ common/helpbase.cpp \ common/http.cpp \ + common/iconbndl.cpp \ common/imagall.cpp \ common/imagbmp.cpp \ common/image.cpp \ @@ -329,6 +330,7 @@ ALL_HEADERS = \ helphtml.h \ helpwin.h \ icon.h \ + iconbndl.h \ imagbmp.h \ image.h \ imaggif.h \ @@ -504,6 +506,7 @@ ALL_HEADERS = \ unix/fontutil.h \ unix/gsockunx.h \ unix/mimetype.h \ + unix/utilsx11.h \ html/forcelnk.h \ html/helpctrl.h \ html/helpdata.h \ @@ -581,6 +584,7 @@ COMMONOBJS = \ hashmap.o \ helpbase.o \ http.o \ + iconbndl.o \ imagall.o \ imagbmp.o \ image.o \ diff --git a/src/microwin/files.lst b/src/microwin/files.lst index 016627c6e9..bc64109b37 100644 --- a/src/microwin/files.lst +++ b/src/microwin/files.lst @@ -101,6 +101,7 @@ ALL_SOURCES = \ common/hashmap.cpp \ common/helpbase.cpp \ common/http.cpp \ + common/iconbndl.cpp \ common/imagall.cpp \ common/imagbmp.cpp \ common/image.cpp \ @@ -329,6 +330,7 @@ ALL_HEADERS = \ helphtml.h \ helpwin.h \ icon.h \ + iconbndl.h \ imagbmp.h \ image.h \ imaggif.h \ @@ -598,6 +600,7 @@ ALL_HEADERS = \ unix/fontutil.h \ unix/gsockunx.h \ unix/mimetype.h \ + unix/utilsx11.h \ html/forcelnk.h \ html/helpctrl.h \ html/helpdata.h \ @@ -674,6 +677,7 @@ COMMONOBJS = \ hashmap.o \ helpbase.o \ http.o \ + iconbndl.o \ imagall.o \ imagbmp.o \ image.o \ diff --git a/src/motif/files.lst b/src/motif/files.lst index 8664bf6791..f704083c0d 100644 --- a/src/motif/files.lst +++ b/src/motif/files.lst @@ -103,6 +103,7 @@ ALL_SOURCES = \ common/hashmap.cpp \ common/helpbase.cpp \ common/http.cpp \ + common/iconbndl.cpp \ common/imagall.cpp \ common/imagbmp.cpp \ common/image.cpp \ @@ -235,6 +236,7 @@ ALL_SOURCES = \ unix/snglinst.cpp \ unix/threadpsx.cpp \ unix/utilsunx.cpp \ + unix/utilsx11.cpp \ html/helpctrl.cpp \ html/helpdata.cpp \ html/helpfrm.cpp \ @@ -358,6 +360,7 @@ ALL_HEADERS = \ helphtml.h \ helpwin.h \ icon.h \ + iconbndl.h \ imagbmp.h \ image.h \ imaggif.h \ @@ -592,6 +595,7 @@ ALL_HEADERS = \ unix/fontutil.h \ unix/gsockunx.h \ unix/mimetype.h \ + unix/utilsx11.h \ html/forcelnk.h \ html/helpctrl.h \ html/helpdata.h \ @@ -668,6 +672,7 @@ COMMONOBJS = \ hashmap.o \ helpbase.o \ http.o \ + iconbndl.o \ imagall.o \ imagbmp.o \ image.o \ @@ -852,7 +857,8 @@ UNIXOBJS = \ mimetype.o \ snglinst.o \ threadpsx.o \ - utilsunx.o + utilsunx.o \ + utilsx11.o HTMLOBJS = \ helpctrl.o \ diff --git a/src/motif/frame.cpp b/src/motif/frame.cpp index cd5b22c681..5092f9fa1a 100644 --- a/src/motif/frame.cpp +++ b/src/motif/frame.cpp @@ -50,6 +50,7 @@ #include #include +#include #if XmVersion >= 1002 #include #else @@ -73,6 +74,7 @@ #endif #include "wx/motif/private.h" +#include "wx/unix/utilsx11.h" // ---------------------------------------------------------------------------- // private functions @@ -627,10 +629,8 @@ void wxFrame::SetTitle(const wxString& title) NULL); } -void wxFrame::SetIcon(const wxIcon& icon) +void wxFrame::DoSetIcon(const wxIcon& icon) { - m_icon = icon; - if (!m_frameShell) return; @@ -640,6 +640,23 @@ void wxFrame::SetIcon(const wxIcon& icon) XtVaSetValues((Widget) m_frameShell, XtNiconPixmap, icon.GetPixmap(), NULL); } +void wxFrame::SetIcon(const wxIcon& icon) +{ + SetIcons( wxIconBundle( icon ) ); +} + +void wxFrame::SetIcons(const wxIconBundle& icons) +{ + wxFrameBase::SetIcons( icons ); + + if (!m_frameShell) + return; + + DoSetIcon( m_icons.GetIcon( -1 ) ); + wxSetIconsX11(GetXDisplay(), + (WXWindow) XtWindow( (Widget) m_frameShell ), icons); +} + void wxFrame::PositionStatusBar() { if (!m_frameStatusBar) diff --git a/src/motif/mdi.cpp b/src/motif/mdi.cpp index a62339fce3..4fa16b4cfe 100644 --- a/src/motif/mdi.cpp +++ b/src/motif/mdi.cpp @@ -527,14 +527,20 @@ void wxMDIChildFrame::SetMenuBar(wxMenuBar *menuBar) // Set icon void wxMDIChildFrame::SetIcon(const wxIcon& icon) { - m_icon = icon; - if (m_icon.Ok()) + m_icons = wxIconBundle( icon ); + + if (icon.Ok()) { // Not appropriate since there are no icons in // a tabbed window } } +void wxMDIChildFrame::SetIcons(const wxIconBundle& icons) +{ + m_icons = icons; +} + void wxMDIChildFrame::SetTitle(const wxString& title) { m_title = title; diff --git a/src/msw/files.lst b/src/msw/files.lst index fcd6a7f740..721ee5869b 100644 --- a/src/msw/files.lst +++ b/src/msw/files.lst @@ -88,6 +88,7 @@ ALL_SOURCES = \ common/hashmap.cpp \ common/helpbase.cpp \ common/http.cpp \ + common/iconbndl.cpp \ common/imagall.cpp \ common/imagbmp.cpp \ common/image.cpp \ @@ -389,6 +390,7 @@ ALL_HEADERS = \ helphtml.h \ helpwin.h \ icon.h \ + iconbndl.h \ imagbmp.h \ image.h \ imaggif.h \ @@ -666,6 +668,7 @@ ALL_HEADERS = \ unix/fontutil.h \ unix/gsockunx.h \ unix/mimetype.h \ + unix/utilsx11.h \ html/forcelnk.h \ html/helpctrl.h \ html/helpdata.h \ @@ -742,6 +745,7 @@ COMMONOBJS = \ hashmap.o \ helpbase.o \ http.o \ + iconbndl.o \ imagall.o \ imagbmp.o \ image.o \ diff --git a/src/msw/frame.cpp b/src/msw/frame.cpp index c4ab391cd8..f6344c7c0c 100644 --- a/src/msw/frame.cpp +++ b/src/msw/frame.cpp @@ -602,8 +602,9 @@ bool wxFrame::HandlePaint() #ifndef __WXMICROWIN__ if ( m_iconized ) { - HICON hIcon = m_icon.Ok() ? GetHiconOf(m_icon) - : (HICON)GetDefaultIcon(); + const wxIcon& icon = GetIcon(); + HICON hIcon = icon.Ok() ? GetHiconOf(icon) + : (HICON)GetDefaultIcon(); // Hold a pointer to the dc so long as the OnPaint() message // is being processed @@ -837,8 +838,9 @@ long wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) case WM_QUERYDRAGICON: { - HICON hIcon = m_icon.Ok() ? GetHiconOf(m_icon) - : (HICON)GetDefaultIcon(); + const wxIcon& icon = GetIcon(); + HICON hIcon = icon.Ok() ? GetHiconOf(icon) + : (HICON)GetDefaultIcon(); rc = (long)hIcon; processed = rc != 0; } diff --git a/src/msw/makefile.b32 b/src/msw/makefile.b32 index 6dae7028c8..8f28aa1b84 100644 --- a/src/msw/makefile.b32 +++ b/src/msw/makefile.b32 @@ -171,6 +171,7 @@ COMMONOBJS = \ $(MSWDIR)\hashmap.obj \ $(MSWDIR)\helpbase.obj \ $(MSWDIR)\http.obj \ + $(MSWDIR)\iconbndl.obj \ $(MSWDIR)\imagall.obj \ $(MSWDIR)\imagbmp.obj \ $(MSWDIR)\image.obj \ @@ -763,6 +764,8 @@ $(MSWDIR)\helpbase.obj: $(COMMDIR)\helpbase.$(SRCSUFF) $(MSWDIR)\http.obj: $(COMMDIR)\http.$(SRCSUFF) +$(MSWDIR)\iconbndl.obj: $(COMMDIR)\iconbndl.$(SRCSUFF) + $(MSWDIR)\imagall.obj: $(COMMDIR)\imagall.$(SRCSUFF) $(MSWDIR)\imagbmp.obj: $(COMMDIR)\imagbmp.$(SRCSUFF) diff --git a/src/msw/makefile.bcc b/src/msw/makefile.bcc index e45dda7353..fbe678ad42 100644 --- a/src/msw/makefile.bcc +++ b/src/msw/makefile.bcc @@ -157,6 +157,7 @@ COMMONOBJS = \ $(MSWDIR)\hash.obj \ $(MSWDIR)\hashmap.obj \ $(MSWDIR)\helpbase.obj \ + $(MSWDIR)\iconbndl.obj \ $(MSWDIR)\imagall.obj \ $(MSWDIR)\imagbmp.obj \ $(MSWDIR)\image.obj \ @@ -615,6 +616,8 @@ $(MSWDIR)\hashmap.obj: $(COMMDIR)\hashmap.$(SRCSUFF) $(MSWDIR)\helpbase.obj: $(COMMDIR)\helpbase.$(SRCSUFF) +$(MSWDIR)\iconbndl.obj: $(COMMDIR)\iconbndl.$(SRCSUFF) + $(MSWDIR)\imagall.obj: $(COMMDIR)\imagall.$(SRCSUFF) $(MSWDIR)\imagbmp.obj: $(COMMDIR)\imagbmp.$(SRCSUFF) diff --git a/src/msw/makefile.dos b/src/msw/makefile.dos index 5fc40b46f4..c318f46e54 100644 --- a/src/msw/makefile.dos +++ b/src/msw/makefile.dos @@ -142,6 +142,7 @@ COMMONOBJS1 = \ $(COMMDIR)\hash.obj \ $(COMMDIR)\hashmap.obj \ $(COMMDIR)\helpbase.obj \ + $(COMMDIR)\iconbndl.obj \ $(COMMDIR)\imagall.obj \ $(COMMDIR)\imagbmp.obj \ $(COMMDIR)\image.obj \ @@ -1057,6 +1058,11 @@ $(COMMDIR)/helpbase.obj: $*.$(SRCSUFF) $(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF) << +$(COMMDIR)/iconbndl.obj: $*.$(SRCSUFF) + cl @<< +$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF) +<< + $(COMMDIR)/imagall.obj: $*.$(SRCSUFF) cl @<< $(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF) diff --git a/src/msw/makefile.g95 b/src/msw/makefile.g95 index ca3ac9e5f2..a8b7b186b6 100644 --- a/src/msw/makefile.g95 +++ b/src/msw/makefile.g95 @@ -210,6 +210,7 @@ COMMONOBJS = \ $(COMMDIR)/geometry.$(OBJSUFF) \ $(COMMDIR)/gifdecod.$(OBJSUFF) \ $(COMMDIR)/helpbase.$(OBJSUFF) \ + $(COMMDIR)/iconbndl.$(OBJSUFF) \ $(COMMDIR)/imagall.$(OBJSUFF) \ $(COMMDIR)/imagbmp.$(OBJSUFF) \ $(COMMDIR)/image.$(OBJSUFF) \ diff --git a/src/msw/makefile.sc b/src/msw/makefile.sc index 19dc30fb14..a8580feab3 100644 --- a/src/msw/makefile.sc +++ b/src/msw/makefile.sc @@ -115,6 +115,7 @@ COMMONOBJS = \ $(COMMDIR)\hashmap.obj \ $(COMMDIR)\helpbase.obj \ $(COMMDIR)\http.obj \ + $(COMMDIR)\iconbndl.obj \ $(COMMDIR)\imagall.obj \ $(COMMDIR)\imagbmp.obj \ $(COMMDIR)\image.obj \ diff --git a/src/msw/makefile.vc b/src/msw/makefile.vc index 3a9008760a..2224446d42 100644 --- a/src/msw/makefile.vc +++ b/src/msw/makefile.vc @@ -191,6 +191,7 @@ COMMONOBJS = \ $(COMMDIR)\$D\hashmap.obj \ $(COMMDIR)\$D\helpbase.obj \ $(COMMDIR)\$D\http.obj \ + $(COMMDIR)\$D\iconbndl.obj \ $(COMMDIR)\$D\imagall.obj \ $(COMMDIR)\$D\imagbmp.obj \ $(COMMDIR)\$D\image.obj \ diff --git a/src/msw/makefile.wat b/src/msw/makefile.wat index 42f7bfeb8b..555b216041 100644 --- a/src/msw/makefile.wat +++ b/src/msw/makefile.wat @@ -153,6 +153,7 @@ COMMONOBJS = & hashmap.obj & helpbase.obj & http.obj & + iconbndl.obj & imagall.obj & imagbmp.obj & image.obj & @@ -903,6 +904,9 @@ helpbase.obj: $(COMMDIR)\helpbase.cpp http.obj: $(COMMDIR)\http.cpp *$(CCC) $(CPPFLAGS) $(IFLAGS) $< +iconbndl.obj: $(COMMDIR)\iconbndl.cpp + *$(CCC) $(CPPFLAGS) $(IFLAGS) $< + imagall.obj: $(COMMDIR)\imagall.cpp *$(CCC) $(CPPFLAGS) $(IFLAGS) $< diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index 0c5ef7d3b3..ae7a11fd57 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -584,14 +584,26 @@ bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style) void wxTopLevelWindowMSW::SetIcon(const wxIcon& icon) { - // this sets m_icon - wxTopLevelWindowBase::SetIcon(icon); + SetIcons( wxIconBundle( icon ) ); +} + +void wxTopLevelWindowMSW::SetIcons(const wxIconBundle& icons) +{ + wxTopLevelWindowBase::SetIcons(icons); #if defined(__WIN95__) && !defined(__WXMICROWIN__) - if ( m_icon.Ok() ) + const wxIcon& sml = icons.GetIcon( wxSize( 16, 16 ) ); + if( sml.Ok() && sml.GetWidth() == 16 && sml.GetHeight() == 16 ) + { + ::SendMessage( GetHwndOf( this ), WM_SETICON, ICON_SMALL, + (LPARAM)GetHiconOf(sml) ); + } + + const wxIcon& big = icons.GetIcon( wxSize( 32, 32 ) ); + if( big.Ok() && big.GetWidth() == 32 && big.GetHeight() == 32 ) { - ::SendMessage(GetHwnd(), WM_SETICON, - (WPARAM)TRUE, (LPARAM)GetHiconOf(m_icon)); + ::SendMessage( GetHwndOf( this ), WM_SETICON, ICON_BIG, + (LPARAM)GetHiconOf(big) ); } #endif // __WIN95__ } diff --git a/src/msw/volume.cpp b/src/msw/volume.cpp index df62ac3e97..5a3ad4e440 100644 --- a/src/msw/volume.cpp +++ b/src/msw/volume.cpp @@ -109,7 +109,8 @@ static FileInfoMap s_fileInfo(25); // Other initialization. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #if wxUSE_GUI -WX_DEFINE_OBJARRAY(wxIconArray); +// already in wx/iconbndl.h +// WX_DEFINE_OBJARRAY(wxIconArray); #endif //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/src/os2/files.lst b/src/os2/files.lst index 2310bdf97b..b7acd13bcb 100644 --- a/src/os2/files.lst +++ b/src/os2/files.lst @@ -97,6 +97,7 @@ ALL_SOURCES = \ common/hashmap.cpp \ common/helpbase.cpp \ common/http.cpp \ + common/iconbndl.cpp \ common/imagall.cpp \ common/imagbmp.cpp \ common/image.cpp \ @@ -368,6 +369,7 @@ ALL_HEADERS = \ helphtml.h \ helpwin.h \ icon.h \ + iconbndl.h \ imagbmp.h \ image.h \ imaggif.h \ @@ -688,6 +690,7 @@ COMMONOBJS = \ hashmap.o \ helpbase.o \ http.o \ + iconbndl.o \ imagall.o \ imagbmp.o \ image.o \ diff --git a/src/univ/topluniv.cpp b/src/univ/topluniv.cpp index f16864f80a..35debbc1fe 100644 --- a/src/univ/topluniv.cpp +++ b/src/univ/topluniv.cpp @@ -296,13 +296,14 @@ int wxTopLevelWindow::GetMinHeight() const // icons // ---------------------------------------------------------------------------- -void wxTopLevelWindow::SetIcon(const wxIcon& icon) +void wxTopLevelWindow::SetIcons(const wxIconBundle& icons) { - wxTopLevelWindowNative::SetIcon(icon); + wxTopLevelWindowNative::SetIcons(icons); if ( ms_drawDecorations && m_renderer ) { wxSize size = m_renderer->GetFrameIconSize(); + const wxIcon& icon = icons.GetIcon( size ); if ( !icon.Ok() || size.x == -1 ) m_titlebarIcon = icon; diff --git a/src/unix/utilsx11.cpp b/src/unix/utilsx11.cpp new file mode 100644 index 0000000000..44dcaeebe7 --- /dev/null +++ b/src/unix/utilsx11.cpp @@ -0,0 +1,89 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: src/unix/utilsx11.cpp +// Purpose: Miscellaneous X11 functions +// Author: Mattia Barbon +// Modified by: +// Created: 25.03.02 +// RCS-ID: $Id$ +// Copyright: (c) wxWindows team +// Licence: wxWindows license +///////////////////////////////////////////////////////////////////////////// + +#if defined(__WXX11__) || defined(__WXGTK__) || defined(__WXMOTIF__) + +#include "wx/unix/utilsx11.h" +#include "wx/iconbndl.h" +#include "wx/image.h" +#include "wx/icon.h" + +#include +#include + +void wxSetIconsX11( WXDisplay* display, WXWindow window, + const wxIconBundle& ib ) +{ + size_t size = 0; + size_t i, max = ib.m_icons.GetCount(); + + for( i = 0; i < max; ++i ) + size += 2 + ib.m_icons[i].GetWidth() * ib.m_icons[i].GetHeight(); + + Atom net_wm_icon = XInternAtom( (Display*)display, "_NET_WM_ICON", 0 ); + + if( size > 0 ) + { + wxUint32* data = new wxUint32[size]; + wxUint32* ptr = data; + + for( i = 0; i < max; ++i ) + { + const wxImage image = ib.m_icons[i].ConvertToImage(); + int width = image.GetWidth(), height = image.GetHeight(); + unsigned char* imageData = image.GetData(); + unsigned char* imageDataEnd = imageData + ( width * height * 3 ); + bool hasMask = image.HasMask(); + unsigned char rMask, gMask, bMask; + unsigned char r, g, b, a; + + if( hasMask ) + { + rMask = image.GetMaskRed(); + gMask = image.GetMaskGreen(); + bMask = image.GetMaskBlue(); + } + + *ptr++ = width; + *ptr++ = height; + + while( imageData < imageDataEnd ) { + r = imageData[0]; + g = imageData[1]; + b = imageData[2]; + if( hasMask && r == rMask && g == gMask && b == bMask ) + a = 0; + else + a = 255; + + *ptr++ = ( a << 24 ) | ( r << 16 ) | ( g << 8 ) | b; + + imageData += 3; + } + } + + XChangeProperty( (Display*)display, + (Window)window, + net_wm_icon, + XA_CARDINAL, 32, + PropModeReplace, + (unsigned char*)data, size ); + delete[] data; + } + else + { + XDeleteProperty( (Display*)display, + (Window)window, + net_wm_icon ); + } +} + +#endif diff --git a/src/wxUniv.dsp b/src/wxUniv.dsp index 448d8e3775..ea6bec33fc 100644 --- a/src/wxUniv.dsp +++ b/src/wxUniv.dsp @@ -309,6 +309,10 @@ SOURCE=.\common\http.cpp # End Source File # Begin Source File +SOURCE=.\common\iconbndl.cpp +# End Source File +# Begin Source File + SOURCE=.\common\imagall.cpp # End Source File # Begin Source File @@ -1626,6 +1630,10 @@ SOURCE=..\include\wx\icon.h # End Source File # Begin Source File +SOURCE=..\include\wx\iconbndl.h +# End Source File +# Begin Source File + SOURCE=..\include\wx\imagbmp.h # End Source File # Begin Source File diff --git a/src/wxWindows.dsp b/src/wxWindows.dsp index d5552193a1..d36fb54842 100644 --- a/src/wxWindows.dsp +++ b/src/wxWindows.dsp @@ -468,6 +468,10 @@ SOURCE=.\common\http.cpp # End Source File # Begin Source File +SOURCE=.\common\iconbndl.cpp +# End Source File +# Begin Source File + SOURCE=.\common\imagall.cpp # End Source File # Begin Source File @@ -1906,6 +1910,10 @@ SOURCE=..\include\wx\icon.h # End Source File # Begin Source File +SOURCE=..\include\wx\iconbndl.h +# End Source File +# Begin Source File + SOURCE=..\include\wx\imagbmp.h # End Source File # Begin Source File diff --git a/src/wxWindows.dsw b/src/wxWindows.dsw index 57f8aafd9a..59b53b0a11 100644 --- a/src/wxWindows.dsw +++ b/src/wxWindows.dsw @@ -1,4 +1,4 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 +Microsoft Developer Studio Workspace File, Format Version 5.00 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! ############################################################################### @@ -59,21 +59,6 @@ Package=<5> Package=<4> {{{ - Begin Project Dependency - Project_Dep_Name jpeg - End Project Dependency - Begin Project Dependency - Project_Dep_Name png - End Project Dependency - Begin Project Dependency - Project_Dep_Name regex - End Project Dependency - Begin Project Dependency - Project_Dep_Name tiff - End Project Dependency - Begin Project Dependency - Project_Dep_Name zlib - End Project Dependency }}} ############################################################################### diff --git a/src/x11/files.lst b/src/x11/files.lst index 6b316bb672..7e96ae2d12 100644 --- a/src/x11/files.lst +++ b/src/x11/files.lst @@ -135,6 +135,7 @@ ALL_SOURCES = \ common/hashmap.cpp \ common/helpbase.cpp \ common/http.cpp \ + common/iconbndl.cpp \ common/imagall.cpp \ common/imagbmp.cpp \ common/image.cpp \ @@ -214,6 +215,7 @@ ALL_SOURCES = \ unix/snglinst.cpp \ unix/threadpsx.cpp \ unix/utilsunx.cpp \ + unix/utilsx11.cpp \ html/helpctrl.cpp \ html/helpdata.cpp \ html/helpfrm.cpp \ @@ -337,6 +339,7 @@ ALL_HEADERS = \ helphtml.h \ helpwin.h \ icon.h \ + iconbndl.h \ imagbmp.h \ image.h \ imaggif.h \ @@ -583,6 +586,7 @@ ALL_HEADERS = \ unix/fontutil.h \ unix/gsockunx.h \ unix/mimetype.h \ + unix/utilsx11.h \ html/forcelnk.h \ html/helpctrl.h \ html/helpdata.h \ @@ -693,6 +697,7 @@ COMMONOBJS = \ hashmap.o \ helpbase.o \ http.o \ + iconbndl.o \ imagall.o \ imagbmp.o \ image.o \ @@ -821,7 +826,8 @@ UNIXOBJS = \ mimetype.o \ snglinst.o \ threadpsx.o \ - utilsunx.o + utilsunx.o \ + utilsx11.o HTMLOBJS = \ helpctrl.o \ diff --git a/src/x11/toplevel.cpp b/src/x11/toplevel.cpp index 7cc9463a81..7f014a8e63 100644 --- a/src/x11/toplevel.cpp +++ b/src/x11/toplevel.cpp @@ -43,6 +43,8 @@ #include "wx/x11/private.h" #include "X11/Xutil.h" +#include "wx/unix/utilsx11.h" + bool wxMWMIsRunning(Window w); // ---------------------------------------------------------------------------- @@ -393,11 +395,8 @@ bool wxTopLevelWindowX11::ShowFullScreen(bool show, long style) // wxTopLevelWindowX11 misc // ---------------------------------------------------------------------------- -void wxTopLevelWindowX11::SetIcon(const wxIcon& icon) +void wxTopLevelWindowX11::DoSetIcon(const wxIcon& icon) { - // this sets m_icon - wxTopLevelWindowBase::SetIcon(icon); - if (icon.Ok() && GetMainWindow()) { #if wxUSE_NANOX @@ -419,6 +418,15 @@ void wxTopLevelWindowX11::SetIcon(const wxIcon& icon) } } +void wxTopLevelWindowX11::SetIcons(const wxIconBundle& icons ) +{ + // this sets m_icon + wxTopLevelWindowBase::SetIcons( icons ); + + DoSetIcon( icons.GetIcon( -1 ) ); + wxSetIconsX11( GetXDisplay(), GetXWindow(), icons ); +} + void wxTopLevelWindowX11::SetTitle(const wxString& title) { m_title = title;