]> git.saurik.com Git - wxWidgets.git/commitdiff
wxIconBundle implementation.
authorMattia Barbon <mbarbon@cpan.org>
Tue, 26 Mar 2002 21:54:23 +0000 (21:54 +0000)
committerMattia Barbon <mbarbon@cpan.org>
Tue, 26 Mar 2002 21:54:23 +0000 (21:54 +0000)
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

51 files changed:
distrib/msw/tmake/Makefile
distrib/msw/tmake/filelist.txt
include/wx/gtk/mdi.h
include/wx/gtk/toplevel.h
include/wx/gtk1/mdi.h
include/wx/gtk1/toplevel.h
include/wx/iconbndl.h [new file with mode: 0644]
include/wx/mac/toplevel.h
include/wx/motif/frame.h
include/wx/motif/mdi.h
include/wx/msw/toplevel.h
include/wx/os2/toplevel.h
include/wx/toplevel.h
include/wx/univ/toplevel.h
include/wx/unix/utilsx11.h [new file with mode: 0644]
include/wx/volume.h
include/wx/x11/toplevel.h
src/common/iconbndl.cpp [new file with mode: 0644]
src/gtk/files.lst
src/gtk/settings.cpp
src/gtk/toplevel.cpp
src/gtk1/files.lst
src/gtk1/settings.cpp
src/gtk1/toplevel.cpp
src/mac/carbon/files.lst
src/mac/files.lst
src/makeprog.vc
src/mgl/files.lst
src/microwin/files.lst
src/motif/files.lst
src/motif/frame.cpp
src/motif/mdi.cpp
src/msw/files.lst
src/msw/frame.cpp
src/msw/makefile.b32
src/msw/makefile.bcc
src/msw/makefile.dos
src/msw/makefile.g95
src/msw/makefile.sc
src/msw/makefile.vc
src/msw/makefile.wat
src/msw/toplevel.cpp
src/msw/volume.cpp
src/os2/files.lst
src/univ/topluniv.cpp
src/unix/utilsx11.cpp [new file with mode: 0644]
src/wxUniv.dsp
src/wxWindows.dsp
src/wxWindows.dsw
src/x11/files.lst
src/x11/toplevel.cpp

index 5711fa40b8daa1ae86a3a44027186673bed1439b..c01444f793a3cf71a5ace0f6b82c6560cac92490 100644 (file)
@@ -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 $@
 
index 9b5f0fcf795cfb2175e5bbc20f60505cce1c5ec8..16fa71ac9ffed0a0202b79075e48ae4b29b6e829 100644 (file)
@@ -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
index 3dd4ca65303d3f93f039142f354d7465a4a3c104..5dd2ae17626a0c7853394daa37f0aeb384b2274e 100644 (file)
@@ -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 );
index c7bf590b523359374e01958efaab4a979903c6bb..a3b842add32c6674f8b4992a2ce06393de683261 100644 (file)
@@ -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();
index 3dd4ca65303d3f93f039142f354d7465a4a3c104..5dd2ae17626a0c7853394daa37f0aeb384b2274e 100644 (file)
@@ -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 );
index c7bf590b523359374e01958efaab4a979903c6bb..a3b842add32c6674f8b4992a2ce06393de683261 100644 (file)
@@ -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 (file)
index 0000000..4022624
--- /dev/null
@@ -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_
index 06b677c50a27c09bfe732d4935b024ba89c9cd67..89f8cc9580c9380bcfb1f78543f8da35a9a8224c 100644 (file)
@@ -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; }
index f0493408da9a56f0d6fb45515467dada110875de..638e8da237d55919ed1e8e2aaee0c24c92a13165 100644 (file)
@@ -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;
index 50bcf4f5d16498e4c9c29bf352d22315aca14377..ee822b515f011a3cb1fbd3f18067a461c5e056d6 100644 (file)
@@ -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();
index 358f7e55da2324116be4eee9da911a5cd009a8e9..85bf00c07286e73bdf65aa09012b2d9f10c7ead7 100644 (file)
@@ -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);
index c52efb6642e72cbeead93a3537d2baa6df46d637..4224ed63b716f44936d3bf89343acc44b26ec063 100644 (file)
@@ -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
index ae36a9fa4224e9e3d94832ede7ffb5cd8db18222..ce058932b0810beda4176889de312a315b5f4530 100644 (file)
@@ -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)
index 1c4811f37b0b40a6b1fd5ceec75b50f66fc92746..a02df1872697ee3dd83d5725253e01bc8e482398 100644 (file)
@@ -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 (file)
index 0000000..44353ef
--- /dev/null
@@ -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_
index 2c1a821fa5d58954c4a80624d7497f4705f046f0..87b9a27ad7166c75cf9fa4b286f8850f112d08a9 100644 (file)
@@ -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
 
index 4ca3ac2df1b4df41dde43328a61b410b7f062325..74f7411c4f9fa7bb0df54c90e8b9424cda6b69ad 100644 (file)
@@ -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 (file)
index 0000000..13a5d84
--- /dev/null
@@ -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 );
+}
index 7a19cc618d7b362db040d61e82dbfea0714f1590..991ca2f4136af97882d57c45cc80502d9fbdea23 100644 (file)
@@ -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 \
index 5bcfff6c21d80f697ce7d32faa0ba4f0ccc50564..9aed45b5a9785c40154876cfc4ff9826264f6e8b 100644 (file)
@@ -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;
index dbe2a3a928a2ffbae0245a44e33f2b28da7980ff..6484fa7f0090a0df223237b5ec2a98600be66ca5 100644 (file)
@@ -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
 // ----------------------------------------------------------------------------
index 7a19cc618d7b362db040d61e82dbfea0714f1590..991ca2f4136af97882d57c45cc80502d9fbdea23 100644 (file)
@@ -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 \
index 5bcfff6c21d80f697ce7d32faa0ba4f0ccc50564..9aed45b5a9785c40154876cfc4ff9826264f6e8b 100644 (file)
@@ -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;
index dbe2a3a928a2ffbae0245a44e33f2b28da7980ff..6484fa7f0090a0df223237b5ec2a98600be66ca5 100644 (file)
@@ -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
 // ----------------------------------------------------------------------------
index bf5ba746c07eb738b6a1f1df7fb430f9122b710f..d02a542c82b150a8588cdbf133cdf21d80b9e93c 100644 (file)
@@ -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 \
index bf5ba746c07eb738b6a1f1df7fb430f9122b710f..d02a542c82b150a8588cdbf133cdf21d80b9e93c 100644 (file)
@@ -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 \
index 3559c1ca82c4efd177a5b330ac98291bf2d624dd..1a4c5ef2bf2b5b0fe35f304a999a897906ad2e55 100644 (file)
@@ -41,7 +41,7 @@ wxUSE_GUI=1
 !if "$(wxUSE_GUI)" == "1"
 
 #!if "$(WXUSINGDLL)" == "1"
-#DUMMYOBJ=
+DUMMYOBJ=
 #!endif
 
 $(PROGRAM).exe:      $(WXLIB) $(OBJECTS) $(PROGRAM).res
index 63dcae44fb99dc6e4fb42ee4d776c4352e4cf9d3..6cbdd7545c41a20cf83b666ddb71132b56b6102c 100644 (file)
@@ -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 \
index 016627c6e973cc4c49501027051e56a29dd2d3c4..bc64109b37701f226935fe4c07ef5aba360e8212 100644 (file)
@@ -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 \
index 8664bf6791a0db564065ae9d85fd6e4b4f9b01db..f704083c0d9f5e29ac5d883dea8e3cfe70956312 100644 (file)
@@ -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 \
index cd5b22c68101a9e0425b6bed789742c93e7b7a62..5092f9fa1a3efc0c29df7b416fa8c40023d09a5f 100644 (file)
@@ -50,6 +50,7 @@
 
 #include <Xm/Xm.h>
 #include <X11/Shell.h>
+#include <X11/Core.h>
 #if XmVersion >= 1002
     #include <Xm/XmAll.h>
 #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)
index a62339fce34445333181d29cbcdd4ceabadef612..4fa16b4cfe044b1c17efb048d89d95332c9c8022 100644 (file)
@@ -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;
index fcd6a7f740d3dd9ed536d9af295dd0f73ab93f26..721ee5869b3b0b3b090f288743709d176bee66bb 100644 (file)
@@ -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 \
index c4ab391cd81bbc8be94c6ffe94cf9feacc86c5d3..f6344c7c0ccb857f906f708fbf56fde52b71d71c 100644 (file)
@@ -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;
             }
index 6dae7028c89a6006736992a68304f6ca8a730169..8f28aa1b84e0d25de10a63a77747837290325569 100644 (file)
@@ -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)
index e45dda7353af2ebf93d9e566618254d509abff07..fbe678ad421daca590f9e7b11e90b382ed159009 100644 (file)
@@ -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)
index 5fc40b46f454a2ca08e6cb17027ea4efaff2105c..c318f46e540e6fe530afcb01fafac4ba74cb2204 100644 (file)
@@ -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)
index ca3ac9e5f2bf86f73e7a38e71c6d475dccb8efaf..a8b7b186b6f8ff46cfee2ec35686846db6693c91 100644 (file)
@@ -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) \
index 19dc30fb1458dca759a062086603773908f5c723..a8580feab3bd19f02d784e7b65a1bbbf167d0f9f 100644 (file)
@@ -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 \
index 3a9008760aaff0b70febc3d9be8a07d105262669..2224446d42df6895b35e634a0d4a33d2fc06778b 100644 (file)
@@ -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 \
index 42f7bfeb8bffef219d74ba1af69131f9baa6162a..555b216041692307ebba432b44a17c4ec148f77b 100644 (file)
@@ -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) $<
 
index 0c5ef7d3b33e2a8cc072c9a67df3527bc8eea685..ae7a11fd57fcb88ff589d1207aaf4888945a8eca 100644 (file)
@@ -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__
 }
index df62ac3e97cdde6467e41e67c52cbf0bd41b4234..5a3ad4e44086e81f0fa92cd18d1640b33452ab04 100644 (file)
@@ -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
 
 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
index 2310bdf97bf02974305ed402d2960eb46e70f606..b7acd13bcbcb9275581a8a2f1b744899880b5bb2 100644 (file)
@@ -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 \
index f16864f80af8e953416a39405a9fb049cbcd0661..35debbc1fe88bb7cc7cf9533ac0e51ebc66e605d 100644 (file)
@@ -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 (file)
index 0000000..44dcaee
--- /dev/null
@@ -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 <X11/Xlib.h>
+#include <X11/Xatom.h>
+
+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
index 448d8e377544a55cea292492fb70d697a176f3a3..ea6bec33fc46a3840efa03adb01dfe113edd626e 100644 (file)
@@ -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
index d5552193a1043793787dd4cbc9c680dac389cc0f..d36fb54842b613e125b1d6ee88c99294fc030b93 100644 (file)
@@ -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
index 57f8aafd9a2c566698f4c32b384a8e06bd5c1e02..59b53b0a11335ff15fb053edddda3f78022ecdd8 100644 (file)
@@ -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
 }}}
 
 ###############################################################################
index 6b316bb672ded8a49cb1b6e000e8434d66f624eb..7e96ae2d12d7ee17ef21139332ed9c2db109173c 100644 (file)
@@ -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 \
index 7cc9463a814c0f8ba3ffc27fd2474516db922e79..7f014a8e63ee72c0f5ddc1ed3ac1acd29d5f1bcf 100644 (file)
@@ -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;