]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_artprov.i
Add support for launching APPL bundles with wxExecute
[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);
79MAKE_CONST_WXSTRING(ART_UNDO);
80MAKE_CONST_WXSTRING(ART_REDO);
81MAKE_CONST_WXSTRING(ART_QUIT);
82MAKE_CONST_WXSTRING(ART_FIND);
83MAKE_CONST_WXSTRING(ART_FIND_AND_REPLACE);
d14a1e28
RD
84
85//---------------------------------------------------------------------------
86
87%{ // Python aware wxArtProvider
88class wxPyArtProvider : public wxArtProvider {
89public:
90
91 virtual wxBitmap CreateBitmap(const wxArtID& id,
92 const wxArtClient& client,
93 const wxSize& size) {
94 wxBitmap rval = wxNullBitmap;
6e6b3557 95 wxPyBlock_t blocked = wxPyBeginBlockThreads();
d14a1e28
RD
96 if ((wxPyCBH_findCallback(m_myInst, "CreateBitmap"))) {
97 PyObject* so = wxPyConstructObject((void*)&size, wxT("wxSize"), 0);
98 PyObject* ro;
99 wxBitmap* ptr;
100 PyObject* s1, *s2;
101 s1 = wx2PyString(id);
102 s2 = wx2PyString(client);
103 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OOO)", s1, s2, so));
104 Py_DECREF(so);
105 Py_DECREF(s1);
106 Py_DECREF(s2);
107 if (ro) {
108 if (wxPyConvertSwigPtr(ro, (void**)&ptr, wxT("wxBitmap")))
109 rval = *ptr;
110 Py_DECREF(ro);
111 }
112 }
da32eb53 113 wxPyEndBlockThreads(blocked);
d14a1e28
RD
114 return rval;
115 }
116
117 PYPRIVATE;
118};
119%}
120
121// The one for SWIG to see
dce2bd22
RD
122
123
124
125DocStr(wxPyArtProvider,
126"The wx.ArtProvider class is used to customize the look of wxWidgets
127application. When wxWidgets needs to display an icon or a bitmap (e.g.
128in the standard file dialog), it does not use hard-coded resource but
129asks wx.ArtProvider for it instead. This way the users can plug in
130their own wx.ArtProvider class and easily replace standard art with
131his/her own version. It is easy thing to do: all that is needed is
132to derive a class from wx.ArtProvider, override it's CreateBitmap
133method and register the provider with wx.ArtProvider.PushProvider::
134
135 class MyArtProvider(wx.ArtProvider):
136 def __init__(self):
137 wx.ArtProvider.__init__(self)
138
139 def CreateBitmap(self, artid, client, size):
140 ...
141 return bmp
d07d2bc9 142", "
dce2bd22
RD
143
144Identifying art resources
145-------------------------
146
147Every bitmap is known to wx.ArtProvider under an unique ID that is
ed2de217
RD
148used when requesting a resource from it. The IDs can have one of the
149following predefined values. Additionally, any string recognized by
07faea28
RD
150custom art providers registered using `PushProvider` may be used.
151
152GTK+ Note
153---------
154
155When running under GTK+ 2, GTK+ stock item IDs (e.g. 'gtk-cdrom') may be used
156as well. Additionally, if wxGTK was compiled against GTK+ >= 2.4, then it is
157also possible to load icons from current icon theme by specifying their name
158without the extension and directory components. Icon themes recognized by GTK+
159follow the freedesktop.org Icon Themes specification. Note that themes are
160not guaranteed to contain all icons, so wx.ArtProvider may return wx.NullBitmap
161or wx.NullIcon. The default theme is typically installed in /usr/share/icons/hicolor.
ed2de217 162
dce2bd22
RD
163
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
178 * wx.ART_PRINT
179 * wx.ART_HELP
180 * wx.ART_TIP
181 * wx.ART_REPORT_VIEW
182 * wx.ART_LIST_VIEW
183 * wx.ART_NEW_DIR
184 * wx.ART_FOLDER
185 * wx.ART_GO_DIR_UP
186 * wx.ART_EXECUTABLE_FILE
187 * wx.ART_NORMAL_FILE
188 * wx.ART_TICK_MARK
189 * wx.ART_CROSS_MARK
190 * wx.ART_ERROR
191 * wx.ART_QUESTION
192 * wx.ART_WARNING
193 * wx.ART_INFORMATION
194 * wx.ART_MISSING_IMAGE
195
196
197Clients
198-------
199
200The Client is the entity that calls wx.ArtProvider's `GetBitmap` or
ed2de217 201`GetIcon` function. Client IDs serve as a hint to wx.ArtProvider
dce2bd22
RD
202that is supposed to help it to choose the best looking bitmap. For
203example it is often desirable to use slightly different icons in menus
204and toolbars even though they represent the same action (e.g.
205wx.ART_FILE_OPEN). Remember that this is really only a hint for
206wx.ArtProvider -- it is common that `wx.ArtProvider.GetBitmap` returns
207identical bitmap for different client values!
208
209 * wx.ART_TOOLBAR
210 * wx.ART_MENU
211 * wx.ART_FRAME_ICON
212 * wx.ART_CMN_DIALOG
213 * wx.ART_HELP_BROWSER
214 * wx.ART_MESSAGE_BOX
ed2de217 215 * wx.ART_BUTTON
dce2bd22
RD
216 * wx.ART_OTHER (used for all requests that don't fit into any
217 of the categories above)
218");
219
ab1f7d2a
RD
220MustHaveApp(wxPyArtProvider);
221MustHaveApp(wxPyArtProvider::GetBitmap);
222MustHaveApp(wxPyArtProvider::GetIcon);
223
1b8c7ba6
RD
224%rename(ArtProvider) wxPyArtProvider;
225class wxPyArtProvider /*: public wxObject*/
d14a1e28
RD
226{
227public:
228
2b9048c5 229 %pythonAppend wxPyArtProvider "self._setCallbackInfo(self, ArtProvider)"
d14a1e28 230 wxPyArtProvider();
d14a1e28
RD
231
232 void _setCallbackInfo(PyObject* self, PyObject* _class);
233
dce2bd22
RD
234 DocDeclStr(
235 static void , PushProvider(wxPyArtProvider *provider),
d07d2bc9 236 "Add new provider to the top of providers stack.", "");
dce2bd22 237
d14a1e28 238
dce2bd22
RD
239 DocDeclStr(
240 static bool , PopProvider(),
d07d2bc9 241 "Remove latest added provider and delete it.", "");
dce2bd22 242
d14a1e28 243
dce2bd22
RD
244 DocDeclStr(
245 static bool , RemoveProvider(wxPyArtProvider *provider),
246 "Remove provider. The provider must have been added previously! The
d07d2bc9 247provider is _not_ deleted.", "");
dce2bd22 248
d14a1e28 249
dce2bd22
RD
250 DocDeclStr(
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
d07d2bc9 255wx.NullBitmap if no provider provides it.", "");
dce2bd22 256
d14a1e28 257
dce2bd22
RD
258 DocDeclStr(
259 static wxIcon , GetIcon(const wxString& id,
d14a1e28 260 const wxString& client = wxPyART_OTHER,
dce2bd22
RD
261 const wxSize& size = wxDefaultSize),
262 "Query the providers for icon with given ID and return it. Return
d07d2bc9 263wx.NullIcon if no provider provides it.", "");
dc236076
RD
264
265 DocDeclStr(
76144efe 266 static wxSize , GetSizeHint(const wxString& client, bool platform_dependent = false),
8e7da44f 267 "Get the size hint of an icon from a specific Art Client, queries the
dc236076
RD
268topmost provider if platform_dependent = false", "");
269
dce2bd22 270
d14a1e28 271
1e0c8722 272 %extend { void Destroy() { delete self; }}
d14a1e28
RD
273};
274
275
276
277//---------------------------------------------------------------------------
278%init %{
279 wxPyPtrTypeMap_Add("wxArtProvider", "wxPyArtProvider");
280%}
281//---------------------------------------------------------------------------