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