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