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