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