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