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