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