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