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