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