]> git.saurik.com Git - wxWidgets.git/blob - wxPython/include/wx/wxPython/wxPython_int.h
8aaf5f46baf2be1c4bbcfa22359921cd0bfc62f7
[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 OnAssert(const wxChar *file,
606 int line,
607 const wxChar *cond,
608 const wxChar *msg);
609 #endif
610 virtual void ExitMainLoop();
611 // virtual int FilterEvent(wxEvent& event); // This one too????
612
613 // For catching Apple Events
614 virtual void MacOpenFile(const wxString &fileName);
615 virtual void MacPrintFile(const wxString &fileName);
616 virtual void MacNewFile();
617 virtual void MacReopenApp();
618
619 static bool GetMacSupportPCMenuShortcuts();
620 static long GetMacAboutMenuItemId();
621 static long GetMacPreferencesMenuItemId();
622 static long GetMacExitMenuItemId();
623 static wxString GetMacHelpMenuTitleName();
624
625 static void SetMacSupportPCMenuShortcuts(bool val);
626 static void SetMacAboutMenuItemId(long val);
627 static void SetMacPreferencesMenuItemId(long val);
628 static void SetMacExitMenuItemId(long val);
629 static void SetMacHelpMenuTitleName(const wxString& val);
630
631
632 void _BootstrapApp();
633
634 // implementation only
635 void SetStartupComplete(bool val) { m_startupComplete = val; };
636
637 PYPRIVATE;
638 int m_assertMode;
639 bool m_startupComplete;
640 };
641
642 extern wxPyApp *wxPythonApp;
643
644
645 //----------------------------------------------------------------------
646 // These macros are used to implement the virtual methods that should
647 // redirect to a Python method if one exists. The names designate the
648 // return type, if any, as well as any parameter types.
649 //---------------------------------------------------------------------------
650
651 #define DEC_PYCALLBACK__(CBNAME) \
652 void CBNAME()
653
654
655 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
656 void CLASS::CBNAME() { \
657 bool found; \
658 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
659 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
660 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
661 wxPyEndBlockThreads(blocked); \
662 if (! found) \
663 PCLASS::CBNAME(); \
664 }
665
666 #define DEC_PYCALLBACK_VOID_(CBNAME) \
667 DEC_PYCALLBACK__(CBNAME)
668
669 #define IMP_PYCALLBACK_VOID_(CLASS, PCLASS, CBNAME) \
670 IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME)
671
672 //---------------------------------------------------------------------------
673
674 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
675 bool CBNAME(int a, int b)
676
677
678 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
679 bool CLASS::CBNAME(int a, int b) { \
680 bool rval=false, found; \
681 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
682 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
683 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
684 wxPyEndBlockThreads(blocked); \
685 if (! found) \
686 rval = PCLASS::CBNAME(a,b); \
687 return rval; \
688 }
689
690 //---------------------------------------------------------------------------
691
692 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
693 void CBNAME(int a, int b)
694
695
696 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
697 void CLASS::CBNAME(int a, int b) { \
698 bool found; \
699 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
700 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
701 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
702 wxPyEndBlockThreads(blocked); \
703 if (! found) \
704 PCLASS::CBNAME(a,b); \
705 }
706
707 //---------------------------------------------------------------------------
708
709 #define DEC_PYCALLBACK_VOID_INT(CBNAME) \
710 void CBNAME(int a)
711
712
713 #define IMP_PYCALLBACK_VOID_INT(CLASS, PCLASS, CBNAME) \
714 void CLASS::CBNAME(int a) { \
715 bool found; \
716 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
717 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
718 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
719 wxPyEndBlockThreads(blocked); \
720 if (! found) \
721 PCLASS::CBNAME(a); \
722 }
723
724 //---------------------------------------------------------------------------
725
726 #define DEC_PYCALLBACK_VOID_INT4(CBNAME) \
727 void CBNAME(int a, int b, int c, int d)
728
729
730 #define IMP_PYCALLBACK_VOID_INT4(CLASS, PCLASS, CBNAME) \
731 void CLASS::CBNAME(int a, int b, int c, int d) { \
732 bool found; \
733 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
734 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
735 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiii)",a,b,c,d)); \
736 wxPyEndBlockThreads(blocked); \
737 if (! found) \
738 PCLASS::CBNAME(a,b,c,d); \
739 }
740
741 //---------------------------------------------------------------------------
742 #define DEC_PYCALLBACK_VOID_INT5(CBNAME) \
743 void CBNAME(int a, int b, int c, int d, int e)
744
745
746 #define IMP_PYCALLBACK_VOID_INT5(CLASS, PCLASS, CBNAME) \
747 void CLASS::CBNAME(int a, int b, int c, int d, int e) { \
748 bool found; \
749 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
750 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
751 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiiii)",a,b,c,d,e)); \
752 wxPyEndBlockThreads(blocked); \
753 if (! found) \
754 PCLASS::CBNAME(a,b,c,d,e); \
755 }
756
757 //---------------------------------------------------------------------------
758
759 #define DEC_PYCALLBACK_VOID_INTPINTP_const(CBNAME) \
760 void CBNAME(int* a, int* b) const
761
762
763 #define IMP_PYCALLBACK_VOID_INTPINTP_const(CLASS, PCLASS, CBNAME) \
764 void CLASS::CBNAME(int* a, int* b) const { \
765 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
766 bool found; \
767 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
768 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
769 PyObject* ro; \
770 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
771 if (ro) { \
772 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
773 PyObject* o1 = PySequence_GetItem(ro, 0); \
774 PyObject* o2 = PySequence_GetItem(ro, 1); \
775 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
776 *a = PyInt_AsLong(o1); *b = PyInt_AsLong(o2); \
777 } \
778 else \
779 PyErr_SetString(PyExc_TypeError, errmsg); \
780 Py_DECREF(o1); \
781 Py_DECREF(o2); \
782 } \
783 else { \
784 PyErr_SetString(PyExc_TypeError, errmsg); \
785 } \
786 Py_DECREF(ro); \
787 } \
788 } \
789 wxPyEndBlockThreads(blocked); \
790 if (! found) \
791 PCLASS::CBNAME(a,b); \
792 }
793
794 //---------------------------------------------------------------------------
795
796 #define DEC_PYCALLBACK_SIZE_const(CBNAME) \
797 wxSize CBNAME() const
798
799
800 #define IMP_PYCALLBACK_SIZE_const(CLASS, PCLASS, CBNAME) \
801 wxSize CLASS::CBNAME() const { \
802 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
803 bool found; wxSize rval(0,0); \
804 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
805 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
806 PyObject* ro; \
807 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
808 if (ro) { \
809 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
810 PyObject* o1 = PySequence_GetItem(ro, 0); \
811 PyObject* o2 = PySequence_GetItem(ro, 1); \
812 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
813 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
814 } \
815 else \
816 PyErr_SetString(PyExc_TypeError, errmsg); \
817 Py_DECREF(o1); \
818 Py_DECREF(o2); \
819 } \
820 else { \
821 PyErr_SetString(PyExc_TypeError, errmsg); \
822 } \
823 Py_DECREF(ro); \
824 } \
825 } \
826 wxPyEndBlockThreads(blocked); \
827 if (! found) \
828 return PCLASS::CBNAME(); \
829 else \
830 return rval; \
831 }
832
833 //---------------------------------------------------------------------------
834
835 #define DEC_PYCALLBACK_BOOL_BOOL(CBNAME) \
836 bool CBNAME(bool a)
837
838
839 #define IMP_PYCALLBACK_BOOL_BOOL(CLASS, PCLASS, CBNAME) \
840 bool CLASS::CBNAME(bool a) { \
841 bool rval=false, found; \
842 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
843 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
844 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
845 wxPyEndBlockThreads(blocked); \
846 if (! found) \
847 rval = PCLASS::CBNAME(a); \
848 return rval; \
849 }
850
851 //---------------------------------------------------------------------------
852
853 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
854 bool CBNAME(int a)
855
856
857 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
858 bool CLASS::CBNAME(int a) { \
859 bool rval=false, found; \
860 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
861 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
862 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
863 wxPyEndBlockThreads(blocked); \
864 if (! found) \
865 rval = PCLASS::CBNAME(a); \
866 return rval; \
867 }
868
869 //---------------------------------------------------------------------------
870
871 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
872 bool CBNAME(int a)
873
874
875 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
876 bool CLASS::CBNAME(int a) { \
877 bool rval=false; \
878 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
879 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
880 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
881 else rval = false; \
882 wxPyEndBlockThreads(blocked); \
883 return rval; \
884 }
885
886
887 //---------------------------------------------------------------------------
888
889 #define DEC_PYCALLBACK__DC(CBNAME) \
890 void CBNAME(wxDC& a)
891
892
893 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
894 void CLASS::CBNAME(wxDC& a) { \
895 bool found; \
896 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
897 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
898 PyObject* obj = wxPyMake_wxObject(&a,false); \
899 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
900 Py_DECREF(obj); \
901 } \
902 wxPyEndBlockThreads(blocked); \
903 if (! found) \
904 PCLASS::CBNAME(a); \
905 }
906
907
908 //---------------------------------------------------------------------------
909
910 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
911 void CBNAME(wxDC& a, bool b)
912
913
914 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
915 void CLASS::CBNAME(wxDC& a, bool b) { \
916 bool found; \
917 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
918 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
919 PyObject* obj = wxPyMake_wxObject(&a,false); \
920 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
921 Py_DECREF(obj); \
922 } \
923 wxPyEndBlockThreads(blocked); \
924 if (! found) \
925 PCLASS::CBNAME(a, b); \
926 }
927
928 //---------------------------------------------------------------------------
929
930 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
931 void CBNAME(wxDC& a, bool b)
932
933
934 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
935 void CLASS::CBNAME(wxDC& a, bool b) { \
936 bool found; \
937 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
938 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
939 PyObject* obj = wxPyMake_wxObject(&a,false); \
940 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
941 Py_DECREF(obj); \
942 } \
943 wxPyEndBlockThreads(blocked); \
944 if (! found) \
945 PCLASS::CBNAME(a, b); \
946 }
947
948 //---------------------------------------------------------------------------
949
950 #define DEC_PYCALLBACK__2DBL(CBNAME) \
951 void CBNAME(double a, double b)
952
953
954 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
955 void CLASS::CBNAME(double a, double b) { \
956 bool found; \
957 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
958 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
959 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
960 wxPyEndBlockThreads(blocked); \
961 if (! found) \
962 PCLASS::CBNAME(a, b); \
963 }
964
965 //---------------------------------------------------------------------------
966
967 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
968 void CBNAME(double a, double b, int c, int d)
969
970
971 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
972 void CLASS::CBNAME(double a, double b, int c, int d) { \
973 bool found; \
974 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
975 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
976 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
977 a,b,c,d)); \
978 wxPyEndBlockThreads(blocked); \
979 if (! found) \
980 PCLASS::CBNAME(a, b, c, d); \
981 }
982
983 //---------------------------------------------------------------------------
984
985 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
986 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
987
988
989 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
990 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
991 bool found; \
992 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
993 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
994 PyObject* obj = wxPyMake_wxObject(&a,false); \
995 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
996 Py_DECREF(obj); \
997 } \
998 wxPyEndBlockThreads(blocked); \
999 if (! found) \
1000 PCLASS::CBNAME(a, b, c, d, e, f); \
1001 }
1002
1003 //---------------------------------------------------------------------------
1004
1005 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
1006 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1007
1008
1009 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1010 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1011 bool found; \
1012 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1013 bool rval=false; \
1014 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1015 PyObject* obj = wxPyMake_wxObject(&a,false); \
1016 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
1017 Py_DECREF(obj); \
1018 } \
1019 wxPyEndBlockThreads(blocked); \
1020 if (! found) \
1021 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
1022 return rval; \
1023 }
1024
1025 //---------------------------------------------------------------------------
1026
1027 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
1028 void CBNAME(bool a, double b, double c, int d, int e)
1029
1030
1031 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1032 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
1033 bool found; \
1034 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1035 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1036 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
1037 (int)a,b,c,d,e)); \
1038 wxPyEndBlockThreads(blocked); \
1039 if (! found) \
1040 PCLASS::CBNAME(a, b, c, d, e); \
1041 }
1042
1043 //---------------------------------------------------------------------------
1044
1045 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
1046 void CBNAME(wxDC& a, double b, double c, double d, double e)
1047
1048
1049 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
1050 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
1051 bool found; \
1052 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1053 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1054 PyObject* obj = wxPyMake_wxObject(&a,false); \
1055 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
1056 Py_DECREF(obj); \
1057 } \
1058 wxPyEndBlockThreads(blocked); \
1059 if (! found) \
1060 PCLASS::CBNAME(a, b, c, d, e); \
1061 }
1062
1063 //---------------------------------------------------------------------------
1064
1065 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
1066 void CBNAME(wxDC& a, bool b)
1067
1068
1069 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
1070 void CLASS::CBNAME(wxDC& a, bool b) { \
1071 bool found; \
1072 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1073 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1074 PyObject* obj = wxPyMake_wxObject(&a,false); \
1075 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
1076 Py_DECREF(obj); \
1077 } \
1078 wxPyEndBlockThreads(blocked); \
1079 if (! found) \
1080 PCLASS::CBNAME(a, b); \
1081 }
1082
1083 //---------------------------------------------------------------------------
1084
1085 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
1086 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f)
1087
1088
1089 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1090 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
1091 int e, int f) { \
1092 bool found; \
1093 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1094 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1095 PyObject* obj = wxPyMake_wxObject(a,false); \
1096 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
1097 Py_DECREF(obj); \
1098 } \
1099 wxPyEndBlockThreads(blocked); \
1100 if (! found) \
1101 PCLASS::CBNAME(a, b, c, d, e, f); \
1102 }
1103
1104 //---------------------------------------------------------------------------
1105
1106 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
1107 void CBNAME(wxControlPoint* a, double b, double c, int d, int e)
1108
1109
1110 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
1111 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
1112 bool found; \
1113 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1114 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1115 PyObject* obj = wxPyMake_wxObject(a,false); \
1116 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
1117 Py_DECREF(obj); \
1118 } \
1119 wxPyEndBlockThreads(blocked); \
1120 if (! found) \
1121 PCLASS::CBNAME(a, b, c, d, e); \
1122 }
1123
1124 //---------------------------------------------------------------------------
1125
1126 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
1127 void CBNAME(double a, double b, int c)
1128
1129
1130 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
1131 void CLASS::CBNAME(double a, double b, int c) { \
1132 bool found; \
1133 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1134 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1135 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
1136 wxPyEndBlockThreads(blocked); \
1137 if (! found) \
1138 PCLASS::CBNAME(a, b, c); \
1139 }
1140
1141 //---------------------------------------------------------------------------
1142
1143 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
1144 void CBNAME(bool a, double b, double c, int d)
1145
1146
1147 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
1148 void CLASS::CBNAME(bool a, double b, double c, int d) { \
1149 bool found; \
1150 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1151 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1152 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\
1153 wxPyEndBlockThreads(blocked); \
1154 if (! found) \
1155 PCLASS::CBNAME(a, b, c, d); \
1156 }
1157
1158 //---------------------------------------------------------------------------
1159 //---------------------------------------------------------------------------
1160
1161 #define DEC_PYCALLBACK__STRING(CBNAME) \
1162 void CBNAME(const wxString& a)
1163
1164 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
1165 void CLASS::CBNAME(const wxString& a) { \
1166 bool found; \
1167 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1168 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1169 PyObject* s = wx2PyString(a); \
1170 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1171 Py_DECREF(s); \
1172 } \
1173 wxPyEndBlockThreads(blocked); \
1174 if (! found) \
1175 PCLASS::CBNAME(a); \
1176 }
1177
1178 //---------------------------------------------------------------------------
1179
1180 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
1181 bool CBNAME(const wxString& a)
1182
1183 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
1184 bool CLASS::CBNAME(const wxString& a) { \
1185 bool rval=false; \
1186 bool found; \
1187 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1188 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1189 PyObject* s = wx2PyString(a); \
1190 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1191 Py_DECREF(s); \
1192 } \
1193 wxPyEndBlockThreads(blocked); \
1194 if (! found) \
1195 rval = PCLASS::CBNAME(a); \
1196 return rval; \
1197 }
1198
1199 //---------------------------------------------------------------------------
1200
1201 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
1202 bool CBNAME(const wxString& a)
1203
1204 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
1205 bool CLASS::CBNAME(const wxString& a) { \
1206 bool rval=false; \
1207 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1208 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1209 PyObject* s = wx2PyString(a); \
1210 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1211 Py_DECREF(s); \
1212 } \
1213 wxPyEndBlockThreads(blocked); \
1214 return rval; \
1215 } \
1216
1217 //---------------------------------------------------------------------------
1218
1219 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
1220 wxString CBNAME(const wxString& a)
1221
1222 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
1223 wxString CLASS::CBNAME(const wxString& a) { \
1224 wxString rval; \
1225 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1226 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1227 PyObject* ro; \
1228 PyObject* s = wx2PyString(a); \
1229 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1230 Py_DECREF(s); \
1231 if (ro) { \
1232 rval = Py2wxString(ro); \
1233 Py_DECREF(ro); \
1234 } \
1235 } \
1236 wxPyEndBlockThreads(blocked); \
1237 return rval; \
1238 } \
1239
1240 //---------------------------------------------------------------------------
1241
1242 #define DEC_PYCALLBACK_STRING_STRING(CBNAME) \
1243 wxString CBNAME(const wxString& a)
1244
1245 #define IMP_PYCALLBACK_STRING_STRING(CLASS, PCLASS, CBNAME) \
1246 wxString CLASS::CBNAME(const wxString& a) { \
1247 wxString rval; \
1248 bool found; \
1249 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1250 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1251 PyObject* ro; \
1252 PyObject* s = wx2PyString(a); \
1253 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1254 Py_DECREF(s); \
1255 if (ro) { \
1256 rval = Py2wxString(ro); \
1257 Py_DECREF(ro); \
1258 } \
1259 } \
1260 if (! found) \
1261 rval = PCLASS::CBNAME(a); \
1262 wxPyEndBlockThreads(blocked); \
1263 return rval; \
1264 } \
1265
1266 //---------------------------------------------------------------------------
1267
1268 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
1269 wxString CBNAME(const wxString& a,int b)
1270
1271 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
1272 wxString CLASS::CBNAME(const wxString& a,int b) { \
1273 wxString rval; \
1274 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1275 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1276 PyObject* ro; \
1277 PyObject* s = wx2PyString(a); \
1278 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oi)",s,b)); \
1279 Py_DECREF(s); \
1280 if (ro) { \
1281 rval = Py2wxString(ro); \
1282 Py_DECREF(ro); \
1283 } \
1284 } \
1285 wxPyEndBlockThreads(blocked); \
1286 return rval; \
1287 } \
1288
1289 //---------------------------------------------------------------------------
1290
1291 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
1292 bool CBNAME(const wxString& a, const wxString& b)
1293
1294 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
1295 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
1296 bool rval=false; \
1297 bool found; \
1298 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1299 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1300 PyObject* s1 = wx2PyString(a); \
1301 PyObject* s2 = wx2PyString(b); \
1302 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",s1,s2)); \
1303 Py_DECREF(s1); \
1304 Py_DECREF(s2); \
1305 } \
1306 wxPyEndBlockThreads(blocked); \
1307 if (! found) \
1308 rval = PCLASS::CBNAME(a, b); \
1309 return rval; \
1310 }
1311
1312 //---------------------------------------------------------------------------
1313
1314 #define DEC_PYCALLBACK_STRING_(CBNAME) \
1315 wxString CBNAME()
1316
1317 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
1318 wxString CLASS::CBNAME() { \
1319 wxString rval; \
1320 bool found; \
1321 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1322 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1323 PyObject* ro; \
1324 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1325 if (ro) { \
1326 rval = Py2wxString(ro); \
1327 Py_DECREF(ro); \
1328 } \
1329 } \
1330 wxPyEndBlockThreads(blocked); \
1331 if (! found) \
1332 rval = PCLASS::CBNAME(); \
1333 return rval; \
1334 }
1335
1336 //---------------------------------------------------------------------------
1337
1338 #define DEC_PYCALLBACK_STRING__const(CBNAME) \
1339 wxString CBNAME() const
1340
1341 #define IMP_PYCALLBACK_STRING__const(CLASS, PCLASS, CBNAME) \
1342 wxString CLASS::CBNAME() const { \
1343 wxString rval; \
1344 bool found; \
1345 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1346 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1347 PyObject* ro; \
1348 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1349 if (ro) { \
1350 rval = Py2wxString(ro); \
1351 Py_DECREF(ro); \
1352 } \
1353 } \
1354 wxPyEndBlockThreads(blocked); \
1355 if (! found) \
1356 rval = PCLASS::CBNAME(); \
1357 return rval; \
1358 }
1359
1360 //---------------------------------------------------------------------------
1361
1362 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
1363 wxString CBNAME()
1364
1365 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
1366 wxString CLASS::CBNAME() { \
1367 wxString rval; \
1368 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1369 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1370 PyObject* ro; \
1371 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1372 if (ro) { \
1373 rval = Py2wxString(ro); \
1374 Py_DECREF(ro); \
1375 } \
1376 } \
1377 wxPyEndBlockThreads(blocked); \
1378 return rval; \
1379 }
1380
1381 //---------------------------------------------------------------------------
1382
1383 #define DEC_PYCALLBACK_STRING__constpure(CBNAME) \
1384 wxString CBNAME() const;
1385
1386 #define IMP_PYCALLBACK_STRING__constpure(CLASS, PCLASS, CBNAME) \
1387 wxString CLASS::CBNAME() const { \
1388 wxString rval; \
1389 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1390 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1391 PyObject* ro; \
1392 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1393 if (ro) { \
1394 rval = Py2wxString(ro); \
1395 Py_DECREF(ro); \
1396 } \
1397 } \
1398 wxPyEndBlockThreads(blocked); \
1399 return rval; \
1400 }
1401
1402 //---------------------------------------------------------------------------
1403
1404 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
1405 bool CBNAME(const wxHtmlTag& a)
1406
1407
1408 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
1409 bool CLASS::CBNAME(const wxHtmlTag& a) { \
1410 bool rval=false; \
1411 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1412 if (wxPyCBH_findCallback2(m_myInst, #CBNAME, false)) { \
1413 PyObject* obj = wxPyConstructObject((void*)&a, wxT("wxHtmlTag"), 0);\
1414 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1415 Py_DECREF(obj); \
1416 } \
1417 wxPyEndBlockThreads(blocked); \
1418 return rval; \
1419 }
1420
1421 //---------------------------------------------------------------------------
1422
1423 #define DEC_PYCALLBACK__CELLINTINT(CBNAME) \
1424 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y)
1425
1426 #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \
1427 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1428 bool found; \
1429 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1430 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1431 PyObject* obj = wxPyMake_wxObject(cell, 0); \
1432 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \
1433 Py_DECREF(obj); \
1434 } \
1435 wxPyEndBlockThreads(blocked); \
1436 if (! found) \
1437 PCLASS::CBNAME(cell, x, y); \
1438 }
1439
1440 //---------------------------------------------------------------------------
1441
1442 #define DEC_PYCALLBACK__COLOUR(CBNAME) \
1443 void CBNAME(const wxColour& c);
1444
1445 #define IMP_PYCALLBACK__COLOUR(CLASS, PCLASS, CBNAME) \
1446 void CLASS::CBNAME(const wxColour& c) { \
1447 bool found; \
1448 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1449 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1450 PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxColour"), 0); \
1451 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
1452 Py_DECREF(obj); \
1453 } \
1454 wxPyEndBlockThreads(blocked); \
1455 if (! found) \
1456 PCLASS::CBNAME(c); \
1457 } \
1458
1459 //---------------------------------------------------------------------------
1460
1461 #define DEC_PYCALLBACK_BOOL_CELLINTINTME(CBNAME) \
1462 bool CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e)
1463
1464 #define IMP_PYCALLBACK_BOOL_CELLINTINTME(CLASS, PCLASS, CBNAME) \
1465 bool CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1466 bool rval=false, found; \
1467 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1468 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1469 PyObject* obj = wxPyMake_wxObject(cell, 0); \
1470 PyObject* o2 = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
1471 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1472 Py_DECREF(obj); \
1473 Py_DECREF(o2); \
1474 } \
1475 wxPyEndBlockThreads(blocked); \
1476 if (! found) \
1477 rval = PCLASS::CBNAME(cell, x, y, e); \
1478 return rval; \
1479 }
1480
1481
1482 //---------------------------------------------------------------------------
1483
1484 #define DEC_PYCALLBACK___pure(CBNAME) \
1485 void CBNAME()
1486
1487
1488 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1489 void CLASS::CBNAME() { \
1490 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1491 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1492 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1493 wxPyEndBlockThreads(blocked); \
1494 }
1495
1496 //---------------------------------------------------------------------------
1497
1498 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1499 wxSize CBNAME()
1500
1501
1502 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1503 wxSize CLASS::CBNAME() { \
1504 const char* errmsg = #CBNAME " should return a 2-tuple of integers or a wxSize object."; \
1505 wxSize rval(0,0); \
1506 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1507 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1508 PyObject* ro; \
1509 wxSize* ptr; \
1510 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1511 if (ro) { \
1512 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxSize"))) \
1513 rval = *ptr; \
1514 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
1515 PyErr_Clear(); \
1516 PyObject* o1 = PySequence_GetItem(ro, 0); \
1517 PyObject* o2 = PySequence_GetItem(ro, 1); \
1518 if (PyNumber_Check(o1) && PyNumber_Check(o2)) \
1519 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
1520 else \
1521 PyErr_SetString(PyExc_TypeError, errmsg); \
1522 Py_DECREF(o1); \
1523 Py_DECREF(o2); \
1524 } \
1525 else { \
1526 PyErr_SetString(PyExc_TypeError, errmsg); \
1527 } \
1528 Py_DECREF(ro); \
1529 } \
1530 } \
1531 wxPyEndBlockThreads(blocked); \
1532 return rval; \
1533 }
1534
1535 //---------------------------------------------------------------------------
1536
1537 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1538 bool CBNAME(wxWindow* a)
1539
1540
1541 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1542 bool CLASS::CBNAME(wxWindow* a) { \
1543 bool rval=false; \
1544 bool found; \
1545 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1546 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1547 PyObject* obj = wxPyMake_wxObject(a,false); \
1548 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1549 Py_DECREF(obj); \
1550 } \
1551 wxPyEndBlockThreads(blocked); \
1552 if (! found) \
1553 rval = PCLASS::CBNAME(a); \
1554 return rval; \
1555 }
1556
1557 //---------------------------------------------------------------------------
1558
1559 #define DEC_PYCALLBACK_BOOL_WXWINDC(CBNAME) \
1560 bool CBNAME(wxWindow* a, wxDC& b)
1561
1562
1563 #define IMP_PYCALLBACK_BOOL_WXWINDC(CLASS, PCLASS, CBNAME) \
1564 bool CLASS::CBNAME(wxWindow* a, wxDC& b) { \
1565 bool rval=false; \
1566 bool found; \
1567 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1568 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1569 PyObject* win = wxPyMake_wxObject(a,false); \
1570 PyObject* dc = wxPyMake_wxObject(&b,false); \
1571 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc));\
1572 Py_DECREF(win); \
1573 Py_DECREF(dc); \
1574 } \
1575 wxPyEndBlockThreads(blocked); \
1576 if (! found) \
1577 rval = PCLASS::CBNAME(a, b); \
1578 return rval; \
1579 }
1580
1581 //---------------------------------------------------------------------------
1582
1583 #define DEC_PYCALLBACK_VOID_WXWINBASE(CBNAME) \
1584 void CBNAME(wxWindowBase* a)
1585
1586
1587 #define IMP_PYCALLBACK_VOID_WXWINBASE(CLASS, PCLASS, CBNAME) \
1588 void CLASS::CBNAME(wxWindowBase* a) { \
1589 bool found; \
1590 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1591 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1592 PyObject* obj = wxPyMake_wxObject(a,false); \
1593 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1594 Py_DECREF(obj); \
1595 } \
1596 wxPyEndBlockThreads(blocked); \
1597 if (! found) \
1598 PCLASS::CBNAME(a); \
1599 }
1600
1601 //---------------------------------------------------------------------------
1602
1603 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1604 bool CBNAME()
1605
1606
1607 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1608 bool CLASS::CBNAME() { \
1609 bool rval=false; \
1610 bool found; \
1611 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1612 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1613 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1614 wxPyEndBlockThreads(blocked); \
1615 if (! found) \
1616 rval = PCLASS::CBNAME(); \
1617 return rval; \
1618 }
1619
1620 //---------------------------------------------------------------------------
1621
1622 #define DEC_PYCALLBACK_BOOL_const(CBNAME) \
1623 bool CBNAME() const
1624
1625
1626 #define IMP_PYCALLBACK_BOOL_const(CLASS, PCLASS, CBNAME) \
1627 bool CLASS::CBNAME() const { \
1628 bool rval=false; \
1629 bool found; \
1630 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1631 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1632 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1633 wxPyEndBlockThreads(blocked); \
1634 if (! found) \
1635 rval = PCLASS::CBNAME(); \
1636 return rval; \
1637 }
1638
1639 //---------------------------------------------------------------------------
1640
1641 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1642 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1643
1644
1645 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1646 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1647 int rval=0; \
1648 bool found; \
1649 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1650 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1651 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1652 wxPyEndBlockThreads(blocked); \
1653 if (! found) \
1654 rval = PCLASS::CBNAME(a, b, c); \
1655 return (wxDragResult)rval; \
1656 }
1657
1658 //---------------------------------------------------------------------------
1659
1660 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1661 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location)
1662
1663 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1664 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1665 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1666 wxFSFile* rval=0; \
1667 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1668 PyObject* ro; \
1669 PyObject* obj = wxPyMake_wxObject(&a,false); \
1670 PyObject* s = wx2PyString(b); \
1671 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)", \
1672 obj, s)); \
1673 if (ro) { \
1674 wxPyConvertSwigPtr(ro, (void **)&rval, wxT("wxFSFile")); \
1675 Py_DECREF(ro); \
1676 } \
1677 Py_DECREF(obj); \
1678 Py_DECREF(s); \
1679 } \
1680 wxPyEndBlockThreads(blocked); \
1681 return rval; \
1682 };
1683
1684 //---------------------------------------------------------------------------
1685
1686 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1687 bool CBNAME(wxDragResult a)
1688
1689
1690 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1691 bool CLASS::CBNAME(wxDragResult a) { \
1692 bool rval=false; \
1693 bool found; \
1694 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1695 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1696 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
1697 wxPyEndBlockThreads(blocked); \
1698 if (! found) \
1699 rval = PCLASS::CBNAME(a); \
1700 return rval; \
1701 }
1702
1703 //---------------------------------------------------------------------------
1704
1705 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1706 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1707
1708
1709 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1710 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1711 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1712 int rval=0; \
1713 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1714 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1715 wxPyEndBlockThreads(blocked); \
1716 return (wxDragResult)rval; \
1717 } \
1718
1719 //---------------------------------------------------------------------------
1720
1721 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1722 bool CBNAME(int a, int b, const wxString& c)
1723
1724 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1725 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1726 bool rval=false; \
1727 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1728 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1729 PyObject* s = wx2PyString(c); \
1730 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
1731 Py_DECREF(s); \
1732 } \
1733 wxPyEndBlockThreads(blocked); \
1734 return rval; \
1735 } \
1736
1737 //---------------------------------------------------------------------------
1738
1739 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1740 size_t CBNAME()
1741
1742
1743 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1744 size_t CLASS::CBNAME() { \
1745 size_t rval=0; \
1746 bool found; \
1747 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1748 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1749 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1750 wxPyEndBlockThreads(blocked); \
1751 if (! found) \
1752 rval = PCLASS::CBNAME(); \
1753 return rval; \
1754 }
1755
1756 //---------------------------------------------------------------------------
1757
1758 #define DEC_PYCALLBACK_SIZET__const(CBNAME) \
1759 size_t CBNAME() const
1760
1761
1762 #define IMP_PYCALLBACK_SIZET__const(CLASS, PCLASS, CBNAME) \
1763 size_t CLASS::CBNAME() const { \
1764 size_t rval=0; \
1765 bool found; \
1766 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1767 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1768 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1769 wxPyEndBlockThreads(blocked); \
1770 if (! found) \
1771 rval = PCLASS::CBNAME(); \
1772 return rval; \
1773 }
1774
1775 //---------------------------------------------------------------------------
1776
1777 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1778 wxDataFormat CBNAME(size_t a)
1779
1780
1781 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1782 wxDataFormat CLASS::CBNAME(size_t a) { \
1783 wxDataFormat rval=0; \
1784 bool found; \
1785 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1786 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1787 PyObject* ro; \
1788 wxDataFormat* ptr; \
1789 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1790 if (ro) { \
1791 if (wxPyCOnvertSwigPtr(ro, (void **)&ptr, wxT("wxDataFormat"))) \
1792 rval = *ptr; \
1793 Py_DECREF(ro); \
1794 } \
1795 } \
1796 wxPyEndBlockThreads(blocked); \
1797 if (! found) \
1798 rval = PCLASS::CBNAME(a); \
1799 return rval; \
1800 }
1801
1802 //---------------------------------------------------------------------------
1803
1804 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1805 void CBNAME(const Type& a)
1806
1807
1808 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1809 void CLASS::CBNAME(const Type& a) { \
1810 bool found; \
1811 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1812 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1813 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1814 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1815 Py_DECREF(obj); \
1816 } \
1817 wxPyEndBlockThreads(blocked); \
1818 if (! found) \
1819 PCLASS::CBNAME(a); \
1820 }
1821
1822
1823 //---------------------------------------------------------------------------
1824
1825 #define DEC_PYCALLBACK__any(CBNAME, Type) \
1826 void CBNAME(Type& a)
1827
1828
1829 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1830 void CLASS::CBNAME(Type& a) { \
1831 bool found; \
1832 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1833 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1834 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1835 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1836 Py_DECREF(obj); \
1837 } \
1838 wxPyEndBlockThreads(blocked); \
1839 if (! found) \
1840 PCLASS::CBNAME(a); \
1841 }
1842
1843 //---------------------------------------------------------------------------
1844
1845 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1846 bool CBNAME(Type& a)
1847
1848
1849 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
1850 bool CLASS::CBNAME(Type& a) { \
1851 bool rv=false; \
1852 bool found; \
1853 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1854 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1855 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1856 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1857 Py_DECREF(obj); \
1858 } \
1859 wxPyEndBlockThreads(blocked); \
1860 if (! found) \
1861 rv = PCLASS::CBNAME(a); \
1862 return rv; \
1863 }
1864
1865 //---------------------------------------------------------------------------
1866
1867 #define DEC_PYCALLBACK_bool_anypure(CBNAME, Type) \
1868 bool CBNAME(Type& a)
1869
1870
1871 #define IMP_PYCALLBACK_bool_anypure(CLASS, PCLASS, CBNAME, Type) \
1872 bool CLASS::CBNAME(Type& a) { \
1873 bool rv=false; \
1874 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1875 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1876 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1877 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1878 Py_DECREF(obj); \
1879 } \
1880 wxPyEndBlockThreads(blocked); \
1881 return rv; \
1882 } \
1883
1884 //---------------------------------------------------------------------------
1885
1886 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
1887 wxString CBNAME(long a, long b) const
1888
1889 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
1890 wxString CLASS::CBNAME(long a, long b) const { \
1891 wxString rval; \
1892 bool found; \
1893 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1894 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1895 PyObject* ro; \
1896 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1897 if (ro) { \
1898 rval = Py2wxString(ro); \
1899 Py_DECREF(ro); \
1900 } \
1901 } \
1902 wxPyEndBlockThreads(blocked); \
1903 if (! found) \
1904 rval = PCLASS::CBNAME(a,b); \
1905 return rval; \
1906 }
1907
1908 //---------------------------------------------------------------------------
1909
1910 #define DEC_PYCALLBACK_INT_LONG(CBNAME) \
1911 int CBNAME(long a) const
1912
1913
1914 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
1915 int CLASS::CBNAME(long a) const { \
1916 int rval=-1; \
1917 bool found; \
1918 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1919 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1920 PyObject* ro; \
1921 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1922 if (ro) { \
1923 rval = PyInt_AsLong(ro); \
1924 Py_DECREF(ro); \
1925 } \
1926 } \
1927 wxPyEndBlockThreads(blocked); \
1928 if (! found) \
1929 rval = PCLASS::CBNAME(a); \
1930 return rval; \
1931 }
1932
1933
1934 #define DEC_PYCALLBACK_INT_LONG_virtual(CBNAME) \
1935 int CBNAME(long a) const;
1936
1937
1938 #define IMP_PYCALLBACK_INT_LONG_virtual(CLASS, PCLASS, CBNAME) \
1939 int CLASS::CBNAME(long a) const { \
1940 int rval=-1; /* this rval is important for OnGetItemImage */ \
1941 bool found; \
1942 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1943 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1944 PyObject* ro; \
1945 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1946 if (ro) { \
1947 rval = PyInt_AsLong(ro); \
1948 Py_DECREF(ro); \
1949 } \
1950 } \
1951 wxPyEndBlockThreads(blocked); \
1952 return rval; \
1953 }
1954
1955
1956 //---------------------------------------------------------------------------
1957
1958 #define DEC_PYCALLBACK_INT_LONGLONG(CBNAME) \
1959 int CBNAME(long a, long b) const
1960
1961
1962 #define IMP_PYCALLBACK_INT_LONGLONG(CLASS, PCLASS, CBNAME) \
1963 int CLASS::CBNAME(long a, long b) const { \
1964 int rval=-1; \
1965 bool found; \
1966 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1967 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1968 PyObject* ro; \
1969 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1970 if (ro) { \
1971 rval = PyInt_AsLong(ro); \
1972 Py_DECREF(ro); \
1973 } \
1974 } \
1975 wxPyEndBlockThreads(blocked); \
1976 if (! found) \
1977 rval = PCLASS::CBNAME(a, b); \
1978 return rval; \
1979 }
1980
1981
1982 #define DEC_PYCALLBACK_INT_LONGLONG_virtual(CBNAME) \
1983 int CBNAME(long a, long b) const;
1984
1985
1986 #define IMP_PYCALLBACK_INT_LONGLONG_virtual(CLASS, PCLASS, CBNAME) \
1987 int CLASS::CBNAME(long a, long b) const { \
1988 int rval=-1; /* this rval is important for OnGetItemImage */ \
1989 bool found; \
1990 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1991 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1992 PyObject* ro; \
1993 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1994 if (ro) { \
1995 rval = PyInt_AsLong(ro); \
1996 Py_DECREF(ro); \
1997 } \
1998 } \
1999 wxPyEndBlockThreads(blocked); \
2000 return rval; \
2001 }
2002
2003
2004 //---------------------------------------------------------------------------
2005
2006 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
2007 wxListItemAttr* CBNAME(long a) const
2008
2009
2010 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
2011 wxListItemAttr *CLASS::CBNAME(long a) const { \
2012 wxListItemAttr *rval = NULL; \
2013 bool found; \
2014 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2015 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2016 PyObject* ro; \
2017 wxListItemAttr* ptr; \
2018 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2019 if (ro) { \
2020 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxListItemAttr")))\
2021 rval = ptr; \
2022 Py_DECREF(ro); \
2023 } \
2024 } \
2025 wxPyEndBlockThreads(blocked); \
2026 if (! found) \
2027 rval = PCLASS::CBNAME(a); \
2028 return rval; \
2029 }
2030
2031 //---------------------------------------------------------------------------
2032
2033 #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
2034 bool CBNAME(wxMouseEvent& e)
2035
2036 #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
2037 bool CLASS::CBNAME(wxMouseEvent& e) { \
2038 bool rval=false; \
2039 bool found; \
2040 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2041 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2042 PyObject* ro; \
2043 PyObject* obj = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
2044 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
2045 if (ro) { \
2046 rval = PyInt_AsLong(ro); \
2047 Py_DECREF(ro); \
2048 } \
2049 Py_DECREF(obj); \
2050 } \
2051 wxPyEndBlockThreads(blocked); \
2052 if (! found) \
2053 return PCLASS::CBNAME(e); \
2054 return rval; \
2055 }
2056
2057 //---------------------------------------------------------------------------
2058
2059 #define DEC_PYCALLBACK_WIZPG__pure(CBNAME) \
2060 wxWizardPage* CBNAME() const
2061
2062 #define IMP_PYCALLBACK_WIZPG__pure(CLASS, PCLASS, CBNAME) \
2063 wxWizardPage* CLASS::CBNAME() const { \
2064 wxWizardPage* rv = NULL; \
2065 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2066 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2067 PyObject* ro; \
2068 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2069 if (ro) { \
2070 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxWizardPage")); \
2071 Py_DECREF(ro); \
2072 } \
2073 } \
2074 wxPyEndBlockThreads(blocked); \
2075 return rv; \
2076 }
2077
2078 //---------------------------------------------------------------------------
2079
2080 #define DEC_PYCALLBACK_BITMAP__pure(CBNAME) \
2081 wxBitmap CBNAME() const
2082
2083 #define IMP_PYCALLBACK_BITMAP__pure(CLASS, PCLASS, CBNAME) \
2084 wxBitmap CLASS::CBNAME() const { \
2085 wxBitmap rv; \
2086 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2087 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2088 PyObject* ro; \
2089 wxBitmap* ptr; \
2090 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2091 if (ro) { \
2092 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxBitmap"))) \
2093 rv = *ptr; \
2094 Py_DECREF(ro); \
2095 } \
2096 } \
2097 wxPyEndBlockThreads(blocked); \
2098 return rv; \
2099 }
2100
2101 //---------------------------------------------------------------------------
2102
2103 #define DEC_PYCALLBACK_OBJECT__pure(CBNAME) \
2104 wxObject* CBNAME()
2105
2106 #define IMP_PYCALLBACK_OBJECT__pure(CLASS, PCLASS, CBNAME) \
2107 wxObject* CLASS::CBNAME() { \
2108 wxObject* rv = NULL; \
2109 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2110 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2111 PyObject* ro; \
2112 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2113 if (ro) { \
2114 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2115 Py_DECREF(ro); \
2116 } \
2117 } \
2118 wxPyEndBlockThreads(blocked); \
2119 return rv; \
2120 }
2121
2122 //---------------------------------------------------------------------------
2123
2124 #define DEC_PYCALLBACK_OBJECT_STRING_pure(CBNAME) \
2125 wxObject* CBNAME(const wxString& a)
2126
2127 #define IMP_PYCALLBACK_OBJECT_STRING_pure(CLASS, PCLASS, CBNAME) \
2128 wxObject* CLASS::CBNAME(const wxString& a) { \
2129 wxObject* rv = NULL; \
2130 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2131 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2132 PyObject* so = wx2PyString(a); \
2133 PyObject* ro; \
2134 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", so)); \
2135 if (ro) { \
2136 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2137 Py_DECREF(ro); \
2138 } \
2139 Py_DECREF(so); \
2140 } \
2141 wxPyEndBlockThreads(blocked); \
2142 return rv; \
2143 }
2144
2145 //---------------------------------------------------------------------------
2146
2147 #define DEC_PYCALLBACK_BOOL_NODE_pure(CBNAME) \
2148 bool CBNAME(wxXmlNode* a)
2149
2150
2151 #define IMP_PYCALLBACK_BOOL_NODE_pure(CLASS, PCLASS, CBNAME) \
2152 bool CLASS::CBNAME(wxXmlNode* a) { \
2153 bool rv=false; \
2154 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2155 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2156 PyObject* obj = wxPyConstructObject((void*)a, wxT("wxXmlNode"), 0); \
2157 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2158 Py_DECREF(obj); \
2159 } \
2160 wxPyEndBlockThreads(blocked); \
2161 return rv; \
2162 } \
2163
2164 //---------------------------------------------------------------------------
2165
2166 #define DEC_PYCALLBACK_COORD_SIZET_constpure(CBNAME) \
2167 wxCoord CBNAME(size_t a) const
2168
2169
2170 #define IMP_PYCALLBACK_COORD_SIZET_constpure(CLASS, PCLASS, CBNAME) \
2171 wxCoord CLASS::CBNAME(size_t a) const { \
2172 wxCoord rval=0; \
2173 bool found; \
2174 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2175 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2176 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
2177 } \
2178 wxPyEndBlockThreads(blocked); \
2179 return rval; \
2180 } \
2181
2182 //---------------------------------------------------------------------------
2183
2184 #define DEC_PYCALLBACK_VOID_SIZETSIZET_const(CBNAME) \
2185 void CBNAME(size_t a, size_t b) const
2186
2187
2188 #define IMP_PYCALLBACK_VOID_SIZETSIZET_const(CLASS, PCLASS, CBNAME) \
2189 void CLASS::CBNAME(size_t a, size_t b) const { \
2190 bool found; \
2191 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2192 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2193 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
2194 wxPyEndBlockThreads(blocked); \
2195 if (! found) \
2196 PCLASS::CBNAME(a,b); \
2197 }
2198 //---------------------------------------------------------------------------
2199
2200 #define DEC_PYCALLBACK_COORD_const(CBNAME) \
2201 wxCoord CBNAME() const
2202
2203
2204 #define IMP_PYCALLBACK_COORD_const(CLASS, PCLASS, CBNAME) \
2205 wxCoord CLASS::CBNAME() const { \
2206 wxCoord rval=0; \
2207 bool found; \
2208 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2209 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2210 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
2211 wxPyEndBlockThreads(blocked); \
2212 if (! found) \
2213 rval = PCLASS::CBNAME(); \
2214 return rval; \
2215 }
2216
2217 //---------------------------------------------------------------------------
2218
2219 #define DEC_PYCALLBACK__DCRECTSIZET_constpure(CBNAME) \
2220 void CBNAME(wxDC& a, const wxRect& b, size_t c) const;
2221
2222 #define IMP_PYCALLBACK__DCRECTSIZET_constpure(CLASS, PCLASS, CBNAME) \
2223 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2224 bool found; \
2225 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2226 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2227 PyObject* obj = wxPyMake_wxObject(&a,false); \
2228 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2229 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2230 Py_DECREF(obj); \
2231 } \
2232 wxPyEndBlockThreads(blocked); \
2233 } \
2234
2235
2236
2237 #define DEC_PYCALLBACK__DCRECTSIZET_const(CBNAME) \
2238 void CBNAME(wxDC& a, const wxRect& b, size_t c) const
2239
2240 #define IMP_PYCALLBACK__DCRECTSIZET_const(CLASS, PCLASS, CBNAME) \
2241 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2242 bool found; \
2243 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2244 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2245 PyObject* obj = wxPyMake_wxObject(&a,false); \
2246 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2247 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2248 Py_DECREF(obj); \
2249 } \
2250 wxPyEndBlockThreads(blocked); \
2251 if (! found) \
2252 PCLASS::CBNAME(a,b,c); \
2253 }
2254
2255
2256 //---------------------------------------------------------------------------
2257 // Same as the above set, but the wxRect is not const
2258
2259 #define DEC_PYCALLBACK__DCRECTSIZET2_constpure(CBNAME) \
2260 void CBNAME(wxDC& a, wxRect& b, size_t c) const;
2261
2262 #define IMP_PYCALLBACK__DCRECTSIZET2_constpure(CLASS, PCLASS, CBNAME) \
2263 void CLASS::CBNAME(wxDC& a, wxRect& b, size_t c) const { \
2264 bool found; \
2265 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2266 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2267 PyObject* obj = wxPyMake_wxObject(&a,false); \
2268 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2269 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2270 Py_DECREF(obj); \
2271 } \
2272 wxPyEndBlockThreads(blocked); \
2273 } \
2274
2275
2276
2277 #define DEC_PYCALLBACK__DCRECTSIZET2_const(CBNAME) \
2278 void CBNAME(wxDC& a, wxRect& b, size_t c) const
2279
2280 #define IMP_PYCALLBACK__DCRECTSIZET2_const(CLASS, PCLASS, CBNAME) \
2281 void CLASS::CBNAME(wxDC& a, wxRect& b, size_t c) const { \
2282 bool found; \
2283 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2284 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2285 PyObject* obj = wxPyMake_wxObject(&a,false); \
2286 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2287 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2288 Py_DECREF(obj); \
2289 } \
2290 wxPyEndBlockThreads(blocked); \
2291 if (! found) \
2292 PCLASS::CBNAME(a,b,c); \
2293 }
2294
2295
2296
2297 //---------------------------------------------------------------------------
2298
2299
2300
2301 #define DEC_PYCALLBACK_STRING_SIZET(CBNAME) \
2302 wxString CBNAME(size_t a) const
2303
2304 #define IMP_PYCALLBACK_STRING_SIZET(CLASS, PCLASS, CBNAME) \
2305 wxString CLASS::CBNAME(size_t a) const { \
2306 wxString rval; \
2307 bool found; \
2308 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2309 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2310 PyObject* ro; \
2311 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2312 if (ro) { \
2313 rval = Py2wxString(ro); \
2314 Py_DECREF(ro); \
2315 } \
2316 } \
2317 wxPyEndBlockThreads(blocked); \
2318 if (! found) \
2319 rval = PCLASS::CBNAME(a); \
2320 return rval; \
2321 }
2322
2323 //---------------------------------------------------------------------------
2324
2325 #define DEC_PYCALLBACK_STRING_SIZET_pure(CBNAME) \
2326 wxString CBNAME(size_t a) const
2327
2328 #define IMP_PYCALLBACK_STRING_SIZET_pure(CLASS, PCLASS, CBNAME) \
2329 wxString CLASS::CBNAME(size_t a) const { \
2330 wxString rval; \
2331 bool found; \
2332 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2333 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2334 PyObject* ro; \
2335 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2336 if (ro) { \
2337 rval = Py2wxString(ro); \
2338 Py_DECREF(ro); \
2339 } \
2340 } \
2341 wxPyEndBlockThreads(blocked); \
2342 return rval; \
2343 } \
2344
2345 //---------------------------------------------------------------------------
2346
2347 #define DEC_PYCALLBACK_VIZATTR_(CBNAME) \
2348 wxVisualAttributes CBNAME() const
2349
2350
2351 #define IMP_PYCALLBACK_VIZATTR_(CLASS, PCLASS, CBNAME) \
2352 wxVisualAttributes CLASS::CBNAME() const { \
2353 wxVisualAttributes rval; \
2354 bool found; \
2355 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2356 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2357 PyObject* ro; \
2358 wxVisualAttributes* ptr; \
2359 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2360 if (ro) { \
2361 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxVisualAttributes"))) \
2362 rval = *ptr; \
2363 Py_DECREF(ro); \
2364 } \
2365 } \
2366 wxPyEndBlockThreads(blocked); \
2367 if (! found) \
2368 rval = PCLASS::CBNAME(); \
2369 return rval; \
2370 }
2371
2372 //---------------------------------------------------------------------------
2373
2374 #endif