]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/helpers.h
Added base_IsAcceptedKey which was fogotten somehow...
[wxWidgets.git] / wxPython / src / helpers.h
CommitLineData
b1462dfa 1////////////////////////////////////////////////////////////////////////////
7bf85405
RD
2// Name: helpers.h
3// Purpose: Helper functions/classes for the wxPython extenaion module
4//
5// Author: Robin Dunn
6//
7// Created: 7/1/97
8// RCS-ID: $Id$
9// Copyright: (c) 1998 by Total Control Software
10// Licence: wxWindows license
11/////////////////////////////////////////////////////////////////////////////
12
13#ifndef __wxp_helpers__
14#define __wxp_helpers__
15
16#include <wx/wx.h>
17
18
cf694132
RD
19//----------------------------------------------------------------------
20
21// if we want to handle threads and Python threads are available...
22#if defined(WXP_USE_THREAD) && defined(WITH_THREAD)
23
24#define WXP_WITH_THREAD
25#define wxPy_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
26#define wxPy_END_ALLOW_THREADS Py_END_ALLOW_THREADS
27
28#else // no Python threads...
29#undef WXP_WITH_THREAD
30#define wxPy_BEGIN_ALLOW_THREADS
31#define wxPy_END_ALLOW_THREADS
32#endif
33
34
efc5f224
RD
35//---------------------------------------------------------------------------
36
37#if defined(__WXMSW__)
38# define HELPEREXPORT __declspec(dllexport)
39#else
40# define HELPEREXPORT
41#endif
42
2f90df85
RD
43typedef unsigned char byte;
44
7bf85405
RD
45//----------------------------------------------------------------------
46
47class wxPyApp: public wxApp
48{
49public:
cf694132
RD
50 wxPyApp();
51 ~wxPyApp();
7bf85405
RD
52 int MainLoop(void);
53 bool OnInit(void);
8bf5d46e 54//# void AfterMainLoop(void);
7bf85405
RD
55};
56
57extern wxPyApp *wxPythonApp;
58
59//----------------------------------------------------------------------
60
0d6f9504 61void __wxPreStart();
7bf85405 62PyObject* __wxStart(PyObject*, PyObject* args);
7ff49f0c 63void __wxCleanup();
7bf85405
RD
64
65extern PyObject* wxPython_dict;
66PyObject* __wxSetDictionary(PyObject*, PyObject* args);
67
7bf85405 68void wxPyEventThunker(wxObject*, wxEvent& event);
efc5f224 69
c368d904
RD
70HELPEREXPORT PyObject* wxPyConstructObject(void* ptr,
71 const char* className,
72 int setThisOwn=0);
d559219f
RD
73HELPEREXPORT bool wxPyRestoreThread();
74HELPEREXPORT void wxPySaveThread(bool doSave);
65dd82cb 75HELPEREXPORT PyObject* wxPy_ConvertList(wxListBase* list, const char* className);
54b96882 76HELPEREXPORT long wxPyGetWinHandle(wxWindow* win);
9b3d3bc4
RD
77
78//----------------------------------------------------------------------
79
80class wxPyUserData : public wxObject {
81public:
82 wxPyUserData(PyObject* obj) { m_obj = obj; Py_INCREF(m_obj); }
83 ~wxPyUserData() {
84 bool doSave = wxPyRestoreThread();
85 Py_DECREF(m_obj);
86 wxPySaveThread(doSave);
87 }
88 PyObject* m_obj;
89};
90
c368d904
RD
91//----------------------------------------------------------------------
92// Handle wxInputStreams by Joerg Baumann
93// See stream.i for implementations
94
95// list class for return list of strings, e.g. readlines()
96WX_DECLARE_LIST(wxString, wxStringPtrList);
97
98
99// C++ class wxPyInputStream to act as base for python class wxInputStream
100// Use it in python like a python file object
101class wxPyInputStream{
102public:
103 // underlying wxInputStream
104 wxInputStream* wxi;
105
106public:
107 wxPyInputStream(wxInputStream* wxi_) : wxi(wxi_) {}
108 ~wxPyInputStream();
109
110 // python file object interface for input files (most of it)
111 void close();
112 void flush();
113 bool eof();
114 wxString* read(int size=-1);
115 wxString* readline(int size=-1);
116 wxStringPtrList* readlines(int sizehint=-1);
117 void seek(int offset, int whence=0);
118 int tell();
119 /*
120 bool isatty();
121 int fileno();
122 void truncate(int size=-1);
123 void write(wxString data);
124 void writelines(wxStringPtrList);
125 */
126};
127
128
7bf85405 129//----------------------------------------------------------------------
2f90df85
RD
130// These are helpers used by the typemaps
131
132HELPEREXPORT byte* byte_LIST_helper(PyObject* source);
133HELPEREXPORT int* int_LIST_helper(PyObject* source);
134HELPEREXPORT long* long_LIST_helper(PyObject* source);
135HELPEREXPORT char** string_LIST_helper(PyObject* source);
136HELPEREXPORT wxPoint* wxPoint_LIST_helper(PyObject* source);
137HELPEREXPORT wxBitmap** wxBitmap_LIST_helper(PyObject* source);
138HELPEREXPORT wxString* wxString_LIST_helper(PyObject* source);
139HELPEREXPORT wxAcceleratorEntry* wxAcceleratorEntry_LIST_helper(PyObject* source);
140
141HELPEREXPORT bool wxSize_helper(PyObject* source, wxSize** obj);
142HELPEREXPORT bool wxPoint_helper(PyObject* source, wxPoint** obj);
143HELPEREXPORT bool wxRealPoint_helper(PyObject* source, wxRealPoint** obj);
144HELPEREXPORT bool wxRect_helper(PyObject* source, wxRect** obj);
f6bcfd97 145HELPEREXPORT bool wxColour_helper(PyObject* source, wxColour** obj);
7bf85405 146
2f90df85 147//----------------------------------------------------------------------
7bf85405
RD
148
149#ifndef SWIGCODE
150extern "C" void SWIG_MakePtr(char *, void *, char *);
151extern "C" char *SWIG_GetPtr(char *, void **, char *);
d559219f 152extern "C" char *SWIG_GetPtrObj(PyObject *obj, void **ptr, char *type);
7bf85405
RD
153#endif
154
155
156#ifdef _MSC_VER
157# pragma warning(disable:4800)
f6bcfd97 158# pragma warning(disable:4190)
7bf85405
RD
159#endif
160
b639c3c5 161
7bf85405
RD
162
163// Non-const versions to keep SWIG happy.
164extern wxPoint wxPyDefaultPosition;
165extern wxSize wxPyDefaultSize;
7bf85405
RD
166extern wxString wxPyEmptyStr;
167
168//----------------------------------------------------------------------
169
170class wxPyCallback : public wxObject {
2f90df85 171 DECLARE_ABSTRACT_CLASS(wxPyCallback);
7bf85405 172public:
cf694132 173 wxPyCallback(PyObject* func);
2f90df85 174 wxPyCallback(const wxPyCallback& other);
cf694132 175 ~wxPyCallback();
7bf85405
RD
176
177 void EventThunker(wxEvent& event);
178
179 PyObject* m_func;
180};
181
7bf85405
RD
182//---------------------------------------------------------------------------
183
184class wxPyTimer : public wxTimer {
185public:
186 wxPyTimer(PyObject* callback);
187 ~wxPyTimer();
188
189 void Notify();
190
191private:
192 PyObject* func;
193};
194
cf694132
RD
195//---------------------------------------------------------------------------
196
bb0054cd
RD
197
198
199
200//---------------------------------------------------------------------------
201// This class holds an instance of a Python Shadow Class object and assists
202// with looking up and invoking Python callback methods from C++ virtual
203// method redirections. For all classes which have virtuals which should be
204// overridable in wxPython, a new subclass is created that contains a
a08cbc01 205// wxPyCallbackHelper.
d559219f 206//
f6bcfd97 207// TODO: This class should be combined with wxPyCallback defined above.
d559219f 208//
bb0054cd 209
efc5f224 210class HELPEREXPORT wxPyCallbackHelper {
bb0054cd
RD
211public:
212 wxPyCallbackHelper();
213 ~wxPyCallbackHelper();
214
2f90df85
RD
215 wxPyCallbackHelper(const wxPyCallbackHelper& other);
216
f6bcfd97 217 void setSelf(PyObject* self, PyObject* _class, int incref=TRUE);
bb0054cd 218
f6bcfd97
BP
219 bool findCallback(const wxString& name) const;
220 int callCallback(PyObject* argTuple) const;
221 PyObject* callCallbackObj(PyObject* argTuple) const;
bb0054cd
RD
222
223private:
224 PyObject* m_self;
f6bcfd97 225 PyObject* m_class;
bb0054cd 226 PyObject* m_lastFound;
b7312675 227 int m_incRef;
bb0054cd
RD
228};
229
230
65dd82cb
RD
231//---------------------------------------------------------------------------
232//---------------------------------------------------------------------------
9b3d3bc4
RD
233// These Event classes can be derived from in Python and passed through the
234// event system without loosing anything. They do this by keeping a reference
235// to themselves and some special case handling in wxPyCallback::EventThunker.
65dd82cb
RD
236
237
e19b7164 238class wxPyEvtSelfRef {
65dd82cb 239public:
e19b7164
RD
240 wxPyEvtSelfRef();
241 ~wxPyEvtSelfRef();
65dd82cb
RD
242
243 void SetSelf(PyObject* self, bool clone=FALSE);
244 PyObject* GetSelf() const;
245
246protected:
247 PyObject* m_self;
248 bool m_cloned;
249};
250
251
e19b7164 252class wxPyEvent : public wxEvent, public wxPyEvtSelfRef {
65dd82cb
RD
253 DECLARE_DYNAMIC_CLASS(wxPyEvent)
254public:
255 wxPyEvent(int id=0);
256 ~wxPyEvent();
257
258 void CopyObject(wxObject& dest) const;
259};
260
261
e19b7164 262class wxPyCommandEvent : public wxCommandEvent, public wxPyEvtSelfRef {
65dd82cb
RD
263 DECLARE_DYNAMIC_CLASS(wxPyCommandEvent)
264public:
265 wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0);
266 ~wxPyCommandEvent();
267
268 void CopyObject(wxObject& dest) const;
269};
270
bb0054cd
RD
271
272//---------------------------------------------------------------------------
273// These macros are used to implement the virtual methods that should
274// redirect to a Python method if one exists. The names designate the
b1462dfa 275// return type, if any, as well as any parameter types.
bb0054cd
RD
276//---------------------------------------------------------------------------
277
f6bcfd97
BP
278#define PYPRIVATE \
279 void _setSelf(PyObject* self, PyObject* _class, int incref=1) { \
280 m_myInst.setSelf(self, _class, incref); \
281 } \
c368d904 282 private: wxPyCallbackHelper m_myInst
efc5f224
RD
283
284//---------------------------------------------------------------------------
285
d559219f
RD
286#define DEC_PYCALLBACK__(CBNAME) \
287 void CBNAME(); \
288 void base_##CBNAME();
289
290
291#define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
292 void CLASS::CBNAME() { \
293 bool doSave = wxPyRestoreThread(); \
294 if (m_myInst.findCallback(#CBNAME)) \
295 m_myInst.callCallback(Py_BuildValue("()")); \
296 else \
297 PCLASS::CBNAME(); \
298 wxPySaveThread(doSave); \
299 } \
300 void CLASS::base_##CBNAME() { \
301 PCLASS::CBNAME(); \
302 }
303
304//---------------------------------------------------------------------------
305
306#define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
307 bool CBNAME(int a, int b); \
308 bool base_##CBNAME(int a, int b);
309
310
311#define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
312 bool CLASS::CBNAME(int a, int b) { \
313 bool rval; \
314 bool doSave = wxPyRestoreThread(); \
bb0054cd 315 if (m_myInst.findCallback(#CBNAME)) \
d559219f 316 rval = m_myInst.callCallback(Py_BuildValue("(ii)",a,b)); \
bb0054cd 317 else \
d559219f
RD
318 rval = PCLASS::CBNAME(a,b); \
319 wxPySaveThread(doSave); \
320 return rval; \
bb0054cd 321 } \
d559219f 322 bool CLASS::base_##CBNAME(int a, int b) { \
bb0054cd
RD
323 return PCLASS::CBNAME(a,b); \
324 }
325
326//---------------------------------------------------------------------------
327
c368d904
RD
328#define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
329 void CBNAME(int a, int b); \
330 void base_##CBNAME(int a, int b);
331
332
333#define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
334 void CLASS::CBNAME(int a, int b) { \
335 bool doSave = wxPyRestoreThread(); \
336 if (m_myInst.findCallback(#CBNAME)) \
337 m_myInst.callCallback(Py_BuildValue("(ii)",a,b)); \
338 else \
339 PCLASS::CBNAME(a,b); \
340 wxPySaveThread(doSave); \
341 } \
342 void CLASS::base_##CBNAME(int a, int b) { \
343 PCLASS::CBNAME(a,b); \
344 }
345
346//---------------------------------------------------------------------------
347
d559219f
RD
348#define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
349 bool CBNAME(int a); \
350 bool base_##CBNAME(int a);
351
352
353#define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
354 bool CLASS::CBNAME(int a) { \
355 bool rval; \
356 bool doSave = wxPyRestoreThread(); \
bb0054cd 357 if (m_myInst.findCallback(#CBNAME)) \
d559219f 358 rval = m_myInst.callCallback(Py_BuildValue("(i)",a)); \
bb0054cd 359 else \
d559219f
RD
360 rval = PCLASS::CBNAME(a); \
361 wxPySaveThread(doSave); \
362 return rval; \
bb0054cd 363 } \
d559219f 364 bool CLASS::base_##CBNAME(int a) { \
bb0054cd
RD
365 return PCLASS::CBNAME(a); \
366 }
367
efc5f224
RD
368//---------------------------------------------------------------------------
369
d559219f
RD
370#define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
371 bool CBNAME(int a);
372
373
374#define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
375 bool CLASS::CBNAME(int a) { \
376 bool rval; \
377 bool doSave = wxPyRestoreThread(); \
bb0054cd 378 if (m_myInst.findCallback(#CBNAME)) \
d559219f 379 rval = m_myInst.callCallback(Py_BuildValue("(i)",a)); \
194fa2ac 380 else rval = FALSE; \
d559219f
RD
381 wxPySaveThread(doSave); \
382 return rval; \
bb0054cd
RD
383 }
384
385
386//---------------------------------------------------------------------------
387
d559219f
RD
388#define DEC_PYCALLBACK__DC(CBNAME) \
389 void CBNAME(wxDC& a); \
390 void base_##CBNAME(wxDC& a);
391
392
393#define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
394 void CLASS::CBNAME(wxDC& a) { \
395 bool doSave = wxPyRestoreThread(); \
396 if (m_myInst.findCallback(#CBNAME)) \
397 m_myInst.callCallback(Py_BuildValue("(O)", \
398 wxPyConstructObject(&a, "wxDC"))); \
399 else \
400 PCLASS::CBNAME(a); \
401 wxPySaveThread(doSave); \
402 } \
403 void CLASS::base_##CBNAME(wxDC& a) { \
404 PCLASS::CBNAME(a); \
bb0054cd
RD
405 }
406
efc5f224
RD
407
408
bb0054cd
RD
409//---------------------------------------------------------------------------
410
d559219f
RD
411#define DEC_PYCALLBACK__DCBOOL(CBNAME) \
412 void CBNAME(wxDC& a, bool b); \
413 void base_##CBNAME(wxDC& a, bool b);
414
415
416#define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
417 void CLASS::CBNAME(wxDC& a, bool b) { \
418 bool doSave = wxPyRestoreThread(); \
efc5f224
RD
419 if (m_myInst.findCallback(#CBNAME)) \
420 m_myInst.callCallback(Py_BuildValue("(Oi)", \
d559219f 421 wxPyConstructObject(&a, "wxDC"), (int)b)); \
efc5f224
RD
422 else \
423 PCLASS::CBNAME(a, b); \
d559219f 424 wxPySaveThread(doSave); \
efc5f224 425 } \
d559219f 426 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
efc5f224
RD
427 PCLASS::CBNAME(a, b); \
428 }
429
430//---------------------------------------------------------------------------
431
d559219f
RD
432#define DEC_PYCALLBACK__DCBOOL(CBNAME) \
433 void CBNAME(wxDC& a, bool b); \
434 void base_##CBNAME(wxDC& a, bool b);
435
436
437#define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
438 void CLASS::CBNAME(wxDC& a, bool b) { \
439 bool doSave = wxPyRestoreThread(); \
efc5f224
RD
440 if (m_myInst.findCallback(#CBNAME)) \
441 m_myInst.callCallback(Py_BuildValue("(Oi)", \
d559219f 442 wxPyConstructObject(&a, "wxDC"), (int)b)); \
efc5f224
RD
443 else \
444 PCLASS::CBNAME(a, b); \
d559219f 445 wxPySaveThread(doSave); \
efc5f224 446 } \
d559219f 447 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
efc5f224
RD
448 PCLASS::CBNAME(a, b); \
449 }
450
451//---------------------------------------------------------------------------
452
d559219f
RD
453#define DEC_PYCALLBACK__2DBL(CBNAME) \
454 void CBNAME(double a, double b); \
455 void base_##CBNAME(double a, double b);
456
457
458#define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
459 void CLASS::CBNAME(double a, double b) { \
460 bool doSave = wxPyRestoreThread(); \
461 if (m_myInst.findCallback(#CBNAME)) \
462 m_myInst.callCallback(Py_BuildValue("(dd)",a,b)); \
463 else \
464 PCLASS::CBNAME(a, b); \
465 wxPySaveThread(doSave); \
466 } \
467 void CLASS::base_##CBNAME(double a, double b) { \
468 PCLASS::CBNAME(a, b); \
efc5f224
RD
469 }
470
471//---------------------------------------------------------------------------
472
d559219f
RD
473#define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
474 void CBNAME(double a, double b, int c, int d); \
475 void base_##CBNAME(double a, double b, int c, int d);
476
477
478#define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
479 void CLASS::CBNAME(double a, double b, int c, int d) { \
480 bool doSave = wxPyRestoreThread(); \
efc5f224
RD
481 if (m_myInst.findCallback(#CBNAME)) \
482 m_myInst.callCallback(Py_BuildValue("(ddii)", \
483 a,b,c,d)); \
484 else \
485 PCLASS::CBNAME(a, b, c, d); \
d559219f 486 wxPySaveThread(doSave); \
efc5f224 487 } \
d559219f 488 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
efc5f224
RD
489 PCLASS::CBNAME(a, b, c, d); \
490 }
491
492//---------------------------------------------------------------------------
493
d559219f
RD
494#define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
495 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
496 void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
497
498
499#define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
500 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
501 bool doSave = wxPyRestoreThread(); \
502 if (m_myInst.findCallback(#CBNAME)) \
503 m_myInst.callCallback(Py_BuildValue("(Oddddi)", \
504 wxPyConstructObject(&a, "wxDC"), \
505 b, c, d, e, (int)f)); \
506 else \
507 PCLASS::CBNAME(a, b, c, d, e, f); \
508 wxPySaveThread(doSave); \
509 } \
510 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
511 PCLASS::CBNAME(a, b, c, d, e, f); \
efc5f224
RD
512 }
513
514//---------------------------------------------------------------------------
515
d559219f
RD
516#define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
517 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
518 bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
519
520
521#define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
522 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
523 bool doSave = wxPyRestoreThread(); \
99a49d3e 524 bool rval; \
d559219f 525 if (m_myInst.findCallback(#CBNAME)) \
99a49d3e 526 rval = m_myInst.callCallback(Py_BuildValue("(Oddddi)", \
d559219f
RD
527 wxPyConstructObject(&a, "wxDC"), \
528 b, c, d, e, (int)f)); \
529 else \
99a49d3e 530 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
d559219f 531 wxPySaveThread(doSave); \
99a49d3e 532 return rval; \
d559219f
RD
533 } \
534 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
535 return PCLASS::CBNAME(a, b, c, d, e, f); \
efc5f224
RD
536 }
537
538//---------------------------------------------------------------------------
539
d559219f
RD
540#define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
541 void CBNAME(bool a, double b, double c, int d, int e); \
542 void base_##CBNAME(bool a, double b, double c, int d, int e);
543
544
545#define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
546 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
547 bool doSave = wxPyRestoreThread(); \
548 if (m_myInst.findCallback(#CBNAME)) \
549 m_myInst.callCallback(Py_BuildValue("(idii)", \
550 (int)a,b,c,d,e)); \
551 else \
552 PCLASS::CBNAME(a, b, c, d, e); \
553 wxPySaveThread(doSave); \
554 } \
555 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
556 PCLASS::CBNAME(a, b, c, d, e); \
efc5f224
RD
557 }
558
559//---------------------------------------------------------------------------
560
d559219f
RD
561#define DEC_PYCALLBACK__DC4DBL(CBNAME) \
562 void CBNAME(wxDC& a, double b, double c, double d, double e); \
563 void base_##CBNAME(wxDC& a, double b, double c, double d, double e);
564
565
566#define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
567 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
568 bool doSave = wxPyRestoreThread(); \
569 if (m_myInst.findCallback(#CBNAME)) \
570 m_myInst.callCallback(Py_BuildValue("(Odddd)", \
571 wxPyConstructObject(&a, "wxDC"), \
572 b, c, d, e)); \
573 else \
574 PCLASS::CBNAME(a, b, c, d, e); \
575 wxPySaveThread(doSave); \
576 } \
577 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
578 PCLASS::CBNAME(a, b, c, d, e); \
efc5f224
RD
579 }
580
581//---------------------------------------------------------------------------
582
d559219f
RD
583#define DEC_PYCALLBACK__DCBOOL(CBNAME) \
584 void CBNAME(wxDC& a, bool b); \
585 void base_##CBNAME(wxDC& a, bool b);
586
587
588#define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
589 void CLASS::CBNAME(wxDC& a, bool b) { \
590 bool doSave = wxPyRestoreThread(); \
efc5f224
RD
591 if (m_myInst.findCallback(#CBNAME)) \
592 m_myInst.callCallback(Py_BuildValue("(Oi)", \
d559219f 593 wxPyConstructObject(&a, "wxDC"), \
efc5f224
RD
594 (int)b)); \
595 else \
596 PCLASS::CBNAME(a, b); \
d559219f 597 wxPySaveThread(doSave); \
efc5f224 598 } \
d559219f 599 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
efc5f224
RD
600 PCLASS::CBNAME(a, b); \
601 }
bb0054cd 602
7bf85405 603//---------------------------------------------------------------------------
7bf85405 604
d559219f
RD
605#define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
606 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
607 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f);
608
609
610#define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
611 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
612 int e, int f) { \
613 bool doSave = wxPyRestoreThread(); \
614 if (m_myInst.findCallback(#CBNAME)) \
615 m_myInst.callCallback(Py_BuildValue("(Oiddii)", \
2f90df85 616 wxPyConstructObject(a, "wxPyControlPoint"), \
d559219f
RD
617 (int)b, c, d, e, f)); \
618 else \
619 PCLASS::CBNAME(a, b, c, d, e, f); \
620 wxPySaveThread(doSave); \
621 } \
622 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
623 int e, int f) { \
624 PCLASS::CBNAME(a, b, c, d, e, f); \
efc5f224
RD
625 }
626
627//---------------------------------------------------------------------------
628
d559219f
RD
629#define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
630 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
631 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e);
632
633
634#define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
635 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
636 bool doSave = wxPyRestoreThread(); \
637 if (m_myInst.findCallback(#CBNAME)) \
638 m_myInst.callCallback(Py_BuildValue("(Oddii)", \
2f90df85 639 wxPyConstructObject(a, "wxPyControlPoint"), \
d559219f
RD
640 b, c, d, e)); \
641 else \
642 PCLASS::CBNAME(a, b, c, d, e); \
643 wxPySaveThread(doSave); \
644 } \
645 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
646 int d, int e) { \
647 PCLASS::CBNAME(a, b, c, d, e); \
efc5f224
RD
648 }
649
650//---------------------------------------------------------------------------
651
d559219f
RD
652#define DEC_PYCALLBACK__2DBLINT(CBNAME) \
653 void CBNAME(double a, double b, int c); \
654 void base_##CBNAME(double a, double b, int c);
655
656
657#define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
658 void CLASS::CBNAME(double a, double b, int c) { \
659 bool doSave = wxPyRestoreThread(); \
efc5f224
RD
660 if (m_myInst.findCallback(#CBNAME)) \
661 m_myInst.callCallback(Py_BuildValue("(ddi)", a,b,c)); \
662 else \
663 PCLASS::CBNAME(a, b, c); \
d559219f 664 wxPySaveThread(doSave); \
efc5f224 665 } \
d559219f 666 void CLASS::base_##CBNAME(double a, double b, int c) { \
efc5f224
RD
667 PCLASS::CBNAME(a, b, c); \
668 }
669
670//---------------------------------------------------------------------------
671
d559219f
RD
672#define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
673 void CBNAME(bool a, double b, double c, int d); \
674 void base_##CBNAME(bool a, double b, double c, int d);
675
676
677#define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
678 void CLASS::CBNAME(bool a, double b, double c, int d) { \
679 bool doSave = wxPyRestoreThread(); \
680 if (m_myInst.findCallback(#CBNAME)) \
681 m_myInst.callCallback(Py_BuildValue("(iddi)", (int)a,b,c,d)); \
682 else \
683 PCLASS::CBNAME(a, b, c, d); \
684 wxPySaveThread(doSave); \
685 } \
686 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
687 PCLASS::CBNAME(a, b, c, d); \
efc5f224
RD
688 }
689
690//---------------------------------------------------------------------------
691//---------------------------------------------------------------------------
389c5527
RD
692
693#define DEC_PYCALLBACK__STRING(CBNAME) \
694 void CBNAME(const wxString& a); \
695 void base_##CBNAME(const wxString& a);
696
697
698#define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
699 void CLASS::CBNAME(const wxString& a) { \
700 bool doSave = wxPyRestoreThread(); \
701 if (m_myInst.findCallback(#CBNAME)) \
702 m_myInst.callCallback(Py_BuildValue("(s)", a.c_str())); \
703 else \
704 PCLASS::CBNAME(a); \
705 wxPySaveThread(doSave); \
706 } \
707 void CLASS::base_##CBNAME(const wxString& a) { \
708 PCLASS::CBNAME(a); \
709 }
710
711//---------------------------------------------------------------------------
712
713#define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
714 bool CBNAME(const wxString& a); \
715 bool base_##CBNAME(const wxString& a);
716
717
718#define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
719 bool CLASS::CBNAME(const wxString& a) { \
720 bool rval; \
721 bool doSave = wxPyRestoreThread(); \
722 if (m_myInst.findCallback(#CBNAME)) \
723 rval = m_myInst.callCallback(Py_BuildValue("(s)", a.c_str())); \
724 else \
725 rval = PCLASS::CBNAME(a); \
726 wxPySaveThread(doSave); \
727 return rval; \
728 } \
729 bool CLASS::base_##CBNAME(const wxString& a) { \
730 return PCLASS::CBNAME(a); \
731 }
732
733//---------------------------------------------------------------------------
734
c368d904
RD
735#define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
736 bool CBNAME(const wxString& a);
737 \
738#define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
739 bool CLASS::CBNAME(const wxString& a) { \
740 bool rval; \
741 bool doSave = wxPyRestoreThread(); \
742 if (m_myInst.findCallback(#CBNAME)) \
743 rval = m_myInst.callCallback(Py_BuildValue("(s)", a.c_str())); \
744 wxPySaveThread(doSave); \
745 return rval; \
746 } \
747
748//---------------------------------------------------------------------------
749
750#define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
751 wxString CBNAME(const wxString& a); \
752
753#define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
754 wxString CLASS::CBNAME(const wxString& a) { \
755 wxString rval; \
756 bool doSave = wxPyRestoreThread(); \
757 if (m_myInst.findCallback(#CBNAME)) { \
758 PyObject* ro; \
759 ro = m_myInst.callCallbackObj(Py_BuildValue("(s)", a.c_str())); \
760 if (ro) { \
761 rval = PyString_AsString(PyObject_Str(ro)); \
762 Py_DECREF(ro); \
763 } \
764 } \
765 wxPySaveThread(doSave); \
766 return rval; \
767 } \
768
769//---------------------------------------------------------------------------
770
771#define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
772 wxString CBNAME(const wxString& a,int b); \
773
774#define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
775 wxString CLASS::CBNAME(const wxString& a,int b) { \
776 wxString rval; \
777 bool doSave = wxPyRestoreThread(); \
778 if (m_myInst.findCallback(#CBNAME)) { \
779 PyObject* ro; \
780 ro = m_myInst.callCallbackObj(Py_BuildValue("(si)", a.c_str(),b)); \
781 if (ro) { \
782 rval = PyString_AsString(PyObject_Str(ro)); \
783 Py_DECREF(ro); \
784 } \
785 } \
786 wxPySaveThread(doSave); \
787 return rval; \
788 } \
789
790//---------------------------------------------------------------------------
791
f0261a72
RD
792#define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
793 bool CBNAME(const wxString& a, const wxString& b); \
794 bool base_##CBNAME(const wxString& a, const wxString& b);
795
796
797#define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
798 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
799 bool rval; \
800 bool doSave = wxPyRestoreThread(); \
801 if (m_myInst.findCallback(#CBNAME)) \
802 rval = m_myInst.callCallback(Py_BuildValue("(ss)", \
803 a.c_str(), b.c_str())); \
804 else \
805 rval = PCLASS::CBNAME(a, b); \
806 wxPySaveThread(doSave); \
807 return rval; \
808 } \
809 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
810 return PCLASS::CBNAME(a, b); \
811 }
812
813//---------------------------------------------------------------------------
814
389c5527
RD
815#define DEC_PYCALLBACK_STRING_(CBNAME) \
816 wxString CBNAME(); \
817 wxString base_##CBNAME();
818
819
820#define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
821 wxString CLASS::CBNAME() { \
822 wxString rval; \
823 bool doSave = wxPyRestoreThread(); \
824 if (m_myInst.findCallback(#CBNAME)) { \
825 PyObject* ro; \
826 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
f6bcfd97
BP
827 if (ro) { \
828 rval = PyString_AsString(PyObject_Str(ro)); \
829 Py_DECREF(ro); \
830 } \
389c5527
RD
831 } \
832 else \
b1462dfa 833 rval = PCLASS::CBNAME(); \
389c5527
RD
834 wxPySaveThread(doSave); \
835 return rval; \
836 } \
b1462dfa
RD
837 wxString CLASS::base_##CBNAME() { \
838 return PCLASS::CBNAME(); \
389c5527
RD
839 }
840
841//---------------------------------------------------------------------------
842
843#define DEC_PYCALLBACK_STRING__pure(CBNAME) \
844 wxString CBNAME();
845
846
847#define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
848 wxString CLASS::CBNAME() { \
849 wxString rval; \
850 bool doSave = wxPyRestoreThread(); \
851 if (m_myInst.findCallback(#CBNAME)) { \
852 PyObject* ro; \
853 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
f6bcfd97
BP
854 if (ro) { \
855 rval = PyString_AsString(PyObject_Str(ro)); \
856 Py_DECREF(ro); \
857 } \
389c5527
RD
858 } \
859 wxPySaveThread(doSave); \
860 return rval; \
861 }
862
863//---------------------------------------------------------------------------
864
865#define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
866 bool CBNAME(const wxHtmlTag& a); \
867
868
869#define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
870 bool CLASS::CBNAME(const wxHtmlTag& a) { \
194fa2ac 871 bool rval = FALSE; \
389c5527
RD
872 bool doSave = wxPyRestoreThread(); \
873 if (m_myInst.findCallback(#CBNAME)) \
874 rval = m_myInst.callCallback(Py_BuildValue("(O)", \
875 wxPyConstructObject((void*)&a,"wxHtmlTag"))); \
876 wxPySaveThread(doSave); \
877 return rval; \
878 }
879
880//---------------------------------------------------------------------------
2f90df85
RD
881
882#define DEC_PYCALLBACK___pure(CBNAME) \
883 void CBNAME(); \
884
885
886#define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
887 void CLASS::CBNAME() { \
888 bool doSave = wxPyRestoreThread(); \
889 if (m_myInst.findCallback(#CBNAME)) \
890 m_myInst.callCallback(Py_BuildValue("()")); \
891 wxPySaveThread(doSave); \
892 }
893
894//---------------------------------------------------------------------------
895
896#define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
897 wxSize CBNAME(); \
898
899
900#define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
901 wxSize CLASS::CBNAME() { \
902 wxSize rval(0,0); \
903 bool doSave = wxPyRestoreThread(); \
904 if (m_myInst.findCallback(#CBNAME)) { \
905 PyObject* ro; \
906 wxSize* ptr; \
907 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
f6bcfd97
BP
908 if (ro) { \
909 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \
910 rval = *ptr; \
911 Py_DECREF(ro); \
912 } \
2f90df85
RD
913 } \
914 wxPySaveThread(doSave); \
915 return rval; \
916 }
917
918//---------------------------------------------------------------------------
919
920#define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
921 bool CBNAME(wxWindow* a); \
922 bool base_##CBNAME(wxWindow* a);
923
924
925#define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
926 bool CLASS::CBNAME(wxWindow* a) { \
927 bool rval; \
928 bool doSave = wxPyRestoreThread(); \
929 if (m_myInst.findCallback(#CBNAME)) \
930 rval = m_myInst.callCallback(Py_BuildValue("(O)", \
931 wxPyConstructObject((void*)a,"wxWindow"))); \
932 else \
933 rval = PCLASS::CBNAME(a); \
934 wxPySaveThread(doSave); \
935 return rval; \
936 } \
937 bool CLASS::base_##CBNAME(wxWindow* a) { \
938 return PCLASS::CBNAME(a); \
939 }
940
389c5527 941//---------------------------------------------------------------------------
2f90df85
RD
942
943#define DEC_PYCALLBACK_BOOL_(CBNAME) \
944 bool CBNAME(); \
945 bool base_##CBNAME();
946
947
948#define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
949 bool CLASS::CBNAME() { \
950 bool rval; \
951 bool doSave = wxPyRestoreThread(); \
952 if (m_myInst.findCallback(#CBNAME)) \
953 rval = m_myInst.callCallback(Py_BuildValue("()")); \
954 else \
955 rval = PCLASS::CBNAME(); \
956 wxPySaveThread(doSave); \
957 return rval; \
958 } \
959 bool CLASS::base_##CBNAME() { \
960 return PCLASS::CBNAME(); \
961 }
962
b1462dfa
RD
963//---------------------------------------------------------------------------
964
965#define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
966 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \
967 wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def);
968
969
970#define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
971 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
972 bool doSave = wxPyRestoreThread(); \
973 int rval; \
974 if (m_myInst.findCallback(#CBNAME)) \
975 rval = m_myInst.callCallback(Py_BuildValue("(iii)", a,b,c));\
976 else \
977 rval = PCLASS::CBNAME(a, b, c); \
978 wxPySaveThread(doSave); \
979 return (wxDragResult)rval; \
980 } \
981 wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
982 return PCLASS::CBNAME(a, b, c); \
983 }
984
985//---------------------------------------------------------------------------
986
c368d904
RD
987#define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
988 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location); \
989
990#define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
991 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
992 bool doSave = wxPyRestoreThread(); \
993 wxFSFile* rval=0; \
994 if (m_myInst.findCallback(#CBNAME)) { \
995 PyObject* ro; \
996 ro=m_myInst.callCallbackObj(Py_BuildValue("(Os)", \
997 wxPyConstructObject(&a, "(wxFileSystemC"),b.c_str())); \
998 if (ro) { \
999 SWIG_GetPtrObj(ro, (void **)&rval, "_wxFSFILE_p"); \
1000 Py_DECREF(ro); \
1001 } \
1002 } \
1003 wxPySaveThread(doSave); \
1004 return rval; \
1005 };
1006
1007//---------------------------------------------------------------------------
1008
b1462dfa
RD
1009#define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1010 bool CBNAME(wxDragResult a); \
1011 bool base_##CBNAME(wxDragResult a);
1012
1013
1014#define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1015 bool CLASS::CBNAME(wxDragResult a) { \
1016 bool doSave = wxPyRestoreThread(); \
1017 bool rval; \
1018 if (m_myInst.findCallback(#CBNAME)) \
1019 rval = m_myInst.callCallback(Py_BuildValue("(i)", a)); \
1020 else \
1021 rval = PCLASS::CBNAME(a); \
1022 wxPySaveThread(doSave); \
1023 return rval; \
1024 } \
1025 bool CLASS::base_##CBNAME(wxDragResult a) { \
1026 return PCLASS::CBNAME(a); \
1027 }
1028
1029//---------------------------------------------------------------------------
1030
1031#define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1032 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def);
1033
1034
1035#define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1036 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1037 bool doSave = wxPyRestoreThread(); \
1038 int rval; \
1039 if (m_myInst.findCallback(#CBNAME)) \
1040 rval = m_myInst.callCallback(Py_BuildValue("(iii)", a,b,c));\
1041 wxPySaveThread(doSave); \
1042 return (wxDragResult)rval; \
1043 } \
1044
1045//---------------------------------------------------------------------------
1046
1047#define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1048 bool CBNAME(int a, int b, const wxString& c);
1049
1050
1051#define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1052 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1053 bool rval; \
1054 bool doSave = wxPyRestoreThread(); \
1055 if (m_myInst.findCallback(#CBNAME)) \
1056 rval = m_myInst.callCallback(Py_BuildValue("(iis)",a,b,c.c_str()));\
1057 wxPySaveThread(doSave); \
1058 return rval; \
1059 } \
1060
1061//---------------------------------------------------------------------------
1062
1063#define DEC_PYCALLBACK_SIZET_(CBNAME) \
1064 size_t CBNAME(); \
1065 size_t base_##CBNAME();
1066
1067
1068#define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1069 size_t CLASS::CBNAME() { \
1070 size_t rval; \
1071 bool doSave = wxPyRestoreThread(); \
1072 if (m_myInst.findCallback(#CBNAME)) \
1073 rval = m_myInst.callCallback(Py_BuildValue("()")); \
1074 else \
1075 rval = PCLASS::CBNAME(); \
1076 wxPySaveThread(doSave); \
1077 return rval; \
1078 } \
1079 size_t CLASS::base_##CBNAME() { \
1080 return PCLASS::CBNAME(); \
1081 }
1082
1083//---------------------------------------------------------------------------
1084
1085#define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1086 wxDataFormat CBNAME(); \
1087 wxDataFormat base_##CBNAME();
1088
1089
1090#define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1091 wxDataFormat CLASS::CBNAME(size_t a) { \
1092 wxDataFormat rval; \
1093 bool doSave = wxPyRestoreThread(); \
1094 if (m_myInst.findCallback(#CBNAME)) { \
1095 PyObject* ro; \
1096 wxDataFormat* ptr; \
1097 ro = m_myInst.callCallbackObj(Py_BuildValue("(i)", a)); \
f6bcfd97
BP
1098 if (ro) { \
1099 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxDataFormat_p")) \
1100 rval = *ptr; \
1101 Py_DECREF(ro); \
1102 } \
b1462dfa
RD
1103 } \
1104 else \
1105 rval = PCLASS::CBNAME(a); \
1106 wxPySaveThread(doSave); \
1107 return rval; \
1108 } \
1109 wxDataFormat CLASS::base_##CBNAME(size_t a) { \
1110 return PCLASS::CBNAME(a); \
1111 }
1112
389c5527 1113//---------------------------------------------------------------------------
f6bcfd97
BP
1114
1115#define DEC_PYCALLBACK__constany(CBNAME, Type) \
1116 void CBNAME(const Type& a); \
1117 void base_##CBNAME(const Type& a);
1118
1119
1120#define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1121 void CLASS::CBNAME(const Type& a) { \
1122 bool doSave = wxPyRestoreThread(); \
1123 if (m_myInst.findCallback(#CBNAME)) \
1124 m_myInst.callCallback(Py_BuildValue("(O)", \
1125 wxPyConstructObject((void*)&a, #Type))); \
1126 else \
1127 PCLASS::CBNAME(a); \
1128 wxPySaveThread(doSave); \
1129 } \
1130 void CLASS::base_##CBNAME(const Type& a) { \
1131 PCLASS::CBNAME(a); \
1132 }
1133
1134
1135//---------------------------------------------------------------------------
1136
1137#define DEC_PYCALLBACK__any(CBNAME, Type) \
1138 void CBNAME(Type& a); \
1139 void base_##CBNAME(Type& a);
1140
1141
1142#define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1143 void CLASS::CBNAME(Type& a) { \
1144 bool doSave = wxPyRestoreThread(); \
1145 if (m_myInst.findCallback(#CBNAME)) \
1146 m_myInst.callCallback(Py_BuildValue("(O)", \
1147 wxPyConstructObject(&a, #Type))); \
1148 else \
1149 PCLASS::CBNAME(a); \
1150 wxPySaveThread(doSave); \
1151 } \
1152 void CLASS::base_##CBNAME(Type& a) { \
1153 PCLASS::CBNAME(a); \
1154 }
1155
efc5f224 1156//---------------------------------------------------------------------------
f6bcfd97
BP
1157
1158#define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1159 bool CBNAME(Type& a); \
1160 bool base_##CBNAME(Type& a);
1161
1162
1163#define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
1164 bool CLASS::CBNAME(Type& a) { \
1165 bool rv; \
1166 bool doSave = wxPyRestoreThread(); \
1167 if (m_myInst.findCallback(#CBNAME)) \
1168 rv = m_myInst.callCallback(Py_BuildValue("(O)", \
1169 wxPyConstructObject(&a, #Type))); \
1170 else \
1171 rv = PCLASS::CBNAME(a); \
1172 wxPySaveThread(doSave); \
1173 return rv; \
1174 } \
1175 bool CLASS::base_##CBNAME(Type& a) { \
1176 return PCLASS::CBNAME(a); \
1177 }
1178
efc5f224
RD
1179//---------------------------------------------------------------------------
1180
7bf85405
RD
1181#endif
1182
efc5f224
RD
1183
1184
b1462dfa 1185