]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/helpers.h
New SWIG generated sources
[wxWidgets.git] / utils / wxPython / src / helpers.h
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
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
35 //---------------------------------------------------------------------------
36
37 #if defined(__WXMSW__)
38 # define HELPEREXPORT __declspec(dllexport)
39 #else
40 # define HELPEREXPORT
41 #endif
42
43 typedef unsigned char byte;
44
45 //----------------------------------------------------------------------
46
47 class wxPyApp: public wxApp
48 {
49 public:
50 wxPyApp();
51 ~wxPyApp();
52 int MainLoop(void);
53 bool OnInit(void);
54 //# void AfterMainLoop(void);
55 };
56
57 extern wxPyApp *wxPythonApp;
58
59 //----------------------------------------------------------------------
60
61 void __wxPreStart();
62 PyObject* __wxStart(PyObject*, PyObject* args);
63
64 extern PyObject* wxPython_dict;
65 PyObject* __wxSetDictionary(PyObject*, PyObject* args);
66
67 void wxPyEventThunker(wxObject*, wxEvent& event);
68
69 HELPEREXPORT PyObject* wxPyConstructObject(void* ptr, const char* className);
70 HELPEREXPORT bool wxPyRestoreThread();
71 HELPEREXPORT void wxPySaveThread(bool doSave);
72 HELPEREXPORT PyObject* wxPy_ConvertList(wxListBase* list, const char* className);
73
74 //----------------------------------------------------------------------
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);
90
91 //----------------------------------------------------------------------
92
93 #ifndef SWIGCODE
94 extern "C" void SWIG_MakePtr(char *, void *, char *);
95 extern "C" char *SWIG_GetPtr(char *, void **, char *);
96 extern "C" char *SWIG_GetPtrObj(PyObject *obj, void **ptr, char *type);
97 #endif
98
99
100 #ifdef _MSC_VER
101 # pragma warning(disable:4800)
102 #endif
103
104
105
106 // Non-const versions to keep SWIG happy.
107 extern wxPoint wxPyDefaultPosition;
108 extern wxSize wxPyDefaultSize;
109 extern wxString wxPyEmptyStr;
110
111 //----------------------------------------------------------------------
112
113 class wxPyCallback : public wxObject {
114 DECLARE_ABSTRACT_CLASS(wxPyCallback);
115 public:
116 wxPyCallback(PyObject* func);
117 wxPyCallback(const wxPyCallback& other);
118 ~wxPyCallback();
119
120 void EventThunker(wxEvent& event);
121
122 PyObject* m_func;
123 };
124
125 //---------------------------------------------------------------------------
126
127 // class wxPyMenu : public wxMenu {
128 // public:
129 // wxPyMenu(const wxString& title = "", PyObject* func=NULL);
130 // ~wxPyMenu();
131
132 // private:
133 // static void MenuCallback(wxMenu& menu, wxCommandEvent& evt);
134 // PyObject* func;
135 // };
136
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
151 //---------------------------------------------------------------------------
152
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
161 // wxPyCallbackHelper.
162 //
163 // **** This class should be combined with wxPyCallback defined above.
164 //
165
166 class HELPEREXPORT wxPyCallbackHelper {
167 public:
168 wxPyCallbackHelper();
169 ~wxPyCallbackHelper();
170
171 wxPyCallbackHelper(const wxPyCallbackHelper& other);
172
173 void setSelf(PyObject* self, int incref=TRUE);
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 int m_incRef;
183 };
184
185
186 //---------------------------------------------------------------------------
187 //---------------------------------------------------------------------------
188 // These classes can be derived from in Python and passed through the event
189 // system without loosing anything. They do this by keeping a reference to
190 // themselves and some special case handling in wxPyCallback::EventThunker.
191
192
193 class wxPyEvtSelfRef {
194 public:
195 wxPyEvtSelfRef();
196 ~wxPyEvtSelfRef();
197
198 void SetSelf(PyObject* self, bool clone=FALSE);
199 PyObject* GetSelf() const;
200
201 protected:
202 PyObject* m_self;
203 bool m_cloned;
204 };
205
206
207 class wxPyEvent : public wxEvent, public wxPyEvtSelfRef {
208 DECLARE_DYNAMIC_CLASS(wxPyEvent)
209 public:
210 wxPyEvent(int id=0);
211 ~wxPyEvent();
212
213 void CopyObject(wxObject& dest) const;
214 };
215
216
217 class wxPyCommandEvent : public wxCommandEvent, public wxPyEvtSelfRef {
218 DECLARE_DYNAMIC_CLASS(wxPyCommandEvent)
219 public:
220 wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0);
221 ~wxPyCommandEvent();
222
223 void CopyObject(wxObject& dest) const;
224 };
225
226
227 //---------------------------------------------------------------------------
228 // These macros are used to implement the virtual methods that should
229 // redirect to a Python method if one exists. The names designate the
230 // return type, if any, as well as any parameter types.
231 //---------------------------------------------------------------------------
232
233 #define PYPRIVATE \
234 void _setSelf(PyObject* self, int incref=1) { \
235 m_myInst.setSelf(self, incref); \
236 } \
237 private: wxPyCallbackHelper m_myInst;
238
239 //---------------------------------------------------------------------------
240
241 #define DEC_PYCALLBACK__(CBNAME) \
242 void CBNAME(); \
243 void base_##CBNAME();
244
245
246 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
247 void CLASS::CBNAME() { \
248 bool doSave = wxPyRestoreThread(); \
249 if (m_myInst.findCallback(#CBNAME)) \
250 m_myInst.callCallback(Py_BuildValue("()")); \
251 else \
252 PCLASS::CBNAME(); \
253 wxPySaveThread(doSave); \
254 } \
255 void CLASS::base_##CBNAME() { \
256 PCLASS::CBNAME(); \
257 }
258
259 //---------------------------------------------------------------------------
260
261 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
262 bool CBNAME(int a, int b); \
263 bool base_##CBNAME(int a, int b);
264
265
266 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
267 bool CLASS::CBNAME(int a, int b) { \
268 bool rval; \
269 bool doSave = wxPyRestoreThread(); \
270 if (m_myInst.findCallback(#CBNAME)) \
271 rval = m_myInst.callCallback(Py_BuildValue("(ii)",a,b)); \
272 else \
273 rval = PCLASS::CBNAME(a,b); \
274 wxPySaveThread(doSave); \
275 return rval; \
276 } \
277 bool CLASS::base_##CBNAME(int a, int b) { \
278 return PCLASS::CBNAME(a,b); \
279 }
280
281 //---------------------------------------------------------------------------
282
283 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
284 bool CBNAME(int a); \
285 bool base_##CBNAME(int a);
286
287
288 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
289 bool CLASS::CBNAME(int a) { \
290 bool rval; \
291 bool doSave = wxPyRestoreThread(); \
292 if (m_myInst.findCallback(#CBNAME)) \
293 rval = m_myInst.callCallback(Py_BuildValue("(i)",a)); \
294 else \
295 rval = PCLASS::CBNAME(a); \
296 wxPySaveThread(doSave); \
297 return rval; \
298 } \
299 bool CLASS::base_##CBNAME(int a) { \
300 return PCLASS::CBNAME(a); \
301 }
302
303 //---------------------------------------------------------------------------
304
305 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
306 bool CBNAME(int a);
307
308
309 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
310 bool CLASS::CBNAME(int a) { \
311 bool rval; \
312 bool doSave = wxPyRestoreThread(); \
313 if (m_myInst.findCallback(#CBNAME)) \
314 rval = m_myInst.callCallback(Py_BuildValue("(i)",a)); \
315 else rval = false; \
316 wxPySaveThread(doSave); \
317 return rval; \
318 }
319
320
321 //---------------------------------------------------------------------------
322
323 #define DEC_PYCALLBACK__DC(CBNAME) \
324 void CBNAME(wxDC& a); \
325 void base_##CBNAME(wxDC& a);
326
327
328 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
329 void CLASS::CBNAME(wxDC& a) { \
330 bool doSave = wxPyRestoreThread(); \
331 if (m_myInst.findCallback(#CBNAME)) \
332 m_myInst.callCallback(Py_BuildValue("(O)", \
333 wxPyConstructObject(&a, "wxDC"))); \
334 else \
335 PCLASS::CBNAME(a); \
336 wxPySaveThread(doSave); \
337 } \
338 void CLASS::base_##CBNAME(wxDC& a) { \
339 PCLASS::CBNAME(a); \
340 }
341
342
343
344 //---------------------------------------------------------------------------
345
346 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
347 void CBNAME(wxDC& a, bool b); \
348 void base_##CBNAME(wxDC& a, bool b);
349
350
351 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
352 void CLASS::CBNAME(wxDC& a, bool b) { \
353 bool doSave = wxPyRestoreThread(); \
354 if (m_myInst.findCallback(#CBNAME)) \
355 m_myInst.callCallback(Py_BuildValue("(Oi)", \
356 wxPyConstructObject(&a, "wxDC"), (int)b)); \
357 else \
358 PCLASS::CBNAME(a, b); \
359 wxPySaveThread(doSave); \
360 } \
361 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
362 PCLASS::CBNAME(a, b); \
363 }
364
365 //---------------------------------------------------------------------------
366
367 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
368 void CBNAME(wxDC& a, bool b); \
369 void base_##CBNAME(wxDC& a, bool b);
370
371
372 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
373 void CLASS::CBNAME(wxDC& a, bool b) { \
374 bool doSave = wxPyRestoreThread(); \
375 if (m_myInst.findCallback(#CBNAME)) \
376 m_myInst.callCallback(Py_BuildValue("(Oi)", \
377 wxPyConstructObject(&a, "wxDC"), (int)b)); \
378 else \
379 PCLASS::CBNAME(a, b); \
380 wxPySaveThread(doSave); \
381 } \
382 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
383 PCLASS::CBNAME(a, b); \
384 }
385
386 //---------------------------------------------------------------------------
387
388 #define DEC_PYCALLBACK__2DBL(CBNAME) \
389 void CBNAME(double a, double b); \
390 void base_##CBNAME(double a, double b);
391
392
393 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
394 void CLASS::CBNAME(double a, double b) { \
395 bool doSave = wxPyRestoreThread(); \
396 if (m_myInst.findCallback(#CBNAME)) \
397 m_myInst.callCallback(Py_BuildValue("(dd)",a,b)); \
398 else \
399 PCLASS::CBNAME(a, b); \
400 wxPySaveThread(doSave); \
401 } \
402 void CLASS::base_##CBNAME(double a, double b) { \
403 PCLASS::CBNAME(a, b); \
404 }
405
406 //---------------------------------------------------------------------------
407
408 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
409 void CBNAME(double a, double b, int c, int d); \
410 void base_##CBNAME(double a, double b, int c, int d);
411
412
413 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
414 void CLASS::CBNAME(double a, double b, int c, int d) { \
415 bool doSave = wxPyRestoreThread(); \
416 if (m_myInst.findCallback(#CBNAME)) \
417 m_myInst.callCallback(Py_BuildValue("(ddii)", \
418 a,b,c,d)); \
419 else \
420 PCLASS::CBNAME(a, b, c, d); \
421 wxPySaveThread(doSave); \
422 } \
423 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
424 PCLASS::CBNAME(a, b, c, d); \
425 }
426
427 //---------------------------------------------------------------------------
428
429 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
430 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
431 void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
432
433
434 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
435 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
436 bool doSave = wxPyRestoreThread(); \
437 if (m_myInst.findCallback(#CBNAME)) \
438 m_myInst.callCallback(Py_BuildValue("(Oddddi)", \
439 wxPyConstructObject(&a, "wxDC"), \
440 b, c, d, e, (int)f)); \
441 else \
442 PCLASS::CBNAME(a, b, c, d, e, f); \
443 wxPySaveThread(doSave); \
444 } \
445 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
446 PCLASS::CBNAME(a, b, c, d, e, f); \
447 }
448
449 //---------------------------------------------------------------------------
450
451 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
452 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
453 bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
454
455
456 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
457 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
458 bool doSave = wxPyRestoreThread(); \
459 bool rval; \
460 if (m_myInst.findCallback(#CBNAME)) \
461 rval = m_myInst.callCallback(Py_BuildValue("(Oddddi)", \
462 wxPyConstructObject(&a, "wxDC"), \
463 b, c, d, e, (int)f)); \
464 else \
465 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
466 wxPySaveThread(doSave); \
467 return rval; \
468 } \
469 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
470 return PCLASS::CBNAME(a, b, c, d, e, f); \
471 }
472
473 //---------------------------------------------------------------------------
474
475 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
476 void CBNAME(bool a, double b, double c, int d, int e); \
477 void base_##CBNAME(bool a, double b, double c, int d, int e);
478
479
480 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
481 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
482 bool doSave = wxPyRestoreThread(); \
483 if (m_myInst.findCallback(#CBNAME)) \
484 m_myInst.callCallback(Py_BuildValue("(idii)", \
485 (int)a,b,c,d,e)); \
486 else \
487 PCLASS::CBNAME(a, b, c, d, e); \
488 wxPySaveThread(doSave); \
489 } \
490 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
491 PCLASS::CBNAME(a, b, c, d, e); \
492 }
493
494 //---------------------------------------------------------------------------
495
496 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
497 void CBNAME(wxDC& a, double b, double c, double d, double e); \
498 void base_##CBNAME(wxDC& a, double b, double c, double d, double e);
499
500
501 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
502 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
503 bool doSave = wxPyRestoreThread(); \
504 if (m_myInst.findCallback(#CBNAME)) \
505 m_myInst.callCallback(Py_BuildValue("(Odddd)", \
506 wxPyConstructObject(&a, "wxDC"), \
507 b, c, d, e)); \
508 else \
509 PCLASS::CBNAME(a, b, c, d, e); \
510 wxPySaveThread(doSave); \
511 } \
512 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
513 PCLASS::CBNAME(a, b, c, d, e); \
514 }
515
516 //---------------------------------------------------------------------------
517
518 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
519 void CBNAME(wxDC& a, bool b); \
520 void base_##CBNAME(wxDC& a, bool b);
521
522
523 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
524 void CLASS::CBNAME(wxDC& a, bool b) { \
525 bool doSave = wxPyRestoreThread(); \
526 if (m_myInst.findCallback(#CBNAME)) \
527 m_myInst.callCallback(Py_BuildValue("(Oi)", \
528 wxPyConstructObject(&a, "wxDC"), \
529 (int)b)); \
530 else \
531 PCLASS::CBNAME(a, b); \
532 wxPySaveThread(doSave); \
533 } \
534 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
535 PCLASS::CBNAME(a, b); \
536 }
537
538 //---------------------------------------------------------------------------
539
540 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
541 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
542 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f);
543
544
545 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
546 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
547 int e, int f) { \
548 bool doSave = wxPyRestoreThread(); \
549 if (m_myInst.findCallback(#CBNAME)) \
550 m_myInst.callCallback(Py_BuildValue("(Oiddii)", \
551 wxPyConstructObject(a, "wxPyControlPoint"), \
552 (int)b, c, d, e, f)); \
553 else \
554 PCLASS::CBNAME(a, b, c, d, e, f); \
555 wxPySaveThread(doSave); \
556 } \
557 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
558 int e, int f) { \
559 PCLASS::CBNAME(a, b, c, d, e, f); \
560 }
561
562 //---------------------------------------------------------------------------
563
564 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
565 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
566 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e);
567
568
569 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
570 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
571 bool doSave = wxPyRestoreThread(); \
572 if (m_myInst.findCallback(#CBNAME)) \
573 m_myInst.callCallback(Py_BuildValue("(Oddii)", \
574 wxPyConstructObject(a, "wxPyControlPoint"), \
575 b, c, d, e)); \
576 else \
577 PCLASS::CBNAME(a, b, c, d, e); \
578 wxPySaveThread(doSave); \
579 } \
580 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
581 int d, int e) { \
582 PCLASS::CBNAME(a, b, c, d, e); \
583 }
584
585 //---------------------------------------------------------------------------
586
587 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
588 void CBNAME(double a, double b, int c); \
589 void base_##CBNAME(double a, double b, int c);
590
591
592 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
593 void CLASS::CBNAME(double a, double b, int c) { \
594 bool doSave = wxPyRestoreThread(); \
595 if (m_myInst.findCallback(#CBNAME)) \
596 m_myInst.callCallback(Py_BuildValue("(ddi)", a,b,c)); \
597 else \
598 PCLASS::CBNAME(a, b, c); \
599 wxPySaveThread(doSave); \
600 } \
601 void CLASS::base_##CBNAME(double a, double b, int c) { \
602 PCLASS::CBNAME(a, b, c); \
603 }
604
605 //---------------------------------------------------------------------------
606
607 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
608 void CBNAME(bool a, double b, double c, int d); \
609 void base_##CBNAME(bool a, double b, double c, int d);
610
611
612 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
613 void CLASS::CBNAME(bool a, double b, double c, int d) { \
614 bool doSave = wxPyRestoreThread(); \
615 if (m_myInst.findCallback(#CBNAME)) \
616 m_myInst.callCallback(Py_BuildValue("(iddi)", (int)a,b,c,d)); \
617 else \
618 PCLASS::CBNAME(a, b, c, d); \
619 wxPySaveThread(doSave); \
620 } \
621 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
622 PCLASS::CBNAME(a, b, c, d); \
623 }
624
625 //---------------------------------------------------------------------------
626 //---------------------------------------------------------------------------
627
628 #define DEC_PYCALLBACK__STRING(CBNAME) \
629 void CBNAME(const wxString& a); \
630 void base_##CBNAME(const wxString& a);
631
632
633 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
634 void CLASS::CBNAME(const wxString& a) { \
635 bool doSave = wxPyRestoreThread(); \
636 if (m_myInst.findCallback(#CBNAME)) \
637 m_myInst.callCallback(Py_BuildValue("(s)", a.c_str())); \
638 else \
639 PCLASS::CBNAME(a); \
640 wxPySaveThread(doSave); \
641 } \
642 void CLASS::base_##CBNAME(const wxString& a) { \
643 PCLASS::CBNAME(a); \
644 }
645
646 //---------------------------------------------------------------------------
647
648 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
649 bool CBNAME(const wxString& a); \
650 bool base_##CBNAME(const wxString& a);
651
652
653 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
654 bool CLASS::CBNAME(const wxString& a) { \
655 bool rval; \
656 bool doSave = wxPyRestoreThread(); \
657 if (m_myInst.findCallback(#CBNAME)) \
658 rval = m_myInst.callCallback(Py_BuildValue("(s)", a.c_str())); \
659 else \
660 rval = PCLASS::CBNAME(a); \
661 wxPySaveThread(doSave); \
662 return rval; \
663 } \
664 bool CLASS::base_##CBNAME(const wxString& a) { \
665 return PCLASS::CBNAME(a); \
666 }
667
668 //---------------------------------------------------------------------------
669
670 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
671 bool CBNAME(const wxString& a, const wxString& b); \
672 bool base_##CBNAME(const wxString& a, const wxString& b);
673
674
675 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
676 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
677 bool rval; \
678 bool doSave = wxPyRestoreThread(); \
679 if (m_myInst.findCallback(#CBNAME)) \
680 rval = m_myInst.callCallback(Py_BuildValue("(ss)", \
681 a.c_str(), b.c_str())); \
682 else \
683 rval = PCLASS::CBNAME(a, b); \
684 wxPySaveThread(doSave); \
685 return rval; \
686 } \
687 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
688 return PCLASS::CBNAME(a, b); \
689 }
690
691 //---------------------------------------------------------------------------
692
693 #define DEC_PYCALLBACK_STRING_(CBNAME) \
694 wxString CBNAME(); \
695 wxString base_##CBNAME();
696
697
698 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
699 wxString CLASS::CBNAME() { \
700 wxString rval; \
701 bool doSave = wxPyRestoreThread(); \
702 if (m_myInst.findCallback(#CBNAME)) { \
703 PyObject* ro; \
704 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
705 rval = PyString_AsString(PyObject_Str(ro)); \
706 } \
707 else \
708 rval = PCLASS::CBNAME(); \
709 wxPySaveThread(doSave); \
710 return rval; \
711 } \
712 wxString CLASS::base_##CBNAME() { \
713 return PCLASS::CBNAME(); \
714 }
715
716 //---------------------------------------------------------------------------
717
718 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
719 wxString CBNAME();
720
721
722 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
723 wxString CLASS::CBNAME() { \
724 wxString rval; \
725 bool doSave = wxPyRestoreThread(); \
726 if (m_myInst.findCallback(#CBNAME)) { \
727 PyObject* ro; \
728 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
729 rval = PyString_AsString(PyObject_Str(ro)); \
730 } \
731 wxPySaveThread(doSave); \
732 return rval; \
733 }
734
735 //---------------------------------------------------------------------------
736
737 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
738 bool CBNAME(const wxHtmlTag& a); \
739
740
741 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
742 bool CLASS::CBNAME(const wxHtmlTag& a) { \
743 bool rval = false; \
744 bool doSave = wxPyRestoreThread(); \
745 if (m_myInst.findCallback(#CBNAME)) \
746 rval = m_myInst.callCallback(Py_BuildValue("(O)", \
747 wxPyConstructObject((void*)&a,"wxHtmlTag"))); \
748 wxPySaveThread(doSave); \
749 return rval; \
750 }
751
752 //---------------------------------------------------------------------------
753
754 #define DEC_PYCALLBACK___pure(CBNAME) \
755 void CBNAME(); \
756
757
758 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
759 void CLASS::CBNAME() { \
760 bool doSave = wxPyRestoreThread(); \
761 if (m_myInst.findCallback(#CBNAME)) \
762 m_myInst.callCallback(Py_BuildValue("()")); \
763 wxPySaveThread(doSave); \
764 }
765
766 //---------------------------------------------------------------------------
767
768 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
769 wxSize CBNAME(); \
770
771
772 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
773 wxSize CLASS::CBNAME() { \
774 wxSize rval(0,0); \
775 bool doSave = wxPyRestoreThread(); \
776 if (m_myInst.findCallback(#CBNAME)) { \
777 PyObject* ro; \
778 wxSize* ptr; \
779 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
780 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \
781 rval = *ptr; \
782 } \
783 wxPySaveThread(doSave); \
784 return rval; \
785 }
786
787 //---------------------------------------------------------------------------
788
789 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
790 bool CBNAME(wxWindow* a); \
791 bool base_##CBNAME(wxWindow* a);
792
793
794 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
795 bool CLASS::CBNAME(wxWindow* a) { \
796 bool rval; \
797 bool doSave = wxPyRestoreThread(); \
798 if (m_myInst.findCallback(#CBNAME)) \
799 rval = m_myInst.callCallback(Py_BuildValue("(O)", \
800 wxPyConstructObject((void*)a,"wxWindow"))); \
801 else \
802 rval = PCLASS::CBNAME(a); \
803 wxPySaveThread(doSave); \
804 return rval; \
805 } \
806 bool CLASS::base_##CBNAME(wxWindow* a) { \
807 return PCLASS::CBNAME(a); \
808 }
809
810 //---------------------------------------------------------------------------
811
812 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
813 bool CBNAME(); \
814 bool base_##CBNAME();
815
816
817 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
818 bool CLASS::CBNAME() { \
819 bool rval; \
820 bool doSave = wxPyRestoreThread(); \
821 if (m_myInst.findCallback(#CBNAME)) \
822 rval = m_myInst.callCallback(Py_BuildValue("()")); \
823 else \
824 rval = PCLASS::CBNAME(); \
825 wxPySaveThread(doSave); \
826 return rval; \
827 } \
828 bool CLASS::base_##CBNAME() { \
829 return PCLASS::CBNAME(); \
830 }
831
832 //---------------------------------------------------------------------------
833
834 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
835 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \
836 wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def);
837
838
839 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
840 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
841 bool doSave = wxPyRestoreThread(); \
842 int rval; \
843 if (m_myInst.findCallback(#CBNAME)) \
844 rval = m_myInst.callCallback(Py_BuildValue("(iii)", a,b,c));\
845 else \
846 rval = PCLASS::CBNAME(a, b, c); \
847 wxPySaveThread(doSave); \
848 return (wxDragResult)rval; \
849 } \
850 wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
851 return PCLASS::CBNAME(a, b, c); \
852 }
853
854 //---------------------------------------------------------------------------
855
856 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
857 bool CBNAME(wxDragResult a); \
858 bool base_##CBNAME(wxDragResult a);
859
860
861 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
862 bool CLASS::CBNAME(wxDragResult a) { \
863 bool doSave = wxPyRestoreThread(); \
864 bool rval; \
865 if (m_myInst.findCallback(#CBNAME)) \
866 rval = m_myInst.callCallback(Py_BuildValue("(i)", a)); \
867 else \
868 rval = PCLASS::CBNAME(a); \
869 wxPySaveThread(doSave); \
870 return rval; \
871 } \
872 bool CLASS::base_##CBNAME(wxDragResult a) { \
873 return PCLASS::CBNAME(a); \
874 }
875
876 //---------------------------------------------------------------------------
877
878 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
879 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def);
880
881
882 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
883 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
884 bool doSave = wxPyRestoreThread(); \
885 int rval; \
886 if (m_myInst.findCallback(#CBNAME)) \
887 rval = m_myInst.callCallback(Py_BuildValue("(iii)", a,b,c));\
888 wxPySaveThread(doSave); \
889 return (wxDragResult)rval; \
890 } \
891
892 //---------------------------------------------------------------------------
893
894 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
895 bool CBNAME(int a, int b, const wxString& c);
896
897
898 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
899 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
900 bool rval; \
901 bool doSave = wxPyRestoreThread(); \
902 if (m_myInst.findCallback(#CBNAME)) \
903 rval = m_myInst.callCallback(Py_BuildValue("(iis)",a,b,c.c_str()));\
904 wxPySaveThread(doSave); \
905 return rval; \
906 } \
907
908 //---------------------------------------------------------------------------
909
910 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
911 size_t CBNAME(); \
912 size_t base_##CBNAME();
913
914
915 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
916 size_t CLASS::CBNAME() { \
917 size_t rval; \
918 bool doSave = wxPyRestoreThread(); \
919 if (m_myInst.findCallback(#CBNAME)) \
920 rval = m_myInst.callCallback(Py_BuildValue("()")); \
921 else \
922 rval = PCLASS::CBNAME(); \
923 wxPySaveThread(doSave); \
924 return rval; \
925 } \
926 size_t CLASS::base_##CBNAME() { \
927 return PCLASS::CBNAME(); \
928 }
929
930 //---------------------------------------------------------------------------
931
932 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
933 wxDataFormat CBNAME(); \
934 wxDataFormat base_##CBNAME();
935
936
937 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
938 wxDataFormat CLASS::CBNAME(size_t a) { \
939 wxDataFormat rval; \
940 bool doSave = wxPyRestoreThread(); \
941 if (m_myInst.findCallback(#CBNAME)) { \
942 PyObject* ro; \
943 wxDataFormat* ptr; \
944 ro = m_myInst.callCallbackObj(Py_BuildValue("(i)", a)); \
945 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxDataFormat_p")) \
946 rval = *ptr; \
947 } \
948 else \
949 rval = PCLASS::CBNAME(a); \
950 wxPySaveThread(doSave); \
951 return rval; \
952 } \
953 wxDataFormat CLASS::base_##CBNAME(size_t a) { \
954 return PCLASS::CBNAME(a); \
955 }
956
957 //---------------------------------------------------------------------------
958 //---------------------------------------------------------------------------
959 //---------------------------------------------------------------------------
960
961 #endif
962
963
964
965