]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/helpers.h
Removed 'interface' pragma for gcc 2.96
[wxWidgets.git] / wxPython / src / helpers.h
CommitLineData
b1462dfa 1////////////////////////////////////////////////////////////////////////////
7bf85405
RD
2// Name: helpers.h
3// Purpose: Helper functions/classes for the wxPython extenaion module
4//
5// Author: Robin Dunn
6//
7// Created: 7/1/97
8// RCS-ID: $Id$
9// Copyright: (c) 1998 by Total Control Software
10// Licence: wxWindows license
11/////////////////////////////////////////////////////////////////////////////
12
13#ifndef __wxp_helpers__
14#define __wxp_helpers__
15
16#include <wx/wx.h>
17
18
cf694132
RD
19//----------------------------------------------------------------------
20
21// if we want to handle threads and Python threads are available...
22#if defined(WXP_USE_THREAD) && defined(WITH_THREAD)
23
24#define WXP_WITH_THREAD
25#define wxPy_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
26#define wxPy_END_ALLOW_THREADS Py_END_ALLOW_THREADS
27
28#else // no Python threads...
29#undef WXP_WITH_THREAD
30#define wxPy_BEGIN_ALLOW_THREADS
31#define wxPy_END_ALLOW_THREADS
32#endif
33
34
efc5f224
RD
35//---------------------------------------------------------------------------
36
37#if defined(__WXMSW__)
38# define HELPEREXPORT __declspec(dllexport)
39#else
40# define HELPEREXPORT
41#endif
42
2f90df85
RD
43typedef unsigned char byte;
44
7bf85405
RD
45//----------------------------------------------------------------------
46
47class wxPyApp: public wxApp
48{
49public:
cf694132
RD
50 wxPyApp();
51 ~wxPyApp();
7bf85405
RD
52 int MainLoop(void);
53 bool OnInit(void);
8bf5d46e 54//# void AfterMainLoop(void);
7bf85405
RD
55};
56
57extern wxPyApp *wxPythonApp;
58
59//----------------------------------------------------------------------
60
0d6f9504 61void __wxPreStart();
7bf85405 62PyObject* __wxStart(PyObject*, PyObject* args);
7ff49f0c 63void __wxCleanup();
7bf85405
RD
64
65extern PyObject* wxPython_dict;
66PyObject* __wxSetDictionary(PyObject*, PyObject* args);
67
7bf85405 68void wxPyEventThunker(wxObject*, wxEvent& event);
efc5f224 69
65dd82cb 70HELPEREXPORT PyObject* wxPyConstructObject(void* ptr, const char* className);
d559219f
RD
71HELPEREXPORT bool wxPyRestoreThread();
72HELPEREXPORT void wxPySaveThread(bool doSave);
65dd82cb 73HELPEREXPORT PyObject* wxPy_ConvertList(wxListBase* list, const char* className);
54b96882 74HELPEREXPORT long wxPyGetWinHandle(wxWindow* win);
9b3d3bc4
RD
75
76//----------------------------------------------------------------------
77
78class wxPyUserData : public wxObject {
79public:
80 wxPyUserData(PyObject* obj) { m_obj = obj; Py_INCREF(m_obj); }
81 ~wxPyUserData() {
82 bool doSave = wxPyRestoreThread();
83 Py_DECREF(m_obj);
84 wxPySaveThread(doSave);
85 }
86 PyObject* m_obj;
87};
88
7bf85405 89//----------------------------------------------------------------------
2f90df85
RD
90// These are helpers used by the typemaps
91
92HELPEREXPORT byte* byte_LIST_helper(PyObject* source);
93HELPEREXPORT int* int_LIST_helper(PyObject* source);
94HELPEREXPORT long* long_LIST_helper(PyObject* source);
95HELPEREXPORT char** string_LIST_helper(PyObject* source);
96HELPEREXPORT wxPoint* wxPoint_LIST_helper(PyObject* source);
97HELPEREXPORT wxBitmap** wxBitmap_LIST_helper(PyObject* source);
98HELPEREXPORT wxString* wxString_LIST_helper(PyObject* source);
99HELPEREXPORT wxAcceleratorEntry* wxAcceleratorEntry_LIST_helper(PyObject* source);
100
101HELPEREXPORT bool wxSize_helper(PyObject* source, wxSize** obj);
102HELPEREXPORT bool wxPoint_helper(PyObject* source, wxPoint** obj);
103HELPEREXPORT bool wxRealPoint_helper(PyObject* source, wxRealPoint** obj);
104HELPEREXPORT bool wxRect_helper(PyObject* source, wxRect** obj);
f6bcfd97 105HELPEREXPORT bool wxColour_helper(PyObject* source, wxColour** obj);
7bf85405 106
2f90df85 107//----------------------------------------------------------------------
7bf85405
RD
108
109#ifndef SWIGCODE
110extern "C" void SWIG_MakePtr(char *, void *, char *);
111extern "C" char *SWIG_GetPtr(char *, void **, char *);
d559219f 112extern "C" char *SWIG_GetPtrObj(PyObject *obj, void **ptr, char *type);
7bf85405
RD
113#endif
114
115
116#ifdef _MSC_VER
117# pragma warning(disable:4800)
f6bcfd97 118# pragma warning(disable:4190)
7bf85405
RD
119#endif
120
b639c3c5 121
7bf85405
RD
122
123// Non-const versions to keep SWIG happy.
124extern wxPoint wxPyDefaultPosition;
125extern wxSize wxPyDefaultSize;
7bf85405
RD
126extern wxString wxPyEmptyStr;
127
128//----------------------------------------------------------------------
129
130class wxPyCallback : public wxObject {
2f90df85 131 DECLARE_ABSTRACT_CLASS(wxPyCallback);
7bf85405 132public:
cf694132 133 wxPyCallback(PyObject* func);
2f90df85 134 wxPyCallback(const wxPyCallback& other);
cf694132 135 ~wxPyCallback();
7bf85405
RD
136
137 void EventThunker(wxEvent& event);
138
139 PyObject* m_func;
140};
141
7bf85405
RD
142//---------------------------------------------------------------------------
143
144class wxPyTimer : public wxTimer {
145public:
146 wxPyTimer(PyObject* callback);
147 ~wxPyTimer();
148
149 void Notify();
150
151private:
152 PyObject* func;
153};
154
cf694132
RD
155//---------------------------------------------------------------------------
156
bb0054cd
RD
157
158
159
160//---------------------------------------------------------------------------
161// This class holds an instance of a Python Shadow Class object and assists
162// with looking up and invoking Python callback methods from C++ virtual
163// method redirections. For all classes which have virtuals which should be
164// overridable in wxPython, a new subclass is created that contains a
a08cbc01 165// wxPyCallbackHelper.
d559219f 166//
f6bcfd97 167// TODO: This class should be combined with wxPyCallback defined above.
d559219f 168//
bb0054cd 169
efc5f224 170class HELPEREXPORT wxPyCallbackHelper {
bb0054cd
RD
171public:
172 wxPyCallbackHelper();
173 ~wxPyCallbackHelper();
174
2f90df85
RD
175 wxPyCallbackHelper(const wxPyCallbackHelper& other);
176
f6bcfd97 177 void setSelf(PyObject* self, PyObject* _class, int incref=TRUE);
bb0054cd 178
f6bcfd97
BP
179 bool findCallback(const wxString& name) const;
180 int callCallback(PyObject* argTuple) const;
181 PyObject* callCallbackObj(PyObject* argTuple) const;
bb0054cd
RD
182
183private:
184 PyObject* m_self;
f6bcfd97 185 PyObject* m_class;
bb0054cd 186 PyObject* m_lastFound;
b7312675 187 int m_incRef;
bb0054cd
RD
188};
189
190
65dd82cb
RD
191//---------------------------------------------------------------------------
192//---------------------------------------------------------------------------
9b3d3bc4
RD
193// These Event classes can be derived from in Python and passed through the
194// event system without loosing anything. They do this by keeping a reference
195// to themselves and some special case handling in wxPyCallback::EventThunker.
65dd82cb
RD
196
197
e19b7164 198class wxPyEvtSelfRef {
65dd82cb 199public:
e19b7164
RD
200 wxPyEvtSelfRef();
201 ~wxPyEvtSelfRef();
65dd82cb
RD
202
203 void SetSelf(PyObject* self, bool clone=FALSE);
204 PyObject* GetSelf() const;
205
206protected:
207 PyObject* m_self;
208 bool m_cloned;
209};
210
211
e19b7164 212class wxPyEvent : public wxEvent, public wxPyEvtSelfRef {
65dd82cb
RD
213 DECLARE_DYNAMIC_CLASS(wxPyEvent)
214public:
215 wxPyEvent(int id=0);
216 ~wxPyEvent();
217
218 void CopyObject(wxObject& dest) const;
219};
220
221
e19b7164 222class wxPyCommandEvent : public wxCommandEvent, public wxPyEvtSelfRef {
65dd82cb
RD
223 DECLARE_DYNAMIC_CLASS(wxPyCommandEvent)
224public:
225 wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0);
226 ~wxPyCommandEvent();
227
228 void CopyObject(wxObject& dest) const;
229};
230
bb0054cd
RD
231
232//---------------------------------------------------------------------------
233// These macros are used to implement the virtual methods that should
234// redirect to a Python method if one exists. The names designate the
b1462dfa 235// return type, if any, as well as any parameter types.
bb0054cd
RD
236//---------------------------------------------------------------------------
237
f6bcfd97
BP
238#define PYPRIVATE \
239 void _setSelf(PyObject* self, PyObject* _class, int incref=1) { \
240 m_myInst.setSelf(self, _class, incref); \
241 } \
efc5f224
RD
242 private: wxPyCallbackHelper m_myInst;
243
244//---------------------------------------------------------------------------
245
d559219f
RD
246#define DEC_PYCALLBACK__(CBNAME) \
247 void CBNAME(); \
248 void base_##CBNAME();
249
250
251#define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
252 void CLASS::CBNAME() { \
253 bool doSave = wxPyRestoreThread(); \
254 if (m_myInst.findCallback(#CBNAME)) \
255 m_myInst.callCallback(Py_BuildValue("()")); \
256 else \
257 PCLASS::CBNAME(); \
258 wxPySaveThread(doSave); \
259 } \
260 void CLASS::base_##CBNAME() { \
261 PCLASS::CBNAME(); \
262 }
263
264//---------------------------------------------------------------------------
265
266#define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
267 bool CBNAME(int a, int b); \
268 bool base_##CBNAME(int a, int b);
269
270
271#define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
272 bool CLASS::CBNAME(int a, int b) { \
273 bool rval; \
274 bool doSave = wxPyRestoreThread(); \
bb0054cd 275 if (m_myInst.findCallback(#CBNAME)) \
d559219f 276 rval = m_myInst.callCallback(Py_BuildValue("(ii)",a,b)); \
bb0054cd 277 else \
d559219f
RD
278 rval = PCLASS::CBNAME(a,b); \
279 wxPySaveThread(doSave); \
280 return rval; \
bb0054cd 281 } \
d559219f 282 bool CLASS::base_##CBNAME(int a, int b) { \
bb0054cd
RD
283 return PCLASS::CBNAME(a,b); \
284 }
285
286//---------------------------------------------------------------------------
287
d559219f
RD
288#define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
289 bool CBNAME(int a); \
290 bool base_##CBNAME(int a);
291
292
293#define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
294 bool CLASS::CBNAME(int a) { \
295 bool rval; \
296 bool doSave = wxPyRestoreThread(); \
bb0054cd 297 if (m_myInst.findCallback(#CBNAME)) \
d559219f 298 rval = m_myInst.callCallback(Py_BuildValue("(i)",a)); \
bb0054cd 299 else \
d559219f
RD
300 rval = PCLASS::CBNAME(a); \
301 wxPySaveThread(doSave); \
302 return rval; \
bb0054cd 303 } \
d559219f 304 bool CLASS::base_##CBNAME(int a) { \
bb0054cd
RD
305 return PCLASS::CBNAME(a); \
306 }
307
efc5f224
RD
308//---------------------------------------------------------------------------
309
d559219f
RD
310#define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
311 bool CBNAME(int a);
312
313
314#define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
315 bool CLASS::CBNAME(int a) { \
316 bool rval; \
317 bool doSave = wxPyRestoreThread(); \
bb0054cd 318 if (m_myInst.findCallback(#CBNAME)) \
d559219f 319 rval = m_myInst.callCallback(Py_BuildValue("(i)",a)); \
194fa2ac 320 else rval = FALSE; \
d559219f
RD
321 wxPySaveThread(doSave); \
322 return rval; \
bb0054cd
RD
323 }
324
325
326//---------------------------------------------------------------------------
327
d559219f
RD
328#define DEC_PYCALLBACK__DC(CBNAME) \
329 void CBNAME(wxDC& a); \
330 void base_##CBNAME(wxDC& a);
331
332
333#define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
334 void CLASS::CBNAME(wxDC& a) { \
335 bool doSave = wxPyRestoreThread(); \
336 if (m_myInst.findCallback(#CBNAME)) \
337 m_myInst.callCallback(Py_BuildValue("(O)", \
338 wxPyConstructObject(&a, "wxDC"))); \
339 else \
340 PCLASS::CBNAME(a); \
341 wxPySaveThread(doSave); \
342 } \
343 void CLASS::base_##CBNAME(wxDC& a) { \
344 PCLASS::CBNAME(a); \
bb0054cd
RD
345 }
346
efc5f224
RD
347
348
bb0054cd
RD
349//---------------------------------------------------------------------------
350
d559219f
RD
351#define DEC_PYCALLBACK__DCBOOL(CBNAME) \
352 void CBNAME(wxDC& a, bool b); \
353 void base_##CBNAME(wxDC& a, bool b);
354
355
356#define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
357 void CLASS::CBNAME(wxDC& a, bool b) { \
358 bool doSave = wxPyRestoreThread(); \
efc5f224
RD
359 if (m_myInst.findCallback(#CBNAME)) \
360 m_myInst.callCallback(Py_BuildValue("(Oi)", \
d559219f 361 wxPyConstructObject(&a, "wxDC"), (int)b)); \
efc5f224
RD
362 else \
363 PCLASS::CBNAME(a, b); \
d559219f 364 wxPySaveThread(doSave); \
efc5f224 365 } \
d559219f 366 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
efc5f224
RD
367 PCLASS::CBNAME(a, b); \
368 }
369
370//---------------------------------------------------------------------------
371
d559219f
RD
372#define DEC_PYCALLBACK__DCBOOL(CBNAME) \
373 void CBNAME(wxDC& a, bool b); \
374 void base_##CBNAME(wxDC& a, bool b);
375
376
377#define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
378 void CLASS::CBNAME(wxDC& a, bool b) { \
379 bool doSave = wxPyRestoreThread(); \
efc5f224
RD
380 if (m_myInst.findCallback(#CBNAME)) \
381 m_myInst.callCallback(Py_BuildValue("(Oi)", \
d559219f 382 wxPyConstructObject(&a, "wxDC"), (int)b)); \
efc5f224
RD
383 else \
384 PCLASS::CBNAME(a, b); \
d559219f 385 wxPySaveThread(doSave); \
efc5f224 386 } \
d559219f 387 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
efc5f224
RD
388 PCLASS::CBNAME(a, b); \
389 }
390
391//---------------------------------------------------------------------------
392
d559219f
RD
393#define DEC_PYCALLBACK__2DBL(CBNAME) \
394 void CBNAME(double a, double b); \
395 void base_##CBNAME(double a, double b);
396
397
398#define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
399 void CLASS::CBNAME(double a, double b) { \
400 bool doSave = wxPyRestoreThread(); \
401 if (m_myInst.findCallback(#CBNAME)) \
402 m_myInst.callCallback(Py_BuildValue("(dd)",a,b)); \
403 else \
404 PCLASS::CBNAME(a, b); \
405 wxPySaveThread(doSave); \
406 } \
407 void CLASS::base_##CBNAME(double a, double b) { \
408 PCLASS::CBNAME(a, b); \
efc5f224
RD
409 }
410
411//---------------------------------------------------------------------------
412
d559219f
RD
413#define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
414 void CBNAME(double a, double b, int c, int d); \
415 void base_##CBNAME(double a, double b, int c, int d);
416
417
418#define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
419 void CLASS::CBNAME(double a, double b, int c, int d) { \
420 bool doSave = wxPyRestoreThread(); \
efc5f224
RD
421 if (m_myInst.findCallback(#CBNAME)) \
422 m_myInst.callCallback(Py_BuildValue("(ddii)", \
423 a,b,c,d)); \
424 else \
425 PCLASS::CBNAME(a, b, c, d); \
d559219f 426 wxPySaveThread(doSave); \
efc5f224 427 } \
d559219f 428 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
efc5f224
RD
429 PCLASS::CBNAME(a, b, c, d); \
430 }
431
432//---------------------------------------------------------------------------
433
d559219f
RD
434#define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
435 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
436 void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
437
438
439#define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
440 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
441 bool doSave = wxPyRestoreThread(); \
442 if (m_myInst.findCallback(#CBNAME)) \
443 m_myInst.callCallback(Py_BuildValue("(Oddddi)", \
444 wxPyConstructObject(&a, "wxDC"), \
445 b, c, d, e, (int)f)); \
446 else \
447 PCLASS::CBNAME(a, b, c, d, e, f); \
448 wxPySaveThread(doSave); \
449 } \
450 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
451 PCLASS::CBNAME(a, b, c, d, e, f); \
efc5f224
RD
452 }
453
454//---------------------------------------------------------------------------
455
d559219f
RD
456#define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
457 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
458 bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
459
460
461#define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
462 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
463 bool doSave = wxPyRestoreThread(); \
99a49d3e 464 bool rval; \
d559219f 465 if (m_myInst.findCallback(#CBNAME)) \
99a49d3e 466 rval = m_myInst.callCallback(Py_BuildValue("(Oddddi)", \
d559219f
RD
467 wxPyConstructObject(&a, "wxDC"), \
468 b, c, d, e, (int)f)); \
469 else \
99a49d3e 470 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
d559219f 471 wxPySaveThread(doSave); \
99a49d3e 472 return rval; \
d559219f
RD
473 } \
474 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
475 return PCLASS::CBNAME(a, b, c, d, e, f); \
efc5f224
RD
476 }
477
478//---------------------------------------------------------------------------
479
d559219f
RD
480#define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
481 void CBNAME(bool a, double b, double c, int d, int e); \
482 void base_##CBNAME(bool a, double b, double c, int d, int e);
483
484
485#define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
486 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
487 bool doSave = wxPyRestoreThread(); \
488 if (m_myInst.findCallback(#CBNAME)) \
489 m_myInst.callCallback(Py_BuildValue("(idii)", \
490 (int)a,b,c,d,e)); \
491 else \
492 PCLASS::CBNAME(a, b, c, d, e); \
493 wxPySaveThread(doSave); \
494 } \
495 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
496 PCLASS::CBNAME(a, b, c, d, e); \
efc5f224
RD
497 }
498
499//---------------------------------------------------------------------------
500
d559219f
RD
501#define DEC_PYCALLBACK__DC4DBL(CBNAME) \
502 void CBNAME(wxDC& a, double b, double c, double d, double e); \
503 void base_##CBNAME(wxDC& a, double b, double c, double d, double e);
504
505
506#define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
507 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
508 bool doSave = wxPyRestoreThread(); \
509 if (m_myInst.findCallback(#CBNAME)) \
510 m_myInst.callCallback(Py_BuildValue("(Odddd)", \
511 wxPyConstructObject(&a, "wxDC"), \
512 b, c, d, e)); \
513 else \
514 PCLASS::CBNAME(a, b, c, d, e); \
515 wxPySaveThread(doSave); \
516 } \
517 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
518 PCLASS::CBNAME(a, b, c, d, e); \
efc5f224
RD
519 }
520
521//---------------------------------------------------------------------------
522
d559219f
RD
523#define DEC_PYCALLBACK__DCBOOL(CBNAME) \
524 void CBNAME(wxDC& a, bool b); \
525 void base_##CBNAME(wxDC& a, bool b);
526
527
528#define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
529 void CLASS::CBNAME(wxDC& a, bool b) { \
530 bool doSave = wxPyRestoreThread(); \
efc5f224
RD
531 if (m_myInst.findCallback(#CBNAME)) \
532 m_myInst.callCallback(Py_BuildValue("(Oi)", \
d559219f 533 wxPyConstructObject(&a, "wxDC"), \
efc5f224
RD
534 (int)b)); \
535 else \
536 PCLASS::CBNAME(a, b); \
d559219f 537 wxPySaveThread(doSave); \
efc5f224 538 } \
d559219f 539 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
efc5f224
RD
540 PCLASS::CBNAME(a, b); \
541 }
bb0054cd 542
7bf85405 543//---------------------------------------------------------------------------
7bf85405 544
d559219f
RD
545#define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
546 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
547 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f);
548
549
550#define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
551 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
552 int e, int f) { \
553 bool doSave = wxPyRestoreThread(); \
554 if (m_myInst.findCallback(#CBNAME)) \
555 m_myInst.callCallback(Py_BuildValue("(Oiddii)", \
2f90df85 556 wxPyConstructObject(a, "wxPyControlPoint"), \
d559219f
RD
557 (int)b, c, d, e, f)); \
558 else \
559 PCLASS::CBNAME(a, b, c, d, e, f); \
560 wxPySaveThread(doSave); \
561 } \
562 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
563 int e, int f) { \
564 PCLASS::CBNAME(a, b, c, d, e, f); \
efc5f224
RD
565 }
566
567//---------------------------------------------------------------------------
568
d559219f
RD
569#define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
570 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
571 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e);
572
573
574#define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
575 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
576 bool doSave = wxPyRestoreThread(); \
577 if (m_myInst.findCallback(#CBNAME)) \
578 m_myInst.callCallback(Py_BuildValue("(Oddii)", \
2f90df85 579 wxPyConstructObject(a, "wxPyControlPoint"), \
d559219f
RD
580 b, c, d, e)); \
581 else \
582 PCLASS::CBNAME(a, b, c, d, e); \
583 wxPySaveThread(doSave); \
584 } \
585 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
586 int d, int e) { \
587 PCLASS::CBNAME(a, b, c, d, e); \
efc5f224
RD
588 }
589
590//---------------------------------------------------------------------------
591
d559219f
RD
592#define DEC_PYCALLBACK__2DBLINT(CBNAME) \
593 void CBNAME(double a, double b, int c); \
594 void base_##CBNAME(double a, double b, int c);
595
596
597#define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
598 void CLASS::CBNAME(double a, double b, int c) { \
599 bool doSave = wxPyRestoreThread(); \
efc5f224
RD
600 if (m_myInst.findCallback(#CBNAME)) \
601 m_myInst.callCallback(Py_BuildValue("(ddi)", a,b,c)); \
602 else \
603 PCLASS::CBNAME(a, b, c); \
d559219f 604 wxPySaveThread(doSave); \
efc5f224 605 } \
d559219f 606 void CLASS::base_##CBNAME(double a, double b, int c) { \
efc5f224
RD
607 PCLASS::CBNAME(a, b, c); \
608 }
609
610//---------------------------------------------------------------------------
611
d559219f
RD
612#define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
613 void CBNAME(bool a, double b, double c, int d); \
614 void base_##CBNAME(bool a, double b, double c, int d);
615
616
617#define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
618 void CLASS::CBNAME(bool a, double b, double c, int d) { \
619 bool doSave = wxPyRestoreThread(); \
620 if (m_myInst.findCallback(#CBNAME)) \
621 m_myInst.callCallback(Py_BuildValue("(iddi)", (int)a,b,c,d)); \
622 else \
623 PCLASS::CBNAME(a, b, c, d); \
624 wxPySaveThread(doSave); \
625 } \
626 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
627 PCLASS::CBNAME(a, b, c, d); \
efc5f224
RD
628 }
629
630//---------------------------------------------------------------------------
631//---------------------------------------------------------------------------
389c5527
RD
632
633#define DEC_PYCALLBACK__STRING(CBNAME) \
634 void CBNAME(const wxString& a); \
635 void base_##CBNAME(const wxString& a);
636
637
638#define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
639 void CLASS::CBNAME(const wxString& a) { \
640 bool doSave = wxPyRestoreThread(); \
641 if (m_myInst.findCallback(#CBNAME)) \
642 m_myInst.callCallback(Py_BuildValue("(s)", a.c_str())); \
643 else \
644 PCLASS::CBNAME(a); \
645 wxPySaveThread(doSave); \
646 } \
647 void CLASS::base_##CBNAME(const wxString& a) { \
648 PCLASS::CBNAME(a); \
649 }
650
651//---------------------------------------------------------------------------
652
653#define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
654 bool CBNAME(const wxString& a); \
655 bool base_##CBNAME(const wxString& a);
656
657
658#define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
659 bool CLASS::CBNAME(const wxString& a) { \
660 bool rval; \
661 bool doSave = wxPyRestoreThread(); \
662 if (m_myInst.findCallback(#CBNAME)) \
663 rval = m_myInst.callCallback(Py_BuildValue("(s)", a.c_str())); \
664 else \
665 rval = PCLASS::CBNAME(a); \
666 wxPySaveThread(doSave); \
667 return rval; \
668 } \
669 bool CLASS::base_##CBNAME(const wxString& a) { \
670 return PCLASS::CBNAME(a); \
671 }
672
673//---------------------------------------------------------------------------
674
f0261a72
RD
675#define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
676 bool CBNAME(const wxString& a, const wxString& b); \
677 bool base_##CBNAME(const wxString& a, const wxString& b);
678
679
680#define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
681 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
682 bool rval; \
683 bool doSave = wxPyRestoreThread(); \
684 if (m_myInst.findCallback(#CBNAME)) \
685 rval = m_myInst.callCallback(Py_BuildValue("(ss)", \
686 a.c_str(), b.c_str())); \
687 else \
688 rval = PCLASS::CBNAME(a, b); \
689 wxPySaveThread(doSave); \
690 return rval; \
691 } \
692 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
693 return PCLASS::CBNAME(a, b); \
694 }
695
696//---------------------------------------------------------------------------
697
389c5527
RD
698#define DEC_PYCALLBACK_STRING_(CBNAME) \
699 wxString CBNAME(); \
700 wxString base_##CBNAME();
701
702
703#define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
704 wxString CLASS::CBNAME() { \
705 wxString rval; \
706 bool doSave = wxPyRestoreThread(); \
707 if (m_myInst.findCallback(#CBNAME)) { \
708 PyObject* ro; \
709 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
f6bcfd97
BP
710 if (ro) { \
711 rval = PyString_AsString(PyObject_Str(ro)); \
712 Py_DECREF(ro); \
713 } \
389c5527
RD
714 } \
715 else \
b1462dfa 716 rval = PCLASS::CBNAME(); \
389c5527
RD
717 wxPySaveThread(doSave); \
718 return rval; \
719 } \
b1462dfa
RD
720 wxString CLASS::base_##CBNAME() { \
721 return PCLASS::CBNAME(); \
389c5527
RD
722 }
723
724//---------------------------------------------------------------------------
725
726#define DEC_PYCALLBACK_STRING__pure(CBNAME) \
727 wxString CBNAME();
728
729
730#define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
731 wxString CLASS::CBNAME() { \
732 wxString rval; \
733 bool doSave = wxPyRestoreThread(); \
734 if (m_myInst.findCallback(#CBNAME)) { \
735 PyObject* ro; \
736 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
f6bcfd97
BP
737 if (ro) { \
738 rval = PyString_AsString(PyObject_Str(ro)); \
739 Py_DECREF(ro); \
740 } \
389c5527
RD
741 } \
742 wxPySaveThread(doSave); \
743 return rval; \
744 }
745
746//---------------------------------------------------------------------------
747
748#define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
749 bool CBNAME(const wxHtmlTag& a); \
750
751
752#define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
753 bool CLASS::CBNAME(const wxHtmlTag& a) { \
194fa2ac 754 bool rval = FALSE; \
389c5527
RD
755 bool doSave = wxPyRestoreThread(); \
756 if (m_myInst.findCallback(#CBNAME)) \
757 rval = m_myInst.callCallback(Py_BuildValue("(O)", \
758 wxPyConstructObject((void*)&a,"wxHtmlTag"))); \
759 wxPySaveThread(doSave); \
760 return rval; \
761 }
762
763//---------------------------------------------------------------------------
2f90df85
RD
764
765#define DEC_PYCALLBACK___pure(CBNAME) \
766 void CBNAME(); \
767
768
769#define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
770 void CLASS::CBNAME() { \
771 bool doSave = wxPyRestoreThread(); \
772 if (m_myInst.findCallback(#CBNAME)) \
773 m_myInst.callCallback(Py_BuildValue("()")); \
774 wxPySaveThread(doSave); \
775 }
776
777//---------------------------------------------------------------------------
778
779#define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
780 wxSize CBNAME(); \
781
782
783#define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
784 wxSize CLASS::CBNAME() { \
785 wxSize rval(0,0); \
786 bool doSave = wxPyRestoreThread(); \
787 if (m_myInst.findCallback(#CBNAME)) { \
788 PyObject* ro; \
789 wxSize* ptr; \
790 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
f6bcfd97
BP
791 if (ro) { \
792 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \
793 rval = *ptr; \
794 Py_DECREF(ro); \
795 } \
2f90df85
RD
796 } \
797 wxPySaveThread(doSave); \
798 return rval; \
799 }
800
801//---------------------------------------------------------------------------
802
803#define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
804 bool CBNAME(wxWindow* a); \
805 bool base_##CBNAME(wxWindow* a);
806
807
808#define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
809 bool CLASS::CBNAME(wxWindow* a) { \
810 bool rval; \
811 bool doSave = wxPyRestoreThread(); \
812 if (m_myInst.findCallback(#CBNAME)) \
813 rval = m_myInst.callCallback(Py_BuildValue("(O)", \
814 wxPyConstructObject((void*)a,"wxWindow"))); \
815 else \
816 rval = PCLASS::CBNAME(a); \
817 wxPySaveThread(doSave); \
818 return rval; \
819 } \
820 bool CLASS::base_##CBNAME(wxWindow* a) { \
821 return PCLASS::CBNAME(a); \
822 }
823
389c5527 824//---------------------------------------------------------------------------
2f90df85
RD
825
826#define DEC_PYCALLBACK_BOOL_(CBNAME) \
827 bool CBNAME(); \
828 bool base_##CBNAME();
829
830
831#define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
832 bool CLASS::CBNAME() { \
833 bool rval; \
834 bool doSave = wxPyRestoreThread(); \
835 if (m_myInst.findCallback(#CBNAME)) \
836 rval = m_myInst.callCallback(Py_BuildValue("()")); \
837 else \
838 rval = PCLASS::CBNAME(); \
839 wxPySaveThread(doSave); \
840 return rval; \
841 } \
842 bool CLASS::base_##CBNAME() { \
843 return PCLASS::CBNAME(); \
844 }
845
b1462dfa
RD
846//---------------------------------------------------------------------------
847
848#define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
849 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \
850 wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def);
851
852
853#define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
854 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
855 bool doSave = wxPyRestoreThread(); \
856 int rval; \
857 if (m_myInst.findCallback(#CBNAME)) \
858 rval = m_myInst.callCallback(Py_BuildValue("(iii)", a,b,c));\
859 else \
860 rval = PCLASS::CBNAME(a, b, c); \
861 wxPySaveThread(doSave); \
862 return (wxDragResult)rval; \
863 } \
864 wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
865 return PCLASS::CBNAME(a, b, c); \
866 }
867
868//---------------------------------------------------------------------------
869
870#define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
871 bool CBNAME(wxDragResult a); \
872 bool base_##CBNAME(wxDragResult a);
873
874
875#define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
876 bool CLASS::CBNAME(wxDragResult a) { \
877 bool doSave = wxPyRestoreThread(); \
878 bool rval; \
879 if (m_myInst.findCallback(#CBNAME)) \
880 rval = m_myInst.callCallback(Py_BuildValue("(i)", a)); \
881 else \
882 rval = PCLASS::CBNAME(a); \
883 wxPySaveThread(doSave); \
884 return rval; \
885 } \
886 bool CLASS::base_##CBNAME(wxDragResult a) { \
887 return PCLASS::CBNAME(a); \
888 }
889
890//---------------------------------------------------------------------------
891
892#define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
893 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def);
894
895
896#define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
897 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
898 bool doSave = wxPyRestoreThread(); \
899 int rval; \
900 if (m_myInst.findCallback(#CBNAME)) \
901 rval = m_myInst.callCallback(Py_BuildValue("(iii)", a,b,c));\
902 wxPySaveThread(doSave); \
903 return (wxDragResult)rval; \
904 } \
905
906//---------------------------------------------------------------------------
907
908#define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
909 bool CBNAME(int a, int b, const wxString& c);
910
911
912#define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
913 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
914 bool rval; \
915 bool doSave = wxPyRestoreThread(); \
916 if (m_myInst.findCallback(#CBNAME)) \
917 rval = m_myInst.callCallback(Py_BuildValue("(iis)",a,b,c.c_str()));\
918 wxPySaveThread(doSave); \
919 return rval; \
920 } \
921
922//---------------------------------------------------------------------------
923
924#define DEC_PYCALLBACK_SIZET_(CBNAME) \
925 size_t CBNAME(); \
926 size_t base_##CBNAME();
927
928
929#define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
930 size_t CLASS::CBNAME() { \
931 size_t rval; \
932 bool doSave = wxPyRestoreThread(); \
933 if (m_myInst.findCallback(#CBNAME)) \
934 rval = m_myInst.callCallback(Py_BuildValue("()")); \
935 else \
936 rval = PCLASS::CBNAME(); \
937 wxPySaveThread(doSave); \
938 return rval; \
939 } \
940 size_t CLASS::base_##CBNAME() { \
941 return PCLASS::CBNAME(); \
942 }
943
944//---------------------------------------------------------------------------
945
946#define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
947 wxDataFormat CBNAME(); \
948 wxDataFormat base_##CBNAME();
949
950
951#define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
952 wxDataFormat CLASS::CBNAME(size_t a) { \
953 wxDataFormat rval; \
954 bool doSave = wxPyRestoreThread(); \
955 if (m_myInst.findCallback(#CBNAME)) { \
956 PyObject* ro; \
957 wxDataFormat* ptr; \
958 ro = m_myInst.callCallbackObj(Py_BuildValue("(i)", a)); \
f6bcfd97
BP
959 if (ro) { \
960 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxDataFormat_p")) \
961 rval = *ptr; \
962 Py_DECREF(ro); \
963 } \
b1462dfa
RD
964 } \
965 else \
966 rval = PCLASS::CBNAME(a); \
967 wxPySaveThread(doSave); \
968 return rval; \
969 } \
970 wxDataFormat CLASS::base_##CBNAME(size_t a) { \
971 return PCLASS::CBNAME(a); \
972 }
973
389c5527 974//---------------------------------------------------------------------------
f6bcfd97
BP
975
976#define DEC_PYCALLBACK__constany(CBNAME, Type) \
977 void CBNAME(const Type& a); \
978 void base_##CBNAME(const Type& a);
979
980
981#define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
982 void CLASS::CBNAME(const Type& a) { \
983 bool doSave = wxPyRestoreThread(); \
984 if (m_myInst.findCallback(#CBNAME)) \
985 m_myInst.callCallback(Py_BuildValue("(O)", \
986 wxPyConstructObject((void*)&a, #Type))); \
987 else \
988 PCLASS::CBNAME(a); \
989 wxPySaveThread(doSave); \
990 } \
991 void CLASS::base_##CBNAME(const Type& a) { \
992 PCLASS::CBNAME(a); \
993 }
994
995
996//---------------------------------------------------------------------------
997
998#define DEC_PYCALLBACK__any(CBNAME, Type) \
999 void CBNAME(Type& a); \
1000 void base_##CBNAME(Type& a);
1001
1002
1003#define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1004 void CLASS::CBNAME(Type& a) { \
1005 bool doSave = wxPyRestoreThread(); \
1006 if (m_myInst.findCallback(#CBNAME)) \
1007 m_myInst.callCallback(Py_BuildValue("(O)", \
1008 wxPyConstructObject(&a, #Type))); \
1009 else \
1010 PCLASS::CBNAME(a); \
1011 wxPySaveThread(doSave); \
1012 } \
1013 void CLASS::base_##CBNAME(Type& a) { \
1014 PCLASS::CBNAME(a); \
1015 }
1016
efc5f224 1017//---------------------------------------------------------------------------
f6bcfd97
BP
1018
1019#define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1020 bool CBNAME(Type& a); \
1021 bool base_##CBNAME(Type& a);
1022
1023
1024#define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
1025 bool CLASS::CBNAME(Type& a) { \
1026 bool rv; \
1027 bool doSave = wxPyRestoreThread(); \
1028 if (m_myInst.findCallback(#CBNAME)) \
1029 rv = m_myInst.callCallback(Py_BuildValue("(O)", \
1030 wxPyConstructObject(&a, #Type))); \
1031 else \
1032 rv = PCLASS::CBNAME(a); \
1033 wxPySaveThread(doSave); \
1034 return rv; \
1035 } \
1036 bool CLASS::base_##CBNAME(Type& a) { \
1037 return PCLASS::CBNAME(a); \
1038 }
1039
efc5f224
RD
1040//---------------------------------------------------------------------------
1041
7bf85405
RD
1042#endif
1043
efc5f224
RD
1044
1045
b1462dfa 1046