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_FILE_SAVE);
52 MAKE_CONST_WXSTRING(ART_FILE_SAVE_AS);
53 MAKE_CONST_WXSTRING(ART_PRINT);
54 MAKE_CONST_WXSTRING(ART_HELP);
55 MAKE_CONST_WXSTRING(ART_TIP);
56 MAKE_CONST_WXSTRING(ART_REPORT_VIEW);
57 MAKE_CONST_WXSTRING(ART_LIST_VIEW);
58 MAKE_CONST_WXSTRING(ART_NEW_DIR);
59 MAKE_CONST_WXSTRING(ART_HARDDISK);
60 MAKE_CONST_WXSTRING(ART_FLOPPY);
61 MAKE_CONST_WXSTRING(ART_CDROM);
62 MAKE_CONST_WXSTRING(ART_REMOVABLE);
63 MAKE_CONST_WXSTRING(ART_FOLDER);
64 MAKE_CONST_WXSTRING(ART_FOLDER_OPEN);
65 MAKE_CONST_WXSTRING(ART_GO_DIR_UP);
66 MAKE_CONST_WXSTRING(ART_EXECUTABLE_FILE);
67 MAKE_CONST_WXSTRING(ART_NORMAL_FILE);
68 MAKE_CONST_WXSTRING(ART_TICK_MARK);
69 MAKE_CONST_WXSTRING(ART_CROSS_MARK);
70 MAKE_CONST_WXSTRING(ART_ERROR);
71 MAKE_CONST_WXSTRING(ART_QUESTION);
72 MAKE_CONST_WXSTRING(ART_WARNING);
73 MAKE_CONST_WXSTRING(ART_INFORMATION);
74 MAKE_CONST_WXSTRING(ART_MISSING_IMAGE);
75 MAKE_CONST_WXSTRING(ART_COPY);
76 MAKE_CONST_WXSTRING(ART_CUT);
77 MAKE_CONST_WXSTRING(ART_PASTE);
78 MAKE_CONST_WXSTRING(ART_DELETE);
79 MAKE_CONST_WXSTRING(ART_UNDO);
80 MAKE_CONST_WXSTRING(ART_REDO);
81 MAKE_CONST_WXSTRING(ART_QUIT);
82 MAKE_CONST_WXSTRING(ART_FIND);
83 MAKE_CONST_WXSTRING(ART_FIND_AND_REPLACE);
85 //---------------------------------------------------------------------------
87 %{ // Python aware wxArtProvider
88 class wxPyArtProvider : public wxArtProvider {
91 virtual wxBitmap CreateBitmap(const wxArtID& id,
92 const wxArtClient& client,
94 wxBitmap rval = wxNullBitmap;
95 bool blocked = wxPyBeginBlockThreads();
96 if ((wxPyCBH_findCallback(m_myInst, "CreateBitmap"))) {
97 PyObject* so = wxPyConstructObject((void*)&size, wxT("wxSize"), 0);
101 s1 = wx2PyString(id);
102 s2 = wx2PyString(client);
103 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OOO)", s1, s2, so));
108 if (wxPyConvertSwigPtr(ro, (void**)&ptr, wxT("wxBitmap")))
113 wxPyEndBlockThreads(blocked);
121 // The one for SWIG to see
125 DocStr(wxPyArtProvider,
126 "The wx.ArtProvider class is used to customize the look of wxWidgets
127 application. When wxWidgets needs to display an icon or a bitmap (e.g.
128 in the standard file dialog), it does not use hard-coded resource but
129 asks wx.ArtProvider for it instead. This way the users can plug in
130 their own wx.ArtProvider class and easily replace standard art with
131 his/her own version. It is easy thing to do: all that is needed is
132 to derive a class from wx.ArtProvider, override it's CreateBitmap
133 method and register the provider with wx.ArtProvider.PushProvider::
135 class MyArtProvider(wx.ArtProvider):
137 wx.ArtProvider.__init__(self)
139 def CreateBitmap(self, artid, client, size):
144 Identifying art resources
145 -------------------------
147 Every bitmap is known to wx.ArtProvider under an unique ID that is
148 used when requesting a resource from it. The IDs can have one of the
149 following predefined values. Additionally, any string recognized by
150 custom art providers registered using `PushProvider` may be used.
155 When running under GTK+ 2, GTK+ stock item IDs (e.g. 'gtk-cdrom') may be used
156 as well. Additionally, if wxGTK was compiled against GTK+ >= 2.4, then it is
157 also possible to load icons from current icon theme by specifying their name
158 without the extension and directory components. Icon themes recognized by GTK+
159 follow the freedesktop.org Icon Themes specification. Note that themes are
160 not guaranteed to contain all icons, so wx.ArtProvider may return wx.NullBitmap
161 or wx.NullIcon. The default theme is typically installed in /usr/share/icons/hicolor.
164 * wx.ART_ADD_BOOKMARK
165 * wx.ART_DEL_BOOKMARK
166 * wx.ART_HELP_SIDE_PANEL
167 * wx.ART_HELP_SETTINGS
175 * wx.ART_GO_TO_PARENT
186 * wx.ART_EXECUTABLE_FILE
194 * wx.ART_MISSING_IMAGE
200 The Client is the entity that calls wx.ArtProvider's `GetBitmap` or
201 `GetIcon` function. Client IDs serve as a hint to wx.ArtProvider
202 that is supposed to help it to choose the best looking bitmap. For
203 example it is often desirable to use slightly different icons in menus
204 and toolbars even though they represent the same action (e.g.
205 wx.ART_FILE_OPEN). Remember that this is really only a hint for
206 wx.ArtProvider -- it is common that `wx.ArtProvider.GetBitmap` returns
207 identical bitmap for different client values!
213 * wx.ART_HELP_BROWSER
216 * wx.ART_OTHER (used for all requests that don't fit into any
217 of the categories above)
220 MustHaveApp(wxPyArtProvider);
221 MustHaveApp(wxPyArtProvider::GetBitmap);
222 MustHaveApp(wxPyArtProvider::GetIcon);
224 %rename(ArtProvider) wxPyArtProvider;
225 class wxPyArtProvider /*: public wxObject*/
229 %pythonAppend wxPyArtProvider "self._setCallbackInfo(self, ArtProvider)"
232 void _setCallbackInfo(PyObject* self, PyObject* _class);
235 static void , PushProvider(wxPyArtProvider *provider),
236 "Add new provider to the top of providers stack.", "");
240 static bool , PopProvider(),
241 "Remove latest added provider and delete it.", "");
245 static bool , RemoveProvider(wxPyArtProvider *provider),
246 "Remove provider. The provider must have been added previously! The
247 provider is _not_ deleted.", "");
251 static wxBitmap , GetBitmap(const wxString& id,
252 const wxString& client = wxPyART_OTHER,
253 const wxSize& size = wxDefaultSize),
254 "Query the providers for bitmap with given ID and return it. Return
255 wx.NullBitmap if no provider provides it.", "");
259 static wxIcon , GetIcon(const wxString& id,
260 const wxString& client = wxPyART_OTHER,
261 const wxSize& size = wxDefaultSize),
262 "Query the providers for icon with given ID and return it. Return
263 wx.NullIcon if no provider provides it.", "");
266 %extend { void Destroy() { delete self; }}
271 //---------------------------------------------------------------------------
273 wxPyPtrTypeMap_Add("wxArtProvider", "wxPyArtProvider");
275 //---------------------------------------------------------------------------