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