X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1afc06c2d8c945535175bf32e427aac0bbb704de..077def0b2a371a7c6cd8a7c94ea85e403cc9b9b1:/utils/wxPython/src/printfw.i diff --git a/utils/wxPython/src/printfw.i b/utils/wxPython/src/printfw.i index 479f5a7989..b5b4c91e70 100644 --- a/utils/wxPython/src/printfw.i +++ b/utils/wxPython/src/printfw.i @@ -16,6 +16,8 @@ #include "helpers.h" #include #include + +#include "printfw.h" %} //---------------------------------------------------------------------- @@ -198,66 +200,53 @@ public: //---------------------------------------------------------------------- // Custom wxPrintout class that knows how to call python %{ -class wxPyPrintout : public wxPrintout { -public: - wxPyPrintout(const wxString& title) : wxPrintout(title) {} - - DEC_PYCALLBACK_BOOL_INTINT(OnBeginDocument); - DEC_PYCALLBACK__(OnEndDocument); - DEC_PYCALLBACK__(OnBeginPrinting); - DEC_PYCALLBACK__(OnEndPrinting); - DEC_PYCALLBACK__(OnPreparePrinting); - DEC_PYCALLBACK_BOOL_INT_pure(OnPrintPage); - DEC_PYCALLBACK_BOOL_INT(HasPage); - - - // Since this one would be tough and ugly to do with the Macros... - void GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) { - bool hadErr = false; - - bool doSave = wxPyRestoreThread(); - if (m_myInst.findCallback("GetPageInfo")) { - PyObject* result = m_myInst.callCallbackObj(Py_BuildValue("()")); - if (result && PyTuple_Check(result) && PyTuple_Size(result) == 4) { - PyObject* val; - - val = PyTuple_GetItem(result, 0); - if (PyInt_Check(val)) *minPage = PyInt_AsLong(val); - else hadErr = true; - - val = PyTuple_GetItem(result, 1); - if (PyInt_Check(val)) *maxPage = PyInt_AsLong(val); - else hadErr = true; - - val = PyTuple_GetItem(result, 2); - if (PyInt_Check(val)) *pageFrom = PyInt_AsLong(val); - else hadErr = true; - - val = PyTuple_GetItem(result, 3); - if (PyInt_Check(val)) *pageTo = PyInt_AsLong(val); - else hadErr = true; - } - else - hadErr = true; - - if (hadErr) { - PyErr_SetString(PyExc_TypeError, "GetPageInfo should return a tuple of 4 integers."); - PyErr_Print(); - } - Py_DECREF(result); + + +// Since this one would be tough and ugly to do with the Macros... +void wxPyPrintout::GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) { + bool hadErr = false; + + bool doSave = wxPyRestoreThread(); + if (m_myInst.findCallback("GetPageInfo")) { + PyObject* result = m_myInst.callCallbackObj(Py_BuildValue("()")); + if (result && PyTuple_Check(result) && PyTuple_Size(result) == 4) { + PyObject* val; + + val = PyTuple_GetItem(result, 0); + if (PyInt_Check(val)) *minPage = PyInt_AsLong(val); + else hadErr = true; + + val = PyTuple_GetItem(result, 1); + if (PyInt_Check(val)) *maxPage = PyInt_AsLong(val); + else hadErr = true; + + val = PyTuple_GetItem(result, 2); + if (PyInt_Check(val)) *pageFrom = PyInt_AsLong(val); + else hadErr = true; + + val = PyTuple_GetItem(result, 3); + if (PyInt_Check(val)) *pageTo = PyInt_AsLong(val); + else hadErr = true; } else - wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo); + hadErr = true; - wxPySaveThread(doSave); + if (hadErr) { + PyErr_SetString(PyExc_TypeError, "GetPageInfo should return a tuple of 4 integers."); + PyErr_Print(); + } + Py_DECREF(result); } - - void base_GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) { + else wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo); - } - PYPRIVATE; -}; + wxPySaveThread(doSave); +} + +void wxPyPrintout::base_GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) { + wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo); +} + IMP_PYCALLBACK_BOOL_INTINT(wxPyPrintout, wxPrintout, OnBeginDocument); IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnEndDocument);