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