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