]> git.saurik.com Git - wxWidgets.git/blob - wxPython/include/wx/wxPython/wxPython_int.h
4ca0e75196f4719e2cb87b48c924ffd550da7eba
[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 #define DEC_PYCALLBACK__INTCOLOUR(CBNAME) \
1474 void CBNAME(int a, const wxColour& c);
1475
1476 #define IMP_PYCALLBACK__INTCOLOUR(CLASS, PCLASS, CBNAME) \
1477 void CLASS::CBNAME(int a, const wxColour& c) { \
1478 bool found; \
1479 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1480 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1481 PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxColour"), 0); \
1482 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)",a, obj)); \
1483 Py_DECREF(obj); \
1484 } \
1485 wxPyEndBlockThreads(blocked); \
1486 if (! found) \
1487 PCLASS::CBNAME(a, c); \
1488 } \
1489
1490 //---------------------------------------------------------------------------
1491
1492 #define DEC_PYCALLBACK__INTFONT(CBNAME) \
1493 void CBNAME(int a, const wxFont& c);
1494
1495 #define IMP_PYCALLBACK__INTFONT(CLASS, PCLASS, CBNAME) \
1496 void CLASS::CBNAME(int a, const wxFont& c) { \
1497 bool found; \
1498 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1499 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1500 PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxFont"), 0); \
1501 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)",a, obj)); \
1502 Py_DECREF(obj); \
1503 } \
1504 wxPyEndBlockThreads(blocked); \
1505 if (! found) \
1506 PCLASS::CBNAME(a, c); \
1507 } \
1508
1509 //---------------------------------------------------------------------------
1510
1511 #define DEC_PYCALLBACK_BOOL_CELLINTINTME(CBNAME) \
1512 bool CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e)
1513
1514 #define IMP_PYCALLBACK_BOOL_CELLINTINTME(CLASS, PCLASS, CBNAME) \
1515 bool CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1516 bool rval=false, found; \
1517 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1518 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1519 PyObject* obj = wxPyMake_wxObject(cell, 0); \
1520 PyObject* o2 = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
1521 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1522 Py_DECREF(obj); \
1523 Py_DECREF(o2); \
1524 } \
1525 wxPyEndBlockThreads(blocked); \
1526 if (! found) \
1527 rval = PCLASS::CBNAME(cell, x, y, e); \
1528 return rval; \
1529 }
1530
1531
1532 //---------------------------------------------------------------------------
1533
1534 #define DEC_PYCALLBACK___pure(CBNAME) \
1535 void CBNAME()
1536
1537
1538 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1539 void CLASS::CBNAME() { \
1540 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1541 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1542 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1543 wxPyEndBlockThreads(blocked); \
1544 }
1545
1546 //---------------------------------------------------------------------------
1547
1548 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1549 wxSize CBNAME()
1550
1551
1552 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1553 wxSize CLASS::CBNAME() { \
1554 const char* errmsg = #CBNAME " should return a 2-tuple of integers or a wxSize object."; \
1555 wxSize rval(0,0); \
1556 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1557 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1558 PyObject* ro; \
1559 wxSize* ptr; \
1560 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1561 if (ro) { \
1562 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxSize"))) \
1563 rval = *ptr; \
1564 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
1565 PyErr_Clear(); \
1566 PyObject* o1 = PySequence_GetItem(ro, 0); \
1567 PyObject* o2 = PySequence_GetItem(ro, 1); \
1568 if (PyNumber_Check(o1) && PyNumber_Check(o2)) \
1569 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
1570 else \
1571 PyErr_SetString(PyExc_TypeError, errmsg); \
1572 Py_DECREF(o1); \
1573 Py_DECREF(o2); \
1574 } \
1575 else { \
1576 PyErr_SetString(PyExc_TypeError, errmsg); \
1577 } \
1578 Py_DECREF(ro); \
1579 } \
1580 } \
1581 wxPyEndBlockThreads(blocked); \
1582 return rval; \
1583 }
1584
1585 //---------------------------------------------------------------------------
1586
1587 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1588 bool CBNAME(wxWindow* a)
1589
1590
1591 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1592 bool CLASS::CBNAME(wxWindow* a) { \
1593 bool rval=false; \
1594 bool found; \
1595 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1596 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1597 PyObject* obj = wxPyMake_wxObject(a,false); \
1598 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1599 Py_DECREF(obj); \
1600 } \
1601 wxPyEndBlockThreads(blocked); \
1602 if (! found) \
1603 rval = PCLASS::CBNAME(a); \
1604 return rval; \
1605 }
1606
1607 //---------------------------------------------------------------------------
1608
1609 #define DEC_PYCALLBACK_BOOL_WXWINDC(CBNAME) \
1610 bool CBNAME(wxWindow* a, wxDC& b)
1611
1612
1613 #define IMP_PYCALLBACK_BOOL_WXWINDC(CLASS, PCLASS, CBNAME) \
1614 bool CLASS::CBNAME(wxWindow* a, wxDC& b) { \
1615 bool rval=false; \
1616 bool found; \
1617 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1618 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1619 PyObject* win = wxPyMake_wxObject(a,false); \
1620 PyObject* dc = wxPyMake_wxObject(&b,false); \
1621 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc));\
1622 Py_DECREF(win); \
1623 Py_DECREF(dc); \
1624 } \
1625 wxPyEndBlockThreads(blocked); \
1626 if (! found) \
1627 rval = PCLASS::CBNAME(a, b); \
1628 return rval; \
1629 }
1630
1631 //---------------------------------------------------------------------------
1632
1633 #define DEC_PYCALLBACK_VOID_WXWINBASE(CBNAME) \
1634 void CBNAME(wxWindowBase* a)
1635
1636
1637 #define IMP_PYCALLBACK_VOID_WXWINBASE(CLASS, PCLASS, CBNAME) \
1638 void CLASS::CBNAME(wxWindowBase* a) { \
1639 bool found; \
1640 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1641 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1642 PyObject* obj = wxPyMake_wxObject(a,false); \
1643 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1644 Py_DECREF(obj); \
1645 } \
1646 wxPyEndBlockThreads(blocked); \
1647 if (! found) \
1648 PCLASS::CBNAME(a); \
1649 }
1650
1651 //---------------------------------------------------------------------------
1652
1653 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1654 bool CBNAME()
1655
1656
1657 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1658 bool CLASS::CBNAME() { \
1659 bool rval=false; \
1660 bool found; \
1661 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1662 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1663 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1664 wxPyEndBlockThreads(blocked); \
1665 if (! found) \
1666 rval = PCLASS::CBNAME(); \
1667 return rval; \
1668 }
1669
1670 //---------------------------------------------------------------------------
1671
1672 #define DEC_PYCALLBACK_BOOL_const(CBNAME) \
1673 bool CBNAME() const
1674
1675
1676 #define IMP_PYCALLBACK_BOOL_const(CLASS, PCLASS, CBNAME) \
1677 bool CLASS::CBNAME() const { \
1678 bool rval=false; \
1679 bool found; \
1680 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1681 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1682 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1683 wxPyEndBlockThreads(blocked); \
1684 if (! found) \
1685 rval = PCLASS::CBNAME(); \
1686 return rval; \
1687 }
1688
1689 //---------------------------------------------------------------------------
1690
1691 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1692 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1693
1694
1695 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1696 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1697 int rval=0; \
1698 bool found; \
1699 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1700 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1701 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1702 wxPyEndBlockThreads(blocked); \
1703 if (! found) \
1704 rval = PCLASS::CBNAME(a, b, c); \
1705 return (wxDragResult)rval; \
1706 }
1707
1708 //---------------------------------------------------------------------------
1709
1710 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1711 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location)
1712
1713 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1714 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1715 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1716 wxFSFile* rval=0; \
1717 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1718 PyObject* ro; \
1719 PyObject* obj = wxPyMake_wxObject(&a,false); \
1720 PyObject* s = wx2PyString(b); \
1721 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)", \
1722 obj, s)); \
1723 if (ro) { \
1724 wxPyConvertSwigPtr(ro, (void **)&rval, wxT("wxFSFile")); \
1725 /* release ownership of the C++ wx.FSFile object. */ \
1726 PyObject_SetAttrString(ro, "thisown", Py_False); \
1727 Py_DECREF(ro); \
1728 } \
1729 Py_DECREF(obj); \
1730 Py_DECREF(s); \
1731 } \
1732 wxPyEndBlockThreads(blocked); \
1733 return rval; \
1734 };
1735
1736 //---------------------------------------------------------------------------
1737
1738 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1739 bool CBNAME(wxDragResult a)
1740
1741
1742 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1743 bool CLASS::CBNAME(wxDragResult a) { \
1744 bool rval=false; \
1745 bool found; \
1746 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1747 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1748 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
1749 wxPyEndBlockThreads(blocked); \
1750 if (! found) \
1751 rval = PCLASS::CBNAME(a); \
1752 return rval; \
1753 }
1754
1755 //---------------------------------------------------------------------------
1756
1757 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1758 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1759
1760
1761 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1762 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1763 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1764 int rval=0; \
1765 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1766 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1767 wxPyEndBlockThreads(blocked); \
1768 return (wxDragResult)rval; \
1769 } \
1770
1771 //---------------------------------------------------------------------------
1772
1773 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1774 bool CBNAME(int a, int b, const wxString& c)
1775
1776 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1777 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1778 bool rval=false; \
1779 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1780 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1781 PyObject* s = wx2PyString(c); \
1782 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
1783 Py_DECREF(s); \
1784 } \
1785 wxPyEndBlockThreads(blocked); \
1786 return rval; \
1787 } \
1788
1789 //---------------------------------------------------------------------------
1790
1791 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1792 size_t CBNAME()
1793
1794
1795 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1796 size_t CLASS::CBNAME() { \
1797 size_t rval=0; \
1798 bool found; \
1799 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1800 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1801 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1802 wxPyEndBlockThreads(blocked); \
1803 if (! found) \
1804 rval = PCLASS::CBNAME(); \
1805 return rval; \
1806 }
1807
1808 //---------------------------------------------------------------------------
1809
1810 #define DEC_PYCALLBACK_SIZET__const(CBNAME) \
1811 size_t CBNAME() const
1812
1813
1814 #define IMP_PYCALLBACK_SIZET__const(CLASS, PCLASS, CBNAME) \
1815 size_t CLASS::CBNAME() const { \
1816 size_t rval=0; \
1817 bool found; \
1818 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1819 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1820 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1821 wxPyEndBlockThreads(blocked); \
1822 if (! found) \
1823 rval = PCLASS::CBNAME(); \
1824 return rval; \
1825 }
1826
1827 //---------------------------------------------------------------------------
1828
1829 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1830 wxDataFormat CBNAME(size_t a)
1831
1832
1833 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1834 wxDataFormat CLASS::CBNAME(size_t a) { \
1835 wxDataFormat rval=0; \
1836 bool found; \
1837 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1838 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1839 PyObject* ro; \
1840 wxDataFormat* ptr; \
1841 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1842 if (ro) { \
1843 if (wxPyCOnvertSwigPtr(ro, (void **)&ptr, wxT("wxDataFormat"))) \
1844 rval = *ptr; \
1845 Py_DECREF(ro); \
1846 } \
1847 } \
1848 wxPyEndBlockThreads(blocked); \
1849 if (! found) \
1850 rval = PCLASS::CBNAME(a); \
1851 return rval; \
1852 }
1853
1854 //---------------------------------------------------------------------------
1855
1856 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1857 void CBNAME(const Type& a)
1858
1859
1860 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1861 void CLASS::CBNAME(const Type& a) { \
1862 bool found; \
1863 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1864 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1865 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1866 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1867 Py_DECREF(obj); \
1868 } \
1869 wxPyEndBlockThreads(blocked); \
1870 if (! found) \
1871 PCLASS::CBNAME(a); \
1872 }
1873
1874
1875 //---------------------------------------------------------------------------
1876
1877 #define DEC_PYCALLBACK__any(CBNAME, Type) \
1878 void CBNAME(Type& a)
1879
1880
1881 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1882 void CLASS::CBNAME(Type& a) { \
1883 bool found; \
1884 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1885 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1886 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1887 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1888 Py_DECREF(obj); \
1889 } \
1890 wxPyEndBlockThreads(blocked); \
1891 if (! found) \
1892 PCLASS::CBNAME(a); \
1893 }
1894
1895 //---------------------------------------------------------------------------
1896
1897 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1898 bool CBNAME(Type& a)
1899
1900
1901 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
1902 bool CLASS::CBNAME(Type& a) { \
1903 bool rv=false; \
1904 bool found; \
1905 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1906 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1907 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1908 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1909 Py_DECREF(obj); \
1910 } \
1911 wxPyEndBlockThreads(blocked); \
1912 if (! found) \
1913 rv = PCLASS::CBNAME(a); \
1914 return rv; \
1915 }
1916
1917 //---------------------------------------------------------------------------
1918
1919 #define DEC_PYCALLBACK_bool_anypure(CBNAME, Type) \
1920 bool CBNAME(Type& a)
1921
1922
1923 #define IMP_PYCALLBACK_bool_anypure(CLASS, PCLASS, CBNAME, Type) \
1924 bool CLASS::CBNAME(Type& a) { \
1925 bool rv=false; \
1926 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1927 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1928 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1929 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1930 Py_DECREF(obj); \
1931 } \
1932 wxPyEndBlockThreads(blocked); \
1933 return rv; \
1934 } \
1935
1936 //---------------------------------------------------------------------------
1937
1938 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
1939 wxString CBNAME(long a, long b) const
1940
1941 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
1942 wxString CLASS::CBNAME(long a, long b) const { \
1943 wxString rval; \
1944 bool found; \
1945 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1946 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1947 PyObject* ro; \
1948 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1949 if (ro) { \
1950 rval = Py2wxString(ro); \
1951 Py_DECREF(ro); \
1952 } \
1953 } \
1954 wxPyEndBlockThreads(blocked); \
1955 if (! found) \
1956 rval = PCLASS::CBNAME(a,b); \
1957 return rval; \
1958 }
1959
1960 //---------------------------------------------------------------------------
1961
1962 #define DEC_PYCALLBACK_INT_LONG(CBNAME) \
1963 int CBNAME(long a) const
1964
1965
1966 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
1967 int CLASS::CBNAME(long a) const { \
1968 int rval=-1; \
1969 bool found; \
1970 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1971 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1972 PyObject* ro; \
1973 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1974 if (ro) { \
1975 rval = PyInt_AsLong(ro); \
1976 Py_DECREF(ro); \
1977 } \
1978 } \
1979 wxPyEndBlockThreads(blocked); \
1980 if (! found) \
1981 rval = PCLASS::CBNAME(a); \
1982 return rval; \
1983 }
1984
1985
1986 #define DEC_PYCALLBACK_INT_LONG_virtual(CBNAME) \
1987 int CBNAME(long a) const;
1988
1989
1990 #define IMP_PYCALLBACK_INT_LONG_virtual(CLASS, PCLASS, CBNAME) \
1991 int CLASS::CBNAME(long a) const { \
1992 int rval=-1; /* this rval is important for OnGetItemImage */ \
1993 bool found; \
1994 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1995 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1996 PyObject* ro; \
1997 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1998 if (ro) { \
1999 rval = PyInt_AsLong(ro); \
2000 Py_DECREF(ro); \
2001 } \
2002 } \
2003 wxPyEndBlockThreads(blocked); \
2004 return rval; \
2005 }
2006
2007
2008 //---------------------------------------------------------------------------
2009
2010 #define DEC_PYCALLBACK_INT_INT(CBNAME) \
2011 int CBNAME(int a)
2012
2013
2014 #define IMP_PYCALLBACK_INT_INT(CLASS, PCLASS, CBNAME) \
2015 int CLASS::CBNAME(int a) { \
2016 int rval=-1; \
2017 bool found; \
2018 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2019 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2020 PyObject* ro; \
2021 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)",a)); \
2022 if (ro) { \
2023 rval = PyInt_AsLong(ro); \
2024 Py_DECREF(ro); \
2025 } \
2026 } \
2027 wxPyEndBlockThreads(blocked); \
2028 if (! found) \
2029 rval = PCLASS::CBNAME(a); \
2030 return rval; \
2031 }
2032
2033 //---------------------------------------------------------------------------
2034
2035 #define DEC_PYCALLBACK_INT_LONGLONG(CBNAME) \
2036 int CBNAME(long a, long b) const
2037
2038
2039 #define IMP_PYCALLBACK_INT_LONGLONG(CLASS, PCLASS, CBNAME) \
2040 int CLASS::CBNAME(long a, long b) const { \
2041 int rval=-1; \
2042 bool found; \
2043 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2044 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2045 PyObject* ro; \
2046 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
2047 if (ro) { \
2048 rval = PyInt_AsLong(ro); \
2049 Py_DECREF(ro); \
2050 } \
2051 } \
2052 wxPyEndBlockThreads(blocked); \
2053 if (! found) \
2054 rval = PCLASS::CBNAME(a, b); \
2055 return rval; \
2056 }
2057
2058
2059 #define DEC_PYCALLBACK_INT_LONGLONG_virtual(CBNAME) \
2060 int CBNAME(long a, long b) const;
2061
2062
2063 #define IMP_PYCALLBACK_INT_LONGLONG_virtual(CLASS, PCLASS, CBNAME) \
2064 int CLASS::CBNAME(long a, long b) const { \
2065 int rval=-1; /* this rval is important for OnGetItemImage */ \
2066 bool found; \
2067 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2068 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2069 PyObject* ro; \
2070 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
2071 if (ro) { \
2072 rval = PyInt_AsLong(ro); \
2073 Py_DECREF(ro); \
2074 } \
2075 } \
2076 wxPyEndBlockThreads(blocked); \
2077 return rval; \
2078 }
2079
2080
2081 //---------------------------------------------------------------------------
2082
2083 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
2084 wxListItemAttr* CBNAME(long a) const
2085
2086
2087 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
2088 wxListItemAttr *CLASS::CBNAME(long a) const { \
2089 wxListItemAttr *rval = NULL; \
2090 bool found; \
2091 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2092 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2093 PyObject* ro; \
2094 wxListItemAttr* ptr; \
2095 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2096 if (ro) { \
2097 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxListItemAttr")))\
2098 rval = ptr; \
2099 Py_DECREF(ro); \
2100 } \
2101 } \
2102 wxPyEndBlockThreads(blocked); \
2103 if (! found) \
2104 rval = PCLASS::CBNAME(a); \
2105 return rval; \
2106 }
2107
2108 //---------------------------------------------------------------------------
2109
2110 #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
2111 bool CBNAME(wxMouseEvent& e)
2112
2113 #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
2114 bool CLASS::CBNAME(wxMouseEvent& e) { \
2115 bool rval=false; \
2116 bool found; \
2117 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2118 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2119 PyObject* ro; \
2120 PyObject* obj = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
2121 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
2122 if (ro) { \
2123 rval = PyInt_AsLong(ro); \
2124 Py_DECREF(ro); \
2125 } \
2126 Py_DECREF(obj); \
2127 } \
2128 wxPyEndBlockThreads(blocked); \
2129 if (! found) \
2130 return PCLASS::CBNAME(e); \
2131 return rval; \
2132 }
2133
2134 //---------------------------------------------------------------------------
2135
2136 #define DEC_PYCALLBACK_WIZPG__pure(CBNAME) \
2137 wxWizardPage* CBNAME() const
2138
2139 #define IMP_PYCALLBACK_WIZPG__pure(CLASS, PCLASS, CBNAME) \
2140 wxWizardPage* CLASS::CBNAME() const { \
2141 wxWizardPage* rv = NULL; \
2142 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2143 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2144 PyObject* ro; \
2145 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2146 if (ro) { \
2147 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxWizardPage")); \
2148 Py_DECREF(ro); \
2149 } \
2150 } \
2151 wxPyEndBlockThreads(blocked); \
2152 return rv; \
2153 }
2154
2155 //---------------------------------------------------------------------------
2156
2157 #define DEC_PYCALLBACK_BITMAP__pure(CBNAME) \
2158 wxBitmap CBNAME() const
2159
2160 #define IMP_PYCALLBACK_BITMAP__pure(CLASS, PCLASS, CBNAME) \
2161 wxBitmap CLASS::CBNAME() const { \
2162 wxBitmap rv; \
2163 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2164 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2165 PyObject* ro; \
2166 wxBitmap* ptr; \
2167 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2168 if (ro) { \
2169 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxBitmap"))) \
2170 rv = *ptr; \
2171 Py_DECREF(ro); \
2172 } \
2173 } \
2174 wxPyEndBlockThreads(blocked); \
2175 return rv; \
2176 }
2177
2178 //---------------------------------------------------------------------------
2179
2180 #define DEC_PYCALLBACK_OBJECT__pure(CBNAME) \
2181 wxObject* CBNAME()
2182
2183 #define IMP_PYCALLBACK_OBJECT__pure(CLASS, PCLASS, CBNAME) \
2184 wxObject* CLASS::CBNAME() { \
2185 wxObject* rv = NULL; \
2186 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2187 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2188 PyObject* ro; \
2189 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2190 if (ro) { \
2191 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2192 Py_DECREF(ro); \
2193 } \
2194 } \
2195 wxPyEndBlockThreads(blocked); \
2196 return rv; \
2197 }
2198
2199 //---------------------------------------------------------------------------
2200
2201 #define DEC_PYCALLBACK_OBJECT_STRING_pure(CBNAME) \
2202 wxObject* CBNAME(const wxString& a)
2203
2204 #define IMP_PYCALLBACK_OBJECT_STRING_pure(CLASS, PCLASS, CBNAME) \
2205 wxObject* CLASS::CBNAME(const wxString& a) { \
2206 wxObject* rv = NULL; \
2207 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2208 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2209 PyObject* so = wx2PyString(a); \
2210 PyObject* ro; \
2211 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", so)); \
2212 if (ro) { \
2213 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2214 Py_DECREF(ro); \
2215 } \
2216 Py_DECREF(so); \
2217 } \
2218 wxPyEndBlockThreads(blocked); \
2219 return rv; \
2220 }
2221
2222 //---------------------------------------------------------------------------
2223
2224 #define DEC_PYCALLBACK_BOOL_NODE_pure(CBNAME) \
2225 bool CBNAME(wxXmlNode* a)
2226
2227
2228 #define IMP_PYCALLBACK_BOOL_NODE_pure(CLASS, PCLASS, CBNAME) \
2229 bool CLASS::CBNAME(wxXmlNode* a) { \
2230 bool rv=false; \
2231 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2232 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2233 PyObject* obj = wxPyConstructObject((void*)a, wxT("wxXmlNode"), 0); \
2234 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2235 Py_DECREF(obj); \
2236 } \
2237 wxPyEndBlockThreads(blocked); \
2238 return rv; \
2239 } \
2240
2241 //---------------------------------------------------------------------------
2242
2243 #define DEC_PYCALLBACK_COORD_SIZET_constpure(CBNAME) \
2244 wxCoord CBNAME(size_t a) const
2245
2246
2247 #define IMP_PYCALLBACK_COORD_SIZET_constpure(CLASS, PCLASS, CBNAME) \
2248 wxCoord CLASS::CBNAME(size_t a) const { \
2249 wxCoord rval=0; \
2250 bool found; \
2251 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2252 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2253 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
2254 } \
2255 wxPyEndBlockThreads(blocked); \
2256 return rval; \
2257 } \
2258
2259 //---------------------------------------------------------------------------
2260
2261 #define DEC_PYCALLBACK_VOID_SIZETSIZET_const(CBNAME) \
2262 void CBNAME(size_t a, size_t b) const
2263
2264
2265 #define IMP_PYCALLBACK_VOID_SIZETSIZET_const(CLASS, PCLASS, CBNAME) \
2266 void CLASS::CBNAME(size_t a, size_t b) const { \
2267 bool found; \
2268 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2269 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2270 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
2271 wxPyEndBlockThreads(blocked); \
2272 if (! found) \
2273 PCLASS::CBNAME(a,b); \
2274 }
2275 //---------------------------------------------------------------------------
2276
2277 #define DEC_PYCALLBACK_COORD_const(CBNAME) \
2278 wxCoord CBNAME() const
2279
2280
2281 #define IMP_PYCALLBACK_COORD_const(CLASS, PCLASS, CBNAME) \
2282 wxCoord CLASS::CBNAME() const { \
2283 wxCoord rval=0; \
2284 bool found; \
2285 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2286 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2287 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
2288 wxPyEndBlockThreads(blocked); \
2289 if (! found) \
2290 rval = PCLASS::CBNAME(); \
2291 return rval; \
2292 }
2293
2294 //---------------------------------------------------------------------------
2295
2296 #define DEC_PYCALLBACK__DCRECTSIZET_constpure(CBNAME) \
2297 void CBNAME(wxDC& a, const wxRect& b, size_t c) const;
2298
2299 #define IMP_PYCALLBACK__DCRECTSIZET_constpure(CLASS, PCLASS, CBNAME) \
2300 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2301 bool found; \
2302 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2303 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2304 PyObject* obj = wxPyMake_wxObject(&a,false); \
2305 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2306 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2307 Py_DECREF(obj); Py_DECREF(ro); \
2308 } \
2309 wxPyEndBlockThreads(blocked); \
2310 } \
2311
2312
2313
2314 #define DEC_PYCALLBACK__DCRECTSIZET_const(CBNAME) \
2315 void CBNAME(wxDC& a, const wxRect& b, size_t c) const
2316
2317 #define IMP_PYCALLBACK__DCRECTSIZET_const(CLASS, PCLASS, CBNAME) \
2318 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2319 bool found; \
2320 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2321 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2322 PyObject* obj = wxPyMake_wxObject(&a,false); \
2323 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2324 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2325 Py_DECREF(obj); Py_DECREF(ro); \
2326 } \
2327 wxPyEndBlockThreads(blocked); \
2328 if (! found) \
2329 PCLASS::CBNAME(a,b,c); \
2330 }
2331
2332
2333 //---------------------------------------------------------------------------
2334 // Same as the above set, but the wxRect is not const
2335
2336 #define DEC_PYCALLBACK__DCRECTSIZET2_constpure(CBNAME) \
2337 void CBNAME(wxDC& a, wxRect& b, size_t c) const;
2338
2339 #define IMP_PYCALLBACK__DCRECTSIZET2_constpure(CLASS, PCLASS, CBNAME) \
2340 void CLASS::CBNAME(wxDC& a, wxRect& b, size_t c) const { \
2341 bool found; \
2342 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2343 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2344 PyObject* obj = wxPyMake_wxObject(&a,false); \
2345 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2346 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2347 Py_DECREF(obj); Py_DECREF(ro); \
2348 } \
2349 wxPyEndBlockThreads(blocked); \
2350 } \
2351
2352
2353
2354 #define DEC_PYCALLBACK__DCRECTSIZET2_const(CBNAME) \
2355 void CBNAME(wxDC& a, wxRect& b, size_t c) const
2356
2357 #define IMP_PYCALLBACK__DCRECTSIZET2_const(CLASS, PCLASS, CBNAME) \
2358 void CLASS::CBNAME(wxDC& a, wxRect& b, size_t c) const { \
2359 bool found; \
2360 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2361 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2362 PyObject* obj = wxPyMake_wxObject(&a,false); \
2363 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2364 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2365 Py_DECREF(obj); Py_DECREF(ro); \
2366 } \
2367 wxPyEndBlockThreads(blocked); \
2368 if (! found) \
2369 PCLASS::CBNAME(a,b,c); \
2370 }
2371
2372 //---------------------------------------------------------------------------
2373
2374 #define DEC_PYCALLBACK_STRING_SIZET(CBNAME) \
2375 wxString CBNAME(size_t a) const
2376
2377 #define IMP_PYCALLBACK_STRING_SIZET(CLASS, PCLASS, CBNAME) \
2378 wxString CLASS::CBNAME(size_t a) const { \
2379 wxString rval; \
2380 bool found; \
2381 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2382 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2383 PyObject* ro; \
2384 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2385 if (ro) { \
2386 rval = Py2wxString(ro); \
2387 Py_DECREF(ro); \
2388 } \
2389 } \
2390 wxPyEndBlockThreads(blocked); \
2391 if (! found) \
2392 rval = PCLASS::CBNAME(a); \
2393 return rval; \
2394 }
2395
2396 //---------------------------------------------------------------------------
2397
2398 #define DEC_PYCALLBACK_STRING_SIZET_pure(CBNAME) \
2399 wxString CBNAME(size_t a) const
2400
2401 #define IMP_PYCALLBACK_STRING_SIZET_pure(CLASS, PCLASS, CBNAME) \
2402 wxString CLASS::CBNAME(size_t a) const { \
2403 wxString rval; \
2404 bool found; \
2405 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2406 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2407 PyObject* ro; \
2408 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2409 if (ro) { \
2410 rval = Py2wxString(ro); \
2411 Py_DECREF(ro); \
2412 } \
2413 } \
2414 wxPyEndBlockThreads(blocked); \
2415 return rval; \
2416 } \
2417
2418 //---------------------------------------------------------------------------
2419
2420 #define DEC_PYCALLBACK_VIZATTR_(CBNAME) \
2421 wxVisualAttributes CBNAME() const
2422
2423
2424 #define IMP_PYCALLBACK_VIZATTR_(CLASS, PCLASS, CBNAME) \
2425 wxVisualAttributes CLASS::CBNAME() const { \
2426 wxVisualAttributes rval; \
2427 bool found; \
2428 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2429 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2430 PyObject* ro; \
2431 wxVisualAttributes* ptr; \
2432 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2433 if (ro) { \
2434 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxVisualAttributes"))) \
2435 rval = *ptr; \
2436 Py_DECREF(ro); \
2437 } \
2438 } \
2439 wxPyEndBlockThreads(blocked); \
2440 if (! found) \
2441 rval = PCLASS::CBNAME(); \
2442 return rval; \
2443 }
2444
2445 //---------------------------------------------------------------------------
2446
2447 #define DEC_PYCALLBACK_FONT_INT(CBNAME) \
2448 wxFont CBNAME(int a)
2449
2450 #define IMP_PYCALLBACK_FONT_INT(CLASS, PCLASS, CBNAME) \
2451 wxFont CLASS::CBNAME(int a) { \
2452 wxFont rv; \
2453 bool found; \
2454 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2455 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2456 PyObject* ro; \
2457 wxFont* ptr; \
2458 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2459 if (ro) { \
2460 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxFont"))) \
2461 rv = *ptr; \
2462 Py_DECREF(ro); \
2463 } \
2464 } \
2465 wxPyEndBlockThreads(blocked); \
2466 if (! found) \
2467 rv = PCLASS::CBNAME(a); \
2468 return rv; \
2469 }
2470
2471 //---------------------------------------------------------------------------
2472
2473 #define DEC_PYCALLBACK_COLOUR_INT(CBNAME) \
2474 wxColour CBNAME(int a)
2475
2476 #define IMP_PYCALLBACK_COLOUR_INT(CLASS, PCLASS, CBNAME) \
2477 wxColour CLASS::CBNAME(int a) { \
2478 wxColour rv; \
2479 bool found; \
2480 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2481 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2482 PyObject* ro; \
2483 wxColour* ptr; \
2484 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2485 if (ro) { \
2486 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxColour"))) \
2487 rv = *ptr; \
2488 Py_DECREF(ro); \
2489 } \
2490 } \
2491 wxPyEndBlockThreads(blocked); \
2492 if (! found) \
2493 rv = PCLASS::CBNAME(a); \
2494 return rv; \
2495 }
2496
2497 //---------------------------------------------------------------------------
2498
2499 #endif