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