]>
Commit | Line | Data |
---|---|---|
b1462dfa | 1 | //////////////////////////////////////////////////////////////////////////// |
7bf85405 | 2 | // Name: helpers.h |
a2426843 | 3 | // Purpose: Helper functions/classes for the wxPython extension module |
7bf85405 RD |
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> | |
1e4a197e | 17 | #include <wx/geometry.h> |
cf694132 | 18 | |
8b9a4190 RD |
19 | //--------------------------------------------------------------------------- |
20 | #ifdef __WXMAC__ // avoid a bug in Carbon headers | |
21 | #define scalb scalbn | |
22 | #endif | |
efc5f224 RD |
23 | //--------------------------------------------------------------------------- |
24 | ||
2f90df85 RD |
25 | typedef unsigned char byte; |
26 | ||
1e4a197e | 27 | void __wxPreStart(PyObject*); |
7bf85405 | 28 | PyObject* __wxStart(PyObject*, PyObject* args); |
7ff49f0c | 29 | void __wxCleanup(); |
7bf85405 | 30 | |
9416aa89 | 31 | //extern PyObject* wxPython_dict; |
7bf85405 RD |
32 | PyObject* __wxSetDictionary(PyObject*, PyObject* args); |
33 | ||
7bf85405 | 34 | void wxPyEventThunker(wxObject*, wxEvent& event); |
efc5f224 | 35 | |
1e7ecb7b | 36 | PyObject* wxPyConstructObject(void* ptr, |
a541c325 | 37 | const wxString& className, |
1e7ecb7b | 38 | int setThisOwn=0); |
9416aa89 | 39 | PyObject* wxPyConstructObject(void* ptr, |
a541c325 | 40 | const wxString& className, |
9416aa89 RD |
41 | PyObject* klass, |
42 | int setThisOwn=0); | |
a541c325 RD |
43 | |
44 | PyObject* wx2PyString(const wxString& src); | |
45 | wxString Py2wxString(PyObject* source); | |
46 | ||
47 | PyObject* wxPyClassExists(const wxString& className); | |
48 | PyObject* wxPyMake_wxObject(wxObject* source, bool checkEvtHandler=TRUE); | |
49 | PyObject* wxPyMake_wxSizer(wxSizer* source); | |
50 | void wxPyPtrTypeMap_Add(const char* commonName, const char* ptrName); | |
9416aa89 | 51 | |
1e7ecb7b | 52 | PyObject* wxPy_ConvertList(wxListBase* list, const char* className); |
a541c325 | 53 | long wxPyGetWinHandle(wxWindow* win); |
9b3d3bc4 | 54 | |
dd116e73 RD |
55 | void wxPy_ReinitStockObjects(); |
56 | ||
57 | ||
19a97bd6 RD |
58 | //---------------------------------------------------------------------- |
59 | ||
4268f798 RD |
60 | // if we want to handle threads and Python threads are available... |
61 | #if defined(WXP_USE_THREAD) && defined(WITH_THREAD) | |
62 | #define WXP_WITH_THREAD | |
63 | #else // no Python threads... | |
64 | #undef WXP_WITH_THREAD | |
65 | #endif | |
19a97bd6 RD |
66 | |
67 | ||
4268f798 RD |
68 | // For Python --> C++ |
69 | PyThreadState* wxPyBeginAllowThreads(); | |
70 | void wxPyEndAllowThreads(PyThreadState* state); | |
9b3d3bc4 | 71 | |
4268f798 RD |
72 | // For C++ --> Python |
73 | void wxPyBeginBlockThreads(); | |
74 | void wxPyEndBlockThreads(); | |
9b3d3bc4 | 75 | |
1e4a197e RD |
76 | #define wxPyBLOCK_THREADS(stmt) wxPyBeginBlockThreads(); stmt; wxPyEndBlockThreads() |
77 | ||
7bf85405 | 78 | //---------------------------------------------------------------------- |
2f90df85 RD |
79 | // These are helpers used by the typemaps |
80 | ||
c8bc7bb8 RD |
81 | wxString* wxString_in_helper(PyObject* source); |
82 | ||
1e7ecb7b RD |
83 | byte* byte_LIST_helper(PyObject* source); |
84 | int* int_LIST_helper(PyObject* source); | |
85 | long* long_LIST_helper(PyObject* source); | |
86 | char** string_LIST_helper(PyObject* source); | |
e0672e2f | 87 | wxPoint* wxPoint_LIST_helper(PyObject* source, int* npoints); |
1e7ecb7b RD |
88 | wxBitmap** wxBitmap_LIST_helper(PyObject* source); |
89 | wxString* wxString_LIST_helper(PyObject* source); | |
90 | wxAcceleratorEntry* wxAcceleratorEntry_LIST_helper(PyObject* source); | |
9d37f964 | 91 | wxPen** wxPen_LIST_helper(PyObject* source); |
1e7ecb7b RD |
92 | |
93 | bool wxSize_helper(PyObject* source, wxSize** obj); | |
94 | bool wxPoint_helper(PyObject* source, wxPoint** obj); | |
95 | bool wxRealPoint_helper(PyObject* source, wxRealPoint** obj); | |
96 | bool wxRect_helper(PyObject* source, wxRect** obj); | |
97 | bool wxColour_helper(PyObject* source, wxColour** obj); | |
7bf85405 | 98 | |
1e4a197e RD |
99 | bool wxPoint2DDouble_helper(PyObject* source, wxPoint2DDouble** obj); |
100 | ||
101 | ||
4acff284 RD |
102 | //---------------------------------------------------------------------- |
103 | // Other helpful stuff | |
104 | ||
9d37f964 RD |
105 | #if PYTHON_API_VERSION < 1009 |
106 | #define PySequence_Fast_GET_ITEM(o, i) \ | |
107 | (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i)) | |
108 | #endif | |
109 | ||
1e4a197e RD |
110 | bool wxPy2int_seq_helper(PyObject* source, int* i1, int* i2); |
111 | bool wxPy4int_seq_helper(PyObject* source, int* i1, int* i2, int* i3, int* i4); | |
9d37f964 RD |
112 | |
113 | ||
7b7ac0ab | 114 | PyObject* wxArrayString2PyList_helper(const wxArrayString& arr); |
293a0a86 | 115 | PyObject* wxArrayInt2PyList_helper(const wxArrayInt& arr); |
b37c7e1d | 116 | |
4acff284 RD |
117 | #define RETURN_NONE() { Py_INCREF(Py_None); return Py_None; } |
118 | #define DECLARE_DEF_STRING(name) static const wxString wxPy##name(wx##name) | |
119 | #define DECLARE_DEF_STRING2(name,val) static const wxString wxPy##name(val) | |
b37c7e1d | 120 | |
1e4a197e RD |
121 | //---------------------------------------------------------------------- |
122 | // functions used by the DrawXXXList enhancements added to wxDC | |
123 | ||
124 | typedef bool (*wxPyDrawListOp_t)(wxDC& dc, PyObject* coords); | |
125 | PyObject* wxPyDrawXXXList(wxDC& dc, wxPyDrawListOp_t doDraw, | |
126 | PyObject* pyCoords, PyObject* pyPens, PyObject* pyBrushes); | |
127 | bool wxPyDrawXXXPoint(wxDC& dc, PyObject* coords); | |
128 | bool wxPyDrawXXXLine(wxDC& dc, PyObject* coords); | |
129 | bool wxPyDrawXXXRectangle(wxDC& dc, PyObject* coords); | |
130 | bool wxPyDrawXXXEllipse(wxDC& dc, PyObject* coords); | |
131 | bool wxPyDrawXXXPolygon(wxDC& dc, PyObject* coords); | |
132 | ||
133 | PyObject* wxPyDrawTextList(wxDC& dc, PyObject* textList, PyObject* pyPoints, | |
134 | PyObject* foregroundList, PyObject* backgroundList); | |
135 | ||
2f90df85 | 136 | //---------------------------------------------------------------------- |
7bf85405 RD |
137 | |
138 | #ifndef SWIGCODE | |
139 | extern "C" void SWIG_MakePtr(char *, void *, char *); | |
140 | extern "C" char *SWIG_GetPtr(char *, void **, char *); | |
d559219f | 141 | extern "C" char *SWIG_GetPtrObj(PyObject *obj, void **ptr, char *type); |
7bf85405 RD |
142 | #endif |
143 | ||
144 | ||
145 | #ifdef _MSC_VER | |
146 | # pragma warning(disable:4800) | |
f6bcfd97 | 147 | # pragma warning(disable:4190) |
7bf85405 RD |
148 | #endif |
149 | ||
7bf85405 RD |
150 | //---------------------------------------------------------------------- |
151 | ||
152 | class wxPyCallback : public wxObject { | |
2f90df85 | 153 | DECLARE_ABSTRACT_CLASS(wxPyCallback); |
7bf85405 | 154 | public: |
cf694132 | 155 | wxPyCallback(PyObject* func); |
2f90df85 | 156 | wxPyCallback(const wxPyCallback& other); |
cf694132 | 157 | ~wxPyCallback(); |
7bf85405 RD |
158 | |
159 | void EventThunker(wxEvent& event); | |
160 | ||
161 | PyObject* m_func; | |
162 | }; | |
163 | ||
7bf85405 RD |
164 | //--------------------------------------------------------------------------- |
165 | ||
166 | class wxPyTimer : public wxTimer { | |
167 | public: | |
168 | wxPyTimer(PyObject* callback); | |
169 | ~wxPyTimer(); | |
170 | ||
171 | void Notify(); | |
172 | ||
173 | private: | |
174 | PyObject* func; | |
175 | }; | |
176 | ||
cf694132 | 177 | //--------------------------------------------------------------------------- |
65dd82cb | 178 | //--------------------------------------------------------------------------- |
9b3d3bc4 RD |
179 | // These Event classes can be derived from in Python and passed through the |
180 | // event system without loosing anything. They do this by keeping a reference | |
181 | // to themselves and some special case handling in wxPyCallback::EventThunker. | |
65dd82cb RD |
182 | |
183 | ||
e19b7164 | 184 | class wxPyEvtSelfRef { |
65dd82cb | 185 | public: |
e19b7164 RD |
186 | wxPyEvtSelfRef(); |
187 | ~wxPyEvtSelfRef(); | |
65dd82cb RD |
188 | |
189 | void SetSelf(PyObject* self, bool clone=FALSE); | |
190 | PyObject* GetSelf() const; | |
3734a866 | 191 | bool GetCloned() const { return m_cloned; } |
65dd82cb RD |
192 | |
193 | protected: | |
194 | PyObject* m_self; | |
195 | bool m_cloned; | |
196 | }; | |
197 | ||
198 | ||
e19b7164 | 199 | class wxPyEvent : public wxEvent, public wxPyEvtSelfRef { |
07b2e1cd | 200 | DECLARE_ABSTRACT_CLASS(wxPyEvent) |
65dd82cb | 201 | public: |
3ef86e32 | 202 | wxPyEvent(int winid=0, wxEventType commandType = wxEVT_NULL); |
07b2e1cd | 203 | wxPyEvent(const wxPyEvent& evt); |
65dd82cb RD |
204 | ~wxPyEvent(); |
205 | ||
07b2e1cd | 206 | virtual wxEvent* Clone() const { return new wxPyEvent(*this); } |
65dd82cb RD |
207 | }; |
208 | ||
209 | ||
e19b7164 | 210 | class wxPyCommandEvent : public wxCommandEvent, public wxPyEvtSelfRef { |
07b2e1cd | 211 | DECLARE_ABSTRACT_CLASS(wxPyCommandEvent) |
65dd82cb RD |
212 | public: |
213 | wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0); | |
07b2e1cd | 214 | wxPyCommandEvent(const wxPyCommandEvent& evt); |
65dd82cb RD |
215 | ~wxPyCommandEvent(); |
216 | ||
07b2e1cd | 217 | virtual wxEvent* Clone() const { return new wxPyCommandEvent(*this); } |
65dd82cb RD |
218 | }; |
219 | ||
bb0054cd | 220 | |
4acff284 RD |
221 | |
222 | //---------------------------------------------------------------------- | |
223 | // Forward decalre a few things used in the exported API | |
224 | class wxPyClientData; | |
225 | class wxPyUserData; | |
226 | class wxPyOORClientData; | |
249a57f4 | 227 | class wxPyCBInputStream; |
4acff284 RD |
228 | |
229 | void wxPyClientData_dtor(wxPyClientData* self); | |
230 | void wxPyUserData_dtor(wxPyUserData* self); | |
231 | void wxPyOORClientData_dtor(wxPyOORClientData* self); | |
249a57f4 | 232 | wxPyCBInputStream* wxPyCBInputStream_create(PyObject *py, bool block); |
4acff284 RD |
233 | |
234 | ||
1e7ecb7b RD |
235 | //--------------------------------------------------------------------------- |
236 | // Export a C API in a struct. Other modules will be able to load this from | |
237 | // the wxc module and will then have safe access to these functions, even if | |
238 | // in another shared library. | |
239 | ||
240 | class wxPyCallbackHelper; | |
241 | ||
bc5f2236 RD |
242 | |
243 | // Make SunCC happy and make typedef's for these that are extern "C" | |
244 | typedef void (*p_SWIG_MakePtr_t)(char*, void*, char*); | |
245 | typedef char* (*p_SWIG_GetPtr_t)(char*, void**, char*); | |
246 | typedef char* (*p_SWIG_GetPtrObj_t)(PyObject*, void**, char*); | |
247 | typedef void (*p_SWIG_RegisterMapping_t)(char*, char*, void *(*cast)(void *)); | |
248 | typedef void (*p_SWIG_addvarlink_t)(PyObject*, char*, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)); | |
249 | typedef PyObject* (*p_SWIG_newvarlink_t)(void); | |
250 | ||
251 | ||
1e7ecb7b RD |
252 | struct wxPyCoreAPI { |
253 | ||
bc5f2236 RD |
254 | p_SWIG_MakePtr_t p_SWIG_MakePtr; |
255 | p_SWIG_GetPtr_t p_SWIG_GetPtr; | |
256 | p_SWIG_GetPtrObj_t p_SWIG_GetPtrObj; | |
257 | p_SWIG_RegisterMapping_t p_SWIG_RegisterMapping; | |
258 | p_SWIG_addvarlink_t p_SWIG_addvarlink; | |
259 | p_SWIG_newvarlink_t p_SWIG_newvarlink; | |
1e7ecb7b | 260 | |
4268f798 RD |
261 | PyThreadState* (*p_wxPyBeginAllowThreads)(); |
262 | void (*p_wxPyEndAllowThreads)(PyThreadState* state); | |
263 | void (*p_wxPyBeginBlockThreads)(); | |
264 | void (*p_wxPyEndBlockThreads)(); | |
19a97bd6 | 265 | |
a541c325 | 266 | PyObject* (*p_wxPyConstructObject)(void *, const wxString&, int); |
1e7ecb7b RD |
267 | PyObject* (*p_wxPy_ConvertList)(wxListBase* list, const char* className); |
268 | ||
c8bc7bb8 | 269 | wxString* (*p_wxString_in_helper)(PyObject* source); |
a541c325 RD |
270 | wxString (*p_Py2wxString)(PyObject* source); |
271 | PyObject* (*p_wx2PyString)(const wxString& src); | |
c8bc7bb8 | 272 | |
1e7ecb7b RD |
273 | byte* (*p_byte_LIST_helper)(PyObject* source); |
274 | int* (*p_int_LIST_helper)(PyObject* source); | |
275 | long* (*p_long_LIST_helper)(PyObject* source); | |
276 | char** (*p_string_LIST_helper)(PyObject* source); | |
e0672e2f | 277 | wxPoint* (*p_wxPoint_LIST_helper)(PyObject* source, int* npoints); |
1e7ecb7b RD |
278 | wxBitmap** (*p_wxBitmap_LIST_helper)(PyObject* source); |
279 | wxString* (*p_wxString_LIST_helper)(PyObject* source); | |
280 | wxAcceleratorEntry* (*p_wxAcceleratorEntry_LIST_helper)(PyObject* source); | |
281 | ||
282 | bool (*p_wxSize_helper)(PyObject* source, wxSize** obj); | |
283 | bool (*p_wxPoint_helper)(PyObject* source, wxPoint** obj); | |
284 | bool (*p_wxRealPoint_helper)(PyObject* source, wxRealPoint** obj); | |
285 | bool (*p_wxRect_helper)(PyObject* source, wxRect** obj); | |
286 | bool (*p_wxColour_helper)(PyObject* source, wxColour** obj); | |
1e4a197e | 287 | bool (*p_wxPoint2DDouble_helper)(PyObject* source, wxPoint2DDouble** obj); |
1e7ecb7b | 288 | |
0122b7e3 | 289 | void (*p_wxPyCBH_setCallbackInfo)(wxPyCallbackHelper& cbh, PyObject* self, PyObject* klass, int incref); |
1e7ecb7b RD |
290 | bool (*p_wxPyCBH_findCallback)(const wxPyCallbackHelper& cbh, const char* name); |
291 | int (*p_wxPyCBH_callCallback)(const wxPyCallbackHelper& cbh, PyObject* argTuple); | |
292 | PyObject* (*p_wxPyCBH_callCallbackObj)(const wxPyCallbackHelper& cbh, PyObject* argTuple); | |
293 | void (*p_wxPyCBH_delete)(wxPyCallbackHelper* cbh); | |
294 | ||
a541c325 | 295 | PyObject* (*p_wxPyClassExists)(const wxString& className); |
2f4e9287 RD |
296 | PyObject* (*p_wxPyMake_wxObject)(wxObject* source, bool checkEvtHandler); |
297 | PyObject* (*p_wxPyMake_wxSizer)(wxSizer* source); | |
9416aa89 | 298 | void (*p_wxPyPtrTypeMap_Add)(const char* commonName, const char* ptrName); |
7b7ac0ab | 299 | PyObject* (*p_wxArrayString2PyList_helper)(const wxArrayString& arr); |
293a0a86 | 300 | PyObject* (*p_wxArrayInt2PyList_helper)(const wxArrayInt& arr); |
4acff284 RD |
301 | |
302 | void (*p_wxPyClientData_dtor)(wxPyClientData*); | |
303 | void (*p_wxPyUserData_dtor)(wxPyUserData*); | |
304 | void (*p_wxPyOORClientData_dtor)(wxPyOORClientData*); | |
249a57f4 RD |
305 | |
306 | wxPyCBInputStream* (*p_wxPyCBInputStream_create)(PyObject *py, bool block); | |
307 | ||
4acff284 RD |
308 | }; |
309 | ||
310 | #ifdef wxPyUSE_EXPORT | |
a2426843 RD |
311 | // Notice that this is static, not extern. This is by design, each module |
312 | // needs one, but doesn't have to use it. | |
313 | static wxPyCoreAPI* wxPyCoreAPIPtr = NULL; | |
4acff284 RD |
314 | #endif |
315 | ||
316 | ||
317 | //--------------------------------------------------------------------------- | |
318 | ||
319 | ||
320 | class wxPyUserData : public wxObject { | |
321 | public: | |
322 | wxPyUserData(PyObject* obj) { | |
323 | m_obj = obj; | |
324 | Py_INCREF(m_obj); | |
325 | } | |
326 | ||
327 | ~wxPyUserData() { | |
328 | #ifdef wxPyUSE_EXPORT | |
329 | wxPyCoreAPIPtr->p_wxPyUserData_dtor(this); | |
330 | #else | |
331 | wxPyUserData_dtor(this); | |
332 | #endif | |
333 | } | |
334 | PyObject* m_obj; | |
335 | }; | |
336 | ||
337 | ||
338 | class wxPyClientData : public wxClientData { | |
339 | public: | |
340 | wxPyClientData(PyObject* obj) { | |
341 | m_obj = obj; | |
342 | Py_INCREF(m_obj); | |
343 | } | |
344 | ||
345 | ~wxPyClientData() { | |
346 | #ifdef wxPyUSE_EXPORT | |
347 | wxPyCoreAPIPtr->p_wxPyClientData_dtor(this); | |
348 | #else | |
349 | wxPyClientData_dtor(this); | |
350 | #endif | |
351 | } | |
352 | PyObject* m_obj; | |
1e7ecb7b RD |
353 | }; |
354 | ||
4acff284 RD |
355 | |
356 | class wxPyOORClientData : public wxPyClientData { | |
357 | public: | |
358 | wxPyOORClientData(PyObject* obj) | |
359 | : wxPyClientData(obj) {} | |
360 | ||
361 | ~wxPyOORClientData() { | |
1e7ecb7b | 362 | #ifdef wxPyUSE_EXPORT |
4acff284 RD |
363 | wxPyCoreAPIPtr->p_wxPyOORClientData_dtor(this); |
364 | #else | |
365 | wxPyOORClientData_dtor(this); | |
1e7ecb7b | 366 | #endif |
4acff284 RD |
367 | } |
368 | }; | |
1e7ecb7b RD |
369 | |
370 | //--------------------------------------------------------------------------- | |
371 | // This class holds an instance of a Python Shadow Class object and assists | |
372 | // with looking up and invoking Python callback methods from C++ virtual | |
373 | // method redirections. For all classes which have virtuals which should be | |
374 | // overridable in wxPython, a new subclass is created that contains a | |
375 | // wxPyCallbackHelper. | |
376 | // | |
377 | ||
378 | class wxPyCallbackHelper { | |
379 | public: | |
380 | wxPyCallbackHelper(const wxPyCallbackHelper& other); | |
381 | ||
382 | wxPyCallbackHelper() { | |
383 | m_class = NULL; | |
384 | m_self = NULL; | |
385 | m_lastFound = NULL; | |
386 | m_incRef = FALSE; | |
387 | } | |
388 | ||
389 | ~wxPyCallbackHelper() { | |
390 | #ifdef wxPyUSE_EXPORT | |
391 | wxPyCoreAPIPtr->p_wxPyCBH_delete(this); | |
392 | #else | |
393 | wxPyCBH_delete(this); | |
394 | #endif | |
395 | } | |
396 | ||
397 | void setSelf(PyObject* self, PyObject* klass, int incref=TRUE); | |
398 | bool findCallback(const char* name) const; | |
399 | int callCallback(PyObject* argTuple) const; | |
400 | PyObject* callCallbackObj(PyObject* argTuple) const; | |
401 | ||
402 | private: | |
403 | PyObject* m_self; | |
404 | PyObject* m_class; | |
405 | PyObject* m_lastFound; | |
406 | int m_incRef; | |
407 | ||
408 | friend void wxPyCBH_delete(wxPyCallbackHelper* cbh); | |
409 | }; | |
410 | ||
411 | ||
0122b7e3 | 412 | void wxPyCBH_setCallbackInfo(wxPyCallbackHelper& cbh, PyObject* self, PyObject* klass, int incref); |
1e7ecb7b RD |
413 | bool wxPyCBH_findCallback(const wxPyCallbackHelper& cbh, const char* name); |
414 | int wxPyCBH_callCallback(const wxPyCallbackHelper& cbh, PyObject* argTuple); | |
415 | PyObject* wxPyCBH_callCallbackObj(const wxPyCallbackHelper& cbh, PyObject* argTuple); | |
416 | void wxPyCBH_delete(wxPyCallbackHelper* cbh); | |
417 | ||
418 | ||
419 | ||
900d9886 | 420 | |
bb0054cd RD |
421 | //--------------------------------------------------------------------------- |
422 | ||
1e4a197e RD |
423 | // This is used in C++ classes that need to be able to make callback to |
424 | // "overloaded" python methods | |
425 | ||
426 | #define PYPRIVATE \ | |
0122b7e3 RD |
427 | void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \ |
428 | wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \ | |
1e4a197e | 429 | } \ |
c368d904 | 430 | private: wxPyCallbackHelper m_myInst |
efc5f224 | 431 | |
1e4a197e RD |
432 | |
433 | //--------------------------------------------------------------------------- | |
434 | ||
435 | enum { | |
436 | wxPYAPP_ASSERT_SUPPRESS = 1, | |
437 | wxPYAPP_ASSERT_EXCEPTION = 2, | |
438 | wxPYAPP_ASSERT_DIALOG = 4, | |
439 | wxPYAPP_ASSERT_LOG = 8 | |
440 | }; | |
441 | ||
442 | class wxPyApp: public wxApp | |
443 | { | |
444 | DECLARE_ABSTRACT_CLASS(wxPyApp); | |
445 | ||
446 | public: | |
447 | wxPyApp(); | |
448 | ~wxPyApp(); | |
449 | bool OnInit(); | |
450 | int MainLoop(); | |
451 | ||
452 | int GetAssertMode() { return m_assertMode; } | |
453 | void SetAssertMode(int mode) { m_assertMode = mode; } | |
454 | ||
455 | virtual bool OnInitGui(); | |
456 | virtual int OnExit(); | |
457 | #ifdef __WXDEBUG__ | |
458 | virtual void OnAssert(const wxChar *file, | |
459 | int line, | |
460 | const wxChar *cond, | |
461 | const wxChar *msg); | |
462 | #endif | |
463 | // virtual int FilterEvent(wxEvent& event); // This one too???? | |
464 | ||
465 | ||
1e4a197e RD |
466 | static bool GetMacSupportPCMenuShortcuts(); |
467 | static long GetMacAboutMenuItemId(); | |
468 | static long GetMacPreferencesMenuItemId(); | |
469 | static long GetMacExitMenuItemId(); | |
470 | static wxString GetMacHelpMenuTitleName(); | |
471 | ||
1e4a197e RD |
472 | static void SetMacSupportPCMenuShortcuts(bool val); |
473 | static void SetMacAboutMenuItemId(long val); | |
474 | static void SetMacPreferencesMenuItemId(long val); | |
475 | static void SetMacExitMenuItemId(long val); | |
476 | static void SetMacHelpMenuTitleName(const wxString& val); | |
477 | ||
478 | ||
479 | PYPRIVATE; | |
480 | int m_assertMode; | |
481 | }; | |
482 | ||
483 | extern wxPyApp *wxPythonApp; | |
484 | ||
485 | ||
486 | //---------------------------------------------------------------------- | |
487 | // These macros are used to implement the virtual methods that should | |
488 | // redirect to a Python method if one exists. The names designate the | |
489 | // return type, if any, as well as any parameter types. | |
efc5f224 RD |
490 | //--------------------------------------------------------------------------- |
491 | ||
d559219f RD |
492 | #define DEC_PYCALLBACK__(CBNAME) \ |
493 | void CBNAME(); \ | |
1fded56b | 494 | void base_##CBNAME() |
d559219f RD |
495 | |
496 | ||
19a97bd6 RD |
497 | #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \ |
498 | void CLASS::CBNAME() { \ | |
499 | bool found; \ | |
1e4a197e | 500 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
501 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
502 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ | |
1e4a197e | 503 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
504 | if (! found) \ |
505 | PCLASS::CBNAME(); \ | |
506 | } \ | |
507 | void CLASS::base_##CBNAME() { \ | |
508 | PCLASS::CBNAME(); \ | |
d559219f RD |
509 | } |
510 | ||
511 | //--------------------------------------------------------------------------- | |
512 | ||
513 | #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \ | |
514 | bool CBNAME(int a, int b); \ | |
1fded56b | 515 | bool base_##CBNAME(int a, int b) |
d559219f RD |
516 | |
517 | ||
518 | #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \ | |
519 | bool CLASS::CBNAME(int a, int b) { \ | |
059a841c | 520 | bool rval=FALSE, found; \ |
4268f798 | 521 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 522 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
1e7ecb7b | 523 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \ |
4268f798 | 524 | wxPyEndBlockThreads(); \ |
19a97bd6 | 525 | if (! found) \ |
d559219f | 526 | rval = PCLASS::CBNAME(a,b); \ |
d559219f | 527 | return rval; \ |
bb0054cd | 528 | } \ |
d559219f | 529 | bool CLASS::base_##CBNAME(int a, int b) { \ |
bb0054cd RD |
530 | return PCLASS::CBNAME(a,b); \ |
531 | } | |
532 | ||
533 | //--------------------------------------------------------------------------- | |
534 | ||
1fded56b RD |
535 | #define DEC_PYCALLBACK_VOID_(CBNAME) \ |
536 | void CBNAME(); \ | |
537 | void base_##CBNAME() | |
538 | ||
539 | ||
540 | #define IMP_PYCALLBACK_VOID_(CLASS, PCLASS, CBNAME) \ | |
541 | void CLASS::CBNAME() { \ | |
542 | bool found; \ | |
543 | wxPyBeginBlockThreads(); \ | |
544 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
545 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ | |
546 | wxPyEndBlockThreads(); \ | |
547 | if (! found) \ | |
548 | PCLASS::CBNAME(); \ | |
549 | } \ | |
550 | void CLASS::base_##CBNAME() { \ | |
551 | PCLASS::CBNAME(); \ | |
552 | } | |
553 | ||
554 | //--------------------------------------------------------------------------- | |
555 | ||
c368d904 RD |
556 | #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \ |
557 | void CBNAME(int a, int b); \ | |
1fded56b | 558 | void base_##CBNAME(int a, int b) |
c368d904 RD |
559 | |
560 | ||
561 | #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \ | |
562 | void CLASS::CBNAME(int a, int b) { \ | |
19a97bd6 | 563 | bool found; \ |
b0e5c039 | 564 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
565 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
566 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \ | |
b0e5c039 | 567 | wxPyEndBlockThreads(); \ |
19a97bd6 | 568 | if (! found) \ |
c368d904 | 569 | PCLASS::CBNAME(a,b); \ |
c368d904 RD |
570 | } \ |
571 | void CLASS::base_##CBNAME(int a, int b) { \ | |
572 | PCLASS::CBNAME(a,b); \ | |
573 | } | |
574 | ||
575 | //--------------------------------------------------------------------------- | |
576 | ||
1fded56b RD |
577 | #define DEC_PYCALLBACK_VOID_INT(CBNAME) \ |
578 | void CBNAME(int a); \ | |
579 | void base_##CBNAME(int a) | |
580 | ||
581 | ||
582 | #define IMP_PYCALLBACK_VOID_INT(CLASS, PCLASS, CBNAME) \ | |
583 | void CLASS::CBNAME(int a) { \ | |
584 | bool found; \ | |
585 | wxPyBeginBlockThreads(); \ | |
586 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
587 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \ | |
588 | wxPyEndBlockThreads(); \ | |
589 | if (! found) \ | |
590 | PCLASS::CBNAME(a); \ | |
591 | } \ | |
592 | void CLASS::base_##CBNAME(int a) { \ | |
593 | PCLASS::CBNAME(a); \ | |
594 | } | |
595 | ||
596 | //--------------------------------------------------------------------------- | |
597 | ||
b0e5c039 RD |
598 | #define DEC_PYCALLBACK_VOID_INT4(CBNAME) \ |
599 | void CBNAME(int a, int b, int c, int d); \ | |
1fded56b | 600 | void base_##CBNAME(int a, int b, int c, int d) |
b0e5c039 RD |
601 | |
602 | ||
603 | #define IMP_PYCALLBACK_VOID_INT4(CLASS, PCLASS, CBNAME) \ | |
604 | void CLASS::CBNAME(int a, int b, int c, int d) { \ | |
605 | bool found; \ | |
606 | wxPyBeginBlockThreads(); \ | |
607 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
608 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiii)",a,b,c,d)); \ | |
609 | wxPyEndBlockThreads(); \ | |
610 | if (! found) \ | |
611 | PCLASS::CBNAME(a,b,c,d); \ | |
612 | } \ | |
613 | void CLASS::base_##CBNAME(int a, int b, int c, int d) { \ | |
614 | PCLASS::CBNAME(a,b,c,d); \ | |
615 | } | |
616 | ||
617 | //--------------------------------------------------------------------------- | |
618 | #define DEC_PYCALLBACK_VOID_INT5(CBNAME) \ | |
619 | void CBNAME(int a, int b, int c, int d, int e); \ | |
1fded56b | 620 | void base_##CBNAME(int a, int b, int c, int d, int e) |
b0e5c039 RD |
621 | |
622 | ||
623 | #define IMP_PYCALLBACK_VOID_INT5(CLASS, PCLASS, CBNAME) \ | |
624 | void CLASS::CBNAME(int a, int b, int c, int d, int e) { \ | |
625 | bool found; \ | |
626 | wxPyBeginBlockThreads(); \ | |
627 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
628 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiiii)",a,b,c,d,e)); \ | |
629 | wxPyEndBlockThreads(); \ | |
630 | if (! found) \ | |
631 | PCLASS::CBNAME(a,b,c,d,e); \ | |
632 | } \ | |
633 | void CLASS::base_##CBNAME(int a, int b, int c, int d, int e) { \ | |
634 | PCLASS::CBNAME(a,b,c,d,e); \ | |
635 | } | |
636 | ||
637 | //--------------------------------------------------------------------------- | |
638 | ||
639 | #define DEC_PYCALLBACK_VOID_INTPINTP_const(CBNAME) \ | |
640 | void CBNAME(int* a, int* b) const; \ | |
1fded56b | 641 | void base_##CBNAME(int* a, int* b) const |
b0e5c039 RD |
642 | |
643 | ||
644 | #define IMP_PYCALLBACK_VOID_INTPINTP_const(CLASS, PCLASS, CBNAME) \ | |
645 | void CLASS::CBNAME(int* a, int* b) const { \ | |
646 | const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \ | |
647 | bool found; \ | |
648 | wxPyBeginBlockThreads(); \ | |
649 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
650 | PyObject* ro; \ | |
651 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \ | |
652 | if (ro) { \ | |
653 | if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \ | |
654 | PyObject* o1 = PySequence_GetItem(ro, 0); \ | |
655 | PyObject* o2 = PySequence_GetItem(ro, 1); \ | |
656 | if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \ | |
657 | *a = PyInt_AsLong(o1); *b = PyInt_AsLong(o2); \ | |
658 | } \ | |
659 | else \ | |
660 | PyErr_SetString(PyExc_TypeError, errmsg); \ | |
661 | Py_DECREF(o1); \ | |
662 | Py_DECREF(o2); \ | |
663 | } \ | |
664 | else { \ | |
665 | PyErr_SetString(PyExc_TypeError, errmsg); \ | |
666 | } \ | |
667 | Py_DECREF(ro); \ | |
668 | } \ | |
669 | } \ | |
670 | wxPyEndBlockThreads(); \ | |
671 | if (! found) \ | |
672 | PCLASS::CBNAME(a,b); \ | |
673 | } \ | |
674 | void CLASS::base_##CBNAME(int* a, int* b) const { \ | |
675 | PCLASS::CBNAME(a,b); \ | |
676 | } | |
677 | ||
678 | ||
679 | //--------------------------------------------------------------------------- | |
680 | ||
681 | #define DEC_PYCALLBACK_SIZE_const(CBNAME) \ | |
682 | wxSize CBNAME() const; \ | |
1fded56b | 683 | wxSize base_##CBNAME() const |
b0e5c039 RD |
684 | |
685 | ||
686 | #define IMP_PYCALLBACK_SIZE_const(CLASS, PCLASS, CBNAME) \ | |
687 | wxSize CLASS::CBNAME() const { \ | |
688 | const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \ | |
689 | bool found; wxSize rval(0,0); \ | |
690 | wxPyBeginBlockThreads(); \ | |
691 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
692 | PyObject* ro; \ | |
693 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \ | |
694 | if (ro) { \ | |
695 | if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \ | |
696 | PyObject* o1 = PySequence_GetItem(ro, 0); \ | |
697 | PyObject* o2 = PySequence_GetItem(ro, 1); \ | |
698 | if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \ | |
699 | rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \ | |
700 | } \ | |
701 | else \ | |
702 | PyErr_SetString(PyExc_TypeError, errmsg); \ | |
703 | Py_DECREF(o1); \ | |
704 | Py_DECREF(o2); \ | |
705 | } \ | |
706 | else { \ | |
707 | PyErr_SetString(PyExc_TypeError, errmsg); \ | |
708 | } \ | |
709 | Py_DECREF(ro); \ | |
710 | } \ | |
711 | } \ | |
712 | wxPyEndBlockThreads(); \ | |
713 | if (! found) \ | |
714 | return PCLASS::CBNAME(); \ | |
715 | else \ | |
716 | return rval; \ | |
717 | } \ | |
718 | wxSize CLASS::base_##CBNAME() const { \ | |
719 | return PCLASS::CBNAME(); \ | |
720 | } | |
721 | ||
722 | ||
723 | //--------------------------------------------------------------------------- | |
724 | ||
1fded56b RD |
725 | #define DEC_PYCALLBACK_BOOL_BOOL(CBNAME) \ |
726 | bool CBNAME(bool a); \ | |
727 | bool base_##CBNAME(bool a) | |
728 | ||
729 | ||
730 | #define IMP_PYCALLBACK_BOOL_BOOL(CLASS, PCLASS, CBNAME) \ | |
731 | bool CLASS::CBNAME(bool a) { \ | |
732 | bool rval=FALSE, found; \ | |
733 | wxPyBeginBlockThreads(); \ | |
734 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
735 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\ | |
736 | wxPyEndBlockThreads(); \ | |
737 | if (! found) \ | |
738 | rval = PCLASS::CBNAME(a); \ | |
739 | return rval; \ | |
740 | } \ | |
741 | bool CLASS::base_##CBNAME(bool a) { \ | |
742 | return PCLASS::CBNAME(a); \ | |
743 | } | |
744 | ||
745 | //--------------------------------------------------------------------------- | |
746 | ||
d559219f RD |
747 | #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \ |
748 | bool CBNAME(int a); \ | |
1fded56b | 749 | bool base_##CBNAME(int a) |
d559219f RD |
750 | |
751 | ||
752 | #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \ | |
753 | bool CLASS::CBNAME(int a) { \ | |
059a841c | 754 | bool rval=FALSE, found; \ |
b0e5c039 | 755 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 756 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
059a841c | 757 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\ |
b0e5c039 | 758 | wxPyEndBlockThreads(); \ |
19a97bd6 | 759 | if (! found) \ |
d559219f | 760 | rval = PCLASS::CBNAME(a); \ |
d559219f | 761 | return rval; \ |
bb0054cd | 762 | } \ |
d559219f | 763 | bool CLASS::base_##CBNAME(int a) { \ |
bb0054cd RD |
764 | return PCLASS::CBNAME(a); \ |
765 | } | |
766 | ||
efc5f224 RD |
767 | //--------------------------------------------------------------------------- |
768 | ||
d559219f | 769 | #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \ |
1fded56b | 770 | bool CBNAME(int a) |
d559219f RD |
771 | |
772 | ||
773 | #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \ | |
774 | bool CLASS::CBNAME(int a) { \ | |
059a841c | 775 | bool rval=FALSE; \ |
4268f798 | 776 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 777 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ |
1e7ecb7b | 778 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \ |
194fa2ac | 779 | else rval = FALSE; \ |
4268f798 | 780 | wxPyEndBlockThreads(); \ |
d559219f | 781 | return rval; \ |
bb0054cd RD |
782 | } |
783 | ||
784 | ||
785 | //--------------------------------------------------------------------------- | |
786 | ||
d559219f RD |
787 | #define DEC_PYCALLBACK__DC(CBNAME) \ |
788 | void CBNAME(wxDC& a); \ | |
1fded56b | 789 | void base_##CBNAME(wxDC& a) |
d559219f RD |
790 | |
791 | ||
19a97bd6 RD |
792 | #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \ |
793 | void CLASS::CBNAME(wxDC& a) { \ | |
794 | bool found; \ | |
3628e088 | 795 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
796 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
797 | PyObject* obj = wxPyMake_wxObject(&a); \ | |
798 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ | |
799 | Py_DECREF(obj); \ | |
800 | } \ | |
3628e088 | 801 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
802 | if (! found) \ |
803 | PCLASS::CBNAME(a); \ | |
804 | } \ | |
805 | void CLASS::base_##CBNAME(wxDC& a) { \ | |
806 | PCLASS::CBNAME(a); \ | |
bb0054cd RD |
807 | } |
808 | ||
efc5f224 RD |
809 | |
810 | ||
bb0054cd RD |
811 | //--------------------------------------------------------------------------- |
812 | ||
d559219f RD |
813 | #define DEC_PYCALLBACK__DCBOOL(CBNAME) \ |
814 | void CBNAME(wxDC& a, bool b); \ | |
1fded56b | 815 | void base_##CBNAME(wxDC& a, bool b) |
d559219f RD |
816 | |
817 | ||
818 | #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \ | |
819 | void CLASS::CBNAME(wxDC& a, bool b) { \ | |
19a97bd6 | 820 | bool found; \ |
4268f798 | 821 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
822 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
823 | PyObject* obj = wxPyMake_wxObject(&a); \ | |
1e7ecb7b | 824 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \ |
de20db99 RD |
825 | Py_DECREF(obj); \ |
826 | } \ | |
4268f798 | 827 | wxPyEndBlockThreads(); \ |
19a97bd6 | 828 | if (! found) \ |
efc5f224 RD |
829 | PCLASS::CBNAME(a, b); \ |
830 | } \ | |
d559219f | 831 | void CLASS::base_##CBNAME(wxDC& a, bool b) { \ |
efc5f224 RD |
832 | PCLASS::CBNAME(a, b); \ |
833 | } | |
834 | ||
835 | //--------------------------------------------------------------------------- | |
836 | ||
d559219f RD |
837 | #define DEC_PYCALLBACK__DCBOOL(CBNAME) \ |
838 | void CBNAME(wxDC& a, bool b); \ | |
1fded56b | 839 | void base_##CBNAME(wxDC& a, bool b) |
d559219f RD |
840 | |
841 | ||
842 | #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \ | |
843 | void CLASS::CBNAME(wxDC& a, bool b) { \ | |
19a97bd6 | 844 | bool found; \ |
4268f798 | 845 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
846 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
847 | PyObject* obj = wxPyMake_wxObject(&a); \ | |
1e7ecb7b | 848 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \ |
de20db99 RD |
849 | Py_DECREF(obj); \ |
850 | } \ | |
4268f798 | 851 | wxPyEndBlockThreads(); \ |
19a97bd6 | 852 | if (! found) \ |
efc5f224 RD |
853 | PCLASS::CBNAME(a, b); \ |
854 | } \ | |
d559219f | 855 | void CLASS::base_##CBNAME(wxDC& a, bool b) { \ |
efc5f224 RD |
856 | PCLASS::CBNAME(a, b); \ |
857 | } | |
858 | ||
859 | //--------------------------------------------------------------------------- | |
860 | ||
d559219f RD |
861 | #define DEC_PYCALLBACK__2DBL(CBNAME) \ |
862 | void CBNAME(double a, double b); \ | |
1fded56b | 863 | void base_##CBNAME(double a, double b) |
d559219f RD |
864 | |
865 | ||
19a97bd6 RD |
866 | #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \ |
867 | void CLASS::CBNAME(double a, double b) { \ | |
868 | bool found; \ | |
4268f798 | 869 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
870 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
871 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \ | |
4268f798 | 872 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
873 | if (! found) \ |
874 | PCLASS::CBNAME(a, b); \ | |
875 | } \ | |
876 | void CLASS::base_##CBNAME(double a, double b) { \ | |
877 | PCLASS::CBNAME(a, b); \ | |
efc5f224 RD |
878 | } |
879 | ||
880 | //--------------------------------------------------------------------------- | |
881 | ||
d559219f RD |
882 | #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \ |
883 | void CBNAME(double a, double b, int c, int d); \ | |
1fded56b | 884 | void base_##CBNAME(double a, double b, int c, int d) |
d559219f RD |
885 | |
886 | ||
887 | #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \ | |
888 | void CLASS::CBNAME(double a, double b, int c, int d) { \ | |
19a97bd6 | 889 | bool found; \ |
4268f798 | 890 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
891 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
892 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \ | |
efc5f224 | 893 | a,b,c,d)); \ |
4268f798 | 894 | wxPyEndBlockThreads(); \ |
19a97bd6 | 895 | if (! found) \ |
efc5f224 RD |
896 | PCLASS::CBNAME(a, b, c, d); \ |
897 | } \ | |
d559219f | 898 | void CLASS::base_##CBNAME(double a, double b, int c, int d) { \ |
efc5f224 RD |
899 | PCLASS::CBNAME(a, b, c, d); \ |
900 | } | |
901 | ||
902 | //--------------------------------------------------------------------------- | |
903 | ||
19a97bd6 | 904 | #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \ |
d559219f | 905 | void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \ |
1fded56b | 906 | void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) |
d559219f RD |
907 | |
908 | ||
909 | #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \ | |
910 | void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \ | |
19a97bd6 | 911 | bool found; \ |
4268f798 | 912 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
913 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
914 | PyObject* obj = wxPyMake_wxObject(&a); \ | |
1e7ecb7b | 915 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \ |
de20db99 RD |
916 | Py_DECREF(obj); \ |
917 | } \ | |
4268f798 | 918 | wxPyEndBlockThreads(); \ |
19a97bd6 | 919 | if (! found) \ |
d559219f | 920 | PCLASS::CBNAME(a, b, c, d, e, f); \ |
d559219f RD |
921 | } \ |
922 | void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\ | |
923 | PCLASS::CBNAME(a, b, c, d, e, f); \ | |
efc5f224 RD |
924 | } |
925 | ||
926 | //--------------------------------------------------------------------------- | |
927 | ||
d559219f RD |
928 | #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \ |
929 | bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \ | |
1fded56b | 930 | bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) |
d559219f RD |
931 | |
932 | ||
933 | #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \ | |
934 | bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \ | |
19a97bd6 | 935 | bool found; \ |
4268f798 | 936 | wxPyBeginBlockThreads(); \ |
059a841c | 937 | bool rval=FALSE; \ |
19a97bd6 RD |
938 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
939 | PyObject* obj = wxPyMake_wxObject(&a); \ | |
1e7ecb7b | 940 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\ |
de20db99 RD |
941 | Py_DECREF(obj); \ |
942 | } \ | |
4268f798 | 943 | wxPyEndBlockThreads(); \ |
19a97bd6 | 944 | if (! found) \ |
99a49d3e | 945 | rval = PCLASS::CBNAME(a, b, c, d, e, f); \ |
99a49d3e | 946 | return rval; \ |
d559219f RD |
947 | } \ |
948 | bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\ | |
949 | return PCLASS::CBNAME(a, b, c, d, e, f); \ | |
efc5f224 RD |
950 | } |
951 | ||
952 | //--------------------------------------------------------------------------- | |
953 | ||
d559219f RD |
954 | #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \ |
955 | void CBNAME(bool a, double b, double c, int d, int e); \ | |
1fded56b | 956 | void base_##CBNAME(bool a, double b, double c, int d, int e) |
d559219f RD |
957 | |
958 | ||
959 | #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \ | |
960 | void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \ | |
19a97bd6 | 961 | bool found; \ |
4268f798 | 962 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 963 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
f2e1c18a | 964 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \ |
d559219f | 965 | (int)a,b,c,d,e)); \ |
4268f798 | 966 | wxPyEndBlockThreads(); \ |
19a97bd6 | 967 | if (! found) \ |
d559219f | 968 | PCLASS::CBNAME(a, b, c, d, e); \ |
d559219f RD |
969 | } \ |
970 | void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \ | |
971 | PCLASS::CBNAME(a, b, c, d, e); \ | |
efc5f224 RD |
972 | } |
973 | ||
974 | //--------------------------------------------------------------------------- | |
975 | ||
19a97bd6 | 976 | #define DEC_PYCALLBACK__DC4DBL(CBNAME) \ |
d559219f | 977 | void CBNAME(wxDC& a, double b, double c, double d, double e); \ |
1fded56b | 978 | void base_##CBNAME(wxDC& a, double b, double c, double d, double e) |
d559219f RD |
979 | |
980 | ||
981 | #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \ | |
982 | void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \ | |
19a97bd6 | 983 | bool found; \ |
4268f798 | 984 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
985 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
986 | PyObject* obj = wxPyMake_wxObject(&a); \ | |
1e7ecb7b | 987 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \ |
de20db99 RD |
988 | Py_DECREF(obj); \ |
989 | } \ | |
4268f798 | 990 | wxPyEndBlockThreads(); \ |
19a97bd6 | 991 | if (! found) \ |
d559219f | 992 | PCLASS::CBNAME(a, b, c, d, e); \ |
d559219f RD |
993 | } \ |
994 | void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\ | |
995 | PCLASS::CBNAME(a, b, c, d, e); \ | |
efc5f224 RD |
996 | } |
997 | ||
998 | //--------------------------------------------------------------------------- | |
999 | ||
d559219f RD |
1000 | #define DEC_PYCALLBACK__DCBOOL(CBNAME) \ |
1001 | void CBNAME(wxDC& a, bool b); \ | |
1fded56b | 1002 | void base_##CBNAME(wxDC& a, bool b) |
d559219f RD |
1003 | |
1004 | ||
19a97bd6 RD |
1005 | #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \ |
1006 | void CLASS::CBNAME(wxDC& a, bool b) { \ | |
1007 | bool found; \ | |
4268f798 | 1008 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
1009 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
1010 | PyObject* obj = wxPyMake_wxObject(&a); \ | |
1011 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \ | |
1012 | Py_DECREF(obj); \ | |
1013 | } \ | |
4268f798 | 1014 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
1015 | if (! found) \ |
1016 | PCLASS::CBNAME(a, b); \ | |
1017 | } \ | |
1018 | void CLASS::base_##CBNAME(wxDC& a, bool b) { \ | |
1019 | PCLASS::CBNAME(a, b); \ | |
efc5f224 | 1020 | } |
bb0054cd | 1021 | |
7bf85405 | 1022 | //--------------------------------------------------------------------------- |
7bf85405 | 1023 | |
d559219f RD |
1024 | #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \ |
1025 | void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \ | |
1fded56b | 1026 | void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f) |
d559219f RD |
1027 | |
1028 | ||
1029 | #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \ | |
1030 | void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \ | |
1031 | int e, int f) { \ | |
19a97bd6 | 1032 | bool found; \ |
4268f798 | 1033 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
1034 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
1035 | PyObject* obj = wxPyMake_wxObject(a); \ | |
1e7ecb7b | 1036 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\ |
de20db99 RD |
1037 | Py_DECREF(obj); \ |
1038 | } \ | |
4268f798 | 1039 | wxPyEndBlockThreads(); \ |
19a97bd6 | 1040 | if (! found) \ |
d559219f | 1041 | PCLASS::CBNAME(a, b, c, d, e, f); \ |
d559219f RD |
1042 | } \ |
1043 | void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \ | |
1044 | int e, int f) { \ | |
1045 | PCLASS::CBNAME(a, b, c, d, e, f); \ | |
efc5f224 RD |
1046 | } |
1047 | ||
1048 | //--------------------------------------------------------------------------- | |
1049 | ||
d559219f RD |
1050 | #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \ |
1051 | void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \ | |
1fded56b | 1052 | void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e) |
d559219f RD |
1053 | |
1054 | ||
1055 | #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \ | |
1056 | void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \ | |
19a97bd6 | 1057 | bool found; \ |
4268f798 | 1058 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
1059 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
1060 | PyObject* obj = wxPyMake_wxObject(a); \ | |
1e7ecb7b | 1061 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \ |
de20db99 RD |
1062 | Py_DECREF(obj); \ |
1063 | } \ | |
4268f798 | 1064 | wxPyEndBlockThreads(); \ |
19a97bd6 | 1065 | if (! found) \ |
d559219f | 1066 | PCLASS::CBNAME(a, b, c, d, e); \ |
d559219f RD |
1067 | } \ |
1068 | void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \ | |
1069 | int d, int e) { \ | |
1070 | PCLASS::CBNAME(a, b, c, d, e); \ | |
efc5f224 RD |
1071 | } |
1072 | ||
1073 | //--------------------------------------------------------------------------- | |
1074 | ||
d559219f RD |
1075 | #define DEC_PYCALLBACK__2DBLINT(CBNAME) \ |
1076 | void CBNAME(double a, double b, int c); \ | |
1fded56b | 1077 | void base_##CBNAME(double a, double b, int c) |
d559219f RD |
1078 | |
1079 | ||
19a97bd6 RD |
1080 | #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \ |
1081 | void CLASS::CBNAME(double a, double b, int c) { \ | |
1082 | bool found; \ | |
4268f798 | 1083 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
1084 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
1085 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \ | |
4268f798 | 1086 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
1087 | if (! found) \ |
1088 | PCLASS::CBNAME(a, b, c); \ | |
1089 | } \ | |
1090 | void CLASS::base_##CBNAME(double a, double b, int c) { \ | |
1091 | PCLASS::CBNAME(a, b, c); \ | |
efc5f224 RD |
1092 | } |
1093 | ||
1094 | //--------------------------------------------------------------------------- | |
1095 | ||
d559219f RD |
1096 | #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \ |
1097 | void CBNAME(bool a, double b, double c, int d); \ | |
1fded56b | 1098 | void base_##CBNAME(bool a, double b, double c, int d) |
d559219f RD |
1099 | |
1100 | ||
1101 | #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \ | |
1102 | void CLASS::CBNAME(bool a, double b, double c, int d) { \ | |
19a97bd6 | 1103 | bool found; \ |
a66212dc | 1104 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
1105 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
1106 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\ | |
a66212dc | 1107 | wxPyEndBlockThreads(); \ |
19a97bd6 | 1108 | if (! found) \ |
d559219f | 1109 | PCLASS::CBNAME(a, b, c, d); \ |
d559219f RD |
1110 | } \ |
1111 | void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \ | |
1112 | PCLASS::CBNAME(a, b, c, d); \ | |
efc5f224 RD |
1113 | } |
1114 | ||
1115 | //--------------------------------------------------------------------------- | |
1116 | //--------------------------------------------------------------------------- | |
389c5527 RD |
1117 | |
1118 | #define DEC_PYCALLBACK__STRING(CBNAME) \ | |
1119 | void CBNAME(const wxString& a); \ | |
1fded56b | 1120 | void base_##CBNAME(const wxString& a) |
389c5527 | 1121 | |
19a97bd6 RD |
1122 | #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \ |
1123 | void CLASS::CBNAME(const wxString& a) { \ | |
1124 | bool found; \ | |
a66212dc RD |
1125 | wxPyBeginBlockThreads(); \ |
1126 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
1127 | PyObject* s = wx2PyString(a); \ | |
1128 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \ | |
1129 | Py_DECREF(s); \ | |
1130 | } \ | |
1131 | wxPyEndBlockThreads(); \ | |
19a97bd6 RD |
1132 | if (! found) \ |
1133 | PCLASS::CBNAME(a); \ | |
1134 | } \ | |
1135 | void CLASS::base_##CBNAME(const wxString& a) { \ | |
1136 | PCLASS::CBNAME(a); \ | |
389c5527 RD |
1137 | } |
1138 | ||
1139 | //--------------------------------------------------------------------------- | |
1140 | ||
1141 | #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \ | |
1142 | bool CBNAME(const wxString& a); \ | |
1fded56b | 1143 | bool base_##CBNAME(const wxString& a) |
389c5527 | 1144 | |
389c5527 RD |
1145 | #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \ |
1146 | bool CLASS::CBNAME(const wxString& a) { \ | |
059a841c | 1147 | bool rval=FALSE; \ |
19a97bd6 | 1148 | bool found; \ |
a66212dc RD |
1149 | wxPyBeginBlockThreads(); \ |
1150 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
1151 | PyObject* s = wx2PyString(a); \ | |
1152 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \ | |
1153 | Py_DECREF(s); \ | |
1154 | } \ | |
1155 | wxPyEndBlockThreads(); \ | |
19a97bd6 | 1156 | if (! found) \ |
389c5527 | 1157 | rval = PCLASS::CBNAME(a); \ |
389c5527 RD |
1158 | return rval; \ |
1159 | } \ | |
1160 | bool CLASS::base_##CBNAME(const wxString& a) { \ | |
1161 | return PCLASS::CBNAME(a); \ | |
1162 | } | |
1163 | ||
1164 | //--------------------------------------------------------------------------- | |
1165 | ||
c368d904 | 1166 | #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \ |
1fded56b | 1167 | bool CBNAME(const wxString& a) |
c8bc7bb8 | 1168 | |
a66212dc RD |
1169 | #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \ |
1170 | bool CLASS::CBNAME(const wxString& a) { \ | |
1171 | bool rval=FALSE; \ | |
1172 | wxPyBeginBlockThreads(); \ | |
1173 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ | |
1174 | PyObject* s = wx2PyString(a); \ | |
1175 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \ | |
1176 | Py_DECREF(s); \ | |
1177 | } \ | |
1178 | wxPyEndBlockThreads(); \ | |
1179 | return rval; \ | |
1180 | } \ | |
c368d904 RD |
1181 | |
1182 | //--------------------------------------------------------------------------- | |
1183 | ||
1184 | #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \ | |
1fded56b | 1185 | wxString CBNAME(const wxString& a) |
c368d904 RD |
1186 | |
1187 | #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \ | |
1188 | wxString CLASS::CBNAME(const wxString& a) { \ | |
1189 | wxString rval; \ | |
a541c325 | 1190 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 1191 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ |
c368d904 | 1192 | PyObject* ro; \ |
a66212dc RD |
1193 | PyObject* s = wx2PyString(a); \ |
1194 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \ | |
1195 | Py_DECREF(s); \ | |
c368d904 | 1196 | if (ro) { \ |
a541c325 RD |
1197 | rval = Py2wxString(ro); \ |
1198 | Py_DECREF(ro); \ | |
c368d904 RD |
1199 | } \ |
1200 | } \ | |
a541c325 | 1201 | wxPyEndBlockThreads(); \ |
c368d904 RD |
1202 | return rval; \ |
1203 | } \ | |
1204 | ||
1205 | //--------------------------------------------------------------------------- | |
1206 | ||
fd512ba2 RD |
1207 | #define DEC_PYCALLBACK_STRING_STRING(CBNAME) \ |
1208 | wxString CBNAME(const wxString& a); \ | |
1fded56b | 1209 | wxString base_##CBNAME(const wxString& a) |
fd512ba2 RD |
1210 | |
1211 | #define IMP_PYCALLBACK_STRING_STRING(CLASS, PCLASS, CBNAME) \ | |
1212 | wxString CLASS::CBNAME(const wxString& a) { \ | |
1213 | wxString rval; \ | |
1214 | bool found; \ | |
1215 | wxPyBeginBlockThreads(); \ | |
1216 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
1217 | PyObject* ro; \ | |
1218 | PyObject* s = wx2PyString(a); \ | |
1219 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \ | |
1220 | Py_DECREF(s); \ | |
1221 | if (ro) { \ | |
1222 | rval = Py2wxString(ro); \ | |
1223 | Py_DECREF(ro); \ | |
1224 | } \ | |
1225 | } \ | |
1226 | if (! found) \ | |
1227 | rval = PCLASS::CBNAME(a); \ | |
1228 | wxPyEndBlockThreads(); \ | |
1229 | return rval; \ | |
1230 | } \ | |
1231 | ||
1232 | //--------------------------------------------------------------------------- | |
1233 | ||
c368d904 | 1234 | #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \ |
1fded56b | 1235 | wxString CBNAME(const wxString& a,int b) |
c368d904 RD |
1236 | |
1237 | #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \ | |
1238 | wxString CLASS::CBNAME(const wxString& a,int b) { \ | |
1239 | wxString rval; \ | |
a66212dc | 1240 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 1241 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ |
c368d904 | 1242 | PyObject* ro; \ |
a66212dc RD |
1243 | PyObject* s = wx2PyString(a); \ |
1244 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oi)",s,b)); \ | |
1245 | Py_DECREF(s); \ | |
c368d904 | 1246 | if (ro) { \ |
a541c325 RD |
1247 | rval = Py2wxString(ro); \ |
1248 | Py_DECREF(ro); \ | |
c368d904 RD |
1249 | } \ |
1250 | } \ | |
a541c325 | 1251 | wxPyEndBlockThreads(); \ |
c368d904 RD |
1252 | return rval; \ |
1253 | } \ | |
1254 | ||
1255 | //--------------------------------------------------------------------------- | |
1256 | ||
f0261a72 RD |
1257 | #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \ |
1258 | bool CBNAME(const wxString& a, const wxString& b); \ | |
1fded56b | 1259 | bool base_##CBNAME(const wxString& a, const wxString& b) |
f0261a72 | 1260 | |
f0261a72 RD |
1261 | #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \ |
1262 | bool CLASS::CBNAME(const wxString& a, const wxString& b) { \ | |
059a841c | 1263 | bool rval=FALSE; \ |
19a97bd6 | 1264 | bool found; \ |
a66212dc RD |
1265 | wxPyBeginBlockThreads(); \ |
1266 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
1267 | PyObject* s1 = wx2PyString(a); \ | |
1268 | PyObject* s2 = wx2PyString(b); \ | |
1269 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",s1,s2)); \ | |
1270 | Py_DECREF(s1); \ | |
1271 | Py_DECREF(s2); \ | |
1272 | } \ | |
a541c325 | 1273 | wxPyEndBlockThreads(); \ |
19a97bd6 | 1274 | if (! found) \ |
f0261a72 | 1275 | rval = PCLASS::CBNAME(a, b); \ |
f0261a72 RD |
1276 | return rval; \ |
1277 | } \ | |
1278 | bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \ | |
1279 | return PCLASS::CBNAME(a, b); \ | |
1280 | } | |
1281 | ||
1282 | //--------------------------------------------------------------------------- | |
1283 | ||
389c5527 RD |
1284 | #define DEC_PYCALLBACK_STRING_(CBNAME) \ |
1285 | wxString CBNAME(); \ | |
1fded56b | 1286 | wxString base_##CBNAME() |
389c5527 | 1287 | |
389c5527 RD |
1288 | #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \ |
1289 | wxString CLASS::CBNAME() { \ | |
1290 | wxString rval; \ | |
19a97bd6 | 1291 | bool found; \ |
4268f798 | 1292 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 1293 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
389c5527 | 1294 | PyObject* ro; \ |
19a97bd6 | 1295 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \ |
f6bcfd97 | 1296 | if (ro) { \ |
a541c325 RD |
1297 | rval = Py2wxString(ro); \ |
1298 | Py_DECREF(ro); \ | |
f6bcfd97 | 1299 | } \ |
389c5527 | 1300 | } \ |
a541c325 | 1301 | wxPyEndBlockThreads(); \ |
19a97bd6 | 1302 | if (! found) \ |
b1462dfa | 1303 | rval = PCLASS::CBNAME(); \ |
389c5527 RD |
1304 | return rval; \ |
1305 | } \ | |
b1462dfa RD |
1306 | wxString CLASS::base_##CBNAME() { \ |
1307 | return PCLASS::CBNAME(); \ | |
389c5527 RD |
1308 | } |
1309 | ||
1310 | //--------------------------------------------------------------------------- | |
1311 | ||
1e4a197e RD |
1312 | #define DEC_PYCALLBACK_STRING__const(CBNAME) \ |
1313 | wxString CBNAME() const; \ | |
1314 | wxString base_##CBNAME() const; | |
1315 | ||
1316 | #define IMP_PYCALLBACK_STRING__const(CLASS, PCLASS, CBNAME) \ | |
1317 | wxString CLASS::CBNAME() const { \ | |
1318 | wxString rval; \ | |
1319 | bool found; \ | |
1320 | wxPyBeginBlockThreads(); \ | |
1321 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
1322 | PyObject* ro; \ | |
1323 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \ | |
1324 | if (ro) { \ | |
1325 | rval = Py2wxString(ro); \ | |
1326 | Py_DECREF(ro); \ | |
1327 | } \ | |
1328 | } \ | |
1329 | wxPyEndBlockThreads(); \ | |
1330 | if (! found) \ | |
1331 | rval = PCLASS::CBNAME(); \ | |
1332 | return rval; \ | |
1333 | } \ | |
1334 | wxString CLASS::base_##CBNAME() const { \ | |
1335 | return PCLASS::CBNAME(); \ | |
1336 | } | |
1337 | ||
1338 | //--------------------------------------------------------------------------- | |
1339 | ||
389c5527 | 1340 | #define DEC_PYCALLBACK_STRING__pure(CBNAME) \ |
1fded56b | 1341 | wxString CBNAME() |
389c5527 | 1342 | |
389c5527 RD |
1343 | #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \ |
1344 | wxString CLASS::CBNAME() { \ | |
1345 | wxString rval; \ | |
4268f798 | 1346 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 1347 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ |
389c5527 | 1348 | PyObject* ro; \ |
19a97bd6 | 1349 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \ |
2d138379 RD |
1350 | if (ro) { \ |
1351 | rval = Py2wxString(ro); \ | |
1352 | Py_DECREF(ro); \ | |
1353 | } \ | |
1354 | } \ | |
1355 | wxPyEndBlockThreads(); \ | |
1356 | return rval; \ | |
1357 | } | |
1358 | ||
1359 | //--------------------------------------------------------------------------- | |
1360 | ||
1361 | #define DEC_PYCALLBACK_STRING__constpure(CBNAME) \ | |
1362 | wxString CBNAME() const; | |
1363 | ||
1364 | #define IMP_PYCALLBACK_STRING__constpure(CLASS, PCLASS, CBNAME) \ | |
1365 | wxString CLASS::CBNAME() const { \ | |
1366 | wxString rval; \ | |
1367 | wxPyBeginBlockThreads(); \ | |
1368 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ | |
1369 | PyObject* ro; \ | |
1370 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \ | |
f6bcfd97 | 1371 | if (ro) { \ |
a541c325 RD |
1372 | rval = Py2wxString(ro); \ |
1373 | Py_DECREF(ro); \ | |
f6bcfd97 | 1374 | } \ |
389c5527 | 1375 | } \ |
a541c325 | 1376 | wxPyEndBlockThreads(); \ |
389c5527 RD |
1377 | return rval; \ |
1378 | } | |
1379 | ||
1380 | //--------------------------------------------------------------------------- | |
1381 | ||
1382 | #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \ | |
1fded56b | 1383 | bool CBNAME(const wxHtmlTag& a) |
389c5527 RD |
1384 | |
1385 | ||
1386 | #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \ | |
1387 | bool CLASS::CBNAME(const wxHtmlTag& a) { \ | |
059a841c | 1388 | bool rval=FALSE; \ |
a66212dc | 1389 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 1390 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ |
1e4a197e | 1391 | PyObject* obj = wxPyConstructObject((void*)&a, wxT("wxHtmlTag"), 0); \ |
19a97bd6 | 1392 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ |
de20db99 RD |
1393 | Py_DECREF(obj); \ |
1394 | } \ | |
a66212dc | 1395 | wxPyEndBlockThreads(); \ |
389c5527 RD |
1396 | return rval; \ |
1397 | } | |
1398 | ||
0122b7e3 RD |
1399 | //--------------------------------------------------------------------------- |
1400 | ||
1401 | #define DEC_PYCALLBACK__CELLINTINT(CBNAME) \ | |
1402 | void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y); \ | |
1fded56b | 1403 | void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) |
0122b7e3 RD |
1404 | |
1405 | #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \ | |
1406 | void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \ | |
0122b7e3 | 1407 | bool found; \ |
a66212dc | 1408 | wxPyBeginBlockThreads(); \ |
0122b7e3 | 1409 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
1e4a197e | 1410 | PyObject* obj = wxPyConstructObject((void*)cell, wxT("wxHtmlCell"), 0); \ |
0122b7e3 RD |
1411 | wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \ |
1412 | Py_DECREF(obj); \ | |
1413 | } \ | |
a66212dc | 1414 | wxPyEndBlockThreads(); \ |
0122b7e3 RD |
1415 | if (! found) \ |
1416 | PCLASS::CBNAME(cell, x, y); \ | |
1417 | } \ | |
1418 | void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \ | |
1419 | PCLASS::CBNAME(cell, x, y); \ | |
1420 | } | |
1421 | ||
1422 | ||
1423 | //--------------------------------------------------------------------------- | |
1424 | ||
1425 | #define DEC_PYCALLBACK__CELLINTINTME(CBNAME) \ | |
1426 | void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e); \ | |
1fded56b | 1427 | void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) |
0122b7e3 RD |
1428 | |
1429 | #define IMP_PYCALLBACK__CELLINTINTME(CLASS, PCLASS, CBNAME) \ | |
1430 | void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \ | |
1431 | bool found; \ | |
a66212dc | 1432 | wxPyBeginBlockThreads(); \ |
0122b7e3 | 1433 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
1e4a197e RD |
1434 | PyObject* obj = wxPyConstructObject((void*)cell, wxT("wxHtmlCell"), 0); \ |
1435 | PyObject* o2 = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \ | |
0122b7e3 RD |
1436 | wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \ |
1437 | Py_DECREF(obj); \ | |
1438 | Py_DECREF(o2); \ | |
1439 | } \ | |
a66212dc | 1440 | wxPyEndBlockThreads(); \ |
0122b7e3 | 1441 | if (! found) \ |
a66212dc | 1442 | PCLASS::CBNAME(cell, x, y, e); \ |
0122b7e3 RD |
1443 | } \ |
1444 | void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \ | |
a66212dc | 1445 | PCLASS::CBNAME(cell, x, y, e); \ |
0122b7e3 RD |
1446 | } |
1447 | ||
1448 | ||
1449 | ||
389c5527 | 1450 | //--------------------------------------------------------------------------- |
2f90df85 RD |
1451 | |
1452 | #define DEC_PYCALLBACK___pure(CBNAME) \ | |
1fded56b | 1453 | void CBNAME() |
2f90df85 RD |
1454 | |
1455 | ||
1456 | #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \ | |
1457 | void CLASS::CBNAME() { \ | |
a66212dc | 1458 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
1459 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ |
1460 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ | |
a66212dc | 1461 | wxPyEndBlockThreads(); \ |
2f90df85 RD |
1462 | } |
1463 | ||
1464 | //--------------------------------------------------------------------------- | |
1465 | ||
1466 | #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \ | |
1fded56b | 1467 | wxSize CBNAME() |
2f90df85 RD |
1468 | |
1469 | ||
1470 | #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \ | |
1471 | wxSize CLASS::CBNAME() { \ | |
db0ff83e | 1472 | const char* errmsg = #CBNAME " should return a 2-tuple of integers or a wxSize object."; \ |
2f90df85 | 1473 | wxSize rval(0,0); \ |
db0ff83e | 1474 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 1475 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ |
2f90df85 RD |
1476 | PyObject* ro; \ |
1477 | wxSize* ptr; \ | |
19a97bd6 | 1478 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \ |
f6bcfd97 BP |
1479 | if (ro) { \ |
1480 | if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \ | |
1481 | rval = *ptr; \ | |
db0ff83e RD |
1482 | else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \ |
1483 | PyObject* o1 = PySequence_GetItem(ro, 0); \ | |
1484 | PyObject* o2 = PySequence_GetItem(ro, 1); \ | |
1485 | if (PyNumber_Check(o1) && PyNumber_Check(o2)) \ | |
1486 | rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \ | |
1487 | else \ | |
1488 | PyErr_SetString(PyExc_TypeError, errmsg); \ | |
1489 | Py_DECREF(o1); \ | |
1490 | Py_DECREF(o2); \ | |
1491 | } \ | |
1492 | else { \ | |
1493 | PyErr_SetString(PyExc_TypeError, errmsg); \ | |
1494 | } \ | |
f6bcfd97 BP |
1495 | Py_DECREF(ro); \ |
1496 | } \ | |
2f90df85 | 1497 | } \ |
db0ff83e | 1498 | wxPyEndBlockThreads(); \ |
2f90df85 RD |
1499 | return rval; \ |
1500 | } | |
1501 | ||
1502 | //--------------------------------------------------------------------------- | |
1503 | ||
1504 | #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \ | |
1505 | bool CBNAME(wxWindow* a); \ | |
1fded56b | 1506 | bool base_##CBNAME(wxWindow* a) |
2f90df85 RD |
1507 | |
1508 | ||
19a97bd6 RD |
1509 | #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \ |
1510 | bool CLASS::CBNAME(wxWindow* a) { \ | |
059a841c | 1511 | bool rval=FALSE; \ |
19a97bd6 | 1512 | bool found; \ |
a66212dc | 1513 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
1514 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
1515 | PyObject* obj = wxPyMake_wxObject(a); \ | |
1516 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ | |
1517 | Py_DECREF(obj); \ | |
1518 | } \ | |
a66212dc | 1519 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
1520 | if (! found) \ |
1521 | rval = PCLASS::CBNAME(a); \ | |
1522 | return rval; \ | |
1523 | } \ | |
1524 | bool CLASS::base_##CBNAME(wxWindow* a) { \ | |
1525 | return PCLASS::CBNAME(a); \ | |
2f90df85 RD |
1526 | } |
1527 | ||
389c5527 | 1528 | //--------------------------------------------------------------------------- |
2f90df85 | 1529 | |
1fded56b RD |
1530 | #define DEC_PYCALLBACK_BOOL_WXWINDC(CBNAME) \ |
1531 | bool CBNAME(wxWindow* a, wxDC& b); \ | |
1532 | bool base_##CBNAME(wxWindow* a, wxDC& b) | |
1533 | ||
1534 | ||
1535 | #define IMP_PYCALLBACK_BOOL_WXWINDC(CLASS, PCLASS, CBNAME) \ | |
1536 | bool CLASS::CBNAME(wxWindow* a, wxDC& b) { \ | |
1537 | bool rval=FALSE; \ | |
1538 | bool found; \ | |
1539 | wxPyBeginBlockThreads(); \ | |
1540 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
1541 | PyObject* win = wxPyMake_wxObject(a); \ | |
1542 | PyObject* dc = wxPyMake_wxObject(&b); \ | |
1543 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc));\ | |
1544 | Py_DECREF(win); \ | |
1545 | Py_DECREF(dc); \ | |
1546 | } \ | |
1547 | wxPyEndBlockThreads(); \ | |
1548 | if (! found) \ | |
1549 | rval = PCLASS::CBNAME(a, b); \ | |
1550 | return rval; \ | |
1551 | } \ | |
1552 | bool CLASS::base_##CBNAME(wxWindow* a, wxDC& b) { \ | |
1553 | return PCLASS::CBNAME(a, b); \ | |
1554 | } | |
1555 | ||
1556 | //--------------------------------------------------------------------------- | |
1557 | ||
aaad759f RD |
1558 | #define DEC_PYCALLBACK_VOID_WXWINBASE(CBNAME) \ |
1559 | void CBNAME(wxWindowBase* a); \ | |
1fded56b | 1560 | void base_##CBNAME(wxWindowBase* a) |
aaad759f RD |
1561 | |
1562 | ||
1563 | #define IMP_PYCALLBACK_VOID_WXWINBASE(CLASS, PCLASS, CBNAME) \ | |
1564 | void CLASS::CBNAME(wxWindowBase* a) { \ | |
1565 | bool found; \ | |
1566 | wxPyBeginBlockThreads(); \ | |
1567 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
1568 | PyObject* obj = wxPyMake_wxObject(a); \ | |
1569 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ | |
1570 | Py_DECREF(obj); \ | |
1571 | } \ | |
1572 | wxPyEndBlockThreads(); \ | |
1573 | if (! found) \ | |
1574 | PCLASS::CBNAME(a); \ | |
1575 | } \ | |
1576 | void CLASS::base_##CBNAME(wxWindowBase* a) { \ | |
1577 | PCLASS::CBNAME(a); \ | |
1578 | } | |
1579 | ||
1580 | //--------------------------------------------------------------------------- | |
1581 | ||
2f90df85 RD |
1582 | #define DEC_PYCALLBACK_BOOL_(CBNAME) \ |
1583 | bool CBNAME(); \ | |
1fded56b | 1584 | bool base_##CBNAME() |
2f90df85 RD |
1585 | |
1586 | ||
19a97bd6 RD |
1587 | #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \ |
1588 | bool CLASS::CBNAME() { \ | |
059a841c | 1589 | bool rval=FALSE; \ |
19a97bd6 | 1590 | bool found; \ |
b0e5c039 | 1591 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
1592 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
1593 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ | |
b0e5c039 | 1594 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
1595 | if (! found) \ |
1596 | rval = PCLASS::CBNAME(); \ | |
1597 | return rval; \ | |
1598 | } \ | |
1599 | bool CLASS::base_##CBNAME() { \ | |
1600 | return PCLASS::CBNAME(); \ | |
2f90df85 RD |
1601 | } |
1602 | ||
b1462dfa RD |
1603 | //--------------------------------------------------------------------------- |
1604 | ||
b0e5c039 RD |
1605 | #define DEC_PYCALLBACK_BOOL_const(CBNAME) \ |
1606 | bool CBNAME() const; \ | |
1fded56b | 1607 | bool base_##CBNAME() const |
b0e5c039 RD |
1608 | |
1609 | ||
1610 | #define IMP_PYCALLBACK_BOOL_const(CLASS, PCLASS, CBNAME) \ | |
1611 | bool CLASS::CBNAME() const { \ | |
1612 | bool rval=FALSE; \ | |
1613 | bool found; \ | |
1614 | wxPyBeginBlockThreads(); \ | |
1615 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
1616 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ | |
1617 | wxPyEndBlockThreads(); \ | |
1618 | if (! found) \ | |
1619 | rval = PCLASS::CBNAME(); \ | |
1620 | return rval; \ | |
1621 | } \ | |
1622 | bool CLASS::base_##CBNAME() const { \ | |
1623 | return PCLASS::CBNAME(); \ | |
1624 | } | |
1625 | ||
1626 | //--------------------------------------------------------------------------- | |
1627 | ||
19a97bd6 RD |
1628 | #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \ |
1629 | wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \ | |
1fded56b | 1630 | wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def) |
b1462dfa RD |
1631 | |
1632 | ||
19a97bd6 RD |
1633 | #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \ |
1634 | wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \ | |
059a841c | 1635 | int rval=0; \ |
19a97bd6 | 1636 | bool found; \ |
cac344f6 | 1637 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 1638 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
1e7ecb7b | 1639 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\ |
cac344f6 | 1640 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
1641 | if (! found) \ |
1642 | rval = PCLASS::CBNAME(a, b, c); \ | |
1643 | return (wxDragResult)rval; \ | |
1644 | } \ | |
1645 | wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \ | |
1646 | return PCLASS::CBNAME(a, b, c); \ | |
b1462dfa RD |
1647 | } |
1648 | ||
1649 | //--------------------------------------------------------------------------- | |
1650 | ||
c368d904 | 1651 | #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \ |
1fded56b | 1652 | wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location) |
c368d904 RD |
1653 | |
1654 | #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \ | |
1655 | wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \ | |
cac344f6 | 1656 | wxPyBeginBlockThreads(); \ |
c368d904 | 1657 | wxFSFile* rval=0; \ |
19a97bd6 | 1658 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ |
c368d904 | 1659 | PyObject* ro; \ |
19a97bd6 | 1660 | PyObject* obj = wxPyMake_wxObject(&a); \ |
a66212dc | 1661 | PyObject* s = wx2PyString(b); \ |
a541c325 | 1662 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)",\ |
a66212dc | 1663 | obj, s)); \ |
c368d904 RD |
1664 | if (ro) { \ |
1665 | SWIG_GetPtrObj(ro, (void **)&rval, "_wxFSFILE_p"); \ | |
1666 | Py_DECREF(ro); \ | |
1667 | } \ | |
de20db99 | 1668 | Py_DECREF(obj); \ |
a66212dc | 1669 | Py_DECREF(s); \ |
de20db99 | 1670 | } \ |
cac344f6 | 1671 | wxPyEndBlockThreads(); \ |
c368d904 RD |
1672 | return rval; \ |
1673 | }; | |
1674 | ||
1675 | //--------------------------------------------------------------------------- | |
1676 | ||
b1462dfa RD |
1677 | #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \ |
1678 | bool CBNAME(wxDragResult a); \ | |
1fded56b | 1679 | bool base_##CBNAME(wxDragResult a) |
b1462dfa RD |
1680 | |
1681 | ||
1682 | #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \ | |
1683 | bool CLASS::CBNAME(wxDragResult a) { \ | |
059a841c | 1684 | bool rval=FALSE; \ |
19a97bd6 | 1685 | bool found; \ |
a541c325 | 1686 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
1687 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
1688 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a));\ | |
a541c325 | 1689 | wxPyEndBlockThreads(); \ |
19a97bd6 | 1690 | if (! found) \ |
b1462dfa | 1691 | rval = PCLASS::CBNAME(a); \ |
b1462dfa RD |
1692 | return rval; \ |
1693 | } \ | |
1694 | bool CLASS::base_##CBNAME(wxDragResult a) { \ | |
1695 | return PCLASS::CBNAME(a); \ | |
1696 | } | |
1697 | ||
1698 | //--------------------------------------------------------------------------- | |
1699 | ||
1700 | #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \ | |
1fded56b | 1701 | wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def) |
b1462dfa RD |
1702 | |
1703 | ||
1704 | #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \ | |
1705 | wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \ | |
a541c325 | 1706 | wxPyBeginBlockThreads(); \ |
059a841c | 1707 | int rval=0; \ |
19a97bd6 | 1708 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ |
1e7ecb7b | 1709 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\ |
a541c325 | 1710 | wxPyEndBlockThreads(); \ |
b1462dfa RD |
1711 | return (wxDragResult)rval; \ |
1712 | } \ | |
1713 | ||
1714 | //--------------------------------------------------------------------------- | |
1715 | ||
1716 | #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \ | |
1fded56b | 1717 | bool CBNAME(int a, int b, const wxString& c) |
b1462dfa | 1718 | |
b1462dfa RD |
1719 | #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \ |
1720 | bool CLASS::CBNAME(int a, int b, const wxString& c) { \ | |
059a841c | 1721 | bool rval=FALSE; \ |
a541c325 | 1722 | wxPyBeginBlockThreads(); \ |
a66212dc RD |
1723 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ |
1724 | PyObject* s = wx2PyString(c); \ | |
1725 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\ | |
1726 | Py_DECREF(s); \ | |
1727 | } \ | |
a541c325 | 1728 | wxPyEndBlockThreads(); \ |
b1462dfa RD |
1729 | return rval; \ |
1730 | } \ | |
1731 | ||
1732 | //--------------------------------------------------------------------------- | |
1733 | ||
1734 | #define DEC_PYCALLBACK_SIZET_(CBNAME) \ | |
1735 | size_t CBNAME(); \ | |
1fded56b | 1736 | size_t base_##CBNAME() |
b1462dfa RD |
1737 | |
1738 | ||
1739 | #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \ | |
1740 | size_t CLASS::CBNAME() { \ | |
059a841c | 1741 | size_t rval=0; \ |
19a97bd6 | 1742 | bool found; \ |
a541c325 | 1743 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
1744 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
1745 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ | |
a541c325 | 1746 | wxPyEndBlockThreads(); \ |
19a97bd6 | 1747 | if (! found) \ |
b1462dfa | 1748 | rval = PCLASS::CBNAME(); \ |
b1462dfa RD |
1749 | return rval; \ |
1750 | } \ | |
1751 | size_t CLASS::base_##CBNAME() { \ | |
1752 | return PCLASS::CBNAME(); \ | |
1753 | } | |
1754 | ||
1755 | //--------------------------------------------------------------------------- | |
1756 | ||
c7e7022c RD |
1757 | #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \ |
1758 | wxDataFormat CBNAME(size_t a); \ | |
1fded56b | 1759 | wxDataFormat base_##CBNAME(size_t a) |
b1462dfa RD |
1760 | |
1761 | ||
1762 | #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \ | |
1763 | wxDataFormat CLASS::CBNAME(size_t a) { \ | |
059a841c | 1764 | wxDataFormat rval=0; \ |
19a97bd6 | 1765 | bool found; \ |
a541c325 | 1766 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 1767 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
b1462dfa RD |
1768 | PyObject* ro; \ |
1769 | wxDataFormat* ptr; \ | |
c7e7022c | 1770 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \ |
f6bcfd97 BP |
1771 | if (ro) { \ |
1772 | if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxDataFormat_p")) \ | |
1773 | rval = *ptr; \ | |
1774 | Py_DECREF(ro); \ | |
1775 | } \ | |
b1462dfa | 1776 | } \ |
a541c325 | 1777 | wxPyEndBlockThreads(); \ |
19a97bd6 | 1778 | if (! found) \ |
b1462dfa | 1779 | rval = PCLASS::CBNAME(a); \ |
b1462dfa RD |
1780 | return rval; \ |
1781 | } \ | |
1782 | wxDataFormat CLASS::base_##CBNAME(size_t a) { \ | |
1783 | return PCLASS::CBNAME(a); \ | |
1784 | } | |
1785 | ||
389c5527 | 1786 | //--------------------------------------------------------------------------- |
f6bcfd97 BP |
1787 | |
1788 | #define DEC_PYCALLBACK__constany(CBNAME, Type) \ | |
1789 | void CBNAME(const Type& a); \ | |
1fded56b | 1790 | void base_##CBNAME(const Type& a) |
f6bcfd97 BP |
1791 | |
1792 | ||
19a97bd6 RD |
1793 | #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \ |
1794 | void CLASS::CBNAME(const Type& a) { \ | |
1795 | bool found; \ | |
a541c325 | 1796 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 1797 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
1e4a197e | 1798 | PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \ |
19a97bd6 RD |
1799 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ |
1800 | Py_DECREF(obj); \ | |
1801 | } \ | |
a541c325 | 1802 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
1803 | if (! found) \ |
1804 | PCLASS::CBNAME(a); \ | |
1805 | } \ | |
1806 | void CLASS::base_##CBNAME(const Type& a) { \ | |
1807 | PCLASS::CBNAME(a); \ | |
f6bcfd97 BP |
1808 | } |
1809 | ||
1810 | ||
1811 | //--------------------------------------------------------------------------- | |
1812 | ||
1813 | #define DEC_PYCALLBACK__any(CBNAME, Type) \ | |
1814 | void CBNAME(Type& a); \ | |
1fded56b | 1815 | void base_##CBNAME(Type& a) |
f6bcfd97 BP |
1816 | |
1817 | ||
19a97bd6 RD |
1818 | #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \ |
1819 | void CLASS::CBNAME(Type& a) { \ | |
1820 | bool found; \ | |
a541c325 | 1821 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 1822 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
1e4a197e | 1823 | PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \ |
19a97bd6 RD |
1824 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ |
1825 | Py_DECREF(obj); \ | |
1826 | } \ | |
a541c325 | 1827 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
1828 | if (! found) \ |
1829 | PCLASS::CBNAME(a); \ | |
1830 | } \ | |
1831 | void CLASS::base_##CBNAME(Type& a) { \ | |
1832 | PCLASS::CBNAME(a); \ | |
f6bcfd97 BP |
1833 | } |
1834 | ||
efc5f224 | 1835 | //--------------------------------------------------------------------------- |
f6bcfd97 BP |
1836 | |
1837 | #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \ | |
1838 | bool CBNAME(Type& a); \ | |
1fded56b | 1839 | bool base_##CBNAME(Type& a) |
f6bcfd97 BP |
1840 | |
1841 | ||
19a97bd6 RD |
1842 | #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \ |
1843 | bool CLASS::CBNAME(Type& a) { \ | |
36fd8ec3 | 1844 | bool rv=FALSE; \ |
19a97bd6 | 1845 | bool found; \ |
a541c325 | 1846 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 1847 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
1e4a197e | 1848 | PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \ |
19a97bd6 RD |
1849 | rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ |
1850 | Py_DECREF(obj); \ | |
1851 | } \ | |
a541c325 | 1852 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
1853 | if (! found) \ |
1854 | rv = PCLASS::CBNAME(a); \ | |
1855 | return rv; \ | |
1856 | } \ | |
1857 | bool CLASS::base_##CBNAME(Type& a) { \ | |
1858 | return PCLASS::CBNAME(a); \ | |
f6bcfd97 BP |
1859 | } |
1860 | ||
efc5f224 RD |
1861 | //--------------------------------------------------------------------------- |
1862 | ||
628c7f79 | 1863 | #define DEC_PYCALLBACK_bool_anypure(CBNAME, Type) \ |
1fded56b | 1864 | bool CBNAME(Type& a) |
628c7f79 RD |
1865 | |
1866 | ||
1867 | #define IMP_PYCALLBACK_bool_anypure(CLASS, PCLASS, CBNAME, Type) \ | |
1868 | bool CLASS::CBNAME(Type& a) { \ | |
1869 | bool rv=FALSE; \ | |
1870 | wxPyBeginBlockThreads(); \ | |
1871 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ | |
1e4a197e | 1872 | PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \ |
628c7f79 RD |
1873 | rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ |
1874 | Py_DECREF(obj); \ | |
1875 | } \ | |
1876 | wxPyEndBlockThreads(); \ | |
1877 | return rv; \ | |
1878 | } \ | |
1879 | ||
1880 | //--------------------------------------------------------------------------- | |
1881 | ||
c7e7022c RD |
1882 | #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \ |
1883 | wxString CBNAME(long a, long b) const; \ | |
1fded56b | 1884 | wxString base_##CBNAME(long a, long b) const |
c7e7022c | 1885 | |
c7e7022c RD |
1886 | #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \ |
1887 | wxString CLASS::CBNAME(long a, long b) const { \ | |
1888 | wxString rval; \ | |
19a97bd6 | 1889 | bool found; \ |
a541c325 | 1890 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 1891 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
c7e7022c RD |
1892 | PyObject* ro; \ |
1893 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \ | |
1894 | if (ro) { \ | |
a541c325 RD |
1895 | rval = Py2wxString(ro); \ |
1896 | Py_DECREF(ro); \ | |
c7e7022c RD |
1897 | } \ |
1898 | } \ | |
a541c325 | 1899 | wxPyEndBlockThreads(); \ |
19a97bd6 | 1900 | if (! found) \ |
c7e7022c | 1901 | rval = PCLASS::CBNAME(a,b); \ |
c7e7022c RD |
1902 | return rval; \ |
1903 | } \ | |
1904 | wxString CLASS::base_##CBNAME(long a, long b) const { \ | |
1905 | return PCLASS::CBNAME(a,b); \ | |
1906 | } | |
1907 | ||
1908 | //--------------------------------------------------------------------------- | |
1909 | ||
1910 | #define DEC_PYCALLBACK_INT_LONG(CBNAME) \ | |
1911 | int CBNAME(long a) const; \ | |
1fded56b | 1912 | int base_##CBNAME(long a) const |
c7e7022c RD |
1913 | |
1914 | ||
1915 | #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \ | |
1916 | int CLASS::CBNAME(long a) const { \ | |
1917 | int rval=-1; \ | |
19a97bd6 | 1918 | bool found; \ |
a541c325 | 1919 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 1920 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
c7e7022c RD |
1921 | PyObject* ro; \ |
1922 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \ | |
1923 | if (ro) { \ | |
1924 | rval = PyInt_AsLong(ro); \ | |
1925 | Py_DECREF(ro); \ | |
1926 | } \ | |
1927 | } \ | |
a541c325 | 1928 | wxPyEndBlockThreads(); \ |
19a97bd6 | 1929 | if (! found) \ |
c7e7022c | 1930 | rval = PCLASS::CBNAME(a); \ |
c7e7022c RD |
1931 | return rval; \ |
1932 | } \ | |
1933 | int CLASS::base_##CBNAME(long a) const { \ | |
1934 | return PCLASS::CBNAME(a); \ | |
1935 | } | |
1936 | ||
1937 | ||
1938 | //--------------------------------------------------------------------------- | |
1939 | ||
1940 | #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \ | |
00b6c4e3 | 1941 | wxListItemAttr* CBNAME(long a) const; \ |
1fded56b | 1942 | wxListItemAttr* base_##CBNAME(long a) const |
c7e7022c RD |
1943 | |
1944 | ||
1945 | #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \ | |
00b6c4e3 | 1946 | wxListItemAttr *CLASS::CBNAME(long a) const { \ |
c7e7022c | 1947 | wxListItemAttr *rval = NULL; \ |
19a97bd6 | 1948 | bool found; \ |
a541c325 | 1949 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 1950 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
c7e7022c RD |
1951 | PyObject* ro; \ |
1952 | wxListItemAttr* ptr; \ | |
1953 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \ | |
1954 | if (ro) { \ | |
1955 | if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxListItemAttr_p")) \ | |
1956 | rval = ptr; \ | |
1957 | Py_DECREF(ro); \ | |
1958 | } \ | |
1959 | } \ | |
a541c325 | 1960 | wxPyEndBlockThreads(); \ |
19a97bd6 | 1961 | if (! found) \ |
c7e7022c | 1962 | rval = PCLASS::CBNAME(a); \ |
c7e7022c RD |
1963 | return rval; \ |
1964 | } \ | |
1fded56b | 1965 | wxListItemAttr *CLASS::base_##CBNAME(long a) const { \ |
c7e7022c RD |
1966 | return PCLASS::CBNAME(a); \ |
1967 | } | |
1968 | ||
1969 | //--------------------------------------------------------------------------- | |
1970 | ||
a541c325 RD |
1971 | #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \ |
1972 | bool CBNAME(wxMouseEvent& e); \ | |
1fded56b | 1973 | bool base_##CBNAME(wxMouseEvent& e) |
0122b7e3 | 1974 | |
a541c325 RD |
1975 | #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \ |
1976 | bool CLASS::CBNAME(wxMouseEvent& e) { \ | |
1977 | bool rval=FALSE; \ | |
1978 | bool found; \ | |
1979 | wxPyBeginBlockThreads(); \ | |
1980 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
1981 | PyObject* ro; \ | |
1e4a197e | 1982 | PyObject* obj = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \ |
a541c325 RD |
1983 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \ |
1984 | if (ro) { \ | |
1985 | rval = PyInt_AsLong(ro); \ | |
1986 | Py_DECREF(ro); \ | |
1987 | } \ | |
1988 | Py_DECREF(obj); \ | |
1989 | } \ | |
1990 | wxPyEndBlockThreads(); \ | |
1991 | if (! found) \ | |
1992 | return PCLASS::CBNAME(e); \ | |
1993 | return rval; \ | |
1994 | } \ | |
1995 | bool CLASS::base_##CBNAME(wxMouseEvent& e) { \ | |
1996 | return PCLASS::CBNAME(e); \ | |
0122b7e3 RD |
1997 | } |
1998 | ||
1999 | ||
2000 | //--------------------------------------------------------------------------- | |
2001 | ||
af83019e | 2002 | #define DEC_PYCALLBACK_WIZPG__pure(CBNAME) \ |
1fded56b | 2003 | wxWizardPage* CBNAME() const |
af83019e RD |
2004 | |
2005 | #define IMP_PYCALLBACK_WIZPG__pure(CLASS, PCLASS, CBNAME) \ | |
2006 | wxWizardPage* CLASS::CBNAME() const { \ | |
2007 | wxWizardPage* rv = NULL; \ | |
af83019e | 2008 | wxPyBeginBlockThreads(); \ |
628c7f79 | 2009 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ |
af83019e RD |
2010 | PyObject* ro; \ |
2011 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \ | |
2012 | if (ro) { \ | |
2013 | SWIG_GetPtrObj(ro, (void **)&rv, "_wxWizardPage_p"); \ | |
2014 | Py_DECREF(ro); \ | |
2015 | } \ | |
2016 | } \ | |
2017 | wxPyEndBlockThreads(); \ | |
2018 | return rv; \ | |
2019 | } | |
2020 | ||
2021 | //--------------------------------------------------------------------------- | |
2022 | ||
2023 | #define DEC_PYCALLBACK_BITMAP__pure(CBNAME) \ | |
1fded56b | 2024 | wxBitmap CBNAME() const |
af83019e RD |
2025 | |
2026 | #define IMP_PYCALLBACK_BITMAP__pure(CLASS, PCLASS, CBNAME) \ | |
2027 | wxBitmap CLASS::CBNAME() const { \ | |
2028 | wxBitmap rv; \ | |
af83019e | 2029 | wxPyBeginBlockThreads(); \ |
628c7f79 | 2030 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ |
af83019e RD |
2031 | PyObject* ro; \ |
2032 | wxBitmap* ptr; \ | |
2033 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \ | |
2034 | if (ro) { \ | |
2035 | if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxBitmap_p")) \ | |
2036 | rv = *ptr; \ | |
2037 | Py_DECREF(ro); \ | |
2038 | } \ | |
2039 | } \ | |
2040 | wxPyEndBlockThreads(); \ | |
2041 | return rv; \ | |
2042 | } | |
2043 | ||
2044 | //--------------------------------------------------------------------------- | |
2045 | ||
628c7f79 | 2046 | #define DEC_PYCALLBACK_OBJECT__pure(CBNAME) \ |
1fded56b | 2047 | wxObject* CBNAME() |
628c7f79 RD |
2048 | |
2049 | #define IMP_PYCALLBACK_OBJECT__pure(CLASS, PCLASS, CBNAME) \ | |
2050 | wxObject* CLASS::CBNAME() { \ | |
2051 | wxObject* rv = NULL; \ | |
2052 | wxPyBeginBlockThreads(); \ | |
2053 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ | |
2054 | PyObject* ro; \ | |
2055 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \ | |
2056 | if (ro) { \ | |
2057 | SWIG_GetPtrObj(ro, (void **)&rv, "_wxObject_p"); \ | |
2058 | Py_DECREF(ro); \ | |
2059 | } \ | |
2060 | } \ | |
2061 | wxPyEndBlockThreads(); \ | |
2062 | return rv; \ | |
2063 | } | |
2064 | ||
2065 | //--------------------------------------------------------------------------- | |
2066 | ||
1e4a197e | 2067 | #define DEC_PYCALLBACK_OBJECT_STRING_pure(CBNAME) \ |
1fded56b | 2068 | wxObject* CBNAME(const wxString& a) |
1e4a197e RD |
2069 | |
2070 | #define IMP_PYCALLBACK_OBJECT_STRING_pure(CLASS, PCLASS, CBNAME) \ | |
2071 | wxObject* CLASS::CBNAME(const wxString& a) { \ | |
2072 | wxObject* rv = NULL; \ | |
2073 | wxPyBeginBlockThreads(); \ | |
2074 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ | |
2075 | PyObject* so = wx2PyString(a); \ | |
2076 | PyObject* ro; \ | |
2077 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", so)); \ | |
2078 | if (ro) { \ | |
2079 | SWIG_GetPtrObj(ro, (void **)&rv, "_wxObject_p"); \ | |
2080 | Py_DECREF(ro); \ | |
2081 | } \ | |
2082 | Py_DECREF(so); \ | |
2083 | } \ | |
2084 | wxPyEndBlockThreads(); \ | |
2085 | return rv; \ | |
2086 | } | |
2087 | ||
2088 | //--------------------------------------------------------------------------- | |
2089 | ||
628c7f79 | 2090 | #define DEC_PYCALLBACK_BOOL_NODE_pure(CBNAME) \ |
1fded56b | 2091 | bool CBNAME(wxXmlNode* a) |
628c7f79 RD |
2092 | |
2093 | ||
2094 | #define IMP_PYCALLBACK_BOOL_NODE_pure(CLASS, PCLASS, CBNAME) \ | |
2095 | bool CLASS::CBNAME(wxXmlNode* a) { \ | |
2096 | bool rv=FALSE; \ | |
2097 | wxPyBeginBlockThreads(); \ | |
2098 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ | |
1e4a197e | 2099 | PyObject* obj = wxPyConstructObject((void*)a, wxT("wxXmlNode"), 0); \ |
628c7f79 RD |
2100 | rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ |
2101 | Py_DECREF(obj); \ | |
2102 | } \ | |
2103 | wxPyEndBlockThreads(); \ | |
2104 | return rv; \ | |
2105 | } \ | |
2106 | ||
2107 | //--------------------------------------------------------------------------- | |
3628e088 RD |
2108 | |
2109 | #define DEC_PYCALLBACK_COORD_SIZET_constpure(CBNAME) \ | |
2110 | wxCoord CBNAME(size_t a) const | |
2111 | ||
2112 | ||
2113 | #define IMP_PYCALLBACK_COORD_SIZET_constpure(CLASS, PCLASS, CBNAME) \ | |
2114 | wxCoord CLASS::CBNAME(size_t a) const { \ | |
2115 | wxCoord rval=0; \ | |
2116 | bool found; \ | |
2117 | wxPyBeginBlockThreads(); \ | |
2118 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
3628e088 RD |
2119 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \ |
2120 | } \ | |
2121 | wxPyEndBlockThreads(); \ | |
2122 | return rval; \ | |
2123 | } \ | |
2124 | ||
2125 | //--------------------------------------------------------------------------- | |
2126 | ||
2127 | #define DEC_PYCALLBACK_VOID_SIZETSIZET_const(CBNAME) \ | |
2128 | void CBNAME(size_t a, size_t b) const; \ | |
2129 | void base_##CBNAME(size_t a, size_t b) const | |
2130 | ||
2131 | ||
2132 | #define IMP_PYCALLBACK_VOID_SIZETSIZET_const(CLASS, PCLASS, CBNAME) \ | |
2133 | void CLASS::CBNAME(size_t a, size_t b) const { \ | |
2134 | bool found; \ | |
2135 | wxPyBeginBlockThreads(); \ | |
2136 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
2137 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \ | |
2138 | wxPyEndBlockThreads(); \ | |
2139 | if (! found) \ | |
2140 | PCLASS::CBNAME(a,b); \ | |
2141 | } \ | |
2142 | void CLASS::base_##CBNAME(size_t a, size_t b) const { \ | |
2143 | PCLASS::CBNAME(a,b); \ | |
2144 | } | |
2145 | ||
2146 | //--------------------------------------------------------------------------- | |
2147 | ||
2148 | #define DEC_PYCALLBACK_COORD_const(CBNAME) \ | |
2149 | wxCoord CBNAME() const; \ | |
2150 | wxCoord base_##CBNAME() const | |
2151 | ||
2152 | ||
2153 | #define IMP_PYCALLBACK_COORD_const(CLASS, PCLASS, CBNAME) \ | |
2154 | wxCoord CLASS::CBNAME() const { \ | |
2155 | wxCoord rval=0; \ | |
2156 | bool found; \ | |
2157 | wxPyBeginBlockThreads(); \ | |
2158 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
2159 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ | |
2160 | wxPyEndBlockThreads(); \ | |
2161 | if (! found) \ | |
2162 | rval = PCLASS::CBNAME(); \ | |
2163 | return rval; \ | |
2164 | } \ | |
2165 | wxCoord CLASS::base_##CBNAME() const { \ | |
2166 | return PCLASS::CBNAME(); \ | |
2167 | } | |
2168 | ||
2169 | //--------------------------------------------------------------------------- | |
2170 | ||
2171 | #define DEC_PYCALLBACK__DCRECTSIZET_constpure(CBNAME) \ | |
2172 | void CBNAME(wxDC& a, const wxRect& b, size_t c) const; | |
2173 | ||
2174 | ||
2175 | #define IMP_PYCALLBACK__DCRECTSIZET_constpure(CLASS, PCLASS, CBNAME) \ | |
2176 | void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \ | |
2177 | bool found; \ | |
2178 | wxPyBeginBlockThreads(); \ | |
2179 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
2180 | PyObject* obj = wxPyMake_wxObject(&a); \ | |
2181 | PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \ | |
2182 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \ | |
2183 | Py_DECREF(obj); \ | |
2184 | } \ | |
2185 | wxPyEndBlockThreads(); \ | |
2186 | } \ | |
2187 | ||
2188 | //--------------------------------------------------------------------------- | |
2189 | ||
2190 | #define DEC_PYCALLBACK__DCRECTSIZET_const(CBNAME) \ | |
2191 | void CBNAME(wxDC& a, const wxRect& b, size_t c) const; \ | |
2192 | void base_##CBNAME(wxDC& a, const wxRect& b, size_t c) const | |
2193 | ||
2194 | ||
2195 | #define IMP_PYCALLBACK__DCRECTSIZET_const(CLASS, PCLASS, CBNAME) \ | |
2196 | void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \ | |
2197 | bool found; \ | |
2198 | wxPyBeginBlockThreads(); \ | |
2199 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
2200 | PyObject* obj = wxPyMake_wxObject(&a); \ | |
2201 | PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \ | |
2202 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \ | |
2203 | Py_DECREF(obj); \ | |
2204 | } \ | |
2205 | wxPyEndBlockThreads(); \ | |
2206 | if (! found) \ | |
2207 | PCLASS::CBNAME(a,b,c); \ | |
2208 | } \ | |
2209 | void CLASS::base_##CBNAME(wxDC& a, const wxRect& b, size_t c) const { \ | |
2210 | PCLASS::CBNAME(a,b,c); \ | |
2211 | } | |
2212 | ||
2213 | //--------------------------------------------------------------------------- | |
2214 | ||
2215 | ||
2216 | #define DEC_PYCALLBACK_STRING_SIZET(CBNAME) \ | |
2217 | wxString CBNAME(size_t a) const; \ | |
2218 | wxString base_##CBNAME(size_t a) const | |
2219 | ||
2220 | #define IMP_PYCALLBACK_STRING_SIZET(CLASS, PCLASS, CBNAME) \ | |
2221 | wxString CLASS::CBNAME(size_t a) const { \ | |
2222 | wxString rval; \ | |
2223 | bool found; \ | |
2224 | wxPyBeginBlockThreads(); \ | |
2225 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
2226 | PyObject* ro; \ | |
2227 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \ | |
2228 | if (ro) { \ | |
2229 | rval = Py2wxString(ro); \ | |
2230 | Py_DECREF(ro); \ | |
2231 | } \ | |
2232 | } \ | |
2233 | wxPyEndBlockThreads(); \ | |
2234 | if (! found) \ | |
2235 | rval = PCLASS::CBNAME(a); \ | |
2236 | return rval; \ | |
2237 | } \ | |
2238 | wxString CLASS::base_##CBNAME(size_t a) const { \ | |
2239 | return PCLASS::CBNAME(a); \ | |
2240 | } | |
2241 | ||
2242 | //--------------------------------------------------------------------------- | |
2243 | ||
2244 | #define DEC_PYCALLBACK_STRING_SIZET_pure(CBNAME) \ | |
2245 | wxString CBNAME(size_t a) const | |
2246 | ||
2247 | #define IMP_PYCALLBACK_STRING_SIZET_pure(CLASS, PCLASS, CBNAME) \ | |
2248 | wxString CLASS::CBNAME(size_t a) const { \ | |
2249 | wxString rval; \ | |
2250 | bool found; \ | |
2251 | wxPyBeginBlockThreads(); \ | |
2252 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
2253 | PyObject* ro; \ | |
2254 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \ | |
2255 | if (ro) { \ | |
2256 | rval = Py2wxString(ro); \ | |
2257 | Py_DECREF(ro); \ | |
2258 | } \ | |
2259 | } \ | |
2260 | wxPyEndBlockThreads(); \ | |
2261 | return rval; \ | |
2262 | } \ | |
2263 | ||
2264 | //--------------------------------------------------------------------------- | |
2265 | ||
7bf85405 | 2266 | #endif |