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