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