]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/printfw.i
Corrected link error for missing wxRegTipProvider::GetTip by giving it
[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() {
273 delete self;
274 }
275 }
276
277 wxDC* GetDC();
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);
282 bool IsPreview();
283
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);
291 };
292
293 //----------------------------------------------------------------------
294
295 class wxPrinter {
296 public:
297 wxPrinter(wxPrintDialogData* data = NULL);
298 ~wxPrinter();
299
300 // bool Abort();
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);
307 };
308
309 //----------------------------------------------------------------------
310
311 class wxPrintPreview {
312 public:
313 wxPrintPreview(wxPyPrintout* printout, wxPyPrintout* printoutForPrinting, wxPrintData* data=NULL);
314 // ~wxPrintPreview(); **** ????
315
316 wxWindow* GetCanvas();
317 int GetCurrentPage();
318 wxFrame * GetFrame();
319 int GetMaxPage();
320 int GetMinPage();
321 wxPrintDialogData& GetPrintDialogData();
322 wxPyPrintout * GetPrintout();
323 wxPyPrintout * GetPrintoutForPrinting();
324 int GetZoom();
325 bool Ok();
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);
332 };
333
334 //----------------------------------------------------------------------
335
336 class wxPreviewFrame : public wxFrame {
337 public:
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");
343
344 %pragma(python) addtomethod = "__init__:wx._StdFrameCallbacks(self)"
345
346 void Initialize();
347
348 // **** need to use derived class so these can be properly overridden:
349 //void CreateControlBar()
350 //void CreateCanvas()
351
352 };
353
354 //----------------------------------------------------------------------
355 //----------------------------------------------------------------------
356 //----------------------------------------------------------------------
357
358
359
360