]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/helpers.h
Updated note about wxSTC using wxPopupWindow
[wxWidgets.git] / wxPython / src / helpers.h
1 ////////////////////////////////////////////////////////////////////////////
2 // Name: helpers.h
3 // Purpose: Helper functions/classes for the wxPython extension 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 //----------------------------------------------------------------------
105 // Other helpful stuff
106
107 #if PYTHON_API_VERSION < 1009
108 #define PySequence_Fast_GET_ITEM(o, i) \
109 (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i))
110 #endif
111
112 bool _2int_seq_helper(PyObject* source, int* i1, int* i2);
113 bool _4int_seq_helper(PyObject* source, int* i1, int* i2, int* i3, int* i4);
114
115
116 PyObject* wxArrayString2PyList_helper(const wxArrayString& arr);
117 PyObject* wxArrayInt2PyList_helper(const wxArrayInt& arr);
118
119 #define RETURN_NONE() { Py_INCREF(Py_None); return Py_None; }
120 #define DECLARE_DEF_STRING(name) static const wxString wxPy##name(wx##name)
121 #define DECLARE_DEF_STRING2(name,val) static const wxString wxPy##name(val)
122
123 //----------------------------------------------------------------------
124
125 #ifndef SWIGCODE
126 extern "C" void SWIG_MakePtr(char *, void *, char *);
127 extern "C" char *SWIG_GetPtr(char *, void **, char *);
128 extern "C" char *SWIG_GetPtrObj(PyObject *obj, void **ptr, char *type);
129 #endif
130
131
132 #ifdef _MSC_VER
133 # pragma warning(disable:4800)
134 # pragma warning(disable:4190)
135 #endif
136
137 //----------------------------------------------------------------------
138
139 class wxPyCallback : public wxObject {
140 DECLARE_ABSTRACT_CLASS(wxPyCallback);
141 public:
142 wxPyCallback(PyObject* func);
143 wxPyCallback(const wxPyCallback& other);
144 ~wxPyCallback();
145
146 void EventThunker(wxEvent& event);
147
148 PyObject* m_func;
149 };
150
151 //---------------------------------------------------------------------------
152
153 class wxPyTimer : public wxTimer {
154 public:
155 wxPyTimer(PyObject* callback);
156 ~wxPyTimer();
157
158 void Notify();
159
160 private:
161 PyObject* func;
162 };
163
164 //---------------------------------------------------------------------------
165 //---------------------------------------------------------------------------
166 // These Event classes can be derived from in Python and passed through the
167 // event system without loosing anything. They do this by keeping a reference
168 // to themselves and some special case handling in wxPyCallback::EventThunker.
169
170
171 class wxPyEvtSelfRef {
172 public:
173 wxPyEvtSelfRef();
174 ~wxPyEvtSelfRef();
175
176 void SetSelf(PyObject* self, bool clone=FALSE);
177 PyObject* GetSelf() const;
178
179 protected:
180 PyObject* m_self;
181 bool m_cloned;
182 };
183
184
185 class wxPyEvent : public wxEvent, public wxPyEvtSelfRef {
186 DECLARE_ABSTRACT_CLASS(wxPyEvent)
187 public:
188 wxPyEvent(int id=0);
189 wxPyEvent(const wxPyEvent& evt);
190 ~wxPyEvent();
191
192 virtual wxEvent* Clone() const { return new wxPyEvent(*this); }
193 };
194
195
196 class wxPyCommandEvent : public wxCommandEvent, public wxPyEvtSelfRef {
197 DECLARE_ABSTRACT_CLASS(wxPyCommandEvent)
198 public:
199 wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0);
200 wxPyCommandEvent(const wxPyCommandEvent& evt);
201 ~wxPyCommandEvent();
202
203 virtual wxEvent* Clone() const { return new wxPyCommandEvent(*this); }
204 };
205
206
207
208 //----------------------------------------------------------------------
209 // Forward decalre a few things used in the exported API
210 class wxPyClientData;
211 class wxPyUserData;
212 class wxPyOORClientData;
213 class wxPyCBInputStream;
214
215 void wxPyClientData_dtor(wxPyClientData* self);
216 void wxPyUserData_dtor(wxPyUserData* self);
217 void wxPyOORClientData_dtor(wxPyOORClientData* self);
218 wxPyCBInputStream* wxPyCBInputStream_create(PyObject *py, bool block);
219
220
221 //---------------------------------------------------------------------------
222 // Export a C API in a struct. Other modules will be able to load this from
223 // the wxc module and will then have safe access to these functions, even if
224 // in another shared library.
225
226 class wxPyCallbackHelper;
227
228
229 // Make SunCC happy and make typedef's for these that are extern "C"
230 typedef void (*p_SWIG_MakePtr_t)(char*, void*, char*);
231 typedef char* (*p_SWIG_GetPtr_t)(char*, void**, char*);
232 typedef char* (*p_SWIG_GetPtrObj_t)(PyObject*, void**, char*);
233 typedef void (*p_SWIG_RegisterMapping_t)(char*, char*, void *(*cast)(void *));
234 typedef void (*p_SWIG_addvarlink_t)(PyObject*, char*, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p));
235 typedef PyObject* (*p_SWIG_newvarlink_t)(void);
236
237
238 struct wxPyCoreAPI {
239
240 p_SWIG_MakePtr_t p_SWIG_MakePtr;
241 p_SWIG_GetPtr_t p_SWIG_GetPtr;
242 p_SWIG_GetPtrObj_t p_SWIG_GetPtrObj;
243 p_SWIG_RegisterMapping_t p_SWIG_RegisterMapping;
244 p_SWIG_addvarlink_t p_SWIG_addvarlink;
245 p_SWIG_newvarlink_t p_SWIG_newvarlink;
246
247 PyThreadState* (*p_wxPyBeginAllowThreads)();
248 void (*p_wxPyEndAllowThreads)(PyThreadState* state);
249 void (*p_wxPyBeginBlockThreads)();
250 void (*p_wxPyEndBlockThreads)();
251
252 PyObject* (*p_wxPyConstructObject)(void *, const wxString&, int);
253 PyObject* (*p_wxPy_ConvertList)(wxListBase* list, const char* className);
254
255 wxString* (*p_wxString_in_helper)(PyObject* source);
256 wxString (*p_Py2wxString)(PyObject* source);
257 PyObject* (*p_wx2PyString)(const wxString& src);
258
259 byte* (*p_byte_LIST_helper)(PyObject* source);
260 int* (*p_int_LIST_helper)(PyObject* source);
261 long* (*p_long_LIST_helper)(PyObject* source);
262 char** (*p_string_LIST_helper)(PyObject* source);
263 wxPoint* (*p_wxPoint_LIST_helper)(PyObject* source, int* npoints);
264 wxBitmap** (*p_wxBitmap_LIST_helper)(PyObject* source);
265 wxString* (*p_wxString_LIST_helper)(PyObject* source);
266 wxAcceleratorEntry* (*p_wxAcceleratorEntry_LIST_helper)(PyObject* source);
267
268 bool (*p_wxSize_helper)(PyObject* source, wxSize** obj);
269 bool (*p_wxPoint_helper)(PyObject* source, wxPoint** obj);
270 bool (*p_wxRealPoint_helper)(PyObject* source, wxRealPoint** obj);
271 bool (*p_wxRect_helper)(PyObject* source, wxRect** obj);
272 bool (*p_wxColour_helper)(PyObject* source, wxColour** obj);
273
274 void (*p_wxPyCBH_setCallbackInfo)(wxPyCallbackHelper& cbh, PyObject* self, PyObject* klass, int incref);
275 bool (*p_wxPyCBH_findCallback)(const wxPyCallbackHelper& cbh, const char* name);
276 int (*p_wxPyCBH_callCallback)(const wxPyCallbackHelper& cbh, PyObject* argTuple);
277 PyObject* (*p_wxPyCBH_callCallbackObj)(const wxPyCallbackHelper& cbh, PyObject* argTuple);
278 void (*p_wxPyCBH_delete)(wxPyCallbackHelper* cbh);
279
280 PyObject* (*p_wxPyClassExists)(const wxString& className);
281 PyObject* (*p_wxPyMake_wxObject)(wxObject* source, bool checkEvtHandler);
282 PyObject* (*p_wxPyMake_wxSizer)(wxSizer* source);
283 void (*p_wxPyPtrTypeMap_Add)(const char* commonName, const char* ptrName);
284 PyObject* (*p_wxArrayString2PyList_helper)(const wxArrayString& arr);
285 PyObject* (*p_wxArrayInt2PyList_helper)(const wxArrayInt& arr);
286
287 void (*p_wxPyClientData_dtor)(wxPyClientData*);
288 void (*p_wxPyUserData_dtor)(wxPyUserData*);
289 void (*p_wxPyOORClientData_dtor)(wxPyOORClientData*);
290
291 wxPyCBInputStream* (*p_wxPyCBInputStream_create)(PyObject *py, bool block);
292
293 };
294
295 #ifdef wxPyUSE_EXPORT
296 // Notice that this is static, not extern. This is by design, each module
297 // needs one, but doesn't have to use it.
298 static wxPyCoreAPI* wxPyCoreAPIPtr = NULL;
299 #endif
300
301
302 //---------------------------------------------------------------------------
303
304
305 class wxPyUserData : public wxObject {
306 public:
307 wxPyUserData(PyObject* obj) {
308 m_obj = obj;
309 Py_INCREF(m_obj);
310 }
311
312 ~wxPyUserData() {
313 #ifdef wxPyUSE_EXPORT
314 wxPyCoreAPIPtr->p_wxPyUserData_dtor(this);
315 #else
316 wxPyUserData_dtor(this);
317 #endif
318 }
319 PyObject* m_obj;
320 };
321
322
323 class wxPyClientData : public wxClientData {
324 public:
325 wxPyClientData(PyObject* obj) {
326 m_obj = obj;
327 Py_INCREF(m_obj);
328 }
329
330 ~wxPyClientData() {
331 #ifdef wxPyUSE_EXPORT
332 wxPyCoreAPIPtr->p_wxPyClientData_dtor(this);
333 #else
334 wxPyClientData_dtor(this);
335 #endif
336 }
337 PyObject* m_obj;
338 };
339
340
341 class wxPyOORClientData : public wxPyClientData {
342 public:
343 wxPyOORClientData(PyObject* obj)
344 : wxPyClientData(obj) {}
345
346 ~wxPyOORClientData() {
347 #ifdef wxPyUSE_EXPORT
348 wxPyCoreAPIPtr->p_wxPyOORClientData_dtor(this);
349 #else
350 wxPyOORClientData_dtor(this);
351 #endif
352 }
353 };
354
355 //---------------------------------------------------------------------------
356 // This class holds an instance of a Python Shadow Class object and assists
357 // with looking up and invoking Python callback methods from C++ virtual
358 // method redirections. For all classes which have virtuals which should be
359 // overridable in wxPython, a new subclass is created that contains a
360 // wxPyCallbackHelper.
361 //
362
363 class wxPyCallbackHelper {
364 public:
365 wxPyCallbackHelper(const wxPyCallbackHelper& other);
366
367 wxPyCallbackHelper() {
368 m_class = NULL;
369 m_self = NULL;
370 m_lastFound = NULL;
371 m_incRef = FALSE;
372 }
373
374 ~wxPyCallbackHelper() {
375 #ifdef wxPyUSE_EXPORT
376 wxPyCoreAPIPtr->p_wxPyCBH_delete(this);
377 #else
378 wxPyCBH_delete(this);
379 #endif
380 }
381
382 void setSelf(PyObject* self, PyObject* klass, int incref=TRUE);
383 bool findCallback(const char* name) const;
384 int callCallback(PyObject* argTuple) const;
385 PyObject* callCallbackObj(PyObject* argTuple) const;
386
387 private:
388 PyObject* m_self;
389 PyObject* m_class;
390 PyObject* m_lastFound;
391 int m_incRef;
392
393 friend void wxPyCBH_delete(wxPyCallbackHelper* cbh);
394 };
395
396
397 void wxPyCBH_setCallbackInfo(wxPyCallbackHelper& cbh, PyObject* self, PyObject* klass, int incref);
398 bool wxPyCBH_findCallback(const wxPyCallbackHelper& cbh, const char* name);
399 int wxPyCBH_callCallback(const wxPyCallbackHelper& cbh, PyObject* argTuple);
400 PyObject* wxPyCBH_callCallbackObj(const wxPyCallbackHelper& cbh, PyObject* argTuple);
401 void wxPyCBH_delete(wxPyCallbackHelper* cbh);
402
403
404
405
406 //---------------------------------------------------------------------------
407 // These macros are used to implement the virtual methods that should
408 // redirect to a Python method if one exists. The names designate the
409 // return type, if any, as well as any parameter types.
410 //---------------------------------------------------------------------------
411
412 #define PYPRIVATE \
413 void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \
414 wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \
415 } \
416 private: wxPyCallbackHelper m_myInst
417
418 //---------------------------------------------------------------------------
419
420 #define DEC_PYCALLBACK__(CBNAME) \
421 void CBNAME(); \
422 void base_##CBNAME();
423
424
425 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
426 void CLASS::CBNAME() { \
427 bool found; \
428 wxPyBeginBlockThreads(); \
429 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
430 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
431 wxPyEndBlockThreads(); \
432 if (! found) \
433 PCLASS::CBNAME(); \
434 } \
435 void CLASS::base_##CBNAME() { \
436 PCLASS::CBNAME(); \
437 }
438
439 //---------------------------------------------------------------------------
440
441 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
442 bool CBNAME(int a, int b); \
443 bool base_##CBNAME(int a, int b);
444
445
446 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
447 bool CLASS::CBNAME(int a, int b) { \
448 bool rval=FALSE, found; \
449 wxPyBeginBlockThreads(); \
450 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
451 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
452 wxPyEndBlockThreads(); \
453 if (! found) \
454 rval = PCLASS::CBNAME(a,b); \
455 return rval; \
456 } \
457 bool CLASS::base_##CBNAME(int a, int b) { \
458 return PCLASS::CBNAME(a,b); \
459 }
460
461 //---------------------------------------------------------------------------
462
463 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
464 void CBNAME(int a, int b); \
465 void base_##CBNAME(int a, int b);
466
467
468 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
469 void CLASS::CBNAME(int a, int b) { \
470 bool found; \
471 wxPyBeginBlockThreads(); \
472 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
473 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
474 wxPyEndBlockThreads(); \
475 if (! found) \
476 PCLASS::CBNAME(a,b); \
477 } \
478 void CLASS::base_##CBNAME(int a, int b) { \
479 PCLASS::CBNAME(a,b); \
480 }
481
482 //---------------------------------------------------------------------------
483
484 #define DEC_PYCALLBACK_VOID_INT4(CBNAME) \
485 void CBNAME(int a, int b, int c, int d); \
486 void base_##CBNAME(int a, int b, int c, int d);
487
488
489 #define IMP_PYCALLBACK_VOID_INT4(CLASS, PCLASS, CBNAME) \
490 void CLASS::CBNAME(int a, int b, int c, int d) { \
491 bool found; \
492 wxPyBeginBlockThreads(); \
493 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
494 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiii)",a,b,c,d)); \
495 wxPyEndBlockThreads(); \
496 if (! found) \
497 PCLASS::CBNAME(a,b,c,d); \
498 } \
499 void CLASS::base_##CBNAME(int a, int b, int c, int d) { \
500 PCLASS::CBNAME(a,b,c,d); \
501 }
502
503 //---------------------------------------------------------------------------
504 #define DEC_PYCALLBACK_VOID_INT5(CBNAME) \
505 void CBNAME(int a, int b, int c, int d, int e); \
506 void base_##CBNAME(int a, int b, int c, int d, int e);
507
508
509 #define IMP_PYCALLBACK_VOID_INT5(CLASS, PCLASS, CBNAME) \
510 void CLASS::CBNAME(int a, int b, int c, int d, int e) { \
511 bool found; \
512 wxPyBeginBlockThreads(); \
513 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
514 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiiii)",a,b,c,d,e)); \
515 wxPyEndBlockThreads(); \
516 if (! found) \
517 PCLASS::CBNAME(a,b,c,d,e); \
518 } \
519 void CLASS::base_##CBNAME(int a, int b, int c, int d, int e) { \
520 PCLASS::CBNAME(a,b,c,d,e); \
521 }
522
523 //---------------------------------------------------------------------------
524
525 #define DEC_PYCALLBACK_VOID_INTPINTP_const(CBNAME) \
526 void CBNAME(int* a, int* b) const; \
527 void base_##CBNAME(int* a, int* b) const;
528
529
530 #define IMP_PYCALLBACK_VOID_INTPINTP_const(CLASS, PCLASS, CBNAME) \
531 void CLASS::CBNAME(int* a, int* b) const { \
532 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
533 bool found; \
534 wxPyBeginBlockThreads(); \
535 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
536 PyObject* ro; \
537 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
538 if (ro) { \
539 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
540 PyObject* o1 = PySequence_GetItem(ro, 0); \
541 PyObject* o2 = PySequence_GetItem(ro, 1); \
542 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
543 *a = PyInt_AsLong(o1); *b = PyInt_AsLong(o2); \
544 } \
545 else \
546 PyErr_SetString(PyExc_TypeError, errmsg); \
547 Py_DECREF(o1); \
548 Py_DECREF(o2); \
549 } \
550 else { \
551 PyErr_SetString(PyExc_TypeError, errmsg); \
552 } \
553 Py_DECREF(ro); \
554 } \
555 } \
556 wxPyEndBlockThreads(); \
557 if (! found) \
558 PCLASS::CBNAME(a,b); \
559 } \
560 void CLASS::base_##CBNAME(int* a, int* b) const { \
561 PCLASS::CBNAME(a,b); \
562 }
563
564
565 //---------------------------------------------------------------------------
566
567 #define DEC_PYCALLBACK_SIZE_const(CBNAME) \
568 wxSize CBNAME() const; \
569 wxSize base_##CBNAME() const;
570
571
572 #define IMP_PYCALLBACK_SIZE_const(CLASS, PCLASS, CBNAME) \
573 wxSize CLASS::CBNAME() const { \
574 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
575 bool found; wxSize rval(0,0); \
576 wxPyBeginBlockThreads(); \
577 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
578 PyObject* ro; \
579 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
580 if (ro) { \
581 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
582 PyObject* o1 = PySequence_GetItem(ro, 0); \
583 PyObject* o2 = PySequence_GetItem(ro, 1); \
584 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
585 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
586 } \
587 else \
588 PyErr_SetString(PyExc_TypeError, errmsg); \
589 Py_DECREF(o1); \
590 Py_DECREF(o2); \
591 } \
592 else { \
593 PyErr_SetString(PyExc_TypeError, errmsg); \
594 } \
595 Py_DECREF(ro); \
596 } \
597 } \
598 wxPyEndBlockThreads(); \
599 if (! found) \
600 return PCLASS::CBNAME(); \
601 else \
602 return rval; \
603 } \
604 wxSize CLASS::base_##CBNAME() const { \
605 return PCLASS::CBNAME(); \
606 }
607
608
609 //---------------------------------------------------------------------------
610
611 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
612 bool CBNAME(int a); \
613 bool base_##CBNAME(int a);
614
615
616 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
617 bool CLASS::CBNAME(int a) { \
618 bool rval=FALSE, found; \
619 wxPyBeginBlockThreads(); \
620 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
621 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
622 wxPyEndBlockThreads(); \
623 if (! found) \
624 rval = PCLASS::CBNAME(a); \
625 return rval; \
626 } \
627 bool CLASS::base_##CBNAME(int a) { \
628 return PCLASS::CBNAME(a); \
629 }
630
631 //---------------------------------------------------------------------------
632
633 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
634 bool CBNAME(int a);
635
636
637 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
638 bool CLASS::CBNAME(int a) { \
639 bool rval=FALSE; \
640 wxPyBeginBlockThreads(); \
641 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
642 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
643 else rval = FALSE; \
644 wxPyEndBlockThreads(); \
645 return rval; \
646 }
647
648
649 //---------------------------------------------------------------------------
650
651 #define DEC_PYCALLBACK__DC(CBNAME) \
652 void CBNAME(wxDC& a); \
653 void base_##CBNAME(wxDC& a);
654
655
656 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
657 void CLASS::CBNAME(wxDC& a) { \
658 bool found; \
659 wxPyBeginBlockThreads(); \
660 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
661 PyObject* obj = wxPyMake_wxObject(&a); \
662 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
663 Py_DECREF(obj); \
664 } \
665 wxPyEndBlockThreads(); \
666 if (! found) \
667 PCLASS::CBNAME(a); \
668 } \
669 void CLASS::base_##CBNAME(wxDC& a) { \
670 PCLASS::CBNAME(a); \
671 }
672
673
674
675 //---------------------------------------------------------------------------
676
677 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
678 void CBNAME(wxDC& a, bool b); \
679 void base_##CBNAME(wxDC& a, bool b);
680
681
682 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
683 void CLASS::CBNAME(wxDC& a, bool b) { \
684 bool found; \
685 wxPyBeginBlockThreads(); \
686 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
687 PyObject* obj = wxPyMake_wxObject(&a); \
688 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
689 Py_DECREF(obj); \
690 } \
691 wxPyEndBlockThreads(); \
692 if (! found) \
693 PCLASS::CBNAME(a, b); \
694 } \
695 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
696 PCLASS::CBNAME(a, b); \
697 }
698
699 //---------------------------------------------------------------------------
700
701 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
702 void CBNAME(wxDC& a, bool b); \
703 void base_##CBNAME(wxDC& a, bool b);
704
705
706 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
707 void CLASS::CBNAME(wxDC& a, bool b) { \
708 bool found; \
709 wxPyBeginBlockThreads(); \
710 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
711 PyObject* obj = wxPyMake_wxObject(&a); \
712 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
713 Py_DECREF(obj); \
714 } \
715 wxPyEndBlockThreads(); \
716 if (! found) \
717 PCLASS::CBNAME(a, b); \
718 } \
719 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
720 PCLASS::CBNAME(a, b); \
721 }
722
723 //---------------------------------------------------------------------------
724
725 #define DEC_PYCALLBACK__2DBL(CBNAME) \
726 void CBNAME(double a, double b); \
727 void base_##CBNAME(double a, double b);
728
729
730 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
731 void CLASS::CBNAME(double a, double b) { \
732 bool found; \
733 wxPyBeginBlockThreads(); \
734 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
735 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
736 wxPyEndBlockThreads(); \
737 if (! found) \
738 PCLASS::CBNAME(a, b); \
739 } \
740 void CLASS::base_##CBNAME(double a, double b) { \
741 PCLASS::CBNAME(a, b); \
742 }
743
744 //---------------------------------------------------------------------------
745
746 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
747 void CBNAME(double a, double b, int c, int d); \
748 void base_##CBNAME(double a, double b, int c, int d);
749
750
751 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
752 void CLASS::CBNAME(double a, double b, int c, int d) { \
753 bool found; \
754 wxPyBeginBlockThreads(); \
755 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
756 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
757 a,b,c,d)); \
758 wxPyEndBlockThreads(); \
759 if (! found) \
760 PCLASS::CBNAME(a, b, c, d); \
761 } \
762 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
763 PCLASS::CBNAME(a, b, c, d); \
764 }
765
766 //---------------------------------------------------------------------------
767
768 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
769 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
770 void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
771
772
773 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
774 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
775 bool found; \
776 wxPyBeginBlockThreads(); \
777 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
778 PyObject* obj = wxPyMake_wxObject(&a); \
779 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
780 Py_DECREF(obj); \
781 } \
782 wxPyEndBlockThreads(); \
783 if (! found) \
784 PCLASS::CBNAME(a, b, c, d, e, f); \
785 } \
786 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
787 PCLASS::CBNAME(a, b, c, d, e, f); \
788 }
789
790 //---------------------------------------------------------------------------
791
792 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
793 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
794 bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
795
796
797 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
798 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
799 bool found; \
800 wxPyBeginBlockThreads(); \
801 bool rval=FALSE; \
802 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
803 PyObject* obj = wxPyMake_wxObject(&a); \
804 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
805 Py_DECREF(obj); \
806 } \
807 wxPyEndBlockThreads(); \
808 if (! found) \
809 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
810 return rval; \
811 } \
812 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
813 return PCLASS::CBNAME(a, b, c, d, e, f); \
814 }
815
816 //---------------------------------------------------------------------------
817
818 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
819 void CBNAME(bool a, double b, double c, int d, int e); \
820 void base_##CBNAME(bool a, double b, double c, int d, int e);
821
822
823 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
824 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
825 bool found; \
826 wxPyBeginBlockThreads(); \
827 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
828 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
829 (int)a,b,c,d,e)); \
830 wxPyEndBlockThreads(); \
831 if (! found) \
832 PCLASS::CBNAME(a, b, c, d, e); \
833 } \
834 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
835 PCLASS::CBNAME(a, b, c, d, e); \
836 }
837
838 //---------------------------------------------------------------------------
839
840 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
841 void CBNAME(wxDC& a, double b, double c, double d, double e); \
842 void base_##CBNAME(wxDC& a, double b, double c, double d, double e);
843
844
845 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
846 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
847 bool found; \
848 wxPyBeginBlockThreads(); \
849 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
850 PyObject* obj = wxPyMake_wxObject(&a); \
851 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
852 Py_DECREF(obj); \
853 } \
854 wxPyEndBlockThreads(); \
855 if (! found) \
856 PCLASS::CBNAME(a, b, c, d, e); \
857 } \
858 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
859 PCLASS::CBNAME(a, b, c, d, e); \
860 }
861
862 //---------------------------------------------------------------------------
863
864 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
865 void CBNAME(wxDC& a, bool b); \
866 void base_##CBNAME(wxDC& a, bool b);
867
868
869 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
870 void CLASS::CBNAME(wxDC& a, bool b) { \
871 bool found; \
872 wxPyBeginBlockThreads(); \
873 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
874 PyObject* obj = wxPyMake_wxObject(&a); \
875 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
876 Py_DECREF(obj); \
877 } \
878 wxPyEndBlockThreads(); \
879 if (! found) \
880 PCLASS::CBNAME(a, b); \
881 } \
882 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
883 PCLASS::CBNAME(a, b); \
884 }
885
886 //---------------------------------------------------------------------------
887
888 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
889 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
890 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f);
891
892
893 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
894 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
895 int e, int f) { \
896 bool found; \
897 wxPyBeginBlockThreads(); \
898 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
899 PyObject* obj = wxPyMake_wxObject(a); \
900 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
901 Py_DECREF(obj); \
902 } \
903 wxPyEndBlockThreads(); \
904 if (! found) \
905 PCLASS::CBNAME(a, b, c, d, e, f); \
906 } \
907 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
908 int e, int f) { \
909 PCLASS::CBNAME(a, b, c, d, e, f); \
910 }
911
912 //---------------------------------------------------------------------------
913
914 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
915 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
916 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e);
917
918
919 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
920 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
921 bool found; \
922 wxPyBeginBlockThreads(); \
923 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
924 PyObject* obj = wxPyMake_wxObject(a); \
925 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
926 Py_DECREF(obj); \
927 } \
928 wxPyEndBlockThreads(); \
929 if (! found) \
930 PCLASS::CBNAME(a, b, c, d, e); \
931 } \
932 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
933 int d, int e) { \
934 PCLASS::CBNAME(a, b, c, d, e); \
935 }
936
937 //---------------------------------------------------------------------------
938
939 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
940 void CBNAME(double a, double b, int c); \
941 void base_##CBNAME(double a, double b, int c);
942
943
944 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
945 void CLASS::CBNAME(double a, double b, int c) { \
946 bool found; \
947 wxPyBeginBlockThreads(); \
948 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
949 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
950 wxPyEndBlockThreads(); \
951 if (! found) \
952 PCLASS::CBNAME(a, b, c); \
953 } \
954 void CLASS::base_##CBNAME(double a, double b, int c) { \
955 PCLASS::CBNAME(a, b, c); \
956 }
957
958 //---------------------------------------------------------------------------
959
960 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
961 void CBNAME(bool a, double b, double c, int d); \
962 void base_##CBNAME(bool a, double b, double c, int d);
963
964
965 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
966 void CLASS::CBNAME(bool a, double b, double c, int d) { \
967 bool found; \
968 wxPyBeginBlockThreads(); \
969 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
970 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\
971 wxPyEndBlockThreads(); \
972 if (! found) \
973 PCLASS::CBNAME(a, b, c, d); \
974 } \
975 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
976 PCLASS::CBNAME(a, b, c, d); \
977 }
978
979 //---------------------------------------------------------------------------
980 //---------------------------------------------------------------------------
981
982 #define DEC_PYCALLBACK__STRING(CBNAME) \
983 void CBNAME(const wxString& a); \
984 void base_##CBNAME(const wxString& a);
985
986 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
987 void CLASS::CBNAME(const wxString& a) { \
988 bool found; \
989 wxPyBeginBlockThreads(); \
990 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
991 PyObject* s = wx2PyString(a); \
992 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
993 Py_DECREF(s); \
994 } \
995 wxPyEndBlockThreads(); \
996 if (! found) \
997 PCLASS::CBNAME(a); \
998 } \
999 void CLASS::base_##CBNAME(const wxString& a) { \
1000 PCLASS::CBNAME(a); \
1001 }
1002
1003 //---------------------------------------------------------------------------
1004
1005 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
1006 bool CBNAME(const wxString& a); \
1007 bool base_##CBNAME(const wxString& a);
1008
1009 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
1010 bool CLASS::CBNAME(const wxString& a) { \
1011 bool rval=FALSE; \
1012 bool found; \
1013 wxPyBeginBlockThreads(); \
1014 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1015 PyObject* s = wx2PyString(a); \
1016 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1017 Py_DECREF(s); \
1018 } \
1019 wxPyEndBlockThreads(); \
1020 if (! found) \
1021 rval = PCLASS::CBNAME(a); \
1022 return rval; \
1023 } \
1024 bool CLASS::base_##CBNAME(const wxString& a) { \
1025 return PCLASS::CBNAME(a); \
1026 }
1027
1028 //---------------------------------------------------------------------------
1029
1030 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
1031 bool CBNAME(const wxString& a);
1032
1033 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
1034 bool CLASS::CBNAME(const wxString& a) { \
1035 bool rval=FALSE; \
1036 wxPyBeginBlockThreads(); \
1037 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1038 PyObject* s = wx2PyString(a); \
1039 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1040 Py_DECREF(s); \
1041 } \
1042 wxPyEndBlockThreads(); \
1043 return rval; \
1044 } \
1045
1046 //---------------------------------------------------------------------------
1047
1048 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
1049 wxString CBNAME(const wxString& a); \
1050
1051 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
1052 wxString CLASS::CBNAME(const wxString& a) { \
1053 wxString rval; \
1054 wxPyBeginBlockThreads(); \
1055 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1056 PyObject* ro; \
1057 PyObject* s = wx2PyString(a); \
1058 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1059 Py_DECREF(s); \
1060 if (ro) { \
1061 rval = Py2wxString(ro); \
1062 Py_DECREF(ro); \
1063 } \
1064 } \
1065 wxPyEndBlockThreads(); \
1066 return rval; \
1067 } \
1068
1069 //---------------------------------------------------------------------------
1070
1071 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
1072 wxString CBNAME(const wxString& a,int b); \
1073
1074 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
1075 wxString CLASS::CBNAME(const wxString& a,int b) { \
1076 wxString rval; \
1077 wxPyBeginBlockThreads(); \
1078 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1079 PyObject* ro; \
1080 PyObject* s = wx2PyString(a); \
1081 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oi)",s,b)); \
1082 Py_DECREF(s); \
1083 if (ro) { \
1084 rval = Py2wxString(ro); \
1085 Py_DECREF(ro); \
1086 } \
1087 } \
1088 wxPyEndBlockThreads(); \
1089 return rval; \
1090 } \
1091
1092 //---------------------------------------------------------------------------
1093
1094 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
1095 bool CBNAME(const wxString& a, const wxString& b); \
1096 bool base_##CBNAME(const wxString& a, const wxString& b);
1097
1098 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
1099 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
1100 bool rval=FALSE; \
1101 bool found; \
1102 wxPyBeginBlockThreads(); \
1103 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1104 PyObject* s1 = wx2PyString(a); \
1105 PyObject* s2 = wx2PyString(b); \
1106 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",s1,s2)); \
1107 Py_DECREF(s1); \
1108 Py_DECREF(s2); \
1109 } \
1110 wxPyEndBlockThreads(); \
1111 if (! found) \
1112 rval = PCLASS::CBNAME(a, b); \
1113 return rval; \
1114 } \
1115 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
1116 return PCLASS::CBNAME(a, b); \
1117 }
1118
1119 //---------------------------------------------------------------------------
1120
1121 #define DEC_PYCALLBACK_STRING_(CBNAME) \
1122 wxString CBNAME(); \
1123 wxString base_##CBNAME();
1124
1125 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
1126 wxString CLASS::CBNAME() { \
1127 wxString rval; \
1128 bool found; \
1129 wxPyBeginBlockThreads(); \
1130 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1131 PyObject* ro; \
1132 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1133 if (ro) { \
1134 rval = Py2wxString(ro); \
1135 Py_DECREF(ro); \
1136 } \
1137 } \
1138 wxPyEndBlockThreads(); \
1139 if (! found) \
1140 rval = PCLASS::CBNAME(); \
1141 return rval; \
1142 } \
1143 wxString CLASS::base_##CBNAME() { \
1144 return PCLASS::CBNAME(); \
1145 }
1146
1147 //---------------------------------------------------------------------------
1148
1149 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
1150 wxString CBNAME();
1151
1152 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
1153 wxString CLASS::CBNAME() { \
1154 wxString rval; \
1155 wxPyBeginBlockThreads(); \
1156 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1157 PyObject* ro; \
1158 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1159 if (ro) { \
1160 rval = Py2wxString(ro); \
1161 Py_DECREF(ro); \
1162 } \
1163 } \
1164 wxPyEndBlockThreads(); \
1165 return rval; \
1166 }
1167
1168 //---------------------------------------------------------------------------
1169
1170 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
1171 bool CBNAME(const wxHtmlTag& a); \
1172
1173
1174 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
1175 bool CLASS::CBNAME(const wxHtmlTag& a) { \
1176 bool rval=FALSE; \
1177 wxPyBeginBlockThreads(); \
1178 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1179 PyObject* obj = wxPyConstructObject((void*)&a, "wxHtmlTag", 0); \
1180 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1181 Py_DECREF(obj); \
1182 } \
1183 wxPyEndBlockThreads(); \
1184 return rval; \
1185 }
1186
1187 //---------------------------------------------------------------------------
1188
1189 #define DEC_PYCALLBACK__CELLINTINT(CBNAME) \
1190 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y); \
1191 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y);
1192
1193 #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \
1194 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1195 bool found; \
1196 wxPyBeginBlockThreads(); \
1197 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1198 PyObject* obj = wxPyConstructObject((void*)cell, "wxHtmlCell", 0); \
1199 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \
1200 Py_DECREF(obj); \
1201 } \
1202 wxPyEndBlockThreads(); \
1203 if (! found) \
1204 PCLASS::CBNAME(cell, x, y); \
1205 } \
1206 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1207 PCLASS::CBNAME(cell, x, y); \
1208 }
1209
1210
1211 //---------------------------------------------------------------------------
1212
1213 #define DEC_PYCALLBACK__CELLINTINTME(CBNAME) \
1214 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e); \
1215 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e);
1216
1217 #define IMP_PYCALLBACK__CELLINTINTME(CLASS, PCLASS, CBNAME) \
1218 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1219 bool found; \
1220 wxPyBeginBlockThreads(); \
1221 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1222 PyObject* obj = wxPyConstructObject((void*)cell, "wxHtmlCell", 0); \
1223 PyObject* o2 = wxPyConstructObject((void*)&e, "wxMouseEvent", 0); \
1224 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1225 Py_DECREF(obj); \
1226 Py_DECREF(o2); \
1227 } \
1228 wxPyEndBlockThreads(); \
1229 if (! found) \
1230 PCLASS::CBNAME(cell, x, y, e); \
1231 } \
1232 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1233 PCLASS::CBNAME(cell, x, y, e); \
1234 }
1235
1236
1237
1238 //---------------------------------------------------------------------------
1239
1240 #define DEC_PYCALLBACK___pure(CBNAME) \
1241 void CBNAME(); \
1242
1243
1244 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1245 void CLASS::CBNAME() { \
1246 wxPyBeginBlockThreads(); \
1247 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1248 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1249 wxPyEndBlockThreads(); \
1250 }
1251
1252 //---------------------------------------------------------------------------
1253
1254 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1255 wxSize CBNAME(); \
1256
1257
1258 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1259 wxSize CLASS::CBNAME() { \
1260 const char* errmsg = #CBNAME " should return a 2-tuple of integers or a wxSize object."; \
1261 wxSize rval(0,0); \
1262 wxPyBeginBlockThreads(); \
1263 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1264 PyObject* ro; \
1265 wxSize* ptr; \
1266 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1267 if (ro) { \
1268 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \
1269 rval = *ptr; \
1270 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
1271 PyObject* o1 = PySequence_GetItem(ro, 0); \
1272 PyObject* o2 = PySequence_GetItem(ro, 1); \
1273 if (PyNumber_Check(o1) && PyNumber_Check(o2)) \
1274 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
1275 else \
1276 PyErr_SetString(PyExc_TypeError, errmsg); \
1277 Py_DECREF(o1); \
1278 Py_DECREF(o2); \
1279 } \
1280 else { \
1281 PyErr_SetString(PyExc_TypeError, errmsg); \
1282 } \
1283 Py_DECREF(ro); \
1284 } \
1285 } \
1286 wxPyEndBlockThreads(); \
1287 return rval; \
1288 }
1289
1290 //---------------------------------------------------------------------------
1291
1292 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1293 bool CBNAME(wxWindow* a); \
1294 bool base_##CBNAME(wxWindow* a);
1295
1296
1297 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1298 bool CLASS::CBNAME(wxWindow* a) { \
1299 bool rval=FALSE; \
1300 bool found; \
1301 wxPyBeginBlockThreads(); \
1302 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1303 PyObject* obj = wxPyMake_wxObject(a); \
1304 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1305 Py_DECREF(obj); \
1306 } \
1307 wxPyEndBlockThreads(); \
1308 if (! found) \
1309 rval = PCLASS::CBNAME(a); \
1310 return rval; \
1311 } \
1312 bool CLASS::base_##CBNAME(wxWindow* a) { \
1313 return PCLASS::CBNAME(a); \
1314 }
1315
1316 //---------------------------------------------------------------------------
1317
1318 #define DEC_PYCALLBACK_VOID_WXWINBASE(CBNAME) \
1319 void CBNAME(wxWindowBase* a); \
1320 void base_##CBNAME(wxWindowBase* a);
1321
1322
1323 #define IMP_PYCALLBACK_VOID_WXWINBASE(CLASS, PCLASS, CBNAME) \
1324 void CLASS::CBNAME(wxWindowBase* a) { \
1325 bool found; \
1326 wxPyBeginBlockThreads(); \
1327 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1328 PyObject* obj = wxPyMake_wxObject(a); \
1329 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1330 Py_DECREF(obj); \
1331 } \
1332 wxPyEndBlockThreads(); \
1333 if (! found) \
1334 PCLASS::CBNAME(a); \
1335 } \
1336 void CLASS::base_##CBNAME(wxWindowBase* a) { \
1337 PCLASS::CBNAME(a); \
1338 }
1339
1340 //---------------------------------------------------------------------------
1341
1342 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1343 bool CBNAME(); \
1344 bool base_##CBNAME();
1345
1346
1347 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1348 bool CLASS::CBNAME() { \
1349 bool rval=FALSE; \
1350 bool found; \
1351 wxPyBeginBlockThreads(); \
1352 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1353 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1354 wxPyEndBlockThreads(); \
1355 if (! found) \
1356 rval = PCLASS::CBNAME(); \
1357 return rval; \
1358 } \
1359 bool CLASS::base_##CBNAME() { \
1360 return PCLASS::CBNAME(); \
1361 }
1362
1363 //---------------------------------------------------------------------------
1364
1365 #define DEC_PYCALLBACK_BOOL_const(CBNAME) \
1366 bool CBNAME() const; \
1367 bool base_##CBNAME() const;
1368
1369
1370 #define IMP_PYCALLBACK_BOOL_const(CLASS, PCLASS, CBNAME) \
1371 bool CLASS::CBNAME() const { \
1372 bool rval=FALSE; \
1373 bool found; \
1374 wxPyBeginBlockThreads(); \
1375 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1376 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1377 wxPyEndBlockThreads(); \
1378 if (! found) \
1379 rval = PCLASS::CBNAME(); \
1380 return rval; \
1381 } \
1382 bool CLASS::base_##CBNAME() const { \
1383 return PCLASS::CBNAME(); \
1384 }
1385
1386 //---------------------------------------------------------------------------
1387
1388 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1389 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \
1390 wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def);
1391
1392
1393 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1394 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1395 int rval=0; \
1396 bool found; \
1397 wxPyBeginBlockThreads(); \
1398 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1399 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1400 wxPyEndBlockThreads(); \
1401 if (! found) \
1402 rval = PCLASS::CBNAME(a, b, c); \
1403 return (wxDragResult)rval; \
1404 } \
1405 wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1406 return PCLASS::CBNAME(a, b, c); \
1407 }
1408
1409 //---------------------------------------------------------------------------
1410
1411 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1412 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location); \
1413
1414 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1415 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1416 wxPyBeginBlockThreads(); \
1417 wxFSFile* rval=0; \
1418 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1419 PyObject* ro; \
1420 PyObject* obj = wxPyMake_wxObject(&a); \
1421 PyObject* s = wx2PyString(b); \
1422 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)",\
1423 obj, s)); \
1424 if (ro) { \
1425 SWIG_GetPtrObj(ro, (void **)&rval, "_wxFSFILE_p"); \
1426 Py_DECREF(ro); \
1427 } \
1428 Py_DECREF(obj); \
1429 Py_DECREF(s); \
1430 } \
1431 wxPyEndBlockThreads(); \
1432 return rval; \
1433 };
1434
1435 //---------------------------------------------------------------------------
1436
1437 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1438 bool CBNAME(wxDragResult a); \
1439 bool base_##CBNAME(wxDragResult a);
1440
1441
1442 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1443 bool CLASS::CBNAME(wxDragResult a) { \
1444 bool rval=FALSE; \
1445 bool found; \
1446 wxPyBeginBlockThreads(); \
1447 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1448 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a));\
1449 wxPyEndBlockThreads(); \
1450 if (! found) \
1451 rval = PCLASS::CBNAME(a); \
1452 return rval; \
1453 } \
1454 bool CLASS::base_##CBNAME(wxDragResult a) { \
1455 return PCLASS::CBNAME(a); \
1456 }
1457
1458 //---------------------------------------------------------------------------
1459
1460 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1461 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def);
1462
1463
1464 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1465 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1466 wxPyBeginBlockThreads(); \
1467 int rval=0; \
1468 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1469 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1470 wxPyEndBlockThreads(); \
1471 return (wxDragResult)rval; \
1472 } \
1473
1474 //---------------------------------------------------------------------------
1475
1476 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1477 bool CBNAME(int a, int b, const wxString& c);
1478
1479 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1480 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1481 bool rval=FALSE; \
1482 wxPyBeginBlockThreads(); \
1483 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1484 PyObject* s = wx2PyString(c); \
1485 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
1486 Py_DECREF(s); \
1487 } \
1488 wxPyEndBlockThreads(); \
1489 return rval; \
1490 } \
1491
1492 //---------------------------------------------------------------------------
1493
1494 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1495 size_t CBNAME(); \
1496 size_t base_##CBNAME();
1497
1498
1499 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1500 size_t CLASS::CBNAME() { \
1501 size_t rval=0; \
1502 bool found; \
1503 wxPyBeginBlockThreads(); \
1504 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1505 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1506 wxPyEndBlockThreads(); \
1507 if (! found) \
1508 rval = PCLASS::CBNAME(); \
1509 return rval; \
1510 } \
1511 size_t CLASS::base_##CBNAME() { \
1512 return PCLASS::CBNAME(); \
1513 }
1514
1515 //---------------------------------------------------------------------------
1516
1517 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1518 wxDataFormat CBNAME(size_t a); \
1519 wxDataFormat base_##CBNAME(size_t a);
1520
1521
1522 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1523 wxDataFormat CLASS::CBNAME(size_t a) { \
1524 wxDataFormat rval=0; \
1525 bool found; \
1526 wxPyBeginBlockThreads(); \
1527 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1528 PyObject* ro; \
1529 wxDataFormat* ptr; \
1530 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1531 if (ro) { \
1532 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxDataFormat_p")) \
1533 rval = *ptr; \
1534 Py_DECREF(ro); \
1535 } \
1536 } \
1537 wxPyEndBlockThreads(); \
1538 if (! found) \
1539 rval = PCLASS::CBNAME(a); \
1540 return rval; \
1541 } \
1542 wxDataFormat CLASS::base_##CBNAME(size_t a) { \
1543 return PCLASS::CBNAME(a); \
1544 }
1545
1546 //---------------------------------------------------------------------------
1547
1548 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1549 void CBNAME(const Type& a); \
1550 void base_##CBNAME(const Type& a);
1551
1552
1553 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1554 void CLASS::CBNAME(const Type& a) { \
1555 bool found; \
1556 wxPyBeginBlockThreads(); \
1557 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1558 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1559 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1560 Py_DECREF(obj); \
1561 } \
1562 wxPyEndBlockThreads(); \
1563 if (! found) \
1564 PCLASS::CBNAME(a); \
1565 } \
1566 void CLASS::base_##CBNAME(const Type& a) { \
1567 PCLASS::CBNAME(a); \
1568 }
1569
1570
1571 //---------------------------------------------------------------------------
1572
1573 #define DEC_PYCALLBACK__any(CBNAME, Type) \
1574 void CBNAME(Type& a); \
1575 void base_##CBNAME(Type& a);
1576
1577
1578 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1579 void CLASS::CBNAME(Type& a) { \
1580 bool found; \
1581 wxPyBeginBlockThreads(); \
1582 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1583 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1584 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1585 Py_DECREF(obj); \
1586 } \
1587 wxPyEndBlockThreads(); \
1588 if (! found) \
1589 PCLASS::CBNAME(a); \
1590 } \
1591 void CLASS::base_##CBNAME(Type& a) { \
1592 PCLASS::CBNAME(a); \
1593 }
1594
1595 //---------------------------------------------------------------------------
1596
1597 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1598 bool CBNAME(Type& a); \
1599 bool base_##CBNAME(Type& a);
1600
1601
1602 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
1603 bool CLASS::CBNAME(Type& a) { \
1604 bool rv=FALSE; \
1605 bool found; \
1606 wxPyBeginBlockThreads(); \
1607 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1608 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1609 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1610 Py_DECREF(obj); \
1611 } \
1612 wxPyEndBlockThreads(); \
1613 if (! found) \
1614 rv = PCLASS::CBNAME(a); \
1615 return rv; \
1616 } \
1617 bool CLASS::base_##CBNAME(Type& a) { \
1618 return PCLASS::CBNAME(a); \
1619 }
1620
1621 //---------------------------------------------------------------------------
1622
1623 #define DEC_PYCALLBACK_bool_anypure(CBNAME, Type) \
1624 bool CBNAME(Type& a);
1625
1626
1627 #define IMP_PYCALLBACK_bool_anypure(CLASS, PCLASS, CBNAME, Type) \
1628 bool CLASS::CBNAME(Type& a) { \
1629 bool rv=FALSE; \
1630 wxPyBeginBlockThreads(); \
1631 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1632 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1633 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1634 Py_DECREF(obj); \
1635 } \
1636 wxPyEndBlockThreads(); \
1637 return rv; \
1638 } \
1639
1640 //---------------------------------------------------------------------------
1641
1642 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
1643 wxString CBNAME(long a, long b) const; \
1644 wxString base_##CBNAME(long a, long b)const ;
1645
1646 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
1647 wxString CLASS::CBNAME(long a, long b) const { \
1648 wxString rval; \
1649 bool found; \
1650 wxPyBeginBlockThreads(); \
1651 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1652 PyObject* ro; \
1653 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1654 if (ro) { \
1655 rval = Py2wxString(ro); \
1656 Py_DECREF(ro); \
1657 } \
1658 } \
1659 wxPyEndBlockThreads(); \
1660 if (! found) \
1661 rval = PCLASS::CBNAME(a,b); \
1662 return rval; \
1663 } \
1664 wxString CLASS::base_##CBNAME(long a, long b) const { \
1665 return PCLASS::CBNAME(a,b); \
1666 }
1667
1668 //---------------------------------------------------------------------------
1669
1670 #define DEC_PYCALLBACK_INT_LONG(CBNAME) \
1671 int CBNAME(long a) const; \
1672 int base_##CBNAME(long a)const ;
1673
1674
1675 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
1676 int CLASS::CBNAME(long a) const { \
1677 int rval=-1; \
1678 bool found; \
1679 wxPyBeginBlockThreads(); \
1680 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1681 PyObject* ro; \
1682 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1683 if (ro) { \
1684 rval = PyInt_AsLong(ro); \
1685 Py_DECREF(ro); \
1686 } \
1687 } \
1688 wxPyEndBlockThreads(); \
1689 if (! found) \
1690 rval = PCLASS::CBNAME(a); \
1691 return rval; \
1692 } \
1693 int CLASS::base_##CBNAME(long a) const { \
1694 return PCLASS::CBNAME(a); \
1695 }
1696
1697
1698 //---------------------------------------------------------------------------
1699
1700 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
1701 wxListItemAttr* CBNAME(long a) const; \
1702 wxListItemAttr* base_##CBNAME(long a);
1703
1704
1705 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
1706 wxListItemAttr *CLASS::CBNAME(long a) const { \
1707 wxListItemAttr *rval = NULL; \
1708 bool found; \
1709 wxPyBeginBlockThreads(); \
1710 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1711 PyObject* ro; \
1712 wxListItemAttr* ptr; \
1713 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1714 if (ro) { \
1715 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxListItemAttr_p")) \
1716 rval = ptr; \
1717 Py_DECREF(ro); \
1718 } \
1719 } \
1720 wxPyEndBlockThreads(); \
1721 if (! found) \
1722 rval = PCLASS::CBNAME(a); \
1723 return rval; \
1724 } \
1725 wxListItemAttr *CLASS::base_##CBNAME(long a) { \
1726 return PCLASS::CBNAME(a); \
1727 }
1728
1729 //---------------------------------------------------------------------------
1730
1731 #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
1732 bool CBNAME(wxMouseEvent& e); \
1733 bool base_##CBNAME(wxMouseEvent& e);
1734
1735 #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
1736 bool CLASS::CBNAME(wxMouseEvent& e) { \
1737 bool rval=FALSE; \
1738 bool found; \
1739 wxPyBeginBlockThreads(); \
1740 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1741 PyObject* ro; \
1742 PyObject* obj = wxPyConstructObject((void*)&e, "wxMouseEvent", 0); \
1743 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
1744 if (ro) { \
1745 rval = PyInt_AsLong(ro); \
1746 Py_DECREF(ro); \
1747 } \
1748 Py_DECREF(obj); \
1749 } \
1750 wxPyEndBlockThreads(); \
1751 if (! found) \
1752 return PCLASS::CBNAME(e); \
1753 return rval; \
1754 } \
1755 bool CLASS::base_##CBNAME(wxMouseEvent& e) { \
1756 return PCLASS::CBNAME(e); \
1757 }
1758
1759
1760 //---------------------------------------------------------------------------
1761
1762 #define DEC_PYCALLBACK_WIZPG__pure(CBNAME) \
1763 wxWizardPage* CBNAME() const;
1764
1765 #define IMP_PYCALLBACK_WIZPG__pure(CLASS, PCLASS, CBNAME) \
1766 wxWizardPage* CLASS::CBNAME() const { \
1767 wxWizardPage* rv = NULL; \
1768 wxPyBeginBlockThreads(); \
1769 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1770 PyObject* ro; \
1771 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1772 if (ro) { \
1773 SWIG_GetPtrObj(ro, (void **)&rv, "_wxWizardPage_p"); \
1774 Py_DECREF(ro); \
1775 } \
1776 } \
1777 wxPyEndBlockThreads(); \
1778 return rv; \
1779 }
1780
1781 //---------------------------------------------------------------------------
1782
1783 #define DEC_PYCALLBACK_BITMAP__pure(CBNAME) \
1784 wxBitmap CBNAME() const;
1785
1786 #define IMP_PYCALLBACK_BITMAP__pure(CLASS, PCLASS, CBNAME) \
1787 wxBitmap CLASS::CBNAME() const { \
1788 wxBitmap rv; \
1789 wxPyBeginBlockThreads(); \
1790 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1791 PyObject* ro; \
1792 wxBitmap* ptr; \
1793 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1794 if (ro) { \
1795 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxBitmap_p")) \
1796 rv = *ptr; \
1797 Py_DECREF(ro); \
1798 } \
1799 } \
1800 wxPyEndBlockThreads(); \
1801 return rv; \
1802 }
1803
1804 //---------------------------------------------------------------------------
1805
1806 #define DEC_PYCALLBACK_OBJECT__pure(CBNAME) \
1807 wxObject* CBNAME();
1808
1809 #define IMP_PYCALLBACK_OBJECT__pure(CLASS, PCLASS, CBNAME) \
1810 wxObject* CLASS::CBNAME() { \
1811 wxObject* rv = NULL; \
1812 wxPyBeginBlockThreads(); \
1813 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1814 PyObject* ro; \
1815 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1816 if (ro) { \
1817 SWIG_GetPtrObj(ro, (void **)&rv, "_wxObject_p"); \
1818 Py_DECREF(ro); \
1819 } \
1820 } \
1821 wxPyEndBlockThreads(); \
1822 return rv; \
1823 }
1824
1825 //---------------------------------------------------------------------------
1826
1827 #define DEC_PYCALLBACK_BOOL_NODE_pure(CBNAME) \
1828 bool CBNAME(wxXmlNode* a);
1829
1830
1831 #define IMP_PYCALLBACK_BOOL_NODE_pure(CLASS, PCLASS, CBNAME) \
1832 bool CLASS::CBNAME(wxXmlNode* a) { \
1833 bool rv=FALSE; \
1834 wxPyBeginBlockThreads(); \
1835 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1836 PyObject* obj = wxPyConstructObject((void*)a, "wxXmlNode", 0); \
1837 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1838 Py_DECREF(obj); \
1839 } \
1840 wxPyEndBlockThreads(); \
1841 return rv; \
1842 } \
1843
1844 //---------------------------------------------------------------------------
1845 #endif