]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/printfw.i
20148f2287c91695c4500335899e98e0b20bc8fb
[wxWidgets.git] / utils / wxPython / src / printfw.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: printfw.i
3 // Purpose: Printing Framework classes
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 7-May-1999
8 // RCS-ID: $Id$
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 %module printfw
14
15 %{
16 #include "helpers.h"
17 #include <wx/print.h>
18 #include <wx/printdlg.h>
19 %}
20
21 //----------------------------------------------------------------------
22
23 %include typemaps.i
24 %include my_typemaps.i
25
26 // Import some definitions of other classes, etc.
27 %import _defs.i
28 %import misc.i
29 %import windows.i
30 %import gdi.i
31 %import cmndlgs.i
32 %import frames.i
33
34
35 %pragma(python) code = "import wx"
36
37
38 //----------------------------------------------------------------------
39
40
41
42 class wxPrintData {
43 public:
44 wxPrintData();
45 ~wxPrintData();
46
47 int GetNoCopies();
48 bool GetCollate();
49 int GetOrientation();
50
51 const wxString& GetPrinterName();
52 bool GetColour();
53 wxDuplexMode GetDuplex();
54 wxPaperSize GetPaperId();
55 const wxSize& GetPaperSize();
56
57 wxPrintQuality GetQuality();
58
59 void SetNoCopies(int v);
60 void SetCollate(bool flag);
61 void SetOrientation(int orient);
62
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);
69
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();
81
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);
94
95 };
96
97 //----------------------------------------------------------------------
98
99 class wxPageSetupDialogData {
100 public:
101 wxPageSetupDialogData();
102 ~wxPageSetupDialogData();
103
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();
122 %addmethods {
123 %new wxPrintData* GetPrintData() {
124 return new wxPrintData(self->GetPrintData()); // force a copy
125 }
126 }
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);
136 };
137
138
139 class wxPageSetupDialog : public wxDialog {
140 public:
141 wxPageSetupDialog(wxWindow* parent, wxPageSetupDialogData* data = NULL);
142
143 %pragma(python) addtomethod = "__init__:wx._StdDialogCallbacks(self)"
144
145 wxPageSetupDialogData& GetPageSetupData();
146 int ShowModal();
147 };
148
149 //----------------------------------------------------------------------
150
151
152 class wxPrintDialogData {
153 public:
154 wxPrintDialogData();
155 ~wxPrintDialogData();
156
157 void EnableHelp(bool flag);
158 void EnablePageNumbers(bool flag);
159 void EnablePrintToFile(bool flag);
160 void EnableSelection(bool flag);
161 bool GetAllPages();
162 bool GetCollate();
163 int GetFromPage();
164 int GetMaxPage();
165 int GetMinPage();
166 int GetNoCopies();
167 %addmethods {
168 %new wxPrintData* GetPrintData() {
169 return new wxPrintData(self->GetPrintData()); // force a copy
170 }
171 }
172 bool GetPrintToFile();
173 int GetToPage();
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);
183 };
184
185
186 class wxPrintDialog : public wxDialog {
187 public:
188 wxPrintDialog(wxWindow* parent, wxPrintDialogData* data = NULL);
189
190 %pragma(python) addtomethod = "__init__:wx._StdDialogCallbacks(self)"
191
192 wxPrintDialogData& GetPrintDialogData();
193 %new wxDC* GetPrintDC();
194 int ShowModal();
195 };
196
197 //----------------------------------------------------------------------
198 //----------------------------------------------------------------------
199 // Custom wxPrintout class that knows how to call python
200 %{
201 class wxPyPrintout : public wxPrintout {
202 public:
203 wxPyPrintout(const wxString& title) : wxPrintout(title) {}
204
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);
212
213
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) {
216 bool hadErr = false;
217
218 if (m_myInst.findCallback("GetPageInfo")) {
219 PyObject* result = m_myInst.callCallbackObj(Py_BuildValue("()"));
220 if (result && PyTuple_Check(result) && PyTuple_Size(result) == 4) {
221 PyObject* val;
222
223 val = PyTuple_GetItem(result, 0);
224 if (PyInt_Check(val)) *minPage = PyInt_AsLong(val);
225 else hadErr = true;
226
227 val = PyTuple_GetItem(result, 1);
228 if (PyInt_Check(val)) *maxPage = PyInt_AsLong(val);
229 else hadErr = true;
230
231 val = PyTuple_GetItem(result, 2);
232 if (PyInt_Check(val)) *pageFrom = PyInt_AsLong(val);
233 else hadErr = true;
234
235 val = PyTuple_GetItem(result, 3);
236 if (PyInt_Check(val)) *pageTo = PyInt_AsLong(val);
237 else hadErr = true;
238 }
239 else
240 hadErr = true;
241
242 if (hadErr) {
243 PyErr_SetString(PyExc_TypeError, "GetPageInfo should return a tuple of 4 integers.");
244 PyErr_Print();
245 }
246 Py_DECREF(result);
247 #ifdef WXP_WITH_THREAD
248 PyEval_SaveThread();
249 #endif
250 }
251 else
252 wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo);
253 }
254 void base_GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) {
255 wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo);
256 }
257
258 PYPRIVATE;
259 };
260 %}
261
262
263 // Now define the custom class for SWIGging
264 %name(wxPrintout) class wxPyPrintout {
265 public:
266 wxPyPrintout(const char* title = "Printout");
267
268 void _setSelf(PyObject* self);
269 %pragma(python) addtomethod = "__init__:self._setSelf(self)"
270
271 %addmethods {
272 void Destroy() { delete self; }
273 }
274
275 wxDC* GetDC();
276 void GetPageSizeMM(int *OUTPUT, int *OUTPUT);
277 void GetPageSizePixels(int *OUTPUT, int *OUTPUT);
278 void GetPPIPrinter(int *OUTPUT, int *OUTPUT);
279 void GetPPIScreen(int *OUTPUT, int *OUTPUT);
280 bool IsPreview();
281
282 bool base_OnBeginDocument(int startPage, int endPage);
283 void base_OnEndDocument();
284 void base_OnBeginPrinting();
285 void base_OnEndPrinting();
286 void base_OnPreparePrinting();
287 void base_GetPageInfo(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT);
288 bool base_HasPage(int page);
289 };
290
291 //----------------------------------------------------------------------
292
293 class wxPrinter {
294 public:
295 wxPrinter(wxPrintDialogData* data = NULL);
296 ~wxPrinter();
297
298 // bool Abort();
299 void CreateAbortWindow(wxWindow* parent, wxPyPrintout* printout);
300 wxPrintDialogData& GetPrintDialogData();
301 bool Print(wxWindow *parent, wxPyPrintout *printout, int prompt=TRUE);
302 wxDC* PrintDialog(wxWindow *parent);
303 void ReportError(wxWindow *parent, wxPyPrintout *printout, char* message);
304 bool Setup(wxWindow *parent);
305 };
306
307 //----------------------------------------------------------------------
308
309 class wxPrintPreview {
310 public:
311 wxPrintPreview(wxPyPrintout* printout, wxPyPrintout* printoutForPrinting, wxPrintData* data=NULL);
312 // ~wxPrintPreview(); **** ????
313
314 wxWindow* GetCanvas();
315 int GetCurrentPage();
316 wxFrame * GetFrame();
317 int GetMaxPage();
318 int GetMinPage();
319 wxPrintDialogData& GetPrintDialogData();
320 wxPyPrintout * GetPrintout();
321 wxPyPrintout * GetPrintoutForPrinting();
322 int GetZoom();
323 bool Ok();
324 bool Print(bool prompt);
325 void SetCanvas(wxWindow* window);
326 void SetCurrentPage(int pageNum);
327 void SetFrame(wxFrame *frame);
328 void SetPrintout(wxPyPrintout *printout);
329 void SetZoom(int percent);
330 };
331
332 //----------------------------------------------------------------------
333
334 class wxPreviewFrame : public wxFrame {
335 public:
336 wxPreviewFrame(wxPrintPreview* preview, wxFrame* parent, const wxString& title,
337 const wxPoint& pos = wxPyDefaultPosition,
338 const wxSize& size = wxPyDefaultSize,
339 long style = wxDEFAULT_FRAME_STYLE,
340 char* name = "frame");
341
342 %pragma(python) addtomethod = "__init__:wx._StdFrameCallbacks(self)"
343
344 void Initialize();
345
346 // **** need to use derived class so these can be properly overridden:
347 //void CreateControlBar()
348 //void CreateCanvas()
349
350 };
351
352 //----------------------------------------------------------------------
353 //----------------------------------------------------------------------
354 //----------------------------------------------------------------------
355
356
357
358