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