1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface stuff for wxArtProvider
7 // Created: 18-June-1999
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
16 //---------------------------------------------------------------------------
20 #include <wx/artprov.h>
23 //---------------------------------------------------------------------------
27 MAKE_CONST_WXSTRING(ART_TOOLBAR);
28 MAKE_CONST_WXSTRING(ART_MENU);
29 MAKE_CONST_WXSTRING(ART_FRAME_ICON);
30 MAKE_CONST_WXSTRING(ART_CMN_DIALOG);
31 MAKE_CONST_WXSTRING(ART_HELP_BROWSER);
32 MAKE_CONST_WXSTRING(ART_MESSAGE_BOX);
33 MAKE_CONST_WXSTRING(ART_BUTTON);
34 MAKE_CONST_WXSTRING(ART_OTHER);
37 MAKE_CONST_WXSTRING(ART_ADD_BOOKMARK);
38 MAKE_CONST_WXSTRING(ART_DEL_BOOKMARK);
39 MAKE_CONST_WXSTRING(ART_HELP_SIDE_PANEL);
40 MAKE_CONST_WXSTRING(ART_HELP_SETTINGS);
41 MAKE_CONST_WXSTRING(ART_HELP_BOOK);
42 MAKE_CONST_WXSTRING(ART_HELP_FOLDER);
43 MAKE_CONST_WXSTRING(ART_HELP_PAGE);
44 MAKE_CONST_WXSTRING(ART_GO_BACK);
45 MAKE_CONST_WXSTRING(ART_GO_FORWARD);
46 MAKE_CONST_WXSTRING(ART_GO_UP);
47 MAKE_CONST_WXSTRING(ART_GO_DOWN);
48 MAKE_CONST_WXSTRING(ART_GO_TO_PARENT);
49 MAKE_CONST_WXSTRING(ART_GO_HOME);
50 MAKE_CONST_WXSTRING(ART_FILE_OPEN);
51 MAKE_CONST_WXSTRING(ART_PRINT);
52 MAKE_CONST_WXSTRING(ART_HELP);
53 MAKE_CONST_WXSTRING(ART_TIP);
54 MAKE_CONST_WXSTRING(ART_REPORT_VIEW);
55 MAKE_CONST_WXSTRING(ART_LIST_VIEW);
56 MAKE_CONST_WXSTRING(ART_NEW_DIR);
57 MAKE_CONST_WXSTRING(ART_FOLDER);
58 MAKE_CONST_WXSTRING(ART_GO_DIR_UP);
59 MAKE_CONST_WXSTRING(ART_EXECUTABLE_FILE);
60 MAKE_CONST_WXSTRING(ART_NORMAL_FILE);
61 MAKE_CONST_WXSTRING(ART_TICK_MARK);
62 MAKE_CONST_WXSTRING(ART_CROSS_MARK);
63 MAKE_CONST_WXSTRING(ART_ERROR);
64 MAKE_CONST_WXSTRING(ART_QUESTION);
65 MAKE_CONST_WXSTRING(ART_WARNING);
66 MAKE_CONST_WXSTRING(ART_INFORMATION);
67 MAKE_CONST_WXSTRING(ART_MISSING_IMAGE);
69 //---------------------------------------------------------------------------
71 %{ // Python aware wxArtProvider
72 class wxPyArtProvider : public wxArtProvider {
75 virtual wxBitmap CreateBitmap(const wxArtID& id,
76 const wxArtClient& client,
78 wxBitmap rval = wxNullBitmap;
79 bool blocked = wxPyBeginBlockThreads();
80 if ((wxPyCBH_findCallback(m_myInst, "CreateBitmap"))) {
81 PyObject* so = wxPyConstructObject((void*)&size, wxT("wxSize"), 0);
86 s2 = wx2PyString(client);
87 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OOO)", s1, s2, so));
92 if (wxPyConvertSwigPtr(ro, (void**)&ptr, wxT("wxBitmap")))
97 wxPyEndBlockThreads(blocked);
105 // The one for SWIG to see
109 DocStr(wxPyArtProvider,
110 "The wx.ArtProvider class is used to customize the look of wxWidgets
111 application. When wxWidgets needs to display an icon or a bitmap (e.g.
112 in the standard file dialog), it does not use hard-coded resource but
113 asks wx.ArtProvider for it instead. This way the users can plug in
114 their own wx.ArtProvider class and easily replace standard art with
115 his/her own version. It is easy thing to do: all that is needed is
116 to derive a class from wx.ArtProvider, override it's CreateBitmap
117 method and register the provider with wx.ArtProvider.PushProvider::
119 class MyArtProvider(wx.ArtProvider):
121 wx.ArtProvider.__init__(self)
123 def CreateBitmap(self, artid, client, size):
128 Identifying art resources
129 -------------------------
131 Every bitmap is known to wx.ArtProvider under an unique ID that is
132 used when requesting a resource from it. The IDs can have one of the
133 following predefined values. Additionally, any string recognized by
134 custom art providers registered using `PushProvider` may be used. When
135 running under GTK+ 2, GTK+ stock item IDs (e.g. 'gtk-cdrom') may be
139 * wx.ART_ADD_BOOKMARK
140 * wx.ART_DEL_BOOKMARK
141 * wx.ART_HELP_SIDE_PANEL
142 * wx.ART_HELP_SETTINGS
150 * wx.ART_GO_TO_PARENT
161 * wx.ART_EXECUTABLE_FILE
169 * wx.ART_MISSING_IMAGE
175 The Client is the entity that calls wx.ArtProvider's `GetBitmap` or
176 `GetIcon` function. Client IDs serve as a hint to wx.ArtProvider
177 that is supposed to help it to choose the best looking bitmap. For
178 example it is often desirable to use slightly different icons in menus
179 and toolbars even though they represent the same action (e.g.
180 wx.ART_FILE_OPEN). Remember that this is really only a hint for
181 wx.ArtProvider -- it is common that `wx.ArtProvider.GetBitmap` returns
182 identical bitmap for different client values!
188 * wx.ART_HELP_BROWSER
191 * wx.ART_OTHER (used for all requests that don't fit into any
192 of the categories above)
195 MustHaveApp(wxPyArtProvider);
196 MustHaveApp(wxPyArtProvider::GetBitmap);
197 MustHaveApp(wxPyArtProvider::GetIcon);
199 %name(ArtProvider) class wxPyArtProvider /*: public wxObject*/
203 %pythonAppend wxPyArtProvider "self._setCallbackInfo(self, ArtProvider)"
206 void _setCallbackInfo(PyObject* self, PyObject* _class);
209 static void , PushProvider(wxPyArtProvider *provider),
210 "Add new provider to the top of providers stack.", "");
214 static bool , PopProvider(),
215 "Remove latest added provider and delete it.", "");
219 static bool , RemoveProvider(wxPyArtProvider *provider),
220 "Remove provider. The provider must have been added previously! The
221 provider is _not_ deleted.", "");
225 static wxBitmap , GetBitmap(const wxString& id,
226 const wxString& client = wxPyART_OTHER,
227 const wxSize& size = wxDefaultSize),
228 "Query the providers for bitmap with given ID and return it. Return
229 wx.NullBitmap if no provider provides it.", "");
233 static wxIcon , GetIcon(const wxString& id,
234 const wxString& client = wxPyART_OTHER,
235 const wxSize& size = wxDefaultSize),
236 "Query the providers for icon with given ID and return it. Return
237 wx.NullIcon if no provider provides it.", "");
240 %extend { void Destroy() { delete self; }}
245 //---------------------------------------------------------------------------
247 wxPyPtrTypeMap_Add("wxArtProvider", "wxPyArtProvider");
249 //---------------------------------------------------------------------------