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