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