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