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