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_LIST);
35 MAKE_CONST_WXSTRING(ART_OTHER);
38 MAKE_CONST_WXSTRING(ART_ADD_BOOKMARK);
39 MAKE_CONST_WXSTRING(ART_DEL_BOOKMARK);
40 MAKE_CONST_WXSTRING(ART_HELP_SIDE_PANEL);
41 MAKE_CONST_WXSTRING(ART_HELP_SETTINGS);
42 MAKE_CONST_WXSTRING(ART_HELP_BOOK);
43 MAKE_CONST_WXSTRING(ART_HELP_FOLDER);
44 MAKE_CONST_WXSTRING(ART_HELP_PAGE);
45 MAKE_CONST_WXSTRING(ART_GO_BACK);
46 MAKE_CONST_WXSTRING(ART_GO_FORWARD);
47 MAKE_CONST_WXSTRING(ART_GO_UP);
48 MAKE_CONST_WXSTRING(ART_GO_DOWN);
49 MAKE_CONST_WXSTRING(ART_GO_TO_PARENT);
50 MAKE_CONST_WXSTRING(ART_GO_HOME);
51 MAKE_CONST_WXSTRING(ART_FILE_OPEN);
52 MAKE_CONST_WXSTRING(ART_FILE_SAVE);
53 MAKE_CONST_WXSTRING(ART_FILE_SAVE_AS);
54 MAKE_CONST_WXSTRING(ART_PRINT);
55 MAKE_CONST_WXSTRING(ART_HELP);
56 MAKE_CONST_WXSTRING(ART_TIP);
57 MAKE_CONST_WXSTRING(ART_REPORT_VIEW);
58 MAKE_CONST_WXSTRING(ART_LIST_VIEW);
59 MAKE_CONST_WXSTRING(ART_NEW_DIR);
60 MAKE_CONST_WXSTRING(ART_HARDDISK);
61 MAKE_CONST_WXSTRING(ART_FLOPPY);
62 MAKE_CONST_WXSTRING(ART_CDROM);
63 MAKE_CONST_WXSTRING(ART_REMOVABLE);
64 MAKE_CONST_WXSTRING(ART_FOLDER);
65 MAKE_CONST_WXSTRING(ART_FOLDER_OPEN);
66 MAKE_CONST_WXSTRING(ART_GO_DIR_UP);
67 MAKE_CONST_WXSTRING(ART_EXECUTABLE_FILE);
68 MAKE_CONST_WXSTRING(ART_NORMAL_FILE);
69 MAKE_CONST_WXSTRING(ART_TICK_MARK);
70 MAKE_CONST_WXSTRING(ART_CROSS_MARK);
71 MAKE_CONST_WXSTRING(ART_ERROR);
72 MAKE_CONST_WXSTRING(ART_QUESTION);
73 MAKE_CONST_WXSTRING(ART_WARNING);
74 MAKE_CONST_WXSTRING(ART_INFORMATION);
75 MAKE_CONST_WXSTRING(ART_MISSING_IMAGE);
76 MAKE_CONST_WXSTRING(ART_COPY);
77 MAKE_CONST_WXSTRING(ART_CUT);
78 MAKE_CONST_WXSTRING(ART_PASTE);
79 MAKE_CONST_WXSTRING(ART_DELETE);
80 MAKE_CONST_WXSTRING(ART_NEW);
81 MAKE_CONST_WXSTRING(ART_UNDO);
82 MAKE_CONST_WXSTRING(ART_REDO);
83 MAKE_CONST_WXSTRING(ART_QUIT);
84 MAKE_CONST_WXSTRING(ART_FIND);
85 MAKE_CONST_WXSTRING(ART_FIND_AND_REPLACE);
87 //---------------------------------------------------------------------------
89 %{ // Python aware wxArtProvider
90 class wxPyArtProvider : public wxArtProvider {
93 virtual wxBitmap CreateBitmap(const wxArtID& id,
94 const wxArtClient& client,
96 wxBitmap rval = wxNullBitmap;
97 wxPyBlock_t blocked = wxPyBeginBlockThreads();
98 if ((wxPyCBH_findCallback(m_myInst, "CreateBitmap"))) {
99 PyObject* so = wxPyConstructObject((void*)&size, wxT("wxSize"), 0);
103 s1 = wx2PyString(id);
104 s2 = wx2PyString(client);
105 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OOO)", s1, s2, so));
110 if (wxPyConvertSwigPtr(ro, (void**)&ptr, wxT("wxBitmap")))
115 wxPyEndBlockThreads(blocked);
119 virtual wxIconBundle CreateIconBundle(const wxArtID& id,
120 const wxArtClient& client)
122 wxIconBundle rval = wxNullIconBundle;
123 wxPyBlock_t blocked = wxPyBeginBlockThreads();
124 if ((wxPyCBH_findCallback(m_myInst, "CreateIconBundle"))) {
128 s1 = wx2PyString(id);
129 s2 = wx2PyString(client);
130 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)", s1, s2));
134 if (wxPyConvertSwigPtr(ro, (void**)&ptr, wxT("wxIconBundle")))
139 wxPyEndBlockThreads(blocked);
147 // The one for SWIG to see
151 DocStr(wxPyArtProvider,
152 "The wx.ArtProvider class is used to customize the look of wxWidgets
153 application. When wxWidgets needs to display an icon or a bitmap (e.g.
154 in the standard file dialog), it does not use hard-coded resource but
155 asks wx.ArtProvider for it instead. This way the users can plug in
156 their own wx.ArtProvider class and easily replace standard art with
157 his/her own version. It is easy thing to do: all that is needed is
158 to derive a class from wx.ArtProvider, override it's CreateBitmap
159 method and register the provider with `wx.ArtProvider.Push`::
161 class MyArtProvider(wx.ArtProvider):
163 wx.ArtProvider.__init__(self)
165 def CreateBitmap(self, artid, client, size):
170 Identifying art resources
171 -------------------------
173 Every bitmap is known to wx.ArtProvider under an unique ID that is
174 used when requesting a resource from it. The IDs can have one of the
175 following predefined values. Additionally, any string recognized by
176 custom art providers registered using `Push` may be used.
181 When running under GTK+ 2, GTK+ stock item IDs (e.g. 'gtk-cdrom') may be used
182 as well. Additionally, if wxGTK was compiled against GTK+ >= 2.4, then it is
183 also possible to load icons from current icon theme by specifying their name
184 without the extension and directory components. Icon themes recognized by GTK+
185 follow the freedesktop.org Icon Themes specification. Note that themes are
186 not guaranteed to contain all icons, so wx.ArtProvider may return wx.NullBitmap
187 or wx.NullIcon. The default theme is typically installed in /usr/share/icons/hicolor.
189 * wx.ART_ADD_BOOKMARK
190 * wx.ART_DEL_BOOKMARK
191 * wx.ART_HELP_SIDE_PANEL
192 * wx.ART_HELP_SETTINGS
200 * wx.ART_GO_TO_PARENT
204 * wx.ART_FILE_SAVE_AS
218 * wx.ART_EXECUTABLE_FILE
226 * wx.ART_MISSING_IMAGE
236 * wx.ART_FIND_AND_REPLACE
242 The Client is the entity that calls wx.ArtProvider's `GetBitmap` or
243 `GetIcon` function. Client IDs serve as a hint to wx.ArtProvider
244 that is supposed to help it to choose the best looking bitmap. For
245 example it is often desirable to use slightly different icons in menus
246 and toolbars even though they represent the same action (e.g.
247 wx.ART_FILE_OPEN). Remember that this is really only a hint for
248 wx.ArtProvider -- it is common that `wx.ArtProvider.GetBitmap` returns
249 identical bitmap for different client values!
255 * wx.ART_HELP_BROWSER
258 * wx.ART_OTHER (used for all requests that don't fit into any
259 of the categories above)
262 MustHaveApp(wxPyArtProvider);
263 MustHaveApp(wxPyArtProvider::GetBitmap);
264 MustHaveApp(wxPyArtProvider::GetIcon);
265 MustHaveApp(wxPyArtProvider::GetBundle);
267 %rename(ArtProvider) wxPyArtProvider;
268 class wxPyArtProvider /*: public wxObject*/
272 %pythonAppend wxPyArtProvider setCallbackInfo(ArtProvider);
276 void _setCallbackInfo(PyObject* self, PyObject* _class);
278 %disownarg( wxPyArtProvider *provider );
281 static void , Push(wxPyArtProvider *provider),
282 "Add new provider to the top of providers stack.", "");
283 %pythoncode { PushProvider = Push }
286 static void , Insert(wxPyArtProvider *provider),
287 "Add new provider to the bottom of providers stack.", "");
288 %pythoncode { InsertProvider = Insert }
290 %cleardisown( wxPyArtProvider *provider );
295 "Remove latest added provider and delete it.", "");
296 %pythoncode { PopProvider = Pop }
298 %pythonAppend Delete "args[1].thisown = 1";
300 static bool , Delete(wxPyArtProvider *provider),
301 "Remove provider. The provider must have been added previously! The
302 provider is _not_ deleted.", "");
303 %pythoncode { RemoveProvider = Delete }
307 static wxBitmap , GetBitmap(const wxString& id,
308 const wxString& client = wxPyART_OTHER,
309 const wxSize& size = wxDefaultSize),
310 "Query the providers for bitmap with given ID and return it. Return
311 wx.NullBitmap if no provider provides it.", "");
315 static wxIcon , GetIcon(const wxString& id,
316 const wxString& client = wxPyART_OTHER,
317 const wxSize& size = wxDefaultSize),
318 "Query the providers for icon with given ID and return it. Return
319 wx.NullIcon if no provider provides it.", "");
322 static wxIconBundle , GetIconBundle(const wxArtID& id,
323 const wxArtClient& client = wxART_OTHER),
324 "Query the providers for iconbundle with given ID and return it. Return
325 wx.NullIconBundle if no provider provides it.", "");
329 static wxSize , GetSizeHint(const wxString& client, bool platform_dependent = false),
330 "Get the size hint of an icon from a specific Art Client, queries the
331 topmost provider if platform_dependent = false", "");
335 %pythonPrepend Destroy "args[0].this.own(False)"
336 %extend { void Destroy() { delete self; }}
341 //---------------------------------------------------------------------------
343 wxPyPtrTypeMap_Add("wxArtProvider", "wxPyArtProvider");
345 //---------------------------------------------------------------------------