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