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