]> git.saurik.com Git - wxWidgets.git/blob - wxPython/include/wx/wxPython/wxPython_int.h
5cc05f5da54882bb9508cfe5b4b64d6c8efa7d5b
[wxWidgets.git] / wxPython / include / wx / wxPython / wxPython_int.h
1 ////////////////////////////////////////////////////////////////////////////
2 // Name: wxPython_int.h (int == internal)
3 // Purpose: Helper functions/classes for the wxPython extension module
4 // This header should only be inclued directly by those source
5 // modules included in the wx._core module. All others should
6 // include wx/wxPython/wxPython.h instead.
7 //
8 // Author: Robin Dunn
9 //
10 // Created: 1-July-1997
11 // RCS-ID: $Id$
12 // Copyright: (c) 1998 by Total Control Software
13 // Licence: wxWindows license
14 /////////////////////////////////////////////////////////////////////////////
15
16 #ifndef __wxp_helpers__
17 #define __wxp_helpers__
18
19 #include <wx/wx.h>
20
21 #include <wx/busyinfo.h>
22 #include <wx/caret.h>
23 #include <wx/choicebk.h>
24 #include <wx/clipbrd.h>
25 #include <wx/colordlg.h>
26 #include <wx/config.h>
27 #include <wx/cshelp.h>
28 #include <wx/dcmirror.h>
29 #include <wx/dcps.h>
30 #include <wx/dirctrl.h>
31 #include <wx/dirdlg.h>
32 #include <wx/dnd.h>
33 #include <wx/docview.h>
34 #include <wx/encconv.h>
35 #include <wx/fdrepdlg.h>
36 #include <wx/fileconf.h>
37 #include <wx/filesys.h>
38 #include <wx/fontdlg.h>
39 #include <wx/fs_inet.h>
40 #include <wx/fs_mem.h>
41 #include <wx/fs_zip.h>
42 #include <wx/gbsizer.h>
43 #include <wx/geometry.h>
44 #include <wx/htmllbox.h>
45 #include <wx/image.h>
46 #include <wx/imaglist.h>
47 #include <wx/intl.h>
48 #include <wx/laywin.h>
49 #include <wx/listbook.h>
50 #include <wx/minifram.h>
51 #include <wx/notebook.h>
52 #include <wx/print.h>
53 #include <wx/printdlg.h>
54 #include <wx/process.h>
55 #include <wx/progdlg.h>
56 #include <wx/sashwin.h>
57 #include <wx/spinbutt.h>
58 #include <wx/spinctrl.h>
59 #include <wx/splash.h>
60 #include <wx/splitter.h>
61 #include <wx/statline.h>
62 #include <wx/stream.h>
63 #include <wx/sysopt.h>
64 #include <wx/taskbar.h>
65 #include <wx/tglbtn.h>
66 #include <wx/tipwin.h>
67 #include <wx/toolbook.h>
68 #include <wx/tooltip.h>
69 #include <wx/treebook.h>
70 #include <wx/vlbox.h>
71 #include <wx/vscroll.h>
72 #include <wx/dateevt.h>
73 #include <wx/datectrl.h>
74
75
76
77 #ifdef _MSC_VER
78 # pragma warning(disable:4800)
79 # pragma warning(disable:4190)
80 #endif
81
82 #ifdef __WXMAC__ // avoid a bug in Carbon headers
83 #define scalb scalbn
84 #endif
85
86 //---------------------------------------------------------------------------
87
88 typedef unsigned char byte;
89 typedef wxPoint2DDouble wxPoint2D;
90
91 #ifndef SWIG_TYPE_TABLE
92 #define SWIG_TYPE_TABLE wxPython_type_table
93 #endif
94
95 #ifdef __WXGTK__
96 #define wxDEFAULT_STATUSBAR_STYLE wxST_SIZEGRIP|wxFULL_REPAINT_ON_RESIZE
97 #else
98 #define wxDEFAULT_STATUSBAR_STYLE wxST_SIZEGRIP
99 #endif
100
101
102 #ifndef wxPyUSE_EXPORTED_API
103
104 void __wxPyPreStart(PyObject*);
105 void __wxPyCleanup();
106 PyObject* __wxPySetDictionary(PyObject*, PyObject* args);
107 PyObject* __wxPyFixStockObjects(PyObject*, PyObject* args);
108
109 void wxSetDefaultPyEncoding(const char* encoding);
110 const char* wxGetDefaultPyEncoding();
111
112
113 void wxPyEventThunker(wxObject*, wxEvent& event);
114
115
116 bool wxPyCheckSwigType(const wxChar* className);
117 PyObject* wxPyConstructObject(void* ptr,
118 const wxChar* className,
119 int setThisOwn=0);
120 bool wxPyConvertSwigPtr(PyObject* obj, void **ptr,
121 const wxChar* className);
122 PyObject* wxPyMakeSwigPtr(void* ptr, const wxChar* classname);
123
124
125 PyObject* wx2PyString(const wxString& src);
126 wxString Py2wxString(PyObject* source);
127
128 PyObject* wxPyMake_wxObject(wxObject* source, bool setThisOwn, bool checkEvtHandler=true);
129 PyObject* wxPyMake_wxSizer(wxSizer* source, bool setThisOwn);
130 void wxPyPtrTypeMap_Add(const char* commonName, const char* ptrName);
131
132 PyObject* wxPy_ConvertList(wxListBase* list);
133 long wxPyGetWinHandle(wxWindow* win);
134
135 void wxPy_ReinitStockObjects(int pass);
136
137 bool wxPyInstance_Check(PyObject* obj);
138 bool wxPySwigInstance_Check(PyObject* obj);
139
140
141 #endif // wxPyUSE_EXPORTED_API
142 //---------------------------------------------------------------------------
143
144 // if we want to handle threads and Python threads are available...
145 #if defined(WXP_USE_THREAD) && defined(WITH_THREAD)
146 #define WXP_WITH_THREAD
147 #else // no Python threads...
148 #undef WXP_WITH_THREAD
149 #endif
150
151
152 // In Python 2.3 and later there are the PyGILState_* APIs that we can use for
153 // blocking threads when calling back into Python. Using them instead of my
154 // home-grown hacks greatly simplifies wxPyBeginBlockThreads and
155 // wxPyEndBlockThreads.
156 //
157 // Unfortunatly there is a bug somewhere when using these new APIs on Python
158 // 2.3. It manifests in Boa Constructor's debugger where it is unable to stop
159 // at breakpoints located in event handlers. I think that the cause may be
160 // something like the original PyThreadState for the main thread is not being
161 // restored for the callbacks, but I can't see where that could be
162 // happening... So we'll only activate this new change for Python 2.4+ :-(
163
164 #if PY_VERSION_HEX < 0x02040000
165 #define wxPyUSE_GIL_STATE 0
166 typedef bool wxPyBlock_t;
167 #else
168 #define wxPyUSE_GIL_STATE 1
169 typedef PyGILState_STATE wxPyBlock_t;
170 #endif
171
172
173 #ifndef wxPyUSE_EXPORTED_API
174
175 // For Python --> C++
176 PyThreadState* wxPyBeginAllowThreads();
177 void wxPyEndAllowThreads(PyThreadState* state);
178
179 // For C++ --> Python
180 wxPyBlock_t wxPyBeginBlockThreads();
181 void wxPyEndBlockThreads(wxPyBlock_t blocked);
182
183 #endif // wxPyUSE_EXPORTED_API
184
185
186 // A macro that will help to execute simple statments wrapped in
187 // StartBlock/EndBlockThreads calls
188 #define wxPyBLOCK_THREADS(stmt) \
189 { wxPyBlock_t blocked = wxPyBeginBlockThreads(); stmt; wxPyEndBlockThreads(blocked); }
190
191 // Raise the NotImplementedError exception (blocking threads)
192 #define wxPyRaiseNotImplemented() \
193 wxPyBLOCK_THREADS(PyErr_SetNone(PyExc_NotImplementedError))
194
195 // Raise any exception with a string value (blocking threads)
196 #define wxPyErr_SetString(err, str) \
197 wxPyBLOCK_THREADS(PyErr_SetString(err, str))
198
199
200 //---------------------------------------------------------------------------
201 // These are helpers used by the typemaps
202
203 #ifndef wxPyUSE_EXPORTED_API
204
205 wxString* wxString_in_helper(PyObject* source);
206
207 byte* byte_LIST_helper(PyObject* source);
208 int* int_LIST_helper(PyObject* source);
209 long* long_LIST_helper(PyObject* source);
210 char** string_LIST_helper(PyObject* source);
211 wxPoint* wxPoint_LIST_helper(PyObject* source, int* npoints);
212 wxBitmap** wxBitmap_LIST_helper(PyObject* source);
213 wxString* wxString_LIST_helper(PyObject* source);
214 wxAcceleratorEntry* wxAcceleratorEntry_LIST_helper(PyObject* source);
215 wxPen** wxPen_LIST_helper(PyObject* source);
216
217 bool wxSize_helper(PyObject* source, wxSize** obj);
218 bool wxPoint_helper(PyObject* source, wxPoint** obj);
219 bool wxRealPoint_helper(PyObject* source, wxRealPoint** obj);
220 bool wxRect_helper(PyObject* source, wxRect** obj);
221 bool wxColour_helper(PyObject* source, wxColour** obj);
222 bool wxPoint2D_helper(PyObject* source, wxPoint2D** obj);
223
224
225 bool wxPySimple_typecheck(PyObject* source, const wxChar* classname, int seqLen);
226 bool wxColour_typecheck(PyObject* source);
227
228 bool wxPyCheckForApp();
229
230
231 template<class T>
232 bool wxPyTwoIntItem_helper(PyObject* source, T** obj, const wxChar* name)
233 {
234 // If source is an object instance then it may already be the right type
235 if (wxPySwigInstance_Check(source)) {
236 T* ptr;
237 if (! wxPyConvertSwigPtr(source, (void **)&ptr, name))
238 goto error;
239 *obj = ptr;
240 return true;
241 }
242 // otherwise a 2-tuple of integers is expected
243 else if (PySequence_Check(source) && PyObject_Length(source) == 2) {
244 PyObject* o1 = PySequence_GetItem(source, 0);
245 PyObject* o2 = PySequence_GetItem(source, 1);
246 if (!PyNumber_Check(o1) || !PyNumber_Check(o2)) {
247 Py_DECREF(o1);
248 Py_DECREF(o2);
249 goto error;
250 }
251 **obj = T(PyInt_AsLong(o1), PyInt_AsLong(o2));
252 Py_DECREF(o1);
253 Py_DECREF(o2);
254 return true;
255 }
256
257 error:
258 wxString msg;
259 msg.Printf(wxT("Expected a 2-tuple of integers or a %s object."), name);
260 PyErr_SetString(PyExc_TypeError, msg.mb_str());
261 return false;
262 }
263
264
265
266 // Other helpful stuff
267 bool wxPy2int_seq_helper(PyObject* source, int* i1, int* i2);
268 bool wxPy4int_seq_helper(PyObject* source, int* i1, int* i2, int* i3, int* i4);
269
270 PyObject* wxArrayString2PyList_helper(const wxArrayString& arr);
271 PyObject* wxArrayInt2PyList_helper(const wxArrayInt& arr);
272
273 #endif // wxPyUSE_EXPORTED_API
274
275 //---------------------------------------------------------------------------
276
277 #if PYTHON_API_VERSION < 1009
278 #define PySequence_Fast_GET_ITEM(o, i) \
279 (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i))
280 #endif
281
282 #define RETURN_NONE() { Py_INCREF(Py_None); return Py_None; }
283 #define DECLARE_DEF_STRING(name) static const wxString wxPy##name(wx##name)
284 #define DECLARE_DEF_STRING2(name,val) static const wxString wxPy##name(val)
285
286 //---------------------------------------------------------------------------
287
288 #ifndef wxPyUSE_EXPORTED_API
289
290 class wxPyCallback : public wxObject {
291 DECLARE_ABSTRACT_CLASS(wxPyCallback)
292 public:
293 wxPyCallback(PyObject* func);
294 wxPyCallback(const wxPyCallback& other);
295 ~wxPyCallback();
296
297 void EventThunker(wxEvent& event);
298
299 PyObject* m_func;
300 };
301
302 #endif // wxPyUSE_EXPORTED_API
303 //---------------------------------------------------------------------------
304 //---------------------------------------------------------------------------
305 // These Event classes can be derived from in Python and passed through the
306 // event system without loosing anything. They do this by keeping a reference
307 // to themselves and some special case handling in wxPyCallback::EventThunker.
308
309
310
311 class wxPyEvtSelfRef {
312 public:
313 wxPyEvtSelfRef();
314 ~wxPyEvtSelfRef();
315
316 void SetSelf(PyObject* self, bool clone=false);
317 PyObject* GetSelf() const;
318 bool GetCloned() const { return m_cloned; }
319
320 protected:
321 PyObject* m_self;
322 bool m_cloned;
323 };
324
325
326 class wxPyEvent : public wxEvent, public wxPyEvtSelfRef {
327 DECLARE_ABSTRACT_CLASS(wxPyEvent)
328 public:
329 wxPyEvent(int winid=0, wxEventType commandType = wxEVT_NULL);
330 wxPyEvent(const wxPyEvent& evt);
331 ~wxPyEvent();
332
333 virtual wxEvent* Clone() const { return new wxPyEvent(*this); }
334 };
335
336
337 class wxPyCommandEvent : public wxCommandEvent, public wxPyEvtSelfRef {
338 DECLARE_ABSTRACT_CLASS(wxPyCommandEvent)
339 public:
340 wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0);
341 wxPyCommandEvent(const wxPyCommandEvent& evt);
342 ~wxPyCommandEvent();
343
344 virtual wxEvent* Clone() const { return new wxPyCommandEvent(*this); }
345 };
346
347
348
349 //----------------------------------------------------------------------
350 // Forward decalre a few things used in the exported API
351 class wxPyClientData;
352 class wxPyUserData;
353 class wxPyOORClientData;
354 class wxPyCBInputStream;
355
356 void wxPyClientData_dtor(wxPyClientData* self);
357 void wxPyUserData_dtor(wxPyUserData* self);
358 void wxPyOORClientData_dtor(wxPyOORClientData* self);
359 wxPyCBInputStream* wxPyCBInputStream_create(PyObject *py, bool block);
360 wxPyCBInputStream* wxPyCBInputStream_copy(wxPyCBInputStream* other);
361
362 //---------------------------------------------------------------------------
363 // Export a C API in a struct. Other modules will be able to load this from
364 // the wx.core module and will then have safe access to these functions, even if
365 // in another shared library.
366
367 class wxPyCallbackHelper;
368
369 struct wxPyCoreAPI {
370
371 bool (*p_wxPyCheckSwigType)(const wxChar* className);
372 PyObject* (*p_wxPyConstructObject)(void* ptr, const wxChar* className, int setThisOwn);
373 bool (*p_wxPyConvertSwigPtr)(PyObject* obj, void **ptr, const wxChar* className);
374 PyObject* (*p_wxPyMakeSwigPtr)(void* ptr, const wxChar* className);
375
376 PyThreadState* (*p_wxPyBeginAllowThreads)();
377 void (*p_wxPyEndAllowThreads)(PyThreadState* state);
378 wxPyBlock_t (*p_wxPyBeginBlockThreads)();
379 void (*p_wxPyEndBlockThreads)(wxPyBlock_t blocked);
380
381 PyObject* (*p_wxPy_ConvertList)(wxListBase* list);
382
383 wxString* (*p_wxString_in_helper)(PyObject* source);
384 wxString (*p_Py2wxString)(PyObject* source);
385 PyObject* (*p_wx2PyString)(const wxString& src);
386
387 byte* (*p_byte_LIST_helper)(PyObject* source);
388 int* (*p_int_LIST_helper)(PyObject* source);
389 long* (*p_long_LIST_helper)(PyObject* source);
390 char** (*p_string_LIST_helper)(PyObject* source);
391 wxPoint* (*p_wxPoint_LIST_helper)(PyObject* source, int* npoints);
392 wxBitmap** (*p_wxBitmap_LIST_helper)(PyObject* source);
393 wxString* (*p_wxString_LIST_helper)(PyObject* source);
394 wxAcceleratorEntry* (*p_wxAcceleratorEntry_LIST_helper)(PyObject* source);
395
396 bool (*p_wxSize_helper)(PyObject* source, wxSize** obj);
397 bool (*p_wxPoint_helper)(PyObject* source, wxPoint** obj);
398 bool (*p_wxRealPoint_helper)(PyObject* source, wxRealPoint** obj);
399 bool (*p_wxRect_helper)(PyObject* source, wxRect** obj);
400 bool (*p_wxColour_helper)(PyObject* source, wxColour** obj);
401 bool (*p_wxPoint2D_helper)(PyObject* source, wxPoint2DDouble** obj);
402
403
404 bool (*p_wxPySimple_typecheck)(PyObject* source, const wxChar* classname, int seqLen);
405 bool (*p_wxColour_typecheck)(PyObject* source);
406
407 void (*p_wxPyCBH_setCallbackInfo)(wxPyCallbackHelper& cbh, PyObject* self, PyObject* klass, int incref);
408 bool (*p_wxPyCBH_findCallback)(const wxPyCallbackHelper& cbh, const char* name);
409 int (*p_wxPyCBH_callCallback)(const wxPyCallbackHelper& cbh, PyObject* argTuple);
410 PyObject* (*p_wxPyCBH_callCallbackObj)(const wxPyCallbackHelper& cbh, PyObject* argTuple);
411 void (*p_wxPyCBH_delete)(wxPyCallbackHelper* cbh);
412
413 PyObject* (*p_wxPyMake_wxObject)(wxObject* source, bool setThisOwn, bool checkEvtHandler);
414 PyObject* (*p_wxPyMake_wxSizer)(wxSizer* source, bool setThisOwn);
415 void (*p_wxPyPtrTypeMap_Add)(const char* commonName, const char* ptrName);
416 bool (*p_wxPy2int_seq_helper)(PyObject* source, int* i1, int* i2);
417 bool (*p_wxPy4int_seq_helper)(PyObject* source, int* i1, int* i2, int* i3, int* i4);
418 PyObject* (*p_wxArrayString2PyList_helper)(const wxArrayString& arr);
419 PyObject* (*p_wxArrayInt2PyList_helper)(const wxArrayInt& arr);
420
421 void (*p_wxPyClientData_dtor)(wxPyClientData*);
422 void (*p_wxPyUserData_dtor)(wxPyUserData*);
423 void (*p_wxPyOORClientData_dtor)(wxPyOORClientData*);
424
425 wxPyCBInputStream* (*p_wxPyCBInputStream_create)(PyObject *py, bool block);
426 wxPyCBInputStream* (*p_wxPyCBInputStream_copy)(wxPyCBInputStream* other);
427
428 bool (*p_wxPyInstance_Check)(PyObject* obj);
429 bool (*p_wxPySwigInstance_Check)(PyObject* obj);
430
431 bool (*p_wxPyCheckForApp)();
432
433 };
434
435 #ifdef wxPyUSE_EXPORTED_API
436 // Notice that this is static, not extern. This is by design, each module
437 // needs one, but doesn't have to use it.
438 static wxPyCoreAPI* wxPyCoreAPIPtr = NULL;
439 inline wxPyCoreAPI* wxPyGetCoreAPIPtr();
440 #endif // wxPyUSE_EXPORTED_API
441
442 //---------------------------------------------------------------------------
443
444 // A wxObject that holds a reference to a Python object
445 class wxPyUserData : public wxObject {
446 public:
447 wxPyUserData(PyObject* obj) {
448 m_obj = obj;
449 Py_INCREF(m_obj);
450 }
451
452 ~wxPyUserData() {
453 #ifdef wxPyUSE_EXPORTED_API
454 wxPyGetCoreAPIPtr()->p_wxPyUserData_dtor(this);
455 #else
456 wxPyUserData_dtor(this);
457 #endif
458 }
459 PyObject* m_obj;
460 };
461
462
463 // A wxClientData that holds a refernece to a Python object
464 class wxPyClientData : public wxClientData {
465 public:
466 wxPyClientData(PyObject* obj, bool incref=true) {
467 m_obj = obj;
468 m_incRef = incref;
469 if (incref)
470 Py_INCREF(m_obj);
471 }
472 ~wxPyClientData() {
473
474 #ifdef wxPyUSE_EXPORTED_API
475 wxPyGetCoreAPIPtr()->p_wxPyClientData_dtor(this);
476 #else
477 wxPyClientData_dtor(this);
478 #endif
479 }
480 PyObject* m_obj;
481 bool m_incRef;
482 };
483
484
485 // Just like wxPyClientData, except when this object is destroyed it does some
486 // OOR magic on the Python Object.
487 class wxPyOORClientData : public wxPyClientData {
488 public:
489 wxPyOORClientData(PyObject* obj, bool incref=true)
490 : wxPyClientData(obj, incref) {}
491 ~wxPyOORClientData() {
492
493 #ifdef wxPyUSE_EXPORTED_API
494 wxPyGetCoreAPIPtr()->p_wxPyOORClientData_dtor(this);
495 #else
496 wxPyOORClientData_dtor(this);
497 #endif
498 }
499 };
500
501
502 //---------------------------------------------------------------------------
503 // A wxImageHandler that can be derived from in Python.
504 //
505
506 class wxPyImageHandler: public wxImageHandler {
507 protected:
508 PyObject *m_self;
509
510 // used for interning method names as PyStrings
511 static PyObject* m_DoCanRead_Name;
512 static PyObject* m_GetImageCount_Name;
513 static PyObject* m_LoadFile_Name;
514 static PyObject* m_SaveFile_Name;
515
516 // converstion helpers
517 PyObject* py_InputStream(wxInputStream* stream);
518 PyObject* py_Image(wxImage* image);
519 PyObject* py_OutputStream(wxOutputStream* stream);
520
521 public:
522 wxPyImageHandler();
523 ~wxPyImageHandler();
524 void _SetSelf(PyObject *self);
525
526 virtual bool LoadFile(wxImage* image, wxInputStream& stream,
527 bool verbose=true, int index=-1 );
528 virtual bool SaveFile(wxImage* image, wxOutputStream& stream,
529 bool verbose=true );
530 virtual int GetImageCount(wxInputStream& stream );
531 virtual bool DoCanRead(wxInputStream &stream);
532 };
533
534
535 //---------------------------------------------------------------------------
536 // This class holds an instance of a Python Shadow Class object and assists
537 // with looking up and invoking Python callback methods from C++ virtual
538 // method redirections. For all classes which have virtuals which should be
539 // overridable in wxPython, a new subclass is created that contains a
540 // wxPyCallbackHelper.
541 //
542
543 class wxPyCallbackHelper {
544 public:
545 wxPyCallbackHelper(const wxPyCallbackHelper& other);
546
547 wxPyCallbackHelper() {
548 m_class = NULL;
549 m_self = NULL;
550 m_lastFound = NULL;
551 m_incRef = false;
552 }
553
554 ~wxPyCallbackHelper() {
555 #ifdef wxPyUSE_EXPORTED_API
556 wxPyGetCoreAPIPtr()->p_wxPyCBH_delete(this);
557 #else
558 wxPyCBH_delete(this);
559 #endif
560 }
561
562 void setSelf(PyObject* self, PyObject* klass, int incref=true);
563 bool findCallback(const char* name) const;
564 int callCallback(PyObject* argTuple) const;
565 PyObject* callCallbackObj(PyObject* argTuple) const;
566 PyObject* GetLastFound() const { return m_lastFound; }
567
568 private:
569 PyObject* m_self;
570 PyObject* m_class;
571 PyObject* m_lastFound;
572 int m_incRef;
573
574 friend void wxPyCBH_delete(wxPyCallbackHelper* cbh);
575 };
576
577
578 void wxPyCBH_setCallbackInfo(wxPyCallbackHelper& cbh, PyObject* self, PyObject* klass, int incref);
579 bool wxPyCBH_findCallback(const wxPyCallbackHelper& cbh, const char* name);
580 int wxPyCBH_callCallback(const wxPyCallbackHelper& cbh, PyObject* argTuple);
581 PyObject* wxPyCBH_callCallbackObj(const wxPyCallbackHelper& cbh, PyObject* argTuple);
582 void wxPyCBH_delete(wxPyCallbackHelper* cbh);
583
584
585
586
587 //---------------------------------------------------------------------------
588
589 // This is used in C++ classes that need to be able to make callback to
590 // "overloaded" python methods
591
592 #define PYPRIVATE \
593 void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \
594 wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \
595 } \
596 private: wxPyCallbackHelper m_myInst
597
598
599 //---------------------------------------------------------------------------
600 // The wxPythonApp class
601
602 enum {
603 wxPYAPP_ASSERT_SUPPRESS = 1,
604 wxPYAPP_ASSERT_EXCEPTION = 2,
605 wxPYAPP_ASSERT_DIALOG = 4,
606 wxPYAPP_ASSERT_LOG = 8
607 };
608
609 class wxPyApp: public wxApp
610 {
611 DECLARE_ABSTRACT_CLASS(wxPyApp)
612
613 public:
614 wxPyApp();
615 ~wxPyApp();
616 bool OnInit();
617 int MainLoop();
618
619 int GetAssertMode() { return m_assertMode; }
620 void SetAssertMode(int mode) { m_assertMode = mode; }
621
622 virtual bool OnInitGui();
623 virtual int OnExit();
624 #ifdef __WXDEBUG__
625 virtual void OnAssert(const wxChar *file,
626 int line,
627 const wxChar *cond,
628 const wxChar *msg);
629 #endif
630 // virtual int FilterEvent(wxEvent& event); // This one too????
631
632 // For catching Apple Events
633 virtual void MacOpenFile(const wxString &fileName);
634 virtual void MacPrintFile(const wxString &fileName);
635 virtual void MacNewFile();
636 virtual void MacReopenApp();
637
638 static bool GetMacSupportPCMenuShortcuts();
639 static long GetMacAboutMenuItemId();
640 static long GetMacPreferencesMenuItemId();
641 static long GetMacExitMenuItemId();
642 static wxString GetMacHelpMenuTitleName();
643
644 static void SetMacSupportPCMenuShortcuts(bool val);
645 static void SetMacAboutMenuItemId(long val);
646 static void SetMacPreferencesMenuItemId(long val);
647 static void SetMacExitMenuItemId(long val);
648 static void SetMacHelpMenuTitleName(const wxString& val);
649
650
651 void _BootstrapApp();
652
653 // implementation only
654 void SetStartupComplete(bool val) { m_startupComplete = val; };
655
656 PYPRIVATE;
657 int m_assertMode;
658 bool m_startupComplete;
659 };
660
661 extern wxPyApp *wxPythonApp;
662
663
664 //----------------------------------------------------------------------
665 // These macros are used to implement the virtual methods that should
666 // redirect to a Python method if one exists. The names designate the
667 // return type, if any, as well as any parameter types.
668 //---------------------------------------------------------------------------
669
670 #define DEC_PYCALLBACK__(CBNAME) \
671 void CBNAME(); \
672 void base_##CBNAME()
673
674
675 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
676 void CLASS::CBNAME() { \
677 bool found; \
678 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
679 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
680 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
681 wxPyEndBlockThreads(blocked); \
682 if (! found) \
683 PCLASS::CBNAME(); \
684 } \
685 void CLASS::base_##CBNAME() { \
686 PCLASS::CBNAME(); \
687 }
688
689 //---------------------------------------------------------------------------
690
691 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
692 bool CBNAME(int a, int b); \
693 bool base_##CBNAME(int a, int b)
694
695
696 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
697 bool CLASS::CBNAME(int a, int b) { \
698 bool rval=false, found; \
699 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
700 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
701 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
702 wxPyEndBlockThreads(blocked); \
703 if (! found) \
704 rval = PCLASS::CBNAME(a,b); \
705 return rval; \
706 } \
707 bool CLASS::base_##CBNAME(int a, int b) { \
708 return PCLASS::CBNAME(a,b); \
709 }
710
711 //---------------------------------------------------------------------------
712
713 #define DEC_PYCALLBACK_VOID_(CBNAME) \
714 void CBNAME(); \
715 void base_##CBNAME()
716
717
718 #define IMP_PYCALLBACK_VOID_(CLASS, PCLASS, CBNAME) \
719 void CLASS::CBNAME() { \
720 bool found; \
721 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
722 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
723 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
724 wxPyEndBlockThreads(blocked); \
725 if (! found) \
726 PCLASS::CBNAME(); \
727 } \
728 void CLASS::base_##CBNAME() { \
729 PCLASS::CBNAME(); \
730 }
731
732 //---------------------------------------------------------------------------
733
734 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
735 void CBNAME(int a, int b); \
736 void base_##CBNAME(int a, int b)
737
738
739 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
740 void CLASS::CBNAME(int a, int b) { \
741 bool found; \
742 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
743 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
744 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
745 wxPyEndBlockThreads(blocked); \
746 if (! found) \
747 PCLASS::CBNAME(a,b); \
748 } \
749 void CLASS::base_##CBNAME(int a, int b) { \
750 PCLASS::CBNAME(a,b); \
751 }
752
753 //---------------------------------------------------------------------------
754
755 #define DEC_PYCALLBACK_VOID_INT(CBNAME) \
756 void CBNAME(int a); \
757 void base_##CBNAME(int a)
758
759
760 #define IMP_PYCALLBACK_VOID_INT(CLASS, PCLASS, CBNAME) \
761 void CLASS::CBNAME(int a) { \
762 bool found; \
763 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
764 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
765 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
766 wxPyEndBlockThreads(blocked); \
767 if (! found) \
768 PCLASS::CBNAME(a); \
769 } \
770 void CLASS::base_##CBNAME(int a) { \
771 PCLASS::CBNAME(a); \
772 }
773
774 //---------------------------------------------------------------------------
775
776 #define DEC_PYCALLBACK_VOID_INT4(CBNAME) \
777 void CBNAME(int a, int b, int c, int d); \
778 void base_##CBNAME(int a, int b, int c, int d)
779
780
781 #define IMP_PYCALLBACK_VOID_INT4(CLASS, PCLASS, CBNAME) \
782 void CLASS::CBNAME(int a, int b, int c, int d) { \
783 bool found; \
784 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
785 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
786 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiii)",a,b,c,d)); \
787 wxPyEndBlockThreads(blocked); \
788 if (! found) \
789 PCLASS::CBNAME(a,b,c,d); \
790 } \
791 void CLASS::base_##CBNAME(int a, int b, int c, int d) { \
792 PCLASS::CBNAME(a,b,c,d); \
793 }
794
795 //---------------------------------------------------------------------------
796 #define DEC_PYCALLBACK_VOID_INT5(CBNAME) \
797 void CBNAME(int a, int b, int c, int d, int e); \
798 void base_##CBNAME(int a, int b, int c, int d, int e)
799
800
801 #define IMP_PYCALLBACK_VOID_INT5(CLASS, PCLASS, CBNAME) \
802 void CLASS::CBNAME(int a, int b, int c, int d, int e) { \
803 bool found; \
804 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
805 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
806 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiiii)",a,b,c,d,e)); \
807 wxPyEndBlockThreads(blocked); \
808 if (! found) \
809 PCLASS::CBNAME(a,b,c,d,e); \
810 } \
811 void CLASS::base_##CBNAME(int a, int b, int c, int d, int e) { \
812 PCLASS::CBNAME(a,b,c,d,e); \
813 }
814
815 //---------------------------------------------------------------------------
816
817 #define DEC_PYCALLBACK_VOID_INTPINTP_const(CBNAME) \
818 void CBNAME(int* a, int* b) const; \
819 void base_##CBNAME(int* a, int* b) const
820
821
822 #define IMP_PYCALLBACK_VOID_INTPINTP_const(CLASS, PCLASS, CBNAME) \
823 void CLASS::CBNAME(int* a, int* b) const { \
824 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
825 bool found; \
826 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
827 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
828 PyObject* ro; \
829 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
830 if (ro) { \
831 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
832 PyObject* o1 = PySequence_GetItem(ro, 0); \
833 PyObject* o2 = PySequence_GetItem(ro, 1); \
834 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
835 *a = PyInt_AsLong(o1); *b = PyInt_AsLong(o2); \
836 } \
837 else \
838 PyErr_SetString(PyExc_TypeError, errmsg); \
839 Py_DECREF(o1); \
840 Py_DECREF(o2); \
841 } \
842 else { \
843 PyErr_SetString(PyExc_TypeError, errmsg); \
844 } \
845 Py_DECREF(ro); \
846 } \
847 } \
848 wxPyEndBlockThreads(blocked); \
849 if (! found) \
850 PCLASS::CBNAME(a,b); \
851 } \
852 void CLASS::base_##CBNAME(int* a, int* b) const { \
853 PCLASS::CBNAME(a,b); \
854 }
855
856
857 //---------------------------------------------------------------------------
858
859 #define DEC_PYCALLBACK_SIZE_const(CBNAME) \
860 wxSize CBNAME() const; \
861 wxSize base_##CBNAME() const
862
863
864 #define IMP_PYCALLBACK_SIZE_const(CLASS, PCLASS, CBNAME) \
865 wxSize CLASS::CBNAME() const { \
866 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
867 bool found; wxSize rval(0,0); \
868 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
869 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
870 PyObject* ro; \
871 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
872 if (ro) { \
873 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
874 PyObject* o1 = PySequence_GetItem(ro, 0); \
875 PyObject* o2 = PySequence_GetItem(ro, 1); \
876 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
877 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
878 } \
879 else \
880 PyErr_SetString(PyExc_TypeError, errmsg); \
881 Py_DECREF(o1); \
882 Py_DECREF(o2); \
883 } \
884 else { \
885 PyErr_SetString(PyExc_TypeError, errmsg); \
886 } \
887 Py_DECREF(ro); \
888 } \
889 } \
890 wxPyEndBlockThreads(blocked); \
891 if (! found) \
892 return PCLASS::CBNAME(); \
893 else \
894 return rval; \
895 } \
896 wxSize CLASS::base_##CBNAME() const { \
897 return PCLASS::CBNAME(); \
898 }
899
900
901 //---------------------------------------------------------------------------
902
903 #define DEC_PYCALLBACK_BOOL_BOOL(CBNAME) \
904 bool CBNAME(bool a); \
905 bool base_##CBNAME(bool a)
906
907
908 #define IMP_PYCALLBACK_BOOL_BOOL(CLASS, PCLASS, CBNAME) \
909 bool CLASS::CBNAME(bool a) { \
910 bool rval=false, found; \
911 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
912 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
913 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
914 wxPyEndBlockThreads(blocked); \
915 if (! found) \
916 rval = PCLASS::CBNAME(a); \
917 return rval; \
918 } \
919 bool CLASS::base_##CBNAME(bool a) { \
920 return PCLASS::CBNAME(a); \
921 }
922
923 //---------------------------------------------------------------------------
924
925 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
926 bool CBNAME(int a); \
927 bool base_##CBNAME(int a)
928
929
930 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
931 bool CLASS::CBNAME(int a) { \
932 bool rval=false, found; \
933 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
934 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
935 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
936 wxPyEndBlockThreads(blocked); \
937 if (! found) \
938 rval = PCLASS::CBNAME(a); \
939 return rval; \
940 } \
941 bool CLASS::base_##CBNAME(int a) { \
942 return PCLASS::CBNAME(a); \
943 }
944
945 //---------------------------------------------------------------------------
946
947 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
948 bool CBNAME(int a)
949
950
951 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
952 bool CLASS::CBNAME(int a) { \
953 bool rval=false; \
954 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
955 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
956 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
957 else rval = false; \
958 wxPyEndBlockThreads(blocked); \
959 return rval; \
960 }
961
962
963 //---------------------------------------------------------------------------
964
965 #define DEC_PYCALLBACK__DC(CBNAME) \
966 void CBNAME(wxDC& a); \
967 void base_##CBNAME(wxDC& a)
968
969
970 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
971 void CLASS::CBNAME(wxDC& a) { \
972 bool found; \
973 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
974 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
975 PyObject* obj = wxPyMake_wxObject(&a,false); \
976 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
977 Py_DECREF(obj); \
978 } \
979 wxPyEndBlockThreads(blocked); \
980 if (! found) \
981 PCLASS::CBNAME(a); \
982 } \
983 void CLASS::base_##CBNAME(wxDC& a) { \
984 PCLASS::CBNAME(a); \
985 }
986
987
988
989 //---------------------------------------------------------------------------
990
991 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
992 void CBNAME(wxDC& a, bool b); \
993 void base_##CBNAME(wxDC& a, bool b)
994
995
996 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
997 void CLASS::CBNAME(wxDC& a, bool b) { \
998 bool found; \
999 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1000 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1001 PyObject* obj = wxPyMake_wxObject(&a,false); \
1002 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
1003 Py_DECREF(obj); \
1004 } \
1005 wxPyEndBlockThreads(blocked); \
1006 if (! found) \
1007 PCLASS::CBNAME(a, b); \
1008 } \
1009 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
1010 PCLASS::CBNAME(a, b); \
1011 }
1012
1013 //---------------------------------------------------------------------------
1014
1015 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
1016 void CBNAME(wxDC& a, bool b); \
1017 void base_##CBNAME(wxDC& a, bool b)
1018
1019
1020 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
1021 void CLASS::CBNAME(wxDC& a, bool b) { \
1022 bool found; \
1023 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1024 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1025 PyObject* obj = wxPyMake_wxObject(&a,false); \
1026 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
1027 Py_DECREF(obj); \
1028 } \
1029 wxPyEndBlockThreads(blocked); \
1030 if (! found) \
1031 PCLASS::CBNAME(a, b); \
1032 } \
1033 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
1034 PCLASS::CBNAME(a, b); \
1035 }
1036
1037 //---------------------------------------------------------------------------
1038
1039 #define DEC_PYCALLBACK__2DBL(CBNAME) \
1040 void CBNAME(double a, double b); \
1041 void base_##CBNAME(double a, double b)
1042
1043
1044 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
1045 void CLASS::CBNAME(double a, double b) { \
1046 bool found; \
1047 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1048 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1049 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
1050 wxPyEndBlockThreads(blocked); \
1051 if (! found) \
1052 PCLASS::CBNAME(a, b); \
1053 } \
1054 void CLASS::base_##CBNAME(double a, double b) { \
1055 PCLASS::CBNAME(a, b); \
1056 }
1057
1058 //---------------------------------------------------------------------------
1059
1060 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
1061 void CBNAME(double a, double b, int c, int d); \
1062 void base_##CBNAME(double a, double b, int c, int d)
1063
1064
1065 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
1066 void CLASS::CBNAME(double a, double b, int c, int d) { \
1067 bool found; \
1068 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1069 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1070 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
1071 a,b,c,d)); \
1072 wxPyEndBlockThreads(blocked); \
1073 if (! found) \
1074 PCLASS::CBNAME(a, b, c, d); \
1075 } \
1076 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
1077 PCLASS::CBNAME(a, b, c, d); \
1078 }
1079
1080 //---------------------------------------------------------------------------
1081
1082 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
1083 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
1084 void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1085
1086
1087 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1088 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1089 bool found; \
1090 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1091 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1092 PyObject* obj = wxPyMake_wxObject(&a,false); \
1093 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
1094 Py_DECREF(obj); \
1095 } \
1096 wxPyEndBlockThreads(blocked); \
1097 if (! found) \
1098 PCLASS::CBNAME(a, b, c, d, e, f); \
1099 } \
1100 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
1101 PCLASS::CBNAME(a, b, c, d, e, f); \
1102 }
1103
1104 //---------------------------------------------------------------------------
1105
1106 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
1107 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
1108 bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1109
1110
1111 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1112 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1113 bool found; \
1114 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1115 bool rval=false; \
1116 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1117 PyObject* obj = wxPyMake_wxObject(&a,false); \
1118 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
1119 Py_DECREF(obj); \
1120 } \
1121 wxPyEndBlockThreads(blocked); \
1122 if (! found) \
1123 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
1124 return rval; \
1125 } \
1126 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
1127 return PCLASS::CBNAME(a, b, c, d, e, f); \
1128 }
1129
1130 //---------------------------------------------------------------------------
1131
1132 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
1133 void CBNAME(bool a, double b, double c, int d, int e); \
1134 void base_##CBNAME(bool a, double b, double c, int d, int e)
1135
1136
1137 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1138 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
1139 bool found; \
1140 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1141 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1142 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
1143 (int)a,b,c,d,e)); \
1144 wxPyEndBlockThreads(blocked); \
1145 if (! found) \
1146 PCLASS::CBNAME(a, b, c, d, e); \
1147 } \
1148 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
1149 PCLASS::CBNAME(a, b, c, d, e); \
1150 }
1151
1152 //---------------------------------------------------------------------------
1153
1154 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
1155 void CBNAME(wxDC& a, double b, double c, double d, double e); \
1156 void base_##CBNAME(wxDC& a, double b, double c, double d, double e)
1157
1158
1159 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
1160 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
1161 bool found; \
1162 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1163 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1164 PyObject* obj = wxPyMake_wxObject(&a,false); \
1165 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
1166 Py_DECREF(obj); \
1167 } \
1168 wxPyEndBlockThreads(blocked); \
1169 if (! found) \
1170 PCLASS::CBNAME(a, b, c, d, e); \
1171 } \
1172 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
1173 PCLASS::CBNAME(a, b, c, d, e); \
1174 }
1175
1176 //---------------------------------------------------------------------------
1177
1178 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
1179 void CBNAME(wxDC& a, bool b); \
1180 void base_##CBNAME(wxDC& a, bool b)
1181
1182
1183 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
1184 void CLASS::CBNAME(wxDC& a, bool b) { \
1185 bool found; \
1186 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1187 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1188 PyObject* obj = wxPyMake_wxObject(&a,false); \
1189 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
1190 Py_DECREF(obj); \
1191 } \
1192 wxPyEndBlockThreads(blocked); \
1193 if (! found) \
1194 PCLASS::CBNAME(a, b); \
1195 } \
1196 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
1197 PCLASS::CBNAME(a, b); \
1198 }
1199
1200 //---------------------------------------------------------------------------
1201
1202 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
1203 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
1204 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f)
1205
1206
1207 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1208 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
1209 int e, int f) { \
1210 bool found; \
1211 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1212 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1213 PyObject* obj = wxPyMake_wxObject(a,false); \
1214 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
1215 Py_DECREF(obj); \
1216 } \
1217 wxPyEndBlockThreads(blocked); \
1218 if (! found) \
1219 PCLASS::CBNAME(a, b, c, d, e, f); \
1220 } \
1221 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
1222 int e, int f) { \
1223 PCLASS::CBNAME(a, b, c, d, e, f); \
1224 }
1225
1226 //---------------------------------------------------------------------------
1227
1228 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
1229 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
1230 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e)
1231
1232
1233 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
1234 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
1235 bool found; \
1236 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1237 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1238 PyObject* obj = wxPyMake_wxObject(a,false); \
1239 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
1240 Py_DECREF(obj); \
1241 } \
1242 wxPyEndBlockThreads(blocked); \
1243 if (! found) \
1244 PCLASS::CBNAME(a, b, c, d, e); \
1245 } \
1246 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
1247 int d, int e) { \
1248 PCLASS::CBNAME(a, b, c, d, e); \
1249 }
1250
1251 //---------------------------------------------------------------------------
1252
1253 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
1254 void CBNAME(double a, double b, int c); \
1255 void base_##CBNAME(double a, double b, int c)
1256
1257
1258 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
1259 void CLASS::CBNAME(double a, double b, int c) { \
1260 bool found; \
1261 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1262 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1263 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
1264 wxPyEndBlockThreads(blocked); \
1265 if (! found) \
1266 PCLASS::CBNAME(a, b, c); \
1267 } \
1268 void CLASS::base_##CBNAME(double a, double b, int c) { \
1269 PCLASS::CBNAME(a, b, c); \
1270 }
1271
1272 //---------------------------------------------------------------------------
1273
1274 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
1275 void CBNAME(bool a, double b, double c, int d); \
1276 void base_##CBNAME(bool a, double b, double c, int d)
1277
1278
1279 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
1280 void CLASS::CBNAME(bool a, double b, double c, int d) { \
1281 bool found; \
1282 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1283 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1284 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\
1285 wxPyEndBlockThreads(blocked); \
1286 if (! found) \
1287 PCLASS::CBNAME(a, b, c, d); \
1288 } \
1289 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
1290 PCLASS::CBNAME(a, b, c, d); \
1291 }
1292
1293 //---------------------------------------------------------------------------
1294 //---------------------------------------------------------------------------
1295
1296 #define DEC_PYCALLBACK__STRING(CBNAME) \
1297 void CBNAME(const wxString& a); \
1298 void base_##CBNAME(const wxString& a)
1299
1300 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
1301 void CLASS::CBNAME(const wxString& a) { \
1302 bool found; \
1303 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1304 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1305 PyObject* s = wx2PyString(a); \
1306 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1307 Py_DECREF(s); \
1308 } \
1309 wxPyEndBlockThreads(blocked); \
1310 if (! found) \
1311 PCLASS::CBNAME(a); \
1312 } \
1313 void CLASS::base_##CBNAME(const wxString& a) { \
1314 PCLASS::CBNAME(a); \
1315 }
1316
1317 //---------------------------------------------------------------------------
1318
1319 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
1320 bool CBNAME(const wxString& a); \
1321 bool base_##CBNAME(const wxString& a)
1322
1323 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
1324 bool CLASS::CBNAME(const wxString& a) { \
1325 bool rval=false; \
1326 bool found; \
1327 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1328 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1329 PyObject* s = wx2PyString(a); \
1330 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1331 Py_DECREF(s); \
1332 } \
1333 wxPyEndBlockThreads(blocked); \
1334 if (! found) \
1335 rval = PCLASS::CBNAME(a); \
1336 return rval; \
1337 } \
1338 bool CLASS::base_##CBNAME(const wxString& a) { \
1339 return PCLASS::CBNAME(a); \
1340 }
1341
1342 //---------------------------------------------------------------------------
1343
1344 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
1345 bool CBNAME(const wxString& a)
1346
1347 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
1348 bool CLASS::CBNAME(const wxString& a) { \
1349 bool rval=false; \
1350 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1351 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1352 PyObject* s = wx2PyString(a); \
1353 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1354 Py_DECREF(s); \
1355 } \
1356 wxPyEndBlockThreads(blocked); \
1357 return rval; \
1358 } \
1359
1360 //---------------------------------------------------------------------------
1361
1362 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
1363 wxString CBNAME(const wxString& a)
1364
1365 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
1366 wxString CLASS::CBNAME(const wxString& a) { \
1367 wxString rval; \
1368 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1369 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1370 PyObject* ro; \
1371 PyObject* s = wx2PyString(a); \
1372 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1373 Py_DECREF(s); \
1374 if (ro) { \
1375 rval = Py2wxString(ro); \
1376 Py_DECREF(ro); \
1377 } \
1378 } \
1379 wxPyEndBlockThreads(blocked); \
1380 return rval; \
1381 } \
1382
1383 //---------------------------------------------------------------------------
1384
1385 #define DEC_PYCALLBACK_STRING_STRING(CBNAME) \
1386 wxString CBNAME(const wxString& a); \
1387 wxString base_##CBNAME(const wxString& a)
1388
1389 #define IMP_PYCALLBACK_STRING_STRING(CLASS, PCLASS, CBNAME) \
1390 wxString CLASS::CBNAME(const wxString& a) { \
1391 wxString rval; \
1392 bool found; \
1393 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1394 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1395 PyObject* ro; \
1396 PyObject* s = wx2PyString(a); \
1397 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1398 Py_DECREF(s); \
1399 if (ro) { \
1400 rval = Py2wxString(ro); \
1401 Py_DECREF(ro); \
1402 } \
1403 } \
1404 if (! found) \
1405 rval = PCLASS::CBNAME(a); \
1406 wxPyEndBlockThreads(blocked); \
1407 return rval; \
1408 } \
1409
1410 //---------------------------------------------------------------------------
1411
1412 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
1413 wxString CBNAME(const wxString& a,int b)
1414
1415 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
1416 wxString CLASS::CBNAME(const wxString& a,int b) { \
1417 wxString rval; \
1418 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1419 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1420 PyObject* ro; \
1421 PyObject* s = wx2PyString(a); \
1422 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oi)",s,b)); \
1423 Py_DECREF(s); \
1424 if (ro) { \
1425 rval = Py2wxString(ro); \
1426 Py_DECREF(ro); \
1427 } \
1428 } \
1429 wxPyEndBlockThreads(blocked); \
1430 return rval; \
1431 } \
1432
1433 //---------------------------------------------------------------------------
1434
1435 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
1436 bool CBNAME(const wxString& a, const wxString& b); \
1437 bool base_##CBNAME(const wxString& a, const wxString& b)
1438
1439 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
1440 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
1441 bool rval=false; \
1442 bool found; \
1443 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1444 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1445 PyObject* s1 = wx2PyString(a); \
1446 PyObject* s2 = wx2PyString(b); \
1447 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",s1,s2)); \
1448 Py_DECREF(s1); \
1449 Py_DECREF(s2); \
1450 } \
1451 wxPyEndBlockThreads(blocked); \
1452 if (! found) \
1453 rval = PCLASS::CBNAME(a, b); \
1454 return rval; \
1455 } \
1456 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
1457 return PCLASS::CBNAME(a, b); \
1458 }
1459
1460 //---------------------------------------------------------------------------
1461
1462 #define DEC_PYCALLBACK_STRING_(CBNAME) \
1463 wxString CBNAME(); \
1464 wxString base_##CBNAME()
1465
1466 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
1467 wxString CLASS::CBNAME() { \
1468 wxString rval; \
1469 bool found; \
1470 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1471 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1472 PyObject* ro; \
1473 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1474 if (ro) { \
1475 rval = Py2wxString(ro); \
1476 Py_DECREF(ro); \
1477 } \
1478 } \
1479 wxPyEndBlockThreads(blocked); \
1480 if (! found) \
1481 rval = PCLASS::CBNAME(); \
1482 return rval; \
1483 } \
1484 wxString CLASS::base_##CBNAME() { \
1485 return PCLASS::CBNAME(); \
1486 }
1487
1488 //---------------------------------------------------------------------------
1489
1490 #define DEC_PYCALLBACK_STRING__const(CBNAME) \
1491 wxString CBNAME() const; \
1492 wxString base_##CBNAME() const;
1493
1494 #define IMP_PYCALLBACK_STRING__const(CLASS, PCLASS, CBNAME) \
1495 wxString CLASS::CBNAME() const { \
1496 wxString rval; \
1497 bool found; \
1498 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1499 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1500 PyObject* ro; \
1501 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1502 if (ro) { \
1503 rval = Py2wxString(ro); \
1504 Py_DECREF(ro); \
1505 } \
1506 } \
1507 wxPyEndBlockThreads(blocked); \
1508 if (! found) \
1509 rval = PCLASS::CBNAME(); \
1510 return rval; \
1511 } \
1512 wxString CLASS::base_##CBNAME() const { \
1513 return PCLASS::CBNAME(); \
1514 }
1515
1516 //---------------------------------------------------------------------------
1517
1518 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
1519 wxString CBNAME()
1520
1521 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
1522 wxString CLASS::CBNAME() { \
1523 wxString rval; \
1524 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1525 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1526 PyObject* ro; \
1527 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1528 if (ro) { \
1529 rval = Py2wxString(ro); \
1530 Py_DECREF(ro); \
1531 } \
1532 } \
1533 wxPyEndBlockThreads(blocked); \
1534 return rval; \
1535 }
1536
1537 //---------------------------------------------------------------------------
1538
1539 #define DEC_PYCALLBACK_STRING__constpure(CBNAME) \
1540 wxString CBNAME() const;
1541
1542 #define IMP_PYCALLBACK_STRING__constpure(CLASS, PCLASS, CBNAME) \
1543 wxString CLASS::CBNAME() const { \
1544 wxString rval; \
1545 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1546 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1547 PyObject* ro; \
1548 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1549 if (ro) { \
1550 rval = Py2wxString(ro); \
1551 Py_DECREF(ro); \
1552 } \
1553 } \
1554 wxPyEndBlockThreads(blocked); \
1555 return rval; \
1556 }
1557
1558 //---------------------------------------------------------------------------
1559
1560 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
1561 bool CBNAME(const wxHtmlTag& a)
1562
1563
1564 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
1565 bool CLASS::CBNAME(const wxHtmlTag& a) { \
1566 bool rval=false; \
1567 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1568 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1569 PyObject* obj = wxPyConstructObject((void*)&a, wxT("wxHtmlTag"), 0);\
1570 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1571 Py_DECREF(obj); \
1572 } \
1573 wxPyEndBlockThreads(blocked); \
1574 return rval; \
1575 }
1576
1577 //---------------------------------------------------------------------------
1578
1579 #define DEC_PYCALLBACK__CELLINTINT(CBNAME) \
1580 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y); \
1581 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y)
1582
1583 #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \
1584 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1585 bool found; \
1586 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1587 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1588 PyObject* obj = wxPyConstructObject((void*)cell, wxT("wxHtmlCell"), 0); \
1589 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \
1590 Py_DECREF(obj); \
1591 } \
1592 wxPyEndBlockThreads(blocked); \
1593 if (! found) \
1594 PCLASS::CBNAME(cell, x, y); \
1595 } \
1596 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1597 PCLASS::CBNAME(cell, x, y); \
1598 }
1599
1600 //---------------------------------------------------------------------------
1601
1602 #define DEC_PYCALLBACK__COLOUR(CBNAME) \
1603 void CBNAME(const wxColour& c); \
1604 void base_##CBNAME(const wxColour& c)
1605
1606 #define IMP_PYCALLBACK__COLOUR(CLASS, PCLASS, CBNAME) \
1607 void CLASS::CBNAME(const wxColour& c) { \
1608 bool found; \
1609 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1610 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1611 PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxColour"), 0); \
1612 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
1613 Py_DECREF(obj); \
1614 } \
1615 wxPyEndBlockThreads(blocked); \
1616 if (! found) \
1617 PCLASS::CBNAME(c); \
1618 } \
1619 void CLASS::base_##CBNAME(const wxColour& c) { \
1620 PCLASS::CBNAME(c); \
1621 }
1622
1623 //---------------------------------------------------------------------------
1624
1625 #define DEC_PYCALLBACK__CELLINTINTME(CBNAME) \
1626 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e); \
1627 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e)
1628
1629 #define IMP_PYCALLBACK__CELLINTINTME(CLASS, PCLASS, CBNAME) \
1630 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1631 bool found; \
1632 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1633 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1634 PyObject* obj = wxPyConstructObject((void*)cell, wxT("wxHtmlCell"), 0); \
1635 PyObject* o2 = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
1636 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1637 Py_DECREF(obj); \
1638 Py_DECREF(o2); \
1639 } \
1640 wxPyEndBlockThreads(blocked); \
1641 if (! found) \
1642 PCLASS::CBNAME(cell, x, y, e); \
1643 } \
1644 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) {\
1645 PCLASS::CBNAME(cell, x, y, e); \
1646 }
1647
1648
1649
1650 //---------------------------------------------------------------------------
1651
1652 #define DEC_PYCALLBACK___pure(CBNAME) \
1653 void CBNAME()
1654
1655
1656 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1657 void CLASS::CBNAME() { \
1658 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1659 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1660 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1661 wxPyEndBlockThreads(blocked); \
1662 }
1663
1664 //---------------------------------------------------------------------------
1665
1666 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1667 wxSize CBNAME()
1668
1669
1670 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1671 wxSize CLASS::CBNAME() { \
1672 const char* errmsg = #CBNAME " should return a 2-tuple of integers or a wxSize object."; \
1673 wxSize rval(0,0); \
1674 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1675 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1676 PyObject* ro; \
1677 wxSize* ptr; \
1678 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1679 if (ro) { \
1680 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxSize"))) \
1681 rval = *ptr; \
1682 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
1683 PyErr_Clear(); \
1684 PyObject* o1 = PySequence_GetItem(ro, 0); \
1685 PyObject* o2 = PySequence_GetItem(ro, 1); \
1686 if (PyNumber_Check(o1) && PyNumber_Check(o2)) \
1687 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
1688 else \
1689 PyErr_SetString(PyExc_TypeError, errmsg); \
1690 Py_DECREF(o1); \
1691 Py_DECREF(o2); \
1692 } \
1693 else { \
1694 PyErr_SetString(PyExc_TypeError, errmsg); \
1695 } \
1696 Py_DECREF(ro); \
1697 } \
1698 } \
1699 wxPyEndBlockThreads(blocked); \
1700 return rval; \
1701 }
1702
1703 //---------------------------------------------------------------------------
1704
1705 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1706 bool CBNAME(wxWindow* a); \
1707 bool base_##CBNAME(wxWindow* a)
1708
1709
1710 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1711 bool CLASS::CBNAME(wxWindow* a) { \
1712 bool rval=false; \
1713 bool found; \
1714 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1715 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1716 PyObject* obj = wxPyMake_wxObject(a,false); \
1717 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1718 Py_DECREF(obj); \
1719 } \
1720 wxPyEndBlockThreads(blocked); \
1721 if (! found) \
1722 rval = PCLASS::CBNAME(a); \
1723 return rval; \
1724 } \
1725 bool CLASS::base_##CBNAME(wxWindow* a) { \
1726 return PCLASS::CBNAME(a); \
1727 }
1728
1729 //---------------------------------------------------------------------------
1730
1731 #define DEC_PYCALLBACK_BOOL_WXWINDC(CBNAME) \
1732 bool CBNAME(wxWindow* a, wxDC& b); \
1733 bool base_##CBNAME(wxWindow* a, wxDC& b)
1734
1735
1736 #define IMP_PYCALLBACK_BOOL_WXWINDC(CLASS, PCLASS, CBNAME) \
1737 bool CLASS::CBNAME(wxWindow* a, wxDC& b) { \
1738 bool rval=false; \
1739 bool found; \
1740 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1741 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1742 PyObject* win = wxPyMake_wxObject(a,false); \
1743 PyObject* dc = wxPyMake_wxObject(&b,false); \
1744 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc));\
1745 Py_DECREF(win); \
1746 Py_DECREF(dc); \
1747 } \
1748 wxPyEndBlockThreads(blocked); \
1749 if (! found) \
1750 rval = PCLASS::CBNAME(a, b); \
1751 return rval; \
1752 } \
1753 bool CLASS::base_##CBNAME(wxWindow* a, wxDC& b) { \
1754 return PCLASS::CBNAME(a, b); \
1755 }
1756
1757 //---------------------------------------------------------------------------
1758
1759 #define DEC_PYCALLBACK_VOID_WXWINBASE(CBNAME) \
1760 void CBNAME(wxWindowBase* a); \
1761 void base_##CBNAME(wxWindowBase* a)
1762
1763
1764 #define IMP_PYCALLBACK_VOID_WXWINBASE(CLASS, PCLASS, CBNAME) \
1765 void CLASS::CBNAME(wxWindowBase* a) { \
1766 bool found; \
1767 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1768 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1769 PyObject* obj = wxPyMake_wxObject(a,false); \
1770 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1771 Py_DECREF(obj); \
1772 } \
1773 wxPyEndBlockThreads(blocked); \
1774 if (! found) \
1775 PCLASS::CBNAME(a); \
1776 } \
1777 void CLASS::base_##CBNAME(wxWindowBase* a) { \
1778 PCLASS::CBNAME(a); \
1779 }
1780
1781 //---------------------------------------------------------------------------
1782
1783 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1784 bool CBNAME(); \
1785 bool base_##CBNAME()
1786
1787
1788 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1789 bool CLASS::CBNAME() { \
1790 bool rval=false; \
1791 bool found; \
1792 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1793 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1794 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1795 wxPyEndBlockThreads(blocked); \
1796 if (! found) \
1797 rval = PCLASS::CBNAME(); \
1798 return rval; \
1799 } \
1800 bool CLASS::base_##CBNAME() { \
1801 return PCLASS::CBNAME(); \
1802 }
1803
1804 //---------------------------------------------------------------------------
1805
1806 #define DEC_PYCALLBACK_BOOL_const(CBNAME) \
1807 bool CBNAME() const; \
1808 bool base_##CBNAME() const
1809
1810
1811 #define IMP_PYCALLBACK_BOOL_const(CLASS, PCLASS, CBNAME) \
1812 bool CLASS::CBNAME() const { \
1813 bool rval=false; \
1814 bool found; \
1815 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1816 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1817 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1818 wxPyEndBlockThreads(blocked); \
1819 if (! found) \
1820 rval = PCLASS::CBNAME(); \
1821 return rval; \
1822 } \
1823 bool CLASS::base_##CBNAME() const { \
1824 return PCLASS::CBNAME(); \
1825 }
1826
1827 //---------------------------------------------------------------------------
1828
1829 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1830 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \
1831 wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1832
1833
1834 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1835 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1836 int rval=0; \
1837 bool found; \
1838 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1839 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1840 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1841 wxPyEndBlockThreads(blocked); \
1842 if (! found) \
1843 rval = PCLASS::CBNAME(a, b, c); \
1844 return (wxDragResult)rval; \
1845 } \
1846 wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1847 return PCLASS::CBNAME(a, b, c); \
1848 }
1849
1850 //---------------------------------------------------------------------------
1851
1852 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1853 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location)
1854
1855 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1856 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1857 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1858 wxFSFile* rval=0; \
1859 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1860 PyObject* ro; \
1861 PyObject* obj = wxPyMake_wxObject(&a,false); \
1862 PyObject* s = wx2PyString(b); \
1863 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)", \
1864 obj, s)); \
1865 if (ro) { \
1866 wxPyConvertSwigPtr(ro, (void **)&rval, wxT("wxFSFile")); \
1867 Py_DECREF(ro); \
1868 } \
1869 Py_DECREF(obj); \
1870 Py_DECREF(s); \
1871 } \
1872 wxPyEndBlockThreads(blocked); \
1873 return rval; \
1874 };
1875
1876 //---------------------------------------------------------------------------
1877
1878 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1879 bool CBNAME(wxDragResult a); \
1880 bool base_##CBNAME(wxDragResult a)
1881
1882
1883 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1884 bool CLASS::CBNAME(wxDragResult a) { \
1885 bool rval=false; \
1886 bool found; \
1887 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1888 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1889 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
1890 wxPyEndBlockThreads(blocked); \
1891 if (! found) \
1892 rval = PCLASS::CBNAME(a); \
1893 return rval; \
1894 } \
1895 bool CLASS::base_##CBNAME(wxDragResult a) { \
1896 return PCLASS::CBNAME(a); \
1897 }
1898
1899 //---------------------------------------------------------------------------
1900
1901 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1902 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1903
1904
1905 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1906 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1907 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1908 int rval=0; \
1909 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1910 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1911 wxPyEndBlockThreads(blocked); \
1912 return (wxDragResult)rval; \
1913 } \
1914
1915 //---------------------------------------------------------------------------
1916
1917 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1918 bool CBNAME(int a, int b, const wxString& c)
1919
1920 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1921 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1922 bool rval=false; \
1923 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1924 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1925 PyObject* s = wx2PyString(c); \
1926 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
1927 Py_DECREF(s); \
1928 } \
1929 wxPyEndBlockThreads(blocked); \
1930 return rval; \
1931 } \
1932
1933 //---------------------------------------------------------------------------
1934
1935 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1936 size_t CBNAME(); \
1937 size_t base_##CBNAME()
1938
1939
1940 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1941 size_t CLASS::CBNAME() { \
1942 size_t rval=0; \
1943 bool found; \
1944 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1945 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1946 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1947 wxPyEndBlockThreads(blocked); \
1948 if (! found) \
1949 rval = PCLASS::CBNAME(); \
1950 return rval; \
1951 } \
1952 size_t CLASS::base_##CBNAME() { \
1953 return PCLASS::CBNAME(); \
1954 }
1955
1956 //---------------------------------------------------------------------------
1957
1958 #define DEC_PYCALLBACK_SIZET__const(CBNAME) \
1959 size_t CBNAME() const; \
1960 size_t base_##CBNAME() const
1961
1962
1963 #define IMP_PYCALLBACK_SIZET__const(CLASS, PCLASS, CBNAME) \
1964 size_t CLASS::CBNAME() const { \
1965 size_t rval=0; \
1966 bool found; \
1967 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1968 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1969 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1970 wxPyEndBlockThreads(blocked); \
1971 if (! found) \
1972 rval = PCLASS::CBNAME(); \
1973 return rval; \
1974 } \
1975 size_t CLASS::base_##CBNAME() const { \
1976 return PCLASS::CBNAME(); \
1977 }
1978
1979 //---------------------------------------------------------------------------
1980
1981 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1982 wxDataFormat CBNAME(size_t a); \
1983 wxDataFormat base_##CBNAME(size_t a)
1984
1985
1986 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1987 wxDataFormat CLASS::CBNAME(size_t a) { \
1988 wxDataFormat rval=0; \
1989 bool found; \
1990 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1991 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1992 PyObject* ro; \
1993 wxDataFormat* ptr; \
1994 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1995 if (ro) { \
1996 if (wxPyCOnvertSwigPtr(ro, (void **)&ptr, wxT("wxDataFormat"))) \
1997 rval = *ptr; \
1998 Py_DECREF(ro); \
1999 } \
2000 } \
2001 wxPyEndBlockThreads(blocked); \
2002 if (! found) \
2003 rval = PCLASS::CBNAME(a); \
2004 return rval; \
2005 } \
2006 wxDataFormat CLASS::base_##CBNAME(size_t a) { \
2007 return PCLASS::CBNAME(a); \
2008 }
2009
2010 //---------------------------------------------------------------------------
2011
2012 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
2013 void CBNAME(const Type& a); \
2014 void base_##CBNAME(const Type& a)
2015
2016
2017 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
2018 void CLASS::CBNAME(const Type& a) { \
2019 bool found; \
2020 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2021 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2022 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
2023 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2024 Py_DECREF(obj); \
2025 } \
2026 wxPyEndBlockThreads(blocked); \
2027 if (! found) \
2028 PCLASS::CBNAME(a); \
2029 } \
2030 void CLASS::base_##CBNAME(const Type& a) { \
2031 PCLASS::CBNAME(a); \
2032 }
2033
2034
2035 //---------------------------------------------------------------------------
2036
2037 #define DEC_PYCALLBACK__any(CBNAME, Type) \
2038 void CBNAME(Type& a); \
2039 void base_##CBNAME(Type& a)
2040
2041
2042 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
2043 void CLASS::CBNAME(Type& a) { \
2044 bool found; \
2045 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2046 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2047 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
2048 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2049 Py_DECREF(obj); \
2050 } \
2051 wxPyEndBlockThreads(blocked); \
2052 if (! found) \
2053 PCLASS::CBNAME(a); \
2054 } \
2055 void CLASS::base_##CBNAME(Type& a) { \
2056 PCLASS::CBNAME(a); \
2057 }
2058
2059 //---------------------------------------------------------------------------
2060
2061 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
2062 bool CBNAME(Type& a); \
2063 bool base_##CBNAME(Type& a)
2064
2065
2066 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
2067 bool CLASS::CBNAME(Type& a) { \
2068 bool rv=false; \
2069 bool found; \
2070 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2071 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2072 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
2073 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2074 Py_DECREF(obj); \
2075 } \
2076 wxPyEndBlockThreads(blocked); \
2077 if (! found) \
2078 rv = PCLASS::CBNAME(a); \
2079 return rv; \
2080 } \
2081 bool CLASS::base_##CBNAME(Type& a) { \
2082 return PCLASS::CBNAME(a); \
2083 }
2084
2085 //---------------------------------------------------------------------------
2086
2087 #define DEC_PYCALLBACK_bool_anypure(CBNAME, Type) \
2088 bool CBNAME(Type& a)
2089
2090
2091 #define IMP_PYCALLBACK_bool_anypure(CLASS, PCLASS, CBNAME, Type) \
2092 bool CLASS::CBNAME(Type& a) { \
2093 bool rv=false; \
2094 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2095 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2096 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
2097 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2098 Py_DECREF(obj); \
2099 } \
2100 wxPyEndBlockThreads(blocked); \
2101 return rv; \
2102 } \
2103
2104 //---------------------------------------------------------------------------
2105
2106 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
2107 wxString CBNAME(long a, long b) const; \
2108 wxString base_##CBNAME(long a, long b) const
2109
2110 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
2111 wxString CLASS::CBNAME(long a, long b) const { \
2112 wxString rval; \
2113 bool found; \
2114 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2115 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2116 PyObject* ro; \
2117 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
2118 if (ro) { \
2119 rval = Py2wxString(ro); \
2120 Py_DECREF(ro); \
2121 } \
2122 } \
2123 wxPyEndBlockThreads(blocked); \
2124 if (! found) \
2125 rval = PCLASS::CBNAME(a,b); \
2126 return rval; \
2127 } \
2128 wxString CLASS::base_##CBNAME(long a, long b) const { \
2129 return PCLASS::CBNAME(a,b); \
2130 }
2131
2132 //---------------------------------------------------------------------------
2133
2134 #define DEC_PYCALLBACK_INT_LONG(CBNAME) \
2135 int CBNAME(long a) const; \
2136 int base_##CBNAME(long a) const
2137
2138
2139 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
2140 int CLASS::CBNAME(long a) const { \
2141 int rval=-1; \
2142 bool found; \
2143 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2144 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2145 PyObject* ro; \
2146 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2147 if (ro) { \
2148 rval = PyInt_AsLong(ro); \
2149 Py_DECREF(ro); \
2150 } \
2151 } \
2152 wxPyEndBlockThreads(blocked); \
2153 if (! found) \
2154 rval = PCLASS::CBNAME(a); \
2155 return rval; \
2156 } \
2157 int CLASS::base_##CBNAME(long a) const { \
2158 return PCLASS::CBNAME(a); \
2159 }
2160
2161
2162
2163
2164 #define DEC_PYCALLBACK_INT_LONG_virtual(CBNAME) \
2165 int CBNAME(long a) const;
2166
2167
2168 #define IMP_PYCALLBACK_INT_LONG_virtual(CLASS, PCLASS, CBNAME) \
2169 int CLASS::CBNAME(long a) const { \
2170 int rval=-1; /* this rval is important for OnGetItemImage */ \
2171 bool found; \
2172 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2173 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2174 PyObject* ro; \
2175 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2176 if (ro) { \
2177 rval = PyInt_AsLong(ro); \
2178 Py_DECREF(ro); \
2179 } \
2180 } \
2181 wxPyEndBlockThreads(blocked); \
2182 return rval; \
2183 }
2184
2185
2186 //---------------------------------------------------------------------------
2187
2188 #define DEC_PYCALLBACK_INT_LONGLONG(CBNAME) \
2189 int CBNAME(long a, long b) const; \
2190 int base_##CBNAME(long a, long b) const
2191
2192
2193 #define IMP_PYCALLBACK_INT_LONGLONG(CLASS, PCLASS, CBNAME) \
2194 int CLASS::CBNAME(long a, long b) const { \
2195 int rval=-1; \
2196 bool found; \
2197 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2198 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2199 PyObject* ro; \
2200 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
2201 if (ro) { \
2202 rval = PyInt_AsLong(ro); \
2203 Py_DECREF(ro); \
2204 } \
2205 } \
2206 wxPyEndBlockThreads(blocked); \
2207 if (! found) \
2208 rval = PCLASS::CBNAME(a, b); \
2209 return rval; \
2210 } \
2211 int CLASS::base_##CBNAME(long a, long b) const { \
2212 return PCLASS::CBNAME(a, b); \
2213 }
2214
2215
2216
2217
2218 #define DEC_PYCALLBACK_INT_LONGLONG_virtual(CBNAME) \
2219 int CBNAME(long a, long b) const;
2220
2221
2222 #define IMP_PYCALLBACK_INT_LONGLONG_virtual(CLASS, PCLASS, CBNAME) \
2223 int CLASS::CBNAME(long a, long b) const { \
2224 int rval=-1; /* this rval is important for OnGetItemImage */ \
2225 bool found; \
2226 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2227 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2228 PyObject* ro; \
2229 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
2230 if (ro) { \
2231 rval = PyInt_AsLong(ro); \
2232 Py_DECREF(ro); \
2233 } \
2234 } \
2235 wxPyEndBlockThreads(blocked); \
2236 return rval; \
2237 }
2238
2239
2240 //---------------------------------------------------------------------------
2241
2242 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
2243 wxListItemAttr* CBNAME(long a) const; \
2244 wxListItemAttr* base_##CBNAME(long a) const
2245
2246
2247 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
2248 wxListItemAttr *CLASS::CBNAME(long a) const { \
2249 wxListItemAttr *rval = NULL; \
2250 bool found; \
2251 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2252 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2253 PyObject* ro; \
2254 wxListItemAttr* ptr; \
2255 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2256 if (ro) { \
2257 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxListItemAttr")))\
2258 rval = ptr; \
2259 Py_DECREF(ro); \
2260 } \
2261 } \
2262 wxPyEndBlockThreads(blocked); \
2263 if (! found) \
2264 rval = PCLASS::CBNAME(a); \
2265 return rval; \
2266 } \
2267 wxListItemAttr *CLASS::base_##CBNAME(long a) const { \
2268 return PCLASS::CBNAME(a); \
2269 }
2270
2271 //---------------------------------------------------------------------------
2272
2273 #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
2274 bool CBNAME(wxMouseEvent& e); \
2275 bool base_##CBNAME(wxMouseEvent& e)
2276
2277 #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
2278 bool CLASS::CBNAME(wxMouseEvent& e) { \
2279 bool rval=false; \
2280 bool found; \
2281 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2282 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2283 PyObject* ro; \
2284 PyObject* obj = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
2285 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
2286 if (ro) { \
2287 rval = PyInt_AsLong(ro); \
2288 Py_DECREF(ro); \
2289 } \
2290 Py_DECREF(obj); \
2291 } \
2292 wxPyEndBlockThreads(blocked); \
2293 if (! found) \
2294 return PCLASS::CBNAME(e); \
2295 return rval; \
2296 } \
2297 bool CLASS::base_##CBNAME(wxMouseEvent& e) { \
2298 return PCLASS::CBNAME(e); \
2299 }
2300
2301
2302 //---------------------------------------------------------------------------
2303
2304 #define DEC_PYCALLBACK_WIZPG__pure(CBNAME) \
2305 wxWizardPage* CBNAME() const
2306
2307 #define IMP_PYCALLBACK_WIZPG__pure(CLASS, PCLASS, CBNAME) \
2308 wxWizardPage* CLASS::CBNAME() const { \
2309 wxWizardPage* rv = NULL; \
2310 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2311 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2312 PyObject* ro; \
2313 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2314 if (ro) { \
2315 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxWizardPage")); \
2316 Py_DECREF(ro); \
2317 } \
2318 } \
2319 wxPyEndBlockThreads(blocked); \
2320 return rv; \
2321 }
2322
2323 //---------------------------------------------------------------------------
2324
2325 #define DEC_PYCALLBACK_BITMAP__pure(CBNAME) \
2326 wxBitmap CBNAME() const
2327
2328 #define IMP_PYCALLBACK_BITMAP__pure(CLASS, PCLASS, CBNAME) \
2329 wxBitmap CLASS::CBNAME() const { \
2330 wxBitmap rv; \
2331 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2332 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2333 PyObject* ro; \
2334 wxBitmap* ptr; \
2335 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2336 if (ro) { \
2337 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxBitmap"))) \
2338 rv = *ptr; \
2339 Py_DECREF(ro); \
2340 } \
2341 } \
2342 wxPyEndBlockThreads(blocked); \
2343 return rv; \
2344 }
2345
2346 //---------------------------------------------------------------------------
2347
2348 #define DEC_PYCALLBACK_OBJECT__pure(CBNAME) \
2349 wxObject* CBNAME()
2350
2351 #define IMP_PYCALLBACK_OBJECT__pure(CLASS, PCLASS, CBNAME) \
2352 wxObject* CLASS::CBNAME() { \
2353 wxObject* rv = NULL; \
2354 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2355 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2356 PyObject* ro; \
2357 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2358 if (ro) { \
2359 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2360 Py_DECREF(ro); \
2361 } \
2362 } \
2363 wxPyEndBlockThreads(blocked); \
2364 return rv; \
2365 }
2366
2367 //---------------------------------------------------------------------------
2368
2369 #define DEC_PYCALLBACK_OBJECT_STRING_pure(CBNAME) \
2370 wxObject* CBNAME(const wxString& a)
2371
2372 #define IMP_PYCALLBACK_OBJECT_STRING_pure(CLASS, PCLASS, CBNAME) \
2373 wxObject* CLASS::CBNAME(const wxString& a) { \
2374 wxObject* rv = NULL; \
2375 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2376 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2377 PyObject* so = wx2PyString(a); \
2378 PyObject* ro; \
2379 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", so)); \
2380 if (ro) { \
2381 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2382 Py_DECREF(ro); \
2383 } \
2384 Py_DECREF(so); \
2385 } \
2386 wxPyEndBlockThreads(blocked); \
2387 return rv; \
2388 }
2389
2390 //---------------------------------------------------------------------------
2391
2392 #define DEC_PYCALLBACK_BOOL_NODE_pure(CBNAME) \
2393 bool CBNAME(wxXmlNode* a)
2394
2395
2396 #define IMP_PYCALLBACK_BOOL_NODE_pure(CLASS, PCLASS, CBNAME) \
2397 bool CLASS::CBNAME(wxXmlNode* a) { \
2398 bool rv=false; \
2399 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2400 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2401 PyObject* obj = wxPyConstructObject((void*)a, wxT("wxXmlNode"), 0); \
2402 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2403 Py_DECREF(obj); \
2404 } \
2405 wxPyEndBlockThreads(blocked); \
2406 return rv; \
2407 } \
2408
2409 //---------------------------------------------------------------------------
2410
2411 #define DEC_PYCALLBACK_COORD_SIZET_constpure(CBNAME) \
2412 wxCoord CBNAME(size_t a) const
2413
2414
2415 #define IMP_PYCALLBACK_COORD_SIZET_constpure(CLASS, PCLASS, CBNAME) \
2416 wxCoord CLASS::CBNAME(size_t a) const { \
2417 wxCoord rval=0; \
2418 bool found; \
2419 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2420 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2421 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
2422 } \
2423 wxPyEndBlockThreads(blocked); \
2424 return rval; \
2425 } \
2426
2427 //---------------------------------------------------------------------------
2428
2429 #define DEC_PYCALLBACK_VOID_SIZETSIZET_const(CBNAME) \
2430 void CBNAME(size_t a, size_t b) const; \
2431 void base_##CBNAME(size_t a, size_t b) const
2432
2433
2434 #define IMP_PYCALLBACK_VOID_SIZETSIZET_const(CLASS, PCLASS, CBNAME) \
2435 void CLASS::CBNAME(size_t a, size_t b) const { \
2436 bool found; \
2437 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2438 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2439 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
2440 wxPyEndBlockThreads(blocked); \
2441 if (! found) \
2442 PCLASS::CBNAME(a,b); \
2443 } \
2444 void CLASS::base_##CBNAME(size_t a, size_t b) const { \
2445 PCLASS::CBNAME(a,b); \
2446 }
2447
2448 //---------------------------------------------------------------------------
2449
2450 #define DEC_PYCALLBACK_COORD_const(CBNAME) \
2451 wxCoord CBNAME() const; \
2452 wxCoord base_##CBNAME() const
2453
2454
2455 #define IMP_PYCALLBACK_COORD_const(CLASS, PCLASS, CBNAME) \
2456 wxCoord CLASS::CBNAME() const { \
2457 wxCoord rval=0; \
2458 bool found; \
2459 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2460 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2461 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
2462 wxPyEndBlockThreads(blocked); \
2463 if (! found) \
2464 rval = PCLASS::CBNAME(); \
2465 return rval; \
2466 } \
2467 wxCoord CLASS::base_##CBNAME() const { \
2468 return PCLASS::CBNAME(); \
2469 }
2470
2471 //---------------------------------------------------------------------------
2472
2473 #define DEC_PYCALLBACK__DCRECTSIZET_constpure(CBNAME) \
2474 void CBNAME(wxDC& a, const wxRect& b, size_t c) const;
2475
2476
2477 #define IMP_PYCALLBACK__DCRECTSIZET_constpure(CLASS, PCLASS, CBNAME) \
2478 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2479 bool found; \
2480 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2481 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2482 PyObject* obj = wxPyMake_wxObject(&a,false); \
2483 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2484 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2485 Py_DECREF(obj); \
2486 } \
2487 wxPyEndBlockThreads(blocked); \
2488 } \
2489
2490 //---------------------------------------------------------------------------
2491
2492 #define DEC_PYCALLBACK__DCRECTSIZET_const(CBNAME) \
2493 void CBNAME(wxDC& a, const wxRect& b, size_t c) const; \
2494 void base_##CBNAME(wxDC& a, const wxRect& b, size_t c) const
2495
2496
2497 #define IMP_PYCALLBACK__DCRECTSIZET_const(CLASS, PCLASS, CBNAME) \
2498 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2499 bool found; \
2500 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2501 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2502 PyObject* obj = wxPyMake_wxObject(&a,false); \
2503 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2504 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2505 Py_DECREF(obj); \
2506 } \
2507 wxPyEndBlockThreads(blocked); \
2508 if (! found) \
2509 PCLASS::CBNAME(a,b,c); \
2510 } \
2511 void CLASS::base_##CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2512 PCLASS::CBNAME(a,b,c); \
2513 }
2514
2515 //---------------------------------------------------------------------------
2516
2517
2518 #define DEC_PYCALLBACK_STRING_SIZET(CBNAME) \
2519 wxString CBNAME(size_t a) const; \
2520 wxString base_##CBNAME(size_t a) const
2521
2522 #define IMP_PYCALLBACK_STRING_SIZET(CLASS, PCLASS, CBNAME) \
2523 wxString CLASS::CBNAME(size_t a) const { \
2524 wxString rval; \
2525 bool found; \
2526 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2527 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2528 PyObject* ro; \
2529 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2530 if (ro) { \
2531 rval = Py2wxString(ro); \
2532 Py_DECREF(ro); \
2533 } \
2534 } \
2535 wxPyEndBlockThreads(blocked); \
2536 if (! found) \
2537 rval = PCLASS::CBNAME(a); \
2538 return rval; \
2539 } \
2540 wxString CLASS::base_##CBNAME(size_t a) const { \
2541 return PCLASS::CBNAME(a); \
2542 }
2543
2544 //---------------------------------------------------------------------------
2545
2546 #define DEC_PYCALLBACK_STRING_SIZET_pure(CBNAME) \
2547 wxString CBNAME(size_t a) const
2548
2549 #define IMP_PYCALLBACK_STRING_SIZET_pure(CLASS, PCLASS, CBNAME) \
2550 wxString CLASS::CBNAME(size_t a) const { \
2551 wxString rval; \
2552 bool found; \
2553 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2554 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2555 PyObject* ro; \
2556 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2557 if (ro) { \
2558 rval = Py2wxString(ro); \
2559 Py_DECREF(ro); \
2560 } \
2561 } \
2562 wxPyEndBlockThreads(blocked); \
2563 return rval; \
2564 } \
2565
2566 //---------------------------------------------------------------------------
2567
2568 #define DEC_PYCALLBACK_VIZATTR_(CBNAME) \
2569 wxVisualAttributes CBNAME() const; \
2570 wxVisualAttributes base_##CBNAME()
2571
2572
2573 #define IMP_PYCALLBACK_VIZATTR_(CLASS, PCLASS, CBNAME) \
2574 wxVisualAttributes CLASS::CBNAME() const { \
2575 wxVisualAttributes rval; \
2576 bool found; \
2577 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2578 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2579 PyObject* ro; \
2580 wxVisualAttributes* ptr; \
2581 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2582 if (ro) { \
2583 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxVisualAttributes"))) \
2584 rval = *ptr; \
2585 Py_DECREF(ro); \
2586 } \
2587 } \
2588 wxPyEndBlockThreads(blocked); \
2589 if (! found) \
2590 rval = PCLASS::CBNAME(); \
2591 return rval; \
2592 } \
2593 wxVisualAttributes CLASS::base_##CBNAME() { \
2594 return PCLASS::CBNAME(); \
2595 }
2596
2597 //---------------------------------------------------------------------------
2598
2599 #endif