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