X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3ca6a5f04692678cd2d9f3ea0843fc3f5a0b254f..8ac67aa10207821a237a18da17f5d25f57f1e9ff:/wxPython/src/printfw.i?ds=sidebyside diff --git a/wxPython/src/printfw.i b/wxPython/src/printfw.i index d849726c21..399b28e0d5 100644 --- a/wxPython/src/printfw.i +++ b/wxPython/src/printfw.i @@ -16,12 +16,23 @@ #include "helpers.h" #include #include +#include #include "printfw.h" %} //---------------------------------------------------------------------- +%{ + // Put some wx default wxChar* values into wxStrings. + static const wxChar* wxPrintoutTitleStr = wxT("Printout"); + DECLARE_DEF_STRING(PrintoutTitleStr); + + DECLARE_DEF_STRING(FrameNameStr); +%} + +//---------------------------------------------------------------------- + %include typemaps.i %include my_typemaps.i @@ -41,7 +52,7 @@ -class wxPrintData { +class wxPrintData : public wxObject { public: wxPrintData(); ~wxPrintData(); @@ -50,6 +61,8 @@ public: bool GetCollate(); int GetOrientation(); + bool Ok(); + const wxString& GetPrinterName(); bool GetColour(); wxDuplexMode GetDuplex(); @@ -69,36 +82,66 @@ public: void SetPaperSize(const wxSize& sz); void SetQuality(wxPrintQuality quality); -// // PostScript-specific data -// const wxString& GetPrinterCommand(); -// const wxString& GetPrinterOptions(); -// const wxString& GetPreviewCommand(); -// const wxString& GetFilename(); -// const wxString& GetFontMetricPath(); -// double GetPrinterScaleX(); -// double GetPrinterScaleY(); -// long GetPrinterTranslateX(); -// long GetPrinterTranslateY(); -// wxPrintMode GetPrintMode(); - -// void SetPrinterCommand(const wxString& command); -// void SetPrinterOptions(const wxString& options); -// void SetPreviewCommand(const wxString& command); -// void SetFilename(const wxString& filename); -// void SetFontMetricPath(const wxString& path); -// void SetPrinterScaleX(double x); -// void SetPrinterScaleY(double y); -// void SetPrinterScaling(double x, double y); -// void SetPrinterTranslateX(long x); -// void SetPrinterTranslateY(long y); -// void SetPrinterTranslation(long x, long y); -// void SetPrintMode(wxPrintMode printMode); + // PostScript-specific data + const wxString& GetPrinterCommand(); + const wxString& GetPrinterOptions(); + const wxString& GetPreviewCommand(); + const wxString& GetFilename(); + const wxString& GetFontMetricPath(); + double GetPrinterScaleX(); + double GetPrinterScaleY(); + long GetPrinterTranslateX(); + long GetPrinterTranslateY(); + wxPrintMode GetPrintMode(); + + void SetPrinterCommand(const wxString& command); + void SetPrinterOptions(const wxString& options); + void SetPreviewCommand(const wxString& command); + void SetFilename(const wxString& filename); + void SetFontMetricPath(const wxString& path); + void SetPrinterScaleX(double x); + void SetPrinterScaleY(double y); + void SetPrinterScaling(double x, double y); + void SetPrinterTranslateX(long x); + void SetPrinterTranslateY(long y); + void SetPrinterTranslation(long x, long y); + void SetPrintMode(wxPrintMode printMode); }; //---------------------------------------------------------------------- -class wxPageSetupDialogData { +#ifdef __WXMSW__ +class wxPrinterDC : public wxDC { +public: + wxPrinterDC(const wxPrintData& printData); + %name(wxPrinterDC2) wxPrinterDC(const wxString& driver, + const wxString& device, + const wxString& output, + bool interactive = TRUE, + int orientation = wxPORTRAIT); +}; +#endif + +//--------------------------------------------------------------------------- + +class wxPostScriptDC : public wxDC { +public: + wxPostScriptDC(const wxPrintData& printData); + %name(wxPostScriptDC2)wxPostScriptDC(const wxString& output, + bool interactive = TRUE, + wxWindow* parent = NULL); + + wxPrintData& GetPrintData(); + void SetPrintData(const wxPrintData& data); + + static void SetResolution(int ppi); + static int GetResolution(); +}; + +//--------------------------------------------------------------------------- + +class wxPageSetupDialogData : public wxObject { public: wxPageSetupDialogData(); ~wxPageSetupDialogData(); @@ -126,6 +169,9 @@ public: return new wxPrintData(self->GetPrintData()); // force a copy } } + + bool Ok(); + void SetDefaultInfo(bool flag); void SetDefaultMinMargins(bool flag); void SetMarginTopLeft(const wxPoint& pt); @@ -151,7 +197,7 @@ public: //---------------------------------------------------------------------- -class wxPrintDialogData { +class wxPrintDialogData : public wxObject { public: wxPrintDialogData(); ~wxPrintDialogData(); @@ -173,6 +219,9 @@ public: } bool GetPrintToFile(); int GetToPage(); + + bool Ok(); + void SetCollate(bool flag); void SetFromPage(int page); void SetMaxPage(int page); @@ -205,9 +254,10 @@ public: // 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 found; - bool doSave = wxPyRestoreThread(); - if (m_myInst.findCallback("GetPageInfo")) { + wxPyBeginBlockThreads(); + if ((found = m_myInst.findCallback("GetPageInfo"))) { PyObject* result = m_myInst.callCallbackObj(Py_BuildValue("()")); if (result && PyTuple_Check(result) && PyTuple_Size(result) == 4) { PyObject* val; @@ -237,10 +287,9 @@ void wxPyPrintout::GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *p } Py_DECREF(result); } - else + wxPyEndBlockThreads(); + if (! found) wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo); - - wxPySaveThread(doSave); } void wxPyPrintout::base_GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) { @@ -261,12 +310,12 @@ IMP_PYCALLBACK_BOOL_INT(wxPyPrintout, wxPrintout, HasPage); // Now define the custom class for SWIGging -%name(wxPrintout) class wxPyPrintout { +%name(wxPrintout) class wxPyPrintout : public wxObject { public: - wxPyPrintout(const char* title = "Printout"); + wxPyPrintout(const wxString& title = wxPyPrintoutTitleStr); - void _setSelf(PyObject* self, PyObject* _class); - %pragma(python) addtomethod = "__init__:self._setSelf(self, wxPrintout)" + void _setCallbackInfo(PyObject* self, PyObject* _class); + %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPrintout)" %addmethods { void Destroy() { delete self; } @@ -290,7 +339,7 @@ public: //---------------------------------------------------------------------- -class wxPrinter { +class wxPrinter : public wxObject { public: wxPrinter(wxPrintDialogData* data = NULL); ~wxPrinter(); @@ -300,13 +349,13 @@ public: wxPrintDialogData& GetPrintDialogData(); bool Print(wxWindow *parent, wxPyPrintout *printout, int prompt=TRUE); wxDC* PrintDialog(wxWindow *parent); - void ReportError(wxWindow *parent, wxPyPrintout *printout, char* message); + void ReportError(wxWindow *parent, wxPyPrintout *printout, const wxString& message); bool Setup(wxWindow *parent); }; //---------------------------------------------------------------------- -class wxPrintPreview { +class wxPrintPreview : public wxObject { public: wxPrintPreview(wxPyPrintout* printout, wxPyPrintout* printoutForPrinting, wxPrintData* data=NULL); // ~wxPrintPreview(); **** ???? @@ -334,12 +383,12 @@ public: class wxPreviewFrame : public wxFrame { public: wxPreviewFrame(wxPrintPreview* preview, wxFrame* parent, const wxString& title, - const wxPoint& pos = wxPyDefaultPosition, - const wxSize& size = wxPyDefaultSize, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE, - char* name = "frame"); + const wxString& name = wxPyFrameNameStr); - %pragma(python) addtomethod = "__init__:#wx._StdFrameCallbacks(self)" + %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" void Initialize(); @@ -350,6 +399,11 @@ public: }; //---------------------------------------------------------------------- + +%init %{ + wxPyPtrTypeMap_Add("wxPrintout", "wxPyPrintout"); +%} + //---------------------------------------------------------------------- //----------------------------------------------------------------------