]>
Commit | Line | Data |
---|---|---|
7bf85405 RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: helpers.h | |
3 | // Purpose: Helper functions/classes for the wxPython extenaion module | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 7/1/97 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 1998 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | #ifndef __wxp_helpers__ | |
14 | #define __wxp_helpers__ | |
15 | ||
16 | #include <wx/wx.h> | |
17 | ||
18 | ||
cf694132 RD |
19 | //---------------------------------------------------------------------- |
20 | ||
21 | // if we want to handle threads and Python threads are available... | |
22 | #if defined(WXP_USE_THREAD) && defined(WITH_THREAD) | |
23 | ||
24 | #define WXP_WITH_THREAD | |
25 | #define wxPy_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS | |
26 | #define wxPy_END_ALLOW_THREADS Py_END_ALLOW_THREADS | |
27 | ||
28 | #else // no Python threads... | |
29 | #undef WXP_WITH_THREAD | |
30 | #define wxPy_BEGIN_ALLOW_THREADS | |
31 | #define wxPy_END_ALLOW_THREADS | |
32 | #endif | |
33 | ||
34 | ||
efc5f224 RD |
35 | //--------------------------------------------------------------------------- |
36 | ||
37 | #if defined(__WXMSW__) | |
38 | # define HELPEREXPORT __declspec(dllexport) | |
39 | #else | |
40 | # define HELPEREXPORT | |
41 | #endif | |
42 | ||
2f90df85 RD |
43 | typedef unsigned char byte; |
44 | ||
7bf85405 RD |
45 | //---------------------------------------------------------------------- |
46 | ||
47 | class wxPyApp: public wxApp | |
48 | { | |
49 | public: | |
cf694132 RD |
50 | wxPyApp(); |
51 | ~wxPyApp(); | |
7bf85405 RD |
52 | int MainLoop(void); |
53 | bool OnInit(void); | |
8bf5d46e | 54 | //# void AfterMainLoop(void); |
7bf85405 RD |
55 | }; |
56 | ||
57 | extern wxPyApp *wxPythonApp; | |
58 | ||
59 | //---------------------------------------------------------------------- | |
60 | ||
0d6f9504 | 61 | void __wxPreStart(); |
7bf85405 RD |
62 | PyObject* __wxStart(PyObject*, PyObject* args); |
63 | ||
64 | extern PyObject* wxPython_dict; | |
65 | PyObject* __wxSetDictionary(PyObject*, PyObject* args); | |
66 | ||
7bf85405 | 67 | void wxPyEventThunker(wxObject*, wxEvent& event); |
efc5f224 RD |
68 | |
69 | HELPEREXPORT PyObject* wxPyConstructObject(void* ptr, char* className); | |
d559219f RD |
70 | HELPEREXPORT bool wxPyRestoreThread(); |
71 | HELPEREXPORT void wxPySaveThread(bool doSave); | |
389c5527 | 72 | HELPEREXPORT PyObject* wxPy_ConvertList(wxListBase* list, char* className); |
7bf85405 RD |
73 | |
74 | //---------------------------------------------------------------------- | |
2f90df85 RD |
75 | // These are helpers used by the typemaps |
76 | ||
77 | HELPEREXPORT byte* byte_LIST_helper(PyObject* source); | |
78 | HELPEREXPORT int* int_LIST_helper(PyObject* source); | |
79 | HELPEREXPORT long* long_LIST_helper(PyObject* source); | |
80 | HELPEREXPORT char** string_LIST_helper(PyObject* source); | |
81 | HELPEREXPORT wxPoint* wxPoint_LIST_helper(PyObject* source); | |
82 | HELPEREXPORT wxBitmap** wxBitmap_LIST_helper(PyObject* source); | |
83 | HELPEREXPORT wxString* wxString_LIST_helper(PyObject* source); | |
84 | HELPEREXPORT wxAcceleratorEntry* wxAcceleratorEntry_LIST_helper(PyObject* source); | |
85 | ||
86 | HELPEREXPORT bool wxSize_helper(PyObject* source, wxSize** obj); | |
87 | HELPEREXPORT bool wxPoint_helper(PyObject* source, wxPoint** obj); | |
88 | HELPEREXPORT bool wxRealPoint_helper(PyObject* source, wxRealPoint** obj); | |
89 | HELPEREXPORT bool wxRect_helper(PyObject* source, wxRect** obj); | |
7bf85405 | 90 | |
2f90df85 | 91 | //---------------------------------------------------------------------- |
7bf85405 RD |
92 | |
93 | #ifndef SWIGCODE | |
94 | extern "C" void SWIG_MakePtr(char *, void *, char *); | |
95 | extern "C" char *SWIG_GetPtr(char *, void **, char *); | |
d559219f | 96 | extern "C" char *SWIG_GetPtrObj(PyObject *obj, void **ptr, char *type); |
7bf85405 RD |
97 | #endif |
98 | ||
99 | ||
100 | #ifdef _MSC_VER | |
101 | # pragma warning(disable:4800) | |
102 | #endif | |
103 | ||
b639c3c5 | 104 | |
7bf85405 RD |
105 | |
106 | // Non-const versions to keep SWIG happy. | |
107 | extern wxPoint wxPyDefaultPosition; | |
108 | extern wxSize wxPyDefaultSize; | |
7bf85405 RD |
109 | extern wxString wxPyEmptyStr; |
110 | ||
111 | //---------------------------------------------------------------------- | |
112 | ||
113 | class wxPyCallback : public wxObject { | |
2f90df85 | 114 | DECLARE_ABSTRACT_CLASS(wxPyCallback); |
7bf85405 | 115 | public: |
cf694132 | 116 | wxPyCallback(PyObject* func); |
2f90df85 | 117 | wxPyCallback(const wxPyCallback& other); |
cf694132 | 118 | ~wxPyCallback(); |
7bf85405 RD |
119 | |
120 | void EventThunker(wxEvent& event); | |
121 | ||
122 | PyObject* m_func; | |
123 | }; | |
124 | ||
125 | //--------------------------------------------------------------------------- | |
126 | ||
8bf5d46e RD |
127 | // class wxPyMenu : public wxMenu { |
128 | // public: | |
129 | // wxPyMenu(const wxString& title = "", PyObject* func=NULL); | |
130 | // ~wxPyMenu(); | |
7bf85405 | 131 | |
8bf5d46e RD |
132 | // private: |
133 | // static void MenuCallback(wxMenu& menu, wxCommandEvent& evt); | |
134 | // PyObject* func; | |
135 | // }; | |
714e6a9e | 136 | |
7bf85405 RD |
137 | |
138 | //--------------------------------------------------------------------------- | |
139 | ||
140 | class wxPyTimer : public wxTimer { | |
141 | public: | |
142 | wxPyTimer(PyObject* callback); | |
143 | ~wxPyTimer(); | |
144 | ||
145 | void Notify(); | |
146 | ||
147 | private: | |
148 | PyObject* func; | |
149 | }; | |
150 | ||
cf694132 RD |
151 | //--------------------------------------------------------------------------- |
152 | ||
bb0054cd RD |
153 | |
154 | ||
155 | ||
156 | //--------------------------------------------------------------------------- | |
157 | // This class holds an instance of a Python Shadow Class object and assists | |
158 | // with looking up and invoking Python callback methods from C++ virtual | |
159 | // method redirections. For all classes which have virtuals which should be | |
160 | // overridable in wxPython, a new subclass is created that contains a | |
a08cbc01 | 161 | // wxPyCallbackHelper. |
d559219f RD |
162 | // |
163 | // **** This class should be combined with wxPyCallback defined above. | |
164 | // | |
bb0054cd | 165 | |
efc5f224 | 166 | class HELPEREXPORT wxPyCallbackHelper { |
bb0054cd RD |
167 | public: |
168 | wxPyCallbackHelper(); | |
169 | ~wxPyCallbackHelper(); | |
170 | ||
2f90df85 RD |
171 | wxPyCallbackHelper(const wxPyCallbackHelper& other); |
172 | ||
173 | void setSelf(PyObject* self, int incref=TRUE); | |
bb0054cd RD |
174 | |
175 | bool findCallback(const wxString& name); | |
176 | int callCallback(PyObject* argTuple); | |
177 | PyObject* callCallbackObj(PyObject* argTuple); | |
178 | ||
179 | private: | |
180 | PyObject* m_self; | |
181 | PyObject* m_lastFound; | |
182 | }; | |
183 | ||
184 | ||
185 | ||
186 | //--------------------------------------------------------------------------- | |
187 | // These macros are used to implement the virtual methods that should | |
188 | // redirect to a Python method if one exists. The names designate the | |
189 | // return type, if any as well as any parameter types. | |
190 | //--------------------------------------------------------------------------- | |
191 | ||
2f90df85 RD |
192 | #define PYPRIVATE \ |
193 | void _setSelf(PyObject* self, int incref=TRUE) { \ | |
194 | m_myInst.setSelf(self, incref); \ | |
195 | } \ | |
efc5f224 RD |
196 | private: wxPyCallbackHelper m_myInst; |
197 | ||
198 | //--------------------------------------------------------------------------- | |
199 | ||
d559219f RD |
200 | #define DEC_PYCALLBACK__(CBNAME) \ |
201 | void CBNAME(); \ | |
202 | void base_##CBNAME(); | |
203 | ||
204 | ||
205 | #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \ | |
206 | void CLASS::CBNAME() { \ | |
207 | bool doSave = wxPyRestoreThread(); \ | |
208 | if (m_myInst.findCallback(#CBNAME)) \ | |
209 | m_myInst.callCallback(Py_BuildValue("()")); \ | |
210 | else \ | |
211 | PCLASS::CBNAME(); \ | |
212 | wxPySaveThread(doSave); \ | |
213 | } \ | |
214 | void CLASS::base_##CBNAME() { \ | |
215 | PCLASS::CBNAME(); \ | |
216 | } | |
217 | ||
218 | //--------------------------------------------------------------------------- | |
219 | ||
220 | #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \ | |
221 | bool CBNAME(int a, int b); \ | |
222 | bool base_##CBNAME(int a, int b); | |
223 | ||
224 | ||
225 | #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \ | |
226 | bool CLASS::CBNAME(int a, int b) { \ | |
227 | bool rval; \ | |
228 | bool doSave = wxPyRestoreThread(); \ | |
bb0054cd | 229 | if (m_myInst.findCallback(#CBNAME)) \ |
d559219f | 230 | rval = m_myInst.callCallback(Py_BuildValue("(ii)",a,b)); \ |
bb0054cd | 231 | else \ |
d559219f RD |
232 | rval = PCLASS::CBNAME(a,b); \ |
233 | wxPySaveThread(doSave); \ | |
234 | return rval; \ | |
bb0054cd | 235 | } \ |
d559219f | 236 | bool CLASS::base_##CBNAME(int a, int b) { \ |
bb0054cd RD |
237 | return PCLASS::CBNAME(a,b); \ |
238 | } | |
239 | ||
240 | //--------------------------------------------------------------------------- | |
241 | ||
d559219f RD |
242 | #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \ |
243 | bool CBNAME(int a); \ | |
244 | bool base_##CBNAME(int a); | |
245 | ||
246 | ||
247 | #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \ | |
248 | bool CLASS::CBNAME(int a) { \ | |
249 | bool rval; \ | |
250 | bool doSave = wxPyRestoreThread(); \ | |
bb0054cd | 251 | if (m_myInst.findCallback(#CBNAME)) \ |
d559219f | 252 | rval = m_myInst.callCallback(Py_BuildValue("(i)",a)); \ |
bb0054cd | 253 | else \ |
d559219f RD |
254 | rval = PCLASS::CBNAME(a); \ |
255 | wxPySaveThread(doSave); \ | |
256 | return rval; \ | |
bb0054cd | 257 | } \ |
d559219f | 258 | bool CLASS::base_##CBNAME(int a) { \ |
bb0054cd RD |
259 | return PCLASS::CBNAME(a); \ |
260 | } | |
261 | ||
efc5f224 RD |
262 | //--------------------------------------------------------------------------- |
263 | ||
d559219f RD |
264 | #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \ |
265 | bool CBNAME(int a); | |
266 | ||
267 | ||
268 | #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \ | |
269 | bool CLASS::CBNAME(int a) { \ | |
270 | bool rval; \ | |
271 | bool doSave = wxPyRestoreThread(); \ | |
bb0054cd | 272 | if (m_myInst.findCallback(#CBNAME)) \ |
d559219f RD |
273 | rval = m_myInst.callCallback(Py_BuildValue("(i)",a)); \ |
274 | else rval = false; \ | |
275 | wxPySaveThread(doSave); \ | |
276 | return rval; \ | |
bb0054cd RD |
277 | } |
278 | ||
279 | ||
280 | //--------------------------------------------------------------------------- | |
281 | ||
d559219f RD |
282 | #define DEC_PYCALLBACK__DC(CBNAME) \ |
283 | void CBNAME(wxDC& a); \ | |
284 | void base_##CBNAME(wxDC& a); | |
285 | ||
286 | ||
287 | #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \ | |
288 | void CLASS::CBNAME(wxDC& a) { \ | |
289 | bool doSave = wxPyRestoreThread(); \ | |
290 | if (m_myInst.findCallback(#CBNAME)) \ | |
291 | m_myInst.callCallback(Py_BuildValue("(O)", \ | |
292 | wxPyConstructObject(&a, "wxDC"))); \ | |
293 | else \ | |
294 | PCLASS::CBNAME(a); \ | |
295 | wxPySaveThread(doSave); \ | |
296 | } \ | |
297 | void CLASS::base_##CBNAME(wxDC& a) { \ | |
298 | PCLASS::CBNAME(a); \ | |
bb0054cd RD |
299 | } |
300 | ||
efc5f224 RD |
301 | |
302 | ||
bb0054cd RD |
303 | //--------------------------------------------------------------------------- |
304 | ||
d559219f RD |
305 | #define DEC_PYCALLBACK__DCBOOL(CBNAME) \ |
306 | void CBNAME(wxDC& a, bool b); \ | |
307 | void base_##CBNAME(wxDC& a, bool b); | |
308 | ||
309 | ||
310 | #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \ | |
311 | void CLASS::CBNAME(wxDC& a, bool b) { \ | |
312 | bool doSave = wxPyRestoreThread(); \ | |
efc5f224 RD |
313 | if (m_myInst.findCallback(#CBNAME)) \ |
314 | m_myInst.callCallback(Py_BuildValue("(Oi)", \ | |
d559219f | 315 | wxPyConstructObject(&a, "wxDC"), (int)b)); \ |
efc5f224 RD |
316 | else \ |
317 | PCLASS::CBNAME(a, b); \ | |
d559219f | 318 | wxPySaveThread(doSave); \ |
efc5f224 | 319 | } \ |
d559219f | 320 | void CLASS::base_##CBNAME(wxDC& a, bool b) { \ |
efc5f224 RD |
321 | PCLASS::CBNAME(a, b); \ |
322 | } | |
323 | ||
324 | //--------------------------------------------------------------------------- | |
325 | ||
d559219f RD |
326 | #define DEC_PYCALLBACK__DCBOOL(CBNAME) \ |
327 | void CBNAME(wxDC& a, bool b); \ | |
328 | void base_##CBNAME(wxDC& a, bool b); | |
329 | ||
330 | ||
331 | #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \ | |
332 | void CLASS::CBNAME(wxDC& a, bool b) { \ | |
333 | bool doSave = wxPyRestoreThread(); \ | |
efc5f224 RD |
334 | if (m_myInst.findCallback(#CBNAME)) \ |
335 | m_myInst.callCallback(Py_BuildValue("(Oi)", \ | |
d559219f | 336 | wxPyConstructObject(&a, "wxDC"), (int)b)); \ |
efc5f224 RD |
337 | else \ |
338 | PCLASS::CBNAME(a, b); \ | |
d559219f | 339 | wxPySaveThread(doSave); \ |
efc5f224 | 340 | } \ |
d559219f | 341 | void CLASS::base_##CBNAME(wxDC& a, bool b) { \ |
efc5f224 RD |
342 | PCLASS::CBNAME(a, b); \ |
343 | } | |
344 | ||
345 | //--------------------------------------------------------------------------- | |
346 | ||
d559219f RD |
347 | #define DEC_PYCALLBACK__2DBL(CBNAME) \ |
348 | void CBNAME(double a, double b); \ | |
349 | void base_##CBNAME(double a, double b); | |
350 | ||
351 | ||
352 | #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \ | |
353 | void CLASS::CBNAME(double a, double b) { \ | |
354 | bool doSave = wxPyRestoreThread(); \ | |
355 | if (m_myInst.findCallback(#CBNAME)) \ | |
356 | m_myInst.callCallback(Py_BuildValue("(dd)",a,b)); \ | |
357 | else \ | |
358 | PCLASS::CBNAME(a, b); \ | |
359 | wxPySaveThread(doSave); \ | |
360 | } \ | |
361 | void CLASS::base_##CBNAME(double a, double b) { \ | |
362 | PCLASS::CBNAME(a, b); \ | |
efc5f224 RD |
363 | } |
364 | ||
365 | //--------------------------------------------------------------------------- | |
366 | ||
d559219f RD |
367 | #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \ |
368 | void CBNAME(double a, double b, int c, int d); \ | |
369 | void base_##CBNAME(double a, double b, int c, int d); | |
370 | ||
371 | ||
372 | #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \ | |
373 | void CLASS::CBNAME(double a, double b, int c, int d) { \ | |
374 | bool doSave = wxPyRestoreThread(); \ | |
efc5f224 RD |
375 | if (m_myInst.findCallback(#CBNAME)) \ |
376 | m_myInst.callCallback(Py_BuildValue("(ddii)", \ | |
377 | a,b,c,d)); \ | |
378 | else \ | |
379 | PCLASS::CBNAME(a, b, c, d); \ | |
d559219f | 380 | wxPySaveThread(doSave); \ |
efc5f224 | 381 | } \ |
d559219f | 382 | void CLASS::base_##CBNAME(double a, double b, int c, int d) { \ |
efc5f224 RD |
383 | PCLASS::CBNAME(a, b, c, d); \ |
384 | } | |
385 | ||
386 | //--------------------------------------------------------------------------- | |
387 | ||
d559219f RD |
388 | #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \ |
389 | void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \ | |
390 | void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f); | |
391 | ||
392 | ||
393 | #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \ | |
394 | void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \ | |
395 | bool doSave = wxPyRestoreThread(); \ | |
396 | if (m_myInst.findCallback(#CBNAME)) \ | |
397 | m_myInst.callCallback(Py_BuildValue("(Oddddi)", \ | |
398 | wxPyConstructObject(&a, "wxDC"), \ | |
399 | b, c, d, e, (int)f)); \ | |
400 | else \ | |
401 | PCLASS::CBNAME(a, b, c, d, e, f); \ | |
402 | wxPySaveThread(doSave); \ | |
403 | } \ | |
404 | void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\ | |
405 | PCLASS::CBNAME(a, b, c, d, e, f); \ | |
efc5f224 RD |
406 | } |
407 | ||
408 | //--------------------------------------------------------------------------- | |
409 | ||
d559219f RD |
410 | #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \ |
411 | bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \ | |
412 | bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f); | |
413 | ||
414 | ||
415 | #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \ | |
416 | bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \ | |
417 | bool doSave = wxPyRestoreThread(); \ | |
418 | if (m_myInst.findCallback(#CBNAME)) \ | |
419 | return m_myInst.callCallback(Py_BuildValue("(Oddddi)", \ | |
420 | wxPyConstructObject(&a, "wxDC"), \ | |
421 | b, c, d, e, (int)f)); \ | |
422 | else \ | |
423 | return PCLASS::CBNAME(a, b, c, d, e, f); \ | |
424 | wxPySaveThread(doSave); \ | |
425 | } \ | |
426 | bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\ | |
427 | return PCLASS::CBNAME(a, b, c, d, e, f); \ | |
efc5f224 RD |
428 | } |
429 | ||
430 | //--------------------------------------------------------------------------- | |
431 | ||
d559219f RD |
432 | #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \ |
433 | void CBNAME(bool a, double b, double c, int d, int e); \ | |
434 | void base_##CBNAME(bool a, double b, double c, int d, int e); | |
435 | ||
436 | ||
437 | #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \ | |
438 | void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \ | |
439 | bool doSave = wxPyRestoreThread(); \ | |
440 | if (m_myInst.findCallback(#CBNAME)) \ | |
441 | m_myInst.callCallback(Py_BuildValue("(idii)", \ | |
442 | (int)a,b,c,d,e)); \ | |
443 | else \ | |
444 | PCLASS::CBNAME(a, b, c, d, e); \ | |
445 | wxPySaveThread(doSave); \ | |
446 | } \ | |
447 | void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \ | |
448 | PCLASS::CBNAME(a, b, c, d, e); \ | |
efc5f224 RD |
449 | } |
450 | ||
451 | //--------------------------------------------------------------------------- | |
452 | ||
d559219f RD |
453 | #define DEC_PYCALLBACK__DC4DBL(CBNAME) \ |
454 | void CBNAME(wxDC& a, double b, double c, double d, double e); \ | |
455 | void base_##CBNAME(wxDC& a, double b, double c, double d, double e); | |
456 | ||
457 | ||
458 | #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \ | |
459 | void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \ | |
460 | bool doSave = wxPyRestoreThread(); \ | |
461 | if (m_myInst.findCallback(#CBNAME)) \ | |
462 | m_myInst.callCallback(Py_BuildValue("(Odddd)", \ | |
463 | wxPyConstructObject(&a, "wxDC"), \ | |
464 | b, c, d, e)); \ | |
465 | else \ | |
466 | PCLASS::CBNAME(a, b, c, d, e); \ | |
467 | wxPySaveThread(doSave); \ | |
468 | } \ | |
469 | void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\ | |
470 | PCLASS::CBNAME(a, b, c, d, e); \ | |
efc5f224 RD |
471 | } |
472 | ||
473 | //--------------------------------------------------------------------------- | |
474 | ||
d559219f RD |
475 | #define DEC_PYCALLBACK__DCBOOL(CBNAME) \ |
476 | void CBNAME(wxDC& a, bool b); \ | |
477 | void base_##CBNAME(wxDC& a, bool b); | |
478 | ||
479 | ||
480 | #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \ | |
481 | void CLASS::CBNAME(wxDC& a, bool b) { \ | |
482 | bool doSave = wxPyRestoreThread(); \ | |
efc5f224 RD |
483 | if (m_myInst.findCallback(#CBNAME)) \ |
484 | m_myInst.callCallback(Py_BuildValue("(Oi)", \ | |
d559219f | 485 | wxPyConstructObject(&a, "wxDC"), \ |
efc5f224 RD |
486 | (int)b)); \ |
487 | else \ | |
488 | PCLASS::CBNAME(a, b); \ | |
d559219f | 489 | wxPySaveThread(doSave); \ |
efc5f224 | 490 | } \ |
d559219f | 491 | void CLASS::base_##CBNAME(wxDC& a, bool b) { \ |
efc5f224 RD |
492 | PCLASS::CBNAME(a, b); \ |
493 | } | |
bb0054cd | 494 | |
7bf85405 | 495 | //--------------------------------------------------------------------------- |
7bf85405 | 496 | |
d559219f RD |
497 | #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \ |
498 | void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \ | |
499 | void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); | |
500 | ||
501 | ||
502 | #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \ | |
503 | void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \ | |
504 | int e, int f) { \ | |
505 | bool doSave = wxPyRestoreThread(); \ | |
506 | if (m_myInst.findCallback(#CBNAME)) \ | |
507 | m_myInst.callCallback(Py_BuildValue("(Oiddii)", \ | |
2f90df85 | 508 | wxPyConstructObject(a, "wxPyControlPoint"), \ |
d559219f RD |
509 | (int)b, c, d, e, f)); \ |
510 | else \ | |
511 | PCLASS::CBNAME(a, b, c, d, e, f); \ | |
512 | wxPySaveThread(doSave); \ | |
513 | } \ | |
514 | void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \ | |
515 | int e, int f) { \ | |
516 | PCLASS::CBNAME(a, b, c, d, e, f); \ | |
efc5f224 RD |
517 | } |
518 | ||
519 | //--------------------------------------------------------------------------- | |
520 | ||
d559219f RD |
521 | #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \ |
522 | void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \ | |
523 | void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e); | |
524 | ||
525 | ||
526 | #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \ | |
527 | void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \ | |
528 | bool doSave = wxPyRestoreThread(); \ | |
529 | if (m_myInst.findCallback(#CBNAME)) \ | |
530 | m_myInst.callCallback(Py_BuildValue("(Oddii)", \ | |
2f90df85 | 531 | wxPyConstructObject(a, "wxPyControlPoint"), \ |
d559219f RD |
532 | b, c, d, e)); \ |
533 | else \ | |
534 | PCLASS::CBNAME(a, b, c, d, e); \ | |
535 | wxPySaveThread(doSave); \ | |
536 | } \ | |
537 | void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \ | |
538 | int d, int e) { \ | |
539 | PCLASS::CBNAME(a, b, c, d, e); \ | |
efc5f224 RD |
540 | } |
541 | ||
542 | //--------------------------------------------------------------------------- | |
543 | ||
d559219f RD |
544 | #define DEC_PYCALLBACK__2DBLINT(CBNAME) \ |
545 | void CBNAME(double a, double b, int c); \ | |
546 | void base_##CBNAME(double a, double b, int c); | |
547 | ||
548 | ||
549 | #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \ | |
550 | void CLASS::CBNAME(double a, double b, int c) { \ | |
551 | bool doSave = wxPyRestoreThread(); \ | |
efc5f224 RD |
552 | if (m_myInst.findCallback(#CBNAME)) \ |
553 | m_myInst.callCallback(Py_BuildValue("(ddi)", a,b,c)); \ | |
554 | else \ | |
555 | PCLASS::CBNAME(a, b, c); \ | |
d559219f | 556 | wxPySaveThread(doSave); \ |
efc5f224 | 557 | } \ |
d559219f | 558 | void CLASS::base_##CBNAME(double a, double b, int c) { \ |
efc5f224 RD |
559 | PCLASS::CBNAME(a, b, c); \ |
560 | } | |
561 | ||
562 | //--------------------------------------------------------------------------- | |
563 | ||
d559219f RD |
564 | #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \ |
565 | void CBNAME(bool a, double b, double c, int d); \ | |
566 | void base_##CBNAME(bool a, double b, double c, int d); | |
567 | ||
568 | ||
569 | #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \ | |
570 | void CLASS::CBNAME(bool a, double b, double c, int d) { \ | |
571 | bool doSave = wxPyRestoreThread(); \ | |
572 | if (m_myInst.findCallback(#CBNAME)) \ | |
573 | m_myInst.callCallback(Py_BuildValue("(iddi)", (int)a,b,c,d)); \ | |
574 | else \ | |
575 | PCLASS::CBNAME(a, b, c, d); \ | |
576 | wxPySaveThread(doSave); \ | |
577 | } \ | |
578 | void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \ | |
579 | PCLASS::CBNAME(a, b, c, d); \ | |
efc5f224 RD |
580 | } |
581 | ||
582 | //--------------------------------------------------------------------------- | |
583 | //--------------------------------------------------------------------------- | |
389c5527 RD |
584 | |
585 | #define DEC_PYCALLBACK__STRING(CBNAME) \ | |
586 | void CBNAME(const wxString& a); \ | |
587 | void base_##CBNAME(const wxString& a); | |
588 | ||
589 | ||
590 | #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \ | |
591 | void CLASS::CBNAME(const wxString& a) { \ | |
592 | bool doSave = wxPyRestoreThread(); \ | |
593 | if (m_myInst.findCallback(#CBNAME)) \ | |
594 | m_myInst.callCallback(Py_BuildValue("(s)", a.c_str())); \ | |
595 | else \ | |
596 | PCLASS::CBNAME(a); \ | |
597 | wxPySaveThread(doSave); \ | |
598 | } \ | |
599 | void CLASS::base_##CBNAME(const wxString& a) { \ | |
600 | PCLASS::CBNAME(a); \ | |
601 | } | |
602 | ||
603 | //--------------------------------------------------------------------------- | |
604 | ||
605 | #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \ | |
606 | bool CBNAME(const wxString& a); \ | |
607 | bool base_##CBNAME(const wxString& a); | |
608 | ||
609 | ||
610 | #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \ | |
611 | bool CLASS::CBNAME(const wxString& a) { \ | |
612 | bool rval; \ | |
613 | bool doSave = wxPyRestoreThread(); \ | |
614 | if (m_myInst.findCallback(#CBNAME)) \ | |
615 | rval = m_myInst.callCallback(Py_BuildValue("(s)", a.c_str())); \ | |
616 | else \ | |
617 | rval = PCLASS::CBNAME(a); \ | |
618 | wxPySaveThread(doSave); \ | |
619 | return rval; \ | |
620 | } \ | |
621 | bool CLASS::base_##CBNAME(const wxString& a) { \ | |
622 | return PCLASS::CBNAME(a); \ | |
623 | } | |
624 | ||
625 | //--------------------------------------------------------------------------- | |
626 | ||
f0261a72 RD |
627 | #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \ |
628 | bool CBNAME(const wxString& a, const wxString& b); \ | |
629 | bool base_##CBNAME(const wxString& a, const wxString& b); | |
630 | ||
631 | ||
632 | #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \ | |
633 | bool CLASS::CBNAME(const wxString& a, const wxString& b) { \ | |
634 | bool rval; \ | |
635 | bool doSave = wxPyRestoreThread(); \ | |
636 | if (m_myInst.findCallback(#CBNAME)) \ | |
637 | rval = m_myInst.callCallback(Py_BuildValue("(ss)", \ | |
638 | a.c_str(), b.c_str())); \ | |
639 | else \ | |
640 | rval = PCLASS::CBNAME(a, b); \ | |
641 | wxPySaveThread(doSave); \ | |
642 | return rval; \ | |
643 | } \ | |
644 | bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \ | |
645 | return PCLASS::CBNAME(a, b); \ | |
646 | } | |
647 | ||
648 | //--------------------------------------------------------------------------- | |
649 | ||
389c5527 RD |
650 | #define DEC_PYCALLBACK_STRING_(CBNAME) \ |
651 | wxString CBNAME(); \ | |
652 | wxString base_##CBNAME(); | |
653 | ||
654 | ||
655 | #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \ | |
656 | wxString CLASS::CBNAME() { \ | |
657 | wxString rval; \ | |
658 | bool doSave = wxPyRestoreThread(); \ | |
659 | if (m_myInst.findCallback(#CBNAME)) { \ | |
660 | PyObject* ro; \ | |
661 | ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \ | |
662 | rval = PyString_AsString(PyObject_Str(ro)); \ | |
663 | } \ | |
664 | else \ | |
665 | rval = PCLASS::CBNAME(a); \ | |
666 | wxPySaveThread(doSave); \ | |
667 | return rval; \ | |
668 | } \ | |
669 | bool CLASS::base_##CBNAME(const wxString& a) { \ | |
670 | return PCLASS::CBNAME(a); \ | |
671 | } | |
672 | ||
673 | //--------------------------------------------------------------------------- | |
674 | ||
675 | #define DEC_PYCALLBACK_STRING__pure(CBNAME) \ | |
676 | wxString CBNAME(); | |
677 | ||
678 | ||
679 | #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \ | |
680 | wxString CLASS::CBNAME() { \ | |
681 | wxString rval; \ | |
682 | bool doSave = wxPyRestoreThread(); \ | |
683 | if (m_myInst.findCallback(#CBNAME)) { \ | |
684 | PyObject* ro; \ | |
685 | ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \ | |
686 | rval = PyString_AsString(PyObject_Str(ro)); \ | |
687 | } \ | |
688 | wxPySaveThread(doSave); \ | |
689 | return rval; \ | |
690 | } | |
691 | ||
692 | //--------------------------------------------------------------------------- | |
693 | ||
694 | #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \ | |
695 | bool CBNAME(const wxHtmlTag& a); \ | |
696 | ||
697 | ||
698 | #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \ | |
699 | bool CLASS::CBNAME(const wxHtmlTag& a) { \ | |
700 | bool rval = false; \ | |
701 | bool doSave = wxPyRestoreThread(); \ | |
702 | if (m_myInst.findCallback(#CBNAME)) \ | |
703 | rval = m_myInst.callCallback(Py_BuildValue("(O)", \ | |
704 | wxPyConstructObject((void*)&a,"wxHtmlTag"))); \ | |
705 | wxPySaveThread(doSave); \ | |
706 | return rval; \ | |
707 | } | |
708 | ||
709 | //--------------------------------------------------------------------------- | |
2f90df85 RD |
710 | |
711 | #define DEC_PYCALLBACK___pure(CBNAME) \ | |
712 | void CBNAME(); \ | |
713 | ||
714 | ||
715 | #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \ | |
716 | void CLASS::CBNAME() { \ | |
717 | bool doSave = wxPyRestoreThread(); \ | |
718 | if (m_myInst.findCallback(#CBNAME)) \ | |
719 | m_myInst.callCallback(Py_BuildValue("()")); \ | |
720 | wxPySaveThread(doSave); \ | |
721 | } | |
722 | ||
723 | //--------------------------------------------------------------------------- | |
724 | ||
725 | #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \ | |
726 | wxSize CBNAME(); \ | |
727 | ||
728 | ||
729 | #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \ | |
730 | wxSize CLASS::CBNAME() { \ | |
731 | wxSize rval(0,0); \ | |
732 | bool doSave = wxPyRestoreThread(); \ | |
733 | if (m_myInst.findCallback(#CBNAME)) { \ | |
734 | PyObject* ro; \ | |
735 | wxSize* ptr; \ | |
736 | ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \ | |
737 | if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \ | |
738 | rval = *ptr; \ | |
739 | } \ | |
740 | wxPySaveThread(doSave); \ | |
741 | return rval; \ | |
742 | } | |
743 | ||
744 | //--------------------------------------------------------------------------- | |
745 | ||
746 | #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \ | |
747 | bool CBNAME(wxWindow* a); \ | |
748 | bool base_##CBNAME(wxWindow* a); | |
749 | ||
750 | ||
751 | #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \ | |
752 | bool CLASS::CBNAME(wxWindow* a) { \ | |
753 | bool rval; \ | |
754 | bool doSave = wxPyRestoreThread(); \ | |
755 | if (m_myInst.findCallback(#CBNAME)) \ | |
756 | rval = m_myInst.callCallback(Py_BuildValue("(O)", \ | |
757 | wxPyConstructObject((void*)a,"wxWindow"))); \ | |
758 | else \ | |
759 | rval = PCLASS::CBNAME(a); \ | |
760 | wxPySaveThread(doSave); \ | |
761 | return rval; \ | |
762 | } \ | |
763 | bool CLASS::base_##CBNAME(wxWindow* a) { \ | |
764 | return PCLASS::CBNAME(a); \ | |
765 | } | |
766 | ||
389c5527 | 767 | //--------------------------------------------------------------------------- |
2f90df85 RD |
768 | |
769 | #define DEC_PYCALLBACK_BOOL_(CBNAME) \ | |
770 | bool CBNAME(); \ | |
771 | bool base_##CBNAME(); | |
772 | ||
773 | ||
774 | #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \ | |
775 | bool CLASS::CBNAME() { \ | |
776 | bool rval; \ | |
777 | bool doSave = wxPyRestoreThread(); \ | |
778 | if (m_myInst.findCallback(#CBNAME)) \ | |
779 | rval = m_myInst.callCallback(Py_BuildValue("()")); \ | |
780 | else \ | |
781 | rval = PCLASS::CBNAME(); \ | |
782 | wxPySaveThread(doSave); \ | |
783 | return rval; \ | |
784 | } \ | |
785 | bool CLASS::base_##CBNAME() { \ | |
786 | return PCLASS::CBNAME(); \ | |
787 | } | |
788 | ||
389c5527 | 789 | //--------------------------------------------------------------------------- |
efc5f224 RD |
790 | //--------------------------------------------------------------------------- |
791 | //--------------------------------------------------------------------------- | |
792 | ||
7bf85405 RD |
793 | #endif |
794 | ||
efc5f224 RD |
795 | |
796 |