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