]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/printfw.i
added wx/defs.h include to correct compilation issues under Mac OS X
[wxWidgets.git] / wxPython / src / printfw.i
CommitLineData
bb0054cd
RD
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>
2abc0a0f
RD
19
20#include "printfw.h"
bb0054cd
RD
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
9416aa89 44class wxPrintData : public wxObject {
bb0054cd
RD
45public:
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
926bb76c
RD
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);
bb0054cd
RD
96
97};
98
99//----------------------------------------------------------------------
100
1b62f00d
RD
101#ifdef __WXMSW__
102class wxPrinterDC : public wxDC {
103public:
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
9416aa89 115class wxPageSetupDialogData : public wxObject {
bb0054cd
RD
116public:
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);
3ca6a5f0 149 void SetPaperId(wxPaperSize id);
bb0054cd
RD
150 void SetPaperSize(const wxSize& size);
151 void SetPrintData(const wxPrintData& printData);
152};
153
154
155class wxPageSetupDialog : public wxDialog {
156public:
157 wxPageSetupDialog(wxWindow* parent, wxPageSetupDialogData* data = NULL);
158
f6bcfd97 159 %pragma(python) addtomethod = "__init__:#wx._StdDialogCallbacks(self)"
bb0054cd
RD
160
161 wxPageSetupDialogData& GetPageSetupData();
162 int ShowModal();
163};
164
165//----------------------------------------------------------------------
166
167
9416aa89 168class wxPrintDialogData : public wxObject {
bb0054cd
RD
169public:
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
202class wxPrintDialog : public wxDialog {
203public:
204 wxPrintDialog(wxWindow* parent, wxPrintDialogData* data = NULL);
205
f6bcfd97 206 %pragma(python) addtomethod = "__init__:#wx._StdDialogCallbacks(self)"
bb0054cd
RD
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%{
2abc0a0f
RD
217
218
219// Since this one would be tough and ugly to do with the Macros...
220void wxPyPrintout::GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) {
194fa2ac 221 bool hadErr = FALSE;
19a97bd6 222 bool found;
2abc0a0f 223
19a97bd6
RD
224 wxPyTState* state = wxPyBeginBlockThreads();
225 if ((found = m_myInst.findCallback("GetPageInfo"))) {
2abc0a0f
RD
226 PyObject* result = m_myInst.callCallbackObj(Py_BuildValue("()"));
227 if (result && PyTuple_Check(result) && PyTuple_Size(result) == 4) {
228 PyObject* val;
229
230 val = PyTuple_GetItem(result, 0);
231 if (PyInt_Check(val)) *minPage = PyInt_AsLong(val);
194fa2ac 232 else hadErr = TRUE;
2abc0a0f
RD
233
234 val = PyTuple_GetItem(result, 1);
235 if (PyInt_Check(val)) *maxPage = PyInt_AsLong(val);
194fa2ac 236 else hadErr = TRUE;
2abc0a0f
RD
237
238 val = PyTuple_GetItem(result, 2);
239 if (PyInt_Check(val)) *pageFrom = PyInt_AsLong(val);
194fa2ac 240 else hadErr = TRUE;
2abc0a0f
RD
241
242 val = PyTuple_GetItem(result, 3);
243 if (PyInt_Check(val)) *pageTo = PyInt_AsLong(val);
194fa2ac 244 else hadErr = TRUE;
bb0054cd
RD
245 }
246 else
194fa2ac 247 hadErr = TRUE;
1afc06c2 248
2abc0a0f
RD
249 if (hadErr) {
250 PyErr_SetString(PyExc_TypeError, "GetPageInfo should return a tuple of 4 integers.");
251 PyErr_Print();
252 }
253 Py_DECREF(result);
bb0054cd 254 }
19a97bd6
RD
255 wxPyEndBlockThreads(state);
256 if (! found)
bb0054cd 257 wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo);
2abc0a0f
RD
258}
259
260void wxPyPrintout::base_GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) {
261 wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo);
262}
263
1afc06c2
RD
264
265IMP_PYCALLBACK_BOOL_INTINT(wxPyPrintout, wxPrintout, OnBeginDocument);
266IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnEndDocument);
267IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnBeginPrinting);
268IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnEndPrinting);
269IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnPreparePrinting);
270IMP_PYCALLBACK_BOOL_INT_pure(wxPyPrintout, wxPrintout, OnPrintPage);
271IMP_PYCALLBACK_BOOL_INT(wxPyPrintout, wxPrintout, HasPage);
272
273
bb0054cd
RD
274%}
275
276
277// Now define the custom class for SWIGging
9416aa89 278%name(wxPrintout) class wxPyPrintout : public wxObject {
bb0054cd
RD
279public:
280 wxPyPrintout(const char* title = "Printout");
281
f6bcfd97
BP
282 void _setSelf(PyObject* self, PyObject* _class);
283 %pragma(python) addtomethod = "__init__:self._setSelf(self, wxPrintout)"
bb0054cd
RD
284
285 %addmethods {
efc5f224 286 void Destroy() { delete self; }
bb0054cd
RD
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
9416aa89 307class wxPrinter : public wxObject {
bb0054cd
RD
308public:
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
9416aa89 323class wxPrintPreview : public wxObject {
bb0054cd
RD
324public:
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
348class wxPreviewFrame : public wxFrame {
349public:
350 wxPreviewFrame(wxPrintPreview* preview, wxFrame* parent, const wxString& title,
b68dc582
RD
351 const wxPoint& pos = wxDefaultPosition,
352 const wxSize& size = wxDefaultSize,
bb0054cd
RD
353 long style = wxDEFAULT_FRAME_STYLE,
354 char* name = "frame");
355
f6bcfd97 356 %pragma(python) addtomethod = "__init__:#wx._StdFrameCallbacks(self)"
bb0054cd
RD
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//----------------------------------------------------------------------
9416aa89
RD
367
368%init %{
369 wxPyPtrTypeMap_Add("wxPrintout", "wxPyPrintout");
370%}
371
bb0054cd
RD
372//----------------------------------------------------------------------
373//----------------------------------------------------------------------
374
375
376
377