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