]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/helpers.h
wxImageHistogram needs WXDLLEXPORT
[wxWidgets.git] / wxPython / src / helpers.h
CommitLineData
b1462dfa 1////////////////////////////////////////////////////////////////////////////
7bf85405 2// Name: helpers.h
a2426843 3// Purpose: Helper functions/classes for the wxPython extension module
7bf85405
RD
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>
1e4a197e 17#include <wx/geometry.h>
cf694132 18
efc5f224
RD
19//---------------------------------------------------------------------------
20
2f90df85
RD
21typedef unsigned char byte;
22
1e4a197e 23void __wxPreStart(PyObject*);
7bf85405 24PyObject* __wxStart(PyObject*, PyObject* args);
7ff49f0c 25void __wxCleanup();
7bf85405 26
9416aa89 27//extern PyObject* wxPython_dict;
7bf85405
RD
28PyObject* __wxSetDictionary(PyObject*, PyObject* args);
29
7bf85405 30void wxPyEventThunker(wxObject*, wxEvent& event);
efc5f224 31
1e7ecb7b 32PyObject* wxPyConstructObject(void* ptr,
a541c325 33 const wxString& className,
1e7ecb7b 34 int setThisOwn=0);
9416aa89 35PyObject* wxPyConstructObject(void* ptr,
a541c325 36 const wxString& className,
9416aa89
RD
37 PyObject* klass,
38 int setThisOwn=0);
a541c325
RD
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);
9416aa89 47
1e7ecb7b 48PyObject* wxPy_ConvertList(wxListBase* list, const char* className);
a541c325 49long wxPyGetWinHandle(wxWindow* win);
9b3d3bc4 50
19a97bd6
RD
51//----------------------------------------------------------------------
52
4268f798
RD
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
19a97bd6
RD
59
60
4268f798
RD
61// For Python --> C++
62PyThreadState* wxPyBeginAllowThreads();
63void wxPyEndAllowThreads(PyThreadState* state);
9b3d3bc4 64
4268f798
RD
65// For C++ --> Python
66void wxPyBeginBlockThreads();
67void wxPyEndBlockThreads();
9b3d3bc4 68
1e4a197e
RD
69#define wxPyBLOCK_THREADS(stmt) wxPyBeginBlockThreads(); stmt; wxPyEndBlockThreads()
70
7bf85405 71//----------------------------------------------------------------------
2f90df85
RD
72// These are helpers used by the typemaps
73
c8bc7bb8
RD
74wxString* wxString_in_helper(PyObject* source);
75
1e7ecb7b
RD
76byte* byte_LIST_helper(PyObject* source);
77int* int_LIST_helper(PyObject* source);
78long* long_LIST_helper(PyObject* source);
79char** string_LIST_helper(PyObject* source);
e0672e2f 80wxPoint* wxPoint_LIST_helper(PyObject* source, int* npoints);
1e7ecb7b
RD
81wxBitmap** wxBitmap_LIST_helper(PyObject* source);
82wxString* wxString_LIST_helper(PyObject* source);
83wxAcceleratorEntry* wxAcceleratorEntry_LIST_helper(PyObject* source);
9d37f964 84wxPen** wxPen_LIST_helper(PyObject* source);
1e7ecb7b
RD
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);
7bf85405 91
1e4a197e
RD
92bool wxPoint2DDouble_helper(PyObject* source, wxPoint2DDouble** obj);
93
94
4acff284
RD
95//----------------------------------------------------------------------
96// Other helpful stuff
97
9d37f964
RD
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
1e4a197e
RD
103bool wxPy2int_seq_helper(PyObject* source, int* i1, int* i2);
104bool wxPy4int_seq_helper(PyObject* source, int* i1, int* i2, int* i3, int* i4);
9d37f964
RD
105
106
7b7ac0ab 107PyObject* wxArrayString2PyList_helper(const wxArrayString& arr);
293a0a86 108PyObject* wxArrayInt2PyList_helper(const wxArrayInt& arr);
b37c7e1d 109
4acff284
RD
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)
b37c7e1d 113
1e4a197e
RD
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
2f90df85 129//----------------------------------------------------------------------
7bf85405
RD
130
131#ifndef SWIGCODE
132extern "C" void SWIG_MakePtr(char *, void *, char *);
133extern "C" char *SWIG_GetPtr(char *, void **, char *);
d559219f 134extern "C" char *SWIG_GetPtrObj(PyObject *obj, void **ptr, char *type);
7bf85405
RD
135#endif
136
137
138#ifdef _MSC_VER
139# pragma warning(disable:4800)
f6bcfd97 140# pragma warning(disable:4190)
7bf85405
RD
141#endif
142
7bf85405
RD
143//----------------------------------------------------------------------
144
145class wxPyCallback : public wxObject {
2f90df85 146 DECLARE_ABSTRACT_CLASS(wxPyCallback);
7bf85405 147public:
cf694132 148 wxPyCallback(PyObject* func);
2f90df85 149 wxPyCallback(const wxPyCallback& other);
cf694132 150 ~wxPyCallback();
7bf85405
RD
151
152 void EventThunker(wxEvent& event);
153
154 PyObject* m_func;
155};
156
7bf85405
RD
157//---------------------------------------------------------------------------
158
159class wxPyTimer : public wxTimer {
160public:
161 wxPyTimer(PyObject* callback);
162 ~wxPyTimer();
163
164 void Notify();
165
166private:
167 PyObject* func;
168};
169
cf694132 170//---------------------------------------------------------------------------
65dd82cb 171//---------------------------------------------------------------------------
9b3d3bc4
RD
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.
65dd82cb
RD
175
176
e19b7164 177class wxPyEvtSelfRef {
65dd82cb 178public:
e19b7164
RD
179 wxPyEvtSelfRef();
180 ~wxPyEvtSelfRef();
65dd82cb
RD
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
e19b7164 191class wxPyEvent : public wxEvent, public wxPyEvtSelfRef {
07b2e1cd 192 DECLARE_ABSTRACT_CLASS(wxPyEvent)
65dd82cb
RD
193public:
194 wxPyEvent(int id=0);
07b2e1cd 195 wxPyEvent(const wxPyEvent& evt);
65dd82cb
RD
196 ~wxPyEvent();
197
07b2e1cd 198 virtual wxEvent* Clone() const { return new wxPyEvent(*this); }
65dd82cb
RD
199};
200
201
e19b7164 202class wxPyCommandEvent : public wxCommandEvent, public wxPyEvtSelfRef {
07b2e1cd 203 DECLARE_ABSTRACT_CLASS(wxPyCommandEvent)
65dd82cb
RD
204public:
205 wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0);
07b2e1cd 206 wxPyCommandEvent(const wxPyCommandEvent& evt);
65dd82cb
RD
207 ~wxPyCommandEvent();
208
07b2e1cd 209 virtual wxEvent* Clone() const { return new wxPyCommandEvent(*this); }
65dd82cb
RD
210};
211
bb0054cd 212
4acff284
RD
213
214//----------------------------------------------------------------------
215// Forward decalre a few things used in the exported API
216class wxPyClientData;
217class wxPyUserData;
218class wxPyOORClientData;
249a57f4 219class wxPyCBInputStream;
4acff284
RD
220
221void wxPyClientData_dtor(wxPyClientData* self);
222void wxPyUserData_dtor(wxPyUserData* self);
223void wxPyOORClientData_dtor(wxPyOORClientData* self);
249a57f4 224wxPyCBInputStream* wxPyCBInputStream_create(PyObject *py, bool block);
4acff284
RD
225
226
1e7ecb7b
RD
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
bc5f2236
RD
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
1e7ecb7b
RD
244struct wxPyCoreAPI {
245
bc5f2236
RD
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;
1e7ecb7b 252
4268f798
RD
253 PyThreadState* (*p_wxPyBeginAllowThreads)();
254 void (*p_wxPyEndAllowThreads)(PyThreadState* state);
255 void (*p_wxPyBeginBlockThreads)();
256 void (*p_wxPyEndBlockThreads)();
19a97bd6 257
a541c325 258 PyObject* (*p_wxPyConstructObject)(void *, const wxString&, int);
1e7ecb7b
RD
259 PyObject* (*p_wxPy_ConvertList)(wxListBase* list, const char* className);
260
c8bc7bb8 261 wxString* (*p_wxString_in_helper)(PyObject* source);
a541c325
RD
262 wxString (*p_Py2wxString)(PyObject* source);
263 PyObject* (*p_wx2PyString)(const wxString& src);
c8bc7bb8 264
1e7ecb7b
RD
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);
e0672e2f 269 wxPoint* (*p_wxPoint_LIST_helper)(PyObject* source, int* npoints);
1e7ecb7b
RD
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);
1e4a197e 279 bool (*p_wxPoint2DDouble_helper)(PyObject* source, wxPoint2DDouble** obj);
1e7ecb7b 280
0122b7e3 281 void (*p_wxPyCBH_setCallbackInfo)(wxPyCallbackHelper& cbh, PyObject* self, PyObject* klass, int incref);
1e7ecb7b
RD
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
a541c325 287 PyObject* (*p_wxPyClassExists)(const wxString& className);
2f4e9287
RD
288 PyObject* (*p_wxPyMake_wxObject)(wxObject* source, bool checkEvtHandler);
289 PyObject* (*p_wxPyMake_wxSizer)(wxSizer* source);
9416aa89 290 void (*p_wxPyPtrTypeMap_Add)(const char* commonName, const char* ptrName);
7b7ac0ab 291 PyObject* (*p_wxArrayString2PyList_helper)(const wxArrayString& arr);
293a0a86 292 PyObject* (*p_wxArrayInt2PyList_helper)(const wxArrayInt& arr);
4acff284
RD
293
294 void (*p_wxPyClientData_dtor)(wxPyClientData*);
295 void (*p_wxPyUserData_dtor)(wxPyUserData*);
296 void (*p_wxPyOORClientData_dtor)(wxPyOORClientData*);
249a57f4
RD
297
298 wxPyCBInputStream* (*p_wxPyCBInputStream_create)(PyObject *py, bool block);
299
4acff284
RD
300};
301
302#ifdef wxPyUSE_EXPORT
a2426843
RD
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;
4acff284
RD
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;
1e7ecb7b
RD
345};
346
4acff284
RD
347
348class wxPyOORClientData : public wxPyClientData {
349public:
350 wxPyOORClientData(PyObject* obj)
351 : wxPyClientData(obj) {}
352
353 ~wxPyOORClientData() {
1e7ecb7b 354#ifdef wxPyUSE_EXPORT
4acff284
RD
355 wxPyCoreAPIPtr->p_wxPyOORClientData_dtor(this);
356#else
357 wxPyOORClientData_dtor(this);
1e7ecb7b 358#endif
4acff284
RD
359 }
360};
1e7ecb7b
RD
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
0122b7e3 404void wxPyCBH_setCallbackInfo(wxPyCallbackHelper& cbh, PyObject* self, PyObject* klass, int incref);
1e7ecb7b
RD
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
900d9886 412
bb0054cd
RD
413//---------------------------------------------------------------------------
414
1e4a197e
RD
415// This is used in C++ classes that need to be able to make callback to
416// "overloaded" python methods
417
418#define PYPRIVATE \
0122b7e3
RD
419 void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \
420 wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \
1e4a197e 421 } \
c368d904 422 private: wxPyCallbackHelper m_myInst
efc5f224 423
1e4a197e
RD
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.
efc5f224
RD
484//---------------------------------------------------------------------------
485
d559219f
RD
486#define DEC_PYCALLBACK__(CBNAME) \
487 void CBNAME(); \
488 void base_##CBNAME();
489
490
19a97bd6
RD
491#define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
492 void CLASS::CBNAME() { \
493 bool found; \
1e4a197e 494 wxPyBeginBlockThreads(); \
19a97bd6
RD
495 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
496 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1e4a197e 497 wxPyEndBlockThreads(); \
19a97bd6
RD
498 if (! found) \
499 PCLASS::CBNAME(); \
500 } \
501 void CLASS::base_##CBNAME() { \
502 PCLASS::CBNAME(); \
d559219f
RD
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) { \
059a841c 514 bool rval=FALSE, found; \
4268f798 515 wxPyBeginBlockThreads(); \
19a97bd6 516 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1e7ecb7b 517 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
4268f798 518 wxPyEndBlockThreads(); \
19a97bd6 519 if (! found) \
d559219f 520 rval = PCLASS::CBNAME(a,b); \
d559219f 521 return rval; \
bb0054cd 522 } \
d559219f 523 bool CLASS::base_##CBNAME(int a, int b) { \
bb0054cd
RD
524 return PCLASS::CBNAME(a,b); \
525 }
526
527//---------------------------------------------------------------------------
528
c368d904
RD
529#define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
530 void CBNAME(int a, int b); \
531 void base_##CBNAME(int a, int b);
532
533
534#define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
535 void CLASS::CBNAME(int a, int b) { \
19a97bd6 536 bool found; \
b0e5c039 537 wxPyBeginBlockThreads(); \
19a97bd6
RD
538 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
539 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
b0e5c039 540 wxPyEndBlockThreads(); \
19a97bd6 541 if (! found) \
c368d904 542 PCLASS::CBNAME(a,b); \
c368d904
RD
543 } \
544 void CLASS::base_##CBNAME(int a, int b) { \
545 PCLASS::CBNAME(a,b); \
546 }
547
548//---------------------------------------------------------------------------
549
b0e5c039
RD
550#define DEC_PYCALLBACK_VOID_INT4(CBNAME) \
551 void CBNAME(int a, int b, int c, int d); \
552 void base_##CBNAME(int a, int b, int c, int d);
553
554
555#define IMP_PYCALLBACK_VOID_INT4(CLASS, PCLASS, CBNAME) \
556 void CLASS::CBNAME(int a, int b, int c, int d) { \
557 bool found; \
558 wxPyBeginBlockThreads(); \
559 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
560 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiii)",a,b,c,d)); \
561 wxPyEndBlockThreads(); \
562 if (! found) \
563 PCLASS::CBNAME(a,b,c,d); \
564 } \
565 void CLASS::base_##CBNAME(int a, int b, int c, int d) { \
566 PCLASS::CBNAME(a,b,c,d); \
567 }
568
569//---------------------------------------------------------------------------
570#define DEC_PYCALLBACK_VOID_INT5(CBNAME) \
571 void CBNAME(int a, int b, int c, int d, int e); \
572 void base_##CBNAME(int a, int b, int c, int d, int e);
573
574
575#define IMP_PYCALLBACK_VOID_INT5(CLASS, PCLASS, CBNAME) \
576 void CLASS::CBNAME(int a, int b, int c, int d, int e) { \
577 bool found; \
578 wxPyBeginBlockThreads(); \
579 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
580 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiiii)",a,b,c,d,e)); \
581 wxPyEndBlockThreads(); \
582 if (! found) \
583 PCLASS::CBNAME(a,b,c,d,e); \
584 } \
585 void CLASS::base_##CBNAME(int a, int b, int c, int d, int e) { \
586 PCLASS::CBNAME(a,b,c,d,e); \
587 }
588
589//---------------------------------------------------------------------------
590
591#define DEC_PYCALLBACK_VOID_INTPINTP_const(CBNAME) \
592 void CBNAME(int* a, int* b) const; \
593 void base_##CBNAME(int* a, int* b) const;
594
595
596#define IMP_PYCALLBACK_VOID_INTPINTP_const(CLASS, PCLASS, CBNAME) \
597 void CLASS::CBNAME(int* a, int* b) const { \
598 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
599 bool found; \
600 wxPyBeginBlockThreads(); \
601 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
602 PyObject* ro; \
603 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
604 if (ro) { \
605 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
606 PyObject* o1 = PySequence_GetItem(ro, 0); \
607 PyObject* o2 = PySequence_GetItem(ro, 1); \
608 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
609 *a = PyInt_AsLong(o1); *b = PyInt_AsLong(o2); \
610 } \
611 else \
612 PyErr_SetString(PyExc_TypeError, errmsg); \
613 Py_DECREF(o1); \
614 Py_DECREF(o2); \
615 } \
616 else { \
617 PyErr_SetString(PyExc_TypeError, errmsg); \
618 } \
619 Py_DECREF(ro); \
620 } \
621 } \
622 wxPyEndBlockThreads(); \
623 if (! found) \
624 PCLASS::CBNAME(a,b); \
625 } \
626 void CLASS::base_##CBNAME(int* a, int* b) const { \
627 PCLASS::CBNAME(a,b); \
628 }
629
630
631//---------------------------------------------------------------------------
632
633#define DEC_PYCALLBACK_SIZE_const(CBNAME) \
634 wxSize CBNAME() const; \
635 wxSize base_##CBNAME() const;
636
637
638#define IMP_PYCALLBACK_SIZE_const(CLASS, PCLASS, CBNAME) \
639 wxSize CLASS::CBNAME() const { \
640 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
641 bool found; wxSize rval(0,0); \
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 rval = wxSize(PyInt_AsLong(o1), 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 return PCLASS::CBNAME(); \
667 else \
668 return rval; \
669 } \
670 wxSize CLASS::base_##CBNAME() const { \
671 return PCLASS::CBNAME(); \
672 }
673
674
675//---------------------------------------------------------------------------
676
d559219f
RD
677#define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
678 bool CBNAME(int a); \
679 bool base_##CBNAME(int a);
680
681
682#define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
683 bool CLASS::CBNAME(int a) { \
059a841c 684 bool rval=FALSE, found; \
b0e5c039 685 wxPyBeginBlockThreads(); \
19a97bd6 686 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
059a841c 687 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
b0e5c039 688 wxPyEndBlockThreads(); \
19a97bd6 689 if (! found) \
d559219f 690 rval = PCLASS::CBNAME(a); \
d559219f 691 return rval; \
bb0054cd 692 } \
d559219f 693 bool CLASS::base_##CBNAME(int a) { \
bb0054cd
RD
694 return PCLASS::CBNAME(a); \
695 }
696
efc5f224
RD
697//---------------------------------------------------------------------------
698
d559219f
RD
699#define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
700 bool CBNAME(int a);
701
702
703#define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
704 bool CLASS::CBNAME(int a) { \
059a841c 705 bool rval=FALSE; \
4268f798 706 wxPyBeginBlockThreads(); \
19a97bd6 707 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1e7ecb7b 708 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
194fa2ac 709 else rval = FALSE; \
4268f798 710 wxPyEndBlockThreads(); \
d559219f 711 return rval; \
bb0054cd
RD
712 }
713
714
715//---------------------------------------------------------------------------
716
d559219f
RD
717#define DEC_PYCALLBACK__DC(CBNAME) \
718 void CBNAME(wxDC& a); \
719 void base_##CBNAME(wxDC& a);
720
721
19a97bd6
RD
722#define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
723 void CLASS::CBNAME(wxDC& a) { \
724 bool found; \
4268f798 725 wxPyBeginBlockThreads(); \
19a97bd6
RD
726 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
727 PyObject* obj = wxPyMake_wxObject(&a); \
728 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
729 Py_DECREF(obj); \
730 } \
4268f798 731 wxPyEndBlockThreads(); \
19a97bd6
RD
732 if (! found) \
733 PCLASS::CBNAME(a); \
734 } \
735 void CLASS::base_##CBNAME(wxDC& a) { \
736 PCLASS::CBNAME(a); \
bb0054cd
RD
737 }
738
efc5f224
RD
739
740
bb0054cd
RD
741//---------------------------------------------------------------------------
742
d559219f
RD
743#define DEC_PYCALLBACK__DCBOOL(CBNAME) \
744 void CBNAME(wxDC& a, bool b); \
745 void base_##CBNAME(wxDC& a, bool b);
746
747
748#define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
749 void CLASS::CBNAME(wxDC& a, bool b) { \
19a97bd6 750 bool found; \
4268f798 751 wxPyBeginBlockThreads(); \
19a97bd6
RD
752 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
753 PyObject* obj = wxPyMake_wxObject(&a); \
1e7ecb7b 754 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
de20db99
RD
755 Py_DECREF(obj); \
756 } \
4268f798 757 wxPyEndBlockThreads(); \
19a97bd6 758 if (! found) \
efc5f224
RD
759 PCLASS::CBNAME(a, b); \
760 } \
d559219f 761 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
efc5f224
RD
762 PCLASS::CBNAME(a, b); \
763 }
764
765//---------------------------------------------------------------------------
766
d559219f
RD
767#define DEC_PYCALLBACK__DCBOOL(CBNAME) \
768 void CBNAME(wxDC& a, bool b); \
769 void base_##CBNAME(wxDC& a, bool b);
770
771
772#define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
773 void CLASS::CBNAME(wxDC& a, bool b) { \
19a97bd6 774 bool found; \
4268f798 775 wxPyBeginBlockThreads(); \
19a97bd6
RD
776 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
777 PyObject* obj = wxPyMake_wxObject(&a); \
1e7ecb7b 778 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
de20db99
RD
779 Py_DECREF(obj); \
780 } \
4268f798 781 wxPyEndBlockThreads(); \
19a97bd6 782 if (! found) \
efc5f224
RD
783 PCLASS::CBNAME(a, b); \
784 } \
d559219f 785 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
efc5f224
RD
786 PCLASS::CBNAME(a, b); \
787 }
788
789//---------------------------------------------------------------------------
790
d559219f
RD
791#define DEC_PYCALLBACK__2DBL(CBNAME) \
792 void CBNAME(double a, double b); \
793 void base_##CBNAME(double a, double b);
794
795
19a97bd6
RD
796#define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
797 void CLASS::CBNAME(double a, double b) { \
798 bool found; \
4268f798 799 wxPyBeginBlockThreads(); \
19a97bd6
RD
800 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
801 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
4268f798 802 wxPyEndBlockThreads(); \
19a97bd6
RD
803 if (! found) \
804 PCLASS::CBNAME(a, b); \
805 } \
806 void CLASS::base_##CBNAME(double a, double b) { \
807 PCLASS::CBNAME(a, b); \
efc5f224
RD
808 }
809
810//---------------------------------------------------------------------------
811
d559219f
RD
812#define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
813 void CBNAME(double a, double b, int c, int d); \
814 void base_##CBNAME(double a, double b, int c, int d);
815
816
817#define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
818 void CLASS::CBNAME(double a, double b, int c, int d) { \
19a97bd6 819 bool found; \
4268f798 820 wxPyBeginBlockThreads(); \
19a97bd6
RD
821 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
822 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
efc5f224 823 a,b,c,d)); \
4268f798 824 wxPyEndBlockThreads(); \
19a97bd6 825 if (! found) \
efc5f224
RD
826 PCLASS::CBNAME(a, b, c, d); \
827 } \
d559219f 828 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
efc5f224
RD
829 PCLASS::CBNAME(a, b, c, d); \
830 }
831
832//---------------------------------------------------------------------------
833
19a97bd6 834#define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
d559219f
RD
835 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
836 void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
837
838
839#define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
840 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
19a97bd6 841 bool found; \
4268f798 842 wxPyBeginBlockThreads(); \
19a97bd6
RD
843 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
844 PyObject* obj = wxPyMake_wxObject(&a); \
1e7ecb7b 845 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
de20db99
RD
846 Py_DECREF(obj); \
847 } \
4268f798 848 wxPyEndBlockThreads(); \
19a97bd6 849 if (! found) \
d559219f 850 PCLASS::CBNAME(a, b, c, d, e, f); \
d559219f
RD
851 } \
852 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
853 PCLASS::CBNAME(a, b, c, d, e, f); \
efc5f224
RD
854 }
855
856//---------------------------------------------------------------------------
857
d559219f
RD
858#define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
859 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
860 bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
861
862
863#define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
864 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
19a97bd6 865 bool found; \
4268f798 866 wxPyBeginBlockThreads(); \
059a841c 867 bool rval=FALSE; \
19a97bd6
RD
868 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
869 PyObject* obj = wxPyMake_wxObject(&a); \
1e7ecb7b 870 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
de20db99
RD
871 Py_DECREF(obj); \
872 } \
4268f798 873 wxPyEndBlockThreads(); \
19a97bd6 874 if (! found) \
99a49d3e 875 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
99a49d3e 876 return rval; \
d559219f
RD
877 } \
878 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
879 return PCLASS::CBNAME(a, b, c, d, e, f); \
efc5f224
RD
880 }
881
882//---------------------------------------------------------------------------
883
d559219f
RD
884#define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
885 void CBNAME(bool a, double b, double c, int d, int e); \
886 void base_##CBNAME(bool a, double b, double c, int d, int e);
887
888
889#define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
890 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
19a97bd6 891 bool found; \
4268f798 892 wxPyBeginBlockThreads(); \
19a97bd6 893 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
f2e1c18a 894 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
d559219f 895 (int)a,b,c,d,e)); \
4268f798 896 wxPyEndBlockThreads(); \
19a97bd6 897 if (! found) \
d559219f 898 PCLASS::CBNAME(a, b, c, d, e); \
d559219f
RD
899 } \
900 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
901 PCLASS::CBNAME(a, b, c, d, e); \
efc5f224
RD
902 }
903
904//---------------------------------------------------------------------------
905
19a97bd6 906#define DEC_PYCALLBACK__DC4DBL(CBNAME) \
d559219f
RD
907 void CBNAME(wxDC& a, double b, double c, double d, double e); \
908 void base_##CBNAME(wxDC& a, double b, double c, double d, double e);
909
910
911#define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
912 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
19a97bd6 913 bool found; \
4268f798 914 wxPyBeginBlockThreads(); \
19a97bd6
RD
915 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
916 PyObject* obj = wxPyMake_wxObject(&a); \
1e7ecb7b 917 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
de20db99
RD
918 Py_DECREF(obj); \
919 } \
4268f798 920 wxPyEndBlockThreads(); \
19a97bd6 921 if (! found) \
d559219f 922 PCLASS::CBNAME(a, b, c, d, e); \
d559219f
RD
923 } \
924 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
925 PCLASS::CBNAME(a, b, c, d, e); \
efc5f224
RD
926 }
927
928//---------------------------------------------------------------------------
929
d559219f
RD
930#define DEC_PYCALLBACK__DCBOOL(CBNAME) \
931 void CBNAME(wxDC& a, bool b); \
932 void base_##CBNAME(wxDC& a, bool b);
933
934
19a97bd6
RD
935#define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
936 void CLASS::CBNAME(wxDC& a, bool b) { \
937 bool found; \
4268f798 938 wxPyBeginBlockThreads(); \
19a97bd6
RD
939 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
940 PyObject* obj = wxPyMake_wxObject(&a); \
941 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
942 Py_DECREF(obj); \
943 } \
4268f798 944 wxPyEndBlockThreads(); \
19a97bd6
RD
945 if (! found) \
946 PCLASS::CBNAME(a, b); \
947 } \
948 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
949 PCLASS::CBNAME(a, b); \
efc5f224 950 }
bb0054cd 951
7bf85405 952//---------------------------------------------------------------------------
7bf85405 953
d559219f
RD
954#define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
955 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
956 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f);
957
958
959#define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
960 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
961 int e, int f) { \
19a97bd6 962 bool found; \
4268f798 963 wxPyBeginBlockThreads(); \
19a97bd6
RD
964 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
965 PyObject* obj = wxPyMake_wxObject(a); \
1e7ecb7b 966 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
de20db99
RD
967 Py_DECREF(obj); \
968 } \
4268f798 969 wxPyEndBlockThreads(); \
19a97bd6 970 if (! found) \
d559219f 971 PCLASS::CBNAME(a, b, c, d, e, f); \
d559219f
RD
972 } \
973 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
974 int e, int f) { \
975 PCLASS::CBNAME(a, b, c, d, e, f); \
efc5f224
RD
976 }
977
978//---------------------------------------------------------------------------
979
d559219f
RD
980#define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
981 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
982 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e);
983
984
985#define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
986 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
19a97bd6 987 bool found; \
4268f798 988 wxPyBeginBlockThreads(); \
19a97bd6
RD
989 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
990 PyObject* obj = wxPyMake_wxObject(a); \
1e7ecb7b 991 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
de20db99
RD
992 Py_DECREF(obj); \
993 } \
4268f798 994 wxPyEndBlockThreads(); \
19a97bd6 995 if (! found) \
d559219f 996 PCLASS::CBNAME(a, b, c, d, e); \
d559219f
RD
997 } \
998 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
999 int d, int e) { \
1000 PCLASS::CBNAME(a, b, c, d, e); \
efc5f224
RD
1001 }
1002
1003//---------------------------------------------------------------------------
1004
d559219f
RD
1005#define DEC_PYCALLBACK__2DBLINT(CBNAME) \
1006 void CBNAME(double a, double b, int c); \
1007 void base_##CBNAME(double a, double b, int c);
1008
1009
19a97bd6
RD
1010#define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
1011 void CLASS::CBNAME(double a, double b, int c) { \
1012 bool found; \
4268f798 1013 wxPyBeginBlockThreads(); \
19a97bd6
RD
1014 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1015 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
4268f798 1016 wxPyEndBlockThreads(); \
19a97bd6
RD
1017 if (! found) \
1018 PCLASS::CBNAME(a, b, c); \
1019 } \
1020 void CLASS::base_##CBNAME(double a, double b, int c) { \
1021 PCLASS::CBNAME(a, b, c); \
efc5f224
RD
1022 }
1023
1024//---------------------------------------------------------------------------
1025
d559219f
RD
1026#define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
1027 void CBNAME(bool a, double b, double c, int d); \
1028 void base_##CBNAME(bool a, double b, double c, int d);
1029
1030
1031#define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
1032 void CLASS::CBNAME(bool a, double b, double c, int d) { \
19a97bd6 1033 bool found; \
a66212dc 1034 wxPyBeginBlockThreads(); \
19a97bd6
RD
1035 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1036 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\
a66212dc 1037 wxPyEndBlockThreads(); \
19a97bd6 1038 if (! found) \
d559219f 1039 PCLASS::CBNAME(a, b, c, d); \
d559219f
RD
1040 } \
1041 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
1042 PCLASS::CBNAME(a, b, c, d); \
efc5f224
RD
1043 }
1044
1045//---------------------------------------------------------------------------
1046//---------------------------------------------------------------------------
389c5527
RD
1047
1048#define DEC_PYCALLBACK__STRING(CBNAME) \
1049 void CBNAME(const wxString& a); \
1050 void base_##CBNAME(const wxString& a);
1051
19a97bd6
RD
1052#define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
1053 void CLASS::CBNAME(const wxString& a) { \
1054 bool found; \
a66212dc
RD
1055 wxPyBeginBlockThreads(); \
1056 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1057 PyObject* s = wx2PyString(a); \
1058 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1059 Py_DECREF(s); \
1060 } \
1061 wxPyEndBlockThreads(); \
19a97bd6
RD
1062 if (! found) \
1063 PCLASS::CBNAME(a); \
1064 } \
1065 void CLASS::base_##CBNAME(const wxString& a) { \
1066 PCLASS::CBNAME(a); \
389c5527
RD
1067 }
1068
1069//---------------------------------------------------------------------------
1070
1071#define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
1072 bool CBNAME(const wxString& a); \
1073 bool base_##CBNAME(const wxString& a);
1074
389c5527
RD
1075#define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
1076 bool CLASS::CBNAME(const wxString& a) { \
059a841c 1077 bool rval=FALSE; \
19a97bd6 1078 bool found; \
a66212dc
RD
1079 wxPyBeginBlockThreads(); \
1080 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1081 PyObject* s = wx2PyString(a); \
1082 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1083 Py_DECREF(s); \
1084 } \
1085 wxPyEndBlockThreads(); \
19a97bd6 1086 if (! found) \
389c5527 1087 rval = PCLASS::CBNAME(a); \
389c5527
RD
1088 return rval; \
1089 } \
1090 bool CLASS::base_##CBNAME(const wxString& a) { \
1091 return PCLASS::CBNAME(a); \
1092 }
1093
1094//---------------------------------------------------------------------------
1095
c368d904
RD
1096#define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
1097 bool CBNAME(const wxString& a);
c8bc7bb8 1098
a66212dc
RD
1099#define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
1100 bool CLASS::CBNAME(const wxString& a) { \
1101 bool rval=FALSE; \
1102 wxPyBeginBlockThreads(); \
1103 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1104 PyObject* s = wx2PyString(a); \
1105 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1106 Py_DECREF(s); \
1107 } \
1108 wxPyEndBlockThreads(); \
1109 return rval; \
1110 } \
c368d904
RD
1111
1112//---------------------------------------------------------------------------
1113
1114#define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
1115 wxString CBNAME(const wxString& a); \
1116
1117#define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
1118 wxString CLASS::CBNAME(const wxString& a) { \
1119 wxString rval; \
a541c325 1120 wxPyBeginBlockThreads(); \
19a97bd6 1121 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
c368d904 1122 PyObject* ro; \
a66212dc
RD
1123 PyObject* s = wx2PyString(a); \
1124 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1125 Py_DECREF(s); \
c368d904 1126 if (ro) { \
a541c325
RD
1127 rval = Py2wxString(ro); \
1128 Py_DECREF(ro); \
c368d904
RD
1129 } \
1130 } \
a541c325 1131 wxPyEndBlockThreads(); \
c368d904
RD
1132 return rval; \
1133 } \
1134
1135//---------------------------------------------------------------------------
1136
fd512ba2
RD
1137#define DEC_PYCALLBACK_STRING_STRING(CBNAME) \
1138 wxString CBNAME(const wxString& a); \
1139 wxString base_##CBNAME(const wxString& a);
1140
1141#define IMP_PYCALLBACK_STRING_STRING(CLASS, PCLASS, CBNAME) \
1142 wxString CLASS::CBNAME(const wxString& a) { \
1143 wxString rval; \
1144 bool found; \
1145 wxPyBeginBlockThreads(); \
1146 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1147 PyObject* ro; \
1148 PyObject* s = wx2PyString(a); \
1149 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1150 Py_DECREF(s); \
1151 if (ro) { \
1152 rval = Py2wxString(ro); \
1153 Py_DECREF(ro); \
1154 } \
1155 } \
1156 if (! found) \
1157 rval = PCLASS::CBNAME(a); \
1158 wxPyEndBlockThreads(); \
1159 return rval; \
1160 } \
1161
1162//---------------------------------------------------------------------------
1163
c368d904
RD
1164#define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
1165 wxString CBNAME(const wxString& a,int b); \
1166
1167#define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
1168 wxString CLASS::CBNAME(const wxString& a,int b) { \
1169 wxString rval; \
a66212dc 1170 wxPyBeginBlockThreads(); \
19a97bd6 1171 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
c368d904 1172 PyObject* ro; \
a66212dc
RD
1173 PyObject* s = wx2PyString(a); \
1174 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oi)",s,b)); \
1175 Py_DECREF(s); \
c368d904 1176 if (ro) { \
a541c325
RD
1177 rval = Py2wxString(ro); \
1178 Py_DECREF(ro); \
c368d904
RD
1179 } \
1180 } \
a541c325 1181 wxPyEndBlockThreads(); \
c368d904
RD
1182 return rval; \
1183 } \
1184
1185//---------------------------------------------------------------------------
1186
f0261a72
RD
1187#define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
1188 bool CBNAME(const wxString& a, const wxString& b); \
1189 bool base_##CBNAME(const wxString& a, const wxString& b);
1190
f0261a72
RD
1191#define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
1192 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
059a841c 1193 bool rval=FALSE; \
19a97bd6 1194 bool found; \
a66212dc
RD
1195 wxPyBeginBlockThreads(); \
1196 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1197 PyObject* s1 = wx2PyString(a); \
1198 PyObject* s2 = wx2PyString(b); \
1199 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",s1,s2)); \
1200 Py_DECREF(s1); \
1201 Py_DECREF(s2); \
1202 } \
a541c325 1203 wxPyEndBlockThreads(); \
19a97bd6 1204 if (! found) \
f0261a72 1205 rval = PCLASS::CBNAME(a, b); \
f0261a72
RD
1206 return rval; \
1207 } \
1208 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
1209 return PCLASS::CBNAME(a, b); \
1210 }
1211
1212//---------------------------------------------------------------------------
1213
389c5527
RD
1214#define DEC_PYCALLBACK_STRING_(CBNAME) \
1215 wxString CBNAME(); \
1216 wxString base_##CBNAME();
1217
389c5527
RD
1218#define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
1219 wxString CLASS::CBNAME() { \
1220 wxString rval; \
19a97bd6 1221 bool found; \
4268f798 1222 wxPyBeginBlockThreads(); \
19a97bd6 1223 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
389c5527 1224 PyObject* ro; \
19a97bd6 1225 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
f6bcfd97 1226 if (ro) { \
a541c325
RD
1227 rval = Py2wxString(ro); \
1228 Py_DECREF(ro); \
f6bcfd97 1229 } \
389c5527 1230 } \
a541c325 1231 wxPyEndBlockThreads(); \
19a97bd6 1232 if (! found) \
b1462dfa 1233 rval = PCLASS::CBNAME(); \
389c5527
RD
1234 return rval; \
1235 } \
b1462dfa
RD
1236 wxString CLASS::base_##CBNAME() { \
1237 return PCLASS::CBNAME(); \
389c5527
RD
1238 }
1239
1240//---------------------------------------------------------------------------
1241
1e4a197e
RD
1242#define DEC_PYCALLBACK_STRING__const(CBNAME) \
1243 wxString CBNAME() const; \
1244 wxString base_##CBNAME() const;
1245
1246#define IMP_PYCALLBACK_STRING__const(CLASS, PCLASS, CBNAME) \
1247 wxString CLASS::CBNAME() const { \
1248 wxString rval; \
1249 bool found; \
1250 wxPyBeginBlockThreads(); \
1251 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1252 PyObject* ro; \
1253 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1254 if (ro) { \
1255 rval = Py2wxString(ro); \
1256 Py_DECREF(ro); \
1257 } \
1258 } \
1259 wxPyEndBlockThreads(); \
1260 if (! found) \
1261 rval = PCLASS::CBNAME(); \
1262 return rval; \
1263 } \
1264 wxString CLASS::base_##CBNAME() const { \
1265 return PCLASS::CBNAME(); \
1266 }
1267
1268//---------------------------------------------------------------------------
1269
389c5527
RD
1270#define DEC_PYCALLBACK_STRING__pure(CBNAME) \
1271 wxString CBNAME();
1272
389c5527
RD
1273#define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
1274 wxString CLASS::CBNAME() { \
1275 wxString rval; \
4268f798 1276 wxPyBeginBlockThreads(); \
19a97bd6 1277 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
389c5527 1278 PyObject* ro; \
19a97bd6 1279 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
f6bcfd97 1280 if (ro) { \
a541c325
RD
1281 rval = Py2wxString(ro); \
1282 Py_DECREF(ro); \
f6bcfd97 1283 } \
389c5527 1284 } \
a541c325 1285 wxPyEndBlockThreads(); \
389c5527
RD
1286 return rval; \
1287 }
1288
1289//---------------------------------------------------------------------------
1290
1291#define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
1292 bool CBNAME(const wxHtmlTag& a); \
1293
1294
1295#define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
1296 bool CLASS::CBNAME(const wxHtmlTag& a) { \
059a841c 1297 bool rval=FALSE; \
a66212dc 1298 wxPyBeginBlockThreads(); \
19a97bd6 1299 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1e4a197e 1300 PyObject* obj = wxPyConstructObject((void*)&a, wxT("wxHtmlTag"), 0); \
19a97bd6 1301 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
de20db99
RD
1302 Py_DECREF(obj); \
1303 } \
a66212dc 1304 wxPyEndBlockThreads(); \
389c5527
RD
1305 return rval; \
1306 }
1307
0122b7e3
RD
1308//---------------------------------------------------------------------------
1309
1310#define DEC_PYCALLBACK__CELLINTINT(CBNAME) \
1311 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y); \
1312 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y);
1313
1314#define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \
1315 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
0122b7e3 1316 bool found; \
a66212dc 1317 wxPyBeginBlockThreads(); \
0122b7e3 1318 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1e4a197e 1319 PyObject* obj = wxPyConstructObject((void*)cell, wxT("wxHtmlCell"), 0); \
0122b7e3
RD
1320 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \
1321 Py_DECREF(obj); \
1322 } \
a66212dc 1323 wxPyEndBlockThreads(); \
0122b7e3
RD
1324 if (! found) \
1325 PCLASS::CBNAME(cell, x, y); \
1326 } \
1327 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1328 PCLASS::CBNAME(cell, x, y); \
1329 }
1330
1331
1332//---------------------------------------------------------------------------
1333
1334#define DEC_PYCALLBACK__CELLINTINTME(CBNAME) \
1335 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e); \
1336 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e);
1337
1338#define IMP_PYCALLBACK__CELLINTINTME(CLASS, PCLASS, CBNAME) \
1339 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1340 bool found; \
a66212dc 1341 wxPyBeginBlockThreads(); \
0122b7e3 1342 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1e4a197e
RD
1343 PyObject* obj = wxPyConstructObject((void*)cell, wxT("wxHtmlCell"), 0); \
1344 PyObject* o2 = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
0122b7e3
RD
1345 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1346 Py_DECREF(obj); \
1347 Py_DECREF(o2); \
1348 } \
a66212dc 1349 wxPyEndBlockThreads(); \
0122b7e3 1350 if (! found) \
a66212dc 1351 PCLASS::CBNAME(cell, x, y, e); \
0122b7e3
RD
1352 } \
1353 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
a66212dc 1354 PCLASS::CBNAME(cell, x, y, e); \
0122b7e3
RD
1355 }
1356
1357
1358
389c5527 1359//---------------------------------------------------------------------------
2f90df85
RD
1360
1361#define DEC_PYCALLBACK___pure(CBNAME) \
1362 void CBNAME(); \
1363
1364
1365#define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1366 void CLASS::CBNAME() { \
a66212dc 1367 wxPyBeginBlockThreads(); \
19a97bd6
RD
1368 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1369 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
a66212dc 1370 wxPyEndBlockThreads(); \
2f90df85
RD
1371 }
1372
1373//---------------------------------------------------------------------------
1374
1375#define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1376 wxSize CBNAME(); \
1377
1378
1379#define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1380 wxSize CLASS::CBNAME() { \
db0ff83e 1381 const char* errmsg = #CBNAME " should return a 2-tuple of integers or a wxSize object."; \
2f90df85 1382 wxSize rval(0,0); \
db0ff83e 1383 wxPyBeginBlockThreads(); \
19a97bd6 1384 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2f90df85
RD
1385 PyObject* ro; \
1386 wxSize* ptr; \
19a97bd6 1387 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
f6bcfd97
BP
1388 if (ro) { \
1389 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \
1390 rval = *ptr; \
db0ff83e
RD
1391 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
1392 PyObject* o1 = PySequence_GetItem(ro, 0); \
1393 PyObject* o2 = PySequence_GetItem(ro, 1); \
1394 if (PyNumber_Check(o1) && PyNumber_Check(o2)) \
1395 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
1396 else \
1397 PyErr_SetString(PyExc_TypeError, errmsg); \
1398 Py_DECREF(o1); \
1399 Py_DECREF(o2); \
1400 } \
1401 else { \
1402 PyErr_SetString(PyExc_TypeError, errmsg); \
1403 } \
f6bcfd97
BP
1404 Py_DECREF(ro); \
1405 } \
2f90df85 1406 } \
db0ff83e 1407 wxPyEndBlockThreads(); \
2f90df85
RD
1408 return rval; \
1409 }
1410
1411//---------------------------------------------------------------------------
1412
1413#define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1414 bool CBNAME(wxWindow* a); \
1415 bool base_##CBNAME(wxWindow* a);
1416
1417
19a97bd6
RD
1418#define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1419 bool CLASS::CBNAME(wxWindow* a) { \
059a841c 1420 bool rval=FALSE; \
19a97bd6 1421 bool found; \
a66212dc 1422 wxPyBeginBlockThreads(); \
19a97bd6
RD
1423 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1424 PyObject* obj = wxPyMake_wxObject(a); \
1425 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1426 Py_DECREF(obj); \
1427 } \
a66212dc 1428 wxPyEndBlockThreads(); \
19a97bd6
RD
1429 if (! found) \
1430 rval = PCLASS::CBNAME(a); \
1431 return rval; \
1432 } \
1433 bool CLASS::base_##CBNAME(wxWindow* a) { \
1434 return PCLASS::CBNAME(a); \
2f90df85
RD
1435 }
1436
389c5527 1437//---------------------------------------------------------------------------
2f90df85 1438
aaad759f
RD
1439#define DEC_PYCALLBACK_VOID_WXWINBASE(CBNAME) \
1440 void CBNAME(wxWindowBase* a); \
1441 void base_##CBNAME(wxWindowBase* a);
1442
1443
1444#define IMP_PYCALLBACK_VOID_WXWINBASE(CLASS, PCLASS, CBNAME) \
1445 void CLASS::CBNAME(wxWindowBase* a) { \
1446 bool found; \
1447 wxPyBeginBlockThreads(); \
1448 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1449 PyObject* obj = wxPyMake_wxObject(a); \
1450 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1451 Py_DECREF(obj); \
1452 } \
1453 wxPyEndBlockThreads(); \
1454 if (! found) \
1455 PCLASS::CBNAME(a); \
1456 } \
1457 void CLASS::base_##CBNAME(wxWindowBase* a) { \
1458 PCLASS::CBNAME(a); \
1459 }
1460
1461//---------------------------------------------------------------------------
1462
2f90df85
RD
1463#define DEC_PYCALLBACK_BOOL_(CBNAME) \
1464 bool CBNAME(); \
1465 bool base_##CBNAME();
1466
1467
19a97bd6
RD
1468#define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1469 bool CLASS::CBNAME() { \
059a841c 1470 bool rval=FALSE; \
19a97bd6 1471 bool found; \
b0e5c039 1472 wxPyBeginBlockThreads(); \
19a97bd6
RD
1473 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1474 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
b0e5c039 1475 wxPyEndBlockThreads(); \
19a97bd6
RD
1476 if (! found) \
1477 rval = PCLASS::CBNAME(); \
1478 return rval; \
1479 } \
1480 bool CLASS::base_##CBNAME() { \
1481 return PCLASS::CBNAME(); \
2f90df85
RD
1482 }
1483
b1462dfa
RD
1484//---------------------------------------------------------------------------
1485
b0e5c039
RD
1486#define DEC_PYCALLBACK_BOOL_const(CBNAME) \
1487 bool CBNAME() const; \
1488 bool base_##CBNAME() const;
1489
1490
1491#define IMP_PYCALLBACK_BOOL_const(CLASS, PCLASS, CBNAME) \
1492 bool CLASS::CBNAME() const { \
1493 bool rval=FALSE; \
1494 bool found; \
1495 wxPyBeginBlockThreads(); \
1496 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1497 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1498 wxPyEndBlockThreads(); \
1499 if (! found) \
1500 rval = PCLASS::CBNAME(); \
1501 return rval; \
1502 } \
1503 bool CLASS::base_##CBNAME() const { \
1504 return PCLASS::CBNAME(); \
1505 }
1506
1507//---------------------------------------------------------------------------
1508
19a97bd6
RD
1509#define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1510 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \
b1462dfa
RD
1511 wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def);
1512
1513
19a97bd6
RD
1514#define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1515 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
059a841c 1516 int rval=0; \
19a97bd6 1517 bool found; \
cac344f6 1518 wxPyBeginBlockThreads(); \
19a97bd6 1519 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1e7ecb7b 1520 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
cac344f6 1521 wxPyEndBlockThreads(); \
19a97bd6
RD
1522 if (! found) \
1523 rval = PCLASS::CBNAME(a, b, c); \
1524 return (wxDragResult)rval; \
1525 } \
1526 wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1527 return PCLASS::CBNAME(a, b, c); \
b1462dfa
RD
1528 }
1529
1530//---------------------------------------------------------------------------
1531
c368d904
RD
1532#define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1533 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location); \
1534
1535#define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1536 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
cac344f6 1537 wxPyBeginBlockThreads(); \
c368d904 1538 wxFSFile* rval=0; \
19a97bd6 1539 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
c368d904 1540 PyObject* ro; \
19a97bd6 1541 PyObject* obj = wxPyMake_wxObject(&a); \
a66212dc 1542 PyObject* s = wx2PyString(b); \
a541c325 1543 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)",\
a66212dc 1544 obj, s)); \
c368d904
RD
1545 if (ro) { \
1546 SWIG_GetPtrObj(ro, (void **)&rval, "_wxFSFILE_p"); \
1547 Py_DECREF(ro); \
1548 } \
de20db99 1549 Py_DECREF(obj); \
a66212dc 1550 Py_DECREF(s); \
de20db99 1551 } \
cac344f6 1552 wxPyEndBlockThreads(); \
c368d904
RD
1553 return rval; \
1554 };
1555
1556//---------------------------------------------------------------------------
1557
b1462dfa
RD
1558#define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1559 bool CBNAME(wxDragResult a); \
1560 bool base_##CBNAME(wxDragResult a);
1561
1562
1563#define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1564 bool CLASS::CBNAME(wxDragResult a) { \
059a841c 1565 bool rval=FALSE; \
19a97bd6 1566 bool found; \
a541c325 1567 wxPyBeginBlockThreads(); \
19a97bd6
RD
1568 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1569 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a));\
a541c325 1570 wxPyEndBlockThreads(); \
19a97bd6 1571 if (! found) \
b1462dfa 1572 rval = PCLASS::CBNAME(a); \
b1462dfa
RD
1573 return rval; \
1574 } \
1575 bool CLASS::base_##CBNAME(wxDragResult a) { \
1576 return PCLASS::CBNAME(a); \
1577 }
1578
1579//---------------------------------------------------------------------------
1580
1581#define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1582 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def);
1583
1584
1585#define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1586 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
a541c325 1587 wxPyBeginBlockThreads(); \
059a841c 1588 int rval=0; \
19a97bd6 1589 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1e7ecb7b 1590 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
a541c325 1591 wxPyEndBlockThreads(); \
b1462dfa
RD
1592 return (wxDragResult)rval; \
1593 } \
1594
1595//---------------------------------------------------------------------------
1596
1597#define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1598 bool CBNAME(int a, int b, const wxString& c);
1599
b1462dfa
RD
1600#define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1601 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
059a841c 1602 bool rval=FALSE; \
a541c325 1603 wxPyBeginBlockThreads(); \
a66212dc
RD
1604 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1605 PyObject* s = wx2PyString(c); \
1606 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
1607 Py_DECREF(s); \
1608 } \
a541c325 1609 wxPyEndBlockThreads(); \
b1462dfa
RD
1610 return rval; \
1611 } \
1612
1613//---------------------------------------------------------------------------
1614
1615#define DEC_PYCALLBACK_SIZET_(CBNAME) \
1616 size_t CBNAME(); \
1617 size_t base_##CBNAME();
1618
1619
1620#define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1621 size_t CLASS::CBNAME() { \
059a841c 1622 size_t rval=0; \
19a97bd6 1623 bool found; \
a541c325 1624 wxPyBeginBlockThreads(); \
19a97bd6
RD
1625 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1626 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
a541c325 1627 wxPyEndBlockThreads(); \
19a97bd6 1628 if (! found) \
b1462dfa 1629 rval = PCLASS::CBNAME(); \
b1462dfa
RD
1630 return rval; \
1631 } \
1632 size_t CLASS::base_##CBNAME() { \
1633 return PCLASS::CBNAME(); \
1634 }
1635
1636//---------------------------------------------------------------------------
1637
c7e7022c
RD
1638#define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1639 wxDataFormat CBNAME(size_t a); \
1640 wxDataFormat base_##CBNAME(size_t a);
b1462dfa
RD
1641
1642
1643#define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1644 wxDataFormat CLASS::CBNAME(size_t a) { \
059a841c 1645 wxDataFormat rval=0; \
19a97bd6 1646 bool found; \
a541c325 1647 wxPyBeginBlockThreads(); \
19a97bd6 1648 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
b1462dfa
RD
1649 PyObject* ro; \
1650 wxDataFormat* ptr; \
c7e7022c 1651 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
f6bcfd97
BP
1652 if (ro) { \
1653 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxDataFormat_p")) \
1654 rval = *ptr; \
1655 Py_DECREF(ro); \
1656 } \
b1462dfa 1657 } \
a541c325 1658 wxPyEndBlockThreads(); \
19a97bd6 1659 if (! found) \
b1462dfa 1660 rval = PCLASS::CBNAME(a); \
b1462dfa
RD
1661 return rval; \
1662 } \
1663 wxDataFormat CLASS::base_##CBNAME(size_t a) { \
1664 return PCLASS::CBNAME(a); \
1665 }
1666
389c5527 1667//---------------------------------------------------------------------------
f6bcfd97
BP
1668
1669#define DEC_PYCALLBACK__constany(CBNAME, Type) \
1670 void CBNAME(const Type& a); \
1671 void base_##CBNAME(const Type& a);
1672
1673
19a97bd6
RD
1674#define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1675 void CLASS::CBNAME(const Type& a) { \
1676 bool found; \
a541c325 1677 wxPyBeginBlockThreads(); \
19a97bd6 1678 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1e4a197e 1679 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
19a97bd6
RD
1680 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1681 Py_DECREF(obj); \
1682 } \
a541c325 1683 wxPyEndBlockThreads(); \
19a97bd6
RD
1684 if (! found) \
1685 PCLASS::CBNAME(a); \
1686 } \
1687 void CLASS::base_##CBNAME(const Type& a) { \
1688 PCLASS::CBNAME(a); \
f6bcfd97
BP
1689 }
1690
1691
1692//---------------------------------------------------------------------------
1693
1694#define DEC_PYCALLBACK__any(CBNAME, Type) \
1695 void CBNAME(Type& a); \
1696 void base_##CBNAME(Type& a);
1697
1698
19a97bd6
RD
1699#define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1700 void CLASS::CBNAME(Type& a) { \
1701 bool found; \
a541c325 1702 wxPyBeginBlockThreads(); \
19a97bd6 1703 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1e4a197e 1704 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
19a97bd6
RD
1705 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1706 Py_DECREF(obj); \
1707 } \
a541c325 1708 wxPyEndBlockThreads(); \
19a97bd6
RD
1709 if (! found) \
1710 PCLASS::CBNAME(a); \
1711 } \
1712 void CLASS::base_##CBNAME(Type& a) { \
1713 PCLASS::CBNAME(a); \
f6bcfd97
BP
1714 }
1715
efc5f224 1716//---------------------------------------------------------------------------
f6bcfd97
BP
1717
1718#define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1719 bool CBNAME(Type& a); \
1720 bool base_##CBNAME(Type& a);
1721
1722
19a97bd6
RD
1723#define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
1724 bool CLASS::CBNAME(Type& a) { \
36fd8ec3 1725 bool rv=FALSE; \
19a97bd6 1726 bool found; \
a541c325 1727 wxPyBeginBlockThreads(); \
19a97bd6 1728 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1e4a197e 1729 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
19a97bd6
RD
1730 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1731 Py_DECREF(obj); \
1732 } \
a541c325 1733 wxPyEndBlockThreads(); \
19a97bd6
RD
1734 if (! found) \
1735 rv = PCLASS::CBNAME(a); \
1736 return rv; \
1737 } \
1738 bool CLASS::base_##CBNAME(Type& a) { \
1739 return PCLASS::CBNAME(a); \
f6bcfd97
BP
1740 }
1741
efc5f224
RD
1742//---------------------------------------------------------------------------
1743
628c7f79
RD
1744#define DEC_PYCALLBACK_bool_anypure(CBNAME, Type) \
1745 bool CBNAME(Type& a);
1746
1747
1748#define IMP_PYCALLBACK_bool_anypure(CLASS, PCLASS, CBNAME, Type) \
1749 bool CLASS::CBNAME(Type& a) { \
1750 bool rv=FALSE; \
1751 wxPyBeginBlockThreads(); \
1752 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1e4a197e 1753 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
628c7f79
RD
1754 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1755 Py_DECREF(obj); \
1756 } \
1757 wxPyEndBlockThreads(); \
1758 return rv; \
1759 } \
1760
1761//---------------------------------------------------------------------------
1762
c7e7022c
RD
1763#define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
1764 wxString CBNAME(long a, long b) const; \
1765 wxString base_##CBNAME(long a, long b)const ;
1766
c7e7022c
RD
1767#define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
1768 wxString CLASS::CBNAME(long a, long b) const { \
1769 wxString rval; \
19a97bd6 1770 bool found; \
a541c325 1771 wxPyBeginBlockThreads(); \
19a97bd6 1772 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
c7e7022c
RD
1773 PyObject* ro; \
1774 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1775 if (ro) { \
a541c325
RD
1776 rval = Py2wxString(ro); \
1777 Py_DECREF(ro); \
c7e7022c
RD
1778 } \
1779 } \
a541c325 1780 wxPyEndBlockThreads(); \
19a97bd6 1781 if (! found) \
c7e7022c 1782 rval = PCLASS::CBNAME(a,b); \
c7e7022c
RD
1783 return rval; \
1784 } \
1785 wxString CLASS::base_##CBNAME(long a, long b) const { \
1786 return PCLASS::CBNAME(a,b); \
1787 }
1788
1789//---------------------------------------------------------------------------
1790
1791#define DEC_PYCALLBACK_INT_LONG(CBNAME) \
1792 int CBNAME(long a) const; \
1793 int base_##CBNAME(long a)const ;
1794
1795
1796#define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
1797 int CLASS::CBNAME(long a) const { \
1798 int rval=-1; \
19a97bd6 1799 bool found; \
a541c325 1800 wxPyBeginBlockThreads(); \
19a97bd6 1801 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
c7e7022c
RD
1802 PyObject* ro; \
1803 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1804 if (ro) { \
1805 rval = PyInt_AsLong(ro); \
1806 Py_DECREF(ro); \
1807 } \
1808 } \
a541c325 1809 wxPyEndBlockThreads(); \
19a97bd6 1810 if (! found) \
c7e7022c 1811 rval = PCLASS::CBNAME(a); \
c7e7022c
RD
1812 return rval; \
1813 } \
1814 int CLASS::base_##CBNAME(long a) const { \
1815 return PCLASS::CBNAME(a); \
1816 }
1817
1818
1819//---------------------------------------------------------------------------
1820
1821#define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
00b6c4e3 1822 wxListItemAttr* CBNAME(long a) const; \
c7e7022c
RD
1823 wxListItemAttr* base_##CBNAME(long a);
1824
1825
1826#define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
00b6c4e3 1827 wxListItemAttr *CLASS::CBNAME(long a) const { \
c7e7022c 1828 wxListItemAttr *rval = NULL; \
19a97bd6 1829 bool found; \
a541c325 1830 wxPyBeginBlockThreads(); \
19a97bd6 1831 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
c7e7022c
RD
1832 PyObject* ro; \
1833 wxListItemAttr* ptr; \
1834 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1835 if (ro) { \
1836 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxListItemAttr_p")) \
1837 rval = ptr; \
1838 Py_DECREF(ro); \
1839 } \
1840 } \
a541c325 1841 wxPyEndBlockThreads(); \
19a97bd6 1842 if (! found) \
c7e7022c 1843 rval = PCLASS::CBNAME(a); \
c7e7022c
RD
1844 return rval; \
1845 } \
1846 wxListItemAttr *CLASS::base_##CBNAME(long a) { \
1847 return PCLASS::CBNAME(a); \
1848 }
1849
1850//---------------------------------------------------------------------------
1851
a541c325
RD
1852#define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
1853 bool CBNAME(wxMouseEvent& e); \
0122b7e3
RD
1854 bool base_##CBNAME(wxMouseEvent& e);
1855
a541c325
RD
1856#define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
1857 bool CLASS::CBNAME(wxMouseEvent& e) { \
1858 bool rval=FALSE; \
1859 bool found; \
1860 wxPyBeginBlockThreads(); \
1861 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1862 PyObject* ro; \
1e4a197e 1863 PyObject* obj = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
a541c325
RD
1864 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
1865 if (ro) { \
1866 rval = PyInt_AsLong(ro); \
1867 Py_DECREF(ro); \
1868 } \
1869 Py_DECREF(obj); \
1870 } \
1871 wxPyEndBlockThreads(); \
1872 if (! found) \
1873 return PCLASS::CBNAME(e); \
1874 return rval; \
1875 } \
1876 bool CLASS::base_##CBNAME(wxMouseEvent& e) { \
1877 return PCLASS::CBNAME(e); \
0122b7e3
RD
1878 }
1879
1880
1881//---------------------------------------------------------------------------
1882
af83019e
RD
1883#define DEC_PYCALLBACK_WIZPG__pure(CBNAME) \
1884 wxWizardPage* CBNAME() const;
1885
1886#define IMP_PYCALLBACK_WIZPG__pure(CLASS, PCLASS, CBNAME) \
1887 wxWizardPage* CLASS::CBNAME() const { \
1888 wxWizardPage* rv = NULL; \
af83019e 1889 wxPyBeginBlockThreads(); \
628c7f79 1890 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
af83019e
RD
1891 PyObject* ro; \
1892 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1893 if (ro) { \
1894 SWIG_GetPtrObj(ro, (void **)&rv, "_wxWizardPage_p"); \
1895 Py_DECREF(ro); \
1896 } \
1897 } \
1898 wxPyEndBlockThreads(); \
1899 return rv; \
1900 }
1901
1902//---------------------------------------------------------------------------
1903
1904#define DEC_PYCALLBACK_BITMAP__pure(CBNAME) \
1905 wxBitmap CBNAME() const;
1906
1907#define IMP_PYCALLBACK_BITMAP__pure(CLASS, PCLASS, CBNAME) \
1908 wxBitmap CLASS::CBNAME() const { \
1909 wxBitmap rv; \
af83019e 1910 wxPyBeginBlockThreads(); \
628c7f79 1911 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
af83019e
RD
1912 PyObject* ro; \
1913 wxBitmap* ptr; \
1914 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1915 if (ro) { \
1916 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxBitmap_p")) \
1917 rv = *ptr; \
1918 Py_DECREF(ro); \
1919 } \
1920 } \
1921 wxPyEndBlockThreads(); \
1922 return rv; \
1923 }
1924
1925//---------------------------------------------------------------------------
1926
628c7f79
RD
1927#define DEC_PYCALLBACK_OBJECT__pure(CBNAME) \
1928 wxObject* CBNAME();
1929
1930#define IMP_PYCALLBACK_OBJECT__pure(CLASS, PCLASS, CBNAME) \
1931 wxObject* CLASS::CBNAME() { \
1932 wxObject* rv = NULL; \
1933 wxPyBeginBlockThreads(); \
1934 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1935 PyObject* ro; \
1936 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1937 if (ro) { \
1938 SWIG_GetPtrObj(ro, (void **)&rv, "_wxObject_p"); \
1939 Py_DECREF(ro); \
1940 } \
1941 } \
1942 wxPyEndBlockThreads(); \
1943 return rv; \
1944 }
1945
1946//---------------------------------------------------------------------------
1947
1e4a197e
RD
1948#define DEC_PYCALLBACK_OBJECT_STRING_pure(CBNAME) \
1949 wxObject* CBNAME(const wxString& a);
1950
1951#define IMP_PYCALLBACK_OBJECT_STRING_pure(CLASS, PCLASS, CBNAME) \
1952 wxObject* CLASS::CBNAME(const wxString& a) { \
1953 wxObject* rv = NULL; \
1954 wxPyBeginBlockThreads(); \
1955 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1956 PyObject* so = wx2PyString(a); \
1957 PyObject* ro; \
1958 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", so)); \
1959 if (ro) { \
1960 SWIG_GetPtrObj(ro, (void **)&rv, "_wxObject_p"); \
1961 Py_DECREF(ro); \
1962 } \
1963 Py_DECREF(so); \
1964 } \
1965 wxPyEndBlockThreads(); \
1966 return rv; \
1967 }
1968
1969//---------------------------------------------------------------------------
1970
628c7f79
RD
1971#define DEC_PYCALLBACK_BOOL_NODE_pure(CBNAME) \
1972 bool CBNAME(wxXmlNode* a);
1973
1974
1975#define IMP_PYCALLBACK_BOOL_NODE_pure(CLASS, PCLASS, CBNAME) \
1976 bool CLASS::CBNAME(wxXmlNode* a) { \
1977 bool rv=FALSE; \
1978 wxPyBeginBlockThreads(); \
1979 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1e4a197e 1980 PyObject* obj = wxPyConstructObject((void*)a, wxT("wxXmlNode"), 0); \
628c7f79
RD
1981 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1982 Py_DECREF(obj); \
1983 } \
1984 wxPyEndBlockThreads(); \
1985 return rv; \
1986 } \
1987
1988//---------------------------------------------------------------------------
7bf85405 1989#endif