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