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