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