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