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