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