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