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