]> git.saurik.com Git - wxWidgets.git/commitdiff
1. changed wxIconBundle to use m_refData and COW to make copying icon bundles
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 7 Apr 2007 19:59:51 +0000 (19:59 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 7 Apr 2007 19:59:51 +0000 (19:59 +0000)
   fast (which was needed for 2)
2. make it possible to return wxIconBundles from wxArtProvider
3. implement Mac-specific wxArtProvider doing (2)

(modified patch 1581960)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45309 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

21 files changed:
Makefile.in
build/bakefiles/files.bkl
build/msw/makefile.vc
docs/changes.txt
docs/latex/wx/artprov.tex
docs/latex/wx/iconbndl.tex
include/wx/artprov.h
include/wx/gdicmn.h
include/wx/iconbndl.h
include/wx/mac/carbon/icon.h
include/wx/toplevel.h
samples/treectrl/treetest.cpp
samples/treectrl/treetest.h
src/common/artprov.cpp
src/common/artstd.cpp
src/common/gdicmn.cpp
src/common/iconbndl.cpp
src/gtk/toplevel.cpp
src/mac/carbon/artmac.cpp [new file with mode: 0644]
src/mac/carbon/icon.cpp
src/unix/utilsx11.cpp

index 32565adb82131fb0b99422eff3885abec96ead64..0906a7f627235b7f536b65c35659c0efcd09a08b 100644 (file)
@@ -4391,6 +4391,7 @@ COND_TOOLKIT_MAC___GUI_SRC_OBJECTS =  \
        monodll_accel.o \
        monodll_aga.o \
        monodll_app.o \
        monodll_accel.o \
        monodll_aga.o \
        monodll_app.o \
+       monodll_artmac.o \
        monodll_bitmap.o \
        monodll_bmpbuttn.o \
        monodll_brush.o \
        monodll_bitmap.o \
        monodll_bmpbuttn.o \
        monodll_brush.o \
@@ -6193,6 +6194,7 @@ COND_TOOLKIT_MAC___GUI_SRC_OBJECTS_1 =  \
        monolib_accel.o \
        monolib_aga.o \
        monolib_app.o \
        monolib_accel.o \
        monolib_aga.o \
        monolib_app.o \
+       monolib_artmac.o \
        monolib_bitmap.o \
        monolib_bmpbuttn.o \
        monolib_brush.o \
        monolib_bitmap.o \
        monolib_bmpbuttn.o \
        monolib_brush.o \
@@ -8224,6 +8226,7 @@ COND_TOOLKIT_MAC___GUI_SRC_OBJECTS_2 =  \
        coredll_accel.o \
        coredll_aga.o \
        coredll_app.o \
        coredll_accel.o \
        coredll_aga.o \
        coredll_app.o \
+       coredll_artmac.o \
        coredll_bitmap.o \
        coredll_bmpbuttn.o \
        coredll_brush.o \
        coredll_bitmap.o \
        coredll_bmpbuttn.o \
        coredll_brush.o \
@@ -9693,6 +9696,7 @@ COND_TOOLKIT_MAC___GUI_SRC_OBJECTS_3 =  \
        corelib_accel.o \
        corelib_aga.o \
        corelib_app.o \
        corelib_accel.o \
        corelib_aga.o \
        corelib_app.o \
+       corelib_artmac.o \
        corelib_bitmap.o \
        corelib_bmpbuttn.o \
        corelib_brush.o \
        corelib_bitmap.o \
        corelib_bmpbuttn.o \
        corelib_brush.o \
@@ -13558,6 +13562,9 @@ monodll_textctrlce.o: $(srcdir)/src/msw/wince/textctrlce.cpp $(MONODLL_ODEP)
 monodll_aga.o: $(srcdir)/src/mac/carbon/aga.cpp $(MONODLL_ODEP)
        $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/mac/carbon/aga.cpp
 
 monodll_aga.o: $(srcdir)/src/mac/carbon/aga.cpp $(MONODLL_ODEP)
        $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/mac/carbon/aga.cpp
 
+monodll_artmac.o: $(srcdir)/src/mac/carbon/artmac.cpp $(MONODLL_ODEP)
+       $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/mac/carbon/artmac.cpp
+
 monodll_dccg.o: $(srcdir)/src/mac/carbon/dccg.cpp $(MONODLL_ODEP)
        $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/mac/carbon/dccg.cpp
 
 monodll_dccg.o: $(srcdir)/src/mac/carbon/dccg.cpp $(MONODLL_ODEP)
        $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/mac/carbon/dccg.cpp
 
@@ -17731,6 +17738,9 @@ monolib_textctrlce.o: $(srcdir)/src/msw/wince/textctrlce.cpp $(MONOLIB_ODEP)
 monolib_aga.o: $(srcdir)/src/mac/carbon/aga.cpp $(MONOLIB_ODEP)
        $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/mac/carbon/aga.cpp
 
 monolib_aga.o: $(srcdir)/src/mac/carbon/aga.cpp $(MONOLIB_ODEP)
        $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/mac/carbon/aga.cpp
 
+monolib_artmac.o: $(srcdir)/src/mac/carbon/artmac.cpp $(MONOLIB_ODEP)
+       $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/mac/carbon/artmac.cpp
+
 monolib_dccg.o: $(srcdir)/src/mac/carbon/dccg.cpp $(MONOLIB_ODEP)
        $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/mac/carbon/dccg.cpp
 
 monolib_dccg.o: $(srcdir)/src/mac/carbon/dccg.cpp $(MONOLIB_ODEP)
        $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/mac/carbon/dccg.cpp
 
@@ -22915,6 +22925,9 @@ coredll_textctrlce.o: $(srcdir)/src/msw/wince/textctrlce.cpp $(COREDLL_ODEP)
 coredll_aga.o: $(srcdir)/src/mac/carbon/aga.cpp $(COREDLL_ODEP)
        $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/mac/carbon/aga.cpp
 
 coredll_aga.o: $(srcdir)/src/mac/carbon/aga.cpp $(COREDLL_ODEP)
        $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/mac/carbon/aga.cpp
 
+coredll_artmac.o: $(srcdir)/src/mac/carbon/artmac.cpp $(COREDLL_ODEP)
+       $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/mac/carbon/artmac.cpp
+
 coredll_dccg.o: $(srcdir)/src/mac/carbon/dccg.cpp $(COREDLL_ODEP)
        $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/mac/carbon/dccg.cpp
 
 coredll_dccg.o: $(srcdir)/src/mac/carbon/dccg.cpp $(COREDLL_ODEP)
        $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/mac/carbon/dccg.cpp
 
@@ -25891,6 +25904,9 @@ corelib_textctrlce.o: $(srcdir)/src/msw/wince/textctrlce.cpp $(CORELIB_ODEP)
 corelib_aga.o: $(srcdir)/src/mac/carbon/aga.cpp $(CORELIB_ODEP)
        $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/mac/carbon/aga.cpp
 
 corelib_aga.o: $(srcdir)/src/mac/carbon/aga.cpp $(CORELIB_ODEP)
        $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/mac/carbon/aga.cpp
 
+corelib_artmac.o: $(srcdir)/src/mac/carbon/artmac.cpp $(CORELIB_ODEP)
+       $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/mac/carbon/artmac.cpp
+
 corelib_dccg.o: $(srcdir)/src/mac/carbon/dccg.cpp $(CORELIB_ODEP)
        $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/mac/carbon/dccg.cpp
 
 corelib_dccg.o: $(srcdir)/src/mac/carbon/dccg.cpp $(CORELIB_ODEP)
        $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/mac/carbon/dccg.cpp
 
index f7aa9e964658f3fe54f3ac4d1d00847c978f7330..3d2921ab1f011fef4faeb20dbbfd2b683d749392 100644 (file)
@@ -2100,6 +2100,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
     src/mac/carbon/accel.cpp
     src/mac/carbon/aga.cpp
     src/mac/carbon/app.cpp
     src/mac/carbon/accel.cpp
     src/mac/carbon/aga.cpp
     src/mac/carbon/app.cpp
+    src/mac/carbon/artmac.cpp
     src/mac/carbon/bitmap.cpp
     src/mac/carbon/bmpbuttn.cpp
     src/mac/carbon/brush.cpp
     src/mac/carbon/bitmap.cpp
     src/mac/carbon/bmpbuttn.cpp
     src/mac/carbon/brush.cpp
index 133a5a2c71fb5749f09fdd5b7c74ecd0ebc9d9a3..147b32cd55697fa5d75008151693931f2b86abfe 100644 (file)
@@ -4486,7 +4486,7 @@ clean:
        -if exist $(LIBDIRNAME)\wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gl.lib del $(LIBDIRNAME)\wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gl.lib
        cd ..\..\samples
        $(MAKE) -f makefile.vc $(MAKEARGS) clean
        -if exist $(LIBDIRNAME)\wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gl.lib del $(LIBDIRNAME)\wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gl.lib
        cd ..\..\samples
        $(MAKE) -f makefile.vc $(MAKEARGS) clean
-       cd $(MAKEDIR)
+       cd "$(MAKEDIR)"
 
 setup_h: $(SETUPHDIR)\wx ..\..\include\wx\$(__SETUP_H_SUBDIR_FILENAMES)\setup.h $(SETUPHDIR)\wx\setup.h $(SETUPHDIR)\wx\msw\rcdefs.h
 
 
 setup_h: $(SETUPHDIR)\wx ..\..\include\wx\$(__SETUP_H_SUBDIR_FILENAMES)\setup.h $(SETUPHDIR)\wx\setup.h $(SETUPHDIR)\wx\msw\rcdefs.h
 
@@ -4833,7 +4833,7 @@ $(LIBDIRNAME)\wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXD
 sub_samples: 
        cd ..\..\samples
        $(MAKE) -f makefile.vc $(MAKEARGS) all
 sub_samples: 
        cd ..\..\samples
        $(MAKE) -f makefile.vc $(MAKEARGS) all
-       cd $(MAKEDIR)
+       cd "$(MAKEDIR)"
 
 $(LIBDIRNAME): 
        if not exist $(LIBDIRNAME) mkdir $(LIBDIRNAME)
 
 $(LIBDIRNAME): 
        if not exist $(LIBDIRNAME) mkdir $(LIBDIRNAME)
index d9141a11c53066e0b245310077a1d080d3297caf..b9068df632ff1921cb1b096fd419009ae354693e 100644 (file)
@@ -115,6 +115,7 @@ wxGTK:
 
 wxMac:
 
 
 wxMac:
 
+- Better IconRef support (Alan Shouls)
 - Fix duplicate (empty) help menu in non-English programs (Andreas Jacobs)
 - Allow accelerators to be used with buttons too (Ryan Wilcox)
 - Support resource forks in wxCopyFile() (Hank Schultz)
 - Fix duplicate (empty) help menu in non-English programs (Andreas Jacobs)
 - Allow accelerators to be used with buttons too (Ryan Wilcox)
 - Support resource forks in wxCopyFile() (Hank Schultz)
index 179111d9e674a45897f3479f43df3ebcbbcc9348..264f579b7e302bcfbc42fd12ecc98f22f6f33649 100644 (file)
@@ -10,9 +10,10 @@ When wxWidgets needs to display an icon or a bitmap (e.g. in the standard file
 dialog), it does not use a hard-coded resource but asks wxArtProvider for it
 instead. This way users can plug in their own wxArtProvider class and easily
 replace standard art with their own version. All
 dialog), it does not use a hard-coded resource but asks wxArtProvider for it
 instead. This way users can plug in their own wxArtProvider class and easily
 replace standard art with their own version. All
-that is needed is to derive a class from wxArtProvider, override its
-\helpref{CreateBitmap}{wxartprovidercreatebitmap} method and register the
-provider with
+that is needed is to derive a class from wxArtProvider, override either its
+\helpref{CreateBitmap}{wxartprovidercreatebitmap} and/or its
+\helpref{CreateIconBundle}{wxartprovidercreateiconbundle} methods
+and register the provider with
 \helpref{wxArtProvider::Push}{wxartproviderpush}:
 
 \begin{verbatim}
 \helpref{wxArtProvider::Push}{wxartproviderpush}:
 
 \begin{verbatim}
@@ -22,12 +23,20 @@ provider with
     wxBitmap CreateBitmap(const wxArtID& id, 
                           const wxArtClient& client,
                           const wxSize size)
     wxBitmap CreateBitmap(const wxArtID& id, 
                           const wxArtClient& client,
                           const wxSize size)
+
+    // optionally override this one as well
+    wxIconBundle CreateIconBundle(const wxArtID& id,
+                                  const wxArtClient& client)
     { ... }
   };
   ...
   wxArtProvider::Push(new MyProvider);
 \end{verbatim}
 
     { ... }
   };
   ...
   wxArtProvider::Push(new MyProvider);
 \end{verbatim}
 
+If you need bitmap images (of the same artwork) that should be displayed at different sizes
+you should probably consider overriding \helpref{CreateIconBundle()}{wxartprovidercreateiconbundle} 
+and supplying icon bundles that contain different bitmap sizes.
+
 There's another way of taking advantage of this class: you can use it in your code and use
 platform native icons as provided by \helpref{wxArtProvider::GetBitmap}{wxartprovidergetbitmap} or 
 \helpref{wxArtProvider::GetIcon}{wxartprovidergeticon} (NB: this is not yet really
 There's another way of taking advantage of this class: you can use it in your code and use
 platform native icons as provided by \helpref{wxArtProvider::GetBitmap}{wxartprovidergetbitmap} or 
 \helpref{wxArtProvider::GetIcon}{wxartprovidergeticon} (NB: this is not yet really
@@ -37,7 +46,7 @@ small).
 
 \membersection{Identifying art resources}\label{artprovideridentifying}
 
 
 \membersection{Identifying art resources}\label{artprovideridentifying}
 
-Every bitmap is known to wxArtProvider under an unique ID that is used by when
+Every bitmap and icon bundle are known to wxArtProvider under an unique ID that is used when
 requesting a resource from it. The ID is represented by wxArtID type and can
 have one of these predefined values (you can see bitmaps represented by these
 constants in the \helpref{artprov}{sampleartprovider} sample):
 requesting a resource from it. The ID is represented by wxArtID type and can
 have one of these predefined values (you can see bitmaps represented by these
 constants in the \helpref{artprov}{sampleartprovider} sample):
@@ -159,10 +168,10 @@ by \helpref{GetBitmap}{wxartprovidergetbitmap}.
 
 \func{wxBitmap}{CreateBitmap}{\param{const wxArtID\& }{id}, \param{const wxArtClient\& }{client}, \param{const wxSize\& }{size}}
 
 
 \func{wxBitmap}{CreateBitmap}{\param{const wxArtID\& }{id}, \param{const wxArtClient\& }{client}, \param{const wxSize\& }{size}}
 
-Derived art provider classes must override this method to create requested 
-art resource. Note that returned bitmaps are cached by wxArtProvider and it is therefore
-not necessary to optimize CreateBitmap for speed (e.g. you may create wxBitmap objects
-from XPMs here).
+Derived art provider classes must override this method or the CreateIconBundle() method
+to create requested art resource. Note that returned bitmaps are cached by wxArtProvider
+and it is therefore not necessary to optimize CreateBitmap() for speed (e.g. you may create
+wxBitmap objects from XPMs here).
 
 \wxheading{Parameters}
 
 
 \wxheading{Parameters}
 
@@ -178,10 +187,33 @@ dimensions, it will be automatically rescaled to meet client's request.}
 
 This is {\bf not} part of wxArtProvider's public API, use
 \helpref{wxArtProvider::GetBitmap}{wxartprovidergetbitmap} or 
 
 This is {\bf not} part of wxArtProvider's public API, use
 \helpref{wxArtProvider::GetBitmap}{wxartprovidergetbitmap} or 
+\helpref{wxArtProvider::GetIconBundle}{wxartprovidergeticonbundle} or
 \helpref{wxArtProvider::GetIcon}{wxartprovidergeticon}
 to query wxArtProvider for a resource.
 
 
 \helpref{wxArtProvider::GetIcon}{wxartprovidergeticon}
 to query wxArtProvider for a resource.
 
 
+\func{wxIconBundle}{CreateIconBundle}{\param{const wxArtID\& }{id}, \param{const wxArtClient\& }{client}}
+
+Derived art provider classes must override this method or the CreateIconBundle method
+to create requested art resource. Note that returned icon bundles are cached by wxArtProvider
+and it is therefore not necessary to optimize CreateIconBundle for speed (e.g. you may create icon bundles
+from artwork resources here).
+
+\wxheading{Parameters}
+
+\docparam{id}{wxArtID unique identifier of the icon bundle.}
+
+\docparam{client}{wxArtClient identifier of the client (i.e. who is asking for the icon bundle).
+This only servers as a hint.}
+
+\wxheading{Note}
+
+This is {\bf not} part of wxArtProvider's public API, use
+\helpref{wxArtProvider::GetBitmap}{wxartprovidergetbitmap} or 
+\helpref{wxArtProvider::GetIconBundle}{wxartprovidergeticonbundle} or
+\helpref{wxArtProvider::GetIcon}{wxartprovidergeticon}
+to query wxArtProvider for a resource.
+
 \membersection{wxArtProvider::Delete}\label{wxartproviderdelete}
 
 \func{static bool}{Delete}{\param{wxArtProvider* }{provider}}
 \membersection{wxArtProvider::Delete}\label{wxartproviderdelete}
 
 \func{static bool}{Delete}{\param{wxArtProvider* }{provider}}
@@ -208,6 +240,23 @@ Query registered providers for bitmap with given ID.
 The bitmap if one of registered providers recognizes the ID or wxNullBitmap otherwise.
 
 
 The bitmap if one of registered providers recognizes the ID or wxNullBitmap otherwise.
 
 
+\membersection{wxArtProvider::GetIconBundle}\label{wxartprovidergeticonbundle}
+
+\func{static wxIconBundle}{GetIconBundle}{\param{const wxArtID\& }{id}, \param{const wxArtClient\& }{client = wxART\_OTHER}}
+
+Query registered providers for icon bundle with given ID.
+
+\wxheading{Parameters}
+
+\docparam{id}{wxArtID unique identifier of the icon bundle.}
+
+\docparam{client}{wxArtClient identifier of the client (i.e. who is asking for the icon bundle).}
+
+\wxheading{Return value}
+
+The icon bundle if one of registered providers recognizes the ID or wxNullIconBundle otherwise.
+
+
 \membersection{wxArtProvider::GetIcon}\label{wxartprovidergeticon}
 
 \func{static wxIcon}{GetIcon}{\param{const wxArtID\& }{id}, \param{const wxArtClient\& }{client = wxART\_OTHER}, \param{const wxSize\& }{size = wxDefaultSize}}
 \membersection{wxArtProvider::GetIcon}\label{wxartprovidergeticon}
 
 \func{static wxIcon}{GetIcon}{\param{const wxArtID\& }{id}, \param{const wxArtClient\& }{client = wxART\_OTHER}, \param{const wxSize\& }{size = wxDefaultSize}}
index d1a68478c38be2fd65fdcb3c0fdb1104d4b66204..e76082bb04cf246232786ebf9489bedba5662420 100644 (file)
@@ -6,7 +6,12 @@ see also \helpref{wxDialog::SetIcons}{wxdialogseticons} and
 
 \wxheading{Derived from}
 
 
 \wxheading{Derived from}
 
-No base class
+\helpref{wxGDIObject}{wxgdiobject}\\
+\helpref{wxObject}{wxobject}
+
+\wxheading{Predefined objects}
+
+{\bf wxNullIconBundle}
 
 \latexignore{\rtfignore{\wxheading{Members}}}
 
 
 \latexignore{\rtfignore{\wxheading{Members}}}
 
@@ -50,7 +55,7 @@ replaced by the new one.
 
 \membersection{wxIconBundle::GetIcon}\label{wxiconbundlegeticon}
 
 
 \membersection{wxIconBundle::GetIcon}\label{wxiconbundlegeticon}
 
-\constfunc{const wxIcon\&}{GetIcon}{\param{const wxSize\& }{size}}
+\constfunc{wxIcon}{GetIcon}{\param{const wxSize\& }{size}}
 
 Returns the icon with the given size; if no such icon exists,
 returns the icon with size wxSYS\_ICON\_X/wxSYS\_ICON\_Y;
 
 Returns the icon with the given size; if no such icon exists,
 returns the icon with size wxSYS\_ICON\_X/wxSYS\_ICON\_Y;
@@ -58,13 +63,24 @@ if no such icon exists,
 returns the first icon in the bundle. If size = wxSize( -1, -1 ),
 returns the icon with size wxSYS\_ICON\_X/wxSYS\_ICON\_Y.
 
 returns the first icon in the bundle. If size = wxSize( -1, -1 ),
 returns the icon with size wxSYS\_ICON\_X/wxSYS\_ICON\_Y.
 
-\constfunc{const wxIcon\&}{GetIcon}{\param{wxCoord }{size = -1}}
+\constfunc{wxIcon}{GetIcon}{\param{wxCoord }{size = -1}}
 
 Same as GetIcon( wxSize( size, size ) ).
 
 
 Same as GetIcon( wxSize( size, size ) ).
 
-\membersection{wxIconBundle::operator=}\label{wxiconbundleoperatorassign}
+\membersection{wxIconBundle::operator $=$}\label{wxiconbundleoperatorassign}
+
+\func{wxIconBundle\&}{operator $=$}{\param{const wxIconBundle\& }{ic}}
+
+Assignment operator, using \helpref{reference counting}{trefcount}.
+
+\membersection{wxIconBundle::operator $==$}\label{wxiconbundleoperatorequals}
+
+\func{bool}{operator $==$}{\param{const wxIconBundle\& }{ic}}
+
+Equality operator. This returns \true if two icon bundles are equal.
 
 
-\func{const wxIconBundle\&}{operator=}{\param{const wxIconBundle\& }{ic}}
+\membersection{wxIconBundle::operator $!=$}\label{wxiconbundleoperatornotequals}
 
 
-Assignment operator.
+\func{bool}{operator $!=$}{\param{const wxIconBundle\& }{ic}}
 
 
+Inequality operator. This returns \true if two icon bundles are not equal.
index 184a21791f1165fc21b3ffa9c9a91502659e5946..e98bd411828c7231062f18724be7110a489424b6 100644 (file)
@@ -15,6 +15,7 @@
 #include "wx/string.h"
 #include "wx/bitmap.h"
 #include "wx/icon.h"
 #include "wx/string.h"
 #include "wx/bitmap.h"
 #include "wx/icon.h"
+#include "wx/iconbndl.h"
 
 class WXDLLEXPORT wxArtProvidersList;
 class WXDLLEXPORT wxArtProviderCache;
 
 class WXDLLEXPORT wxArtProvidersList;
 class WXDLLEXPORT wxArtProviderCache;
@@ -44,6 +45,7 @@ typedef wxString wxArtID;
 #define wxART_HELP_BROWSER         wxART_MAKE_CLIENT_ID(wxART_HELP_BROWSER)
 #define wxART_MESSAGE_BOX          wxART_MAKE_CLIENT_ID(wxART_MESSAGE_BOX)
 #define wxART_BUTTON               wxART_MAKE_CLIENT_ID(wxART_BUTTON)
 #define wxART_HELP_BROWSER         wxART_MAKE_CLIENT_ID(wxART_HELP_BROWSER)
 #define wxART_MESSAGE_BOX          wxART_MAKE_CLIENT_ID(wxART_MESSAGE_BOX)
 #define wxART_BUTTON               wxART_MAKE_CLIENT_ID(wxART_BUTTON)
+#define wxART_LIST                 wxART_MAKE_CLIENT_ID(wxART_LIST)
 
 #define wxART_OTHER                wxART_MAKE_CLIENT_ID(wxART_OTHER)
 
 
 #define wxART_OTHER                wxART_MAKE_CLIENT_ID(wxART_OTHER)
 
@@ -146,6 +148,11 @@ public:
                           const wxArtClient& client = wxART_OTHER,
                           const wxSize& size = wxDefaultSize);
 
                           const wxArtClient& client = wxART_OTHER,
                           const wxSize& size = wxDefaultSize);
 
+    // Query the providers for iconbundle with given ID and return it. Return
+    // wxNullIconBundle if no provider provides it.
+    static wxIconBundle GetIconBundle(const wxArtID& id,
+                                      const wxArtClient& client = wxART_OTHER);
+
     // Get the size hint of an icon from a specific wxArtClient, queries
     // the topmost provider if platform_dependent = false
     static wxSize GetSizeHint(const wxArtClient& client, bool platform_dependent = false);
     // Get the size hint of an icon from a specific wxArtClient, queries
     // the topmost provider if platform_dependent = false
     static wxSize GetSizeHint(const wxArtClient& client, bool platform_dependent = false);
@@ -177,12 +184,18 @@ protected:
         return GetSizeHint(client, true);
     }
 
         return GetSizeHint(client, true);
     }
 
-    // Derived classes must override this method to create requested
-    // art resource. This method is called only once per instance's
-    // lifetime for each requested wxArtID.
+    // Derived classes must override CreateBitmap or CreateIconBundle
+    // (or both) to create requested art resource. This method is called
+    // only once per instance's lifetime for each requested wxArtID.
     virtual wxBitmap CreateBitmap(const wxArtID& WXUNUSED(id),
                                   const wxArtClient& WXUNUSED(client),
     virtual wxBitmap CreateBitmap(const wxArtID& WXUNUSED(id),
                                   const wxArtClient& WXUNUSED(client),
-                                  const wxSize& WXUNUSED(size)) = 0;
+                                  const wxSize& WXUNUSED(size)) { return wxNullBitmap; }
+
+    virtual wxIconBundle CreateIconBundle(const wxArtID& WXUNUSED(id),
+                                          const wxArtClient& WXUNUSED(client))
+    {
+        return wxNullIconBundle;
+    }
 
 private:
     static void CommonAddingProvider();
 
 private:
     static void CommonAddingProvider();
index 18dce6cbfb6f618b6397e9ef240a69f355a40ccf..acd374d4c389c577537305fbd5ec0349167ecfe5 100644 (file)
@@ -37,6 +37,7 @@ class WXDLLIMPEXP_CORE wxPalette;
 class WXDLLIMPEXP_CORE wxPen;
 class WXDLLIMPEXP_CORE wxRegion;
 class WXDLLIMPEXP_BASE wxString;
 class WXDLLIMPEXP_CORE wxPen;
 class WXDLLIMPEXP_CORE wxRegion;
 class WXDLLIMPEXP_BASE wxString;
+class WXDLLIMPEXP_CORE wxIconBundle;
 
 // ---------------------------------------------------------------------------
 // constants
 
 // ---------------------------------------------------------------------------
 // constants
@@ -712,9 +713,10 @@ extern WXDLLEXPORT_DATA(wxIcon)       wxNullIcon;
 extern WXDLLEXPORT_DATA(wxCursor)     wxNullCursor;
 extern WXDLLEXPORT_DATA(wxPen)        wxNullPen;
 extern WXDLLEXPORT_DATA(wxBrush)      wxNullBrush;
 extern WXDLLEXPORT_DATA(wxCursor)     wxNullCursor;
 extern WXDLLEXPORT_DATA(wxPen)        wxNullPen;
 extern WXDLLEXPORT_DATA(wxBrush)      wxNullBrush;
-extern WXDLLEXPORT_DATA(wxPalette)     wxNullPalette;
+extern WXDLLEXPORT_DATA(wxPalette)    wxNullPalette;
 extern WXDLLEXPORT_DATA(wxFont)       wxNullFont;
 extern WXDLLEXPORT_DATA(wxColour)     wxNullColour;
 extern WXDLLEXPORT_DATA(wxFont)       wxNullFont;
 extern WXDLLEXPORT_DATA(wxColour)     wxNullColour;
+extern WXDLLEXPORT_DATA(wxIconBundle) wxNullIconBundle;
 
 extern WXDLLEXPORT_DATA(wxColourDatabase*)  wxTheColourDatabase;
 
 
 extern WXDLLEXPORT_DATA(wxColourDatabase*)  wxTheColourDatabase;
 
index 3749467240b63a30a6827098bb7e2ced603f46b6..8a76d39eb5fa28b3dbf6fa1f0d86d80db700205b 100644 (file)
 #define _WX_ICONBNDL_H_
 
 #include "wx/dynarray.h"
 #define _WX_ICONBNDL_H_
 
 #include "wx/dynarray.h"
+#include "wx/gdiobj.h"
 // for wxSize
 #include "wx/gdicmn.h"
 // for wxSize
 #include "wx/gdicmn.h"
+#include "wx/icon.h"
 
 class WXDLLIMPEXP_CORE wxIcon;
 class WXDLLIMPEXP_BASE wxString;
 
 
 class WXDLLIMPEXP_CORE wxIcon;
 class WXDLLIMPEXP_BASE wxString;
 
-WX_DECLARE_EXPORTED_OBJARRAY( wxIcon, wxIconArray );
+class WXDLLEXPORT wxIconBundle;
+
+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
 
 // 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
+class WXDLLEXPORT wxIconBundle : public wxGDIObject
 {
 public:
     // default constructor
 {
 public:
     // default constructor
-    wxIconBundle() : m_icons() {}
+    wxIconBundle();
+
     // initializes the bundle with the icon(s) found in the file
     // initializes the bundle with the icon(s) found in the file
-    wxIconBundle( const wxString& file, long type ) : m_icons()
-        { AddIcon( file, type ); }
+    wxIconBundle(const wxString& file, long type);
+
     // initializes the bundle with a single icon
     // initializes the bundle with a single icon
-    wxIconBundle( const wxIcon& icon ) : m_icons()
-        { AddIcon( icon ); }
+    wxIconBundle(const wxIcon& icon);
+
+    // initializes the bundle from another icon bundle
+    wxIconBundle(const wxIconBundle& icon);
 
 
-    const wxIconBundle& operator =( const wxIconBundle& ic );
-    wxIconBundle( const wxIconBundle& ic ) : m_icons()
-        { *this = ic; }
+    wxIconBundle& operator=(const wxIconBundle& ic)
+        { if ( this != &ic) Ref(ic); return *this; }
+
+    virtual bool IsOk() const;
 
 
-    ~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
 
     // 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 );
+    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
     // 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 );
+    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
 
     // 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;
+    wxIcon GetIcon(const wxSize& size) const;
+
     // equivalent to GetIcon( wxSize( size, size ) )
     // equivalent to GetIcon( wxSize( size, size ) )
-    const wxIcon& GetIcon( wxCoord size = wxDefaultCoord ) const
+    wxIcon GetIcon(wxCoord size = wxDefaultCoord) const
         { return GetIcon( wxSize( size, size ) ); }
         { return GetIcon( wxSize( size, size ) ); }
+
+
+    // enumerate all icons in the bundle: don't use these functions if ti can
+    // be avoided, using GetIcon() directly is better
+
+    // return the number of available icons
+    size_t GetIconCount() const;
+
+    // return the icon at index (must be < GetIconCount())
+    wxIcon GetIconByIndex(size_t n) const;
+
+protected:
+    virtual wxObjectRefData *CreateRefData() const;
+    virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
+
 private:
     // delete all icons
     void DeleteIcons();
 private:
     // delete all icons
     void DeleteIcons();
-public:
-    wxIconArray m_icons;
+
+    DECLARE_DYNAMIC_CLASS(wxIconBundle)
 };
 
 };
 
-#endif
-    // _WX_ICONBNDL_H_
+#endif // _WX_ICONBNDL_H_
index 2e9e0d0af93d8dca084dc7352571b8edc5d70a5e..5e786bca58beec03f2c780ccc6272b88cd55c094 100644 (file)
@@ -29,6 +29,9 @@ public:
     {
       LoadFile(loc.GetFileName(), wxBITMAP_TYPE_ICON);
     }
     {
       LoadFile(loc.GetFileName(), wxBITMAP_TYPE_ICON);
     }
+
+    wxIcon(WXHICON icon, const wxSize& size);
+
     virtual ~wxIcon();
 
     bool LoadFile(const wxString& name, wxBitmapType flags /* = wxBITMAP_TYPE_ICON_RESOURCE */ ,
     virtual ~wxIcon();
 
     bool LoadFile(const wxString& name, wxBitmapType flags /* = wxBITMAP_TYPE_ICON_RESOURCE */ ,
index a4530bd2b8a0174180ea76bdc10430351a0d3a92..381467833702ef7886739fb26b8fd70800063005 100644 (file)
@@ -145,7 +145,7 @@ public:
     virtual bool IsIconized() const = 0;
 
     // get the frame icon
     virtual bool IsIconized() const = 0;
 
     // get the frame icon
-    const wxIcon& GetIcon() const { return m_icons.GetIcon( -1 ); }
+    wxIcon GetIcon() const { return m_icons.GetIcon( -1 ); }
 
     // get the frame icons
     const wxIconBundle& GetIcons() const { return m_icons; }
 
     // get the frame icons
     const wxIconBundle& GetIcons() const { return m_icons; }
index 1eab7f8e1394aad5f8637b161c459945df7d0a60..73a7bb62f9f28e29c6e292754e500413253b5bab 100644 (file)
@@ -24,6 +24,7 @@
 #include "wx/colordlg.h"
 #include "wx/numdlg.h"
 
 #include "wx/colordlg.h"
 #include "wx/numdlg.h"
 
+#include "wx/artprov.h"
 #include "wx/image.h"
 #include "wx/imaglist.h"
 #include "wx/treectrl.h"
 #include "wx/image.h"
 #include "wx/imaglist.h"
 #include "wx/treectrl.h"
@@ -96,6 +97,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
     MENU_LINK(DeleteAll)
     MENU_LINK(Recreate)
     MENU_LINK(ToggleImages)
     MENU_LINK(DeleteAll)
     MENU_LINK(Recreate)
     MENU_LINK(ToggleImages)
+    MENU_LINK(ToggleAlternateImages)
     MENU_LINK(ToggleButtons)
     MENU_LINK(SetImageSize)
     MENU_LINK(CollapseAndReset)
     MENU_LINK(ToggleButtons)
     MENU_LINK(SetImageSize)
     MENU_LINK(CollapseAndReset)
@@ -209,6 +211,7 @@ MyFrame::MyFrame(const wxString& title, int x, int y, int w, int h)
     style_menu->AppendCheckItem(TreeTest_ToggleSel, wxT("Toggle &selection mode"));
 #endif // NO_MULTIPLE_SELECTION
     style_menu->AppendCheckItem(TreeTest_ToggleImages, wxT("Toggle show ima&ges"));
     style_menu->AppendCheckItem(TreeTest_ToggleSel, wxT("Toggle &selection mode"));
 #endif // NO_MULTIPLE_SELECTION
     style_menu->AppendCheckItem(TreeTest_ToggleImages, wxT("Toggle show ima&ges"));
+    style_menu->AppendCheckItem(TreeTest_ToggleAlternateImages, wxT("Toggle alternate images"));
     style_menu->Append(TreeTest_SetImageSize, wxT("Set image si&ze..."));
     style_menu->AppendSeparator();
     style_menu->Append(TreeTest_SetFgColour, wxT("Set &foreground colour..."));
     style_menu->Append(TreeTest_SetImageSize, wxT("Set image si&ze..."));
     style_menu->AppendSeparator();
     style_menu->Append(TreeTest_SetFgColour, wxT("Set &foreground colour..."));
@@ -276,6 +279,7 @@ MyFrame::MyFrame(const wxString& title, int x, int y, int w, int h)
     CreateTreeWithDefStyle();
 
     menu_bar->Check(TreeTest_ToggleImages, true);
     CreateTreeWithDefStyle();
 
     menu_bar->Check(TreeTest_ToggleImages, true);
+    menu_bar->Check(TreeTest_ToggleAlternateImages, false);
 
 #if wxUSE_STATUSBAR
     // create a status bar
 
 #if wxUSE_STATUSBAR
     // create a status bar
@@ -601,6 +605,14 @@ void MyFrame::OnToggleImages(wxCommandEvent& WXUNUSED(event))
     }
 }
 
     }
 }
 
+void MyFrame::OnToggleAlternateImages(wxCommandEvent& WXUNUSED(event))
+{
+    bool alternateImages = m_treeCtrl->AlternateImages();
+
+    m_treeCtrl->SetAlternateImages(!alternateImages);
+    m_treeCtrl->CreateImageList(0);
+}
+
 void MyFrame::OnToggleButtons(wxCommandEvent& WXUNUSED(event))
 {
 #if USE_GENERIC_TREECTRL || !defined(__WXMSW__)
 void MyFrame::OnToggleButtons(wxCommandEvent& WXUNUSED(event))
 {
 #if USE_GENERIC_TREECTRL || !defined(__WXMSW__)
@@ -706,7 +718,8 @@ IMPLEMENT_DYNAMIC_CLASS(MyTreeCtrl, wxTreeCtrl)
 MyTreeCtrl::MyTreeCtrl(wxWindow *parent, const wxWindowID id,
                        const wxPoint& pos, const wxSize& size,
                        long style)
 MyTreeCtrl::MyTreeCtrl(wxWindow *parent, const wxWindowID id,
                        const wxPoint& pos, const wxSize& size,
                        long style)
-          : wxTreeCtrl(parent, id, pos, size, style)
+          : wxTreeCtrl(parent, id, pos, size, style),
+            m_alternateImages(false)
 {
     m_reverseSort = false;
 
 {
     m_reverseSort = false;
 
@@ -734,15 +747,29 @@ void MyTreeCtrl::CreateImageList(int size)
     // should correspond to TreeCtrlIcon_xxx enum
     wxBusyCursor wait;
     wxIcon icons[5];
     // should correspond to TreeCtrlIcon_xxx enum
     wxBusyCursor wait;
     wxIcon icons[5];
-    icons[0] = wxIcon(icon1_xpm);
-    icons[1] = wxIcon(icon2_xpm);
-    icons[2] = wxIcon(icon3_xpm);
-    icons[3] = wxIcon(icon4_xpm);
-    icons[4] = wxIcon(icon5_xpm);
 
 
-    int sizeOrig = icons[0].GetWidth();
+    if (m_alternateImages)
+    {
+        icons[TreeCtrlIcon_File] = wxIcon(icon1_xpm);
+        icons[TreeCtrlIcon_FileSelected] = wxIcon(icon2_xpm);
+        icons[TreeCtrlIcon_Folder] = wxIcon(icon3_xpm);
+        icons[TreeCtrlIcon_FolderSelected] = wxIcon(icon4_xpm);
+        icons[TreeCtrlIcon_FolderOpened] = wxIcon(icon5_xpm);
+    }
+    else
+    {
+        wxSize iconSize(size, size);
+
+        icons[TreeCtrlIcon_File] =
+        icons[TreeCtrlIcon_FileSelected] = wxArtProvider::GetIcon(wxART_NORMAL_FILE, wxART_LIST, iconSize);
+        icons[TreeCtrlIcon_Folder] =
+        icons[TreeCtrlIcon_FolderSelected] =
+        icons[TreeCtrlIcon_FolderOpened] = wxArtProvider::GetIcon(wxART_FOLDER, wxART_LIST, iconSize);
+    }
+
     for ( size_t i = 0; i < WXSIZEOF(icons); i++ )
     {
     for ( size_t i = 0; i < WXSIZEOF(icons); i++ )
     {
+        int sizeOrig = icons[0].GetWidth();
         if ( size == sizeOrig )
         {
             images->Add(icons[i]);
         if ( size == sizeOrig )
         {
             images->Add(icons[i]);
@@ -771,12 +798,25 @@ void MyTreeCtrl::CreateButtonsImageList(int size)
     // should correspond to TreeCtrlIcon_xxx enum
     wxBusyCursor wait;
     wxIcon icons[4];
     // should correspond to TreeCtrlIcon_xxx enum
     wxBusyCursor wait;
     wxIcon icons[4];
-    icons[0] = wxIcon(icon3_xpm);   // closed
-    icons[1] = wxIcon(icon3_xpm);   // closed, selected
-    icons[2] = wxIcon(icon5_xpm);   // open
-    icons[3] = wxIcon(icon5_xpm);   // open, selected
 
 
-    for ( size_t i = 0; i < WXSIZEOF(icons); i++ )
+    if (m_alternateImages)
+    {
+        icons[0] = wxIcon(icon3_xpm);   // closed
+        icons[1] = wxIcon(icon3_xpm);   // closed, selected
+        icons[2] = wxIcon(icon5_xpm);   // open
+        icons[3] = wxIcon(icon5_xpm);   // open, selected
+    }
+    else
+    {
+        wxSize iconSize(size, size);
+
+        icons[0] =                                                                 // closed
+        icons[1] = wxArtProvider::GetIcon(wxART_FOLDER, wxART_LIST, iconSize);     // closed, selected
+        icons[2] =                                                                 // open
+        icons[3] = wxArtProvider::GetIcon(wxART_FOLDER_OPEN, wxART_LIST, iconSize);// open, selected
+    }
+
+   for ( size_t i = 0; i < WXSIZEOF(icons); i++ )
     {
         int sizeOrig = icons[i].GetWidth();
         if ( size == sizeOrig )
     {
         int sizeOrig = icons[i].GetWidth();
         if ( size == sizeOrig )
index f9a2f3bcaa9519c52450a3641fd52270284a6914..14e26e6a1343129fd95c077359202006cf5656cf 100644 (file)
@@ -61,7 +61,7 @@ public:
         TreeCtrlIcon_FolderOpened
     };
 
         TreeCtrlIcon_FolderOpened
     };
 
-    MyTreeCtrl() { }
+    MyTreeCtrl() { m_alternateImages = false; }
     MyTreeCtrl(wxWindow *parent, const wxWindowID id,
                const wxPoint& pos, const wxSize& size,
                long style);
     MyTreeCtrl(wxWindow *parent, const wxWindowID id,
                const wxPoint& pos, const wxSize& size,
                long style);
@@ -111,6 +111,9 @@ public:
 
     void SetLastItem(wxTreeItemId id) { m_lastItem = id; }
 
 
     void SetLastItem(wxTreeItemId id) { m_lastItem = id; }
 
+    void SetAlternateImages(bool show) { m_alternateImages = show; }
+    bool AlternateImages() const { return m_alternateImages; }
+
 protected:
     virtual int OnCompareItems(const wxTreeItemId& i1, const wxTreeItemId& i2);
 
 protected:
     virtual int OnCompareItems(const wxTreeItemId& i1, const wxTreeItemId& i2);
 
@@ -133,6 +136,7 @@ private:
     bool         m_reverseSort;             // flag for OnCompareItems
     wxTreeItemId m_lastItem,                // for OnEnsureVisible()
                  m_draggedItem;             // item being dragged right now
     bool         m_reverseSort;             // flag for OnCompareItems
     wxTreeItemId m_lastItem,                // for OnEnsureVisible()
                  m_draggedItem;             // item being dragged right now
+    bool         m_alternateImages;
 
     // NB: due to an ugly wxMSW hack you _must_ use DECLARE_DYNAMIC_CLASS()
     //     if you want your overloaded OnCompareItems() to be called.
 
     // NB: due to an ugly wxMSW hack you _must_ use DECLARE_DYNAMIC_CLASS()
     //     if you want your overloaded OnCompareItems() to be called.
@@ -193,6 +197,7 @@ public:
     void OnRecreate(wxCommandEvent& event);
     void OnToggleButtons(wxCommandEvent& event);
     void OnToggleImages(wxCommandEvent& event);
     void OnRecreate(wxCommandEvent& event);
     void OnToggleButtons(wxCommandEvent& event);
     void OnToggleImages(wxCommandEvent& event);
+    void OnToggleAlternateImages(wxCommandEvent& event);
     void OnSetImageSize(wxCommandEvent& event);
     void OnCollapseAndReset(wxCommandEvent& event);
 
     void OnSetImageSize(wxCommandEvent& event);
     void OnCollapseAndReset(wxCommandEvent& event);
 
@@ -274,6 +279,7 @@ enum
     TreeTest_DeleteAll,
     TreeTest_Recreate,
     TreeTest_ToggleImages,
     TreeTest_DeleteAll,
     TreeTest_Recreate,
     TreeTest_ToggleImages,
+    TreeTest_ToggleAlternateImages,
     TreeTest_ToggleButtons,
     TreeTest_SetImageSize,
     TreeTest_ToggleSel,
     TreeTest_ToggleButtons,
     TreeTest_SetImageSize,
     TreeTest_ToggleSel,
index dd5cdb4bd5a4c43e2c2086325d9043d5f8fb3ab0..bd79bb96e346408085ae57efe60f22baa736a432 100644 (file)
@@ -43,6 +43,7 @@ WX_DEFINE_LIST(wxArtProvidersList)
 // ----------------------------------------------------------------------------
 
 WX_DECLARE_EXPORTED_STRING_HASH_MAP(wxBitmap, wxArtProviderBitmapsHash);
 // ----------------------------------------------------------------------------
 
 WX_DECLARE_EXPORTED_STRING_HASH_MAP(wxBitmap, wxArtProviderBitmapsHash);
+WX_DECLARE_EXPORTED_STRING_HASH_MAP(wxIconBundle, wxArtProviderIconBundlesHash);
 
 class WXDLLEXPORT wxArtProviderCache
 {
 
 class WXDLLEXPORT wxArtProviderCache
 {
@@ -51,14 +52,22 @@ public:
     void PutBitmap(const wxString& full_id, const wxBitmap& bmp)
         { m_bitmapsHash[full_id] = bmp; }
 
     void PutBitmap(const wxString& full_id, const wxBitmap& bmp)
         { m_bitmapsHash[full_id] = bmp; }
 
+    bool GetIconBundle(const wxString& full_id, wxIconBundle* bmp);
+    void PutIconBundle(const wxString& full_id, const wxIconBundle& iconbundle)
+        { m_iconBundlesHash[full_id] = iconbundle; }
+
     void Clear();
 
     static wxString ConstructHashID(const wxArtID& id,
                                     const wxArtClient& client,
                                     const wxSize& size);
 
     void Clear();
 
     static wxString ConstructHashID(const wxArtID& id,
                                     const wxArtClient& client,
                                     const wxSize& size);
 
+    static wxString ConstructHashID(const wxArtID& id,
+                                    const wxArtClient& client);
+
 private:
 private:
-    wxArtProviderBitmapsHash m_bitmapsHash;
+    wxArtProviderBitmapsHash m_bitmapsHash;         // cache of wxBitmaps
+    wxArtProviderIconBundlesHash m_iconBundlesHash; // cache of wxIconBundles
 };
 
 bool wxArtProviderCache::GetBitmap(const wxString& full_id, wxBitmap* bmp)
 };
 
 bool wxArtProviderCache::GetBitmap(const wxString& full_id, wxBitmap* bmp)
@@ -75,21 +84,43 @@ bool wxArtProviderCache::GetBitmap(const wxString& full_id, wxBitmap* bmp)
     }
 }
 
     }
 }
 
+bool wxArtProviderCache::GetIconBundle(const wxString& full_id, wxIconBundle* bmp)
+{
+    wxArtProviderIconBundlesHash::iterator entry = m_iconBundlesHash.find(full_id);
+    if ( entry == m_iconBundlesHash.end() )
+    {
+        return false;
+    }
+    else
+    {
+        *bmp = entry->second;
+        return true;
+    }
+}
+
 void wxArtProviderCache::Clear()
 {
     m_bitmapsHash.clear();
 void wxArtProviderCache::Clear()
 {
     m_bitmapsHash.clear();
+    m_iconBundlesHash.clear();
 }
 
 }
 
-/*static*/ wxString wxArtProviderCache::ConstructHashID(
-                                const wxArtID& id, const wxArtClient& client,
-                                const wxSize& size)
+/* static */ wxString
+wxArtProviderCache::ConstructHashID(const wxArtID& id,
+                                    const wxArtClient& client)
 {
 {
-    wxString str;
-    str.Printf(wxT("%s-%s-%i-%i"), id.c_str(), client.c_str(), size.x, size.y);
-    return str;
+    return id + _T('-') + client;
 }
 
 
 }
 
 
+/* static */ wxString
+wxArtProviderCache::ConstructHashID(const wxArtID& id,
+                                    const wxArtClient& client,
+                                    const wxSize& size)
+{
+    return ConstructHashID(id, client) + _T('-') +
+            wxString::Format(_T("%d-%d"), size.x, size.y);
+}
+
 // ============================================================================
 // wxArtProvider class
 // ============================================================================
 // ============================================================================
 // wxArtProvider class
 // ============================================================================
@@ -216,20 +247,53 @@ wxArtProvider::~wxArtProvider()
 #endif
                 break;
             }
 #endif
                 break;
             }
+            // We could try the IconBundles here and convert what we find
+            // to a bitmap.
         }
         }
-
         sm_cache->PutBitmap(hashId, bmp);
         sm_cache->PutBitmap(hashId, bmp);
-    }
+        }
 
     return bmp;
 }
 
 
     return bmp;
 }
 
+/*static*/ wxIconBundle wxArtProvider::GetIconBundle(const wxArtID& id, const wxArtClient& client)
+{
+    // safety-check against writing client,id,size instead of id,client,size:
+    wxASSERT_MSG( client.Last() == _T('C'), _T("invalid 'client' parameter") );
+
+    wxCHECK_MSG( sm_providers, wxNullIconBundle, _T("no wxArtProvider exists") );
+
+    wxString hashId = wxArtProviderCache::ConstructHashID(id, client);
+
+    wxIconBundle iconbundle;
+    if ( !sm_cache->GetIconBundle(hashId, &iconbundle) )
+    {
+        for (wxArtProvidersList::compatibility_iterator node = sm_providers->GetFirst();
+             node; node = node->GetNext())
+        {
+            iconbundle = node->GetData()->CreateIconBundle(id, client);
+            if ( iconbundle.IsOk() )
+                break;
+        }
+
+        sm_cache->PutIconBundle(hashId, iconbundle);
+    }
+
+    return iconbundle;
+}
+
 /*static*/ wxIcon wxArtProvider::GetIcon(const wxArtID& id,
                                          const wxArtClient& client,
                                          const wxSize& size)
 {
     wxCHECK_MSG( sm_providers, wxNullIcon, _T("no wxArtProvider exists") );
 
 /*static*/ wxIcon wxArtProvider::GetIcon(const wxArtID& id,
                                          const wxArtClient& client,
                                          const wxSize& size)
 {
     wxCHECK_MSG( sm_providers, wxNullIcon, _T("no wxArtProvider exists") );
 
+    // First look for an appropriate icon bundle - this will give us the best icon
+    wxIconBundle iconBundle = GetIconBundle(id, client);
+    if ( iconBundle.IsOk() )
+        return iconBundle.GetIcon(size);
+
+    // If there is no icon bundle then look for a bitmap
     wxBitmap bmp = GetBitmap(id, client, size);
     if ( !bmp.Ok() )
         return wxNullIcon;
     wxBitmap bmp = GetBitmap(id, client, size);
     if ( !bmp.Ok() )
         return wxNullIcon;
index c3e4fe994b110ace2d9cd26c0727d4a4a7e7bbc8..c5a9679e3892ff43aa9e8b34cf8e0aa788790f47 100644 (file)
@@ -77,7 +77,7 @@ protected:
     wxArtProvider::Push(new wxDefaultArtProvider);
 }
 
     wxArtProvider::Push(new wxDefaultArtProvider);
 }
 
-#if !defined(__WXGTK20__) || defined(__WXUNIVERSAL__)
+#if !(defined(__WXGTK20__) || defined(__WXMAC__)) || defined(__WXUNIVERSAL__)
 /*static*/ void wxArtProvider::InitNativeProvider()
 {
 }
 /*static*/ void wxArtProvider::InitNativeProvider()
 {
 }
index a4b09c94938c0f7874a2a5c881f3aef3f12d2fa2..0214f8cad3fa200d5386ab835578df99e4adc549 100644 (file)
@@ -25,6 +25,7 @@
     #include "wx/brush.h"
     #include "wx/palette.h"
     #include "wx/icon.h"
     #include "wx/brush.h"
     #include "wx/palette.h"
     #include "wx/icon.h"
+    #include "wx/iconbndl.h"
     #include "wx/cursor.h"
     #include "wx/settings.h"
     #include "wx/bitmap.h"
     #include "wx/cursor.h"
     #include "wx/settings.h"
     #include "wx/bitmap.h"
@@ -52,6 +53,7 @@ WXDLLIMPEXP_DATA_CORE(wxPen)     wxNullPen;
 #if wxUSE_PALETTE
 WXDLLIMPEXP_DATA_CORE(wxPalette) wxNullPalette;
 #endif
 #if wxUSE_PALETTE
 WXDLLIMPEXP_DATA_CORE(wxPalette) wxNullPalette;
 #endif
+WXDLLIMPEXP_DATA_CORE(wxIconBundle) wxNullIconBundle;
 
 const wxSize wxDefaultSize(wxDefaultCoord, wxDefaultCoord);
 const wxPoint wxDefaultPosition(wxDefaultCoord, wxDefaultCoord);
 
 const wxSize wxDefaultSize(wxDefaultCoord, wxDefaultCoord);
 const wxPoint wxDefaultPosition(wxDefaultCoord, wxDefaultCoord);
index e15376f5bb2bc8f8307c7ad72c02d5f46bc4d1bd..19ede4871a4845a261e7d8c79e6300e664ab3343 100644 (file)
@@ -1,13 +1,21 @@
 /////////////////////////////////////////////////////////////////////////////
 // Name:        src/common/iconbndl.cpp
 // Purpose:     wxIconBundle
 /////////////////////////////////////////////////////////////////////////////
 // Name:        src/common/iconbndl.cpp
 // Purpose:     wxIconBundle
-// Author:      Mattia Barbon
+// Author:      Mattia Barbon, Vadim Zeitlin
 // Created:     23.03.2002
 // RCS-ID:      $Id$
 // Copyright:   (c) Mattia barbon
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // Created:     23.03.2002
 // RCS-ID:      $Id$
 // Copyright:   (c) Mattia barbon
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
 
 WX_DEFINE_OBJARRAY(wxIconArray)
 
 
 WX_DEFINE_OBJARRAY(wxIconArray)
 
-const wxIconBundle& wxIconBundle::operator =( const wxIconBundle& ic )
+IMPLEMENT_DYNAMIC_CLASS(wxIconBundle, wxGDIObject)
+
+#define M_ICONBUNDLEDATA ((wxIconBundleRefData *)m_refData)
+
+// ----------------------------------------------------------------------------
+// wxIconBundleRefData
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxIconBundleRefData : public wxGDIRefData
+{
+public:
+    // default and copy ctors and assignment operators are ok
+
+protected:
+    wxIconArray m_icons;
+
+    friend class WXDLLEXPORT wxIconBundle;
+};
+
+// ============================================================================
+// wxIconBundle implementation
+// ============================================================================
+
+wxIconBundle::wxIconBundle()
+            : wxGDIObject()
+{
+    m_refData = new wxIconBundleRefData;
+}
+
+wxIconBundle::wxIconBundle(const wxString& file, long type)
+            : wxGDIObject()
 {
 {
-    if( this == &ic ) return *this;
+    m_refData = new wxIconBundleRefData;
+    AddIcon(file, type);
+}
 
 
-    size_t i, max = ic.m_icons.GetCount();
+wxIconBundle::wxIconBundle(const wxIconBundle& icon)
+            : wxGDIObject()
+{
+    Ref(icon);
+}
 
 
-    DeleteIcons();
-    for( i = 0; i < max; ++i )
-        m_icons.Add( ic.m_icons[i] );
+wxIconBundle::wxIconBundle(const wxIcon& icon)
+            : wxGDIObject()
+{
+    m_refData = new wxIconBundleRefData;
+    AddIcon(icon);
+}
 
 
-    return *this;
+wxObjectRefData *wxIconBundle::CreateRefData() const
+{
+    return new wxIconBundleRefData;
+}
+
+wxObjectRefData *wxIconBundle::CloneRefData(const wxObjectRefData *data) const
+{
+    return new wxIconBundleRefData(*wx_static_cast(const wxIconBundleRefData *, data));
 }
 
 void wxIconBundle::DeleteIcons()
 {
 }
 
 void wxIconBundle::DeleteIcons()
 {
-    m_icons.Empty();
+    wxIconBundleRefData* ref = new wxIconBundleRefData();
+    UnRef();
+    m_refData = ref;
 }
 
 }
 
-#if wxUSE_IMAGE
-void wxIconBundle::AddIcon( const wxString& file, long type )
-#else
-void wxIconBundle::AddIcon( const wxString& WXUNUSED(file), long WXUNUSED(type) )
-#endif
+bool wxIconBundle::IsOk() const
+{
+    return M_ICONBUNDLEDATA && !M_ICONBUNDLEDATA->m_icons.IsEmpty();
+}
+
+void wxIconBundle::AddIcon(const wxString& file, long type)
 {
 {
+#ifdef __WXMAC__
+    // Deal with standard icons
+    if ( type == wxBITMAP_TYPE_ICON_RESOURCE )
+    {
+        wxIcon tmp(file, type);
+        if (tmp.Ok())
+        {
+            AddIcon(tmp);
+            return;
+        }
+    }
+#endif // __WXMAC__
+
 #if wxUSE_IMAGE && (!defined(__WXMSW__) || wxUSE_WXDIB)
 #if wxUSE_IMAGE && (!defined(__WXMSW__) || wxUSE_WXDIB)
-    size_t count = wxImage::GetImageCount( file, type );
-    size_t i;
     wxImage image;
 
     wxImage image;
 
-    for( i = 0; i < count; ++i )
+    const size_t count = wxImage::GetImageCount( file, type );
+    for ( size_t i = 0; i < count; ++i )
     {
     {
-        if( !image.LoadFile( file, type, i ) )
+        if ( !image.LoadFile( file, type, i ) )
         {
             wxLogError( _("Failed to load image %d from file '%s'."),
                         i, file.c_str() );
             continue;
         }
 
         {
             wxLogError( _("Failed to load image %d from file '%s'."),
                         i, file.c_str() );
             continue;
         }
 
-        wxIcon* tmp = new wxIcon();
-        tmp->CopyFromBitmap( wxBitmap( image ) );
-        AddIcon( *tmp );
-        delete tmp;
+        wxIcon tmp;
+        tmp.CopyFromBitmap(wxBitmap(image));
+        AddIcon(tmp);
     }
     }
-#endif
+#else // !wxUSE_IMAGE
+    wxUnusedVar(file);
+    wxUnusedVar(type);
+#endif // wxUSE_IMAGE/!wxUSE_IMAGE
 }
 
 }
 
-const wxIcon& wxIconBundle::GetIcon( const wxSize& size ) const
+wxIcon wxIconBundle::GetIcon(const wxSize& size) const
 {
 {
-    // temp. variable needed to fix Borland C++ 5.5.1 problem
-    // with passing a return value through two functions
-    wxIcon *tmp;
-
-    size_t max = m_icons.GetCount();
-
-    // if we have one or no icon, we can return now without doing more work:
-    if ( max <= 1 )
-    {
-        if ( max == 1 ) // fix for broken BCC
-            tmp = &m_icons[0];
-        else // max == 0
-            tmp = &wxNullIcon;
-        return *tmp;
-    }
+    wxCHECK_MSG( IsOk(), wxNullIcon, _T("invalid icon bundle") );
 
 
-    // there are more icons, find the best match:
-    wxCoord sysX = wxSystemSettings::GetMetric( wxSYS_ICON_X ),
-            sysY = wxSystemSettings::GetMetric( wxSYS_ICON_Y );
+    const wxIconArray& iconArray = M_ICONBUNDLEDATA->m_icons;
 
 
-    wxIcon *sysIcon = 0;
+    const size_t count = iconArray.size();
 
 
-    for( size_t i = 0; i < max; i++ )
+    // optimize for the common case of icon bundles containing one icon only
+    wxIcon iconBest;
+    switch ( count )
     {
     {
-        if( !m_icons[i].Ok() )
-            continue;
-        wxCoord sx = m_icons[i].GetWidth(), sy = m_icons[i].GetHeight();
-        // requested size
-        if( sx == size.x && sy == size.y )
-        {
-            tmp = &m_icons[i]; // fix for broken BCC
-            return *tmp;
-        }
-        // keep track if there is a system-size icon
-        if( sx == sysX && sy == sysY )
-            sysIcon = &m_icons[i];
+        case 0:
+            // nothing to do, iconBest is already invalid
+            break;
+
+        case 1:
+            iconBest = iconArray[0];
+            break;
+
+        default:
+            // there is more than one icon, find the best match:
+            wxCoord sysX = wxSystemSettings::GetMetric( wxSYS_ICON_X ),
+                    sysY = wxSystemSettings::GetMetric( wxSYS_ICON_Y );
+
+            for ( size_t i = 0; i < count; i++ )
+            {
+                const wxIcon& icon = iconArray[i];
+                wxCoord sx = icon.GetWidth(),
+                        sy = icon.GetHeight();
+
+                // if we got an icon of exactly the requested size, we're done
+                if ( sx == size.x && sy == size.y )
+                {
+                    iconBest = icon;
+                    break;
+                }
+
+                // the best icon is by default (arbitrarily) the first one but
+                // if we find a system-sized icon, take it instead
+                if ( sx == sysX && sy == sysY || !iconBest.IsOk() )
+                    iconBest = icon;
+            }
     }
 
     }
 
-    // return the system-sized icon if we've got one
-    if( sysIcon ) return *sysIcon;
-    // we certainly have at least one icon thanks to the <=1 check above
-    tmp = &m_icons[0];
-    return *tmp;
+#ifdef __WXMAC__
+    return wxIcon(iconBest.GetHICON(), size);
+#else
+    return iconBest;
+#endif
 }
 
 }
 
-void wxIconBundle::AddIcon( const wxIcon& icon )
+void wxIconBundle::AddIcon(const wxIcon& icon)
 {
 {
-    size_t i, max = m_icons.GetCount();
+    wxCHECK_RET( icon.IsOk(), _T("invalid icon") );
 
 
-    for( i = 0; i < max; ++i )
+    AllocExclusive();
+
+    wxIconArray& iconArray = M_ICONBUNDLEDATA->m_icons;
+
+    // replace existing icon with the same size if we already have it
+    const size_t count = iconArray.size();
+    for ( size_t i = 0; i < count; ++i )
     {
     {
-        wxIcon& tmp = m_icons[i];
-        if( tmp.Ok() && tmp.GetWidth() == icon.GetWidth() &&
-            tmp.GetHeight() == icon.GetHeight() )
+        wxIcon& tmp = iconArray[i];
+        if ( tmp.Ok() &&
+                tmp.GetWidth() == icon.GetWidth() &&
+                tmp.GetHeight() == icon.GetHeight() )
         {
             tmp = icon;
             return;
         }
     }
 
         {
             tmp = icon;
             return;
         }
     }
 
-    m_icons.Add( icon );
+    // if we don't, add an icon with new size
+    iconArray.Add(icon);
 }
 }
+
+size_t wxIconBundle::GetIconCount() const
+{
+    return M_ICONBUNDLEDATA->m_icons.size();
+}
+
+wxIcon wxIconBundle::GetIconByIndex(size_t n) const
+{
+    return M_ICONBUNDLEDATA->m_icons[n];
+}
+
index f47a53f8b8ff7e4f82611d362e6d4e84447ccf2b..b97cae23634caf99a203986422fed8ab87c89557 100644 (file)
@@ -1175,7 +1175,13 @@ void wxTopLevelWindowGTK::SetTitle( const wxString &title )
 
 void wxTopLevelWindowGTK::SetIcon( const wxIcon &icon )
 {
 
 void wxTopLevelWindowGTK::SetIcon( const wxIcon &icon )
 {
-    SetIcons( wxIconBundle( icon ) );
+    // passing wxNullIcon to SetIcon() is possible (it means that we shouldn't
+    // have any icon), but adding an invalid icon to wxIconBundle is not
+    wxIconBundle icons;
+    if ( icon.Ok() )
+        icons.AddIcon(icon);
+
+    SetIcons(icons);
 }
 
 void wxTopLevelWindowGTK::SetIcons( const wxIconBundle &icons )
 }
 
 void wxTopLevelWindowGTK::SetIcons( const wxIconBundle &icons )
@@ -1185,15 +1191,13 @@ void wxTopLevelWindowGTK::SetIcons( const wxIconBundle &icons )
     wxTopLevelWindowBase::SetIcons( icons );
 
     GList *list = NULL;
     wxTopLevelWindowBase::SetIcons( icons );
 
     GList *list = NULL;
-    size_t max = icons.m_icons.GetCount();
 
 
-    for (size_t i = 0; i < max; i++)
+    const size_t numIcons = icons.GetIconCount();
+    for ( size_t i = 0; i < numIcons; i++ )
     {
     {
-        if (icons.m_icons[i].Ok())
-        {
-            list = g_list_prepend(list, icons.m_icons[i].GetPixbuf());
-        }
+        list = g_list_prepend(list, icons.GetIconByIndex(i).GetPixbuf());
     }
     }
+
     gtk_window_set_icon_list(GTK_WINDOW(m_widget), list);
     g_list_free(list);
 }
     gtk_window_set_icon_list(GTK_WINDOW(m_widget), list);
     g_list_free(list);
 }
diff --git a/src/mac/carbon/artmac.cpp b/src/mac/carbon/artmac.cpp
new file mode 100644 (file)
index 0000000..466ba9b
--- /dev/null
@@ -0,0 +1,108 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        src/mac/carbon/artmac.cpp
+// Purpose:     wxArtProvider instance with native Mac stock icons
+// Author:      Alan Shouls
+// Created:     2006-10-30
+// RCS-ID:      $Id$
+// Copyright:   (c) wxWindows team
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+// ---------------------------------------------------------------------------
+// headers
+// ---------------------------------------------------------------------------
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#if defined(__BORLANDC__)
+    #pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+    #include "wx/image.h"
+#endif
+
+#include "wx/artprov.h"
+#include "wx/image.h"
+
+// ----------------------------------------------------------------------------
+// wxMacArtProvider
+// ----------------------------------------------------------------------------
+
+class wxMacArtProvider : public wxArtProvider
+{
+protected:
+    virtual wxBitmap CreateBitmap(const wxArtID& id, const wxArtClient& client,
+                                  const wxSize& size);
+    virtual wxIconBundle CreateIconBundle(const wxArtID& id,
+                                          const wxArtClient& client);
+};
+
+/* static */ void wxArtProvider::InitNativeProvider()
+{
+    wxArtProvider::Push(new wxMacArtProvider);
+}
+
+// ----------------------------------------------------------------------------
+// helper macros
+// ----------------------------------------------------------------------------
+
+#define CREATE_STD_ICON(iconId, xpmRc) \
+    { \
+        wxIconBundle icon(_T(iconId), wxBITMAP_TYPE_ICON_RESOURCE); \
+        return icon; \
+    }
+
+// Macro used in CreateBitmap to get wxICON_FOO icons:
+#define ART_MSGBOX(artId, iconId, xpmRc) \
+    if ( id == artId ) \
+    { \
+        CREATE_STD_ICON(#iconId, xpmRc) \
+    }
+
+static wxIconBundle wxMacArtProvider_CreateIconBundle(const wxArtID& id)
+{
+    ART_MSGBOX(wxART_ERROR,       wxICON_ERROR,       error)
+    ART_MSGBOX(wxART_INFORMATION, wxICON_INFORMATION, info)
+    ART_MSGBOX(wxART_WARNING,     wxICON_WARNING,     warning)
+    ART_MSGBOX(wxART_QUESTION,    wxICON_QUESTION,    question)
+
+    ART_MSGBOX(wxART_FOLDER,      wxICON_FOLDER,      folder)
+    ART_MSGBOX(wxART_FOLDER_OPEN, wxICON_FOLDER_OPEN, folder_open)
+    ART_MSGBOX(wxART_NORMAL_FILE, wxICON_NORMAL_FILE, deffile)
+
+    return wxNullIconBundle;
+}
+
+// ----------------------------------------------------------------------------
+// CreateIconBundle
+// ----------------------------------------------------------------------------
+
+wxIconBundle wxMacArtProvider::CreateIconBundle(const wxArtID& id, const wxArtClient& client)
+{
+    // On the Mac folders in lists are always drawn closed, so if an open
+    // folder icon is asked for we will ask for a closed one in its place
+    if ( client == wxART_LIST && id == wxART_FOLDER_OPEN )
+        return wxMacArtProvider_CreateIconBundle(wxART_FOLDER);
+
+    return wxMacArtProvider_CreateIconBundle(id);
+}
+
+// ----------------------------------------------------------------------------
+// CreateBitmap
+// ----------------------------------------------------------------------------
+
+wxBitmap wxMacArtProvider::CreateBitmap(const wxArtID& id,
+                                        const wxArtClient& client,
+                                        const wxSize& reqSize)
+{
+    wxIconBundle ic(CreateIconBundle(id, client));
+    if (ic.IsOk())
+    {
+        wxIcon theIcon(ic.GetIcon(reqSize));
+        return wxBitmap(theIcon);
+    }
+
+    return wxNullBitmap;
+}
index 7084b59cfcd6f6e2a6f545c18f3c577fb1cf75a0..68e908bf25b9bf5bb4741d98ce18470fa1eed8fd 100644 (file)
@@ -53,6 +53,18 @@ wxIcon::wxIcon(
     LoadFile( icon_file, (wxBitmapType) flags, desiredWidth, desiredHeight );
 }
 
     LoadFile( icon_file, (wxBitmapType) flags, desiredWidth, desiredHeight );
 }
 
+wxIcon::wxIcon(WXHICON icon, const wxSize& size)
+      : wxGDIObject()
+{
+    // as the icon owns that ref, we have to acquire it as well
+    if (icon)
+        AcquireIconRef( (IconRef) icon ) ;
+
+    m_refData = new wxIconRefData( icon ) ;
+    M_ICONDATA->SetWidth( size.x ) ;
+    M_ICONDATA->SetHeight( size.y ) ;
+}
+
 wxIcon::~wxIcon()
 {
 }
 wxIcon::~wxIcon()
 {
 }
@@ -126,6 +138,18 @@ bool wxIcon::LoadFile(
         {
             theId = kAlertStopIcon ;
         }
         {
             theId = kAlertStopIcon ;
         }
+        else if ( filename == wxT("wxICON_FOLDER") )
+        {
+            theId = kGenericFolderIcon ;
+        }
+        else if ( filename == wxT("wxICON_FOLDER_OPEN") )
+        {
+            theId = kOpenFolderIcon ;
+        }
+        else if ( filename == wxT("wxICON_NORMAL_FILE") )
+        {
+            theId = kGenericDocumentIcon ;
+        }
         else
         {
 #if 0
         else
         {
 #if 0
index f6627e6e69b51d904d5fdcb1935208f4791017bf..67e641c3cb5a92061372bcc0581542e803619674 100644 (file)
@@ -106,31 +106,32 @@ private:
 // Setting icons for window manager:
 // ----------------------------------------------------------------------------
 
 // Setting icons for window manager:
 // ----------------------------------------------------------------------------
 
-void wxSetIconsX11( WXDisplay* display, WXWindow window,
-                    const wxIconBundle& ib )
+void
+wxSetIconsX11(WXDisplay* display, WXWindow window, const wxIconBundle& ib)
 {
 #if !wxUSE_NANOX
     size_t size = 0;
 {
 #if !wxUSE_NANOX
     size_t size = 0;
-    size_t i, max = ib.m_icons.GetCount();
 
 
-    for( i = 0; i < max; ++i )
-        if( ib.m_icons[i].Ok() )
-            size += 2 + ib.m_icons[i].GetWidth() * ib.m_icons[i].GetHeight();
+    const size_t numIcons = ib.GetIconCount();
+    for ( size_t i = 0; i < numIcons; ++i )
+    {
+        const wxIcon icon = ib.GetIconByIndex(i);
+
+        size += 2 + icon.GetWidth() * icon.GetHeight();
+    }
 
     wxMAKE_ATOM(_NET_WM_ICON, (Display*)display);
 
 
     wxMAKE_ATOM(_NET_WM_ICON, (Display*)display);
 
-    if( size > 0 )
+    if ( size > 0 )
     {
     {
-//       The code below is correct for 64-bit machines also.
-//       wxUint32* data = new wxUint32[size];
-//       wxUint32* ptr = data;
         unsigned long* data = new unsigned long[size];
         unsigned long* ptr = data;
 
         unsigned long* data = new unsigned long[size];
         unsigned long* ptr = data;
 
-        for( i = 0; i < max; ++i )
+        for ( size_t i = 0; i < numIcons; ++i )
         {
         {
-            const wxImage image = ib.m_icons[i].ConvertToImage();
-            int width = image.GetWidth(), height = image.GetHeight();
+            const wxImage image = ib.GetIconByIndex(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* imageData = image.GetData();
             unsigned char* imageDataEnd = imageData + ( width * height * 3 );
             bool hasMask = image.HasMask();
@@ -153,7 +154,8 @@ void wxSetIconsX11( WXDisplay* display, WXWindow window,
             *ptr++ = width;
             *ptr++ = height;
 
             *ptr++ = width;
             *ptr++ = height;
 
-            while( imageData < imageDataEnd ) {
+            while ( imageData < imageDataEnd )
+            {
                 r = imageData[0];
                 g = imageData[1];
                 b = imageData[2];
                 r = imageData[0];
                 g = imageData[1];
                 b = imageData[2];