]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/helpers.h
Forgot to set OOR info on wxSplashScreen
[wxWidgets.git] / 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 typedef unsigned char byte;
22
23
24 class wxPyApp: public wxApp
25 {
26 public:
27 wxPyApp();
28 ~wxPyApp();
29 bool OnInit();
30 int MainLoop();
31 };
32
33 extern wxPyApp *wxPythonApp;
34
35 //----------------------------------------------------------------------
36
37 void __wxPreStart();
38 PyObject* __wxStart(PyObject*, PyObject* args);
39 void __wxCleanup();
40
41 //extern PyObject* wxPython_dict;
42 PyObject* __wxSetDictionary(PyObject*, PyObject* args);
43
44 void wxPyEventThunker(wxObject*, wxEvent& event);
45
46 PyObject* wxPyConstructObject(void* ptr,
47 const wxString& className,
48 int setThisOwn=0);
49 PyObject* wxPyConstructObject(void* ptr,
50 const wxString& className,
51 PyObject* klass,
52 int setThisOwn=0);
53
54 PyObject* wx2PyString(const wxString& src);
55 wxString Py2wxString(PyObject* source);
56
57 PyObject* wxPyClassExists(const wxString& className);
58 PyObject* wxPyMake_wxObject(wxObject* source, bool checkEvtHandler=TRUE);
59 PyObject* wxPyMake_wxSizer(wxSizer* source);
60 void wxPyPtrTypeMap_Add(const char* commonName, const char* ptrName);
61
62 PyObject* wxPy_ConvertList(wxListBase* list, const char* className);
63 long wxPyGetWinHandle(wxWindow* win);
64
65 //----------------------------------------------------------------------
66
67 // if we want to handle threads and Python threads are available...
68 #if defined(WXP_USE_THREAD) && defined(WITH_THREAD)
69 #define WXP_WITH_THREAD
70 #else // no Python threads...
71 #undef WXP_WITH_THREAD
72 #endif
73
74
75 // For Python --> C++
76 PyThreadState* wxPyBeginAllowThreads();
77 void wxPyEndAllowThreads(PyThreadState* state);
78
79 // For C++ --> Python
80 void wxPyBeginBlockThreads();
81 void wxPyEndBlockThreads();
82
83 //----------------------------------------------------------------------
84 // These are helpers used by the typemaps
85
86 wxString* wxString_in_helper(PyObject* source);
87
88 byte* byte_LIST_helper(PyObject* source);
89 int* int_LIST_helper(PyObject* source);
90 long* long_LIST_helper(PyObject* source);
91 char** string_LIST_helper(PyObject* source);
92 wxPoint* wxPoint_LIST_helper(PyObject* source, int* npoints);
93 wxBitmap** wxBitmap_LIST_helper(PyObject* source);
94 wxString* wxString_LIST_helper(PyObject* source);
95 wxAcceleratorEntry* wxAcceleratorEntry_LIST_helper(PyObject* source);
96 wxPen** wxPen_LIST_helper(PyObject* source);
97
98 bool wxSize_helper(PyObject* source, wxSize** obj);
99 bool wxPoint_helper(PyObject* source, wxPoint** obj);
100 bool wxRealPoint_helper(PyObject* source, wxRealPoint** obj);
101 bool wxRect_helper(PyObject* source, wxRect** obj);
102 bool wxColour_helper(PyObject* source, wxColour** obj);
103
104 #if PYTHON_API_VERSION < 1009
105 #define PySequence_Fast_GET_ITEM(o, i) \
106 (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i))
107 #endif
108
109 bool _2int_seq_helper(PyObject* source, int* i1, int* i2);
110 bool _4int_seq_helper(PyObject* source, int* i1, int* i2, int* i3, int* i4);
111
112
113 PyObject* wxArrayString2PyList_helper(const wxArrayString& arr);
114 PyObject* wxArrayInt2PyList_helper(const wxArrayInt& arr);
115
116
117 #define RETURN_NONE() { Py_INCREF(Py_None); return Py_None; }
118 #define DECLARE_DEF_STRING(name) static wxString wxPy##name(wx##name)
119
120 //----------------------------------------------------------------------
121
122 #ifndef SWIGCODE
123 extern "C" void SWIG_MakePtr(char *, void *, char *);
124 extern "C" char *SWIG_GetPtr(char *, void **, char *);
125 extern "C" char *SWIG_GetPtrObj(PyObject *obj, void **ptr, char *type);
126 #endif
127
128
129 #ifdef _MSC_VER
130 # pragma warning(disable:4800)
131 # pragma warning(disable:4190)
132 #endif
133
134 //----------------------------------------------------------------------
135
136 class wxPyCallback : public wxObject {
137 DECLARE_ABSTRACT_CLASS(wxPyCallback);
138 public:
139 wxPyCallback(PyObject* func);
140 wxPyCallback(const wxPyCallback& other);
141 ~wxPyCallback();
142
143 void EventThunker(wxEvent& event);
144
145 PyObject* m_func;
146 };
147
148 //---------------------------------------------------------------------------
149
150 class wxPyTimer : public wxTimer {
151 public:
152 wxPyTimer(PyObject* callback);
153 ~wxPyTimer();
154
155 void Notify();
156
157 private:
158 PyObject* func;
159 };
160
161 //---------------------------------------------------------------------------
162 //---------------------------------------------------------------------------
163 // These Event classes can be derived from in Python and passed through the
164 // event system without loosing anything. They do this by keeping a reference
165 // to themselves and some special case handling in wxPyCallback::EventThunker.
166
167
168 class wxPyEvtSelfRef {
169 public:
170 wxPyEvtSelfRef();
171 ~wxPyEvtSelfRef();
172
173 void SetSelf(PyObject* self, bool clone=FALSE);
174 PyObject* GetSelf() const;
175
176 protected:
177 PyObject* m_self;
178 bool m_cloned;
179 };
180
181
182 class wxPyEvent : public wxEvent, public wxPyEvtSelfRef {
183 DECLARE_ABSTRACT_CLASS(wxPyEvent)
184 public:
185 wxPyEvent(int id=0);
186 wxPyEvent(const wxPyEvent& evt);
187 ~wxPyEvent();
188
189 virtual wxEvent* Clone() const { return new wxPyEvent(*this); }
190 };
191
192
193 class wxPyCommandEvent : public wxCommandEvent, public wxPyEvtSelfRef {
194 DECLARE_ABSTRACT_CLASS(wxPyCommandEvent)
195 public:
196 wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0);
197 wxPyCommandEvent(const wxPyCommandEvent& evt);
198 ~wxPyCommandEvent();
199
200 virtual wxEvent* Clone() const { return new wxPyCommandEvent(*this); }
201 };
202
203
204 //---------------------------------------------------------------------------
205 // Export a C API in a struct. Other modules will be able to load this from
206 // the wxc module and will then have safe access to these functions, even if
207 // in another shared library.
208
209 class wxPyCallbackHelper;
210
211 struct wxPyCoreAPI {
212
213 void (*p_SWIG_MakePtr)(char*, void*, char*);
214 char* (*p_SWIG_GetPtr)(char*, void**, char*);
215 char* (*p_SWIG_GetPtrObj)(PyObject*, void**, char*);
216 void (*p_SWIG_RegisterMapping)(char*, char*, void *(*cast)(void *));
217 void (*p_SWIG_addvarlink)(PyObject*, char*, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p));
218 PyObject* (*p_SWIG_newvarlink)(void);
219
220 PyThreadState* (*p_wxPyBeginAllowThreads)();
221 void (*p_wxPyEndAllowThreads)(PyThreadState* state);
222 void (*p_wxPyBeginBlockThreads)();
223 void (*p_wxPyEndBlockThreads)();
224
225 PyObject* (*p_wxPyConstructObject)(void *, const wxString&, int);
226 PyObject* (*p_wxPy_ConvertList)(wxListBase* list, const char* className);
227
228 wxString* (*p_wxString_in_helper)(PyObject* source);
229 wxString (*p_Py2wxString)(PyObject* source);
230 PyObject* (*p_wx2PyString)(const wxString& src);
231
232 byte* (*p_byte_LIST_helper)(PyObject* source);
233 int* (*p_int_LIST_helper)(PyObject* source);
234 long* (*p_long_LIST_helper)(PyObject* source);
235 char** (*p_string_LIST_helper)(PyObject* source);
236 wxPoint* (*p_wxPoint_LIST_helper)(PyObject* source, int* npoints);
237 wxBitmap** (*p_wxBitmap_LIST_helper)(PyObject* source);
238 wxString* (*p_wxString_LIST_helper)(PyObject* source);
239 wxAcceleratorEntry* (*p_wxAcceleratorEntry_LIST_helper)(PyObject* source);
240
241 bool (*p_wxSize_helper)(PyObject* source, wxSize** obj);
242 bool (*p_wxPoint_helper)(PyObject* source, wxPoint** obj);
243 bool (*p_wxRealPoint_helper)(PyObject* source, wxRealPoint** obj);
244 bool (*p_wxRect_helper)(PyObject* source, wxRect** obj);
245 bool (*p_wxColour_helper)(PyObject* source, wxColour** obj);
246
247 void (*p_wxPyCBH_setCallbackInfo)(wxPyCallbackHelper& cbh, PyObject* self, PyObject* klass, int incref);
248 bool (*p_wxPyCBH_findCallback)(const wxPyCallbackHelper& cbh, const char* name);
249 int (*p_wxPyCBH_callCallback)(const wxPyCallbackHelper& cbh, PyObject* argTuple);
250 PyObject* (*p_wxPyCBH_callCallbackObj)(const wxPyCallbackHelper& cbh, PyObject* argTuple);
251 void (*p_wxPyCBH_delete)(wxPyCallbackHelper* cbh);
252
253 PyObject* (*p_wxPyClassExists)(const wxString& className);
254 PyObject* (*p_wxPyMake_wxObject)(wxObject* source, bool checkEvtHandler);
255 PyObject* (*p_wxPyMake_wxSizer)(wxSizer* source);
256 void (*p_wxPyPtrTypeMap_Add)(const char* commonName, const char* ptrName);
257 PyObject* (*p_wxArrayString2PyList_helper)(const wxArrayString& arr);
258 PyObject* (*p_wxArrayInt2PyList_helper)(const wxArrayInt& arr);
259 };
260
261 #ifdef wxPyUSE_EXPORT
262 static wxPyCoreAPI* wxPyCoreAPIPtr = NULL; // Each module needs one, but may not use it.
263 #endif
264
265 //---------------------------------------------------------------------------
266 // This class holds an instance of a Python Shadow Class object and assists
267 // with looking up and invoking Python callback methods from C++ virtual
268 // method redirections. For all classes which have virtuals which should be
269 // overridable in wxPython, a new subclass is created that contains a
270 // wxPyCallbackHelper.
271 //
272
273 class wxPyCallbackHelper {
274 public:
275 wxPyCallbackHelper(const wxPyCallbackHelper& other);
276
277 wxPyCallbackHelper() {
278 m_class = NULL;
279 m_self = NULL;
280 m_lastFound = NULL;
281 m_incRef = FALSE;
282 }
283
284 ~wxPyCallbackHelper() {
285 #ifdef wxPyUSE_EXPORT
286 wxPyCoreAPIPtr->p_wxPyCBH_delete(this);
287 #else
288 wxPyCBH_delete(this);
289 #endif
290 }
291
292 void setSelf(PyObject* self, PyObject* klass, int incref=TRUE);
293 bool findCallback(const char* name) const;
294 int callCallback(PyObject* argTuple) const;
295 PyObject* callCallbackObj(PyObject* argTuple) const;
296
297 private:
298 PyObject* m_self;
299 PyObject* m_class;
300 PyObject* m_lastFound;
301 int m_incRef;
302
303 friend void wxPyCBH_delete(wxPyCallbackHelper* cbh);
304 };
305
306
307 void wxPyCBH_setCallbackInfo(wxPyCallbackHelper& cbh, PyObject* self, PyObject* klass, int incref);
308 bool wxPyCBH_findCallback(const wxPyCallbackHelper& cbh, const char* name);
309 int wxPyCBH_callCallback(const wxPyCallbackHelper& cbh, PyObject* argTuple);
310 PyObject* wxPyCBH_callCallbackObj(const wxPyCallbackHelper& cbh, PyObject* argTuple);
311 void wxPyCBH_delete(wxPyCallbackHelper* cbh);
312
313
314
315 //----------------------------------------------------------------------
316
317 class wxPyUserData : public wxObject {
318 public:
319 wxPyUserData(PyObject* obj) {
320 m_obj = obj;
321 Py_INCREF(m_obj);
322 }
323
324 ~wxPyUserData() {
325 #ifdef wxPyUSE_EXPORT
326 wxPyCoreAPIPtr->p_wxPyBeginBlockThreads();
327 Py_DECREF(m_obj);
328 wxPyCoreAPIPtr->p_wxPyEndBlockThreads();
329 #else
330 wxPyBeginBlockThreads();
331 Py_DECREF(m_obj);
332 wxPyEndBlockThreads();
333 #endif
334 }
335 PyObject* m_obj;
336 };
337
338
339
340 class wxPyClientData : public wxClientData {
341 public:
342 wxPyClientData(PyObject* obj) {
343 m_obj = obj;
344 Py_INCREF(m_obj);
345 }
346
347 ~wxPyClientData() {
348 #ifdef wxPyUSE_EXPORT
349 wxPyCoreAPIPtr->p_wxPyBeginBlockThreads();
350 Py_DECREF(m_obj);
351 wxPyCoreAPIPtr->p_wxPyEndBlockThreads();
352 #else
353 wxPyBeginBlockThreads();
354 Py_DECREF(m_obj);
355 wxPyEndBlockThreads();
356 #endif
357 }
358 PyObject* m_obj;
359 };
360
361
362
363 //---------------------------------------------------------------------------
364 // These macros are used to implement the virtual methods that should
365 // redirect to a Python method if one exists. The names designate the
366 // return type, if any, as well as any parameter types.
367 //---------------------------------------------------------------------------
368
369 #define PYPRIVATE \
370 void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \
371 wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \
372 } \
373 private: wxPyCallbackHelper m_myInst
374
375 //---------------------------------------------------------------------------
376
377 #define DEC_PYCALLBACK__(CBNAME) \
378 void CBNAME(); \
379 void base_##CBNAME();
380
381
382 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
383 void CLASS::CBNAME() { \
384 bool found; \
385 wxPyBeginBlockThreads(); \
386 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
387 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
388 wxPyEndBlockThreads(); \
389 if (! found) \
390 PCLASS::CBNAME(); \
391 } \
392 void CLASS::base_##CBNAME() { \
393 PCLASS::CBNAME(); \
394 }
395
396 //---------------------------------------------------------------------------
397
398 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
399 bool CBNAME(int a, int b); \
400 bool base_##CBNAME(int a, int b);
401
402
403 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
404 bool CLASS::CBNAME(int a, int b) { \
405 bool rval=FALSE, found; \
406 wxPyBeginBlockThreads(); \
407 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
408 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
409 wxPyEndBlockThreads(); \
410 if (! found) \
411 rval = PCLASS::CBNAME(a,b); \
412 return rval; \
413 } \
414 bool CLASS::base_##CBNAME(int a, int b) { \
415 return PCLASS::CBNAME(a,b); \
416 }
417
418 //---------------------------------------------------------------------------
419
420 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
421 void CBNAME(int a, int b); \
422 void base_##CBNAME(int a, int b);
423
424
425 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
426 void CLASS::CBNAME(int a, int b) { \
427 bool found; \
428 wxPyBeginBlockThreads(); \
429 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
430 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
431 wxPyEndBlockThreads(); \
432 if (! found) \
433 PCLASS::CBNAME(a,b); \
434 } \
435 void CLASS::base_##CBNAME(int a, int b) { \
436 PCLASS::CBNAME(a,b); \
437 }
438
439 //---------------------------------------------------------------------------
440
441 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
442 bool CBNAME(int a); \
443 bool base_##CBNAME(int a);
444
445
446 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
447 bool CLASS::CBNAME(int a) { \
448 bool rval=FALSE, found; \
449 wxPyBeginBlockThreads(); \
450 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
451 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
452 wxPyEndBlockThreads(); \
453 if (! found) \
454 rval = PCLASS::CBNAME(a); \
455 return rval; \
456 } \
457 bool CLASS::base_##CBNAME(int a) { \
458 return PCLASS::CBNAME(a); \
459 }
460
461 //---------------------------------------------------------------------------
462
463 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
464 bool CBNAME(int a);
465
466
467 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
468 bool CLASS::CBNAME(int a) { \
469 bool rval=FALSE; \
470 wxPyBeginBlockThreads(); \
471 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
472 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
473 else rval = FALSE; \
474 wxPyEndBlockThreads(); \
475 return rval; \
476 }
477
478
479 //---------------------------------------------------------------------------
480
481 #define DEC_PYCALLBACK__DC(CBNAME) \
482 void CBNAME(wxDC& a); \
483 void base_##CBNAME(wxDC& a);
484
485
486 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
487 void CLASS::CBNAME(wxDC& a) { \
488 bool found; \
489 wxPyBeginBlockThreads(); \
490 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
491 PyObject* obj = wxPyMake_wxObject(&a); \
492 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
493 Py_DECREF(obj); \
494 } \
495 wxPyEndBlockThreads(); \
496 if (! found) \
497 PCLASS::CBNAME(a); \
498 } \
499 void CLASS::base_##CBNAME(wxDC& a) { \
500 PCLASS::CBNAME(a); \
501 }
502
503
504
505 //---------------------------------------------------------------------------
506
507 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
508 void CBNAME(wxDC& a, bool b); \
509 void base_##CBNAME(wxDC& a, bool b);
510
511
512 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
513 void CLASS::CBNAME(wxDC& a, bool b) { \
514 bool found; \
515 wxPyBeginBlockThreads(); \
516 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
517 PyObject* obj = wxPyMake_wxObject(&a); \
518 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
519 Py_DECREF(obj); \
520 } \
521 wxPyEndBlockThreads(); \
522 if (! found) \
523 PCLASS::CBNAME(a, b); \
524 } \
525 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
526 PCLASS::CBNAME(a, b); \
527 }
528
529 //---------------------------------------------------------------------------
530
531 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
532 void CBNAME(wxDC& a, bool b); \
533 void base_##CBNAME(wxDC& a, bool b);
534
535
536 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
537 void CLASS::CBNAME(wxDC& a, bool b) { \
538 bool found; \
539 wxPyBeginBlockThreads(); \
540 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
541 PyObject* obj = wxPyMake_wxObject(&a); \
542 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
543 Py_DECREF(obj); \
544 } \
545 wxPyEndBlockThreads(); \
546 if (! found) \
547 PCLASS::CBNAME(a, b); \
548 } \
549 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
550 PCLASS::CBNAME(a, b); \
551 }
552
553 //---------------------------------------------------------------------------
554
555 #define DEC_PYCALLBACK__2DBL(CBNAME) \
556 void CBNAME(double a, double b); \
557 void base_##CBNAME(double a, double b);
558
559
560 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
561 void CLASS::CBNAME(double a, double b) { \
562 bool found; \
563 wxPyBeginBlockThreads(); \
564 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
565 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
566 wxPyEndBlockThreads(); \
567 if (! found) \
568 PCLASS::CBNAME(a, b); \
569 } \
570 void CLASS::base_##CBNAME(double a, double b) { \
571 PCLASS::CBNAME(a, b); \
572 }
573
574 //---------------------------------------------------------------------------
575
576 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
577 void CBNAME(double a, double b, int c, int d); \
578 void base_##CBNAME(double a, double b, int c, int d);
579
580
581 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
582 void CLASS::CBNAME(double a, double b, int c, int d) { \
583 bool found; \
584 wxPyBeginBlockThreads(); \
585 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
586 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
587 a,b,c,d)); \
588 wxPyEndBlockThreads(); \
589 if (! found) \
590 PCLASS::CBNAME(a, b, c, d); \
591 } \
592 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
593 PCLASS::CBNAME(a, b, c, d); \
594 }
595
596 //---------------------------------------------------------------------------
597
598 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
599 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
600 void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
601
602
603 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
604 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
605 bool found; \
606 wxPyBeginBlockThreads(); \
607 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
608 PyObject* obj = wxPyMake_wxObject(&a); \
609 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
610 Py_DECREF(obj); \
611 } \
612 wxPyEndBlockThreads(); \
613 if (! found) \
614 PCLASS::CBNAME(a, b, c, d, e, f); \
615 } \
616 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
617 PCLASS::CBNAME(a, b, c, d, e, f); \
618 }
619
620 //---------------------------------------------------------------------------
621
622 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
623 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
624 bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
625
626
627 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
628 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
629 bool found; \
630 wxPyBeginBlockThreads(); \
631 bool rval=FALSE; \
632 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
633 PyObject* obj = wxPyMake_wxObject(&a); \
634 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
635 Py_DECREF(obj); \
636 } \
637 wxPyEndBlockThreads(); \
638 if (! found) \
639 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
640 return rval; \
641 } \
642 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
643 return PCLASS::CBNAME(a, b, c, d, e, f); \
644 }
645
646 //---------------------------------------------------------------------------
647
648 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
649 void CBNAME(bool a, double b, double c, int d, int e); \
650 void base_##CBNAME(bool a, double b, double c, int d, int e);
651
652
653 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
654 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
655 bool found; \
656 wxPyBeginBlockThreads(); \
657 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
658 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
659 (int)a,b,c,d,e)); \
660 wxPyEndBlockThreads(); \
661 if (! found) \
662 PCLASS::CBNAME(a, b, c, d, e); \
663 } \
664 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
665 PCLASS::CBNAME(a, b, c, d, e); \
666 }
667
668 //---------------------------------------------------------------------------
669
670 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
671 void CBNAME(wxDC& a, double b, double c, double d, double e); \
672 void base_##CBNAME(wxDC& a, double b, double c, double d, double e);
673
674
675 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
676 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
677 bool found; \
678 wxPyBeginBlockThreads(); \
679 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
680 PyObject* obj = wxPyMake_wxObject(&a); \
681 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
682 Py_DECREF(obj); \
683 } \
684 wxPyEndBlockThreads(); \
685 if (! found) \
686 PCLASS::CBNAME(a, b, c, d, e); \
687 } \
688 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
689 PCLASS::CBNAME(a, b, c, d, e); \
690 }
691
692 //---------------------------------------------------------------------------
693
694 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
695 void CBNAME(wxDC& a, bool b); \
696 void base_##CBNAME(wxDC& a, bool b);
697
698
699 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
700 void CLASS::CBNAME(wxDC& a, bool b) { \
701 bool found; \
702 wxPyBeginBlockThreads(); \
703 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
704 PyObject* obj = wxPyMake_wxObject(&a); \
705 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
706 Py_DECREF(obj); \
707 } \
708 wxPyEndBlockThreads(); \
709 if (! found) \
710 PCLASS::CBNAME(a, b); \
711 } \
712 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
713 PCLASS::CBNAME(a, b); \
714 }
715
716 //---------------------------------------------------------------------------
717
718 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
719 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
720 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f);
721
722
723 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
724 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
725 int e, int f) { \
726 bool found; \
727 wxPyBeginBlockThreads(); \
728 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
729 PyObject* obj = wxPyMake_wxObject(a); \
730 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
731 Py_DECREF(obj); \
732 } \
733 wxPyEndBlockThreads(); \
734 if (! found) \
735 PCLASS::CBNAME(a, b, c, d, e, f); \
736 } \
737 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
738 int e, int f) { \
739 PCLASS::CBNAME(a, b, c, d, e, f); \
740 }
741
742 //---------------------------------------------------------------------------
743
744 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
745 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
746 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e);
747
748
749 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
750 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
751 bool found; \
752 wxPyBeginBlockThreads(); \
753 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
754 PyObject* obj = wxPyMake_wxObject(a); \
755 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
756 Py_DECREF(obj); \
757 } \
758 wxPyEndBlockThreads(); \
759 if (! found) \
760 PCLASS::CBNAME(a, b, c, d, e); \
761 } \
762 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
763 int d, int e) { \
764 PCLASS::CBNAME(a, b, c, d, e); \
765 }
766
767 //---------------------------------------------------------------------------
768
769 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
770 void CBNAME(double a, double b, int c); \
771 void base_##CBNAME(double a, double b, int c);
772
773
774 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
775 void CLASS::CBNAME(double a, double b, int c) { \
776 bool found; \
777 wxPyBeginBlockThreads(); \
778 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
779 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
780 wxPyEndBlockThreads(); \
781 if (! found) \
782 PCLASS::CBNAME(a, b, c); \
783 } \
784 void CLASS::base_##CBNAME(double a, double b, int c) { \
785 PCLASS::CBNAME(a, b, c); \
786 }
787
788 //---------------------------------------------------------------------------
789
790 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
791 void CBNAME(bool a, double b, double c, int d); \
792 void base_##CBNAME(bool a, double b, double c, int d);
793
794
795 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
796 void CLASS::CBNAME(bool a, double b, double c, int d) { \
797 bool found; \
798 wxPyBeginBlockThreads(); \
799 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
800 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\
801 wxPyEndBlockThreads(); \
802 if (! found) \
803 PCLASS::CBNAME(a, b, c, d); \
804 } \
805 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
806 PCLASS::CBNAME(a, b, c, d); \
807 }
808
809 //---------------------------------------------------------------------------
810 //---------------------------------------------------------------------------
811
812 #define DEC_PYCALLBACK__STRING(CBNAME) \
813 void CBNAME(const wxString& a); \
814 void base_##CBNAME(const wxString& a);
815
816 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
817 void CLASS::CBNAME(const wxString& a) { \
818 bool found; \
819 wxPyBeginBlockThreads(); \
820 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
821 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", wx2PyString(a))); \
822 wxPyEndBlockThreads(); \
823 if (! found) \
824 PCLASS::CBNAME(a); \
825 } \
826 void CLASS::base_##CBNAME(const wxString& a) { \
827 PCLASS::CBNAME(a); \
828 }
829
830 //---------------------------------------------------------------------------
831
832 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
833 bool CBNAME(const wxString& a); \
834 bool base_##CBNAME(const wxString& a);
835
836 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
837 bool CLASS::CBNAME(const wxString& a) { \
838 bool rval=FALSE; \
839 bool found; \
840 wxPyBeginBlockThreads(); \
841 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
842 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", wx2PyString(a)));\
843 wxPyEndBlockThreads(); \
844 if (! found) \
845 rval = PCLASS::CBNAME(a); \
846 return rval; \
847 } \
848 bool CLASS::base_##CBNAME(const wxString& a) { \
849 return PCLASS::CBNAME(a); \
850 }
851
852 //---------------------------------------------------------------------------
853
854 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
855 bool CBNAME(const wxString& a);
856
857 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
858 bool CLASS::CBNAME(const wxString& a) { \
859 bool rval=FALSE; \
860 wxPyBeginBlockThreads(); \
861 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
862 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", wx2PyString(a))); \
863 wxPyEndBlockThreads(); \
864 return rval; \
865 } \
866
867 //---------------------------------------------------------------------------
868
869 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
870 wxString CBNAME(const wxString& a); \
871
872 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
873 wxString CLASS::CBNAME(const wxString& a) { \
874 wxString rval; \
875 wxPyBeginBlockThreads(); \
876 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
877 PyObject* ro; \
878 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", wx2PyString(a)));\
879 if (ro) { \
880 rval = Py2wxString(ro); \
881 Py_DECREF(ro); \
882 } \
883 } \
884 wxPyEndBlockThreads(); \
885 return rval; \
886 } \
887
888 //---------------------------------------------------------------------------
889
890 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
891 wxString CBNAME(const wxString& a,int b); \
892
893 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
894 wxString CLASS::CBNAME(const wxString& a,int b) { \
895 wxString rval; \
896 wxPyBeginBlockThreads(); \
897 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
898 PyObject* ro; \
899 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oi)", wx2PyString(a),b)); \
900 if (ro) { \
901 rval = Py2wxString(ro); \
902 Py_DECREF(ro); \
903 } \
904 } \
905 wxPyEndBlockThreads(); \
906 return rval; \
907 } \
908
909 //---------------------------------------------------------------------------
910
911 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
912 bool CBNAME(const wxString& a, const wxString& b); \
913 bool base_##CBNAME(const wxString& a, const wxString& b);
914
915 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
916 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
917 bool rval=FALSE; \
918 bool found; \
919 wxPyBeginBlockThreads(); \
920 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
921 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", \
922 wx2PyString(a), wx2PyString(b))); \
923 wxPyEndBlockThreads(); \
924 if (! found) \
925 rval = PCLASS::CBNAME(a, b); \
926 return rval; \
927 } \
928 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
929 return PCLASS::CBNAME(a, b); \
930 }
931
932 //---------------------------------------------------------------------------
933
934 #define DEC_PYCALLBACK_STRING_(CBNAME) \
935 wxString CBNAME(); \
936 wxString base_##CBNAME();
937
938 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
939 wxString CLASS::CBNAME() { \
940 wxString rval; \
941 bool found; \
942 wxPyBeginBlockThreads(); \
943 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
944 PyObject* ro; \
945 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
946 if (ro) { \
947 rval = Py2wxString(ro); \
948 Py_DECREF(ro); \
949 } \
950 } \
951 wxPyEndBlockThreads(); \
952 if (! found) \
953 rval = PCLASS::CBNAME(); \
954 return rval; \
955 } \
956 wxString CLASS::base_##CBNAME() { \
957 return PCLASS::CBNAME(); \
958 }
959
960 //---------------------------------------------------------------------------
961
962 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
963 wxString CBNAME();
964
965 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
966 wxString CLASS::CBNAME() { \
967 wxString rval; \
968 wxPyBeginBlockThreads(); \
969 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
970 PyObject* ro; \
971 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
972 if (ro) { \
973 rval = Py2wxString(ro); \
974 Py_DECREF(ro); \
975 } \
976 } \
977 wxPyEndBlockThreads(); \
978 return rval; \
979 }
980
981 //---------------------------------------------------------------------------
982
983 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
984 bool CBNAME(const wxHtmlTag& a); \
985
986
987 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
988 bool CLASS::CBNAME(const wxHtmlTag& a) { \
989 bool rval=FALSE; \
990 wxPyBeginBlockThreads(); \
991 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
992 PyObject* obj = wxPyConstructObject((void*)&a, "wxHtmlTag", 0); \
993 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
994 Py_DECREF(obj); \
995 } \
996 wxPyEndBlockThreads(); \
997 return rval; \
998 }
999
1000 //---------------------------------------------------------------------------
1001
1002 #define DEC_PYCALLBACK__CELLINTINT(CBNAME) \
1003 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y); \
1004 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y);
1005
1006 #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \
1007 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1008 bool found; \
1009 wxPyBeginBlockThreads(); \
1010 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1011 PyObject* obj = wxPyConstructObject((void*)cell, "wxHtmlCell", 0); \
1012 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \
1013 Py_DECREF(obj); \
1014 } \
1015 wxPyEndBlockThreads(); \
1016 if (! found) \
1017 PCLASS::CBNAME(cell, x, y); \
1018 } \
1019 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1020 PCLASS::CBNAME(cell, x, y); \
1021 }
1022
1023
1024 //---------------------------------------------------------------------------
1025
1026 #define DEC_PYCALLBACK__CELLINTINTME(CBNAME) \
1027 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e); \
1028 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e);
1029
1030 #define IMP_PYCALLBACK__CELLINTINTME(CLASS, PCLASS, CBNAME) \
1031 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1032 bool found; \
1033 wxPyBeginBlockThreads(); \
1034 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1035 PyObject* obj = wxPyConstructObject((void*)cell, "wxHtmlCell", 0); \
1036 PyObject* o2 = wxPyConstructObject((void*)&e, "wxMouseEvent", 0); \
1037 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1038 Py_DECREF(obj); \
1039 Py_DECREF(o2); \
1040 } \
1041 wxPyEndBlockThreads(); \
1042 if (! found) \
1043 PCLASS::CBNAME(cell, x, y, e); \
1044 } \
1045 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1046 PCLASS::CBNAME(cell, x, y, e); \
1047 }
1048
1049
1050
1051 //---------------------------------------------------------------------------
1052
1053 #define DEC_PYCALLBACK___pure(CBNAME) \
1054 void CBNAME(); \
1055
1056
1057 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1058 void CLASS::CBNAME() { \
1059 wxPyBeginBlockThreads(); \
1060 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1061 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1062 wxPyEndBlockThreads(); \
1063 }
1064
1065 //---------------------------------------------------------------------------
1066
1067 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1068 wxSize CBNAME(); \
1069
1070
1071 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1072 wxSize CLASS::CBNAME() { \
1073 const char* errmsg = #CBNAME " should return a 2-tuple of integers or a wxSize object."; \
1074 wxSize rval(0,0); \
1075 wxPyBeginBlockThreads(); \
1076 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1077 PyObject* ro; \
1078 wxSize* ptr; \
1079 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1080 if (ro) { \
1081 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \
1082 rval = *ptr; \
1083 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
1084 PyObject* o1 = PySequence_GetItem(ro, 0); \
1085 PyObject* o2 = PySequence_GetItem(ro, 1); \
1086 if (PyNumber_Check(o1) && PyNumber_Check(o2)) \
1087 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
1088 else \
1089 PyErr_SetString(PyExc_TypeError, errmsg); \
1090 Py_DECREF(o1); \
1091 Py_DECREF(o2); \
1092 } \
1093 else { \
1094 PyErr_SetString(PyExc_TypeError, errmsg); \
1095 } \
1096 Py_DECREF(ro); \
1097 } \
1098 } \
1099 wxPyEndBlockThreads(); \
1100 return rval; \
1101 }
1102
1103 //---------------------------------------------------------------------------
1104
1105 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1106 bool CBNAME(wxWindow* a); \
1107 bool base_##CBNAME(wxWindow* a);
1108
1109
1110 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1111 bool CLASS::CBNAME(wxWindow* a) { \
1112 bool rval=FALSE; \
1113 bool found; \
1114 wxPyBeginBlockThreads(); \
1115 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1116 PyObject* obj = wxPyMake_wxObject(a); \
1117 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1118 Py_DECREF(obj); \
1119 } \
1120 wxPyEndBlockThreads(); \
1121 if (! found) \
1122 rval = PCLASS::CBNAME(a); \
1123 return rval; \
1124 } \
1125 bool CLASS::base_##CBNAME(wxWindow* a) { \
1126 return PCLASS::CBNAME(a); \
1127 }
1128
1129 //---------------------------------------------------------------------------
1130
1131 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1132 bool CBNAME(); \
1133 bool base_##CBNAME();
1134
1135
1136 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1137 bool CLASS::CBNAME() { \
1138 bool rval=FALSE; \
1139 bool found; \
1140 wxPyBeginBlockThreads(); \
1141 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1142 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1143 wxPyEndBlockThreads(); \
1144 if (! found) \
1145 rval = PCLASS::CBNAME(); \
1146 return rval; \
1147 } \
1148 bool CLASS::base_##CBNAME() { \
1149 return PCLASS::CBNAME(); \
1150 }
1151
1152 //---------------------------------------------------------------------------
1153
1154 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1155 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \
1156 wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def);
1157
1158
1159 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1160 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1161 int rval=0; \
1162 bool found; \
1163 wxPyBeginBlockThreads(); \
1164 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1165 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1166 wxPyEndBlockThreads(); \
1167 if (! found) \
1168 rval = PCLASS::CBNAME(a, b, c); \
1169 return (wxDragResult)rval; \
1170 } \
1171 wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1172 return PCLASS::CBNAME(a, b, c); \
1173 }
1174
1175 //---------------------------------------------------------------------------
1176
1177 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1178 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location); \
1179
1180 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1181 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1182 wxPyBeginBlockThreads(); \
1183 wxFSFile* rval=0; \
1184 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1185 PyObject* ro; \
1186 PyObject* obj = wxPyMake_wxObject(&a); \
1187 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)",\
1188 obj, wx2PyString(b))); \
1189 if (ro) { \
1190 SWIG_GetPtrObj(ro, (void **)&rval, "_wxFSFILE_p"); \
1191 Py_DECREF(ro); \
1192 } \
1193 Py_DECREF(obj); \
1194 } \
1195 wxPyEndBlockThreads(); \
1196 return rval; \
1197 };
1198
1199 //---------------------------------------------------------------------------
1200
1201 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1202 bool CBNAME(wxDragResult a); \
1203 bool base_##CBNAME(wxDragResult a);
1204
1205
1206 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1207 bool CLASS::CBNAME(wxDragResult a) { \
1208 bool rval=FALSE; \
1209 bool found; \
1210 wxPyBeginBlockThreads(); \
1211 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1212 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a));\
1213 wxPyEndBlockThreads(); \
1214 if (! found) \
1215 rval = PCLASS::CBNAME(a); \
1216 return rval; \
1217 } \
1218 bool CLASS::base_##CBNAME(wxDragResult a) { \
1219 return PCLASS::CBNAME(a); \
1220 }
1221
1222 //---------------------------------------------------------------------------
1223
1224 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1225 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def);
1226
1227
1228 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1229 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1230 wxPyBeginBlockThreads(); \
1231 int rval=0; \
1232 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1233 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1234 wxPyEndBlockThreads(); \
1235 return (wxDragResult)rval; \
1236 } \
1237
1238 //---------------------------------------------------------------------------
1239
1240 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1241 bool CBNAME(int a, int b, const wxString& c);
1242
1243 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1244 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1245 bool rval=FALSE; \
1246 wxPyBeginBlockThreads(); \
1247 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1248 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b, wx2PyString(c)));\
1249 wxPyEndBlockThreads(); \
1250 return rval; \
1251 } \
1252
1253 //---------------------------------------------------------------------------
1254
1255 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1256 size_t CBNAME(); \
1257 size_t base_##CBNAME();
1258
1259
1260 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1261 size_t CLASS::CBNAME() { \
1262 size_t rval=0; \
1263 bool found; \
1264 wxPyBeginBlockThreads(); \
1265 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1266 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1267 wxPyEndBlockThreads(); \
1268 if (! found) \
1269 rval = PCLASS::CBNAME(); \
1270 return rval; \
1271 } \
1272 size_t CLASS::base_##CBNAME() { \
1273 return PCLASS::CBNAME(); \
1274 }
1275
1276 //---------------------------------------------------------------------------
1277
1278 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1279 wxDataFormat CBNAME(size_t a); \
1280 wxDataFormat base_##CBNAME(size_t a);
1281
1282
1283 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1284 wxDataFormat CLASS::CBNAME(size_t a) { \
1285 wxDataFormat rval=0; \
1286 bool found; \
1287 wxPyBeginBlockThreads(); \
1288 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1289 PyObject* ro; \
1290 wxDataFormat* ptr; \
1291 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1292 if (ro) { \
1293 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxDataFormat_p")) \
1294 rval = *ptr; \
1295 Py_DECREF(ro); \
1296 } \
1297 } \
1298 wxPyEndBlockThreads(); \
1299 if (! found) \
1300 rval = PCLASS::CBNAME(a); \
1301 return rval; \
1302 } \
1303 wxDataFormat CLASS::base_##CBNAME(size_t a) { \
1304 return PCLASS::CBNAME(a); \
1305 }
1306
1307 //---------------------------------------------------------------------------
1308
1309 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1310 void CBNAME(const Type& a); \
1311 void base_##CBNAME(const Type& a);
1312
1313
1314 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1315 void CLASS::CBNAME(const Type& a) { \
1316 bool found; \
1317 wxPyBeginBlockThreads(); \
1318 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1319 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1320 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1321 Py_DECREF(obj); \
1322 } \
1323 wxPyEndBlockThreads(); \
1324 if (! found) \
1325 PCLASS::CBNAME(a); \
1326 } \
1327 void CLASS::base_##CBNAME(const Type& a) { \
1328 PCLASS::CBNAME(a); \
1329 }
1330
1331
1332 //---------------------------------------------------------------------------
1333
1334 #define DEC_PYCALLBACK__any(CBNAME, Type) \
1335 void CBNAME(Type& a); \
1336 void base_##CBNAME(Type& a);
1337
1338
1339 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1340 void CLASS::CBNAME(Type& a) { \
1341 bool found; \
1342 wxPyBeginBlockThreads(); \
1343 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1344 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1345 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1346 Py_DECREF(obj); \
1347 } \
1348 wxPyEndBlockThreads(); \
1349 if (! found) \
1350 PCLASS::CBNAME(a); \
1351 } \
1352 void CLASS::base_##CBNAME(Type& a) { \
1353 PCLASS::CBNAME(a); \
1354 }
1355
1356 //---------------------------------------------------------------------------
1357
1358 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1359 bool CBNAME(Type& a); \
1360 bool base_##CBNAME(Type& a);
1361
1362
1363 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
1364 bool CLASS::CBNAME(Type& a) { \
1365 bool rv=FALSE; \
1366 bool found; \
1367 wxPyBeginBlockThreads(); \
1368 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1369 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1370 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1371 Py_DECREF(obj); \
1372 } \
1373 wxPyEndBlockThreads(); \
1374 if (! found) \
1375 rv = PCLASS::CBNAME(a); \
1376 return rv; \
1377 } \
1378 bool CLASS::base_##CBNAME(Type& a) { \
1379 return PCLASS::CBNAME(a); \
1380 }
1381
1382 //---------------------------------------------------------------------------
1383
1384 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
1385 wxString CBNAME(long a, long b) const; \
1386 wxString base_##CBNAME(long a, long b)const ;
1387
1388 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
1389 wxString CLASS::CBNAME(long a, long b) const { \
1390 wxString rval; \
1391 bool found; \
1392 wxPyBeginBlockThreads(); \
1393 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1394 PyObject* ro; \
1395 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1396 if (ro) { \
1397 rval = Py2wxString(ro); \
1398 Py_DECREF(ro); \
1399 } \
1400 } \
1401 wxPyEndBlockThreads(); \
1402 if (! found) \
1403 rval = PCLASS::CBNAME(a,b); \
1404 return rval; \
1405 } \
1406 wxString CLASS::base_##CBNAME(long a, long b) const { \
1407 return PCLASS::CBNAME(a,b); \
1408 }
1409
1410 //---------------------------------------------------------------------------
1411
1412 #define DEC_PYCALLBACK_INT_LONG(CBNAME) \
1413 int CBNAME(long a) const; \
1414 int base_##CBNAME(long a)const ;
1415
1416
1417 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
1418 int CLASS::CBNAME(long a) const { \
1419 int rval=-1; \
1420 bool found; \
1421 wxPyBeginBlockThreads(); \
1422 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1423 PyObject* ro; \
1424 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1425 if (ro) { \
1426 rval = PyInt_AsLong(ro); \
1427 Py_DECREF(ro); \
1428 } \
1429 } \
1430 wxPyEndBlockThreads(); \
1431 if (! found) \
1432 rval = PCLASS::CBNAME(a); \
1433 return rval; \
1434 } \
1435 int CLASS::base_##CBNAME(long a) const { \
1436 return PCLASS::CBNAME(a); \
1437 }
1438
1439
1440 //---------------------------------------------------------------------------
1441
1442 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
1443 wxListItemAttr* CBNAME(long a) const; \
1444 wxListItemAttr* base_##CBNAME(long a);
1445
1446
1447 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
1448 wxListItemAttr *CLASS::CBNAME(long a) const { \
1449 wxListItemAttr *rval = NULL; \
1450 bool found; \
1451 wxPyBeginBlockThreads(); \
1452 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1453 PyObject* ro; \
1454 wxListItemAttr* ptr; \
1455 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1456 if (ro) { \
1457 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxListItemAttr_p")) \
1458 rval = ptr; \
1459 Py_DECREF(ro); \
1460 } \
1461 } \
1462 wxPyEndBlockThreads(); \
1463 if (! found) \
1464 rval = PCLASS::CBNAME(a); \
1465 return rval; \
1466 } \
1467 wxListItemAttr *CLASS::base_##CBNAME(long a) { \
1468 return PCLASS::CBNAME(a); \
1469 }
1470
1471 //---------------------------------------------------------------------------
1472
1473 #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
1474 bool CBNAME(wxMouseEvent& e); \
1475 bool base_##CBNAME(wxMouseEvent& e);
1476
1477 #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
1478 bool CLASS::CBNAME(wxMouseEvent& e) { \
1479 bool rval=FALSE; \
1480 bool found; \
1481 wxPyBeginBlockThreads(); \
1482 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1483 PyObject* ro; \
1484 PyObject* obj = wxPyConstructObject((void*)&e, "wxMouseEvent", 0); \
1485 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
1486 if (ro) { \
1487 rval = PyInt_AsLong(ro); \
1488 Py_DECREF(ro); \
1489 } \
1490 Py_DECREF(obj); \
1491 } \
1492 wxPyEndBlockThreads(); \
1493 if (! found) \
1494 return PCLASS::CBNAME(e); \
1495 return rval; \
1496 } \
1497 bool CLASS::base_##CBNAME(wxMouseEvent& e) { \
1498 return PCLASS::CBNAME(e); \
1499 }
1500
1501
1502 //---------------------------------------------------------------------------
1503
1504 #endif