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