1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Printing Framework classes
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
18 #include <wx/printdlg.h>
21 //----------------------------------------------------------------------
24 %include my_typemaps.i
26 // Import some definitions of other classes, etc.
35 %pragma(python) code = "import wx"
38 //----------------------------------------------------------------------
51 const wxString& GetPrinterName();
53 wxDuplexMode GetDuplex();
54 wxPaperSize GetPaperId();
55 const wxSize& GetPaperSize();
57 wxPrintQuality GetQuality();
59 void SetNoCopies(int v);
60 void SetCollate(bool flag);
61 void SetOrientation(int orient);
63 void SetPrinterName(const wxString& name);
64 void SetColour(bool colour);
65 void SetDuplex(wxDuplexMode duplex);
66 void SetPaperId(wxPaperSize sizeId);
67 void SetPaperSize(const wxSize& sz);
68 void SetQuality(wxPrintQuality quality);
70 // // PostScript-specific data
71 // const wxString& GetPrinterCommand();
72 // const wxString& GetPrinterOptions();
73 // const wxString& GetPreviewCommand();
74 // const wxString& GetFilename();
75 // const wxString& GetFontMetricPath();
76 // double GetPrinterScaleX();
77 // double GetPrinterScaleY();
78 // long GetPrinterTranslateX();
79 // long GetPrinterTranslateY();
80 // wxPrintMode GetPrintMode();
82 // void SetPrinterCommand(const wxString& command);
83 // void SetPrinterOptions(const wxString& options);
84 // void SetPreviewCommand(const wxString& command);
85 // void SetFilename(const wxString& filename);
86 // void SetFontMetricPath(const wxString& path);
87 // void SetPrinterScaleX(double x);
88 // void SetPrinterScaleY(double y);
89 // void SetPrinterScaling(double x, double y);
90 // void SetPrinterTranslateX(long x);
91 // void SetPrinterTranslateY(long y);
92 // void SetPrinterTranslation(long x, long y);
93 // void SetPrintMode(wxPrintMode printMode);
97 //----------------------------------------------------------------------
99 class wxPageSetupDialogData {
101 wxPageSetupDialogData();
102 ~wxPageSetupDialogData();
104 void EnableHelp(bool flag);
105 void EnableMargins(bool flag);
106 void EnableOrientation(bool flag);
107 void EnablePaper(bool flag);
108 void EnablePrinter(bool flag);
109 bool GetDefaultMinMargins();
110 bool GetEnableMargins();
111 bool GetEnableOrientation();
112 bool GetEnablePaper();
113 bool GetEnablePrinter();
114 bool GetEnableHelp();
115 bool GetDefaultInfo();
116 wxPoint GetMarginTopLeft();
117 wxPoint GetMarginBottomRight();
118 wxPoint GetMinMarginTopLeft();
119 wxPoint GetMinMarginBottomRight();
120 wxPaperSize GetPaperId();
121 wxSize GetPaperSize();
123 %new wxPrintData* GetPrintData() {
124 return new wxPrintData(self->GetPrintData()); // force a copy
127 void SetDefaultInfo(bool flag);
128 void SetDefaultMinMargins(bool flag);
129 void SetMarginTopLeft(const wxPoint& pt);
130 void SetMarginBottomRight(const wxPoint& pt);
131 void SetMinMarginTopLeft(const wxPoint& pt);
132 void SetMinMarginBottomRight(const wxPoint& pt);
133 void SetPaperId(wxPaperSize& id);
134 void SetPaperSize(const wxSize& size);
135 void SetPrintData(const wxPrintData& printData);
139 class wxPageSetupDialog : public wxDialog {
141 wxPageSetupDialog(wxWindow* parent, wxPageSetupDialogData* data = NULL);
143 %pragma(python) addtomethod = "__init__:wx._StdDialogCallbacks(self)"
145 wxPageSetupDialogData& GetPageSetupData();
149 //----------------------------------------------------------------------
152 class wxPrintDialogData {
155 ~wxPrintDialogData();
157 void EnableHelp(bool flag);
158 void EnablePageNumbers(bool flag);
159 void EnablePrintToFile(bool flag);
160 void EnableSelection(bool flag);
168 %new wxPrintData* GetPrintData() {
169 return new wxPrintData(self->GetPrintData()); // force a copy
172 bool GetPrintToFile();
174 void SetCollate(bool flag);
175 void SetFromPage(int page);
176 void SetMaxPage(int page);
177 void SetMinPage(int page);
178 void SetNoCopies(int n);
179 void SetPrintData(const wxPrintData& printData);
180 void SetPrintToFile(bool flag);
181 void SetSetupDialog(bool flag);
182 void SetToPage(int page);
186 class wxPrintDialog : public wxDialog {
188 wxPrintDialog(wxWindow* parent, wxPrintDialogData* data = NULL);
190 %pragma(python) addtomethod = "__init__:wx._StdDialogCallbacks(self)"
192 wxPrintDialogData& GetPrintDialogData();
193 %new wxDC* GetPrintDC();
197 //----------------------------------------------------------------------
198 //----------------------------------------------------------------------
199 // Custom wxPrintout class that knows how to call python
201 class wxPyPrintout : public wxPrintout {
203 wxPyPrintout(const wxString& title) : wxPrintout(title) {}
205 PYCALLBACK_BOOL_INTINT(wxPrintout, OnBeginDocument);
206 PYCALLBACK__(wxPrintout, OnEndDocument);
207 PYCALLBACK__(wxPrintout, OnBeginPrinting);
208 PYCALLBACK__(wxPrintout, OnEndPrinting);
209 PYCALLBACK__(wxPrintout, OnPreparePrinting);
210 PYCALLBACK_BOOL_INT_pure(wxPrintout, OnPrintPage);
211 PYCALLBACK_BOOL_INT(wxPrintout, HasPage);
214 // Since this one would be tough and ugly to do with the Macros...
215 void GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) {
218 if (m_myInst.findCallback("GetPageInfo")) {
219 PyObject* result = m_myInst.callCallbackObj(Py_BuildValue("()"));
220 if (result && PyTuple_Check(result) && PyTuple_Size(result) == 4) {
223 val = PyTuple_GetItem(result, 0);
224 if (PyInt_Check(val)) *minPage = PyInt_AsLong(val);
227 val = PyTuple_GetItem(result, 1);
228 if (PyInt_Check(val)) *maxPage = PyInt_AsLong(val);
231 val = PyTuple_GetItem(result, 2);
232 if (PyInt_Check(val)) *pageFrom = PyInt_AsLong(val);
235 val = PyTuple_GetItem(result, 3);
236 if (PyInt_Check(val)) *pageTo = PyInt_AsLong(val);
243 PyErr_SetString(PyExc_TypeError, "GetPageInfo should return a tuple of 4 integers.");
247 #ifdef WXP_WITH_THREAD
252 wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo);
254 void base_GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) {
255 wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo);
263 // Now define the custom class for SWIGging
264 %name(wxPrintout) class wxPyPrintout {
266 wxPyPrintout(const char* title = "Printout");
268 void _setSelf(PyObject* self);
269 %pragma(python) addtomethod = "__init__:self._setSelf(self)"
278 void GetPageSizeMM(int *OUTPUT, int *OUTPUT);
279 void GetPageSizePixels(int *OUTPUT, int *OUTPUT);
280 void GetPPIPrinter(int *OUTPUT, int *OUTPUT);
281 void GetPPIScreen(int *OUTPUT, int *OUTPUT);
284 bool base_OnBeginDocument(int startPage, int endPage);
285 void base_OnEndDocument();
286 void base_OnBeginPrinting();
287 void base_OnEndPrinting();
288 void base_OnPreparePrinting();
289 void base_GetPageInfo(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT);
290 bool base_HasPage(int page);
293 //----------------------------------------------------------------------
297 wxPrinter(wxPrintDialogData* data = NULL);
301 void CreateAbortWindow(wxWindow* parent, wxPyPrintout* printout);
302 wxPrintDialogData& GetPrintDialogData();
303 bool Print(wxWindow *parent, wxPyPrintout *printout, int prompt=TRUE);
304 wxDC* PrintDialog(wxWindow *parent);
305 void ReportError(wxWindow *parent, wxPyPrintout *printout, char* message);
306 bool Setup(wxWindow *parent);
309 //----------------------------------------------------------------------
311 class wxPrintPreview {
313 wxPrintPreview(wxPyPrintout* printout, wxPyPrintout* printoutForPrinting, wxPrintData* data=NULL);
314 // ~wxPrintPreview(); **** ????
316 wxWindow* GetCanvas();
317 int GetCurrentPage();
318 wxFrame * GetFrame();
321 wxPrintDialogData& GetPrintDialogData();
322 wxPyPrintout * GetPrintout();
323 wxPyPrintout * GetPrintoutForPrinting();
326 bool Print(bool prompt);
327 void SetCanvas(wxWindow* window);
328 void SetCurrentPage(int pageNum);
329 void SetFrame(wxFrame *frame);
330 void SetPrintout(wxPyPrintout *printout);
331 void SetZoom(int percent);
334 //----------------------------------------------------------------------
336 class wxPreviewFrame : public wxFrame {
338 wxPreviewFrame(wxPrintPreview* preview, wxFrame* parent, const wxString& title,
339 const wxPoint& pos = wxPyDefaultPosition,
340 const wxSize& size = wxPyDefaultSize,
341 long style = wxDEFAULT_FRAME_STYLE,
342 char* name = "frame");
344 %pragma(python) addtomethod = "__init__:wx._StdFrameCallbacks(self)"
348 // **** need to use derived class so these can be properly overridden:
349 //void CreateControlBar()
350 //void CreateCanvas()
354 //----------------------------------------------------------------------
355 //----------------------------------------------------------------------
356 //----------------------------------------------------------------------