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