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