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