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