]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_artprov.i
Updating with Vadim's API changes.
[wxWidgets.git] / wxPython / src / _artprov.i
CommitLineData
d14a1e28
RD
1/////////////////////////////////////////////////////////////////////////////
2// Name: _artprov.i
3// Purpose: SWIG interface stuff for wxArtProvider
4//
5// Author: Robin Dunn
6//
7// Created: 18-June-1999
8// RCS-ID: $Id$
9// Copyright: (c) 2003 by Total Control Software
10// Licence: wxWindows license
11/////////////////////////////////////////////////////////////////////////////
12
13// Not a %module
14
15
16//---------------------------------------------------------------------------
17%newgroup
18
19%{
20#include <wx/artprov.h>
21%}
22
23//---------------------------------------------------------------------------
24
25
26// Art clients
27MAKE_CONST_WXSTRING(ART_TOOLBAR);
28MAKE_CONST_WXSTRING(ART_MENU);
29MAKE_CONST_WXSTRING(ART_FRAME_ICON);
30MAKE_CONST_WXSTRING(ART_CMN_DIALOG);
31MAKE_CONST_WXSTRING(ART_HELP_BROWSER);
32MAKE_CONST_WXSTRING(ART_MESSAGE_BOX);
ed2de217 33MAKE_CONST_WXSTRING(ART_BUTTON);
d14a1e28
RD
34MAKE_CONST_WXSTRING(ART_OTHER);
35
36// Art IDs
37MAKE_CONST_WXSTRING(ART_ADD_BOOKMARK);
38MAKE_CONST_WXSTRING(ART_DEL_BOOKMARK);
39MAKE_CONST_WXSTRING(ART_HELP_SIDE_PANEL);
40MAKE_CONST_WXSTRING(ART_HELP_SETTINGS);
41MAKE_CONST_WXSTRING(ART_HELP_BOOK);
42MAKE_CONST_WXSTRING(ART_HELP_FOLDER);
43MAKE_CONST_WXSTRING(ART_HELP_PAGE);
44MAKE_CONST_WXSTRING(ART_GO_BACK);
45MAKE_CONST_WXSTRING(ART_GO_FORWARD);
46MAKE_CONST_WXSTRING(ART_GO_UP);
47MAKE_CONST_WXSTRING(ART_GO_DOWN);
48MAKE_CONST_WXSTRING(ART_GO_TO_PARENT);
49MAKE_CONST_WXSTRING(ART_GO_HOME);
50MAKE_CONST_WXSTRING(ART_FILE_OPEN);
6e1eab53
RD
51MAKE_CONST_WXSTRING(ART_FILE_SAVE);
52MAKE_CONST_WXSTRING(ART_FILE_SAVE_AS);
d14a1e28
RD
53MAKE_CONST_WXSTRING(ART_PRINT);
54MAKE_CONST_WXSTRING(ART_HELP);
55MAKE_CONST_WXSTRING(ART_TIP);
56MAKE_CONST_WXSTRING(ART_REPORT_VIEW);
57MAKE_CONST_WXSTRING(ART_LIST_VIEW);
58MAKE_CONST_WXSTRING(ART_NEW_DIR);
020303e6
RD
59MAKE_CONST_WXSTRING(ART_HARDDISK);
60MAKE_CONST_WXSTRING(ART_FLOPPY);
61MAKE_CONST_WXSTRING(ART_CDROM);
62MAKE_CONST_WXSTRING(ART_REMOVABLE);
d14a1e28 63MAKE_CONST_WXSTRING(ART_FOLDER);
020303e6 64MAKE_CONST_WXSTRING(ART_FOLDER_OPEN);
d14a1e28
RD
65MAKE_CONST_WXSTRING(ART_GO_DIR_UP);
66MAKE_CONST_WXSTRING(ART_EXECUTABLE_FILE);
67MAKE_CONST_WXSTRING(ART_NORMAL_FILE);
68MAKE_CONST_WXSTRING(ART_TICK_MARK);
69MAKE_CONST_WXSTRING(ART_CROSS_MARK);
70MAKE_CONST_WXSTRING(ART_ERROR);
71MAKE_CONST_WXSTRING(ART_QUESTION);
72MAKE_CONST_WXSTRING(ART_WARNING);
73MAKE_CONST_WXSTRING(ART_INFORMATION);
74MAKE_CONST_WXSTRING(ART_MISSING_IMAGE);
6e1eab53
RD
75MAKE_CONST_WXSTRING(ART_COPY);
76MAKE_CONST_WXSTRING(ART_CUT);
77MAKE_CONST_WXSTRING(ART_PASTE);
78MAKE_CONST_WXSTRING(ART_DELETE);
406011a8 79MAKE_CONST_WXSTRING(ART_NEW);
6e1eab53
RD
80MAKE_CONST_WXSTRING(ART_UNDO);
81MAKE_CONST_WXSTRING(ART_REDO);
82MAKE_CONST_WXSTRING(ART_QUIT);
83MAKE_CONST_WXSTRING(ART_FIND);
84MAKE_CONST_WXSTRING(ART_FIND_AND_REPLACE);
d14a1e28
RD
85
86//---------------------------------------------------------------------------
87
88%{ // Python aware wxArtProvider
89class wxPyArtProvider : public wxArtProvider {
90public:
91
92 virtual wxBitmap CreateBitmap(const wxArtID& id,
93 const wxArtClient& client,
94 const wxSize& size) {
95 wxBitmap rval = wxNullBitmap;
6e6b3557 96 wxPyBlock_t blocked = wxPyBeginBlockThreads();
d14a1e28
RD
97 if ((wxPyCBH_findCallback(m_myInst, "CreateBitmap"))) {
98 PyObject* so = wxPyConstructObject((void*)&size, wxT("wxSize"), 0);
99 PyObject* ro;
100 wxBitmap* ptr;
101 PyObject* s1, *s2;
102 s1 = wx2PyString(id);
103 s2 = wx2PyString(client);
104 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OOO)", s1, s2, so));
105 Py_DECREF(so);
106 Py_DECREF(s1);
107 Py_DECREF(s2);
108 if (ro) {
109 if (wxPyConvertSwigPtr(ro, (void**)&ptr, wxT("wxBitmap")))
110 rval = *ptr;
111 Py_DECREF(ro);
112 }
113 }
da32eb53 114 wxPyEndBlockThreads(blocked);
d14a1e28
RD
115 return rval;
116 }
117
118 PYPRIVATE;
119};
120%}
121
122// The one for SWIG to see
dce2bd22
RD
123
124
125
126DocStr(wxPyArtProvider,
127"The wx.ArtProvider class is used to customize the look of wxWidgets
128application. When wxWidgets needs to display an icon or a bitmap (e.g.
129in the standard file dialog), it does not use hard-coded resource but
130asks wx.ArtProvider for it instead. This way the users can plug in
131their own wx.ArtProvider class and easily replace standard art with
132his/her own version. It is easy thing to do: all that is needed is
133to derive a class from wx.ArtProvider, override it's CreateBitmap
4391d97b 134method and register the provider with `wx.ArtProvider.Push`::
dce2bd22
RD
135
136 class MyArtProvider(wx.ArtProvider):
137 def __init__(self):
138 wx.ArtProvider.__init__(self)
139
140 def CreateBitmap(self, artid, client, size):
141 ...
142 return bmp
d07d2bc9 143", "
dce2bd22
RD
144
145Identifying art resources
146-------------------------
147
148Every bitmap is known to wx.ArtProvider under an unique ID that is
ed2de217
RD
149used when requesting a resource from it. The IDs can have one of the
150following predefined values. Additionally, any string recognized by
4391d97b 151custom art providers registered using `Push` may be used.
07faea28
RD
152
153GTK+ Note
154---------
155
156When running under GTK+ 2, GTK+ stock item IDs (e.g. 'gtk-cdrom') may be used
157as well. Additionally, if wxGTK was compiled against GTK+ >= 2.4, then it is
158also possible to load icons from current icon theme by specifying their name
159without the extension and directory components. Icon themes recognized by GTK+
160follow the freedesktop.org Icon Themes specification. Note that themes are
161not guaranteed to contain all icons, so wx.ArtProvider may return wx.NullBitmap
162or wx.NullIcon. The default theme is typically installed in /usr/share/icons/hicolor.
ed2de217 163
dce2bd22
RD
164 * wx.ART_ADD_BOOKMARK
165 * wx.ART_DEL_BOOKMARK
166 * wx.ART_HELP_SIDE_PANEL
167 * wx.ART_HELP_SETTINGS
168 * wx.ART_HELP_BOOK
169 * wx.ART_HELP_FOLDER
170 * wx.ART_HELP_PAGE
171 * wx.ART_GO_BACK
172 * wx.ART_GO_FORWARD
173 * wx.ART_GO_UP
174 * wx.ART_GO_DOWN
175 * wx.ART_GO_TO_PARENT
176 * wx.ART_GO_HOME
177 * wx.ART_FILE_OPEN
406011a8
RD
178 * wx.ART_FILE_SAVE
179 * wx.ART_FILE_SAVE_AS
dce2bd22
RD
180 * wx.ART_PRINT
181 * wx.ART_HELP
182 * wx.ART_TIP
183 * wx.ART_REPORT_VIEW
184 * wx.ART_LIST_VIEW
185 * wx.ART_NEW_DIR
406011a8
RD
186 * wx.ART_HARDDISK
187 * wx.ART_FLOPPY
188 * wx.ART_CDROM
189 * wx.ART_REMOVABLE
dce2bd22 190 * wx.ART_FOLDER
406011a8 191 * wx.ART_FOLDER_OPEN
dce2bd22
RD
192 * wx.ART_GO_DIR_UP
193 * wx.ART_EXECUTABLE_FILE
194 * wx.ART_NORMAL_FILE
195 * wx.ART_TICK_MARK
196 * wx.ART_CROSS_MARK
197 * wx.ART_ERROR
198 * wx.ART_QUESTION
199 * wx.ART_WARNING
200 * wx.ART_INFORMATION
406011a8
RD
201 * wx.ART_MISSING_IMAGE
202 * wx.ART_COPY
203 * wx.ART_CUT
204 * wx.ART_PASTE
205 * wx.ART_DELETE
206 * wx.ART_NEW
207 * wx.ART_UNDO
208 * wx.ART_REDO
209 * wx.ART_QUIT
210 * wx.ART_FIND
211 * wx.ART_FIND_AND_REPLACE
dce2bd22
RD
212
213
214Clients
215-------
216
217The Client is the entity that calls wx.ArtProvider's `GetBitmap` or
ed2de217 218`GetIcon` function. Client IDs serve as a hint to wx.ArtProvider
dce2bd22
RD
219that is supposed to help it to choose the best looking bitmap. For
220example it is often desirable to use slightly different icons in menus
221and toolbars even though they represent the same action (e.g.
222wx.ART_FILE_OPEN). Remember that this is really only a hint for
223wx.ArtProvider -- it is common that `wx.ArtProvider.GetBitmap` returns
224identical bitmap for different client values!
225
226 * wx.ART_TOOLBAR
227 * wx.ART_MENU
228 * wx.ART_FRAME_ICON
229 * wx.ART_CMN_DIALOG
230 * wx.ART_HELP_BROWSER
231 * wx.ART_MESSAGE_BOX
ed2de217 232 * wx.ART_BUTTON
dce2bd22
RD
233 * wx.ART_OTHER (used for all requests that don't fit into any
234 of the categories above)
235");
236
ab1f7d2a
RD
237MustHaveApp(wxPyArtProvider);
238MustHaveApp(wxPyArtProvider::GetBitmap);
239MustHaveApp(wxPyArtProvider::GetIcon);
240
1b8c7ba6
RD
241%rename(ArtProvider) wxPyArtProvider;
242class wxPyArtProvider /*: public wxObject*/
d14a1e28
RD
243{
244public:
245
c25f90f6 246 %pythonAppend wxPyArtProvider setCallbackInfo(ArtProvider);
d14a1e28 247 wxPyArtProvider();
214c4fbe 248 ~wxPyArtProvider();
d14a1e28
RD
249
250 void _setCallbackInfo(PyObject* self, PyObject* _class);
251
214c4fbe 252 %disownarg( wxPyArtProvider *provider );
4391d97b 253
dce2bd22 254 DocDeclStr(
4391d97b 255 static void , Push(wxPyArtProvider *provider),
d07d2bc9 256 "Add new provider to the top of providers stack.", "");
584d6f48 257 %pythoncode { PushProvider = Push }
4391d97b 258
e0bfbd2c 259 DocDeclStr(
4391d97b 260 static void , Insert(wxPyArtProvider *provider),
e0bfbd2c 261 "Add new provider to the bottom of providers stack.", "");
584d6f48 262 %pythoncode { InsertProvider = Insert }
4391d97b 263
214c4fbe 264 %cleardisown( wxPyArtProvider *provider );
dce2bd22 265
d14a1e28 266
dce2bd22 267 DocDeclStr(
4391d97b 268 static bool , Pop(),
d07d2bc9 269 "Remove latest added provider and delete it.", "");
584d6f48 270 %pythoncode { PopProvider = Pop }
dce2bd22 271
4391d97b 272 %pythonAppend Delete "args[1].thisown = 1";
dce2bd22 273 DocDeclStr(
4391d97b 274 static bool , Delete(wxPyArtProvider *provider),
dce2bd22 275 "Remove provider. The provider must have been added previously! The
d07d2bc9 276provider is _not_ deleted.", "");
584d6f48 277 %pythoncode { RemoveProvider = Delete }
4391d97b 278
d14a1e28 279
dce2bd22
RD
280 DocDeclStr(
281 static wxBitmap , GetBitmap(const wxString& id,
282 const wxString& client = wxPyART_OTHER,
283 const wxSize& size = wxDefaultSize),
284 "Query the providers for bitmap with given ID and return it. Return
d07d2bc9 285wx.NullBitmap if no provider provides it.", "");
dce2bd22 286
d14a1e28 287
dce2bd22
RD
288 DocDeclStr(
289 static wxIcon , GetIcon(const wxString& id,
d14a1e28 290 const wxString& client = wxPyART_OTHER,
dce2bd22
RD
291 const wxSize& size = wxDefaultSize),
292 "Query the providers for icon with given ID and return it. Return
d07d2bc9 293wx.NullIcon if no provider provides it.", "");
dc236076
RD
294
295 DocDeclStr(
76144efe 296 static wxSize , GetSizeHint(const wxString& client, bool platform_dependent = false),
8e7da44f 297 "Get the size hint of an icon from a specific Art Client, queries the
dc236076
RD
298topmost provider if platform_dependent = false", "");
299
dce2bd22 300
d14a1e28 301
4b5a79cf 302 %pythonPrepend Destroy "args[0].this.own(False)"
1e0c8722 303 %extend { void Destroy() { delete self; }}
d14a1e28
RD
304};
305
306
307
308//---------------------------------------------------------------------------
309%init %{
310 wxPyPtrTypeMap_Add("wxArtProvider", "wxPyArtProvider");
311%}
312//---------------------------------------------------------------------------