]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/helpers.h
patch fix for a constant definition under OS/2 VA V4.0
[wxWidgets.git] / wxPython / src / helpers.h
1 ////////////////////////////////////////////////////////////////////////////
2 // Name: helpers.h
3 // Purpose: Helper functions/classes for the wxPython extenaion module
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 7/1/97
8 // RCS-ID: $Id$
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 #ifndef __wxp_helpers__
14 #define __wxp_helpers__
15
16 #include <wx/wx.h>
17
18 //----------------------------------------------------------------------
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
34 //---------------------------------------------------------------------------
35
36 typedef unsigned char byte;
37
38
39 class wxPyApp: public wxApp
40 {
41 public:
42 wxPyApp();
43 ~wxPyApp();
44 int MainLoop(void);
45 bool OnInit(void);
46 };
47 extern wxPyApp *wxPythonApp;
48
49 //----------------------------------------------------------------------
50
51 void __wxPreStart();
52 PyObject* __wxStart(PyObject*, PyObject* args);
53 void __wxCleanup();
54
55 //extern PyObject* wxPython_dict;
56 PyObject* __wxSetDictionary(PyObject*, PyObject* args);
57
58 void wxPyEventThunker(wxObject*, wxEvent& event);
59
60 PyObject* wxPyConstructObject(void* ptr,
61 const char* className,
62 int setThisOwn=0);
63 PyObject* wxPyConstructObject(void* ptr,
64 const char* className,
65 PyObject* klass,
66 int setThisOwn=0);
67 PyObject* wxPyClassExists(const char* className);
68 PyObject* wxPyMake_wxObject(wxObject* source);
69 void wxPyPtrTypeMap_Add(const char* commonName, const char* ptrName);
70
71 PyObject* wxPy_ConvertList(wxListBase* list, const char* className);
72 long wxPyGetWinHandle(wxWindow* win);
73
74 //----------------------------------------------------------------------
75
76 struct wxPyTState {
77 PyThreadState* newState;
78 PyThreadState* prevState;
79
80 wxPyTState() : newState(NULL), prevState(NULL) {}
81 };
82
83
84 wxPyTState* wxPyBeginBlockThreads();
85 void wxPyEndBlockThreads(wxPyTState* state);
86
87
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()
93 WX_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
98 class wxPyInputStream {
99 public:
100 // underlying wxInputStream
101 wxInputStream* wxi;
102
103 public:
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
126 //----------------------------------------------------------------------
127 // These are helpers used by the typemaps
128
129 byte* byte_LIST_helper(PyObject* source);
130 int* int_LIST_helper(PyObject* source);
131 long* long_LIST_helper(PyObject* source);
132 char** string_LIST_helper(PyObject* source);
133 wxPoint* wxPoint_LIST_helper(PyObject* source, int* npoints);
134 wxBitmap** wxBitmap_LIST_helper(PyObject* source);
135 wxString* wxString_LIST_helper(PyObject* source);
136 wxAcceleratorEntry* wxAcceleratorEntry_LIST_helper(PyObject* source);
137
138 bool wxSize_helper(PyObject* source, wxSize** obj);
139 bool wxPoint_helper(PyObject* source, wxPoint** obj);
140 bool wxRealPoint_helper(PyObject* source, wxRealPoint** obj);
141 bool wxRect_helper(PyObject* source, wxRect** obj);
142 bool wxColour_helper(PyObject* source, wxColour** obj);
143
144 //----------------------------------------------------------------------
145
146 #ifndef SWIGCODE
147 extern "C" void SWIG_MakePtr(char *, void *, char *);
148 extern "C" char *SWIG_GetPtr(char *, void **, char *);
149 extern "C" char *SWIG_GetPtrObj(PyObject *obj, void **ptr, char *type);
150 #endif
151
152
153 #ifdef _MSC_VER
154 # pragma warning(disable:4800)
155 # pragma warning(disable:4190)
156 #endif
157
158 //----------------------------------------------------------------------
159
160 class wxPyCallback : public wxObject {
161 DECLARE_ABSTRACT_CLASS(wxPyCallback);
162 public:
163 wxPyCallback(PyObject* func);
164 wxPyCallback(const wxPyCallback& other);
165 ~wxPyCallback();
166
167 void EventThunker(wxEvent& event);
168
169 PyObject* m_func;
170 };
171
172 //---------------------------------------------------------------------------
173
174 class wxPyTimer : public wxTimer {
175 public:
176 wxPyTimer(PyObject* callback);
177 ~wxPyTimer();
178
179 void Notify();
180
181 private:
182 PyObject* func;
183 };
184
185 //---------------------------------------------------------------------------
186 //---------------------------------------------------------------------------
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.
190
191
192 class wxPyEvtSelfRef {
193 public:
194 wxPyEvtSelfRef();
195 ~wxPyEvtSelfRef();
196
197 void SetSelf(PyObject* self, bool clone=FALSE);
198 PyObject* GetSelf() const;
199
200 protected:
201 PyObject* m_self;
202 bool m_cloned;
203 };
204
205
206 class wxPyEvent : public wxEvent, public wxPyEvtSelfRef {
207 DECLARE_DYNAMIC_CLASS(wxPyEvent)
208 public:
209 wxPyEvent(int id=0);
210 ~wxPyEvent();
211
212 void CopyObject(wxObject& dest) const;
213 };
214
215
216 class wxPyCommandEvent : public wxCommandEvent, public wxPyEvtSelfRef {
217 DECLARE_DYNAMIC_CLASS(wxPyCommandEvent)
218 public:
219 wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0);
220 ~wxPyCommandEvent();
221
222 void CopyObject(wxObject& dest) const;
223 };
224
225
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
231 class wxPyCallbackHelper;
232
233 struct 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
242 wxPyTState* (*p_wxPyBeginBlockThreads)();
243 void (*p_wxPyEndBlockThreads)(wxPyTState* state);
244
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);
252 wxPoint* (*p_wxPoint_LIST_helper)(PyObject* source, int* npoints);
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
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
273 };
274
275 #ifdef wxPyUSE_EXPORT
276 static 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
287 class wxPyCallbackHelper {
288 public:
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
311 private:
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
321 void wxPyCBH_setSelf(wxPyCallbackHelper& cbh, PyObject* self, PyObject* klass, int incref);
322 bool wxPyCBH_findCallback(const wxPyCallbackHelper& cbh, const char* name);
323 int wxPyCBH_callCallback(const wxPyCallbackHelper& cbh, PyObject* argTuple);
324 PyObject* wxPyCBH_callCallbackObj(const wxPyCallbackHelper& cbh, PyObject* argTuple);
325 void wxPyCBH_delete(wxPyCallbackHelper* cbh);
326
327
328
329 //----------------------------------------------------------------------
330
331 class wxPyUserData : public wxObject {
332 public:
333 wxPyUserData(PyObject* obj) {
334 m_obj = obj;
335 Py_INCREF(m_obj);
336 }
337
338 ~wxPyUserData() {
339 #ifdef wxPyUSE_EXPORT
340 wxPyTState* state = wxPyCoreAPIPtr->p_wxPyBeginBlockThreads();
341 Py_DECREF(m_obj);
342 wxPyCoreAPIPtr->p_wxPyEndBlockThreads(state);
343 #else
344 wxPyTState* state = wxPyBeginBlockThreads();
345 Py_DECREF(m_obj);
346 wxPyEndBlockThreads(state);
347 #endif
348 }
349 PyObject* m_obj;
350 };
351
352
353
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
357 // return type, if any, as well as any parameter types.
358 //---------------------------------------------------------------------------
359
360 #define PYPRIVATE \
361 void _setSelf(PyObject* self, PyObject* _class, int incref=1) { \
362 wxPyCBH_setSelf(m_myInst, self, _class, incref); \
363 } \
364 private: wxPyCallbackHelper m_myInst
365
366 //---------------------------------------------------------------------------
367
368 #define DEC_PYCALLBACK__(CBNAME) \
369 void CBNAME(); \
370 void base_##CBNAME();
371
372
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(); \
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) { \
396 bool rval=FALSE, found; \
397 wxPyTState* state = wxPyBeginBlockThreads(); \
398 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
399 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
400 wxPyEndBlockThreads(state); \
401 if (! found) \
402 rval = PCLASS::CBNAME(a,b); \
403 return rval; \
404 } \
405 bool CLASS::base_##CBNAME(int a, int b) { \
406 return PCLASS::CBNAME(a,b); \
407 }
408
409 //---------------------------------------------------------------------------
410
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) { \
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) \
424 PCLASS::CBNAME(a,b); \
425 } \
426 void CLASS::base_##CBNAME(int a, int b) { \
427 PCLASS::CBNAME(a,b); \
428 }
429
430 //---------------------------------------------------------------------------
431
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) { \
439 bool rval=FALSE, found; \
440 wxPyTState* state = wxPyBeginBlockThreads(); \
441 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
442 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
443 wxPyEndBlockThreads(state); \
444 if (! found) \
445 rval = PCLASS::CBNAME(a); \
446 return rval; \
447 } \
448 bool CLASS::base_##CBNAME(int a) { \
449 return PCLASS::CBNAME(a); \
450 }
451
452 //---------------------------------------------------------------------------
453
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) { \
460 bool rval=FALSE; \
461 wxPyTState* state = wxPyBeginBlockThreads(); \
462 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
463 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
464 else rval = FALSE; \
465 wxPyEndBlockThreads(state); \
466 return rval; \
467 }
468
469
470 //---------------------------------------------------------------------------
471
472 #define DEC_PYCALLBACK__DC(CBNAME) \
473 void CBNAME(wxDC& a); \
474 void base_##CBNAME(wxDC& a);
475
476
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); \
492 }
493
494
495
496 //---------------------------------------------------------------------------
497
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) { \
505 bool found; \
506 wxPyTState* state = wxPyBeginBlockThreads(); \
507 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
508 PyObject* obj = wxPyMake_wxObject(&a); \
509 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
510 Py_DECREF(obj); \
511 } \
512 wxPyEndBlockThreads(state); \
513 if (! found) \
514 PCLASS::CBNAME(a, b); \
515 } \
516 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
517 PCLASS::CBNAME(a, b); \
518 }
519
520 //---------------------------------------------------------------------------
521
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) { \
529 bool found; \
530 wxPyTState* state = wxPyBeginBlockThreads(); \
531 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
532 PyObject* obj = wxPyMake_wxObject(&a); \
533 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
534 Py_DECREF(obj); \
535 } \
536 wxPyEndBlockThreads(state); \
537 if (! found) \
538 PCLASS::CBNAME(a, b); \
539 } \
540 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
541 PCLASS::CBNAME(a, b); \
542 }
543
544 //---------------------------------------------------------------------------
545
546 #define DEC_PYCALLBACK__2DBL(CBNAME) \
547 void CBNAME(double a, double b); \
548 void base_##CBNAME(double a, double b);
549
550
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); \
563 }
564
565 //---------------------------------------------------------------------------
566
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) { \
574 bool found; \
575 wxPyTState* state = wxPyBeginBlockThreads(); \
576 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
577 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
578 a,b,c,d)); \
579 wxPyEndBlockThreads(state); \
580 if (! found) \
581 PCLASS::CBNAME(a, b, c, d); \
582 } \
583 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
584 PCLASS::CBNAME(a, b, c, d); \
585 }
586
587 //---------------------------------------------------------------------------
588
589 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
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) { \
596 bool found; \
597 wxPyTState* state = wxPyBeginBlockThreads(); \
598 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
599 PyObject* obj = wxPyMake_wxObject(&a); \
600 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
601 Py_DECREF(obj); \
602 } \
603 wxPyEndBlockThreads(state); \
604 if (! found) \
605 PCLASS::CBNAME(a, b, c, d, e, f); \
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); \
609 }
610
611 //---------------------------------------------------------------------------
612
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) { \
620 bool found; \
621 wxPyTState* state = wxPyBeginBlockThreads(); \
622 bool rval=FALSE; \
623 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
624 PyObject* obj = wxPyMake_wxObject(&a); \
625 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
626 Py_DECREF(obj); \
627 } \
628 wxPyEndBlockThreads(state); \
629 if (! found) \
630 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
631 return rval; \
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); \
635 }
636
637 //---------------------------------------------------------------------------
638
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) { \
646 bool found; \
647 wxPyTState* state = wxPyBeginBlockThreads(); \
648 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
649 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
650 (int)a,b,c,d,e)); \
651 wxPyEndBlockThreads(state); \
652 if (! found) \
653 PCLASS::CBNAME(a, b, c, d, e); \
654 } \
655 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
656 PCLASS::CBNAME(a, b, c, d, e); \
657 }
658
659 //---------------------------------------------------------------------------
660
661 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
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) { \
668 bool found; \
669 wxPyTState* state = wxPyBeginBlockThreads(); \
670 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
671 PyObject* obj = wxPyMake_wxObject(&a); \
672 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
673 Py_DECREF(obj); \
674 } \
675 wxPyEndBlockThreads(state); \
676 if (! found) \
677 PCLASS::CBNAME(a, b, c, d, e); \
678 } \
679 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
680 PCLASS::CBNAME(a, b, c, d, e); \
681 }
682
683 //---------------------------------------------------------------------------
684
685 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
686 void CBNAME(wxDC& a, bool b); \
687 void base_##CBNAME(wxDC& a, bool b);
688
689
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); \
705 }
706
707 //---------------------------------------------------------------------------
708
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) { \
717 bool found; \
718 wxPyTState* state = wxPyBeginBlockThreads(); \
719 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
720 PyObject* obj = wxPyMake_wxObject(a); \
721 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
722 Py_DECREF(obj); \
723 } \
724 wxPyEndBlockThreads(state); \
725 if (! found) \
726 PCLASS::CBNAME(a, b, c, d, e, f); \
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); \
731 }
732
733 //---------------------------------------------------------------------------
734
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) { \
742 bool found; \
743 wxPyTState* state = wxPyBeginBlockThreads(); \
744 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
745 PyObject* obj = wxPyMake_wxObject(a); \
746 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
747 Py_DECREF(obj); \
748 } \
749 wxPyEndBlockThreads(state); \
750 if (! found) \
751 PCLASS::CBNAME(a, b, c, d, e); \
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); \
756 }
757
758 //---------------------------------------------------------------------------
759
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
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); \
777 }
778
779 //---------------------------------------------------------------------------
780
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) { \
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) \
794 PCLASS::CBNAME(a, b, c, d); \
795 } \
796 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
797 PCLASS::CBNAME(a, b, c, d); \
798 }
799
800 //---------------------------------------------------------------------------
801 //---------------------------------------------------------------------------
802
803 #define DEC_PYCALLBACK__STRING(CBNAME) \
804 void CBNAME(const wxString& a); \
805 void base_##CBNAME(const wxString& a);
806
807
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); \
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) { \
831 bool rval=FALSE; \
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) \
838 rval = PCLASS::CBNAME(a); \
839 return rval; \
840 } \
841 bool CLASS::base_##CBNAME(const wxString& a) { \
842 return PCLASS::CBNAME(a); \
843 }
844
845 //---------------------------------------------------------------------------
846
847 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
848 bool CBNAME(const wxString& a);
849 \
850 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
851 bool CLASS::CBNAME(const wxString& a) { \
852 bool rval=FALSE; \
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 } \
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; \
868 wxPyTState* state = wxPyBeginBlockThreads(); \
869 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
870 PyObject* ro; \
871 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(s)", a.c_str()));\
872 if (ro) { \
873 PyObject* str = PyObject_Str(ro); \
874 rval = PyString_AsString(str); \
875 Py_DECREF(ro); Py_DECREF(str); \
876 } \
877 } \
878 wxPyEndBlockThreads(state); \
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; \
890 wxPyTState* state = wxPyBeginBlockThreads(); \
891 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
892 PyObject* ro; \
893 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(si)", a.c_str(),b)); \
894 if (ro) { \
895 PyObject* str = PyObject_Str(ro); \
896 rval = PyString_AsString(str); \
897 Py_DECREF(ro); Py_DECREF(str); \
898 } \
899 } \
900 wxPyEndBlockThreads(state); \
901 return rval; \
902 } \
903
904 //---------------------------------------------------------------------------
905
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) { \
913 bool rval=FALSE; \
914 bool found; \
915 wxPyTState* state = wxPyBeginBlockThreads(); \
916 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
917 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ss)", \
918 a.c_str(), b.c_str())); \
919 wxPyEndBlockThreads(state); \
920 if (! found) \
921 rval = PCLASS::CBNAME(a, b); \
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
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; \
938 bool found; \
939 wxPyTState* state = wxPyBeginBlockThreads(); \
940 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
941 PyObject* ro; \
942 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
943 if (ro) { \
944 PyObject* str = PyObject_Str(ro); \
945 rval = PyString_AsString(str); \
946 Py_DECREF(ro); Py_DECREF(str); \
947 } \
948 } \
949 wxPyEndBlockThreads(state); \
950 if (! found) \
951 rval = PCLASS::CBNAME(); \
952 return rval; \
953 } \
954 wxString CLASS::base_##CBNAME() { \
955 return PCLASS::CBNAME(); \
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; \
967 wxPyTState* state = wxPyBeginBlockThreads(); \
968 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
969 PyObject* ro; \
970 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
971 if (ro) { \
972 PyObject* str = PyObject_Str(ro); \
973 rval = PyString_AsString(str); \
974 Py_DECREF(ro); Py_DECREF(str); \
975 } \
976 } \
977 wxPyEndBlockThreads(state); \
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) { \
989 bool rval=FALSE; \
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)); \
994 Py_DECREF(obj); \
995 } \
996 wxPyEndBlockThreads(state); \
997 return rval; \
998 }
999
1000 //---------------------------------------------------------------------------
1001
1002 #define DEC_PYCALLBACK___pure(CBNAME) \
1003 void CBNAME(); \
1004
1005
1006 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1007 void CLASS::CBNAME() { \
1008 wxPyTState* state = wxPyBeginBlockThreads(); \
1009 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1010 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1011 wxPyEndBlockThreads(state); \
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); \
1023 wxPyTState* state = wxPyBeginBlockThreads(); \
1024 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1025 PyObject* ro; \
1026 wxSize* ptr; \
1027 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1028 if (ro) { \
1029 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \
1030 rval = *ptr; \
1031 Py_DECREF(ro); \
1032 } \
1033 } \
1034 wxPyEndBlockThreads(state); \
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
1045 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1046 bool CLASS::CBNAME(wxWindow* a) { \
1047 bool rval=FALSE; \
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); \
1062 }
1063
1064 //---------------------------------------------------------------------------
1065
1066 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1067 bool CBNAME(); \
1068 bool base_##CBNAME();
1069
1070
1071 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1072 bool CLASS::CBNAME() { \
1073 bool rval=FALSE; \
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(); \
1085 }
1086
1087 //---------------------------------------------------------------------------
1088
1089 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1090 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \
1091 wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def);
1092
1093
1094 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1095 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1096 int rval=0; \
1097 bool found; \
1098 wxPyTState* state = wxPyBeginBlockThreads(); \
1099 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1100 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
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); \
1108 }
1109
1110 //---------------------------------------------------------------------------
1111
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) { \
1117 wxPyTState* state = wxPyBeginBlockThreads(); \
1118 wxFSFile* rval=0; \
1119 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1120 PyObject* ro; \
1121 PyObject* obj = wxPyMake_wxObject(&a); \
1122 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Os)",\
1123 obj, b.c_str())); \
1124 if (ro) { \
1125 SWIG_GetPtrObj(ro, (void **)&rval, "_wxFSFILE_p"); \
1126 Py_DECREF(ro); \
1127 } \
1128 Py_DECREF(obj); \
1129 } \
1130 wxPyEndBlockThreads(state); \
1131 return rval; \
1132 };
1133
1134 //---------------------------------------------------------------------------
1135
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) { \
1143 bool rval=FALSE; \
1144 bool found; \
1145 wxPyTState* state = wxPyBeginBlockThreads(); \
1146 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1147 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a));\
1148 wxPyEndBlockThreads(state); \
1149 if (! found) \
1150 rval = PCLASS::CBNAME(a); \
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) { \
1165 wxPyTState* state = wxPyBeginBlockThreads(); \
1166 int rval=0; \
1167 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1168 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1169 wxPyEndBlockThreads(state); \
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) { \
1181 bool rval=FALSE; \
1182 wxPyTState* state = wxPyBeginBlockThreads(); \
1183 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1184 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)",a,b,c.c_str()));\
1185 wxPyEndBlockThreads(state); \
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() { \
1198 size_t rval=0; \
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) \
1205 rval = PCLASS::CBNAME(); \
1206 return rval; \
1207 } \
1208 size_t CLASS::base_##CBNAME() { \
1209 return PCLASS::CBNAME(); \
1210 }
1211
1212 //---------------------------------------------------------------------------
1213
1214 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1215 wxDataFormat CBNAME(size_t a); \
1216 wxDataFormat base_##CBNAME(size_t a);
1217
1218
1219 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1220 wxDataFormat CLASS::CBNAME(size_t a) { \
1221 wxDataFormat rval=0; \
1222 bool found; \
1223 wxPyTState* state = wxPyBeginBlockThreads(); \
1224 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1225 PyObject* ro; \
1226 wxDataFormat* ptr; \
1227 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1228 if (ro) { \
1229 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxDataFormat_p")) \
1230 rval = *ptr; \
1231 Py_DECREF(ro); \
1232 } \
1233 } \
1234 wxPyEndBlockThreads(state); \
1235 if (! found) \
1236 rval = PCLASS::CBNAME(a); \
1237 return rval; \
1238 } \
1239 wxDataFormat CLASS::base_##CBNAME(size_t a) { \
1240 return PCLASS::CBNAME(a); \
1241 }
1242
1243 //---------------------------------------------------------------------------
1244
1245 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1246 void CBNAME(const Type& a); \
1247 void base_##CBNAME(const Type& a);
1248
1249
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); \
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
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); \
1290 }
1291
1292 //---------------------------------------------------------------------------
1293
1294 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1295 bool CBNAME(Type& a); \
1296 bool base_##CBNAME(Type& a);
1297
1298
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); \
1316 }
1317
1318 //---------------------------------------------------------------------------
1319
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; \
1328 bool found; \
1329 wxPyTState* state = wxPyBeginBlockThreads(); \
1330 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
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 } \
1339 wxPyEndBlockThreads(state); \
1340 if (! found) \
1341 rval = PCLASS::CBNAME(a,b); \
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; \
1358 bool found; \
1359 wxPyTState* state = wxPyBeginBlockThreads(); \
1360 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
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 } \
1368 wxPyEndBlockThreads(state); \
1369 if (! found) \
1370 rval = PCLASS::CBNAME(a); \
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) \
1381 wxListItemAttr* CBNAME(long a) const; \
1382 wxListItemAttr* base_##CBNAME(long a);
1383
1384
1385 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
1386 wxListItemAttr *CLASS::CBNAME(long a) const { \
1387 wxListItemAttr *rval = NULL; \
1388 bool found; \
1389 wxPyTState* state = wxPyBeginBlockThreads(); \
1390 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
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 } \
1400 wxPyEndBlockThreads(state); \
1401 if (! found) \
1402 rval = PCLASS::CBNAME(a); \
1403 return rval; \
1404 } \
1405 wxListItemAttr *CLASS::base_##CBNAME(long a) { \
1406 return PCLASS::CBNAME(a); \
1407 }
1408
1409 //---------------------------------------------------------------------------
1410
1411 #endif