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