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