]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/helpers.h
Further fixes for wx-config and MacOS X.
[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
0122b7e3 263 void (*p_wxPyCBH_setCallbackInfo)(wxPyCallbackHelper& cbh, PyObject* self, PyObject* klass, int incref);
1e7ecb7b
RD
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
0122b7e3 321void wxPyCBH_setCallbackInfo(wxPyCallbackHelper& cbh, PyObject* self, PyObject* klass, int incref);
1e7ecb7b
RD
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
900d9886
RD
354class wxPyClientData : public wxClientData {
355public:
356 wxPyClientData(PyObject* obj) {
357 m_obj = obj;
358 Py_INCREF(m_obj);
359 }
360
361 ~wxPyClientData() {
362#ifdef wxPyUSE_EXPORT
363 wxPyTState* state = wxPyCoreAPIPtr->p_wxPyBeginBlockThreads();
364 Py_DECREF(m_obj);
365 wxPyCoreAPIPtr->p_wxPyEndBlockThreads(state);
366#else
367 wxPyTState* state = wxPyBeginBlockThreads();
368 Py_DECREF(m_obj);
369 wxPyEndBlockThreads(state);
370#endif
371 }
372 PyObject* m_obj;
373};
374
375
376
bb0054cd
RD
377//---------------------------------------------------------------------------
378// These macros are used to implement the virtual methods that should
379// redirect to a Python method if one exists. The names designate the
b1462dfa 380// return type, if any, as well as any parameter types.
bb0054cd
RD
381//---------------------------------------------------------------------------
382
f6bcfd97 383#define PYPRIVATE \
0122b7e3
RD
384 void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \
385 wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \
f6bcfd97 386 } \
c368d904 387 private: wxPyCallbackHelper m_myInst
efc5f224
RD
388
389//---------------------------------------------------------------------------
390
d559219f
RD
391#define DEC_PYCALLBACK__(CBNAME) \
392 void CBNAME(); \
393 void base_##CBNAME();
394
395
19a97bd6
RD
396#define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
397 void CLASS::CBNAME() { \
398 bool found; \
399 wxPyTState* state = wxPyBeginBlockThreads(); \
400 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
401 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
402 wxPyEndBlockThreads(state); \
403 if (! found) \
404 PCLASS::CBNAME(); \
405 } \
406 void CLASS::base_##CBNAME() { \
407 PCLASS::CBNAME(); \
d559219f
RD
408 }
409
410//---------------------------------------------------------------------------
411
412#define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
413 bool CBNAME(int a, int b); \
414 bool base_##CBNAME(int a, int b);
415
416
417#define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
418 bool CLASS::CBNAME(int a, int b) { \
059a841c 419 bool rval=FALSE, found; \
19a97bd6
RD
420 wxPyTState* state = wxPyBeginBlockThreads(); \
421 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1e7ecb7b 422 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
19a97bd6
RD
423 wxPyEndBlockThreads(state); \
424 if (! found) \
d559219f 425 rval = PCLASS::CBNAME(a,b); \
d559219f 426 return rval; \
bb0054cd 427 } \
d559219f 428 bool CLASS::base_##CBNAME(int a, int b) { \
bb0054cd
RD
429 return PCLASS::CBNAME(a,b); \
430 }
431
432//---------------------------------------------------------------------------
433
c368d904
RD
434#define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
435 void CBNAME(int a, int b); \
436 void base_##CBNAME(int a, int b);
437
438
439#define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
440 void CLASS::CBNAME(int a, int b) { \
19a97bd6
RD
441 bool found; \
442 wxPyTState* state = wxPyBeginBlockThreads(); \
443 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
444 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
445 wxPyEndBlockThreads(state); \
446 if (! found) \
c368d904 447 PCLASS::CBNAME(a,b); \
c368d904
RD
448 } \
449 void CLASS::base_##CBNAME(int a, int b) { \
450 PCLASS::CBNAME(a,b); \
451 }
452
453//---------------------------------------------------------------------------
454
d559219f
RD
455#define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
456 bool CBNAME(int a); \
457 bool base_##CBNAME(int a);
458
459
460#define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
461 bool CLASS::CBNAME(int a) { \
059a841c 462 bool rval=FALSE, found; \
19a97bd6
RD
463 wxPyTState* state = wxPyBeginBlockThreads(); \
464 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
059a841c 465 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
19a97bd6
RD
466 wxPyEndBlockThreads(state); \
467 if (! found) \
d559219f 468 rval = PCLASS::CBNAME(a); \
d559219f 469 return rval; \
bb0054cd 470 } \
d559219f 471 bool CLASS::base_##CBNAME(int a) { \
bb0054cd
RD
472 return PCLASS::CBNAME(a); \
473 }
474
efc5f224
RD
475//---------------------------------------------------------------------------
476
d559219f
RD
477#define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
478 bool CBNAME(int a);
479
480
481#define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
482 bool CLASS::CBNAME(int a) { \
059a841c 483 bool rval=FALSE; \
19a97bd6
RD
484 wxPyTState* state = wxPyBeginBlockThreads(); \
485 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1e7ecb7b 486 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
194fa2ac 487 else rval = FALSE; \
19a97bd6 488 wxPyEndBlockThreads(state); \
d559219f 489 return rval; \
bb0054cd
RD
490 }
491
492
493//---------------------------------------------------------------------------
494
d559219f
RD
495#define DEC_PYCALLBACK__DC(CBNAME) \
496 void CBNAME(wxDC& a); \
497 void base_##CBNAME(wxDC& a);
498
499
19a97bd6
RD
500#define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
501 void CLASS::CBNAME(wxDC& a) { \
502 bool found; \
503 wxPyTState* state = wxPyBeginBlockThreads(); \
504 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
505 PyObject* obj = wxPyMake_wxObject(&a); \
506 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
507 Py_DECREF(obj); \
508 } \
509 wxPyEndBlockThreads(state); \
510 if (! found) \
511 PCLASS::CBNAME(a); \
512 } \
513 void CLASS::base_##CBNAME(wxDC& a) { \
514 PCLASS::CBNAME(a); \
bb0054cd
RD
515 }
516
efc5f224
RD
517
518
bb0054cd
RD
519//---------------------------------------------------------------------------
520
d559219f
RD
521#define DEC_PYCALLBACK__DCBOOL(CBNAME) \
522 void CBNAME(wxDC& a, bool b); \
523 void base_##CBNAME(wxDC& a, bool b);
524
525
526#define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
527 void CLASS::CBNAME(wxDC& a, bool b) { \
19a97bd6
RD
528 bool found; \
529 wxPyTState* state = wxPyBeginBlockThreads(); \
530 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
531 PyObject* obj = wxPyMake_wxObject(&a); \
1e7ecb7b 532 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
de20db99
RD
533 Py_DECREF(obj); \
534 } \
19a97bd6
RD
535 wxPyEndBlockThreads(state); \
536 if (! found) \
efc5f224
RD
537 PCLASS::CBNAME(a, b); \
538 } \
d559219f 539 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
efc5f224
RD
540 PCLASS::CBNAME(a, b); \
541 }
542
543//---------------------------------------------------------------------------
544
d559219f
RD
545#define DEC_PYCALLBACK__DCBOOL(CBNAME) \
546 void CBNAME(wxDC& a, bool b); \
547 void base_##CBNAME(wxDC& a, bool b);
548
549
550#define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
551 void CLASS::CBNAME(wxDC& a, bool b) { \
19a97bd6
RD
552 bool found; \
553 wxPyTState* state = wxPyBeginBlockThreads(); \
554 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
555 PyObject* obj = wxPyMake_wxObject(&a); \
1e7ecb7b 556 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
de20db99
RD
557 Py_DECREF(obj); \
558 } \
19a97bd6
RD
559 wxPyEndBlockThreads(state); \
560 if (! found) \
efc5f224
RD
561 PCLASS::CBNAME(a, b); \
562 } \
d559219f 563 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
efc5f224
RD
564 PCLASS::CBNAME(a, b); \
565 }
566
567//---------------------------------------------------------------------------
568
d559219f
RD
569#define DEC_PYCALLBACK__2DBL(CBNAME) \
570 void CBNAME(double a, double b); \
571 void base_##CBNAME(double a, double b);
572
573
19a97bd6
RD
574#define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
575 void CLASS::CBNAME(double a, double b) { \
576 bool found; \
577 wxPyTState* state = wxPyBeginBlockThreads(); \
578 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
579 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
580 wxPyEndBlockThreads(state); \
581 if (! found) \
582 PCLASS::CBNAME(a, b); \
583 } \
584 void CLASS::base_##CBNAME(double a, double b) { \
585 PCLASS::CBNAME(a, b); \
efc5f224
RD
586 }
587
588//---------------------------------------------------------------------------
589
d559219f
RD
590#define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
591 void CBNAME(double a, double b, int c, int d); \
592 void base_##CBNAME(double a, double b, int c, int d);
593
594
595#define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
596 void CLASS::CBNAME(double a, double b, int c, int d) { \
19a97bd6
RD
597 bool found; \
598 wxPyTState* state = wxPyBeginBlockThreads(); \
599 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
600 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
efc5f224 601 a,b,c,d)); \
19a97bd6
RD
602 wxPyEndBlockThreads(state); \
603 if (! found) \
efc5f224
RD
604 PCLASS::CBNAME(a, b, c, d); \
605 } \
d559219f 606 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
efc5f224
RD
607 PCLASS::CBNAME(a, b, c, d); \
608 }
609
610//---------------------------------------------------------------------------
611
19a97bd6 612#define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
d559219f
RD
613 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
614 void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
615
616
617#define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
618 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
19a97bd6
RD
619 bool found; \
620 wxPyTState* state = wxPyBeginBlockThreads(); \
621 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
622 PyObject* obj = wxPyMake_wxObject(&a); \
1e7ecb7b 623 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
de20db99
RD
624 Py_DECREF(obj); \
625 } \
19a97bd6
RD
626 wxPyEndBlockThreads(state); \
627 if (! found) \
d559219f 628 PCLASS::CBNAME(a, b, c, d, e, f); \
d559219f
RD
629 } \
630 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
631 PCLASS::CBNAME(a, b, c, d, e, f); \
efc5f224
RD
632 }
633
634//---------------------------------------------------------------------------
635
d559219f
RD
636#define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
637 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
638 bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
639
640
641#define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
642 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
19a97bd6
RD
643 bool found; \
644 wxPyTState* state = wxPyBeginBlockThreads(); \
059a841c 645 bool rval=FALSE; \
19a97bd6
RD
646 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
647 PyObject* obj = wxPyMake_wxObject(&a); \
1e7ecb7b 648 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
de20db99
RD
649 Py_DECREF(obj); \
650 } \
19a97bd6
RD
651 wxPyEndBlockThreads(state); \
652 if (! found) \
99a49d3e 653 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
99a49d3e 654 return rval; \
d559219f
RD
655 } \
656 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
657 return PCLASS::CBNAME(a, b, c, d, e, f); \
efc5f224
RD
658 }
659
660//---------------------------------------------------------------------------
661
d559219f
RD
662#define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
663 void CBNAME(bool a, double b, double c, int d, int e); \
664 void base_##CBNAME(bool a, double b, double c, int d, int e);
665
666
667#define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
668 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
19a97bd6
RD
669 bool found; \
670 wxPyTState* state = wxPyBeginBlockThreads(); \
671 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
f2e1c18a 672 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
d559219f 673 (int)a,b,c,d,e)); \
19a97bd6
RD
674 wxPyEndBlockThreads(state); \
675 if (! found) \
d559219f 676 PCLASS::CBNAME(a, b, c, d, e); \
d559219f
RD
677 } \
678 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
679 PCLASS::CBNAME(a, b, c, d, e); \
efc5f224
RD
680 }
681
682//---------------------------------------------------------------------------
683
19a97bd6 684#define DEC_PYCALLBACK__DC4DBL(CBNAME) \
d559219f
RD
685 void CBNAME(wxDC& a, double b, double c, double d, double e); \
686 void base_##CBNAME(wxDC& a, double b, double c, double d, double e);
687
688
689#define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
690 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
19a97bd6
RD
691 bool found; \
692 wxPyTState* state = wxPyBeginBlockThreads(); \
693 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
694 PyObject* obj = wxPyMake_wxObject(&a); \
1e7ecb7b 695 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
de20db99
RD
696 Py_DECREF(obj); \
697 } \
19a97bd6
RD
698 wxPyEndBlockThreads(state); \
699 if (! found) \
d559219f 700 PCLASS::CBNAME(a, b, c, d, e); \
d559219f
RD
701 } \
702 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
703 PCLASS::CBNAME(a, b, c, d, e); \
efc5f224
RD
704 }
705
706//---------------------------------------------------------------------------
707
d559219f
RD
708#define DEC_PYCALLBACK__DCBOOL(CBNAME) \
709 void CBNAME(wxDC& a, bool b); \
710 void base_##CBNAME(wxDC& a, bool b);
711
712
19a97bd6
RD
713#define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
714 void CLASS::CBNAME(wxDC& a, bool b) { \
715 bool found; \
716 wxPyTState* state = wxPyBeginBlockThreads(); \
717 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
718 PyObject* obj = wxPyMake_wxObject(&a); \
719 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
720 Py_DECREF(obj); \
721 } \
722 wxPyEndBlockThreads(state); \
723 if (! found) \
724 PCLASS::CBNAME(a, b); \
725 } \
726 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
727 PCLASS::CBNAME(a, b); \
efc5f224 728 }
bb0054cd 729
7bf85405 730//---------------------------------------------------------------------------
7bf85405 731
d559219f
RD
732#define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
733 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
734 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f);
735
736
737#define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
738 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
739 int e, int f) { \
19a97bd6
RD
740 bool found; \
741 wxPyTState* state = wxPyBeginBlockThreads(); \
742 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
743 PyObject* obj = wxPyMake_wxObject(a); \
1e7ecb7b 744 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
de20db99
RD
745 Py_DECREF(obj); \
746 } \
19a97bd6
RD
747 wxPyEndBlockThreads(state); \
748 if (! found) \
d559219f 749 PCLASS::CBNAME(a, b, c, d, e, f); \
d559219f
RD
750 } \
751 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
752 int e, int f) { \
753 PCLASS::CBNAME(a, b, c, d, e, f); \
efc5f224
RD
754 }
755
756//---------------------------------------------------------------------------
757
d559219f
RD
758#define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
759 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
760 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e);
761
762
763#define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
764 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
19a97bd6
RD
765 bool found; \
766 wxPyTState* state = wxPyBeginBlockThreads(); \
767 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
768 PyObject* obj = wxPyMake_wxObject(a); \
1e7ecb7b 769 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
de20db99
RD
770 Py_DECREF(obj); \
771 } \
19a97bd6
RD
772 wxPyEndBlockThreads(state); \
773 if (! found) \
d559219f 774 PCLASS::CBNAME(a, b, c, d, e); \
d559219f
RD
775 } \
776 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
777 int d, int e) { \
778 PCLASS::CBNAME(a, b, c, d, e); \
efc5f224
RD
779 }
780
781//---------------------------------------------------------------------------
782
d559219f
RD
783#define DEC_PYCALLBACK__2DBLINT(CBNAME) \
784 void CBNAME(double a, double b, int c); \
785 void base_##CBNAME(double a, double b, int c);
786
787
19a97bd6
RD
788#define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
789 void CLASS::CBNAME(double a, double b, int c) { \
790 bool found; \
791 wxPyTState* state = wxPyBeginBlockThreads(); \
792 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
793 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
794 wxPyEndBlockThreads(state); \
795 if (! found) \
796 PCLASS::CBNAME(a, b, c); \
797 } \
798 void CLASS::base_##CBNAME(double a, double b, int c) { \
799 PCLASS::CBNAME(a, b, c); \
efc5f224
RD
800 }
801
802//---------------------------------------------------------------------------
803
d559219f
RD
804#define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
805 void CBNAME(bool a, double b, double c, int d); \
806 void base_##CBNAME(bool a, double b, double c, int d);
807
808
809#define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
810 void CLASS::CBNAME(bool a, double b, double c, int d) { \
19a97bd6
RD
811 bool found; \
812 wxPyTState* state = wxPyBeginBlockThreads(); \
813 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
814 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\
815 wxPyEndBlockThreads(state); \
816 if (! found) \
d559219f 817 PCLASS::CBNAME(a, b, c, d); \
d559219f
RD
818 } \
819 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
820 PCLASS::CBNAME(a, b, c, d); \
efc5f224
RD
821 }
822
823//---------------------------------------------------------------------------
824//---------------------------------------------------------------------------
389c5527
RD
825
826#define DEC_PYCALLBACK__STRING(CBNAME) \
827 void CBNAME(const wxString& a); \
828 void base_##CBNAME(const wxString& a);
829
830
19a97bd6
RD
831#define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
832 void CLASS::CBNAME(const wxString& a) { \
833 bool found; \
834 wxPyTState* state = wxPyBeginBlockThreads(); \
835 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
836 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str())); \
837 wxPyEndBlockThreads(state); \
838 if (! found) \
839 PCLASS::CBNAME(a); \
840 } \
841 void CLASS::base_##CBNAME(const wxString& a) { \
842 PCLASS::CBNAME(a); \
389c5527
RD
843 }
844
845//---------------------------------------------------------------------------
846
847#define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
848 bool CBNAME(const wxString& a); \
849 bool base_##CBNAME(const wxString& a);
850
851
852#define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
853 bool CLASS::CBNAME(const wxString& a) { \
059a841c 854 bool rval=FALSE; \
19a97bd6
RD
855 bool found; \
856 wxPyTState* state = wxPyBeginBlockThreads(); \
857 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
858 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str()));\
859 wxPyEndBlockThreads(state); \
860 if (! found) \
389c5527 861 rval = PCLASS::CBNAME(a); \
389c5527
RD
862 return rval; \
863 } \
864 bool CLASS::base_##CBNAME(const wxString& a) { \
865 return PCLASS::CBNAME(a); \
866 }
867
868//---------------------------------------------------------------------------
869
c368d904
RD
870#define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
871 bool CBNAME(const wxString& a);
872 \
19a97bd6
RD
873#define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
874 bool CLASS::CBNAME(const wxString& a) { \
059a841c 875 bool rval=FALSE; \
19a97bd6
RD
876 wxPyTState* state = wxPyBeginBlockThreads(); \
877 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
878 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str())); \
879 wxPyEndBlockThreads(state); \
880 return rval; \
881 } \
c368d904
RD
882
883//---------------------------------------------------------------------------
884
885#define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
886 wxString CBNAME(const wxString& a); \
887
888#define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
889 wxString CLASS::CBNAME(const wxString& a) { \
890 wxString rval; \
19a97bd6
RD
891 wxPyTState* state = wxPyBeginBlockThreads(); \
892 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
c368d904 893 PyObject* ro; \
19a97bd6 894 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(s)", a.c_str()));\
c368d904 895 if (ro) { \
de20db99
RD
896 PyObject* str = PyObject_Str(ro); \
897 rval = PyString_AsString(str); \
898 Py_DECREF(ro); Py_DECREF(str); \
c368d904
RD
899 } \
900 } \
19a97bd6 901 wxPyEndBlockThreads(state); \
c368d904
RD
902 return rval; \
903 } \
904
905//---------------------------------------------------------------------------
906
907#define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
908 wxString CBNAME(const wxString& a,int b); \
909
910#define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
911 wxString CLASS::CBNAME(const wxString& a,int b) { \
912 wxString rval; \
19a97bd6
RD
913 wxPyTState* state = wxPyBeginBlockThreads(); \
914 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
c368d904 915 PyObject* ro; \
1e7ecb7b 916 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(si)", a.c_str(),b)); \
c368d904 917 if (ro) { \
de20db99
RD
918 PyObject* str = PyObject_Str(ro); \
919 rval = PyString_AsString(str); \
920 Py_DECREF(ro); Py_DECREF(str); \
c368d904
RD
921 } \
922 } \
19a97bd6 923 wxPyEndBlockThreads(state); \
c368d904
RD
924 return rval; \
925 } \
926
927//---------------------------------------------------------------------------
928
f0261a72
RD
929#define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
930 bool CBNAME(const wxString& a, const wxString& b); \
931 bool base_##CBNAME(const wxString& a, const wxString& b);
932
933
934#define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
935 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
059a841c 936 bool rval=FALSE; \
19a97bd6
RD
937 bool found; \
938 wxPyTState* state = wxPyBeginBlockThreads(); \
939 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
940 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ss)", \
f0261a72 941 a.c_str(), b.c_str())); \
19a97bd6
RD
942 wxPyEndBlockThreads(state); \
943 if (! found) \
f0261a72 944 rval = PCLASS::CBNAME(a, b); \
f0261a72
RD
945 return rval; \
946 } \
947 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
948 return PCLASS::CBNAME(a, b); \
949 }
950
951//---------------------------------------------------------------------------
952
389c5527
RD
953#define DEC_PYCALLBACK_STRING_(CBNAME) \
954 wxString CBNAME(); \
955 wxString base_##CBNAME();
956
957
958#define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
959 wxString CLASS::CBNAME() { \
960 wxString rval; \
19a97bd6
RD
961 bool found; \
962 wxPyTState* state = wxPyBeginBlockThreads(); \
963 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
389c5527 964 PyObject* ro; \
19a97bd6 965 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
f6bcfd97 966 if (ro) { \
de20db99
RD
967 PyObject* str = PyObject_Str(ro); \
968 rval = PyString_AsString(str); \
969 Py_DECREF(ro); Py_DECREF(str); \
f6bcfd97 970 } \
389c5527 971 } \
19a97bd6
RD
972 wxPyEndBlockThreads(state); \
973 if (! found) \
b1462dfa 974 rval = PCLASS::CBNAME(); \
389c5527
RD
975 return rval; \
976 } \
b1462dfa
RD
977 wxString CLASS::base_##CBNAME() { \
978 return PCLASS::CBNAME(); \
389c5527
RD
979 }
980
981//---------------------------------------------------------------------------
982
983#define DEC_PYCALLBACK_STRING__pure(CBNAME) \
984 wxString CBNAME();
985
986
987#define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
988 wxString CLASS::CBNAME() { \
989 wxString rval; \
19a97bd6
RD
990 wxPyTState* state = wxPyBeginBlockThreads(); \
991 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
389c5527 992 PyObject* ro; \
19a97bd6 993 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
f6bcfd97 994 if (ro) { \
de20db99
RD
995 PyObject* str = PyObject_Str(ro); \
996 rval = PyString_AsString(str); \
997 Py_DECREF(ro); Py_DECREF(str); \
f6bcfd97 998 } \
389c5527 999 } \
19a97bd6 1000 wxPyEndBlockThreads(state); \
389c5527
RD
1001 return rval; \
1002 }
1003
1004//---------------------------------------------------------------------------
1005
1006#define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
1007 bool CBNAME(const wxHtmlTag& a); \
1008
1009
1010#define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
1011 bool CLASS::CBNAME(const wxHtmlTag& a) { \
059a841c 1012 bool rval=FALSE; \
19a97bd6
RD
1013 wxPyTState* state = wxPyBeginBlockThreads(); \
1014 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1015 PyObject* obj = wxPyConstructObject((void*)&a, "wxHtmlTag", 0); \
1016 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
de20db99
RD
1017 Py_DECREF(obj); \
1018 } \
19a97bd6 1019 wxPyEndBlockThreads(state); \
389c5527
RD
1020 return rval; \
1021 }
1022
0122b7e3
RD
1023//---------------------------------------------------------------------------
1024
1025#define DEC_PYCALLBACK__CELLINTINT(CBNAME) \
1026 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y); \
1027 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y);
1028
1029#define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \
1030 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1031 wxString rval; \
1032 bool found; \
1033 wxPyTState* state = wxPyBeginBlockThreads(); \
1034 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1035 PyObject* obj = wxPyConstructObject((void*)cell, "wxHtmlCell", 0); \
1036 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \
1037 Py_DECREF(obj); \
1038 } \
1039 wxPyEndBlockThreads(state); \
1040 if (! found) \
1041 PCLASS::CBNAME(cell, x, y); \
1042 } \
1043 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1044 PCLASS::CBNAME(cell, x, y); \
1045 }
1046
1047
1048//---------------------------------------------------------------------------
1049
1050#define DEC_PYCALLBACK__CELLINTINTME(CBNAME) \
1051 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e); \
1052 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e);
1053
1054#define IMP_PYCALLBACK__CELLINTINTME(CLASS, PCLASS, CBNAME) \
1055 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1056 bool found; \
1057 wxPyTState* state = wxPyBeginBlockThreads(); \
1058 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1059 PyObject* obj = wxPyConstructObject((void*)cell, "wxHtmlCell", 0); \
1060 PyObject* o2 = wxPyConstructObject((void*)&e, "wxMouseEvent", 0); \
1061 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1062 Py_DECREF(obj); \
1063 Py_DECREF(o2); \
1064 } \
1065 wxPyEndBlockThreads(state); \
1066 if (! found) \
1067 PCLASS::CBNAME(cell, x, y, e); \
1068 } \
1069 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1070 PCLASS::CBNAME(cell, x, y, e); \
1071 }
1072
1073
1074
389c5527 1075//---------------------------------------------------------------------------
2f90df85
RD
1076
1077#define DEC_PYCALLBACK___pure(CBNAME) \
1078 void CBNAME(); \
1079
1080
1081#define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1082 void CLASS::CBNAME() { \
19a97bd6
RD
1083 wxPyTState* state = wxPyBeginBlockThreads(); \
1084 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1085 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1086 wxPyEndBlockThreads(state); \
2f90df85
RD
1087 }
1088
1089//---------------------------------------------------------------------------
1090
1091#define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1092 wxSize CBNAME(); \
1093
1094
1095#define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1096 wxSize CLASS::CBNAME() { \
1097 wxSize rval(0,0); \
19a97bd6
RD
1098 wxPyTState* state = wxPyBeginBlockThreads(); \
1099 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2f90df85
RD
1100 PyObject* ro; \
1101 wxSize* ptr; \
19a97bd6 1102 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
f6bcfd97
BP
1103 if (ro) { \
1104 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \
1105 rval = *ptr; \
1106 Py_DECREF(ro); \
1107 } \
2f90df85 1108 } \
19a97bd6 1109 wxPyEndBlockThreads(state); \
2f90df85
RD
1110 return rval; \
1111 }
1112
1113//---------------------------------------------------------------------------
1114
1115#define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1116 bool CBNAME(wxWindow* a); \
1117 bool base_##CBNAME(wxWindow* a);
1118
1119
19a97bd6
RD
1120#define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1121 bool CLASS::CBNAME(wxWindow* a) { \
059a841c 1122 bool rval=FALSE; \
19a97bd6
RD
1123 bool found; \
1124 wxPyTState* state = wxPyBeginBlockThreads(); \
1125 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1126 PyObject* obj = wxPyMake_wxObject(a); \
1127 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1128 Py_DECREF(obj); \
1129 } \
1130 wxPyEndBlockThreads(state); \
1131 if (! found) \
1132 rval = PCLASS::CBNAME(a); \
1133 return rval; \
1134 } \
1135 bool CLASS::base_##CBNAME(wxWindow* a) { \
1136 return PCLASS::CBNAME(a); \
2f90df85
RD
1137 }
1138
389c5527 1139//---------------------------------------------------------------------------
2f90df85
RD
1140
1141#define DEC_PYCALLBACK_BOOL_(CBNAME) \
1142 bool CBNAME(); \
1143 bool base_##CBNAME();
1144
1145
19a97bd6
RD
1146#define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1147 bool CLASS::CBNAME() { \
059a841c 1148 bool rval=FALSE; \
19a97bd6
RD
1149 bool found; \
1150 wxPyTState* state = wxPyBeginBlockThreads(); \
1151 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1152 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1153 wxPyEndBlockThreads(state); \
1154 if (! found) \
1155 rval = PCLASS::CBNAME(); \
1156 return rval; \
1157 } \
1158 bool CLASS::base_##CBNAME() { \
1159 return PCLASS::CBNAME(); \
2f90df85
RD
1160 }
1161
b1462dfa
RD
1162//---------------------------------------------------------------------------
1163
19a97bd6
RD
1164#define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1165 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \
b1462dfa
RD
1166 wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def);
1167
1168
19a97bd6
RD
1169#define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1170 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
059a841c 1171 int rval=0; \
19a97bd6
RD
1172 bool found; \
1173 wxPyTState* state = wxPyBeginBlockThreads(); \
19a97bd6 1174 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1e7ecb7b 1175 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
19a97bd6
RD
1176 wxPyEndBlockThreads(state); \
1177 if (! found) \
1178 rval = PCLASS::CBNAME(a, b, c); \
1179 return (wxDragResult)rval; \
1180 } \
1181 wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1182 return PCLASS::CBNAME(a, b, c); \
b1462dfa
RD
1183 }
1184
1185//---------------------------------------------------------------------------
1186
c368d904
RD
1187#define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1188 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location); \
1189
1190#define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1191 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
19a97bd6 1192 wxPyTState* state = wxPyBeginBlockThreads(); \
c368d904 1193 wxFSFile* rval=0; \
19a97bd6 1194 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
c368d904 1195 PyObject* ro; \
19a97bd6
RD
1196 PyObject* obj = wxPyMake_wxObject(&a); \
1197 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Os)",\
de20db99 1198 obj, b.c_str())); \
c368d904
RD
1199 if (ro) { \
1200 SWIG_GetPtrObj(ro, (void **)&rval, "_wxFSFILE_p"); \
1201 Py_DECREF(ro); \
1202 } \
de20db99
RD
1203 Py_DECREF(obj); \
1204 } \
19a97bd6 1205 wxPyEndBlockThreads(state); \
c368d904
RD
1206 return rval; \
1207 };
1208
1209//---------------------------------------------------------------------------
1210
b1462dfa
RD
1211#define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1212 bool CBNAME(wxDragResult a); \
1213 bool base_##CBNAME(wxDragResult a);
1214
1215
1216#define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1217 bool CLASS::CBNAME(wxDragResult a) { \
059a841c 1218 bool rval=FALSE; \
19a97bd6
RD
1219 bool found; \
1220 wxPyTState* state = wxPyBeginBlockThreads(); \
19a97bd6
RD
1221 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1222 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a));\
1223 wxPyEndBlockThreads(state); \
1224 if (! found) \
b1462dfa 1225 rval = PCLASS::CBNAME(a); \
b1462dfa
RD
1226 return rval; \
1227 } \
1228 bool CLASS::base_##CBNAME(wxDragResult a) { \
1229 return PCLASS::CBNAME(a); \
1230 }
1231
1232//---------------------------------------------------------------------------
1233
1234#define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1235 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def);
1236
1237
1238#define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1239 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
19a97bd6 1240 wxPyTState* state = wxPyBeginBlockThreads(); \
059a841c 1241 int rval=0; \
19a97bd6 1242 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1e7ecb7b 1243 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
19a97bd6 1244 wxPyEndBlockThreads(state); \
b1462dfa
RD
1245 return (wxDragResult)rval; \
1246 } \
1247
1248//---------------------------------------------------------------------------
1249
1250#define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1251 bool CBNAME(int a, int b, const wxString& c);
1252
1253
1254#define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1255 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
059a841c 1256 bool rval=FALSE; \
19a97bd6
RD
1257 wxPyTState* state = wxPyBeginBlockThreads(); \
1258 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1e7ecb7b 1259 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)",a,b,c.c_str()));\
19a97bd6 1260 wxPyEndBlockThreads(state); \
b1462dfa
RD
1261 return rval; \
1262 } \
1263
1264//---------------------------------------------------------------------------
1265
1266#define DEC_PYCALLBACK_SIZET_(CBNAME) \
1267 size_t CBNAME(); \
1268 size_t base_##CBNAME();
1269
1270
1271#define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1272 size_t CLASS::CBNAME() { \
059a841c 1273 size_t rval=0; \
19a97bd6
RD
1274 bool found; \
1275 wxPyTState* state = wxPyBeginBlockThreads(); \
1276 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1277 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1278 wxPyEndBlockThreads(state); \
1279 if (! found) \
b1462dfa 1280 rval = PCLASS::CBNAME(); \
b1462dfa
RD
1281 return rval; \
1282 } \
1283 size_t CLASS::base_##CBNAME() { \
1284 return PCLASS::CBNAME(); \
1285 }
1286
1287//---------------------------------------------------------------------------
1288
c7e7022c
RD
1289#define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1290 wxDataFormat CBNAME(size_t a); \
1291 wxDataFormat base_##CBNAME(size_t a);
b1462dfa
RD
1292
1293
1294#define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1295 wxDataFormat CLASS::CBNAME(size_t a) { \
059a841c 1296 wxDataFormat rval=0; \
19a97bd6
RD
1297 bool found; \
1298 wxPyTState* state = wxPyBeginBlockThreads(); \
1299 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
b1462dfa
RD
1300 PyObject* ro; \
1301 wxDataFormat* ptr; \
c7e7022c 1302 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
f6bcfd97
BP
1303 if (ro) { \
1304 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxDataFormat_p")) \
1305 rval = *ptr; \
1306 Py_DECREF(ro); \
1307 } \
b1462dfa 1308 } \
19a97bd6
RD
1309 wxPyEndBlockThreads(state); \
1310 if (! found) \
b1462dfa 1311 rval = PCLASS::CBNAME(a); \
b1462dfa
RD
1312 return rval; \
1313 } \
1314 wxDataFormat CLASS::base_##CBNAME(size_t a) { \
1315 return PCLASS::CBNAME(a); \
1316 }
1317
389c5527 1318//---------------------------------------------------------------------------
f6bcfd97
BP
1319
1320#define DEC_PYCALLBACK__constany(CBNAME, Type) \
1321 void CBNAME(const Type& a); \
1322 void base_##CBNAME(const Type& a);
1323
1324
19a97bd6
RD
1325#define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1326 void CLASS::CBNAME(const Type& a) { \
1327 bool found; \
1328 wxPyTState* state = wxPyBeginBlockThreads(); \
1329 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1330 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1331 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1332 Py_DECREF(obj); \
1333 } \
1334 wxPyEndBlockThreads(state); \
1335 if (! found) \
1336 PCLASS::CBNAME(a); \
1337 } \
1338 void CLASS::base_##CBNAME(const Type& a) { \
1339 PCLASS::CBNAME(a); \
f6bcfd97
BP
1340 }
1341
1342
1343//---------------------------------------------------------------------------
1344
1345#define DEC_PYCALLBACK__any(CBNAME, Type) \
1346 void CBNAME(Type& a); \
1347 void base_##CBNAME(Type& a);
1348
1349
19a97bd6
RD
1350#define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1351 void CLASS::CBNAME(Type& a) { \
1352 bool found; \
1353 wxPyTState* state = wxPyBeginBlockThreads(); \
1354 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1355 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1356 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1357 Py_DECREF(obj); \
1358 } \
1359 wxPyEndBlockThreads(state); \
1360 if (! found) \
1361 PCLASS::CBNAME(a); \
1362 } \
1363 void CLASS::base_##CBNAME(Type& a) { \
1364 PCLASS::CBNAME(a); \
f6bcfd97
BP
1365 }
1366
efc5f224 1367//---------------------------------------------------------------------------
f6bcfd97
BP
1368
1369#define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1370 bool CBNAME(Type& a); \
1371 bool base_##CBNAME(Type& a);
1372
1373
19a97bd6
RD
1374#define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
1375 bool CLASS::CBNAME(Type& a) { \
1376 bool rv; \
1377 bool found; \
1378 wxPyTState* state = wxPyBeginBlockThreads(); \
1379 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1380 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1381 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1382 Py_DECREF(obj); \
1383 } \
1384 wxPyEndBlockThreads(state); \
1385 if (! found) \
1386 rv = PCLASS::CBNAME(a); \
1387 return rv; \
1388 } \
1389 bool CLASS::base_##CBNAME(Type& a) { \
1390 return PCLASS::CBNAME(a); \
f6bcfd97
BP
1391 }
1392
efc5f224
RD
1393//---------------------------------------------------------------------------
1394
c7e7022c
RD
1395#define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
1396 wxString CBNAME(long a, long b) const; \
1397 wxString base_##CBNAME(long a, long b)const ;
1398
1399
1400#define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
1401 wxString CLASS::CBNAME(long a, long b) const { \
1402 wxString rval; \
19a97bd6
RD
1403 bool found; \
1404 wxPyTState* state = wxPyBeginBlockThreads(); \
1405 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
c7e7022c
RD
1406 PyObject* ro; \
1407 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1408 if (ro) { \
1409 PyObject* str = PyObject_Str(ro); \
1410 rval = PyString_AsString(str); \
1411 Py_DECREF(ro); Py_DECREF(str); \
1412 } \
1413 } \
19a97bd6
RD
1414 wxPyEndBlockThreads(state); \
1415 if (! found) \
c7e7022c 1416 rval = PCLASS::CBNAME(a,b); \
c7e7022c
RD
1417 return rval; \
1418 } \
1419 wxString CLASS::base_##CBNAME(long a, long b) const { \
1420 return PCLASS::CBNAME(a,b); \
1421 }
1422
1423//---------------------------------------------------------------------------
1424
1425#define DEC_PYCALLBACK_INT_LONG(CBNAME) \
1426 int CBNAME(long a) const; \
1427 int base_##CBNAME(long a)const ;
1428
1429
1430#define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
1431 int CLASS::CBNAME(long a) const { \
1432 int rval=-1; \
19a97bd6
RD
1433 bool found; \
1434 wxPyTState* state = wxPyBeginBlockThreads(); \
1435 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
c7e7022c
RD
1436 PyObject* ro; \
1437 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1438 if (ro) { \
1439 rval = PyInt_AsLong(ro); \
1440 Py_DECREF(ro); \
1441 } \
1442 } \
19a97bd6
RD
1443 wxPyEndBlockThreads(state); \
1444 if (! found) \
c7e7022c 1445 rval = PCLASS::CBNAME(a); \
c7e7022c
RD
1446 return rval; \
1447 } \
1448 int CLASS::base_##CBNAME(long a) const { \
1449 return PCLASS::CBNAME(a); \
1450 }
1451
1452
1453//---------------------------------------------------------------------------
1454
1455#define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
00b6c4e3 1456 wxListItemAttr* CBNAME(long a) const; \
c7e7022c
RD
1457 wxListItemAttr* base_##CBNAME(long a);
1458
1459
1460#define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
00b6c4e3 1461 wxListItemAttr *CLASS::CBNAME(long a) const { \
c7e7022c 1462 wxListItemAttr *rval = NULL; \
19a97bd6
RD
1463 bool found; \
1464 wxPyTState* state = wxPyBeginBlockThreads(); \
1465 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
c7e7022c
RD
1466 PyObject* ro; \
1467 wxListItemAttr* ptr; \
1468 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1469 if (ro) { \
1470 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxListItemAttr_p")) \
1471 rval = ptr; \
1472 Py_DECREF(ro); \
1473 } \
1474 } \
19a97bd6
RD
1475 wxPyEndBlockThreads(state); \
1476 if (! found) \
c7e7022c 1477 rval = PCLASS::CBNAME(a); \
c7e7022c
RD
1478 return rval; \
1479 } \
1480 wxListItemAttr *CLASS::base_##CBNAME(long a) { \
1481 return PCLASS::CBNAME(a); \
1482 }
1483
1484//---------------------------------------------------------------------------
1485
0122b7e3
RD
1486#define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
1487 bool CBNAME(wxMouseEvent& e); \
1488 bool base_##CBNAME(wxMouseEvent& e);
1489
1490#define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
1491 bool CLASS::CBNAME(wxMouseEvent& e) { \
1492 bool rval; \
1493 bool found; \
1494 wxPyTState* state = wxPyBeginBlockThreads(); \
1495 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1496 PyObject* ro; \
1497 PyObject* obj = wxPyConstructObject((void*)&e, "wxMouseEvent", 0); \
1498 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
1499 if (ro) { \
1500 rval = PyInt_AsLong(ro); \
1501 Py_DECREF(ro); \
1502 } \
1503 Py_DECREF(obj); \
1504 } \
1505 wxPyEndBlockThreads(state); \
1506 if (! found) \
1507 return PCLASS::CBNAME(e); \
1508 } \
1509 bool CLASS::base_##CBNAME(wxMouseEvent& e) { \
1510 return PCLASS::CBNAME(e); \
1511 }
1512
1513
1514//---------------------------------------------------------------------------
1515
7bf85405 1516#endif