]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/helpers.h
IRIX compilation fixes
[wxWidgets.git] / utils / 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
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
43 typedef unsigned char byte;
44
45 //----------------------------------------------------------------------
46
47 class wxPyApp: public wxApp
48 {
49 public:
50 wxPyApp();
51 ~wxPyApp();
52 int MainLoop(void);
53 bool OnInit(void);
54 //# void AfterMainLoop(void);
55 };
56
57 extern wxPyApp *wxPythonApp;
58
59 //----------------------------------------------------------------------
60
61 void __wxPreStart();
62 PyObject* __wxStart(PyObject*, PyObject* args);
63
64 extern PyObject* wxPython_dict;
65 PyObject* __wxSetDictionary(PyObject*, PyObject* args);
66
67 void wxPyEventThunker(wxObject*, wxEvent& event);
68
69 HELPEREXPORT PyObject* wxPyConstructObject(void* ptr, const char* className);
70 HELPEREXPORT bool wxPyRestoreThread();
71 HELPEREXPORT void wxPySaveThread(bool doSave);
72 HELPEREXPORT PyObject* wxPy_ConvertList(wxListBase* list, const char* className);
73
74 //----------------------------------------------------------------------
75 // These are helpers used by the typemaps
76
77 HELPEREXPORT byte* byte_LIST_helper(PyObject* source);
78 HELPEREXPORT int* int_LIST_helper(PyObject* source);
79 HELPEREXPORT long* long_LIST_helper(PyObject* source);
80 HELPEREXPORT char** string_LIST_helper(PyObject* source);
81 HELPEREXPORT wxPoint* wxPoint_LIST_helper(PyObject* source);
82 HELPEREXPORT wxBitmap** wxBitmap_LIST_helper(PyObject* source);
83 HELPEREXPORT wxString* wxString_LIST_helper(PyObject* source);
84 HELPEREXPORT wxAcceleratorEntry* wxAcceleratorEntry_LIST_helper(PyObject* source);
85
86 HELPEREXPORT bool wxSize_helper(PyObject* source, wxSize** obj);
87 HELPEREXPORT bool wxPoint_helper(PyObject* source, wxPoint** obj);
88 HELPEREXPORT bool wxRealPoint_helper(PyObject* source, wxRealPoint** obj);
89 HELPEREXPORT bool wxRect_helper(PyObject* source, wxRect** obj);
90
91 //----------------------------------------------------------------------
92
93 #ifndef SWIGCODE
94 extern "C" void SWIG_MakePtr(char *, void *, char *);
95 extern "C" char *SWIG_GetPtr(char *, void **, char *);
96 extern "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.
107 extern wxPoint wxPyDefaultPosition;
108 extern wxSize wxPyDefaultSize;
109 extern wxString wxPyEmptyStr;
110
111 //----------------------------------------------------------------------
112
113 class wxPyCallback : public wxObject {
114 DECLARE_ABSTRACT_CLASS(wxPyCallback);
115 public:
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
140 class wxPyTimer : public wxTimer {
141 public:
142 wxPyTimer(PyObject* callback);
143 ~wxPyTimer();
144
145 void Notify();
146
147 private:
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
166 class HELPEREXPORT wxPyCallbackHelper {
167 public:
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
179 private:
180 PyObject* m_self;
181 PyObject* m_lastFound;
182 };
183
184
185 //---------------------------------------------------------------------------
186 //---------------------------------------------------------------------------
187 // These classes can be derived from in Python and passed through the event
188 // system without loosing anything. They do this by keeping a reference to
189 // themselves and some special case handling in wxPyCallback::EventThunker.
190
191
192 class wxPyEvtSelfRef {
193 public:
194 wxPyEvtSelfRef();
195 ~wxPyEvtSelfRef();
196
197 void SetSelf(PyObject* self, bool clone=FALSE);
198 PyObject* GetSelf() const;
199
200 protected:
201 PyObject* m_self;
202 bool m_cloned;
203 };
204
205
206 class wxPyEvent : public wxEvent, public wxPyEvtSelfRef {
207 DECLARE_DYNAMIC_CLASS(wxPyEvent)
208 public:
209 wxPyEvent(int id=0);
210 ~wxPyEvent();
211
212 void CopyObject(wxObject& dest) const;
213 };
214
215
216 class wxPyCommandEvent : public wxCommandEvent, public wxPyEvtSelfRef {
217 DECLARE_DYNAMIC_CLASS(wxPyCommandEvent)
218 public:
219 wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0);
220 ~wxPyCommandEvent();
221
222 void CopyObject(wxObject& dest) const;
223 };
224
225
226 //---------------------------------------------------------------------------
227 // These macros are used to implement the virtual methods that should
228 // redirect to a Python method if one exists. The names designate the
229 // return type, if any, as well as any parameter types.
230 //---------------------------------------------------------------------------
231
232 #define PYPRIVATE \
233 void _setSelf(PyObject* self, int incref=TRUE) { \
234 m_myInst.setSelf(self, incref); \
235 } \
236 private: wxPyCallbackHelper m_myInst;
237
238 //---------------------------------------------------------------------------
239
240 #define DEC_PYCALLBACK__(CBNAME) \
241 void CBNAME(); \
242 void base_##CBNAME();
243
244
245 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
246 void CLASS::CBNAME() { \
247 bool doSave = wxPyRestoreThread(); \
248 if (m_myInst.findCallback(#CBNAME)) \
249 m_myInst.callCallback(Py_BuildValue("()")); \
250 else \
251 PCLASS::CBNAME(); \
252 wxPySaveThread(doSave); \
253 } \
254 void CLASS::base_##CBNAME() { \
255 PCLASS::CBNAME(); \
256 }
257
258 //---------------------------------------------------------------------------
259
260 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
261 bool CBNAME(int a, int b); \
262 bool base_##CBNAME(int a, int b);
263
264
265 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
266 bool CLASS::CBNAME(int a, int b) { \
267 bool rval; \
268 bool doSave = wxPyRestoreThread(); \
269 if (m_myInst.findCallback(#CBNAME)) \
270 rval = m_myInst.callCallback(Py_BuildValue("(ii)",a,b)); \
271 else \
272 rval = PCLASS::CBNAME(a,b); \
273 wxPySaveThread(doSave); \
274 return rval; \
275 } \
276 bool CLASS::base_##CBNAME(int a, int b) { \
277 return PCLASS::CBNAME(a,b); \
278 }
279
280 //---------------------------------------------------------------------------
281
282 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
283 bool CBNAME(int a); \
284 bool base_##CBNAME(int a);
285
286
287 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
288 bool CLASS::CBNAME(int a) { \
289 bool rval; \
290 bool doSave = wxPyRestoreThread(); \
291 if (m_myInst.findCallback(#CBNAME)) \
292 rval = m_myInst.callCallback(Py_BuildValue("(i)",a)); \
293 else \
294 rval = PCLASS::CBNAME(a); \
295 wxPySaveThread(doSave); \
296 return rval; \
297 } \
298 bool CLASS::base_##CBNAME(int a) { \
299 return PCLASS::CBNAME(a); \
300 }
301
302 //---------------------------------------------------------------------------
303
304 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
305 bool CBNAME(int a);
306
307
308 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
309 bool CLASS::CBNAME(int a) { \
310 bool rval; \
311 bool doSave = wxPyRestoreThread(); \
312 if (m_myInst.findCallback(#CBNAME)) \
313 rval = m_myInst.callCallback(Py_BuildValue("(i)",a)); \
314 else rval = false; \
315 wxPySaveThread(doSave); \
316 return rval; \
317 }
318
319
320 //---------------------------------------------------------------------------
321
322 #define DEC_PYCALLBACK__DC(CBNAME) \
323 void CBNAME(wxDC& a); \
324 void base_##CBNAME(wxDC& a);
325
326
327 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
328 void CLASS::CBNAME(wxDC& a) { \
329 bool doSave = wxPyRestoreThread(); \
330 if (m_myInst.findCallback(#CBNAME)) \
331 m_myInst.callCallback(Py_BuildValue("(O)", \
332 wxPyConstructObject(&a, "wxDC"))); \
333 else \
334 PCLASS::CBNAME(a); \
335 wxPySaveThread(doSave); \
336 } \
337 void CLASS::base_##CBNAME(wxDC& a) { \
338 PCLASS::CBNAME(a); \
339 }
340
341
342
343 //---------------------------------------------------------------------------
344
345 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
346 void CBNAME(wxDC& a, bool b); \
347 void base_##CBNAME(wxDC& a, bool b);
348
349
350 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
351 void CLASS::CBNAME(wxDC& a, bool b) { \
352 bool doSave = wxPyRestoreThread(); \
353 if (m_myInst.findCallback(#CBNAME)) \
354 m_myInst.callCallback(Py_BuildValue("(Oi)", \
355 wxPyConstructObject(&a, "wxDC"), (int)b)); \
356 else \
357 PCLASS::CBNAME(a, b); \
358 wxPySaveThread(doSave); \
359 } \
360 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
361 PCLASS::CBNAME(a, b); \
362 }
363
364 //---------------------------------------------------------------------------
365
366 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
367 void CBNAME(wxDC& a, bool b); \
368 void base_##CBNAME(wxDC& a, bool b);
369
370
371 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
372 void CLASS::CBNAME(wxDC& a, bool b) { \
373 bool doSave = wxPyRestoreThread(); \
374 if (m_myInst.findCallback(#CBNAME)) \
375 m_myInst.callCallback(Py_BuildValue("(Oi)", \
376 wxPyConstructObject(&a, "wxDC"), (int)b)); \
377 else \
378 PCLASS::CBNAME(a, b); \
379 wxPySaveThread(doSave); \
380 } \
381 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
382 PCLASS::CBNAME(a, b); \
383 }
384
385 //---------------------------------------------------------------------------
386
387 #define DEC_PYCALLBACK__2DBL(CBNAME) \
388 void CBNAME(double a, double b); \
389 void base_##CBNAME(double a, double b);
390
391
392 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
393 void CLASS::CBNAME(double a, double b) { \
394 bool doSave = wxPyRestoreThread(); \
395 if (m_myInst.findCallback(#CBNAME)) \
396 m_myInst.callCallback(Py_BuildValue("(dd)",a,b)); \
397 else \
398 PCLASS::CBNAME(a, b); \
399 wxPySaveThread(doSave); \
400 } \
401 void CLASS::base_##CBNAME(double a, double b) { \
402 PCLASS::CBNAME(a, b); \
403 }
404
405 //---------------------------------------------------------------------------
406
407 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
408 void CBNAME(double a, double b, int c, int d); \
409 void base_##CBNAME(double a, double b, int c, int d);
410
411
412 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
413 void CLASS::CBNAME(double a, double b, int c, int d) { \
414 bool doSave = wxPyRestoreThread(); \
415 if (m_myInst.findCallback(#CBNAME)) \
416 m_myInst.callCallback(Py_BuildValue("(ddii)", \
417 a,b,c,d)); \
418 else \
419 PCLASS::CBNAME(a, b, c, d); \
420 wxPySaveThread(doSave); \
421 } \
422 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
423 PCLASS::CBNAME(a, b, c, d); \
424 }
425
426 //---------------------------------------------------------------------------
427
428 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
429 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
430 void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
431
432
433 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
434 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
435 bool doSave = wxPyRestoreThread(); \
436 if (m_myInst.findCallback(#CBNAME)) \
437 m_myInst.callCallback(Py_BuildValue("(Oddddi)", \
438 wxPyConstructObject(&a, "wxDC"), \
439 b, c, d, e, (int)f)); \
440 else \
441 PCLASS::CBNAME(a, b, c, d, e, f); \
442 wxPySaveThread(doSave); \
443 } \
444 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
445 PCLASS::CBNAME(a, b, c, d, e, f); \
446 }
447
448 //---------------------------------------------------------------------------
449
450 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
451 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
452 bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
453
454
455 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
456 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
457 bool doSave = wxPyRestoreThread(); \
458 bool rval; \
459 if (m_myInst.findCallback(#CBNAME)) \
460 rval = m_myInst.callCallback(Py_BuildValue("(Oddddi)", \
461 wxPyConstructObject(&a, "wxDC"), \
462 b, c, d, e, (int)f)); \
463 else \
464 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
465 wxPySaveThread(doSave); \
466 return rval; \
467 } \
468 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
469 return PCLASS::CBNAME(a, b, c, d, e, f); \
470 }
471
472 //---------------------------------------------------------------------------
473
474 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
475 void CBNAME(bool a, double b, double c, int d, int e); \
476 void base_##CBNAME(bool a, double b, double c, int d, int e);
477
478
479 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
480 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
481 bool doSave = wxPyRestoreThread(); \
482 if (m_myInst.findCallback(#CBNAME)) \
483 m_myInst.callCallback(Py_BuildValue("(idii)", \
484 (int)a,b,c,d,e)); \
485 else \
486 PCLASS::CBNAME(a, b, c, d, e); \
487 wxPySaveThread(doSave); \
488 } \
489 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
490 PCLASS::CBNAME(a, b, c, d, e); \
491 }
492
493 //---------------------------------------------------------------------------
494
495 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
496 void CBNAME(wxDC& a, double b, double c, double d, double e); \
497 void base_##CBNAME(wxDC& a, double b, double c, double d, double e);
498
499
500 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
501 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
502 bool doSave = wxPyRestoreThread(); \
503 if (m_myInst.findCallback(#CBNAME)) \
504 m_myInst.callCallback(Py_BuildValue("(Odddd)", \
505 wxPyConstructObject(&a, "wxDC"), \
506 b, c, d, e)); \
507 else \
508 PCLASS::CBNAME(a, b, c, d, e); \
509 wxPySaveThread(doSave); \
510 } \
511 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
512 PCLASS::CBNAME(a, b, c, d, e); \
513 }
514
515 //---------------------------------------------------------------------------
516
517 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
518 void CBNAME(wxDC& a, bool b); \
519 void base_##CBNAME(wxDC& a, bool b);
520
521
522 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
523 void CLASS::CBNAME(wxDC& a, bool b) { \
524 bool doSave = wxPyRestoreThread(); \
525 if (m_myInst.findCallback(#CBNAME)) \
526 m_myInst.callCallback(Py_BuildValue("(Oi)", \
527 wxPyConstructObject(&a, "wxDC"), \
528 (int)b)); \
529 else \
530 PCLASS::CBNAME(a, b); \
531 wxPySaveThread(doSave); \
532 } \
533 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
534 PCLASS::CBNAME(a, b); \
535 }
536
537 //---------------------------------------------------------------------------
538
539 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
540 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
541 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f);
542
543
544 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
545 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
546 int e, int f) { \
547 bool doSave = wxPyRestoreThread(); \
548 if (m_myInst.findCallback(#CBNAME)) \
549 m_myInst.callCallback(Py_BuildValue("(Oiddii)", \
550 wxPyConstructObject(a, "wxPyControlPoint"), \
551 (int)b, c, d, e, f)); \
552 else \
553 PCLASS::CBNAME(a, b, c, d, e, f); \
554 wxPySaveThread(doSave); \
555 } \
556 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
557 int e, int f) { \
558 PCLASS::CBNAME(a, b, c, d, e, f); \
559 }
560
561 //---------------------------------------------------------------------------
562
563 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
564 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
565 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e);
566
567
568 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
569 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
570 bool doSave = wxPyRestoreThread(); \
571 if (m_myInst.findCallback(#CBNAME)) \
572 m_myInst.callCallback(Py_BuildValue("(Oddii)", \
573 wxPyConstructObject(a, "wxPyControlPoint"), \
574 b, c, d, e)); \
575 else \
576 PCLASS::CBNAME(a, b, c, d, e); \
577 wxPySaveThread(doSave); \
578 } \
579 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
580 int d, int e) { \
581 PCLASS::CBNAME(a, b, c, d, e); \
582 }
583
584 //---------------------------------------------------------------------------
585
586 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
587 void CBNAME(double a, double b, int c); \
588 void base_##CBNAME(double a, double b, int c);
589
590
591 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
592 void CLASS::CBNAME(double a, double b, int c) { \
593 bool doSave = wxPyRestoreThread(); \
594 if (m_myInst.findCallback(#CBNAME)) \
595 m_myInst.callCallback(Py_BuildValue("(ddi)", a,b,c)); \
596 else \
597 PCLASS::CBNAME(a, b, c); \
598 wxPySaveThread(doSave); \
599 } \
600 void CLASS::base_##CBNAME(double a, double b, int c) { \
601 PCLASS::CBNAME(a, b, c); \
602 }
603
604 //---------------------------------------------------------------------------
605
606 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
607 void CBNAME(bool a, double b, double c, int d); \
608 void base_##CBNAME(bool a, double b, double c, int d);
609
610
611 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
612 void CLASS::CBNAME(bool a, double b, double c, int d) { \
613 bool doSave = wxPyRestoreThread(); \
614 if (m_myInst.findCallback(#CBNAME)) \
615 m_myInst.callCallback(Py_BuildValue("(iddi)", (int)a,b,c,d)); \
616 else \
617 PCLASS::CBNAME(a, b, c, d); \
618 wxPySaveThread(doSave); \
619 } \
620 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
621 PCLASS::CBNAME(a, b, c, d); \
622 }
623
624 //---------------------------------------------------------------------------
625 //---------------------------------------------------------------------------
626
627 #define DEC_PYCALLBACK__STRING(CBNAME) \
628 void CBNAME(const wxString& a); \
629 void base_##CBNAME(const wxString& a);
630
631
632 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
633 void CLASS::CBNAME(const wxString& a) { \
634 bool doSave = wxPyRestoreThread(); \
635 if (m_myInst.findCallback(#CBNAME)) \
636 m_myInst.callCallback(Py_BuildValue("(s)", a.c_str())); \
637 else \
638 PCLASS::CBNAME(a); \
639 wxPySaveThread(doSave); \
640 } \
641 void CLASS::base_##CBNAME(const wxString& a) { \
642 PCLASS::CBNAME(a); \
643 }
644
645 //---------------------------------------------------------------------------
646
647 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
648 bool CBNAME(const wxString& a); \
649 bool base_##CBNAME(const wxString& a);
650
651
652 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
653 bool CLASS::CBNAME(const wxString& a) { \
654 bool rval; \
655 bool doSave = wxPyRestoreThread(); \
656 if (m_myInst.findCallback(#CBNAME)) \
657 rval = m_myInst.callCallback(Py_BuildValue("(s)", a.c_str())); \
658 else \
659 rval = PCLASS::CBNAME(a); \
660 wxPySaveThread(doSave); \
661 return rval; \
662 } \
663 bool CLASS::base_##CBNAME(const wxString& a) { \
664 return PCLASS::CBNAME(a); \
665 }
666
667 //---------------------------------------------------------------------------
668
669 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
670 bool CBNAME(const wxString& a, const wxString& b); \
671 bool base_##CBNAME(const wxString& a, const wxString& b);
672
673
674 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
675 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
676 bool rval; \
677 bool doSave = wxPyRestoreThread(); \
678 if (m_myInst.findCallback(#CBNAME)) \
679 rval = m_myInst.callCallback(Py_BuildValue("(ss)", \
680 a.c_str(), b.c_str())); \
681 else \
682 rval = PCLASS::CBNAME(a, b); \
683 wxPySaveThread(doSave); \
684 return rval; \
685 } \
686 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
687 return PCLASS::CBNAME(a, b); \
688 }
689
690 //---------------------------------------------------------------------------
691
692 #define DEC_PYCALLBACK_STRING_(CBNAME) \
693 wxString CBNAME(); \
694 wxString base_##CBNAME();
695
696
697 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
698 wxString CLASS::CBNAME() { \
699 wxString rval; \
700 bool doSave = wxPyRestoreThread(); \
701 if (m_myInst.findCallback(#CBNAME)) { \
702 PyObject* ro; \
703 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
704 rval = PyString_AsString(PyObject_Str(ro)); \
705 } \
706 else \
707 rval = PCLASS::CBNAME(); \
708 wxPySaveThread(doSave); \
709 return rval; \
710 } \
711 wxString CLASS::base_##CBNAME() { \
712 return PCLASS::CBNAME(); \
713 }
714
715 //---------------------------------------------------------------------------
716
717 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
718 wxString CBNAME();
719
720
721 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
722 wxString CLASS::CBNAME() { \
723 wxString rval; \
724 bool doSave = wxPyRestoreThread(); \
725 if (m_myInst.findCallback(#CBNAME)) { \
726 PyObject* ro; \
727 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
728 rval = PyString_AsString(PyObject_Str(ro)); \
729 } \
730 wxPySaveThread(doSave); \
731 return rval; \
732 }
733
734 //---------------------------------------------------------------------------
735
736 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
737 bool CBNAME(const wxHtmlTag& a); \
738
739
740 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
741 bool CLASS::CBNAME(const wxHtmlTag& a) { \
742 bool rval = false; \
743 bool doSave = wxPyRestoreThread(); \
744 if (m_myInst.findCallback(#CBNAME)) \
745 rval = m_myInst.callCallback(Py_BuildValue("(O)", \
746 wxPyConstructObject((void*)&a,"wxHtmlTag"))); \
747 wxPySaveThread(doSave); \
748 return rval; \
749 }
750
751 //---------------------------------------------------------------------------
752
753 #define DEC_PYCALLBACK___pure(CBNAME) \
754 void CBNAME(); \
755
756
757 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
758 void CLASS::CBNAME() { \
759 bool doSave = wxPyRestoreThread(); \
760 if (m_myInst.findCallback(#CBNAME)) \
761 m_myInst.callCallback(Py_BuildValue("()")); \
762 wxPySaveThread(doSave); \
763 }
764
765 //---------------------------------------------------------------------------
766
767 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
768 wxSize CBNAME(); \
769
770
771 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
772 wxSize CLASS::CBNAME() { \
773 wxSize rval(0,0); \
774 bool doSave = wxPyRestoreThread(); \
775 if (m_myInst.findCallback(#CBNAME)) { \
776 PyObject* ro; \
777 wxSize* ptr; \
778 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
779 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \
780 rval = *ptr; \
781 } \
782 wxPySaveThread(doSave); \
783 return rval; \
784 }
785
786 //---------------------------------------------------------------------------
787
788 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
789 bool CBNAME(wxWindow* a); \
790 bool base_##CBNAME(wxWindow* a);
791
792
793 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
794 bool CLASS::CBNAME(wxWindow* a) { \
795 bool rval; \
796 bool doSave = wxPyRestoreThread(); \
797 if (m_myInst.findCallback(#CBNAME)) \
798 rval = m_myInst.callCallback(Py_BuildValue("(O)", \
799 wxPyConstructObject((void*)a,"wxWindow"))); \
800 else \
801 rval = PCLASS::CBNAME(a); \
802 wxPySaveThread(doSave); \
803 return rval; \
804 } \
805 bool CLASS::base_##CBNAME(wxWindow* a) { \
806 return PCLASS::CBNAME(a); \
807 }
808
809 //---------------------------------------------------------------------------
810
811 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
812 bool CBNAME(); \
813 bool base_##CBNAME();
814
815
816 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
817 bool CLASS::CBNAME() { \
818 bool rval; \
819 bool doSave = wxPyRestoreThread(); \
820 if (m_myInst.findCallback(#CBNAME)) \
821 rval = m_myInst.callCallback(Py_BuildValue("()")); \
822 else \
823 rval = PCLASS::CBNAME(); \
824 wxPySaveThread(doSave); \
825 return rval; \
826 } \
827 bool CLASS::base_##CBNAME() { \
828 return PCLASS::CBNAME(); \
829 }
830
831 //---------------------------------------------------------------------------
832
833 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
834 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \
835 wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def);
836
837
838 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
839 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
840 bool doSave = wxPyRestoreThread(); \
841 int rval; \
842 if (m_myInst.findCallback(#CBNAME)) \
843 rval = m_myInst.callCallback(Py_BuildValue("(iii)", a,b,c));\
844 else \
845 rval = PCLASS::CBNAME(a, b, c); \
846 wxPySaveThread(doSave); \
847 return (wxDragResult)rval; \
848 } \
849 wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
850 return PCLASS::CBNAME(a, b, c); \
851 }
852
853 //---------------------------------------------------------------------------
854
855 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
856 bool CBNAME(wxDragResult a); \
857 bool base_##CBNAME(wxDragResult a);
858
859
860 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
861 bool CLASS::CBNAME(wxDragResult a) { \
862 bool doSave = wxPyRestoreThread(); \
863 bool rval; \
864 if (m_myInst.findCallback(#CBNAME)) \
865 rval = m_myInst.callCallback(Py_BuildValue("(i)", a)); \
866 else \
867 rval = PCLASS::CBNAME(a); \
868 wxPySaveThread(doSave); \
869 return rval; \
870 } \
871 bool CLASS::base_##CBNAME(wxDragResult a) { \
872 return PCLASS::CBNAME(a); \
873 }
874
875 //---------------------------------------------------------------------------
876
877 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
878 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def);
879
880
881 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
882 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
883 bool doSave = wxPyRestoreThread(); \
884 int rval; \
885 if (m_myInst.findCallback(#CBNAME)) \
886 rval = m_myInst.callCallback(Py_BuildValue("(iii)", a,b,c));\
887 wxPySaveThread(doSave); \
888 return (wxDragResult)rval; \
889 } \
890
891 //---------------------------------------------------------------------------
892
893 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
894 bool CBNAME(int a, int b, const wxString& c);
895
896
897 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
898 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
899 bool rval; \
900 bool doSave = wxPyRestoreThread(); \
901 if (m_myInst.findCallback(#CBNAME)) \
902 rval = m_myInst.callCallback(Py_BuildValue("(iis)",a,b,c.c_str()));\
903 wxPySaveThread(doSave); \
904 return rval; \
905 } \
906
907 //---------------------------------------------------------------------------
908
909 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
910 size_t CBNAME(); \
911 size_t base_##CBNAME();
912
913
914 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
915 size_t CLASS::CBNAME() { \
916 size_t rval; \
917 bool doSave = wxPyRestoreThread(); \
918 if (m_myInst.findCallback(#CBNAME)) \
919 rval = m_myInst.callCallback(Py_BuildValue("()")); \
920 else \
921 rval = PCLASS::CBNAME(); \
922 wxPySaveThread(doSave); \
923 return rval; \
924 } \
925 size_t CLASS::base_##CBNAME() { \
926 return PCLASS::CBNAME(); \
927 }
928
929 //---------------------------------------------------------------------------
930
931 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
932 wxDataFormat CBNAME(); \
933 wxDataFormat base_##CBNAME();
934
935
936 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
937 wxDataFormat CLASS::CBNAME(size_t a) { \
938 wxDataFormat rval; \
939 bool doSave = wxPyRestoreThread(); \
940 if (m_myInst.findCallback(#CBNAME)) { \
941 PyObject* ro; \
942 wxDataFormat* ptr; \
943 ro = m_myInst.callCallbackObj(Py_BuildValue("(i)", a)); \
944 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxDataFormat_p")) \
945 rval = *ptr; \
946 } \
947 else \
948 rval = PCLASS::CBNAME(a); \
949 wxPySaveThread(doSave); \
950 return rval; \
951 } \
952 wxDataFormat CLASS::base_##CBNAME(size_t a) { \
953 return PCLASS::CBNAME(a); \
954 }
955
956 //---------------------------------------------------------------------------
957 //---------------------------------------------------------------------------
958 //---------------------------------------------------------------------------
959
960 #endif
961
962
963
964