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