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