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