]> git.saurik.com Git - wxWidgets.git/blame_incremental - utils/wxPython/src/helpers.h
Added event class constructors
[wxWidgets.git] / utils / 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
21// if we want to handle threads and Python threads are available...
22#if defined(WXP_USE_THREAD) && defined(WITH_THREAD)
23
24#define WXP_WITH_THREAD
25#define wxPy_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
26#define wxPy_END_ALLOW_THREADS Py_END_ALLOW_THREADS
27
28#else // no Python threads...
29#undef WXP_WITH_THREAD
30#define wxPy_BEGIN_ALLOW_THREADS
31#define wxPy_END_ALLOW_THREADS
32#endif
33
34
35//---------------------------------------------------------------------------
36
37#if defined(__WXMSW__)
38# define HELPEREXPORT __declspec(dllexport)
39#else
40# define HELPEREXPORT
41#endif
42
43typedef unsigned char byte;
44
45//----------------------------------------------------------------------
46
47class wxPyApp: public wxApp
48{
49public:
50 wxPyApp();
51 ~wxPyApp();
52 int MainLoop(void);
53 bool OnInit(void);
54//# void AfterMainLoop(void);
55};
56
57extern wxPyApp *wxPythonApp;
58
59//----------------------------------------------------------------------
60
61void __wxPreStart();
62PyObject* __wxStart(PyObject*, PyObject* args);
63
64extern PyObject* wxPython_dict;
65PyObject* __wxSetDictionary(PyObject*, PyObject* args);
66
67void wxPyEventThunker(wxObject*, wxEvent& event);
68
69HELPEREXPORT PyObject* wxPyConstructObject(void* ptr, char* className);
70HELPEREXPORT bool wxPyRestoreThread();
71HELPEREXPORT void wxPySaveThread(bool doSave);
72HELPEREXPORT PyObject* wxPy_ConvertList(wxListBase* list, char* className);
73
74//----------------------------------------------------------------------
75// These are helpers used by the typemaps
76
77HELPEREXPORT byte* byte_LIST_helper(PyObject* source);
78HELPEREXPORT int* int_LIST_helper(PyObject* source);
79HELPEREXPORT long* long_LIST_helper(PyObject* source);
80HELPEREXPORT char** string_LIST_helper(PyObject* source);
81HELPEREXPORT wxPoint* wxPoint_LIST_helper(PyObject* source);
82HELPEREXPORT wxBitmap** wxBitmap_LIST_helper(PyObject* source);
83HELPEREXPORT wxString* wxString_LIST_helper(PyObject* source);
84HELPEREXPORT wxAcceleratorEntry* wxAcceleratorEntry_LIST_helper(PyObject* source);
85
86HELPEREXPORT bool wxSize_helper(PyObject* source, wxSize** obj);
87HELPEREXPORT bool wxPoint_helper(PyObject* source, wxPoint** obj);
88HELPEREXPORT bool wxRealPoint_helper(PyObject* source, wxRealPoint** obj);
89HELPEREXPORT bool wxRect_helper(PyObject* source, wxRect** obj);
90
91//----------------------------------------------------------------------
92
93#ifndef SWIGCODE
94extern "C" void SWIG_MakePtr(char *, void *, char *);
95extern "C" char *SWIG_GetPtr(char *, void **, char *);
96extern "C" char *SWIG_GetPtrObj(PyObject *obj, void **ptr, char *type);
97#endif
98
99
100#ifdef _MSC_VER
101# pragma warning(disable:4800)
102#endif
103
104
105
106// Non-const versions to keep SWIG happy.
107extern wxPoint wxPyDefaultPosition;
108extern wxSize wxPyDefaultSize;
109extern wxString wxPyEmptyStr;
110
111//----------------------------------------------------------------------
112
113class wxPyCallback : public wxObject {
114 DECLARE_ABSTRACT_CLASS(wxPyCallback);
115public:
116 wxPyCallback(PyObject* func);
117 wxPyCallback(const wxPyCallback& other);
118 ~wxPyCallback();
119
120 void EventThunker(wxEvent& event);
121
122 PyObject* m_func;
123};
124
125//---------------------------------------------------------------------------
126
127// class wxPyMenu : public wxMenu {
128// public:
129// wxPyMenu(const wxString& title = "", PyObject* func=NULL);
130// ~wxPyMenu();
131
132// private:
133// static void MenuCallback(wxMenu& menu, wxCommandEvent& evt);
134// PyObject* func;
135// };
136
137
138//---------------------------------------------------------------------------
139
140class wxPyTimer : public wxTimer {
141public:
142 wxPyTimer(PyObject* callback);
143 ~wxPyTimer();
144
145 void Notify();
146
147private:
148 PyObject* func;
149};
150
151//---------------------------------------------------------------------------
152
153
154
155
156//---------------------------------------------------------------------------
157// This class holds an instance of a Python Shadow Class object and assists
158// with looking up and invoking Python callback methods from C++ virtual
159// method redirections. For all classes which have virtuals which should be
160// overridable in wxPython, a new subclass is created that contains a
161// wxPyCallbackHelper.
162//
163// **** This class should be combined with wxPyCallback defined above.
164//
165
166class HELPEREXPORT wxPyCallbackHelper {
167public:
168 wxPyCallbackHelper();
169 ~wxPyCallbackHelper();
170
171 wxPyCallbackHelper(const wxPyCallbackHelper& other);
172
173 void setSelf(PyObject* self, int incref=TRUE);
174
175 bool findCallback(const wxString& name);
176 int callCallback(PyObject* argTuple);
177 PyObject* callCallbackObj(PyObject* argTuple);
178
179private:
180 PyObject* m_self;
181 PyObject* m_lastFound;
182};
183
184
185
186//---------------------------------------------------------------------------
187// These macros are used to implement the virtual methods that should
188// redirect to a Python method if one exists. The names designate the
189// return type, if any as well as any parameter types.
190//---------------------------------------------------------------------------
191
192#define PYPRIVATE \
193 void _setSelf(PyObject* self, int incref=TRUE) { \
194 m_myInst.setSelf(self, incref); \
195 } \
196 private: wxPyCallbackHelper m_myInst;
197
198//---------------------------------------------------------------------------
199
200#define DEC_PYCALLBACK__(CBNAME) \
201 void CBNAME(); \
202 void base_##CBNAME();
203
204
205#define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
206 void CLASS::CBNAME() { \
207 bool doSave = wxPyRestoreThread(); \
208 if (m_myInst.findCallback(#CBNAME)) \
209 m_myInst.callCallback(Py_BuildValue("()")); \
210 else \
211 PCLASS::CBNAME(); \
212 wxPySaveThread(doSave); \
213 } \
214 void CLASS::base_##CBNAME() { \
215 PCLASS::CBNAME(); \
216 }
217
218//---------------------------------------------------------------------------
219
220#define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
221 bool CBNAME(int a, int b); \
222 bool base_##CBNAME(int a, int b);
223
224
225#define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
226 bool CLASS::CBNAME(int a, int b) { \
227 bool rval; \
228 bool doSave = wxPyRestoreThread(); \
229 if (m_myInst.findCallback(#CBNAME)) \
230 rval = m_myInst.callCallback(Py_BuildValue("(ii)",a,b)); \
231 else \
232 rval = PCLASS::CBNAME(a,b); \
233 wxPySaveThread(doSave); \
234 return rval; \
235 } \
236 bool CLASS::base_##CBNAME(int a, int b) { \
237 return PCLASS::CBNAME(a,b); \
238 }
239
240//---------------------------------------------------------------------------
241
242#define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
243 bool CBNAME(int a); \
244 bool base_##CBNAME(int a);
245
246
247#define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
248 bool CLASS::CBNAME(int a) { \
249 bool rval; \
250 bool doSave = wxPyRestoreThread(); \
251 if (m_myInst.findCallback(#CBNAME)) \
252 rval = m_myInst.callCallback(Py_BuildValue("(i)",a)); \
253 else \
254 rval = PCLASS::CBNAME(a); \
255 wxPySaveThread(doSave); \
256 return rval; \
257 } \
258 bool CLASS::base_##CBNAME(int a) { \
259 return PCLASS::CBNAME(a); \
260 }
261
262//---------------------------------------------------------------------------
263
264#define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
265 bool CBNAME(int a);
266
267
268#define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
269 bool CLASS::CBNAME(int a) { \
270 bool rval; \
271 bool doSave = wxPyRestoreThread(); \
272 if (m_myInst.findCallback(#CBNAME)) \
273 rval = m_myInst.callCallback(Py_BuildValue("(i)",a)); \
274 else rval = false; \
275 wxPySaveThread(doSave); \
276 return rval; \
277 }
278
279
280//---------------------------------------------------------------------------
281
282#define DEC_PYCALLBACK__DC(CBNAME) \
283 void CBNAME(wxDC& a); \
284 void base_##CBNAME(wxDC& a);
285
286
287#define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
288 void CLASS::CBNAME(wxDC& a) { \
289 bool doSave = wxPyRestoreThread(); \
290 if (m_myInst.findCallback(#CBNAME)) \
291 m_myInst.callCallback(Py_BuildValue("(O)", \
292 wxPyConstructObject(&a, "wxDC"))); \
293 else \
294 PCLASS::CBNAME(a); \
295 wxPySaveThread(doSave); \
296 } \
297 void CLASS::base_##CBNAME(wxDC& a) { \
298 PCLASS::CBNAME(a); \
299 }
300
301
302
303//---------------------------------------------------------------------------
304
305#define DEC_PYCALLBACK__DCBOOL(CBNAME) \
306 void CBNAME(wxDC& a, bool b); \
307 void base_##CBNAME(wxDC& a, bool b);
308
309
310#define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
311 void CLASS::CBNAME(wxDC& a, bool b) { \
312 bool doSave = wxPyRestoreThread(); \
313 if (m_myInst.findCallback(#CBNAME)) \
314 m_myInst.callCallback(Py_BuildValue("(Oi)", \
315 wxPyConstructObject(&a, "wxDC"), (int)b)); \
316 else \
317 PCLASS::CBNAME(a, b); \
318 wxPySaveThread(doSave); \
319 } \
320 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
321 PCLASS::CBNAME(a, b); \
322 }
323
324//---------------------------------------------------------------------------
325
326#define DEC_PYCALLBACK__DCBOOL(CBNAME) \
327 void CBNAME(wxDC& a, bool b); \
328 void base_##CBNAME(wxDC& a, bool b);
329
330
331#define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
332 void CLASS::CBNAME(wxDC& a, bool b) { \
333 bool doSave = wxPyRestoreThread(); \
334 if (m_myInst.findCallback(#CBNAME)) \
335 m_myInst.callCallback(Py_BuildValue("(Oi)", \
336 wxPyConstructObject(&a, "wxDC"), (int)b)); \
337 else \
338 PCLASS::CBNAME(a, b); \
339 wxPySaveThread(doSave); \
340 } \
341 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
342 PCLASS::CBNAME(a, b); \
343 }
344
345//---------------------------------------------------------------------------
346
347#define DEC_PYCALLBACK__2DBL(CBNAME) \
348 void CBNAME(double a, double b); \
349 void base_##CBNAME(double a, double b);
350
351
352#define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
353 void CLASS::CBNAME(double a, double b) { \
354 bool doSave = wxPyRestoreThread(); \
355 if (m_myInst.findCallback(#CBNAME)) \
356 m_myInst.callCallback(Py_BuildValue("(dd)",a,b)); \
357 else \
358 PCLASS::CBNAME(a, b); \
359 wxPySaveThread(doSave); \
360 } \
361 void CLASS::base_##CBNAME(double a, double b) { \
362 PCLASS::CBNAME(a, b); \
363 }
364
365//---------------------------------------------------------------------------
366
367#define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
368 void CBNAME(double a, double b, int c, int d); \
369 void base_##CBNAME(double a, double b, int c, int d);
370
371
372#define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
373 void CLASS::CBNAME(double a, double b, int c, int d) { \
374 bool doSave = wxPyRestoreThread(); \
375 if (m_myInst.findCallback(#CBNAME)) \
376 m_myInst.callCallback(Py_BuildValue("(ddii)", \
377 a,b,c,d)); \
378 else \
379 PCLASS::CBNAME(a, b, c, d); \
380 wxPySaveThread(doSave); \
381 } \
382 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
383 PCLASS::CBNAME(a, b, c, d); \
384 }
385
386//---------------------------------------------------------------------------
387
388#define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
389 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
390 void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
391
392
393#define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
394 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
395 bool doSave = wxPyRestoreThread(); \
396 if (m_myInst.findCallback(#CBNAME)) \
397 m_myInst.callCallback(Py_BuildValue("(Oddddi)", \
398 wxPyConstructObject(&a, "wxDC"), \
399 b, c, d, e, (int)f)); \
400 else \
401 PCLASS::CBNAME(a, b, c, d, e, f); \
402 wxPySaveThread(doSave); \
403 } \
404 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
405 PCLASS::CBNAME(a, b, c, d, e, f); \
406 }
407
408//---------------------------------------------------------------------------
409
410#define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
411 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
412 bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
413
414
415#define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
416 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
417 bool doSave = wxPyRestoreThread(); \
418 if (m_myInst.findCallback(#CBNAME)) \
419 return m_myInst.callCallback(Py_BuildValue("(Oddddi)", \
420 wxPyConstructObject(&a, "wxDC"), \
421 b, c, d, e, (int)f)); \
422 else \
423 return PCLASS::CBNAME(a, b, c, d, e, f); \
424 wxPySaveThread(doSave); \
425 } \
426 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
427 return PCLASS::CBNAME(a, b, c, d, e, f); \
428 }
429
430//---------------------------------------------------------------------------
431
432#define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
433 void CBNAME(bool a, double b, double c, int d, int e); \
434 void base_##CBNAME(bool a, double b, double c, int d, int e);
435
436
437#define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
438 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
439 bool doSave = wxPyRestoreThread(); \
440 if (m_myInst.findCallback(#CBNAME)) \
441 m_myInst.callCallback(Py_BuildValue("(idii)", \
442 (int)a,b,c,d,e)); \
443 else \
444 PCLASS::CBNAME(a, b, c, d, e); \
445 wxPySaveThread(doSave); \
446 } \
447 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
448 PCLASS::CBNAME(a, b, c, d, e); \
449 }
450
451//---------------------------------------------------------------------------
452
453#define DEC_PYCALLBACK__DC4DBL(CBNAME) \
454 void CBNAME(wxDC& a, double b, double c, double d, double e); \
455 void base_##CBNAME(wxDC& a, double b, double c, double d, double e);
456
457
458#define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
459 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
460 bool doSave = wxPyRestoreThread(); \
461 if (m_myInst.findCallback(#CBNAME)) \
462 m_myInst.callCallback(Py_BuildValue("(Odddd)", \
463 wxPyConstructObject(&a, "wxDC"), \
464 b, c, d, e)); \
465 else \
466 PCLASS::CBNAME(a, b, c, d, e); \
467 wxPySaveThread(doSave); \
468 } \
469 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
470 PCLASS::CBNAME(a, b, c, d, e); \
471 }
472
473//---------------------------------------------------------------------------
474
475#define DEC_PYCALLBACK__DCBOOL(CBNAME) \
476 void CBNAME(wxDC& a, bool b); \
477 void base_##CBNAME(wxDC& a, bool b);
478
479
480#define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
481 void CLASS::CBNAME(wxDC& a, bool b) { \
482 bool doSave = wxPyRestoreThread(); \
483 if (m_myInst.findCallback(#CBNAME)) \
484 m_myInst.callCallback(Py_BuildValue("(Oi)", \
485 wxPyConstructObject(&a, "wxDC"), \
486 (int)b)); \
487 else \
488 PCLASS::CBNAME(a, b); \
489 wxPySaveThread(doSave); \
490 } \
491 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
492 PCLASS::CBNAME(a, b); \
493 }
494
495//---------------------------------------------------------------------------
496
497#define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
498 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
499 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f);
500
501
502#define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
503 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
504 int e, int f) { \
505 bool doSave = wxPyRestoreThread(); \
506 if (m_myInst.findCallback(#CBNAME)) \
507 m_myInst.callCallback(Py_BuildValue("(Oiddii)", \
508 wxPyConstructObject(a, "wxPyControlPoint"), \
509 (int)b, c, d, e, f)); \
510 else \
511 PCLASS::CBNAME(a, b, c, d, e, f); \
512 wxPySaveThread(doSave); \
513 } \
514 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
515 int e, int f) { \
516 PCLASS::CBNAME(a, b, c, d, e, f); \
517 }
518
519//---------------------------------------------------------------------------
520
521#define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
522 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
523 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e);
524
525
526#define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
527 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
528 bool doSave = wxPyRestoreThread(); \
529 if (m_myInst.findCallback(#CBNAME)) \
530 m_myInst.callCallback(Py_BuildValue("(Oddii)", \
531 wxPyConstructObject(a, "wxPyControlPoint"), \
532 b, c, d, e)); \
533 else \
534 PCLASS::CBNAME(a, b, c, d, e); \
535 wxPySaveThread(doSave); \
536 } \
537 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
538 int d, int e) { \
539 PCLASS::CBNAME(a, b, c, d, e); \
540 }
541
542//---------------------------------------------------------------------------
543
544#define DEC_PYCALLBACK__2DBLINT(CBNAME) \
545 void CBNAME(double a, double b, int c); \
546 void base_##CBNAME(double a, double b, int c);
547
548
549#define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
550 void CLASS::CBNAME(double a, double b, int c) { \
551 bool doSave = wxPyRestoreThread(); \
552 if (m_myInst.findCallback(#CBNAME)) \
553 m_myInst.callCallback(Py_BuildValue("(ddi)", a,b,c)); \
554 else \
555 PCLASS::CBNAME(a, b, c); \
556 wxPySaveThread(doSave); \
557 } \
558 void CLASS::base_##CBNAME(double a, double b, int c) { \
559 PCLASS::CBNAME(a, b, c); \
560 }
561
562//---------------------------------------------------------------------------
563
564#define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
565 void CBNAME(bool a, double b, double c, int d); \
566 void base_##CBNAME(bool a, double b, double c, int d);
567
568
569#define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
570 void CLASS::CBNAME(bool a, double b, double c, int d) { \
571 bool doSave = wxPyRestoreThread(); \
572 if (m_myInst.findCallback(#CBNAME)) \
573 m_myInst.callCallback(Py_BuildValue("(iddi)", (int)a,b,c,d)); \
574 else \
575 PCLASS::CBNAME(a, b, c, d); \
576 wxPySaveThread(doSave); \
577 } \
578 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
579 PCLASS::CBNAME(a, b, c, d); \
580 }
581
582//---------------------------------------------------------------------------
583//---------------------------------------------------------------------------
584
585#define DEC_PYCALLBACK__STRING(CBNAME) \
586 void CBNAME(const wxString& a); \
587 void base_##CBNAME(const wxString& a);
588
589
590#define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
591 void CLASS::CBNAME(const wxString& a) { \
592 bool doSave = wxPyRestoreThread(); \
593 if (m_myInst.findCallback(#CBNAME)) \
594 m_myInst.callCallback(Py_BuildValue("(s)", a.c_str())); \
595 else \
596 PCLASS::CBNAME(a); \
597 wxPySaveThread(doSave); \
598 } \
599 void CLASS::base_##CBNAME(const wxString& a) { \
600 PCLASS::CBNAME(a); \
601 }
602
603//---------------------------------------------------------------------------
604
605#define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
606 bool CBNAME(const wxString& a); \
607 bool base_##CBNAME(const wxString& a);
608
609
610#define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
611 bool CLASS::CBNAME(const wxString& a) { \
612 bool rval; \
613 bool doSave = wxPyRestoreThread(); \
614 if (m_myInst.findCallback(#CBNAME)) \
615 rval = m_myInst.callCallback(Py_BuildValue("(s)", a.c_str())); \
616 else \
617 rval = PCLASS::CBNAME(a); \
618 wxPySaveThread(doSave); \
619 return rval; \
620 } \
621 bool CLASS::base_##CBNAME(const wxString& a) { \
622 return PCLASS::CBNAME(a); \
623 }
624
625//---------------------------------------------------------------------------
626
627#define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
628 bool CBNAME(const wxString& a, const wxString& b); \
629 bool base_##CBNAME(const wxString& a, const wxString& b);
630
631
632#define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
633 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
634 bool rval; \
635 bool doSave = wxPyRestoreThread(); \
636 if (m_myInst.findCallback(#CBNAME)) \
637 rval = m_myInst.callCallback(Py_BuildValue("(ss)", \
638 a.c_str(), b.c_str())); \
639 else \
640 rval = PCLASS::CBNAME(a, b); \
641 wxPySaveThread(doSave); \
642 return rval; \
643 } \
644 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
645 return PCLASS::CBNAME(a, b); \
646 }
647
648//---------------------------------------------------------------------------
649
650#define DEC_PYCALLBACK_STRING_(CBNAME) \
651 wxString CBNAME(); \
652 wxString base_##CBNAME();
653
654
655#define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
656 wxString CLASS::CBNAME() { \
657 wxString rval; \
658 bool doSave = wxPyRestoreThread(); \
659 if (m_myInst.findCallback(#CBNAME)) { \
660 PyObject* ro; \
661 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
662 rval = PyString_AsString(PyObject_Str(ro)); \
663 } \
664 else \
665 rval = PCLASS::CBNAME(a); \
666 wxPySaveThread(doSave); \
667 return rval; \
668 } \
669 bool CLASS::base_##CBNAME(const wxString& a) { \
670 return PCLASS::CBNAME(a); \
671 }
672
673//---------------------------------------------------------------------------
674
675#define DEC_PYCALLBACK_STRING__pure(CBNAME) \
676 wxString CBNAME();
677
678
679#define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
680 wxString CLASS::CBNAME() { \
681 wxString rval; \
682 bool doSave = wxPyRestoreThread(); \
683 if (m_myInst.findCallback(#CBNAME)) { \
684 PyObject* ro; \
685 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
686 rval = PyString_AsString(PyObject_Str(ro)); \
687 } \
688 wxPySaveThread(doSave); \
689 return rval; \
690 }
691
692//---------------------------------------------------------------------------
693
694#define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
695 bool CBNAME(const wxHtmlTag& a); \
696
697
698#define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
699 bool CLASS::CBNAME(const wxHtmlTag& a) { \
700 bool rval = false; \
701 bool doSave = wxPyRestoreThread(); \
702 if (m_myInst.findCallback(#CBNAME)) \
703 rval = m_myInst.callCallback(Py_BuildValue("(O)", \
704 wxPyConstructObject((void*)&a,"wxHtmlTag"))); \
705 wxPySaveThread(doSave); \
706 return rval; \
707 }
708
709//---------------------------------------------------------------------------
710
711#define DEC_PYCALLBACK___pure(CBNAME) \
712 void CBNAME(); \
713
714
715#define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
716 void CLASS::CBNAME() { \
717 bool doSave = wxPyRestoreThread(); \
718 if (m_myInst.findCallback(#CBNAME)) \
719 m_myInst.callCallback(Py_BuildValue("()")); \
720 wxPySaveThread(doSave); \
721 }
722
723//---------------------------------------------------------------------------
724
725#define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
726 wxSize CBNAME(); \
727
728
729#define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
730 wxSize CLASS::CBNAME() { \
731 wxSize rval(0,0); \
732 bool doSave = wxPyRestoreThread(); \
733 if (m_myInst.findCallback(#CBNAME)) { \
734 PyObject* ro; \
735 wxSize* ptr; \
736 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
737 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \
738 rval = *ptr; \
739 } \
740 wxPySaveThread(doSave); \
741 return rval; \
742 }
743
744//---------------------------------------------------------------------------
745
746#define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
747 bool CBNAME(wxWindow* a); \
748 bool base_##CBNAME(wxWindow* a);
749
750
751#define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
752 bool CLASS::CBNAME(wxWindow* a) { \
753 bool rval; \
754 bool doSave = wxPyRestoreThread(); \
755 if (m_myInst.findCallback(#CBNAME)) \
756 rval = m_myInst.callCallback(Py_BuildValue("(O)", \
757 wxPyConstructObject((void*)a,"wxWindow"))); \
758 else \
759 rval = PCLASS::CBNAME(a); \
760 wxPySaveThread(doSave); \
761 return rval; \
762 } \
763 bool CLASS::base_##CBNAME(wxWindow* a) { \
764 return PCLASS::CBNAME(a); \
765 }
766
767//---------------------------------------------------------------------------
768
769#define DEC_PYCALLBACK_BOOL_(CBNAME) \
770 bool CBNAME(); \
771 bool base_##CBNAME();
772
773
774#define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
775 bool CLASS::CBNAME() { \
776 bool rval; \
777 bool doSave = wxPyRestoreThread(); \
778 if (m_myInst.findCallback(#CBNAME)) \
779 rval = m_myInst.callCallback(Py_BuildValue("()")); \
780 else \
781 rval = PCLASS::CBNAME(); \
782 wxPySaveThread(doSave); \
783 return rval; \
784 } \
785 bool CLASS::base_##CBNAME() { \
786 return PCLASS::CBNAME(); \
787 }
788
789//---------------------------------------------------------------------------
790//---------------------------------------------------------------------------
791//---------------------------------------------------------------------------
792
793#endif
794
795
796