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