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