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