]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/printfw.i
* Added IsPaused() to wxSoundFileStream
[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 #include "printfw.h"
21 %}
22
23 //----------------------------------------------------------------------
24
25 %include typemaps.i
26 %include my_typemaps.i
27
28 // Import some definitions of other classes, etc.
29 %import _defs.i
30 %import misc.i
31 %import windows.i
32 %import gdi.i
33 %import cmndlgs.i
34 %import frames.i
35
36
37 %pragma(python) code = "import wx"
38
39
40 //----------------------------------------------------------------------
41
42
43
44 class wxPrintData {
45 public:
46 wxPrintData();
47 ~wxPrintData();
48
49 int GetNoCopies();
50 bool GetCollate();
51 int GetOrientation();
52
53 const wxString& GetPrinterName();
54 bool GetColour();
55 wxDuplexMode GetDuplex();
56 wxPaperSize GetPaperId();
57 const wxSize& GetPaperSize();
58
59 wxPrintQuality GetQuality();
60
61 void SetNoCopies(int v);
62 void SetCollate(bool flag);
63 void SetOrientation(int orient);
64
65 void SetPrinterName(const wxString& name);
66 void SetColour(bool colour);
67 void SetDuplex(wxDuplexMode duplex);
68 void SetPaperId(wxPaperSize sizeId);
69 void SetPaperSize(const wxSize& sz);
70 void SetQuality(wxPrintQuality quality);
71
72 // // PostScript-specific data
73 // const wxString& GetPrinterCommand();
74 // const wxString& GetPrinterOptions();
75 // const wxString& GetPreviewCommand();
76 // const wxString& GetFilename();
77 // const wxString& GetFontMetricPath();
78 // double GetPrinterScaleX();
79 // double GetPrinterScaleY();
80 // long GetPrinterTranslateX();
81 // long GetPrinterTranslateY();
82 // wxPrintMode GetPrintMode();
83
84 // void SetPrinterCommand(const wxString& command);
85 // void SetPrinterOptions(const wxString& options);
86 // void SetPreviewCommand(const wxString& command);
87 // void SetFilename(const wxString& filename);
88 // void SetFontMetricPath(const wxString& path);
89 // void SetPrinterScaleX(double x);
90 // void SetPrinterScaleY(double y);
91 // void SetPrinterScaling(double x, double y);
92 // void SetPrinterTranslateX(long x);
93 // void SetPrinterTranslateY(long y);
94 // void SetPrinterTranslation(long x, long y);
95 // void SetPrintMode(wxPrintMode printMode);
96
97 };
98
99 //----------------------------------------------------------------------
100
101 class wxPageSetupDialogData {
102 public:
103 wxPageSetupDialogData();
104 ~wxPageSetupDialogData();
105
106 void EnableHelp(bool flag);
107 void EnableMargins(bool flag);
108 void EnableOrientation(bool flag);
109 void EnablePaper(bool flag);
110 void EnablePrinter(bool flag);
111 bool GetDefaultMinMargins();
112 bool GetEnableMargins();
113 bool GetEnableOrientation();
114 bool GetEnablePaper();
115 bool GetEnablePrinter();
116 bool GetEnableHelp();
117 bool GetDefaultInfo();
118 wxPoint GetMarginTopLeft();
119 wxPoint GetMarginBottomRight();
120 wxPoint GetMinMarginTopLeft();
121 wxPoint GetMinMarginBottomRight();
122 wxPaperSize GetPaperId();
123 wxSize GetPaperSize();
124 %addmethods {
125 %new wxPrintData* GetPrintData() {
126 return new wxPrintData(self->GetPrintData()); // force a copy
127 }
128 }
129 void SetDefaultInfo(bool flag);
130 void SetDefaultMinMargins(bool flag);
131 void SetMarginTopLeft(const wxPoint& pt);
132 void SetMarginBottomRight(const wxPoint& pt);
133 void SetMinMarginTopLeft(const wxPoint& pt);
134 void SetMinMarginBottomRight(const wxPoint& pt);
135 void SetPaperId(wxPaperSize& id);
136 void SetPaperSize(const wxSize& size);
137 void SetPrintData(const wxPrintData& printData);
138 };
139
140
141 class wxPageSetupDialog : public wxDialog {
142 public:
143 wxPageSetupDialog(wxWindow* parent, wxPageSetupDialogData* data = NULL);
144
145 %pragma(python) addtomethod = "__init__:wx._StdDialogCallbacks(self)"
146
147 wxPageSetupDialogData& GetPageSetupData();
148 int ShowModal();
149 };
150
151 //----------------------------------------------------------------------
152
153
154 class wxPrintDialogData {
155 public:
156 wxPrintDialogData();
157 ~wxPrintDialogData();
158
159 void EnableHelp(bool flag);
160 void EnablePageNumbers(bool flag);
161 void EnablePrintToFile(bool flag);
162 void EnableSelection(bool flag);
163 bool GetAllPages();
164 bool GetCollate();
165 int GetFromPage();
166 int GetMaxPage();
167 int GetMinPage();
168 int GetNoCopies();
169 %addmethods {
170 %new wxPrintData* GetPrintData() {
171 return new wxPrintData(self->GetPrintData()); // force a copy
172 }
173 }
174 bool GetPrintToFile();
175 int GetToPage();
176 void SetCollate(bool flag);
177 void SetFromPage(int page);
178 void SetMaxPage(int page);
179 void SetMinPage(int page);
180 void SetNoCopies(int n);
181 void SetPrintData(const wxPrintData& printData);
182 void SetPrintToFile(bool flag);
183 void SetSetupDialog(bool flag);
184 void SetToPage(int page);
185 };
186
187
188 class wxPrintDialog : public wxDialog {
189 public:
190 wxPrintDialog(wxWindow* parent, wxPrintDialogData* data = NULL);
191
192 %pragma(python) addtomethod = "__init__:wx._StdDialogCallbacks(self)"
193
194 wxPrintDialogData& GetPrintDialogData();
195 %new wxDC* GetPrintDC();
196 int ShowModal();
197 };
198
199 //----------------------------------------------------------------------
200 //----------------------------------------------------------------------
201 // Custom wxPrintout class that knows how to call python
202 %{
203
204
205 // Since this one would be tough and ugly to do with the Macros...
206 void wxPyPrintout::GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) {
207 bool hadErr = FALSE;
208
209 bool doSave = wxPyRestoreThread();
210 if (m_myInst.findCallback("GetPageInfo")) {
211 PyObject* result = m_myInst.callCallbackObj(Py_BuildValue("()"));
212 if (result && PyTuple_Check(result) && PyTuple_Size(result) == 4) {
213 PyObject* val;
214
215 val = PyTuple_GetItem(result, 0);
216 if (PyInt_Check(val)) *minPage = PyInt_AsLong(val);
217 else hadErr = TRUE;
218
219 val = PyTuple_GetItem(result, 1);
220 if (PyInt_Check(val)) *maxPage = PyInt_AsLong(val);
221 else hadErr = TRUE;
222
223 val = PyTuple_GetItem(result, 2);
224 if (PyInt_Check(val)) *pageFrom = PyInt_AsLong(val);
225 else hadErr = TRUE;
226
227 val = PyTuple_GetItem(result, 3);
228 if (PyInt_Check(val)) *pageTo = PyInt_AsLong(val);
229 else hadErr = TRUE;
230 }
231 else
232 hadErr = TRUE;
233
234 if (hadErr) {
235 PyErr_SetString(PyExc_TypeError, "GetPageInfo should return a tuple of 4 integers.");
236 PyErr_Print();
237 }
238 Py_DECREF(result);
239 }
240 else
241 wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo);
242
243 wxPySaveThread(doSave);
244 }
245
246 void wxPyPrintout::base_GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) {
247 wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo);
248 }
249
250
251 IMP_PYCALLBACK_BOOL_INTINT(wxPyPrintout, wxPrintout, OnBeginDocument);
252 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnEndDocument);
253 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnBeginPrinting);
254 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnEndPrinting);
255 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnPreparePrinting);
256 IMP_PYCALLBACK_BOOL_INT_pure(wxPyPrintout, wxPrintout, OnPrintPage);
257 IMP_PYCALLBACK_BOOL_INT(wxPyPrintout, wxPrintout, HasPage);
258
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