]> git.saurik.com Git - wxWidgets.git/blob - wxPython/include/wx/wxPython/wxPython_int.h
2d42ea5e51772e62f24ad4431055839ce39c2e27
[wxWidgets.git] / wxPython / include / wx / wxPython / wxPython_int.h
1 ////////////////////////////////////////////////////////////////////////////
2 // Name: wxPython_int.h (int == internal)
3 // Purpose: Helper functions/classes for the wxPython extension module
4 // This header should only be inclued directly by those source
5 // modules included in the wx._core module. All others should
6 // include wx/wxPython/wxPython.h instead.
7 //
8 // Author: Robin Dunn
9 //
10 // Created: 1-July-1997
11 // RCS-ID: $Id$
12 // Copyright: (c) 1998 by Total Control Software
13 // Licence: wxWindows license
14 /////////////////////////////////////////////////////////////////////////////
15
16 #ifndef __wxp_helpers__
17 #define __wxp_helpers__
18
19 #include <wx/wx.h>
20
21 #include <wx/busyinfo.h>
22 #include <wx/caret.h>
23 #include <wx/clipbrd.h>
24 #include <wx/colordlg.h>
25 #include <wx/config.h>
26 #include <wx/cshelp.h>
27 #include <wx/dcbuffer.h>
28 #include <wx/dcmirror.h>
29 #include <wx/dcps.h>
30 #include <wx/dirctrl.h>
31 #include <wx/dirdlg.h>
32 #include <wx/dnd.h>
33 #include <wx/docview.h>
34 #include <wx/encconv.h>
35 #include <wx/fdrepdlg.h>
36 #include <wx/fileconf.h>
37 #include <wx/filesys.h>
38 #include <wx/fontdlg.h>
39 #include <wx/fs_inet.h>
40 #include <wx/fs_mem.h>
41 #include <wx/fs_zip.h>
42 #include <wx/gbsizer.h>
43 #include <wx/geometry.h>
44 #include <wx/htmllbox.h>
45 #include <wx/image.h>
46 #include <wx/imaglist.h>
47 #include <wx/intl.h>
48 #include <wx/laywin.h>
49 #include <wx/listbook.h>
50 #include <wx/minifram.h>
51 #include <wx/notebook.h>
52 #include <wx/print.h>
53 #include <wx/printdlg.h>
54 #include <wx/process.h>
55 #include <wx/progdlg.h>
56 #include <wx/sashwin.h>
57 #include <wx/spinbutt.h>
58 #include <wx/spinctrl.h>
59 #include <wx/splash.h>
60 #include <wx/splitter.h>
61 #include <wx/statline.h>
62 #include <wx/stream.h>
63 #include <wx/sysopt.h>
64 #include <wx/taskbar.h>
65 #include <wx/tglbtn.h>
66 #include <wx/tipwin.h>
67 #include <wx/tooltip.h>
68 #include <wx/vlbox.h>
69 #include <wx/vscroll.h>
70
71
72 #ifdef _MSC_VER
73 # pragma warning(disable:4800)
74 # pragma warning(disable:4190)
75 #endif
76
77 #ifdef __WXMAC__ // avoid a bug in Carbon headers
78 #define scalb scalbn
79 #endif
80
81 //---------------------------------------------------------------------------
82
83 typedef unsigned char byte;
84 typedef wxPoint2DDouble wxPoint2D;
85
86 const bool True = true;
87 const bool False = false;
88
89
90 #ifndef wxPyUSE_EXPORTED_API
91
92 void __wxPyPreStart(PyObject*);
93 void __wxPyCleanup();
94 PyObject* __wxPySetDictionary(PyObject*, PyObject* args);
95 PyObject* __wxPyFixStockObjects(PyObject*, PyObject* args);
96
97
98 void wxPyEventThunker(wxObject*, wxEvent& event);
99
100
101 bool wxPyCheckSwigType(const wxChar* className);
102 PyObject* wxPyConstructObject(void* ptr,
103 const wxChar* className,
104 int setThisOwn=0);
105 bool wxPyConvertSwigPtr(PyObject* obj, void **ptr,
106 const wxChar* className);
107 PyObject* wxPyMakeSwigPtr(void* ptr, const wxChar* classname);
108
109
110 PyObject* wx2PyString(const wxString& src);
111 wxString Py2wxString(PyObject* source);
112
113 PyObject* wxPyMake_wxObject(wxObject* source, bool checkEvtHandler=True);
114 PyObject* wxPyMake_wxSizer(wxSizer* source);
115 void wxPyPtrTypeMap_Add(const char* commonName, const char* ptrName);
116
117 PyObject* wxPy_ConvertList(wxListBase* list);
118 long wxPyGetWinHandle(wxWindow* win);
119
120 void wxPy_ReinitStockObjects(int pass);
121
122 bool wxPyInstance_Check(PyObject* obj);
123 bool wxPySwigInstance_Check(PyObject* obj);
124
125
126 #endif // wxPyUSE_EXPORTED_API
127 //---------------------------------------------------------------------------
128
129 // if we want to handle threads and Python threads are available...
130 #if defined(WXP_USE_THREAD) && defined(WITH_THREAD)
131 #define WXP_WITH_THREAD
132 #else // no Python threads...
133 #undef WXP_WITH_THREAD
134 #endif
135
136 #ifndef wxPyUSE_EXPORTED_API
137
138 // For Python --> C++
139 PyThreadState* wxPyBeginAllowThreads();
140 void wxPyEndAllowThreads(PyThreadState* state);
141
142 // For C++ --> Python
143 void wxPyBeginBlockThreads();
144 void wxPyEndBlockThreads();
145
146 #endif // wxPyUSE_EXPORTED_API
147
148 #define wxPyBLOCK_THREADS(stmt) wxPyBeginBlockThreads(); stmt; wxPyEndBlockThreads()
149
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
320 // Make SunCC happy and make typedef's for these that are extern "C"
321 typedef swig_type_info* (*p_SWIG_Python_TypeRegister_t)(swig_type_info *);
322 typedef swig_type_info* (*p_SWIG_Python_TypeCheck_t)(char *c, swig_type_info *);
323 typedef void* (*p_SWIG_Python_TypeCast_t)(swig_type_info *, void *);
324 typedef swig_type_info* (*p_SWIG_Python_TypeDynamicCast_t)(swig_type_info *, void **);
325 typedef const char* (*p_SWIG_Python_TypeName_t)(const swig_type_info *);
326 typedef swig_type_info* (*p_SWIG_Python_TypeQuery_t)(const char *);
327 typedef void (*p_SWIG_Python_TypeClientData_t)(swig_type_info *, void *);
328 typedef PyObject* (*p_SWIG_Python_newvarlink_t)(void);
329 typedef void (*p_SWIG_Python_addvarlink_t)(PyObject *, char *, PyObject *(*)(void), int (*)(PyObject *));
330 typedef int (*p_SWIG_Python_ConvertPtr_t)(PyObject *, void **, swig_type_info *, int);
331 typedef int (*p_SWIG_Python_ConvertPacked_t)(PyObject *, void *, int sz, swig_type_info *, int);
332 typedef char* (*p_SWIG_Python_PackData_t)(char *c, void *, int);
333 typedef char* (*p_SWIG_Python_UnpackData_t)(char *c, void *, int);
334 typedef PyObject* (*p_SWIG_Python_NewPointerObj_t)(void *, swig_type_info *,int own);
335 typedef PyObject* (*p_SWIG_Python_NewPackedObj_t)(void *, int sz, swig_type_info *);
336 typedef void (*p_SWIG_Python_InstallConstants_t)(PyObject *d, swig_const_info constants[]);
337 typedef void* (*p_SWIG_Python_MustGetPtr_t)(PyObject *, swig_type_info *, int, int);
338
339
340 struct wxPyCoreAPI {
341
342 p_SWIG_Python_TypeRegister_t p_SWIG_Python_TypeRegister;
343 p_SWIG_Python_TypeCheck_t p_SWIG_Python_TypeCheck;
344 p_SWIG_Python_TypeCast_t p_SWIG_Python_TypeCast;
345 p_SWIG_Python_TypeDynamicCast_t p_SWIG_Python_TypeDynamicCast;
346 p_SWIG_Python_TypeName_t p_SWIG_Python_TypeName;
347 p_SWIG_Python_TypeQuery_t p_SWIG_Python_TypeQuery;
348 p_SWIG_Python_TypeClientData_t p_SWIG_Python_TypeClientData;
349 p_SWIG_Python_newvarlink_t p_SWIG_Python_newvarlink;
350 p_SWIG_Python_addvarlink_t p_SWIG_Python_addvarlink;
351 p_SWIG_Python_ConvertPtr_t p_SWIG_Python_ConvertPtr;
352 p_SWIG_Python_ConvertPacked_t p_SWIG_Python_ConvertPacked;
353 p_SWIG_Python_PackData_t p_SWIG_Python_PackData;
354 p_SWIG_Python_UnpackData_t p_SWIG_Python_UnpackData;
355 p_SWIG_Python_NewPointerObj_t p_SWIG_Python_NewPointerObj;
356 p_SWIG_Python_NewPackedObj_t p_SWIG_Python_NewPackedObj;
357 p_SWIG_Python_InstallConstants_t p_SWIG_Python_InstallConstants;
358 p_SWIG_Python_MustGetPtr_t p_SWIG_Python_MustGetPtr;
359
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
583 static bool GetMacSupportPCMenuShortcuts();
584 static long GetMacAboutMenuItemId();
585 static long GetMacPreferencesMenuItemId();
586 static long GetMacExitMenuItemId();
587 static wxString GetMacHelpMenuTitleName();
588
589 static void SetMacSupportPCMenuShortcuts(bool val);
590 static void SetMacAboutMenuItemId(long val);
591 static void SetMacPreferencesMenuItemId(long val);
592 static void SetMacExitMenuItemId(long val);
593 static void SetMacHelpMenuTitleName(const wxString& val);
594
595
596 void _BootstrapApp();
597
598 // implementation only
599 void SetStartupComplete(bool val) { m_startupComplete = val; };
600
601 PYPRIVATE;
602 int m_assertMode;
603 bool m_startupComplete;
604 };
605
606 extern wxPyApp *wxPythonApp;
607
608
609 //----------------------------------------------------------------------
610 // These macros are used to implement the virtual methods that should
611 // redirect to a Python method if one exists. The names designate the
612 // return type, if any, as well as any parameter types.
613 //---------------------------------------------------------------------------
614
615 #define DEC_PYCALLBACK__(CBNAME) \
616 void CBNAME(); \
617 void base_##CBNAME()
618
619
620 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
621 void CLASS::CBNAME() { \
622 bool found; \
623 wxPyBeginBlockThreads(); \
624 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
625 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
626 wxPyEndBlockThreads(); \
627 if (! found) \
628 PCLASS::CBNAME(); \
629 } \
630 void CLASS::base_##CBNAME() { \
631 PCLASS::CBNAME(); \
632 }
633
634 //---------------------------------------------------------------------------
635
636 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
637 bool CBNAME(int a, int b); \
638 bool base_##CBNAME(int a, int b)
639
640
641 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
642 bool CLASS::CBNAME(int a, int b) { \
643 bool rval=False, found; \
644 wxPyBeginBlockThreads(); \
645 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
646 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
647 wxPyEndBlockThreads(); \
648 if (! found) \
649 rval = PCLASS::CBNAME(a,b); \
650 return rval; \
651 } \
652 bool CLASS::base_##CBNAME(int a, int b) { \
653 return PCLASS::CBNAME(a,b); \
654 }
655
656 //---------------------------------------------------------------------------
657
658 #define DEC_PYCALLBACK_VOID_(CBNAME) \
659 void CBNAME(); \
660 void base_##CBNAME()
661
662
663 #define IMP_PYCALLBACK_VOID_(CLASS, PCLASS, CBNAME) \
664 void CLASS::CBNAME() { \
665 bool found; \
666 wxPyBeginBlockThreads(); \
667 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
668 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
669 wxPyEndBlockThreads(); \
670 if (! found) \
671 PCLASS::CBNAME(); \
672 } \
673 void CLASS::base_##CBNAME() { \
674 PCLASS::CBNAME(); \
675 }
676
677 //---------------------------------------------------------------------------
678
679 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
680 void CBNAME(int a, int b); \
681 void base_##CBNAME(int a, int b)
682
683
684 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
685 void CLASS::CBNAME(int a, int b) { \
686 bool found; \
687 wxPyBeginBlockThreads(); \
688 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
689 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
690 wxPyEndBlockThreads(); \
691 if (! found) \
692 PCLASS::CBNAME(a,b); \
693 } \
694 void CLASS::base_##CBNAME(int a, int b) { \
695 PCLASS::CBNAME(a,b); \
696 }
697
698 //---------------------------------------------------------------------------
699
700 #define DEC_PYCALLBACK_VOID_INT(CBNAME) \
701 void CBNAME(int a); \
702 void base_##CBNAME(int a)
703
704
705 #define IMP_PYCALLBACK_VOID_INT(CLASS, PCLASS, CBNAME) \
706 void CLASS::CBNAME(int a) { \
707 bool found; \
708 wxPyBeginBlockThreads(); \
709 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
710 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
711 wxPyEndBlockThreads(); \
712 if (! found) \
713 PCLASS::CBNAME(a); \
714 } \
715 void CLASS::base_##CBNAME(int a) { \
716 PCLASS::CBNAME(a); \
717 }
718
719 //---------------------------------------------------------------------------
720
721 #define DEC_PYCALLBACK_VOID_INT4(CBNAME) \
722 void CBNAME(int a, int b, int c, int d); \
723 void base_##CBNAME(int a, int b, int c, int d)
724
725
726 #define IMP_PYCALLBACK_VOID_INT4(CLASS, PCLASS, CBNAME) \
727 void CLASS::CBNAME(int a, int b, int c, int d) { \
728 bool found; \
729 wxPyBeginBlockThreads(); \
730 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
731 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiii)",a,b,c,d)); \
732 wxPyEndBlockThreads(); \
733 if (! found) \
734 PCLASS::CBNAME(a,b,c,d); \
735 } \
736 void CLASS::base_##CBNAME(int a, int b, int c, int d) { \
737 PCLASS::CBNAME(a,b,c,d); \
738 }
739
740 //---------------------------------------------------------------------------
741 #define DEC_PYCALLBACK_VOID_INT5(CBNAME) \
742 void CBNAME(int a, int b, int c, int d, int e); \
743 void base_##CBNAME(int a, int b, int c, int d, int e)
744
745
746 #define IMP_PYCALLBACK_VOID_INT5(CLASS, PCLASS, CBNAME) \
747 void CLASS::CBNAME(int a, int b, int c, int d, int e) { \
748 bool found; \
749 wxPyBeginBlockThreads(); \
750 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
751 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiiii)",a,b,c,d,e)); \
752 wxPyEndBlockThreads(); \
753 if (! found) \
754 PCLASS::CBNAME(a,b,c,d,e); \
755 } \
756 void CLASS::base_##CBNAME(int a, int b, int c, int d, int e) { \
757 PCLASS::CBNAME(a,b,c,d,e); \
758 }
759
760 //---------------------------------------------------------------------------
761
762 #define DEC_PYCALLBACK_VOID_INTPINTP_const(CBNAME) \
763 void CBNAME(int* a, int* b) const; \
764 void base_##CBNAME(int* a, int* b) const
765
766
767 #define IMP_PYCALLBACK_VOID_INTPINTP_const(CLASS, PCLASS, CBNAME) \
768 void CLASS::CBNAME(int* a, int* b) const { \
769 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
770 bool found; \
771 wxPyBeginBlockThreads(); \
772 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
773 PyObject* ro; \
774 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
775 if (ro) { \
776 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
777 PyObject* o1 = PySequence_GetItem(ro, 0); \
778 PyObject* o2 = PySequence_GetItem(ro, 1); \
779 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
780 *a = PyInt_AsLong(o1); *b = PyInt_AsLong(o2); \
781 } \
782 else \
783 PyErr_SetString(PyExc_TypeError, errmsg); \
784 Py_DECREF(o1); \
785 Py_DECREF(o2); \
786 } \
787 else { \
788 PyErr_SetString(PyExc_TypeError, errmsg); \
789 } \
790 Py_DECREF(ro); \
791 } \
792 } \
793 wxPyEndBlockThreads(); \
794 if (! found) \
795 PCLASS::CBNAME(a,b); \
796 } \
797 void CLASS::base_##CBNAME(int* a, int* b) const { \
798 PCLASS::CBNAME(a,b); \
799 }
800
801
802 //---------------------------------------------------------------------------
803
804 #define DEC_PYCALLBACK_SIZE_const(CBNAME) \
805 wxSize CBNAME() const; \
806 wxSize base_##CBNAME() const
807
808
809 #define IMP_PYCALLBACK_SIZE_const(CLASS, PCLASS, CBNAME) \
810 wxSize CLASS::CBNAME() const { \
811 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
812 bool found; wxSize rval(0,0); \
813 wxPyBeginBlockThreads(); \
814 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
815 PyObject* ro; \
816 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
817 if (ro) { \
818 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
819 PyObject* o1 = PySequence_GetItem(ro, 0); \
820 PyObject* o2 = PySequence_GetItem(ro, 1); \
821 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
822 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
823 } \
824 else \
825 PyErr_SetString(PyExc_TypeError, errmsg); \
826 Py_DECREF(o1); \
827 Py_DECREF(o2); \
828 } \
829 else { \
830 PyErr_SetString(PyExc_TypeError, errmsg); \
831 } \
832 Py_DECREF(ro); \
833 } \
834 } \
835 wxPyEndBlockThreads(); \
836 if (! found) \
837 return PCLASS::CBNAME(); \
838 else \
839 return rval; \
840 } \
841 wxSize CLASS::base_##CBNAME() const { \
842 return PCLASS::CBNAME(); \
843 }
844
845
846 //---------------------------------------------------------------------------
847
848 #define DEC_PYCALLBACK_BOOL_BOOL(CBNAME) \
849 bool CBNAME(bool a); \
850 bool base_##CBNAME(bool a)
851
852
853 #define IMP_PYCALLBACK_BOOL_BOOL(CLASS, PCLASS, CBNAME) \
854 bool CLASS::CBNAME(bool a) { \
855 bool rval=False, found; \
856 wxPyBeginBlockThreads(); \
857 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
858 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
859 wxPyEndBlockThreads(); \
860 if (! found) \
861 rval = PCLASS::CBNAME(a); \
862 return rval; \
863 } \
864 bool CLASS::base_##CBNAME(bool a) { \
865 return PCLASS::CBNAME(a); \
866 }
867
868 //---------------------------------------------------------------------------
869
870 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
871 bool CBNAME(int a); \
872 bool base_##CBNAME(int a)
873
874
875 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
876 bool CLASS::CBNAME(int a) { \
877 bool rval=False, found; \
878 wxPyBeginBlockThreads(); \
879 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
880 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
881 wxPyEndBlockThreads(); \
882 if (! found) \
883 rval = PCLASS::CBNAME(a); \
884 return rval; \
885 } \
886 bool CLASS::base_##CBNAME(int a) { \
887 return PCLASS::CBNAME(a); \
888 }
889
890 //---------------------------------------------------------------------------
891
892 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
893 bool CBNAME(int a)
894
895
896 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
897 bool CLASS::CBNAME(int a) { \
898 bool rval=False; \
899 wxPyBeginBlockThreads(); \
900 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
901 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
902 else rval = False; \
903 wxPyEndBlockThreads(); \
904 return rval; \
905 }
906
907
908 //---------------------------------------------------------------------------
909
910 #define DEC_PYCALLBACK__DC(CBNAME) \
911 void CBNAME(wxDC& a); \
912 void base_##CBNAME(wxDC& a)
913
914
915 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
916 void CLASS::CBNAME(wxDC& a) { \
917 bool found; \
918 wxPyBeginBlockThreads(); \
919 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
920 PyObject* obj = wxPyMake_wxObject(&a); \
921 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
922 Py_DECREF(obj); \
923 } \
924 wxPyEndBlockThreads(); \
925 if (! found) \
926 PCLASS::CBNAME(a); \
927 } \
928 void CLASS::base_##CBNAME(wxDC& a) { \
929 PCLASS::CBNAME(a); \
930 }
931
932
933
934 //---------------------------------------------------------------------------
935
936 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
937 void CBNAME(wxDC& a, bool b); \
938 void base_##CBNAME(wxDC& a, bool b)
939
940
941 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
942 void CLASS::CBNAME(wxDC& a, bool b) { \
943 bool found; \
944 wxPyBeginBlockThreads(); \
945 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
946 PyObject* obj = wxPyMake_wxObject(&a); \
947 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
948 Py_DECREF(obj); \
949 } \
950 wxPyEndBlockThreads(); \
951 if (! found) \
952 PCLASS::CBNAME(a, b); \
953 } \
954 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
955 PCLASS::CBNAME(a, b); \
956 }
957
958 //---------------------------------------------------------------------------
959
960 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
961 void CBNAME(wxDC& a, bool b); \
962 void base_##CBNAME(wxDC& a, bool b)
963
964
965 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
966 void CLASS::CBNAME(wxDC& a, bool b) { \
967 bool found; \
968 wxPyBeginBlockThreads(); \
969 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
970 PyObject* obj = wxPyMake_wxObject(&a); \
971 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
972 Py_DECREF(obj); \
973 } \
974 wxPyEndBlockThreads(); \
975 if (! found) \
976 PCLASS::CBNAME(a, b); \
977 } \
978 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
979 PCLASS::CBNAME(a, b); \
980 }
981
982 //---------------------------------------------------------------------------
983
984 #define DEC_PYCALLBACK__2DBL(CBNAME) \
985 void CBNAME(double a, double b); \
986 void base_##CBNAME(double a, double b)
987
988
989 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
990 void CLASS::CBNAME(double a, double b) { \
991 bool found; \
992 wxPyBeginBlockThreads(); \
993 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
994 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
995 wxPyEndBlockThreads(); \
996 if (! found) \
997 PCLASS::CBNAME(a, b); \
998 } \
999 void CLASS::base_##CBNAME(double a, double b) { \
1000 PCLASS::CBNAME(a, b); \
1001 }
1002
1003 //---------------------------------------------------------------------------
1004
1005 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
1006 void CBNAME(double a, double b, int c, int d); \
1007 void base_##CBNAME(double a, double b, int c, int d)
1008
1009
1010 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
1011 void CLASS::CBNAME(double a, double b, int c, int d) { \
1012 bool found; \
1013 wxPyBeginBlockThreads(); \
1014 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1015 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
1016 a,b,c,d)); \
1017 wxPyEndBlockThreads(); \
1018 if (! found) \
1019 PCLASS::CBNAME(a, b, c, d); \
1020 } \
1021 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
1022 PCLASS::CBNAME(a, b, c, d); \
1023 }
1024
1025 //---------------------------------------------------------------------------
1026
1027 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
1028 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
1029 void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1030
1031
1032 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1033 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1034 bool found; \
1035 wxPyBeginBlockThreads(); \
1036 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1037 PyObject* obj = wxPyMake_wxObject(&a); \
1038 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
1039 Py_DECREF(obj); \
1040 } \
1041 wxPyEndBlockThreads(); \
1042 if (! found) \
1043 PCLASS::CBNAME(a, b, c, d, e, f); \
1044 } \
1045 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
1046 PCLASS::CBNAME(a, b, c, d, e, f); \
1047 }
1048
1049 //---------------------------------------------------------------------------
1050
1051 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
1052 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
1053 bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1054
1055
1056 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1057 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1058 bool found; \
1059 wxPyBeginBlockThreads(); \
1060 bool rval=False; \
1061 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1062 PyObject* obj = wxPyMake_wxObject(&a); \
1063 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
1064 Py_DECREF(obj); \
1065 } \
1066 wxPyEndBlockThreads(); \
1067 if (! found) \
1068 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
1069 return rval; \
1070 } \
1071 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
1072 return PCLASS::CBNAME(a, b, c, d, e, f); \
1073 }
1074
1075 //---------------------------------------------------------------------------
1076
1077 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
1078 void CBNAME(bool a, double b, double c, int d, int e); \
1079 void base_##CBNAME(bool a, double b, double c, int d, int e)
1080
1081
1082 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1083 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
1084 bool found; \
1085 wxPyBeginBlockThreads(); \
1086 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1087 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
1088 (int)a,b,c,d,e)); \
1089 wxPyEndBlockThreads(); \
1090 if (! found) \
1091 PCLASS::CBNAME(a, b, c, d, e); \
1092 } \
1093 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
1094 PCLASS::CBNAME(a, b, c, d, e); \
1095 }
1096
1097 //---------------------------------------------------------------------------
1098
1099 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
1100 void CBNAME(wxDC& a, double b, double c, double d, double e); \
1101 void base_##CBNAME(wxDC& a, double b, double c, double d, double e)
1102
1103
1104 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
1105 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
1106 bool found; \
1107 wxPyBeginBlockThreads(); \
1108 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1109 PyObject* obj = wxPyMake_wxObject(&a); \
1110 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
1111 Py_DECREF(obj); \
1112 } \
1113 wxPyEndBlockThreads(); \
1114 if (! found) \
1115 PCLASS::CBNAME(a, b, c, d, e); \
1116 } \
1117 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
1118 PCLASS::CBNAME(a, b, c, d, e); \
1119 }
1120
1121 //---------------------------------------------------------------------------
1122
1123 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
1124 void CBNAME(wxDC& a, bool b); \
1125 void base_##CBNAME(wxDC& a, bool b)
1126
1127
1128 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
1129 void CLASS::CBNAME(wxDC& a, bool b) { \
1130 bool found; \
1131 wxPyBeginBlockThreads(); \
1132 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1133 PyObject* obj = wxPyMake_wxObject(&a); \
1134 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
1135 Py_DECREF(obj); \
1136 } \
1137 wxPyEndBlockThreads(); \
1138 if (! found) \
1139 PCLASS::CBNAME(a, b); \
1140 } \
1141 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
1142 PCLASS::CBNAME(a, b); \
1143 }
1144
1145 //---------------------------------------------------------------------------
1146
1147 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
1148 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
1149 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f)
1150
1151
1152 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1153 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
1154 int e, int f) { \
1155 bool found; \
1156 wxPyBeginBlockThreads(); \
1157 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1158 PyObject* obj = wxPyMake_wxObject(a); \
1159 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
1160 Py_DECREF(obj); \
1161 } \
1162 wxPyEndBlockThreads(); \
1163 if (! found) \
1164 PCLASS::CBNAME(a, b, c, d, e, f); \
1165 } \
1166 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
1167 int e, int f) { \
1168 PCLASS::CBNAME(a, b, c, d, e, f); \
1169 }
1170
1171 //---------------------------------------------------------------------------
1172
1173 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
1174 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
1175 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e)
1176
1177
1178 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
1179 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
1180 bool found; \
1181 wxPyBeginBlockThreads(); \
1182 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1183 PyObject* obj = wxPyMake_wxObject(a); \
1184 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
1185 Py_DECREF(obj); \
1186 } \
1187 wxPyEndBlockThreads(); \
1188 if (! found) \
1189 PCLASS::CBNAME(a, b, c, d, e); \
1190 } \
1191 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
1192 int d, int e) { \
1193 PCLASS::CBNAME(a, b, c, d, e); \
1194 }
1195
1196 //---------------------------------------------------------------------------
1197
1198 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
1199 void CBNAME(double a, double b, int c); \
1200 void base_##CBNAME(double a, double b, int c)
1201
1202
1203 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
1204 void CLASS::CBNAME(double a, double b, int c) { \
1205 bool found; \
1206 wxPyBeginBlockThreads(); \
1207 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1208 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
1209 wxPyEndBlockThreads(); \
1210 if (! found) \
1211 PCLASS::CBNAME(a, b, c); \
1212 } \
1213 void CLASS::base_##CBNAME(double a, double b, int c) { \
1214 PCLASS::CBNAME(a, b, c); \
1215 }
1216
1217 //---------------------------------------------------------------------------
1218
1219 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
1220 void CBNAME(bool a, double b, double c, int d); \
1221 void base_##CBNAME(bool a, double b, double c, int d)
1222
1223
1224 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
1225 void CLASS::CBNAME(bool a, double b, double c, int d) { \
1226 bool found; \
1227 wxPyBeginBlockThreads(); \
1228 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1229 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\
1230 wxPyEndBlockThreads(); \
1231 if (! found) \
1232 PCLASS::CBNAME(a, b, c, d); \
1233 } \
1234 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
1235 PCLASS::CBNAME(a, b, c, d); \
1236 }
1237
1238 //---------------------------------------------------------------------------
1239 //---------------------------------------------------------------------------
1240
1241 #define DEC_PYCALLBACK__STRING(CBNAME) \
1242 void CBNAME(const wxString& a); \
1243 void base_##CBNAME(const wxString& a)
1244
1245 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
1246 void CLASS::CBNAME(const wxString& a) { \
1247 bool found; \
1248 wxPyBeginBlockThreads(); \
1249 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1250 PyObject* s = wx2PyString(a); \
1251 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1252 Py_DECREF(s); \
1253 } \
1254 wxPyEndBlockThreads(); \
1255 if (! found) \
1256 PCLASS::CBNAME(a); \
1257 } \
1258 void CLASS::base_##CBNAME(const wxString& a) { \
1259 PCLASS::CBNAME(a); \
1260 }
1261
1262 //---------------------------------------------------------------------------
1263
1264 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
1265 bool CBNAME(const wxString& a); \
1266 bool base_##CBNAME(const wxString& a)
1267
1268 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
1269 bool CLASS::CBNAME(const wxString& a) { \
1270 bool rval=False; \
1271 bool found; \
1272 wxPyBeginBlockThreads(); \
1273 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1274 PyObject* s = wx2PyString(a); \
1275 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1276 Py_DECREF(s); \
1277 } \
1278 wxPyEndBlockThreads(); \
1279 if (! found) \
1280 rval = PCLASS::CBNAME(a); \
1281 return rval; \
1282 } \
1283 bool CLASS::base_##CBNAME(const wxString& a) { \
1284 return PCLASS::CBNAME(a); \
1285 }
1286
1287 //---------------------------------------------------------------------------
1288
1289 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
1290 bool CBNAME(const wxString& a)
1291
1292 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
1293 bool CLASS::CBNAME(const wxString& a) { \
1294 bool rval=False; \
1295 wxPyBeginBlockThreads(); \
1296 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1297 PyObject* s = wx2PyString(a); \
1298 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1299 Py_DECREF(s); \
1300 } \
1301 wxPyEndBlockThreads(); \
1302 return rval; \
1303 } \
1304
1305 //---------------------------------------------------------------------------
1306
1307 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
1308 wxString CBNAME(const wxString& a)
1309
1310 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
1311 wxString CLASS::CBNAME(const wxString& a) { \
1312 wxString rval; \
1313 wxPyBeginBlockThreads(); \
1314 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1315 PyObject* ro; \
1316 PyObject* s = wx2PyString(a); \
1317 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1318 Py_DECREF(s); \
1319 if (ro) { \
1320 rval = Py2wxString(ro); \
1321 Py_DECREF(ro); \
1322 } \
1323 } \
1324 wxPyEndBlockThreads(); \
1325 return rval; \
1326 } \
1327
1328 //---------------------------------------------------------------------------
1329
1330 #define DEC_PYCALLBACK_STRING_STRING(CBNAME) \
1331 wxString CBNAME(const wxString& a); \
1332 wxString base_##CBNAME(const wxString& a)
1333
1334 #define IMP_PYCALLBACK_STRING_STRING(CLASS, PCLASS, CBNAME) \
1335 wxString CLASS::CBNAME(const wxString& a) { \
1336 wxString rval; \
1337 bool found; \
1338 wxPyBeginBlockThreads(); \
1339 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1340 PyObject* ro; \
1341 PyObject* s = wx2PyString(a); \
1342 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1343 Py_DECREF(s); \
1344 if (ro) { \
1345 rval = Py2wxString(ro); \
1346 Py_DECREF(ro); \
1347 } \
1348 } \
1349 if (! found) \
1350 rval = PCLASS::CBNAME(a); \
1351 wxPyEndBlockThreads(); \
1352 return rval; \
1353 } \
1354
1355 //---------------------------------------------------------------------------
1356
1357 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
1358 wxString CBNAME(const wxString& a,int b)
1359
1360 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
1361 wxString CLASS::CBNAME(const wxString& a,int b) { \
1362 wxString rval; \
1363 wxPyBeginBlockThreads(); \
1364 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1365 PyObject* ro; \
1366 PyObject* s = wx2PyString(a); \
1367 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oi)",s,b)); \
1368 Py_DECREF(s); \
1369 if (ro) { \
1370 rval = Py2wxString(ro); \
1371 Py_DECREF(ro); \
1372 } \
1373 } \
1374 wxPyEndBlockThreads(); \
1375 return rval; \
1376 } \
1377
1378 //---------------------------------------------------------------------------
1379
1380 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
1381 bool CBNAME(const wxString& a, const wxString& b); \
1382 bool base_##CBNAME(const wxString& a, const wxString& b)
1383
1384 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
1385 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
1386 bool rval=False; \
1387 bool found; \
1388 wxPyBeginBlockThreads(); \
1389 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1390 PyObject* s1 = wx2PyString(a); \
1391 PyObject* s2 = wx2PyString(b); \
1392 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",s1,s2)); \
1393 Py_DECREF(s1); \
1394 Py_DECREF(s2); \
1395 } \
1396 wxPyEndBlockThreads(); \
1397 if (! found) \
1398 rval = PCLASS::CBNAME(a, b); \
1399 return rval; \
1400 } \
1401 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
1402 return PCLASS::CBNAME(a, b); \
1403 }
1404
1405 //---------------------------------------------------------------------------
1406
1407 #define DEC_PYCALLBACK_STRING_(CBNAME) \
1408 wxString CBNAME(); \
1409 wxString base_##CBNAME()
1410
1411 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
1412 wxString CLASS::CBNAME() { \
1413 wxString rval; \
1414 bool found; \
1415 wxPyBeginBlockThreads(); \
1416 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1417 PyObject* ro; \
1418 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1419 if (ro) { \
1420 rval = Py2wxString(ro); \
1421 Py_DECREF(ro); \
1422 } \
1423 } \
1424 wxPyEndBlockThreads(); \
1425 if (! found) \
1426 rval = PCLASS::CBNAME(); \
1427 return rval; \
1428 } \
1429 wxString CLASS::base_##CBNAME() { \
1430 return PCLASS::CBNAME(); \
1431 }
1432
1433 //---------------------------------------------------------------------------
1434
1435 #define DEC_PYCALLBACK_STRING__const(CBNAME) \
1436 wxString CBNAME() const; \
1437 wxString base_##CBNAME() const;
1438
1439 #define IMP_PYCALLBACK_STRING__const(CLASS, PCLASS, CBNAME) \
1440 wxString CLASS::CBNAME() const { \
1441 wxString rval; \
1442 bool found; \
1443 wxPyBeginBlockThreads(); \
1444 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1445 PyObject* ro; \
1446 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1447 if (ro) { \
1448 rval = Py2wxString(ro); \
1449 Py_DECREF(ro); \
1450 } \
1451 } \
1452 wxPyEndBlockThreads(); \
1453 if (! found) \
1454 rval = PCLASS::CBNAME(); \
1455 return rval; \
1456 } \
1457 wxString CLASS::base_##CBNAME() const { \
1458 return PCLASS::CBNAME(); \
1459 }
1460
1461 //---------------------------------------------------------------------------
1462
1463 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
1464 wxString CBNAME()
1465
1466 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
1467 wxString CLASS::CBNAME() { \
1468 wxString rval; \
1469 wxPyBeginBlockThreads(); \
1470 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1471 PyObject* ro; \
1472 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1473 if (ro) { \
1474 rval = Py2wxString(ro); \
1475 Py_DECREF(ro); \
1476 } \
1477 } \
1478 wxPyEndBlockThreads(); \
1479 return rval; \
1480 }
1481
1482 //---------------------------------------------------------------------------
1483
1484 #define DEC_PYCALLBACK_STRING__constpure(CBNAME) \
1485 wxString CBNAME() const;
1486
1487 #define IMP_PYCALLBACK_STRING__constpure(CLASS, PCLASS, CBNAME) \
1488 wxString CLASS::CBNAME() const { \
1489 wxString rval; \
1490 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(); \
1500 return rval; \
1501 }
1502
1503 //---------------------------------------------------------------------------
1504
1505 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
1506 bool CBNAME(const wxHtmlTag& a)
1507
1508
1509 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
1510 bool CLASS::CBNAME(const wxHtmlTag& a) { \
1511 bool rval=False; \
1512 wxPyBeginBlockThreads(); \
1513 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1514 PyObject* obj = wxPyConstructObject((void*)&a, wxT("wxHtmlTag"), 0); \
1515 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1516 Py_DECREF(obj); \
1517 } \
1518 wxPyEndBlockThreads(); \
1519 return rval; \
1520 }
1521
1522 //---------------------------------------------------------------------------
1523
1524 #define DEC_PYCALLBACK__CELLINTINT(CBNAME) \
1525 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y); \
1526 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y)
1527
1528 #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \
1529 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1530 bool found; \
1531 wxPyBeginBlockThreads(); \
1532 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1533 PyObject* obj = wxPyConstructObject((void*)cell, wxT("wxHtmlCell"), 0); \
1534 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \
1535 Py_DECREF(obj); \
1536 } \
1537 wxPyEndBlockThreads(); \
1538 if (! found) \
1539 PCLASS::CBNAME(cell, x, y); \
1540 } \
1541 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1542 PCLASS::CBNAME(cell, x, y); \
1543 }
1544
1545
1546 //---------------------------------------------------------------------------
1547
1548 #define DEC_PYCALLBACK__CELLINTINTME(CBNAME) \
1549 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e); \
1550 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e)
1551
1552 #define IMP_PYCALLBACK__CELLINTINTME(CLASS, PCLASS, CBNAME) \
1553 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1554 bool found; \
1555 wxPyBeginBlockThreads(); \
1556 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1557 PyObject* obj = wxPyConstructObject((void*)cell, wxT("wxHtmlCell"), 0); \
1558 PyObject* o2 = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
1559 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1560 Py_DECREF(obj); \
1561 Py_DECREF(o2); \
1562 } \
1563 wxPyEndBlockThreads(); \
1564 if (! found) \
1565 PCLASS::CBNAME(cell, x, y, e); \
1566 } \
1567 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1568 PCLASS::CBNAME(cell, x, y, e); \
1569 }
1570
1571
1572
1573 //---------------------------------------------------------------------------
1574
1575 #define DEC_PYCALLBACK___pure(CBNAME) \
1576 void CBNAME()
1577
1578
1579 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1580 void CLASS::CBNAME() { \
1581 wxPyBeginBlockThreads(); \
1582 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1583 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1584 wxPyEndBlockThreads(); \
1585 }
1586
1587 //---------------------------------------------------------------------------
1588
1589 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1590 wxSize CBNAME()
1591
1592
1593 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1594 wxSize CLASS::CBNAME() { \
1595 const char* errmsg = #CBNAME " should return a 2-tuple of integers or a wxSize object."; \
1596 wxSize rval(0,0); \
1597 wxPyBeginBlockThreads(); \
1598 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1599 PyObject* ro; \
1600 wxSize* ptr; \
1601 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1602 if (ro) { \
1603 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxSize"))) \
1604 rval = *ptr; \
1605 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
1606 PyObject* o1 = PySequence_GetItem(ro, 0); \
1607 PyObject* o2 = PySequence_GetItem(ro, 1); \
1608 if (PyNumber_Check(o1) && PyNumber_Check(o2)) \
1609 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
1610 else \
1611 PyErr_SetString(PyExc_TypeError, errmsg); \
1612 Py_DECREF(o1); \
1613 Py_DECREF(o2); \
1614 } \
1615 else { \
1616 PyErr_SetString(PyExc_TypeError, errmsg); \
1617 } \
1618 Py_DECREF(ro); \
1619 } \
1620 } \
1621 wxPyEndBlockThreads(); \
1622 return rval; \
1623 }
1624
1625 //---------------------------------------------------------------------------
1626
1627 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1628 bool CBNAME(wxWindow* a); \
1629 bool base_##CBNAME(wxWindow* a)
1630
1631
1632 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1633 bool CLASS::CBNAME(wxWindow* a) { \
1634 bool rval=False; \
1635 bool found; \
1636 wxPyBeginBlockThreads(); \
1637 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1638 PyObject* obj = wxPyMake_wxObject(a); \
1639 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1640 Py_DECREF(obj); \
1641 } \
1642 wxPyEndBlockThreads(); \
1643 if (! found) \
1644 rval = PCLASS::CBNAME(a); \
1645 return rval; \
1646 } \
1647 bool CLASS::base_##CBNAME(wxWindow* a) { \
1648 return PCLASS::CBNAME(a); \
1649 }
1650
1651 //---------------------------------------------------------------------------
1652
1653 #define DEC_PYCALLBACK_BOOL_WXWINDC(CBNAME) \
1654 bool CBNAME(wxWindow* a, wxDC& b); \
1655 bool base_##CBNAME(wxWindow* a, wxDC& b)
1656
1657
1658 #define IMP_PYCALLBACK_BOOL_WXWINDC(CLASS, PCLASS, CBNAME) \
1659 bool CLASS::CBNAME(wxWindow* a, wxDC& b) { \
1660 bool rval=False; \
1661 bool found; \
1662 wxPyBeginBlockThreads(); \
1663 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1664 PyObject* win = wxPyMake_wxObject(a); \
1665 PyObject* dc = wxPyMake_wxObject(&b); \
1666 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc));\
1667 Py_DECREF(win); \
1668 Py_DECREF(dc); \
1669 } \
1670 wxPyEndBlockThreads(); \
1671 if (! found) \
1672 rval = PCLASS::CBNAME(a, b); \
1673 return rval; \
1674 } \
1675 bool CLASS::base_##CBNAME(wxWindow* a, wxDC& b) { \
1676 return PCLASS::CBNAME(a, b); \
1677 }
1678
1679 //---------------------------------------------------------------------------
1680
1681 #define DEC_PYCALLBACK_VOID_WXWINBASE(CBNAME) \
1682 void CBNAME(wxWindowBase* a); \
1683 void base_##CBNAME(wxWindowBase* a)
1684
1685
1686 #define IMP_PYCALLBACK_VOID_WXWINBASE(CLASS, PCLASS, CBNAME) \
1687 void CLASS::CBNAME(wxWindowBase* a) { \
1688 bool found; \
1689 wxPyBeginBlockThreads(); \
1690 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1691 PyObject* obj = wxPyMake_wxObject(a); \
1692 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1693 Py_DECREF(obj); \
1694 } \
1695 wxPyEndBlockThreads(); \
1696 if (! found) \
1697 PCLASS::CBNAME(a); \
1698 } \
1699 void CLASS::base_##CBNAME(wxWindowBase* a) { \
1700 PCLASS::CBNAME(a); \
1701 }
1702
1703 //---------------------------------------------------------------------------
1704
1705 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1706 bool CBNAME(); \
1707 bool base_##CBNAME()
1708
1709
1710 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1711 bool CLASS::CBNAME() { \
1712 bool rval=False; \
1713 bool found; \
1714 wxPyBeginBlockThreads(); \
1715 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1716 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1717 wxPyEndBlockThreads(); \
1718 if (! found) \
1719 rval = PCLASS::CBNAME(); \
1720 return rval; \
1721 } \
1722 bool CLASS::base_##CBNAME() { \
1723 return PCLASS::CBNAME(); \
1724 }
1725
1726 //---------------------------------------------------------------------------
1727
1728 #define DEC_PYCALLBACK_BOOL_const(CBNAME) \
1729 bool CBNAME() const; \
1730 bool base_##CBNAME() const
1731
1732
1733 #define IMP_PYCALLBACK_BOOL_const(CLASS, PCLASS, CBNAME) \
1734 bool CLASS::CBNAME() const { \
1735 bool rval=False; \
1736 bool found; \
1737 wxPyBeginBlockThreads(); \
1738 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1739 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1740 wxPyEndBlockThreads(); \
1741 if (! found) \
1742 rval = PCLASS::CBNAME(); \
1743 return rval; \
1744 } \
1745 bool CLASS::base_##CBNAME() const { \
1746 return PCLASS::CBNAME(); \
1747 }
1748
1749 //---------------------------------------------------------------------------
1750
1751 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1752 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \
1753 wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1754
1755
1756 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1757 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1758 int rval=0; \
1759 bool found; \
1760 wxPyBeginBlockThreads(); \
1761 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1762 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1763 wxPyEndBlockThreads(); \
1764 if (! found) \
1765 rval = PCLASS::CBNAME(a, b, c); \
1766 return (wxDragResult)rval; \
1767 } \
1768 wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1769 return PCLASS::CBNAME(a, b, c); \
1770 }
1771
1772 //---------------------------------------------------------------------------
1773
1774 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1775 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location)
1776
1777 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1778 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1779 wxPyBeginBlockThreads(); \
1780 wxFSFile* rval=0; \
1781 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1782 PyObject* ro; \
1783 PyObject* obj = wxPyMake_wxObject(&a); \
1784 PyObject* s = wx2PyString(b); \
1785 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)",\
1786 obj, s)); \
1787 if (ro) { \
1788 wxPyConvertSwigPtr(ro, (void **)&rval, wxT("wxFSFILE"));\
1789 Py_DECREF(ro); \
1790 } \
1791 Py_DECREF(obj); \
1792 Py_DECREF(s); \
1793 } \
1794 wxPyEndBlockThreads(); \
1795 return rval; \
1796 };
1797
1798 //---------------------------------------------------------------------------
1799
1800 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1801 bool CBNAME(wxDragResult a); \
1802 bool base_##CBNAME(wxDragResult a)
1803
1804
1805 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1806 bool CLASS::CBNAME(wxDragResult a) { \
1807 bool rval=False; \
1808 bool found; \
1809 wxPyBeginBlockThreads(); \
1810 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1811 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a));\
1812 wxPyEndBlockThreads(); \
1813 if (! found) \
1814 rval = PCLASS::CBNAME(a); \
1815 return rval; \
1816 } \
1817 bool CLASS::base_##CBNAME(wxDragResult a) { \
1818 return PCLASS::CBNAME(a); \
1819 }
1820
1821 //---------------------------------------------------------------------------
1822
1823 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1824 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1825
1826
1827 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1828 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1829 wxPyBeginBlockThreads(); \
1830 int rval=0; \
1831 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1832 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1833 wxPyEndBlockThreads(); \
1834 return (wxDragResult)rval; \
1835 } \
1836
1837 //---------------------------------------------------------------------------
1838
1839 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1840 bool CBNAME(int a, int b, const wxString& c)
1841
1842 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1843 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1844 bool rval=False; \
1845 wxPyBeginBlockThreads(); \
1846 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1847 PyObject* s = wx2PyString(c); \
1848 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
1849 Py_DECREF(s); \
1850 } \
1851 wxPyEndBlockThreads(); \
1852 return rval; \
1853 } \
1854
1855 //---------------------------------------------------------------------------
1856
1857 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1858 size_t CBNAME(); \
1859 size_t base_##CBNAME()
1860
1861
1862 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1863 size_t CLASS::CBNAME() { \
1864 size_t rval=0; \
1865 bool found; \
1866 wxPyBeginBlockThreads(); \
1867 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1868 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1869 wxPyEndBlockThreads(); \
1870 if (! found) \
1871 rval = PCLASS::CBNAME(); \
1872 return rval; \
1873 } \
1874 size_t CLASS::base_##CBNAME() { \
1875 return PCLASS::CBNAME(); \
1876 }
1877
1878 //---------------------------------------------------------------------------
1879
1880 #define DEC_PYCALLBACK_SIZET__const(CBNAME) \
1881 size_t CBNAME() const; \
1882 size_t base_##CBNAME() const
1883
1884
1885 #define IMP_PYCALLBACK_SIZET__const(CLASS, PCLASS, CBNAME) \
1886 size_t CLASS::CBNAME() const { \
1887 size_t rval=0; \
1888 bool found; \
1889 wxPyBeginBlockThreads(); \
1890 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1891 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1892 wxPyEndBlockThreads(); \
1893 if (! found) \
1894 rval = PCLASS::CBNAME(); \
1895 return rval; \
1896 } \
1897 size_t CLASS::base_##CBNAME() const { \
1898 return PCLASS::CBNAME(); \
1899 }
1900
1901 //---------------------------------------------------------------------------
1902
1903 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1904 wxDataFormat CBNAME(size_t a); \
1905 wxDataFormat base_##CBNAME(size_t a)
1906
1907
1908 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1909 wxDataFormat CLASS::CBNAME(size_t a) { \
1910 wxDataFormat rval=0; \
1911 bool found; \
1912 wxPyBeginBlockThreads(); \
1913 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1914 PyObject* ro; \
1915 wxDataFormat* ptr; \
1916 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1917 if (ro) { \
1918 if (wxPyCOnvertSwigPtr(ro, (void **)&ptr, wxT("wxDataFormat"))) \
1919 rval = *ptr; \
1920 Py_DECREF(ro); \
1921 } \
1922 } \
1923 wxPyEndBlockThreads(); \
1924 if (! found) \
1925 rval = PCLASS::CBNAME(a); \
1926 return rval; \
1927 } \
1928 wxDataFormat CLASS::base_##CBNAME(size_t a) { \
1929 return PCLASS::CBNAME(a); \
1930 }
1931
1932 //---------------------------------------------------------------------------
1933
1934 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1935 void CBNAME(const Type& a); \
1936 void base_##CBNAME(const Type& a)
1937
1938
1939 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1940 void CLASS::CBNAME(const Type& a) { \
1941 bool found; \
1942 wxPyBeginBlockThreads(); \
1943 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1944 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1945 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1946 Py_DECREF(obj); \
1947 } \
1948 wxPyEndBlockThreads(); \
1949 if (! found) \
1950 PCLASS::CBNAME(a); \
1951 } \
1952 void CLASS::base_##CBNAME(const Type& a) { \
1953 PCLASS::CBNAME(a); \
1954 }
1955
1956
1957 //---------------------------------------------------------------------------
1958
1959 #define DEC_PYCALLBACK__any(CBNAME, Type) \
1960 void CBNAME(Type& a); \
1961 void base_##CBNAME(Type& a)
1962
1963
1964 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1965 void CLASS::CBNAME(Type& a) { \
1966 bool found; \
1967 wxPyBeginBlockThreads(); \
1968 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1969 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1970 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1971 Py_DECREF(obj); \
1972 } \
1973 wxPyEndBlockThreads(); \
1974 if (! found) \
1975 PCLASS::CBNAME(a); \
1976 } \
1977 void CLASS::base_##CBNAME(Type& a) { \
1978 PCLASS::CBNAME(a); \
1979 }
1980
1981 //---------------------------------------------------------------------------
1982
1983 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1984 bool CBNAME(Type& a); \
1985 bool base_##CBNAME(Type& a)
1986
1987
1988 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
1989 bool CLASS::CBNAME(Type& a) { \
1990 bool rv=False; \
1991 bool found; \
1992 wxPyBeginBlockThreads(); \
1993 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1994 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1995 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1996 Py_DECREF(obj); \
1997 } \
1998 wxPyEndBlockThreads(); \
1999 if (! found) \
2000 rv = PCLASS::CBNAME(a); \
2001 return rv; \
2002 } \
2003 bool CLASS::base_##CBNAME(Type& a) { \
2004 return PCLASS::CBNAME(a); \
2005 }
2006
2007 //---------------------------------------------------------------------------
2008
2009 #define DEC_PYCALLBACK_bool_anypure(CBNAME, Type) \
2010 bool CBNAME(Type& a)
2011
2012
2013 #define IMP_PYCALLBACK_bool_anypure(CLASS, PCLASS, CBNAME, Type) \
2014 bool CLASS::CBNAME(Type& a) { \
2015 bool rv=False; \
2016 wxPyBeginBlockThreads(); \
2017 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2018 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
2019 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2020 Py_DECREF(obj); \
2021 } \
2022 wxPyEndBlockThreads(); \
2023 return rv; \
2024 } \
2025
2026 //---------------------------------------------------------------------------
2027
2028 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
2029 wxString CBNAME(long a, long b) const; \
2030 wxString base_##CBNAME(long a, long b) const
2031
2032 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
2033 wxString CLASS::CBNAME(long a, long b) const { \
2034 wxString rval; \
2035 bool found; \
2036 wxPyBeginBlockThreads(); \
2037 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2038 PyObject* ro; \
2039 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
2040 if (ro) { \
2041 rval = Py2wxString(ro); \
2042 Py_DECREF(ro); \
2043 } \
2044 } \
2045 wxPyEndBlockThreads(); \
2046 if (! found) \
2047 rval = PCLASS::CBNAME(a,b); \
2048 return rval; \
2049 } \
2050 wxString CLASS::base_##CBNAME(long a, long b) const { \
2051 return PCLASS::CBNAME(a,b); \
2052 }
2053
2054 //---------------------------------------------------------------------------
2055
2056 #define DEC_PYCALLBACK_INT_LONG(CBNAME) \
2057 int CBNAME(long a) const; \
2058 int base_##CBNAME(long a) const
2059
2060
2061 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
2062 int CLASS::CBNAME(long a) const { \
2063 int rval=-1; \
2064 bool found; \
2065 wxPyBeginBlockThreads(); \
2066 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2067 PyObject* ro; \
2068 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2069 if (ro) { \
2070 rval = PyInt_AsLong(ro); \
2071 Py_DECREF(ro); \
2072 } \
2073 } \
2074 wxPyEndBlockThreads(); \
2075 if (! found) \
2076 rval = PCLASS::CBNAME(a); \
2077 return rval; \
2078 } \
2079 int CLASS::base_##CBNAME(long a) const { \
2080 return PCLASS::CBNAME(a); \
2081 }
2082
2083
2084 //---------------------------------------------------------------------------
2085
2086 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
2087 wxListItemAttr* CBNAME(long a) const; \
2088 wxListItemAttr* base_##CBNAME(long a) const
2089
2090
2091 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
2092 wxListItemAttr *CLASS::CBNAME(long a) const { \
2093 wxListItemAttr *rval = NULL; \
2094 bool found; \
2095 wxPyBeginBlockThreads(); \
2096 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2097 PyObject* ro; \
2098 wxListItemAttr* ptr; \
2099 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2100 if (ro) { \
2101 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxListItemAttr")))\
2102 rval = ptr; \
2103 Py_DECREF(ro); \
2104 } \
2105 } \
2106 wxPyEndBlockThreads(); \
2107 if (! found) \
2108 rval = PCLASS::CBNAME(a); \
2109 return rval; \
2110 } \
2111 wxListItemAttr *CLASS::base_##CBNAME(long a) const { \
2112 return PCLASS::CBNAME(a); \
2113 }
2114
2115 //---------------------------------------------------------------------------
2116
2117 #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
2118 bool CBNAME(wxMouseEvent& e); \
2119 bool base_##CBNAME(wxMouseEvent& e)
2120
2121 #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
2122 bool CLASS::CBNAME(wxMouseEvent& e) { \
2123 bool rval=False; \
2124 bool found; \
2125 wxPyBeginBlockThreads(); \
2126 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2127 PyObject* ro; \
2128 PyObject* obj = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
2129 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
2130 if (ro) { \
2131 rval = PyInt_AsLong(ro); \
2132 Py_DECREF(ro); \
2133 } \
2134 Py_DECREF(obj); \
2135 } \
2136 wxPyEndBlockThreads(); \
2137 if (! found) \
2138 return PCLASS::CBNAME(e); \
2139 return rval; \
2140 } \
2141 bool CLASS::base_##CBNAME(wxMouseEvent& e) { \
2142 return PCLASS::CBNAME(e); \
2143 }
2144
2145
2146 //---------------------------------------------------------------------------
2147
2148 #define DEC_PYCALLBACK_WIZPG__pure(CBNAME) \
2149 wxWizardPage* CBNAME() const
2150
2151 #define IMP_PYCALLBACK_WIZPG__pure(CLASS, PCLASS, CBNAME) \
2152 wxWizardPage* CLASS::CBNAME() const { \
2153 wxWizardPage* rv = NULL; \
2154 wxPyBeginBlockThreads(); \
2155 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2156 PyObject* ro; \
2157 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2158 if (ro) { \
2159 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxWizardPage")); \
2160 Py_DECREF(ro); \
2161 } \
2162 } \
2163 wxPyEndBlockThreads(); \
2164 return rv; \
2165 }
2166
2167 //---------------------------------------------------------------------------
2168
2169 #define DEC_PYCALLBACK_BITMAP__pure(CBNAME) \
2170 wxBitmap CBNAME() const
2171
2172 #define IMP_PYCALLBACK_BITMAP__pure(CLASS, PCLASS, CBNAME) \
2173 wxBitmap CLASS::CBNAME() const { \
2174 wxBitmap rv; \
2175 wxPyBeginBlockThreads(); \
2176 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2177 PyObject* ro; \
2178 wxBitmap* ptr; \
2179 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2180 if (ro) { \
2181 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxBitmap"))) \
2182 rv = *ptr; \
2183 Py_DECREF(ro); \
2184 } \
2185 } \
2186 wxPyEndBlockThreads(); \
2187 return rv; \
2188 }
2189
2190 //---------------------------------------------------------------------------
2191
2192 #define DEC_PYCALLBACK_OBJECT__pure(CBNAME) \
2193 wxObject* CBNAME()
2194
2195 #define IMP_PYCALLBACK_OBJECT__pure(CLASS, PCLASS, CBNAME) \
2196 wxObject* CLASS::CBNAME() { \
2197 wxObject* rv = NULL; \
2198 wxPyBeginBlockThreads(); \
2199 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2200 PyObject* ro; \
2201 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2202 if (ro) { \
2203 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2204 Py_DECREF(ro); \
2205 } \
2206 } \
2207 wxPyEndBlockThreads(); \
2208 return rv; \
2209 }
2210
2211 //---------------------------------------------------------------------------
2212
2213 #define DEC_PYCALLBACK_OBJECT_STRING_pure(CBNAME) \
2214 wxObject* CBNAME(const wxString& a)
2215
2216 #define IMP_PYCALLBACK_OBJECT_STRING_pure(CLASS, PCLASS, CBNAME) \
2217 wxObject* CLASS::CBNAME(const wxString& a) { \
2218 wxObject* rv = NULL; \
2219 wxPyBeginBlockThreads(); \
2220 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2221 PyObject* so = wx2PyString(a); \
2222 PyObject* ro; \
2223 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", so)); \
2224 if (ro) { \
2225 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2226 Py_DECREF(ro); \
2227 } \
2228 Py_DECREF(so); \
2229 } \
2230 wxPyEndBlockThreads(); \
2231 return rv; \
2232 }
2233
2234 //---------------------------------------------------------------------------
2235
2236 #define DEC_PYCALLBACK_BOOL_NODE_pure(CBNAME) \
2237 bool CBNAME(wxXmlNode* a)
2238
2239
2240 #define IMP_PYCALLBACK_BOOL_NODE_pure(CLASS, PCLASS, CBNAME) \
2241 bool CLASS::CBNAME(wxXmlNode* a) { \
2242 bool rv=False; \
2243 wxPyBeginBlockThreads(); \
2244 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2245 PyObject* obj = wxPyConstructObject((void*)a, wxT("wxXmlNode"), 0); \
2246 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2247 Py_DECREF(obj); \
2248 } \
2249 wxPyEndBlockThreads(); \
2250 return rv; \
2251 } \
2252
2253 //---------------------------------------------------------------------------
2254
2255 #define DEC_PYCALLBACK_COORD_SIZET_constpure(CBNAME) \
2256 wxCoord CBNAME(size_t a) const
2257
2258
2259 #define IMP_PYCALLBACK_COORD_SIZET_constpure(CLASS, PCLASS, CBNAME) \
2260 wxCoord CLASS::CBNAME(size_t a) const { \
2261 wxCoord rval=0; \
2262 bool found; \
2263 wxPyBeginBlockThreads(); \
2264 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2265 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
2266 } \
2267 wxPyEndBlockThreads(); \
2268 return rval; \
2269 } \
2270
2271 //---------------------------------------------------------------------------
2272
2273 #define DEC_PYCALLBACK_VOID_SIZETSIZET_const(CBNAME) \
2274 void CBNAME(size_t a, size_t b) const; \
2275 void base_##CBNAME(size_t a, size_t b) const
2276
2277
2278 #define IMP_PYCALLBACK_VOID_SIZETSIZET_const(CLASS, PCLASS, CBNAME) \
2279 void CLASS::CBNAME(size_t a, size_t b) const { \
2280 bool found; \
2281 wxPyBeginBlockThreads(); \
2282 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2283 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
2284 wxPyEndBlockThreads(); \
2285 if (! found) \
2286 PCLASS::CBNAME(a,b); \
2287 } \
2288 void CLASS::base_##CBNAME(size_t a, size_t b) const { \
2289 PCLASS::CBNAME(a,b); \
2290 }
2291
2292 //---------------------------------------------------------------------------
2293
2294 #define DEC_PYCALLBACK_COORD_const(CBNAME) \
2295 wxCoord CBNAME() const; \
2296 wxCoord base_##CBNAME() const
2297
2298
2299 #define IMP_PYCALLBACK_COORD_const(CLASS, PCLASS, CBNAME) \
2300 wxCoord CLASS::CBNAME() const { \
2301 wxCoord rval=0; \
2302 bool found; \
2303 wxPyBeginBlockThreads(); \
2304 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2305 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
2306 wxPyEndBlockThreads(); \
2307 if (! found) \
2308 rval = PCLASS::CBNAME(); \
2309 return rval; \
2310 } \
2311 wxCoord CLASS::base_##CBNAME() const { \
2312 return PCLASS::CBNAME(); \
2313 }
2314
2315 //---------------------------------------------------------------------------
2316
2317 #define DEC_PYCALLBACK__DCRECTSIZET_constpure(CBNAME) \
2318 void CBNAME(wxDC& a, const wxRect& b, size_t c) const;
2319
2320
2321 #define IMP_PYCALLBACK__DCRECTSIZET_constpure(CLASS, PCLASS, CBNAME) \
2322 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2323 bool found; \
2324 wxPyBeginBlockThreads(); \
2325 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2326 PyObject* obj = wxPyMake_wxObject(&a); \
2327 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2328 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2329 Py_DECREF(obj); \
2330 } \
2331 wxPyEndBlockThreads(); \
2332 } \
2333
2334 //---------------------------------------------------------------------------
2335
2336 #define DEC_PYCALLBACK__DCRECTSIZET_const(CBNAME) \
2337 void CBNAME(wxDC& a, const wxRect& b, size_t c) const; \
2338 void base_##CBNAME(wxDC& a, const wxRect& b, size_t c) const
2339
2340
2341 #define IMP_PYCALLBACK__DCRECTSIZET_const(CLASS, PCLASS, CBNAME) \
2342 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2343 bool found; \
2344 wxPyBeginBlockThreads(); \
2345 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2346 PyObject* obj = wxPyMake_wxObject(&a); \
2347 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2348 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2349 Py_DECREF(obj); \
2350 } \
2351 wxPyEndBlockThreads(); \
2352 if (! found) \
2353 PCLASS::CBNAME(a,b,c); \
2354 } \
2355 void CLASS::base_##CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2356 PCLASS::CBNAME(a,b,c); \
2357 }
2358
2359 //---------------------------------------------------------------------------
2360
2361
2362 #define DEC_PYCALLBACK_STRING_SIZET(CBNAME) \
2363 wxString CBNAME(size_t a) const; \
2364 wxString base_##CBNAME(size_t a) const
2365
2366 #define IMP_PYCALLBACK_STRING_SIZET(CLASS, PCLASS, CBNAME) \
2367 wxString CLASS::CBNAME(size_t a) const { \
2368 wxString rval; \
2369 bool found; \
2370 wxPyBeginBlockThreads(); \
2371 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2372 PyObject* ro; \
2373 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2374 if (ro) { \
2375 rval = Py2wxString(ro); \
2376 Py_DECREF(ro); \
2377 } \
2378 } \
2379 wxPyEndBlockThreads(); \
2380 if (! found) \
2381 rval = PCLASS::CBNAME(a); \
2382 return rval; \
2383 } \
2384 wxString CLASS::base_##CBNAME(size_t a) const { \
2385 return PCLASS::CBNAME(a); \
2386 }
2387
2388 //---------------------------------------------------------------------------
2389
2390 #define DEC_PYCALLBACK_STRING_SIZET_pure(CBNAME) \
2391 wxString CBNAME(size_t a) const
2392
2393 #define IMP_PYCALLBACK_STRING_SIZET_pure(CLASS, PCLASS, CBNAME) \
2394 wxString CLASS::CBNAME(size_t a) const { \
2395 wxString rval; \
2396 bool found; \
2397 wxPyBeginBlockThreads(); \
2398 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2399 PyObject* ro; \
2400 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2401 if (ro) { \
2402 rval = Py2wxString(ro); \
2403 Py_DECREF(ro); \
2404 } \
2405 } \
2406 wxPyEndBlockThreads(); \
2407 return rval; \
2408 } \
2409
2410 //---------------------------------------------------------------------------
2411
2412 #endif