]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/printfw.i
highlight the focused item in non report mode too
[wxWidgets.git] / 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 : public wxObject {
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 #ifdef __WXMSW__
102 class wxPrinterDC : public wxDC {
103 public:
104 wxPrinterDC(const wxPrintData& printData);
105 %name(wxPrinterDC2) wxPrinterDC(const wxString& driver,
106 const wxString& device,
107 const wxString& output,
108 bool interactive = TRUE,
109 int orientation = wxPORTRAIT);
110 };
111 #endif
112
113 //---------------------------------------------------------------------------
114
115 class wxPageSetupDialogData : public wxObject {
116 public:
117 wxPageSetupDialogData();
118 ~wxPageSetupDialogData();
119
120 void EnableHelp(bool flag);
121 void EnableMargins(bool flag);
122 void EnableOrientation(bool flag);
123 void EnablePaper(bool flag);
124 void EnablePrinter(bool flag);
125 bool GetDefaultMinMargins();
126 bool GetEnableMargins();
127 bool GetEnableOrientation();
128 bool GetEnablePaper();
129 bool GetEnablePrinter();
130 bool GetEnableHelp();
131 bool GetDefaultInfo();
132 wxPoint GetMarginTopLeft();
133 wxPoint GetMarginBottomRight();
134 wxPoint GetMinMarginTopLeft();
135 wxPoint GetMinMarginBottomRight();
136 wxPaperSize GetPaperId();
137 wxSize GetPaperSize();
138 %addmethods {
139 %new wxPrintData* GetPrintData() {
140 return new wxPrintData(self->GetPrintData()); // force a copy
141 }
142 }
143 void SetDefaultInfo(bool flag);
144 void SetDefaultMinMargins(bool flag);
145 void SetMarginTopLeft(const wxPoint& pt);
146 void SetMarginBottomRight(const wxPoint& pt);
147 void SetMinMarginTopLeft(const wxPoint& pt);
148 void SetMinMarginBottomRight(const wxPoint& pt);
149 void SetPaperId(wxPaperSize id);
150 void SetPaperSize(const wxSize& size);
151 void SetPrintData(const wxPrintData& printData);
152 };
153
154
155 class wxPageSetupDialog : public wxDialog {
156 public:
157 wxPageSetupDialog(wxWindow* parent, wxPageSetupDialogData* data = NULL);
158
159 %pragma(python) addtomethod = "__init__:#wx._StdDialogCallbacks(self)"
160
161 wxPageSetupDialogData& GetPageSetupData();
162 int ShowModal();
163 };
164
165 //----------------------------------------------------------------------
166
167
168 class wxPrintDialogData : public wxObject {
169 public:
170 wxPrintDialogData();
171 ~wxPrintDialogData();
172
173 void EnableHelp(bool flag);
174 void EnablePageNumbers(bool flag);
175 void EnablePrintToFile(bool flag);
176 void EnableSelection(bool flag);
177 bool GetAllPages();
178 bool GetCollate();
179 int GetFromPage();
180 int GetMaxPage();
181 int GetMinPage();
182 int GetNoCopies();
183 %addmethods {
184 %new wxPrintData* GetPrintData() {
185 return new wxPrintData(self->GetPrintData()); // force a copy
186 }
187 }
188 bool GetPrintToFile();
189 int GetToPage();
190 void SetCollate(bool flag);
191 void SetFromPage(int page);
192 void SetMaxPage(int page);
193 void SetMinPage(int page);
194 void SetNoCopies(int n);
195 void SetPrintData(const wxPrintData& printData);
196 void SetPrintToFile(bool flag);
197 void SetSetupDialog(bool flag);
198 void SetToPage(int page);
199 };
200
201
202 class wxPrintDialog : public wxDialog {
203 public:
204 wxPrintDialog(wxWindow* parent, wxPrintDialogData* data = NULL);
205
206 %pragma(python) addtomethod = "__init__:#wx._StdDialogCallbacks(self)"
207
208 wxPrintDialogData& GetPrintDialogData();
209 %new wxDC* GetPrintDC();
210 int ShowModal();
211 };
212
213 //----------------------------------------------------------------------
214 //----------------------------------------------------------------------
215 // Custom wxPrintout class that knows how to call python
216 %{
217
218
219 // Since this one would be tough and ugly to do with the Macros...
220 void wxPyPrintout::GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) {
221 bool hadErr = FALSE;
222
223 bool doSave = wxPyRestoreThread();
224 if (m_myInst.findCallback("GetPageInfo")) {
225 PyObject* result = m_myInst.callCallbackObj(Py_BuildValue("()"));
226 if (result && PyTuple_Check(result) && PyTuple_Size(result) == 4) {
227 PyObject* val;
228
229 val = PyTuple_GetItem(result, 0);
230 if (PyInt_Check(val)) *minPage = PyInt_AsLong(val);
231 else hadErr = TRUE;
232
233 val = PyTuple_GetItem(result, 1);
234 if (PyInt_Check(val)) *maxPage = PyInt_AsLong(val);
235 else hadErr = TRUE;
236
237 val = PyTuple_GetItem(result, 2);
238 if (PyInt_Check(val)) *pageFrom = PyInt_AsLong(val);
239 else hadErr = TRUE;
240
241 val = PyTuple_GetItem(result, 3);
242 if (PyInt_Check(val)) *pageTo = PyInt_AsLong(val);
243 else hadErr = TRUE;
244 }
245 else
246 hadErr = TRUE;
247
248 if (hadErr) {
249 PyErr_SetString(PyExc_TypeError, "GetPageInfo should return a tuple of 4 integers.");
250 PyErr_Print();
251 }
252 Py_DECREF(result);
253 }
254 else
255 wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo);
256
257 wxPySaveThread(doSave);
258 }
259
260 void wxPyPrintout::base_GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) {
261 wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo);
262 }
263
264
265 IMP_PYCALLBACK_BOOL_INTINT(wxPyPrintout, wxPrintout, OnBeginDocument);
266 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnEndDocument);
267 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnBeginPrinting);
268 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnEndPrinting);
269 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnPreparePrinting);
270 IMP_PYCALLBACK_BOOL_INT_pure(wxPyPrintout, wxPrintout, OnPrintPage);
271 IMP_PYCALLBACK_BOOL_INT(wxPyPrintout, wxPrintout, HasPage);
272
273
274 %}
275
276
277 // Now define the custom class for SWIGging
278 %name(wxPrintout) class wxPyPrintout : public wxObject {
279 public:
280 wxPyPrintout(const char* title = "Printout");
281
282 void _setSelf(PyObject* self, PyObject* _class);
283 %pragma(python) addtomethod = "__init__:self._setSelf(self, wxPrintout)"
284
285 %addmethods {
286 void Destroy() { delete self; }
287 }
288
289 wxDC* GetDC();
290 void GetPageSizeMM(int *OUTPUT, int *OUTPUT);
291 void GetPageSizePixels(int *OUTPUT, int *OUTPUT);
292 void GetPPIPrinter(int *OUTPUT, int *OUTPUT);
293 void GetPPIScreen(int *OUTPUT, int *OUTPUT);
294 bool IsPreview();
295
296 bool base_OnBeginDocument(int startPage, int endPage);
297 void base_OnEndDocument();
298 void base_OnBeginPrinting();
299 void base_OnEndPrinting();
300 void base_OnPreparePrinting();
301 void base_GetPageInfo(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT);
302 bool base_HasPage(int page);
303 };
304
305 //----------------------------------------------------------------------
306
307 class wxPrinter : public wxObject {
308 public:
309 wxPrinter(wxPrintDialogData* data = NULL);
310 ~wxPrinter();
311
312 // bool Abort();
313 void CreateAbortWindow(wxWindow* parent, wxPyPrintout* printout);
314 wxPrintDialogData& GetPrintDialogData();
315 bool Print(wxWindow *parent, wxPyPrintout *printout, int prompt=TRUE);
316 wxDC* PrintDialog(wxWindow *parent);
317 void ReportError(wxWindow *parent, wxPyPrintout *printout, char* message);
318 bool Setup(wxWindow *parent);
319 };
320
321 //----------------------------------------------------------------------
322
323 class wxPrintPreview : public wxObject {
324 public:
325 wxPrintPreview(wxPyPrintout* printout, wxPyPrintout* printoutForPrinting, wxPrintData* data=NULL);
326 // ~wxPrintPreview(); **** ????
327
328 wxWindow* GetCanvas();
329 int GetCurrentPage();
330 wxFrame * GetFrame();
331 int GetMaxPage();
332 int GetMinPage();
333 wxPrintDialogData& GetPrintDialogData();
334 wxPyPrintout * GetPrintout();
335 wxPyPrintout * GetPrintoutForPrinting();
336 int GetZoom();
337 bool Ok();
338 bool Print(bool prompt);
339 void SetCanvas(wxWindow* window);
340 void SetCurrentPage(int pageNum);
341 void SetFrame(wxFrame *frame);
342 void SetPrintout(wxPyPrintout *printout);
343 void SetZoom(int percent);
344 };
345
346 //----------------------------------------------------------------------
347
348 class wxPreviewFrame : public wxFrame {
349 public:
350 wxPreviewFrame(wxPrintPreview* preview, wxFrame* parent, const wxString& title,
351 const wxPoint& pos = wxDefaultPosition,
352 const wxSize& size = wxDefaultSize,
353 long style = wxDEFAULT_FRAME_STYLE,
354 char* name = "frame");
355
356 %pragma(python) addtomethod = "__init__:#wx._StdFrameCallbacks(self)"
357
358 void Initialize();
359
360 // **** need to use derived class so these can be properly overridden:
361 //void CreateControlBar()
362 //void CreateCanvas()
363
364 };
365
366 //----------------------------------------------------------------------
367
368 %init %{
369 wxPyPtrTypeMap_Add("wxPrintout", "wxPyPrintout");
370 %}
371
372 //----------------------------------------------------------------------
373 //----------------------------------------------------------------------
374
375
376
377