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