]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/src/_artprov.i
Add a column for GetUnicodeKey
[wxWidgets.git] / wxPython / src / _artprov.i
... / ...
CommitLineData
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);
33MAKE_CONST_WXSTRING(ART_BUTTON);
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);
51MAKE_CONST_WXSTRING(ART_PRINT);
52MAKE_CONST_WXSTRING(ART_HELP);
53MAKE_CONST_WXSTRING(ART_TIP);
54MAKE_CONST_WXSTRING(ART_REPORT_VIEW);
55MAKE_CONST_WXSTRING(ART_LIST_VIEW);
56MAKE_CONST_WXSTRING(ART_NEW_DIR);
57MAKE_CONST_WXSTRING(ART_FOLDER);
58MAKE_CONST_WXSTRING(ART_GO_DIR_UP);
59MAKE_CONST_WXSTRING(ART_EXECUTABLE_FILE);
60MAKE_CONST_WXSTRING(ART_NORMAL_FILE);
61MAKE_CONST_WXSTRING(ART_TICK_MARK);
62MAKE_CONST_WXSTRING(ART_CROSS_MARK);
63MAKE_CONST_WXSTRING(ART_ERROR);
64MAKE_CONST_WXSTRING(ART_QUESTION);
65MAKE_CONST_WXSTRING(ART_WARNING);
66MAKE_CONST_WXSTRING(ART_INFORMATION);
67MAKE_CONST_WXSTRING(ART_MISSING_IMAGE);
68
69//---------------------------------------------------------------------------
70
71%{ // Python aware wxArtProvider
72class wxPyArtProvider : public wxArtProvider {
73public:
74
75 virtual wxBitmap CreateBitmap(const wxArtID& id,
76 const wxArtClient& client,
77 const wxSize& size) {
78 wxBitmap rval = wxNullBitmap;
79 bool blocked = wxPyBeginBlockThreads();
80 if ((wxPyCBH_findCallback(m_myInst, "CreateBitmap"))) {
81 PyObject* so = wxPyConstructObject((void*)&size, wxT("wxSize"), 0);
82 PyObject* ro;
83 wxBitmap* ptr;
84 PyObject* s1, *s2;
85 s1 = wx2PyString(id);
86 s2 = wx2PyString(client);
87 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OOO)", s1, s2, so));
88 Py_DECREF(so);
89 Py_DECREF(s1);
90 Py_DECREF(s2);
91 if (ro) {
92 if (wxPyConvertSwigPtr(ro, (void**)&ptr, wxT("wxBitmap")))
93 rval = *ptr;
94 Py_DECREF(ro);
95 }
96 }
97 wxPyEndBlockThreads(blocked);
98 return rval;
99 }
100
101 PYPRIVATE;
102};
103%}
104
105// The one for SWIG to see
106
107
108
109DocStr(wxPyArtProvider,
110"The wx.ArtProvider class is used to customize the look of wxWidgets
111application. When wxWidgets needs to display an icon or a bitmap (e.g.
112in the standard file dialog), it does not use hard-coded resource but
113asks wx.ArtProvider for it instead. This way the users can plug in
114their own wx.ArtProvider class and easily replace standard art with
115his/her own version. It is easy thing to do: all that is needed is
116to derive a class from wx.ArtProvider, override it's CreateBitmap
117method and register the provider with wx.ArtProvider.PushProvider::
118
119 class MyArtProvider(wx.ArtProvider):
120 def __init__(self):
121 wx.ArtProvider.__init__(self)
122
123 def CreateBitmap(self, artid, client, size):
124 ...
125 return bmp
126", "
127
128Identifying art resources
129-------------------------
130
131Every bitmap is known to wx.ArtProvider under an unique ID that is
132used when requesting a resource from it. The IDs can have one of the
133following predefined values. Additionally, any string recognized by
134custom art providers registered using `PushProvider` may be used. When
135running under GTK+ 2, GTK+ stock item IDs (e.g. 'gtk-cdrom') may be
136used as well.
137
138
139 * wx.ART_ADD_BOOKMARK
140 * wx.ART_DEL_BOOKMARK
141 * wx.ART_HELP_SIDE_PANEL
142 * wx.ART_HELP_SETTINGS
143 * wx.ART_HELP_BOOK
144 * wx.ART_HELP_FOLDER
145 * wx.ART_HELP_PAGE
146 * wx.ART_GO_BACK
147 * wx.ART_GO_FORWARD
148 * wx.ART_GO_UP
149 * wx.ART_GO_DOWN
150 * wx.ART_GO_TO_PARENT
151 * wx.ART_GO_HOME
152 * wx.ART_FILE_OPEN
153 * wx.ART_PRINT
154 * wx.ART_HELP
155 * wx.ART_TIP
156 * wx.ART_REPORT_VIEW
157 * wx.ART_LIST_VIEW
158 * wx.ART_NEW_DIR
159 * wx.ART_FOLDER
160 * wx.ART_GO_DIR_UP
161 * wx.ART_EXECUTABLE_FILE
162 * wx.ART_NORMAL_FILE
163 * wx.ART_TICK_MARK
164 * wx.ART_CROSS_MARK
165 * wx.ART_ERROR
166 * wx.ART_QUESTION
167 * wx.ART_WARNING
168 * wx.ART_INFORMATION
169 * wx.ART_MISSING_IMAGE
170
171
172Clients
173-------
174
175The Client is the entity that calls wx.ArtProvider's `GetBitmap` or
176`GetIcon` function. Client IDs serve as a hint to wx.ArtProvider
177that is supposed to help it to choose the best looking bitmap. For
178example it is often desirable to use slightly different icons in menus
179and toolbars even though they represent the same action (e.g.
180wx.ART_FILE_OPEN). Remember that this is really only a hint for
181wx.ArtProvider -- it is common that `wx.ArtProvider.GetBitmap` returns
182identical bitmap for different client values!
183
184 * wx.ART_TOOLBAR
185 * wx.ART_MENU
186 * wx.ART_FRAME_ICON
187 * wx.ART_CMN_DIALOG
188 * wx.ART_HELP_BROWSER
189 * wx.ART_MESSAGE_BOX
190 * wx.ART_BUTTON
191 * wx.ART_OTHER (used for all requests that don't fit into any
192 of the categories above)
193");
194
195MustHaveApp(wxPyArtProvider);
196MustHaveApp(wxPyArtProvider::GetBitmap);
197MustHaveApp(wxPyArtProvider::GetIcon);
198
199%name(ArtProvider) class wxPyArtProvider /*: public wxObject*/
200{
201public:
202
203 %pythonAppend wxPyArtProvider "self._setCallbackInfo(self, ArtProvider)"
204 wxPyArtProvider();
205
206 void _setCallbackInfo(PyObject* self, PyObject* _class);
207
208 DocDeclStr(
209 static void , PushProvider(wxPyArtProvider *provider),
210 "Add new provider to the top of providers stack.", "");
211
212
213 DocDeclStr(
214 static bool , PopProvider(),
215 "Remove latest added provider and delete it.", "");
216
217
218 DocDeclStr(
219 static bool , RemoveProvider(wxPyArtProvider *provider),
220 "Remove provider. The provider must have been added previously! The
221provider is _not_ deleted.", "");
222
223
224 DocDeclStr(
225 static wxBitmap , GetBitmap(const wxString& id,
226 const wxString& client = wxPyART_OTHER,
227 const wxSize& size = wxDefaultSize),
228 "Query the providers for bitmap with given ID and return it. Return
229wx.NullBitmap if no provider provides it.", "");
230
231
232 DocDeclStr(
233 static wxIcon , GetIcon(const wxString& id,
234 const wxString& client = wxPyART_OTHER,
235 const wxSize& size = wxDefaultSize),
236 "Query the providers for icon with given ID and return it. Return
237wx.NullIcon if no provider provides it.", "");
238
239
240 %extend { void Destroy() { delete self; }}
241};
242
243
244
245//---------------------------------------------------------------------------
246%init %{
247 wxPyPtrTypeMap_Add("wxArtProvider", "wxPyArtProvider");
248%}
249//---------------------------------------------------------------------------