]> git.saurik.com Git - wxWidgets.git/blob - wxPython/include/wx/wxPython/wxPython_int.h
9fb470f26824e69f10271e23c6aa84a72132b472
[wxWidgets.git] / wxPython / include / wx / wxPython / wxPython_int.h
1 ////////////////////////////////////////////////////////////////////////////
2 // Name: wxPython_int.h (int == internal)
3 // Purpose: Helper functions/classes for the wxPython extension module
4 // This header should only be inclued directly by those source
5 // modules included in the wx._core module. All others should
6 // include wx/wxPython/wxPython.h instead.
7 //
8 // Author: Robin Dunn
9 //
10 // Created: 1-July-1997
11 // RCS-ID: $Id$
12 // Copyright: (c) 1998 by Total Control Software
13 // Licence: wxWindows license
14 /////////////////////////////////////////////////////////////////////////////
15
16 #ifndef __wxp_helpers__
17 #define __wxp_helpers__
18
19 #include <wx/wx.h>
20
21 #include <wx/busyinfo.h>
22 #include <wx/caret.h>
23 #include <wx/clipbrd.h>
24 #include <wx/colordlg.h>
25 #include <wx/config.h>
26 #include <wx/cshelp.h>
27 #include <wx/dcbuffer.h>
28 #include <wx/dcmirror.h>
29 #include <wx/dcps.h>
30 #include <wx/dirctrl.h>
31 #include <wx/dirdlg.h>
32 #include <wx/dnd.h>
33 #include <wx/docview.h>
34 #include <wx/encconv.h>
35 #include <wx/fdrepdlg.h>
36 #include <wx/fileconf.h>
37 #include <wx/filesys.h>
38 #include <wx/fontdlg.h>
39 #include <wx/fs_inet.h>
40 #include <wx/fs_mem.h>
41 #include <wx/fs_zip.h>
42 #include <wx/gbsizer.h>
43 #include <wx/geometry.h>
44 #include <wx/htmllbox.h>
45 #include <wx/image.h>
46 #include <wx/imaglist.h>
47 #include <wx/intl.h>
48 #include <wx/laywin.h>
49 #include <wx/listbook.h>
50 #include <wx/minifram.h>
51 #include <wx/notebook.h>
52 #include <wx/print.h>
53 #include <wx/printdlg.h>
54 #include <wx/process.h>
55 #include <wx/progdlg.h>
56 #include <wx/sashwin.h>
57 #include <wx/spinbutt.h>
58 #include <wx/spinctrl.h>
59 #include <wx/splash.h>
60 #include <wx/splitter.h>
61 #include <wx/statline.h>
62 #include <wx/stream.h>
63 #include <wx/sysopt.h>
64 #include <wx/taskbar.h>
65 #include <wx/tglbtn.h>
66 #include <wx/tipwin.h>
67 #include <wx/tooltip.h>
68 #include <wx/vlbox.h>
69 #include <wx/vscroll.h>
70
71
72 #ifdef _MSC_VER
73 # pragma warning(disable:4800)
74 # pragma warning(disable:4190)
75 #endif
76
77 #ifdef __WXMAC__ // avoid a bug in Carbon headers
78 #define scalb scalbn
79 #endif
80
81 //---------------------------------------------------------------------------
82
83 typedef unsigned char byte;
84 typedef wxPoint2DDouble wxPoint2D;
85
86 const bool True = true;
87 const bool False = false;
88
89
90 #ifndef wxPyUSE_EXPORTED_API
91
92 void __wxPyPreStart(PyObject*);
93 void __wxPyCleanup();
94 PyObject* __wxPySetDictionary(PyObject*, PyObject* args);
95 PyObject* __wxPyFixStockObjects(PyObject*, PyObject* args);
96
97
98 void wxPyEventThunker(wxObject*, wxEvent& event);
99
100
101 bool wxPyCheckSwigType(const wxChar* className);
102 PyObject* wxPyConstructObject(void* ptr,
103 const wxChar* className,
104 int setThisOwn=0);
105 bool wxPyConvertSwigPtr(PyObject* obj, void **ptr,
106 const wxChar* className);
107 PyObject* wxPyMakeSwigPtr(void* ptr, const wxChar* classname);
108
109
110 PyObject* wx2PyString(const wxString& src);
111 wxString Py2wxString(PyObject* source);
112
113 PyObject* wxPyMake_wxObject(wxObject* source, bool checkEvtHandler=True);
114 PyObject* wxPyMake_wxSizer(wxSizer* source);
115 void wxPyPtrTypeMap_Add(const char* commonName, const char* ptrName);
116
117 PyObject* wxPy_ConvertList(wxListBase* list);
118 long wxPyGetWinHandle(wxWindow* win);
119
120 void wxPy_ReinitStockObjects(int pass);
121
122 bool wxPyInstance_Check(PyObject* obj);
123 bool wxPySwigInstance_Check(PyObject* obj);
124
125
126 #endif // wxPyUSE_EXPORTED_API
127 //---------------------------------------------------------------------------
128
129 // if we want to handle threads and Python threads are available...
130 #if defined(WXP_USE_THREAD) && defined(WITH_THREAD)
131 #define WXP_WITH_THREAD
132 #else // no Python threads...
133 #undef WXP_WITH_THREAD
134 #endif
135
136 #ifndef wxPyUSE_EXPORTED_API
137
138 // For Python --> C++
139 PyThreadState* wxPyBeginAllowThreads();
140 void wxPyEndAllowThreads(PyThreadState* state);
141
142 // For C++ --> Python
143 void wxPyBeginBlockThreads();
144 void wxPyEndBlockThreads();
145
146 #endif // wxPyUSE_EXPORTED_API
147
148 #define wxPyBLOCK_THREADS(stmt) { wxPyBeginBlockThreads(); stmt; wxPyEndBlockThreads(); }
149 #define wxPyRaiseNotImplemented() wxPyBLOCK_THREADS(PyErr_SetNone(PyExc_NotImplementedError))
150
151 //---------------------------------------------------------------------------
152 // These are helpers used by the typemaps
153
154 #ifndef wxPyUSE_EXPORTED_API
155
156 wxString* wxString_in_helper(PyObject* source);
157
158 byte* byte_LIST_helper(PyObject* source);
159 int* int_LIST_helper(PyObject* source);
160 long* long_LIST_helper(PyObject* source);
161 char** string_LIST_helper(PyObject* source);
162 wxPoint* wxPoint_LIST_helper(PyObject* source, int* npoints);
163 wxBitmap** wxBitmap_LIST_helper(PyObject* source);
164 wxString* wxString_LIST_helper(PyObject* source);
165 wxAcceleratorEntry* wxAcceleratorEntry_LIST_helper(PyObject* source);
166 wxPen** wxPen_LIST_helper(PyObject* source);
167
168 bool wxSize_helper(PyObject* source, wxSize** obj);
169 bool wxPoint_helper(PyObject* source, wxPoint** obj);
170 bool wxRealPoint_helper(PyObject* source, wxRealPoint** obj);
171 bool wxRect_helper(PyObject* source, wxRect** obj);
172 bool wxColour_helper(PyObject* source, wxColour** obj);
173 bool wxPoint2D_helper(PyObject* source, wxPoint2D** obj);
174
175
176 bool wxPySimple_typecheck(PyObject* source, const wxChar* classname, int seqLen);
177 bool wxColour_typecheck(PyObject* source);
178
179
180 template<class T>
181 bool wxPyTwoIntItem_helper(PyObject* source, T** obj, const wxChar* name)
182 {
183 // If source is an object instance then it may already be the right type
184 if (wxPySwigInstance_Check(source)) {
185 T* ptr;
186 if (! wxPyConvertSwigPtr(source, (void **)&ptr, name))
187 goto error;
188 *obj = ptr;
189 return True;
190 }
191 // otherwise a 2-tuple of integers is expected
192 else if (PySequence_Check(source) && PyObject_Length(source) == 2) {
193 PyObject* o1 = PySequence_GetItem(source, 0);
194 PyObject* o2 = PySequence_GetItem(source, 1);
195 if (!PyNumber_Check(o1) || !PyNumber_Check(o2)) {
196 Py_DECREF(o1);
197 Py_DECREF(o2);
198 goto error;
199 }
200 **obj = T(PyInt_AsLong(o1), PyInt_AsLong(o2));
201 Py_DECREF(o1);
202 Py_DECREF(o2);
203 return True;
204 }
205
206 error:
207 wxString msg;
208 msg.Printf(wxT("Expected a 2-tuple of integers or a %s object."), name);
209 PyErr_SetString(PyExc_TypeError, msg.mb_str());
210 return False;
211 }
212
213
214
215 // Other helpful stuff
216 bool wxPy2int_seq_helper(PyObject* source, int* i1, int* i2);
217 bool wxPy4int_seq_helper(PyObject* source, int* i1, int* i2, int* i3, int* i4);
218
219 PyObject* wxArrayString2PyList_helper(const wxArrayString& arr);
220 PyObject* wxArrayInt2PyList_helper(const wxArrayInt& arr);
221
222 #endif // wxPyUSE_EXPORTED_API
223
224 //---------------------------------------------------------------------------
225
226 #if PYTHON_API_VERSION < 1009
227 #define PySequence_Fast_GET_ITEM(o, i) \
228 (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i))
229 #endif
230
231 #define RETURN_NONE() { Py_INCREF(Py_None); return Py_None; }
232 #define DECLARE_DEF_STRING(name) static const wxString wxPy##name(wx##name)
233 #define DECLARE_DEF_STRING2(name,val) static const wxString wxPy##name(val)
234
235 //---------------------------------------------------------------------------
236
237 #ifndef wxPyUSE_EXPORTED_API
238
239 class wxPyCallback : public wxObject {
240 DECLARE_ABSTRACT_CLASS(wxPyCallback);
241 public:
242 wxPyCallback(PyObject* func);
243 wxPyCallback(const wxPyCallback& other);
244 ~wxPyCallback();
245
246 void EventThunker(wxEvent& event);
247
248 PyObject* m_func;
249 };
250
251 #endif // wxPyUSE_EXPORTED_API
252 //---------------------------------------------------------------------------
253 //---------------------------------------------------------------------------
254 // These Event classes can be derived from in Python and passed through the
255 // event system without loosing anything. They do this by keeping a reference
256 // to themselves and some special case handling in wxPyCallback::EventThunker.
257
258
259
260 class wxPyEvtSelfRef {
261 public:
262 wxPyEvtSelfRef();
263 ~wxPyEvtSelfRef();
264
265 void SetSelf(PyObject* self, bool clone=False);
266 PyObject* GetSelf() const;
267 bool GetCloned() const { return m_cloned; }
268
269 protected:
270 PyObject* m_self;
271 bool m_cloned;
272 };
273
274
275 class wxPyEvent : public wxEvent, public wxPyEvtSelfRef {
276 DECLARE_ABSTRACT_CLASS(wxPyEvent)
277 public:
278 wxPyEvent(int winid=0, wxEventType commandType = wxEVT_NULL);
279 wxPyEvent(const wxPyEvent& evt);
280 ~wxPyEvent();
281
282 virtual wxEvent* Clone() const { return new wxPyEvent(*this); }
283 };
284
285
286 class wxPyCommandEvent : public wxCommandEvent, public wxPyEvtSelfRef {
287 DECLARE_ABSTRACT_CLASS(wxPyCommandEvent)
288 public:
289 wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0);
290 wxPyCommandEvent(const wxPyCommandEvent& evt);
291 ~wxPyCommandEvent();
292
293 virtual wxEvent* Clone() const { return new wxPyCommandEvent(*this); }
294 };
295
296
297
298 //----------------------------------------------------------------------
299 // Forward decalre a few things used in the exported API
300 class wxPyClientData;
301 class wxPyUserData;
302 class wxPyOORClientData;
303 class wxPyCBInputStream;
304
305 void wxPyClientData_dtor(wxPyClientData* self);
306 void wxPyUserData_dtor(wxPyUserData* self);
307 void wxPyOORClientData_dtor(wxPyOORClientData* self);
308 wxPyCBInputStream* wxPyCBInputStream_create(PyObject *py, bool block);
309
310
311 //---------------------------------------------------------------------------
312 // Export a C API in a struct. Other modules will be able to load this from
313 // the wx.core module and will then have safe access to these functions, even if
314 // in another shared library.
315
316 class wxPyCallbackHelper;
317 struct swig_type_info;
318 struct swig_const_info;
319
320 typedef double (*py_objasdbl_conv)(PyObject *obj);
321
322 // Make SunCC happy and make typedef's for these that are extern "C"
323 typedef swig_type_info* (*p_SWIG_Python_TypeRegister_t)(swig_type_info *);
324 typedef swig_type_info* (*p_SWIG_Python_TypeCheck_t)(char *c, swig_type_info *);
325 typedef void* (*p_SWIG_Python_TypeCast_t)(swig_type_info *, void *);
326 typedef swig_type_info* (*p_SWIG_Python_TypeDynamicCast_t)(swig_type_info *, void **);
327 typedef const char* (*p_SWIG_Python_TypeName_t)(const swig_type_info *);
328 typedef swig_type_info* (*p_SWIG_Python_TypeQuery_t)(const char *);
329 typedef void (*p_SWIG_Python_TypeClientData_t)(swig_type_info *, void *);
330 typedef PyObject* (*p_SWIG_Python_newvarlink_t)(void);
331 typedef void (*p_SWIG_Python_addvarlink_t)(PyObject *, char *, PyObject *(*)(void), int (*)(PyObject *));
332 typedef int (*p_SWIG_Python_ConvertPtr_t)(PyObject *, void **, swig_type_info *, int);
333 typedef int (*p_SWIG_Python_ConvertPacked_t)(PyObject *, void *, int sz, swig_type_info *, int);
334 typedef char* (*p_SWIG_Python_PackData_t)(char *c, void *, int);
335 typedef char* (*p_SWIG_Python_UnpackData_t)(char *c, void *, int);
336 typedef PyObject* (*p_SWIG_Python_NewPointerObj_t)(void *, swig_type_info *,int own);
337 typedef PyObject* (*p_SWIG_Python_NewPackedObj_t)(void *, int sz, swig_type_info *);
338 typedef void (*p_SWIG_Python_InstallConstants_t)(PyObject *d, swig_const_info constants[]);
339 typedef void* (*p_SWIG_Python_MustGetPtr_t)(PyObject *, swig_type_info *, int, int);
340
341 typedef char* (*p_SWIG_PyObj_AsCharPtr_t)(PyObject *obj, swig_type_info* pchar_info);
342 typedef PyObject * (*p_SWIG_PyObj_FromCharPtr_t)(const char* cptr);
343 typedef unsigned long (*p_SWIG_PyObj_AsUnsignedLong_t)(PyObject * obj);
344 typedef long (*p_SWIG_PyObj_AsLongInRange_t)(PyObject * obj, const char* type,
345 long min_value, long max_value);
346 typedef unsigned long (*p_SWIG_PyObj_AsUnsignedLongInRange_t)(PyObject *obj, const char* type,
347 unsigned long max_value);
348 typedef char * (*p_SWIG_PyObj_AsNewCharPtr_t)(PyObject *obj, swig_type_info* pchar_info);
349 typedef void (*p_SWIG_PyObj_AsCharPtrAndSize_t)(PyObject *obj, swig_type_info* pchar_info,
350 char** cptr, size_t* size);
351 typedef void (*p_SWIG_PyObj_AsCharArray_t)(PyObject *obj, swig_type_info* pchar_info,
352 char* carray, size_t size);
353 typedef PyObject * (*p_SWIG_PyObj_FromCharArray_t)(const char* carray, size_t size);
354 typedef float (*p_SWIG_PyObj_AsFloatConv_t)(PyObject *obj, py_objasdbl_conv pyconv);
355
356
357
358
359 struct wxPyCoreAPI {
360
361 p_SWIG_Python_TypeRegister_t p_SWIG_Python_TypeRegister;
362 p_SWIG_Python_TypeCheck_t p_SWIG_Python_TypeCheck;
363 p_SWIG_Python_TypeCast_t p_SWIG_Python_TypeCast;
364 p_SWIG_Python_TypeDynamicCast_t p_SWIG_Python_TypeDynamicCast;
365 p_SWIG_Python_TypeName_t p_SWIG_Python_TypeName;
366 p_SWIG_Python_TypeQuery_t p_SWIG_Python_TypeQuery;
367 p_SWIG_Python_TypeClientData_t p_SWIG_Python_TypeClientData;
368 p_SWIG_Python_newvarlink_t p_SWIG_Python_newvarlink;
369 p_SWIG_Python_addvarlink_t p_SWIG_Python_addvarlink;
370 p_SWIG_Python_ConvertPtr_t p_SWIG_Python_ConvertPtr;
371 p_SWIG_Python_ConvertPacked_t p_SWIG_Python_ConvertPacked;
372 p_SWIG_Python_PackData_t p_SWIG_Python_PackData;
373 p_SWIG_Python_UnpackData_t p_SWIG_Python_UnpackData;
374 p_SWIG_Python_NewPointerObj_t p_SWIG_Python_NewPointerObj;
375 p_SWIG_Python_NewPackedObj_t p_SWIG_Python_NewPackedObj;
376 p_SWIG_Python_InstallConstants_t p_SWIG_Python_InstallConstants;
377 p_SWIG_Python_MustGetPtr_t p_SWIG_Python_MustGetPtr;
378
379 p_SWIG_PyObj_AsCharPtr_t p_SWIG_PyObj_AsCharPtr;
380 p_SWIG_PyObj_FromCharPtr_t p_SWIG_PyObj_FromCharPtr;
381 p_SWIG_PyObj_AsUnsignedLong_t p_SWIG_PyObj_AsUnsignedLong;
382 p_SWIG_PyObj_AsLongInRange_t p_SWIG_PyObj_AsLongInRange;
383 p_SWIG_PyObj_AsUnsignedLongInRange_t p_SWIG_PyObj_AsUnsignedLongInRange;
384 p_SWIG_PyObj_AsNewCharPtr_t p_SWIG_PyObj_AsNewCharPtr;
385 p_SWIG_PyObj_AsCharPtrAndSize_t p_SWIG_PyObj_AsCharPtrAndSize;
386 p_SWIG_PyObj_AsCharArray_t p_SWIG_PyObj_AsCharArray;
387 p_SWIG_PyObj_FromCharArray_t p_SWIG_PyObj_FromCharArray;
388 p_SWIG_PyObj_AsFloatConv_t p_SWIG_PyObj_AsFloatConv;
389
390 bool (*p_wxPyCheckSwigType)(const wxChar* className);
391 PyObject* (*p_wxPyConstructObject)(void* ptr, const wxChar* className, int setThisOwn);
392 bool (*p_wxPyConvertSwigPtr)(PyObject* obj, void **ptr, const wxChar* className);
393 PyObject* (*p_wxPyMakeSwigPtr)(void* ptr, const wxChar* className);
394
395 PyThreadState* (*p_wxPyBeginAllowThreads)();
396 void (*p_wxPyEndAllowThreads)(PyThreadState* state);
397 void (*p_wxPyBeginBlockThreads)();
398 void (*p_wxPyEndBlockThreads)();
399
400 PyObject* (*p_wxPy_ConvertList)(wxListBase* list);
401
402 wxString* (*p_wxString_in_helper)(PyObject* source);
403 wxString (*p_Py2wxString)(PyObject* source);
404 PyObject* (*p_wx2PyString)(const wxString& src);
405
406 byte* (*p_byte_LIST_helper)(PyObject* source);
407 int* (*p_int_LIST_helper)(PyObject* source);
408 long* (*p_long_LIST_helper)(PyObject* source);
409 char** (*p_string_LIST_helper)(PyObject* source);
410 wxPoint* (*p_wxPoint_LIST_helper)(PyObject* source, int* npoints);
411 wxBitmap** (*p_wxBitmap_LIST_helper)(PyObject* source);
412 wxString* (*p_wxString_LIST_helper)(PyObject* source);
413 wxAcceleratorEntry* (*p_wxAcceleratorEntry_LIST_helper)(PyObject* source);
414
415 bool (*p_wxSize_helper)(PyObject* source, wxSize** obj);
416 bool (*p_wxPoint_helper)(PyObject* source, wxPoint** obj);
417 bool (*p_wxRealPoint_helper)(PyObject* source, wxRealPoint** obj);
418 bool (*p_wxRect_helper)(PyObject* source, wxRect** obj);
419 bool (*p_wxColour_helper)(PyObject* source, wxColour** obj);
420 bool (*p_wxPoint2D_helper)(PyObject* source, wxPoint2DDouble** obj);
421
422
423 bool (*p_wxPySimple_typecheck)(PyObject* source, const wxChar* classname, int seqLen);
424 bool (*p_wxColour_typecheck)(PyObject* source);
425
426 void (*p_wxPyCBH_setCallbackInfo)(wxPyCallbackHelper& cbh, PyObject* self, PyObject* klass, int incref);
427 bool (*p_wxPyCBH_findCallback)(const wxPyCallbackHelper& cbh, const char* name);
428 int (*p_wxPyCBH_callCallback)(const wxPyCallbackHelper& cbh, PyObject* argTuple);
429 PyObject* (*p_wxPyCBH_callCallbackObj)(const wxPyCallbackHelper& cbh, PyObject* argTuple);
430 void (*p_wxPyCBH_delete)(wxPyCallbackHelper* cbh);
431
432 PyObject* (*p_wxPyMake_wxObject)(wxObject* source, bool checkEvtHandler);
433 PyObject* (*p_wxPyMake_wxSizer)(wxSizer* source);
434 void (*p_wxPyPtrTypeMap_Add)(const char* commonName, const char* ptrName);
435 bool (*p_wxPy2int_seq_helper)(PyObject* source, int* i1, int* i2);
436 bool (*p_wxPy4int_seq_helper)(PyObject* source, int* i1, int* i2, int* i3, int* i4);
437 PyObject* (*p_wxArrayString2PyList_helper)(const wxArrayString& arr);
438 PyObject* (*p_wxArrayInt2PyList_helper)(const wxArrayInt& arr);
439
440 void (*p_wxPyClientData_dtor)(wxPyClientData*);
441 void (*p_wxPyUserData_dtor)(wxPyUserData*);
442 void (*p_wxPyOORClientData_dtor)(wxPyOORClientData*);
443
444 wxPyCBInputStream* (*p_wxPyCBInputStream_create)(PyObject *py, bool block);
445
446 bool (*p_wxPyInstance_Check)(PyObject* obj);
447 bool (*p_wxPySwigInstance_Check)(PyObject* obj);
448
449 };
450
451 #ifdef wxPyUSE_EXPORTED_API
452 // Notice that this is static, not extern. This is by design, each module
453 // needs one, but doesn't have to use it.
454 static wxPyCoreAPI* wxPyCoreAPIPtr = NULL;
455 #endif // wxPyUSE_EXPORTED_API
456
457 //---------------------------------------------------------------------------
458
459 // A wxObject that holds a reference to a Python object
460 class wxPyUserData : public wxObject {
461 public:
462 wxPyUserData(PyObject* obj) {
463 m_obj = obj;
464 Py_INCREF(m_obj);
465 }
466
467 ~wxPyUserData() {
468 #ifdef wxPyUSE_EXPORTED_API
469 wxPyCoreAPIPtr->p_wxPyUserData_dtor(this);
470 #else
471 wxPyUserData_dtor(this);
472 #endif
473 }
474 PyObject* m_obj;
475 };
476
477
478 // A wxClientData that holds a refernece to a Python object
479 class wxPyClientData : public wxClientData {
480 public:
481 wxPyClientData(PyObject* obj) {
482 m_obj = obj;
483 Py_INCREF(m_obj);
484 }
485
486 ~wxPyClientData() {
487 #ifdef wxPyUSE_EXPORTED_API
488 wxPyCoreAPIPtr->p_wxPyClientData_dtor(this);
489 #else
490 wxPyClientData_dtor(this);
491 #endif
492 }
493 PyObject* m_obj;
494 };
495
496
497 // Just like wxPyClientData, except when this object is destroyed it does some
498 // OOR magic on the Python Object.
499 class wxPyOORClientData : public wxPyClientData {
500 public:
501 wxPyOORClientData(PyObject* obj)
502 : wxPyClientData(obj) {}
503
504 ~wxPyOORClientData() {
505 #ifdef wxPyUSE_EXPORTED_API
506 wxPyCoreAPIPtr->p_wxPyOORClientData_dtor(this);
507 #else
508 wxPyOORClientData_dtor(this);
509 #endif
510 }
511 };
512
513
514 //---------------------------------------------------------------------------
515 // This class holds an instance of a Python Shadow Class object and assists
516 // with looking up and invoking Python callback methods from C++ virtual
517 // method redirections. For all classes which have virtuals which should be
518 // overridable in wxPython, a new subclass is created that contains a
519 // wxPyCallbackHelper.
520 //
521
522 class wxPyCallbackHelper {
523 public:
524 wxPyCallbackHelper(const wxPyCallbackHelper& other);
525
526 wxPyCallbackHelper() {
527 m_class = NULL;
528 m_self = NULL;
529 m_lastFound = NULL;
530 m_incRef = False;
531 }
532
533 ~wxPyCallbackHelper() {
534 #ifdef wxPyUSE_EXPORTED_API
535 wxPyCoreAPIPtr->p_wxPyCBH_delete(this);
536 #else
537 wxPyCBH_delete(this);
538 #endif
539 }
540
541 void setSelf(PyObject* self, PyObject* klass, int incref=True);
542 bool findCallback(const char* name) const;
543 int callCallback(PyObject* argTuple) const;
544 PyObject* callCallbackObj(PyObject* argTuple) const;
545 PyObject* GetLastFound() const { return m_lastFound; }
546
547 private:
548 PyObject* m_self;
549 PyObject* m_class;
550 PyObject* m_lastFound;
551 int m_incRef;
552
553 friend void wxPyCBH_delete(wxPyCallbackHelper* cbh);
554 };
555
556
557 void wxPyCBH_setCallbackInfo(wxPyCallbackHelper& cbh, PyObject* self, PyObject* klass, int incref);
558 bool wxPyCBH_findCallback(const wxPyCallbackHelper& cbh, const char* name);
559 int wxPyCBH_callCallback(const wxPyCallbackHelper& cbh, PyObject* argTuple);
560 PyObject* wxPyCBH_callCallbackObj(const wxPyCallbackHelper& cbh, PyObject* argTuple);
561 void wxPyCBH_delete(wxPyCallbackHelper* cbh);
562
563
564
565
566 //---------------------------------------------------------------------------
567
568 // This is used in C++ classes that need to be able to make callback to
569 // "overloaded" python methods
570
571 #define PYPRIVATE \
572 void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \
573 wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \
574 } \
575 private: wxPyCallbackHelper m_myInst
576
577
578 //---------------------------------------------------------------------------
579 // The wxPythonApp class
580
581 enum {
582 wxPYAPP_ASSERT_SUPPRESS = 1,
583 wxPYAPP_ASSERT_EXCEPTION = 2,
584 wxPYAPP_ASSERT_DIALOG = 4,
585 wxPYAPP_ASSERT_LOG = 8
586 };
587
588 class wxPyApp: public wxApp
589 {
590 DECLARE_ABSTRACT_CLASS(wxPyApp);
591
592 public:
593 wxPyApp();
594 ~wxPyApp();
595 bool OnInit();
596 int MainLoop();
597
598 int GetAssertMode() { return m_assertMode; }
599 void SetAssertMode(int mode) { m_assertMode = mode; }
600
601 virtual bool OnInitGui();
602 virtual int OnExit();
603 #ifdef __WXDEBUG__
604 virtual void OnAssert(const wxChar *file,
605 int line,
606 const wxChar *cond,
607 const wxChar *msg);
608 #endif
609 // virtual int FilterEvent(wxEvent& event); // This one too????
610
611
612 static bool GetMacSupportPCMenuShortcuts();
613 static long GetMacAboutMenuItemId();
614 static long GetMacPreferencesMenuItemId();
615 static long GetMacExitMenuItemId();
616 static wxString GetMacHelpMenuTitleName();
617
618 static void SetMacSupportPCMenuShortcuts(bool val);
619 static void SetMacAboutMenuItemId(long val);
620 static void SetMacPreferencesMenuItemId(long val);
621 static void SetMacExitMenuItemId(long val);
622 static void SetMacHelpMenuTitleName(const wxString& val);
623
624
625 void _BootstrapApp();
626
627 // implementation only
628 void SetStartupComplete(bool val) { m_startupComplete = val; };
629
630 PYPRIVATE;
631 int m_assertMode;
632 bool m_startupComplete;
633 };
634
635 extern wxPyApp *wxPythonApp;
636
637
638 //----------------------------------------------------------------------
639 // These macros are used to implement the virtual methods that should
640 // redirect to a Python method if one exists. The names designate the
641 // return type, if any, as well as any parameter types.
642 //---------------------------------------------------------------------------
643
644 #define DEC_PYCALLBACK__(CBNAME) \
645 void CBNAME(); \
646 void base_##CBNAME()
647
648
649 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
650 void CLASS::CBNAME() { \
651 bool found; \
652 wxPyBeginBlockThreads(); \
653 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
654 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
655 wxPyEndBlockThreads(); \
656 if (! found) \
657 PCLASS::CBNAME(); \
658 } \
659 void CLASS::base_##CBNAME() { \
660 PCLASS::CBNAME(); \
661 }
662
663 //---------------------------------------------------------------------------
664
665 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
666 bool CBNAME(int a, int b); \
667 bool base_##CBNAME(int a, int b)
668
669
670 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
671 bool CLASS::CBNAME(int a, int b) { \
672 bool rval=False, found; \
673 wxPyBeginBlockThreads(); \
674 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
675 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
676 wxPyEndBlockThreads(); \
677 if (! found) \
678 rval = PCLASS::CBNAME(a,b); \
679 return rval; \
680 } \
681 bool CLASS::base_##CBNAME(int a, int b) { \
682 return PCLASS::CBNAME(a,b); \
683 }
684
685 //---------------------------------------------------------------------------
686
687 #define DEC_PYCALLBACK_VOID_(CBNAME) \
688 void CBNAME(); \
689 void base_##CBNAME()
690
691
692 #define IMP_PYCALLBACK_VOID_(CLASS, PCLASS, CBNAME) \
693 void CLASS::CBNAME() { \
694 bool found; \
695 wxPyBeginBlockThreads(); \
696 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
697 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
698 wxPyEndBlockThreads(); \
699 if (! found) \
700 PCLASS::CBNAME(); \
701 } \
702 void CLASS::base_##CBNAME() { \
703 PCLASS::CBNAME(); \
704 }
705
706 //---------------------------------------------------------------------------
707
708 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
709 void CBNAME(int a, int b); \
710 void base_##CBNAME(int a, int b)
711
712
713 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
714 void CLASS::CBNAME(int a, int b) { \
715 bool found; \
716 wxPyBeginBlockThreads(); \
717 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
718 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
719 wxPyEndBlockThreads(); \
720 if (! found) \
721 PCLASS::CBNAME(a,b); \
722 } \
723 void CLASS::base_##CBNAME(int a, int b) { \
724 PCLASS::CBNAME(a,b); \
725 }
726
727 //---------------------------------------------------------------------------
728
729 #define DEC_PYCALLBACK_VOID_INT(CBNAME) \
730 void CBNAME(int a); \
731 void base_##CBNAME(int a)
732
733
734 #define IMP_PYCALLBACK_VOID_INT(CLASS, PCLASS, CBNAME) \
735 void CLASS::CBNAME(int a) { \
736 bool found; \
737 wxPyBeginBlockThreads(); \
738 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
739 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
740 wxPyEndBlockThreads(); \
741 if (! found) \
742 PCLASS::CBNAME(a); \
743 } \
744 void CLASS::base_##CBNAME(int a) { \
745 PCLASS::CBNAME(a); \
746 }
747
748 //---------------------------------------------------------------------------
749
750 #define DEC_PYCALLBACK_VOID_INT4(CBNAME) \
751 void CBNAME(int a, int b, int c, int d); \
752 void base_##CBNAME(int a, int b, int c, int d)
753
754
755 #define IMP_PYCALLBACK_VOID_INT4(CLASS, PCLASS, CBNAME) \
756 void CLASS::CBNAME(int a, int b, int c, int d) { \
757 bool found; \
758 wxPyBeginBlockThreads(); \
759 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
760 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiii)",a,b,c,d)); \
761 wxPyEndBlockThreads(); \
762 if (! found) \
763 PCLASS::CBNAME(a,b,c,d); \
764 } \
765 void CLASS::base_##CBNAME(int a, int b, int c, int d) { \
766 PCLASS::CBNAME(a,b,c,d); \
767 }
768
769 //---------------------------------------------------------------------------
770 #define DEC_PYCALLBACK_VOID_INT5(CBNAME) \
771 void CBNAME(int a, int b, int c, int d, int e); \
772 void base_##CBNAME(int a, int b, int c, int d, int e)
773
774
775 #define IMP_PYCALLBACK_VOID_INT5(CLASS, PCLASS, CBNAME) \
776 void CLASS::CBNAME(int a, int b, int c, int d, int e) { \
777 bool found; \
778 wxPyBeginBlockThreads(); \
779 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
780 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiiii)",a,b,c,d,e)); \
781 wxPyEndBlockThreads(); \
782 if (! found) \
783 PCLASS::CBNAME(a,b,c,d,e); \
784 } \
785 void CLASS::base_##CBNAME(int a, int b, int c, int d, int e) { \
786 PCLASS::CBNAME(a,b,c,d,e); \
787 }
788
789 //---------------------------------------------------------------------------
790
791 #define DEC_PYCALLBACK_VOID_INTPINTP_const(CBNAME) \
792 void CBNAME(int* a, int* b) const; \
793 void base_##CBNAME(int* a, int* b) const
794
795
796 #define IMP_PYCALLBACK_VOID_INTPINTP_const(CLASS, PCLASS, CBNAME) \
797 void CLASS::CBNAME(int* a, int* b) const { \
798 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
799 bool found; \
800 wxPyBeginBlockThreads(); \
801 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
802 PyObject* ro; \
803 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
804 if (ro) { \
805 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
806 PyObject* o1 = PySequence_GetItem(ro, 0); \
807 PyObject* o2 = PySequence_GetItem(ro, 1); \
808 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
809 *a = PyInt_AsLong(o1); *b = PyInt_AsLong(o2); \
810 } \
811 else \
812 PyErr_SetString(PyExc_TypeError, errmsg); \
813 Py_DECREF(o1); \
814 Py_DECREF(o2); \
815 } \
816 else { \
817 PyErr_SetString(PyExc_TypeError, errmsg); \
818 } \
819 Py_DECREF(ro); \
820 } \
821 } \
822 wxPyEndBlockThreads(); \
823 if (! found) \
824 PCLASS::CBNAME(a,b); \
825 } \
826 void CLASS::base_##CBNAME(int* a, int* b) const { \
827 PCLASS::CBNAME(a,b); \
828 }
829
830
831 //---------------------------------------------------------------------------
832
833 #define DEC_PYCALLBACK_SIZE_const(CBNAME) \
834 wxSize CBNAME() const; \
835 wxSize base_##CBNAME() const
836
837
838 #define IMP_PYCALLBACK_SIZE_const(CLASS, PCLASS, CBNAME) \
839 wxSize CLASS::CBNAME() const { \
840 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
841 bool found; wxSize rval(0,0); \
842 wxPyBeginBlockThreads(); \
843 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
844 PyObject* ro; \
845 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
846 if (ro) { \
847 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
848 PyObject* o1 = PySequence_GetItem(ro, 0); \
849 PyObject* o2 = PySequence_GetItem(ro, 1); \
850 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
851 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
852 } \
853 else \
854 PyErr_SetString(PyExc_TypeError, errmsg); \
855 Py_DECREF(o1); \
856 Py_DECREF(o2); \
857 } \
858 else { \
859 PyErr_SetString(PyExc_TypeError, errmsg); \
860 } \
861 Py_DECREF(ro); \
862 } \
863 } \
864 wxPyEndBlockThreads(); \
865 if (! found) \
866 return PCLASS::CBNAME(); \
867 else \
868 return rval; \
869 } \
870 wxSize CLASS::base_##CBNAME() const { \
871 return PCLASS::CBNAME(); \
872 }
873
874
875 //---------------------------------------------------------------------------
876
877 #define DEC_PYCALLBACK_BOOL_BOOL(CBNAME) \
878 bool CBNAME(bool a); \
879 bool base_##CBNAME(bool a)
880
881
882 #define IMP_PYCALLBACK_BOOL_BOOL(CLASS, PCLASS, CBNAME) \
883 bool CLASS::CBNAME(bool a) { \
884 bool rval=False, found; \
885 wxPyBeginBlockThreads(); \
886 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
887 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
888 wxPyEndBlockThreads(); \
889 if (! found) \
890 rval = PCLASS::CBNAME(a); \
891 return rval; \
892 } \
893 bool CLASS::base_##CBNAME(bool a) { \
894 return PCLASS::CBNAME(a); \
895 }
896
897 //---------------------------------------------------------------------------
898
899 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
900 bool CBNAME(int a); \
901 bool base_##CBNAME(int a)
902
903
904 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
905 bool CLASS::CBNAME(int a) { \
906 bool rval=False, found; \
907 wxPyBeginBlockThreads(); \
908 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
909 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
910 wxPyEndBlockThreads(); \
911 if (! found) \
912 rval = PCLASS::CBNAME(a); \
913 return rval; \
914 } \
915 bool CLASS::base_##CBNAME(int a) { \
916 return PCLASS::CBNAME(a); \
917 }
918
919 //---------------------------------------------------------------------------
920
921 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
922 bool CBNAME(int a)
923
924
925 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
926 bool CLASS::CBNAME(int a) { \
927 bool rval=False; \
928 wxPyBeginBlockThreads(); \
929 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
930 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
931 else rval = False; \
932 wxPyEndBlockThreads(); \
933 return rval; \
934 }
935
936
937 //---------------------------------------------------------------------------
938
939 #define DEC_PYCALLBACK__DC(CBNAME) \
940 void CBNAME(wxDC& a); \
941 void base_##CBNAME(wxDC& a)
942
943
944 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
945 void CLASS::CBNAME(wxDC& a) { \
946 bool found; \
947 wxPyBeginBlockThreads(); \
948 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
949 PyObject* obj = wxPyMake_wxObject(&a); \
950 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
951 Py_DECREF(obj); \
952 } \
953 wxPyEndBlockThreads(); \
954 if (! found) \
955 PCLASS::CBNAME(a); \
956 } \
957 void CLASS::base_##CBNAME(wxDC& a) { \
958 PCLASS::CBNAME(a); \
959 }
960
961
962
963 //---------------------------------------------------------------------------
964
965 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
966 void CBNAME(wxDC& a, bool b); \
967 void base_##CBNAME(wxDC& a, bool b)
968
969
970 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
971 void CLASS::CBNAME(wxDC& a, bool b) { \
972 bool found; \
973 wxPyBeginBlockThreads(); \
974 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
975 PyObject* obj = wxPyMake_wxObject(&a); \
976 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
977 Py_DECREF(obj); \
978 } \
979 wxPyEndBlockThreads(); \
980 if (! found) \
981 PCLASS::CBNAME(a, b); \
982 } \
983 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
984 PCLASS::CBNAME(a, b); \
985 }
986
987 //---------------------------------------------------------------------------
988
989 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
990 void CBNAME(wxDC& a, bool b); \
991 void base_##CBNAME(wxDC& a, bool b)
992
993
994 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
995 void CLASS::CBNAME(wxDC& a, bool b) { \
996 bool found; \
997 wxPyBeginBlockThreads(); \
998 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
999 PyObject* obj = wxPyMake_wxObject(&a); \
1000 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
1001 Py_DECREF(obj); \
1002 } \
1003 wxPyEndBlockThreads(); \
1004 if (! found) \
1005 PCLASS::CBNAME(a, b); \
1006 } \
1007 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
1008 PCLASS::CBNAME(a, b); \
1009 }
1010
1011 //---------------------------------------------------------------------------
1012
1013 #define DEC_PYCALLBACK__2DBL(CBNAME) \
1014 void CBNAME(double a, double b); \
1015 void base_##CBNAME(double a, double b)
1016
1017
1018 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
1019 void CLASS::CBNAME(double a, double b) { \
1020 bool found; \
1021 wxPyBeginBlockThreads(); \
1022 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1023 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
1024 wxPyEndBlockThreads(); \
1025 if (! found) \
1026 PCLASS::CBNAME(a, b); \
1027 } \
1028 void CLASS::base_##CBNAME(double a, double b) { \
1029 PCLASS::CBNAME(a, b); \
1030 }
1031
1032 //---------------------------------------------------------------------------
1033
1034 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
1035 void CBNAME(double a, double b, int c, int d); \
1036 void base_##CBNAME(double a, double b, int c, int d)
1037
1038
1039 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
1040 void CLASS::CBNAME(double a, double b, int c, int d) { \
1041 bool found; \
1042 wxPyBeginBlockThreads(); \
1043 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1044 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
1045 a,b,c,d)); \
1046 wxPyEndBlockThreads(); \
1047 if (! found) \
1048 PCLASS::CBNAME(a, b, c, d); \
1049 } \
1050 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
1051 PCLASS::CBNAME(a, b, c, d); \
1052 }
1053
1054 //---------------------------------------------------------------------------
1055
1056 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
1057 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
1058 void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1059
1060
1061 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1062 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1063 bool found; \
1064 wxPyBeginBlockThreads(); \
1065 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1066 PyObject* obj = wxPyMake_wxObject(&a); \
1067 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
1068 Py_DECREF(obj); \
1069 } \
1070 wxPyEndBlockThreads(); \
1071 if (! found) \
1072 PCLASS::CBNAME(a, b, c, d, e, f); \
1073 } \
1074 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
1075 PCLASS::CBNAME(a, b, c, d, e, f); \
1076 }
1077
1078 //---------------------------------------------------------------------------
1079
1080 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
1081 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
1082 bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1083
1084
1085 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1086 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1087 bool found; \
1088 wxPyBeginBlockThreads(); \
1089 bool rval=False; \
1090 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1091 PyObject* obj = wxPyMake_wxObject(&a); \
1092 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
1093 Py_DECREF(obj); \
1094 } \
1095 wxPyEndBlockThreads(); \
1096 if (! found) \
1097 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
1098 return rval; \
1099 } \
1100 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
1101 return PCLASS::CBNAME(a, b, c, d, e, f); \
1102 }
1103
1104 //---------------------------------------------------------------------------
1105
1106 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
1107 void CBNAME(bool a, double b, double c, int d, int e); \
1108 void base_##CBNAME(bool a, double b, double c, int d, int e)
1109
1110
1111 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1112 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
1113 bool found; \
1114 wxPyBeginBlockThreads(); \
1115 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1116 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
1117 (int)a,b,c,d,e)); \
1118 wxPyEndBlockThreads(); \
1119 if (! found) \
1120 PCLASS::CBNAME(a, b, c, d, e); \
1121 } \
1122 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
1123 PCLASS::CBNAME(a, b, c, d, e); \
1124 }
1125
1126 //---------------------------------------------------------------------------
1127
1128 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
1129 void CBNAME(wxDC& a, double b, double c, double d, double e); \
1130 void base_##CBNAME(wxDC& a, double b, double c, double d, double e)
1131
1132
1133 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
1134 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
1135 bool found; \
1136 wxPyBeginBlockThreads(); \
1137 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1138 PyObject* obj = wxPyMake_wxObject(&a); \
1139 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
1140 Py_DECREF(obj); \
1141 } \
1142 wxPyEndBlockThreads(); \
1143 if (! found) \
1144 PCLASS::CBNAME(a, b, c, d, e); \
1145 } \
1146 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
1147 PCLASS::CBNAME(a, b, c, d, e); \
1148 }
1149
1150 //---------------------------------------------------------------------------
1151
1152 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
1153 void CBNAME(wxDC& a, bool b); \
1154 void base_##CBNAME(wxDC& a, bool b)
1155
1156
1157 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
1158 void CLASS::CBNAME(wxDC& a, bool b) { \
1159 bool found; \
1160 wxPyBeginBlockThreads(); \
1161 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1162 PyObject* obj = wxPyMake_wxObject(&a); \
1163 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
1164 Py_DECREF(obj); \
1165 } \
1166 wxPyEndBlockThreads(); \
1167 if (! found) \
1168 PCLASS::CBNAME(a, b); \
1169 } \
1170 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
1171 PCLASS::CBNAME(a, b); \
1172 }
1173
1174 //---------------------------------------------------------------------------
1175
1176 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
1177 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
1178 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f)
1179
1180
1181 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1182 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
1183 int e, int f) { \
1184 bool found; \
1185 wxPyBeginBlockThreads(); \
1186 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1187 PyObject* obj = wxPyMake_wxObject(a); \
1188 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
1189 Py_DECREF(obj); \
1190 } \
1191 wxPyEndBlockThreads(); \
1192 if (! found) \
1193 PCLASS::CBNAME(a, b, c, d, e, f); \
1194 } \
1195 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
1196 int e, int f) { \
1197 PCLASS::CBNAME(a, b, c, d, e, f); \
1198 }
1199
1200 //---------------------------------------------------------------------------
1201
1202 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
1203 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
1204 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e)
1205
1206
1207 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
1208 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
1209 bool found; \
1210 wxPyBeginBlockThreads(); \
1211 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1212 PyObject* obj = wxPyMake_wxObject(a); \
1213 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
1214 Py_DECREF(obj); \
1215 } \
1216 wxPyEndBlockThreads(); \
1217 if (! found) \
1218 PCLASS::CBNAME(a, b, c, d, e); \
1219 } \
1220 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
1221 int d, int e) { \
1222 PCLASS::CBNAME(a, b, c, d, e); \
1223 }
1224
1225 //---------------------------------------------------------------------------
1226
1227 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
1228 void CBNAME(double a, double b, int c); \
1229 void base_##CBNAME(double a, double b, int c)
1230
1231
1232 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
1233 void CLASS::CBNAME(double a, double b, int c) { \
1234 bool found; \
1235 wxPyBeginBlockThreads(); \
1236 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1237 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
1238 wxPyEndBlockThreads(); \
1239 if (! found) \
1240 PCLASS::CBNAME(a, b, c); \
1241 } \
1242 void CLASS::base_##CBNAME(double a, double b, int c) { \
1243 PCLASS::CBNAME(a, b, c); \
1244 }
1245
1246 //---------------------------------------------------------------------------
1247
1248 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
1249 void CBNAME(bool a, double b, double c, int d); \
1250 void base_##CBNAME(bool a, double b, double c, int d)
1251
1252
1253 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
1254 void CLASS::CBNAME(bool a, double b, double c, int d) { \
1255 bool found; \
1256 wxPyBeginBlockThreads(); \
1257 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1258 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\
1259 wxPyEndBlockThreads(); \
1260 if (! found) \
1261 PCLASS::CBNAME(a, b, c, d); \
1262 } \
1263 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
1264 PCLASS::CBNAME(a, b, c, d); \
1265 }
1266
1267 //---------------------------------------------------------------------------
1268 //---------------------------------------------------------------------------
1269
1270 #define DEC_PYCALLBACK__STRING(CBNAME) \
1271 void CBNAME(const wxString& a); \
1272 void base_##CBNAME(const wxString& a)
1273
1274 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
1275 void CLASS::CBNAME(const wxString& a) { \
1276 bool found; \
1277 wxPyBeginBlockThreads(); \
1278 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1279 PyObject* s = wx2PyString(a); \
1280 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1281 Py_DECREF(s); \
1282 } \
1283 wxPyEndBlockThreads(); \
1284 if (! found) \
1285 PCLASS::CBNAME(a); \
1286 } \
1287 void CLASS::base_##CBNAME(const wxString& a) { \
1288 PCLASS::CBNAME(a); \
1289 }
1290
1291 //---------------------------------------------------------------------------
1292
1293 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
1294 bool CBNAME(const wxString& a); \
1295 bool base_##CBNAME(const wxString& a)
1296
1297 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
1298 bool CLASS::CBNAME(const wxString& a) { \
1299 bool rval=False; \
1300 bool found; \
1301 wxPyBeginBlockThreads(); \
1302 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1303 PyObject* s = wx2PyString(a); \
1304 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1305 Py_DECREF(s); \
1306 } \
1307 wxPyEndBlockThreads(); \
1308 if (! found) \
1309 rval = PCLASS::CBNAME(a); \
1310 return rval; \
1311 } \
1312 bool CLASS::base_##CBNAME(const wxString& a) { \
1313 return PCLASS::CBNAME(a); \
1314 }
1315
1316 //---------------------------------------------------------------------------
1317
1318 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
1319 bool CBNAME(const wxString& a)
1320
1321 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
1322 bool CLASS::CBNAME(const wxString& a) { \
1323 bool rval=False; \
1324 wxPyBeginBlockThreads(); \
1325 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1326 PyObject* s = wx2PyString(a); \
1327 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1328 Py_DECREF(s); \
1329 } \
1330 wxPyEndBlockThreads(); \
1331 return rval; \
1332 } \
1333
1334 //---------------------------------------------------------------------------
1335
1336 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
1337 wxString CBNAME(const wxString& a)
1338
1339 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
1340 wxString CLASS::CBNAME(const wxString& a) { \
1341 wxString rval; \
1342 wxPyBeginBlockThreads(); \
1343 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1344 PyObject* ro; \
1345 PyObject* s = wx2PyString(a); \
1346 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1347 Py_DECREF(s); \
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_STRING(CBNAME) \
1360 wxString CBNAME(const wxString& a); \
1361 wxString base_##CBNAME(const wxString& a)
1362
1363 #define IMP_PYCALLBACK_STRING_STRING(CLASS, PCLASS, CBNAME) \
1364 wxString CLASS::CBNAME(const wxString& a) { \
1365 wxString rval; \
1366 bool found; \
1367 wxPyBeginBlockThreads(); \
1368 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1369 PyObject* ro; \
1370 PyObject* s = wx2PyString(a); \
1371 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1372 Py_DECREF(s); \
1373 if (ro) { \
1374 rval = Py2wxString(ro); \
1375 Py_DECREF(ro); \
1376 } \
1377 } \
1378 if (! found) \
1379 rval = PCLASS::CBNAME(a); \
1380 wxPyEndBlockThreads(); \
1381 return rval; \
1382 } \
1383
1384 //---------------------------------------------------------------------------
1385
1386 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
1387 wxString CBNAME(const wxString& a,int b)
1388
1389 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
1390 wxString CLASS::CBNAME(const wxString& a,int b) { \
1391 wxString rval; \
1392 wxPyBeginBlockThreads(); \
1393 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1394 PyObject* ro; \
1395 PyObject* s = wx2PyString(a); \
1396 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oi)",s,b)); \
1397 Py_DECREF(s); \
1398 if (ro) { \
1399 rval = Py2wxString(ro); \
1400 Py_DECREF(ro); \
1401 } \
1402 } \
1403 wxPyEndBlockThreads(); \
1404 return rval; \
1405 } \
1406
1407 //---------------------------------------------------------------------------
1408
1409 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
1410 bool CBNAME(const wxString& a, const wxString& b); \
1411 bool base_##CBNAME(const wxString& a, const wxString& b)
1412
1413 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
1414 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
1415 bool rval=False; \
1416 bool found; \
1417 wxPyBeginBlockThreads(); \
1418 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1419 PyObject* s1 = wx2PyString(a); \
1420 PyObject* s2 = wx2PyString(b); \
1421 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",s1,s2)); \
1422 Py_DECREF(s1); \
1423 Py_DECREF(s2); \
1424 } \
1425 wxPyEndBlockThreads(); \
1426 if (! found) \
1427 rval = PCLASS::CBNAME(a, b); \
1428 return rval; \
1429 } \
1430 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
1431 return PCLASS::CBNAME(a, b); \
1432 }
1433
1434 //---------------------------------------------------------------------------
1435
1436 #define DEC_PYCALLBACK_STRING_(CBNAME) \
1437 wxString CBNAME(); \
1438 wxString base_##CBNAME()
1439
1440 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
1441 wxString CLASS::CBNAME() { \
1442 wxString rval; \
1443 bool found; \
1444 wxPyBeginBlockThreads(); \
1445 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1446 PyObject* ro; \
1447 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1448 if (ro) { \
1449 rval = Py2wxString(ro); \
1450 Py_DECREF(ro); \
1451 } \
1452 } \
1453 wxPyEndBlockThreads(); \
1454 if (! found) \
1455 rval = PCLASS::CBNAME(); \
1456 return rval; \
1457 } \
1458 wxString CLASS::base_##CBNAME() { \
1459 return PCLASS::CBNAME(); \
1460 }
1461
1462 //---------------------------------------------------------------------------
1463
1464 #define DEC_PYCALLBACK_STRING__const(CBNAME) \
1465 wxString CBNAME() const; \
1466 wxString base_##CBNAME() const;
1467
1468 #define IMP_PYCALLBACK_STRING__const(CLASS, PCLASS, CBNAME) \
1469 wxString CLASS::CBNAME() const { \
1470 wxString rval; \
1471 bool found; \
1472 wxPyBeginBlockThreads(); \
1473 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1474 PyObject* ro; \
1475 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1476 if (ro) { \
1477 rval = Py2wxString(ro); \
1478 Py_DECREF(ro); \
1479 } \
1480 } \
1481 wxPyEndBlockThreads(); \
1482 if (! found) \
1483 rval = PCLASS::CBNAME(); \
1484 return rval; \
1485 } \
1486 wxString CLASS::base_##CBNAME() const { \
1487 return PCLASS::CBNAME(); \
1488 }
1489
1490 //---------------------------------------------------------------------------
1491
1492 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
1493 wxString CBNAME()
1494
1495 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
1496 wxString CLASS::CBNAME() { \
1497 wxString rval; \
1498 wxPyBeginBlockThreads(); \
1499 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1500 PyObject* ro; \
1501 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1502 if (ro) { \
1503 rval = Py2wxString(ro); \
1504 Py_DECREF(ro); \
1505 } \
1506 } \
1507 wxPyEndBlockThreads(); \
1508 return rval; \
1509 }
1510
1511 //---------------------------------------------------------------------------
1512
1513 #define DEC_PYCALLBACK_STRING__constpure(CBNAME) \
1514 wxString CBNAME() const;
1515
1516 #define IMP_PYCALLBACK_STRING__constpure(CLASS, PCLASS, CBNAME) \
1517 wxString CLASS::CBNAME() const { \
1518 wxString rval; \
1519 wxPyBeginBlockThreads(); \
1520 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1521 PyObject* ro; \
1522 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1523 if (ro) { \
1524 rval = Py2wxString(ro); \
1525 Py_DECREF(ro); \
1526 } \
1527 } \
1528 wxPyEndBlockThreads(); \
1529 return rval; \
1530 }
1531
1532 //---------------------------------------------------------------------------
1533
1534 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
1535 bool CBNAME(const wxHtmlTag& a)
1536
1537
1538 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
1539 bool CLASS::CBNAME(const wxHtmlTag& a) { \
1540 bool rval=False; \
1541 wxPyBeginBlockThreads(); \
1542 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1543 PyObject* obj = wxPyConstructObject((void*)&a, wxT("wxHtmlTag"), 0); \
1544 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1545 Py_DECREF(obj); \
1546 } \
1547 wxPyEndBlockThreads(); \
1548 return rval; \
1549 }
1550
1551 //---------------------------------------------------------------------------
1552
1553 #define DEC_PYCALLBACK__CELLINTINT(CBNAME) \
1554 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y); \
1555 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y)
1556
1557 #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \
1558 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1559 bool found; \
1560 wxPyBeginBlockThreads(); \
1561 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1562 PyObject* obj = wxPyConstructObject((void*)cell, wxT("wxHtmlCell"), 0); \
1563 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \
1564 Py_DECREF(obj); \
1565 } \
1566 wxPyEndBlockThreads(); \
1567 if (! found) \
1568 PCLASS::CBNAME(cell, x, y); \
1569 } \
1570 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1571 PCLASS::CBNAME(cell, x, y); \
1572 }
1573
1574
1575 //---------------------------------------------------------------------------
1576
1577 #define DEC_PYCALLBACK__CELLINTINTME(CBNAME) \
1578 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e); \
1579 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e)
1580
1581 #define IMP_PYCALLBACK__CELLINTINTME(CLASS, PCLASS, CBNAME) \
1582 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1583 bool found; \
1584 wxPyBeginBlockThreads(); \
1585 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1586 PyObject* obj = wxPyConstructObject((void*)cell, wxT("wxHtmlCell"), 0); \
1587 PyObject* o2 = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
1588 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1589 Py_DECREF(obj); \
1590 Py_DECREF(o2); \
1591 } \
1592 wxPyEndBlockThreads(); \
1593 if (! found) \
1594 PCLASS::CBNAME(cell, x, y, e); \
1595 } \
1596 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1597 PCLASS::CBNAME(cell, x, y, e); \
1598 }
1599
1600
1601
1602 //---------------------------------------------------------------------------
1603
1604 #define DEC_PYCALLBACK___pure(CBNAME) \
1605 void CBNAME()
1606
1607
1608 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1609 void CLASS::CBNAME() { \
1610 wxPyBeginBlockThreads(); \
1611 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1612 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1613 wxPyEndBlockThreads(); \
1614 }
1615
1616 //---------------------------------------------------------------------------
1617
1618 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1619 wxSize CBNAME()
1620
1621
1622 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1623 wxSize CLASS::CBNAME() { \
1624 const char* errmsg = #CBNAME " should return a 2-tuple of integers or a wxSize object."; \
1625 wxSize rval(0,0); \
1626 wxPyBeginBlockThreads(); \
1627 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1628 PyObject* ro; \
1629 wxSize* ptr; \
1630 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1631 if (ro) { \
1632 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxSize"))) \
1633 rval = *ptr; \
1634 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
1635 PyObject* o1 = PySequence_GetItem(ro, 0); \
1636 PyObject* o2 = PySequence_GetItem(ro, 1); \
1637 if (PyNumber_Check(o1) && PyNumber_Check(o2)) \
1638 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
1639 else \
1640 PyErr_SetString(PyExc_TypeError, errmsg); \
1641 Py_DECREF(o1); \
1642 Py_DECREF(o2); \
1643 } \
1644 else { \
1645 PyErr_SetString(PyExc_TypeError, errmsg); \
1646 } \
1647 Py_DECREF(ro); \
1648 } \
1649 } \
1650 wxPyEndBlockThreads(); \
1651 return rval; \
1652 }
1653
1654 //---------------------------------------------------------------------------
1655
1656 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1657 bool CBNAME(wxWindow* a); \
1658 bool base_##CBNAME(wxWindow* a)
1659
1660
1661 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1662 bool CLASS::CBNAME(wxWindow* a) { \
1663 bool rval=False; \
1664 bool found; \
1665 wxPyBeginBlockThreads(); \
1666 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1667 PyObject* obj = wxPyMake_wxObject(a); \
1668 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1669 Py_DECREF(obj); \
1670 } \
1671 wxPyEndBlockThreads(); \
1672 if (! found) \
1673 rval = PCLASS::CBNAME(a); \
1674 return rval; \
1675 } \
1676 bool CLASS::base_##CBNAME(wxWindow* a) { \
1677 return PCLASS::CBNAME(a); \
1678 }
1679
1680 //---------------------------------------------------------------------------
1681
1682 #define DEC_PYCALLBACK_BOOL_WXWINDC(CBNAME) \
1683 bool CBNAME(wxWindow* a, wxDC& b); \
1684 bool base_##CBNAME(wxWindow* a, wxDC& b)
1685
1686
1687 #define IMP_PYCALLBACK_BOOL_WXWINDC(CLASS, PCLASS, CBNAME) \
1688 bool CLASS::CBNAME(wxWindow* a, wxDC& b) { \
1689 bool rval=False; \
1690 bool found; \
1691 wxPyBeginBlockThreads(); \
1692 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1693 PyObject* win = wxPyMake_wxObject(a); \
1694 PyObject* dc = wxPyMake_wxObject(&b); \
1695 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc));\
1696 Py_DECREF(win); \
1697 Py_DECREF(dc); \
1698 } \
1699 wxPyEndBlockThreads(); \
1700 if (! found) \
1701 rval = PCLASS::CBNAME(a, b); \
1702 return rval; \
1703 } \
1704 bool CLASS::base_##CBNAME(wxWindow* a, wxDC& b) { \
1705 return PCLASS::CBNAME(a, b); \
1706 }
1707
1708 //---------------------------------------------------------------------------
1709
1710 #define DEC_PYCALLBACK_VOID_WXWINBASE(CBNAME) \
1711 void CBNAME(wxWindowBase* a); \
1712 void base_##CBNAME(wxWindowBase* a)
1713
1714
1715 #define IMP_PYCALLBACK_VOID_WXWINBASE(CLASS, PCLASS, CBNAME) \
1716 void CLASS::CBNAME(wxWindowBase* a) { \
1717 bool found; \
1718 wxPyBeginBlockThreads(); \
1719 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1720 PyObject* obj = wxPyMake_wxObject(a); \
1721 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1722 Py_DECREF(obj); \
1723 } \
1724 wxPyEndBlockThreads(); \
1725 if (! found) \
1726 PCLASS::CBNAME(a); \
1727 } \
1728 void CLASS::base_##CBNAME(wxWindowBase* a) { \
1729 PCLASS::CBNAME(a); \
1730 }
1731
1732 //---------------------------------------------------------------------------
1733
1734 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1735 bool CBNAME(); \
1736 bool base_##CBNAME()
1737
1738
1739 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1740 bool CLASS::CBNAME() { \
1741 bool rval=False; \
1742 bool found; \
1743 wxPyBeginBlockThreads(); \
1744 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1745 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1746 wxPyEndBlockThreads(); \
1747 if (! found) \
1748 rval = PCLASS::CBNAME(); \
1749 return rval; \
1750 } \
1751 bool CLASS::base_##CBNAME() { \
1752 return PCLASS::CBNAME(); \
1753 }
1754
1755 //---------------------------------------------------------------------------
1756
1757 #define DEC_PYCALLBACK_BOOL_const(CBNAME) \
1758 bool CBNAME() const; \
1759 bool base_##CBNAME() const
1760
1761
1762 #define IMP_PYCALLBACK_BOOL_const(CLASS, PCLASS, CBNAME) \
1763 bool CLASS::CBNAME() const { \
1764 bool rval=False; \
1765 bool found; \
1766 wxPyBeginBlockThreads(); \
1767 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1768 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1769 wxPyEndBlockThreads(); \
1770 if (! found) \
1771 rval = PCLASS::CBNAME(); \
1772 return rval; \
1773 } \
1774 bool CLASS::base_##CBNAME() const { \
1775 return PCLASS::CBNAME(); \
1776 }
1777
1778 //---------------------------------------------------------------------------
1779
1780 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1781 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \
1782 wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1783
1784
1785 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1786 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1787 int rval=0; \
1788 bool found; \
1789 wxPyBeginBlockThreads(); \
1790 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1791 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1792 wxPyEndBlockThreads(); \
1793 if (! found) \
1794 rval = PCLASS::CBNAME(a, b, c); \
1795 return (wxDragResult)rval; \
1796 } \
1797 wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1798 return PCLASS::CBNAME(a, b, c); \
1799 }
1800
1801 //---------------------------------------------------------------------------
1802
1803 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1804 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location)
1805
1806 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1807 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1808 wxPyBeginBlockThreads(); \
1809 wxFSFile* rval=0; \
1810 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1811 PyObject* ro; \
1812 PyObject* obj = wxPyMake_wxObject(&a); \
1813 PyObject* s = wx2PyString(b); \
1814 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)",\
1815 obj, s)); \
1816 if (ro) { \
1817 wxPyConvertSwigPtr(ro, (void **)&rval, wxT("wxFSFILE"));\
1818 Py_DECREF(ro); \
1819 } \
1820 Py_DECREF(obj); \
1821 Py_DECREF(s); \
1822 } \
1823 wxPyEndBlockThreads(); \
1824 return rval; \
1825 };
1826
1827 //---------------------------------------------------------------------------
1828
1829 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1830 bool CBNAME(wxDragResult a); \
1831 bool base_##CBNAME(wxDragResult a)
1832
1833
1834 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1835 bool CLASS::CBNAME(wxDragResult a) { \
1836 bool rval=False; \
1837 bool found; \
1838 wxPyBeginBlockThreads(); \
1839 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1840 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a));\
1841 wxPyEndBlockThreads(); \
1842 if (! found) \
1843 rval = PCLASS::CBNAME(a); \
1844 return rval; \
1845 } \
1846 bool CLASS::base_##CBNAME(wxDragResult a) { \
1847 return PCLASS::CBNAME(a); \
1848 }
1849
1850 //---------------------------------------------------------------------------
1851
1852 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1853 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1854
1855
1856 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1857 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1858 wxPyBeginBlockThreads(); \
1859 int rval=0; \
1860 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1861 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1862 wxPyEndBlockThreads(); \
1863 return (wxDragResult)rval; \
1864 } \
1865
1866 //---------------------------------------------------------------------------
1867
1868 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1869 bool CBNAME(int a, int b, const wxString& c)
1870
1871 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1872 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1873 bool rval=False; \
1874 wxPyBeginBlockThreads(); \
1875 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1876 PyObject* s = wx2PyString(c); \
1877 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
1878 Py_DECREF(s); \
1879 } \
1880 wxPyEndBlockThreads(); \
1881 return rval; \
1882 } \
1883
1884 //---------------------------------------------------------------------------
1885
1886 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1887 size_t CBNAME(); \
1888 size_t base_##CBNAME()
1889
1890
1891 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1892 size_t CLASS::CBNAME() { \
1893 size_t rval=0; \
1894 bool found; \
1895 wxPyBeginBlockThreads(); \
1896 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1897 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1898 wxPyEndBlockThreads(); \
1899 if (! found) \
1900 rval = PCLASS::CBNAME(); \
1901 return rval; \
1902 } \
1903 size_t CLASS::base_##CBNAME() { \
1904 return PCLASS::CBNAME(); \
1905 }
1906
1907 //---------------------------------------------------------------------------
1908
1909 #define DEC_PYCALLBACK_SIZET__const(CBNAME) \
1910 size_t CBNAME() const; \
1911 size_t base_##CBNAME() const
1912
1913
1914 #define IMP_PYCALLBACK_SIZET__const(CLASS, PCLASS, CBNAME) \
1915 size_t CLASS::CBNAME() const { \
1916 size_t rval=0; \
1917 bool found; \
1918 wxPyBeginBlockThreads(); \
1919 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1920 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1921 wxPyEndBlockThreads(); \
1922 if (! found) \
1923 rval = PCLASS::CBNAME(); \
1924 return rval; \
1925 } \
1926 size_t CLASS::base_##CBNAME() const { \
1927 return PCLASS::CBNAME(); \
1928 }
1929
1930 //---------------------------------------------------------------------------
1931
1932 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1933 wxDataFormat CBNAME(size_t a); \
1934 wxDataFormat base_##CBNAME(size_t a)
1935
1936
1937 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1938 wxDataFormat CLASS::CBNAME(size_t a) { \
1939 wxDataFormat rval=0; \
1940 bool found; \
1941 wxPyBeginBlockThreads(); \
1942 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1943 PyObject* ro; \
1944 wxDataFormat* ptr; \
1945 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1946 if (ro) { \
1947 if (wxPyCOnvertSwigPtr(ro, (void **)&ptr, wxT("wxDataFormat"))) \
1948 rval = *ptr; \
1949 Py_DECREF(ro); \
1950 } \
1951 } \
1952 wxPyEndBlockThreads(); \
1953 if (! found) \
1954 rval = PCLASS::CBNAME(a); \
1955 return rval; \
1956 } \
1957 wxDataFormat CLASS::base_##CBNAME(size_t a) { \
1958 return PCLASS::CBNAME(a); \
1959 }
1960
1961 //---------------------------------------------------------------------------
1962
1963 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1964 void CBNAME(const Type& a); \
1965 void base_##CBNAME(const Type& a)
1966
1967
1968 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1969 void CLASS::CBNAME(const Type& a) { \
1970 bool found; \
1971 wxPyBeginBlockThreads(); \
1972 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1973 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1974 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1975 Py_DECREF(obj); \
1976 } \
1977 wxPyEndBlockThreads(); \
1978 if (! found) \
1979 PCLASS::CBNAME(a); \
1980 } \
1981 void CLASS::base_##CBNAME(const Type& a) { \
1982 PCLASS::CBNAME(a); \
1983 }
1984
1985
1986 //---------------------------------------------------------------------------
1987
1988 #define DEC_PYCALLBACK__any(CBNAME, Type) \
1989 void CBNAME(Type& a); \
1990 void base_##CBNAME(Type& a)
1991
1992
1993 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1994 void CLASS::CBNAME(Type& a) { \
1995 bool found; \
1996 wxPyBeginBlockThreads(); \
1997 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1998 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1999 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2000 Py_DECREF(obj); \
2001 } \
2002 wxPyEndBlockThreads(); \
2003 if (! found) \
2004 PCLASS::CBNAME(a); \
2005 } \
2006 void CLASS::base_##CBNAME(Type& a) { \
2007 PCLASS::CBNAME(a); \
2008 }
2009
2010 //---------------------------------------------------------------------------
2011
2012 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
2013 bool CBNAME(Type& a); \
2014 bool base_##CBNAME(Type& a)
2015
2016
2017 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
2018 bool CLASS::CBNAME(Type& a) { \
2019 bool rv=False; \
2020 bool found; \
2021 wxPyBeginBlockThreads(); \
2022 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2023 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
2024 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2025 Py_DECREF(obj); \
2026 } \
2027 wxPyEndBlockThreads(); \
2028 if (! found) \
2029 rv = PCLASS::CBNAME(a); \
2030 return rv; \
2031 } \
2032 bool CLASS::base_##CBNAME(Type& a) { \
2033 return PCLASS::CBNAME(a); \
2034 }
2035
2036 //---------------------------------------------------------------------------
2037
2038 #define DEC_PYCALLBACK_bool_anypure(CBNAME, Type) \
2039 bool CBNAME(Type& a)
2040
2041
2042 #define IMP_PYCALLBACK_bool_anypure(CLASS, PCLASS, CBNAME, Type) \
2043 bool CLASS::CBNAME(Type& a) { \
2044 bool rv=False; \
2045 wxPyBeginBlockThreads(); \
2046 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2047 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
2048 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2049 Py_DECREF(obj); \
2050 } \
2051 wxPyEndBlockThreads(); \
2052 return rv; \
2053 } \
2054
2055 //---------------------------------------------------------------------------
2056
2057 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
2058 wxString CBNAME(long a, long b) const; \
2059 wxString base_##CBNAME(long a, long b) const
2060
2061 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
2062 wxString CLASS::CBNAME(long a, long b) const { \
2063 wxString rval; \
2064 bool found; \
2065 wxPyBeginBlockThreads(); \
2066 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2067 PyObject* ro; \
2068 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
2069 if (ro) { \
2070 rval = Py2wxString(ro); \
2071 Py_DECREF(ro); \
2072 } \
2073 } \
2074 wxPyEndBlockThreads(); \
2075 if (! found) \
2076 rval = PCLASS::CBNAME(a,b); \
2077 return rval; \
2078 } \
2079 wxString CLASS::base_##CBNAME(long a, long b) const { \
2080 return PCLASS::CBNAME(a,b); \
2081 }
2082
2083 //---------------------------------------------------------------------------
2084
2085 #define DEC_PYCALLBACK_INT_LONG(CBNAME) \
2086 int CBNAME(long a) const; \
2087 int base_##CBNAME(long a) const
2088
2089
2090 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
2091 int CLASS::CBNAME(long a) const { \
2092 int rval=-1; \
2093 bool found; \
2094 wxPyBeginBlockThreads(); \
2095 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2096 PyObject* ro; \
2097 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2098 if (ro) { \
2099 rval = PyInt_AsLong(ro); \
2100 Py_DECREF(ro); \
2101 } \
2102 } \
2103 wxPyEndBlockThreads(); \
2104 if (! found) \
2105 rval = PCLASS::CBNAME(a); \
2106 return rval; \
2107 } \
2108 int CLASS::base_##CBNAME(long a) const { \
2109 return PCLASS::CBNAME(a); \
2110 }
2111
2112
2113 //---------------------------------------------------------------------------
2114
2115 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
2116 wxListItemAttr* CBNAME(long a) const; \
2117 wxListItemAttr* base_##CBNAME(long a) const
2118
2119
2120 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
2121 wxListItemAttr *CLASS::CBNAME(long a) const { \
2122 wxListItemAttr *rval = NULL; \
2123 bool found; \
2124 wxPyBeginBlockThreads(); \
2125 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2126 PyObject* ro; \
2127 wxListItemAttr* ptr; \
2128 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2129 if (ro) { \
2130 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxListItemAttr")))\
2131 rval = ptr; \
2132 Py_DECREF(ro); \
2133 } \
2134 } \
2135 wxPyEndBlockThreads(); \
2136 if (! found) \
2137 rval = PCLASS::CBNAME(a); \
2138 return rval; \
2139 } \
2140 wxListItemAttr *CLASS::base_##CBNAME(long a) const { \
2141 return PCLASS::CBNAME(a); \
2142 }
2143
2144 //---------------------------------------------------------------------------
2145
2146 #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
2147 bool CBNAME(wxMouseEvent& e); \
2148 bool base_##CBNAME(wxMouseEvent& e)
2149
2150 #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
2151 bool CLASS::CBNAME(wxMouseEvent& e) { \
2152 bool rval=False; \
2153 bool found; \
2154 wxPyBeginBlockThreads(); \
2155 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2156 PyObject* ro; \
2157 PyObject* obj = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
2158 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
2159 if (ro) { \
2160 rval = PyInt_AsLong(ro); \
2161 Py_DECREF(ro); \
2162 } \
2163 Py_DECREF(obj); \
2164 } \
2165 wxPyEndBlockThreads(); \
2166 if (! found) \
2167 return PCLASS::CBNAME(e); \
2168 return rval; \
2169 } \
2170 bool CLASS::base_##CBNAME(wxMouseEvent& e) { \
2171 return PCLASS::CBNAME(e); \
2172 }
2173
2174
2175 //---------------------------------------------------------------------------
2176
2177 #define DEC_PYCALLBACK_WIZPG__pure(CBNAME) \
2178 wxWizardPage* CBNAME() const
2179
2180 #define IMP_PYCALLBACK_WIZPG__pure(CLASS, PCLASS, CBNAME) \
2181 wxWizardPage* CLASS::CBNAME() const { \
2182 wxWizardPage* rv = NULL; \
2183 wxPyBeginBlockThreads(); \
2184 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2185 PyObject* ro; \
2186 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2187 if (ro) { \
2188 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxWizardPage")); \
2189 Py_DECREF(ro); \
2190 } \
2191 } \
2192 wxPyEndBlockThreads(); \
2193 return rv; \
2194 }
2195
2196 //---------------------------------------------------------------------------
2197
2198 #define DEC_PYCALLBACK_BITMAP__pure(CBNAME) \
2199 wxBitmap CBNAME() const
2200
2201 #define IMP_PYCALLBACK_BITMAP__pure(CLASS, PCLASS, CBNAME) \
2202 wxBitmap CLASS::CBNAME() const { \
2203 wxBitmap rv; \
2204 wxPyBeginBlockThreads(); \
2205 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2206 PyObject* ro; \
2207 wxBitmap* ptr; \
2208 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2209 if (ro) { \
2210 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxBitmap"))) \
2211 rv = *ptr; \
2212 Py_DECREF(ro); \
2213 } \
2214 } \
2215 wxPyEndBlockThreads(); \
2216 return rv; \
2217 }
2218
2219 //---------------------------------------------------------------------------
2220
2221 #define DEC_PYCALLBACK_OBJECT__pure(CBNAME) \
2222 wxObject* CBNAME()
2223
2224 #define IMP_PYCALLBACK_OBJECT__pure(CLASS, PCLASS, CBNAME) \
2225 wxObject* CLASS::CBNAME() { \
2226 wxObject* rv = NULL; \
2227 wxPyBeginBlockThreads(); \
2228 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2229 PyObject* ro; \
2230 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2231 if (ro) { \
2232 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2233 Py_DECREF(ro); \
2234 } \
2235 } \
2236 wxPyEndBlockThreads(); \
2237 return rv; \
2238 }
2239
2240 //---------------------------------------------------------------------------
2241
2242 #define DEC_PYCALLBACK_OBJECT_STRING_pure(CBNAME) \
2243 wxObject* CBNAME(const wxString& a)
2244
2245 #define IMP_PYCALLBACK_OBJECT_STRING_pure(CLASS, PCLASS, CBNAME) \
2246 wxObject* CLASS::CBNAME(const wxString& a) { \
2247 wxObject* rv = NULL; \
2248 wxPyBeginBlockThreads(); \
2249 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2250 PyObject* so = wx2PyString(a); \
2251 PyObject* ro; \
2252 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", so)); \
2253 if (ro) { \
2254 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2255 Py_DECREF(ro); \
2256 } \
2257 Py_DECREF(so); \
2258 } \
2259 wxPyEndBlockThreads(); \
2260 return rv; \
2261 }
2262
2263 //---------------------------------------------------------------------------
2264
2265 #define DEC_PYCALLBACK_BOOL_NODE_pure(CBNAME) \
2266 bool CBNAME(wxXmlNode* a)
2267
2268
2269 #define IMP_PYCALLBACK_BOOL_NODE_pure(CLASS, PCLASS, CBNAME) \
2270 bool CLASS::CBNAME(wxXmlNode* a) { \
2271 bool rv=False; \
2272 wxPyBeginBlockThreads(); \
2273 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2274 PyObject* obj = wxPyConstructObject((void*)a, wxT("wxXmlNode"), 0); \
2275 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2276 Py_DECREF(obj); \
2277 } \
2278 wxPyEndBlockThreads(); \
2279 return rv; \
2280 } \
2281
2282 //---------------------------------------------------------------------------
2283
2284 #define DEC_PYCALLBACK_COORD_SIZET_constpure(CBNAME) \
2285 wxCoord CBNAME(size_t a) const
2286
2287
2288 #define IMP_PYCALLBACK_COORD_SIZET_constpure(CLASS, PCLASS, CBNAME) \
2289 wxCoord CLASS::CBNAME(size_t a) const { \
2290 wxCoord rval=0; \
2291 bool found; \
2292 wxPyBeginBlockThreads(); \
2293 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2294 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
2295 } \
2296 wxPyEndBlockThreads(); \
2297 return rval; \
2298 } \
2299
2300 //---------------------------------------------------------------------------
2301
2302 #define DEC_PYCALLBACK_VOID_SIZETSIZET_const(CBNAME) \
2303 void CBNAME(size_t a, size_t b) const; \
2304 void base_##CBNAME(size_t a, size_t b) const
2305
2306
2307 #define IMP_PYCALLBACK_VOID_SIZETSIZET_const(CLASS, PCLASS, CBNAME) \
2308 void CLASS::CBNAME(size_t a, size_t b) const { \
2309 bool found; \
2310 wxPyBeginBlockThreads(); \
2311 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2312 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
2313 wxPyEndBlockThreads(); \
2314 if (! found) \
2315 PCLASS::CBNAME(a,b); \
2316 } \
2317 void CLASS::base_##CBNAME(size_t a, size_t b) const { \
2318 PCLASS::CBNAME(a,b); \
2319 }
2320
2321 //---------------------------------------------------------------------------
2322
2323 #define DEC_PYCALLBACK_COORD_const(CBNAME) \
2324 wxCoord CBNAME() const; \
2325 wxCoord base_##CBNAME() const
2326
2327
2328 #define IMP_PYCALLBACK_COORD_const(CLASS, PCLASS, CBNAME) \
2329 wxCoord CLASS::CBNAME() const { \
2330 wxCoord rval=0; \
2331 bool found; \
2332 wxPyBeginBlockThreads(); \
2333 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2334 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
2335 wxPyEndBlockThreads(); \
2336 if (! found) \
2337 rval = PCLASS::CBNAME(); \
2338 return rval; \
2339 } \
2340 wxCoord CLASS::base_##CBNAME() const { \
2341 return PCLASS::CBNAME(); \
2342 }
2343
2344 //---------------------------------------------------------------------------
2345
2346 #define DEC_PYCALLBACK__DCRECTSIZET_constpure(CBNAME) \
2347 void CBNAME(wxDC& a, const wxRect& b, size_t c) const;
2348
2349
2350 #define IMP_PYCALLBACK__DCRECTSIZET_constpure(CLASS, PCLASS, CBNAME) \
2351 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2352 bool found; \
2353 wxPyBeginBlockThreads(); \
2354 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2355 PyObject* obj = wxPyMake_wxObject(&a); \
2356 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2357 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2358 Py_DECREF(obj); \
2359 } \
2360 wxPyEndBlockThreads(); \
2361 } \
2362
2363 //---------------------------------------------------------------------------
2364
2365 #define DEC_PYCALLBACK__DCRECTSIZET_const(CBNAME) \
2366 void CBNAME(wxDC& a, const wxRect& b, size_t c) const; \
2367 void base_##CBNAME(wxDC& a, const wxRect& b, size_t c) const
2368
2369
2370 #define IMP_PYCALLBACK__DCRECTSIZET_const(CLASS, PCLASS, CBNAME) \
2371 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2372 bool found; \
2373 wxPyBeginBlockThreads(); \
2374 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2375 PyObject* obj = wxPyMake_wxObject(&a); \
2376 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2377 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2378 Py_DECREF(obj); \
2379 } \
2380 wxPyEndBlockThreads(); \
2381 if (! found) \
2382 PCLASS::CBNAME(a,b,c); \
2383 } \
2384 void CLASS::base_##CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2385 PCLASS::CBNAME(a,b,c); \
2386 }
2387
2388 //---------------------------------------------------------------------------
2389
2390
2391 #define DEC_PYCALLBACK_STRING_SIZET(CBNAME) \
2392 wxString CBNAME(size_t a) const; \
2393 wxString base_##CBNAME(size_t a) const
2394
2395 #define IMP_PYCALLBACK_STRING_SIZET(CLASS, PCLASS, CBNAME) \
2396 wxString CLASS::CBNAME(size_t a) const { \
2397 wxString rval; \
2398 bool found; \
2399 wxPyBeginBlockThreads(); \
2400 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2401 PyObject* ro; \
2402 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2403 if (ro) { \
2404 rval = Py2wxString(ro); \
2405 Py_DECREF(ro); \
2406 } \
2407 } \
2408 wxPyEndBlockThreads(); \
2409 if (! found) \
2410 rval = PCLASS::CBNAME(a); \
2411 return rval; \
2412 } \
2413 wxString CLASS::base_##CBNAME(size_t a) const { \
2414 return PCLASS::CBNAME(a); \
2415 }
2416
2417 //---------------------------------------------------------------------------
2418
2419 #define DEC_PYCALLBACK_STRING_SIZET_pure(CBNAME) \
2420 wxString CBNAME(size_t a) const
2421
2422 #define IMP_PYCALLBACK_STRING_SIZET_pure(CLASS, PCLASS, CBNAME) \
2423 wxString CLASS::CBNAME(size_t a) const { \
2424 wxString rval; \
2425 bool found; \
2426 wxPyBeginBlockThreads(); \
2427 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2428 PyObject* ro; \
2429 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2430 if (ro) { \
2431 rval = Py2wxString(ro); \
2432 Py_DECREF(ro); \
2433 } \
2434 } \
2435 wxPyEndBlockThreads(); \
2436 return rval; \
2437 } \
2438
2439 //---------------------------------------------------------------------------
2440
2441 #endif