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