]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/printfw.i
synthetize 'button up' event before doubleclick, 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 #include <wx/dcps.h>
20
21 #include "printfw.h"
22 %}
23
24 //----------------------------------------------------------------------
25
26 %include typemaps.i
27 %include my_typemaps.i
28
29 // Import some definitions of other classes, etc.
30 %import _defs.i
31 %import misc.i
32 %import windows.i
33 %import gdi.i
34 %import cmndlgs.i
35 %import frames.i
36
37
38 %pragma(python) code = "import wx"
39
40
41 //----------------------------------------------------------------------
42
43
44
45 class wxPrintData : public wxObject {
46 public:
47 wxPrintData();
48 ~wxPrintData();
49
50 int GetNoCopies();
51 bool GetCollate();
52 int GetOrientation();
53
54 const wxString& GetPrinterName();
55 bool GetColour();
56 wxDuplexMode GetDuplex();
57 wxPaperSize GetPaperId();
58 const wxSize& GetPaperSize();
59
60 wxPrintQuality GetQuality();
61
62 void SetNoCopies(int v);
63 void SetCollate(bool flag);
64 void SetOrientation(int orient);
65
66 void SetPrinterName(const wxString& name);
67 void SetColour(bool colour);
68 void SetDuplex(wxDuplexMode duplex);
69 void SetPaperId(wxPaperSize sizeId);
70 void SetPaperSize(const wxSize& sz);
71 void SetQuality(wxPrintQuality quality);
72
73 // PostScript-specific data
74 const wxString& GetPrinterCommand();
75 const wxString& GetPrinterOptions();
76 const wxString& GetPreviewCommand();
77 const wxString& GetFilename();
78 const wxString& GetFontMetricPath();
79 double GetPrinterScaleX();
80 double GetPrinterScaleY();
81 long GetPrinterTranslateX();
82 long GetPrinterTranslateY();
83 wxPrintMode GetPrintMode();
84
85 void SetPrinterCommand(const wxString& command);
86 void SetPrinterOptions(const wxString& options);
87 void SetPreviewCommand(const wxString& command);
88 void SetFilename(const wxString& filename);
89 void SetFontMetricPath(const wxString& path);
90 void SetPrinterScaleX(double x);
91 void SetPrinterScaleY(double y);
92 void SetPrinterScaling(double x, double y);
93 void SetPrinterTranslateX(long x);
94 void SetPrinterTranslateY(long y);
95 void SetPrinterTranslation(long x, long y);
96 void SetPrintMode(wxPrintMode printMode);
97
98 };
99
100 //----------------------------------------------------------------------
101
102 #ifdef __WXMSW__
103 class wxPrinterDC : public wxDC {
104 public:
105 wxPrinterDC(const wxPrintData& printData);
106 %name(wxPrinterDC2) wxPrinterDC(const wxString& driver,
107 const wxString& device,
108 const wxString& output,
109 bool interactive = TRUE,
110 int orientation = wxPORTRAIT);
111 };
112 #endif
113
114 //---------------------------------------------------------------------------
115
116 class wxPostScriptDC : public wxDC {
117 public:
118 wxPostScriptDC(const wxPrintData& printData);
119 %name(wxPostScriptDC2)wxPostScriptDC(const wxString& output,
120 bool interactive = TRUE,
121 wxWindow* parent = NULL);
122
123 wxPrintData& GetPrintData();
124 void SetPrintData(const wxPrintData& data);
125
126 static void SetResolution(int ppi);
127 static int GetResolution();
128 };
129
130 //---------------------------------------------------------------------------
131
132 class wxPageSetupDialogData : public wxObject {
133 public:
134 wxPageSetupDialogData();
135 ~wxPageSetupDialogData();
136
137 void EnableHelp(bool flag);
138 void EnableMargins(bool flag);
139 void EnableOrientation(bool flag);
140 void EnablePaper(bool flag);
141 void EnablePrinter(bool flag);
142 bool GetDefaultMinMargins();
143 bool GetEnableMargins();
144 bool GetEnableOrientation();
145 bool GetEnablePaper();
146 bool GetEnablePrinter();
147 bool GetEnableHelp();
148 bool GetDefaultInfo();
149 wxPoint GetMarginTopLeft();
150 wxPoint GetMarginBottomRight();
151 wxPoint GetMinMarginTopLeft();
152 wxPoint GetMinMarginBottomRight();
153 wxPaperSize GetPaperId();
154 wxSize GetPaperSize();
155 %addmethods {
156 %new wxPrintData* GetPrintData() {
157 return new wxPrintData(self->GetPrintData()); // force a copy
158 }
159 }
160 void SetDefaultInfo(bool flag);
161 void SetDefaultMinMargins(bool flag);
162 void SetMarginTopLeft(const wxPoint& pt);
163 void SetMarginBottomRight(const wxPoint& pt);
164 void SetMinMarginTopLeft(const wxPoint& pt);
165 void SetMinMarginBottomRight(const wxPoint& pt);
166 void SetPaperId(wxPaperSize id);
167 void SetPaperSize(const wxSize& size);
168 void SetPrintData(const wxPrintData& printData);
169 };
170
171
172 class wxPageSetupDialog : public wxDialog {
173 public:
174 wxPageSetupDialog(wxWindow* parent, wxPageSetupDialogData* data = NULL);
175
176 %pragma(python) addtomethod = "__init__:#wx._StdDialogCallbacks(self)"
177
178 wxPageSetupDialogData& GetPageSetupData();
179 int ShowModal();
180 };
181
182 //----------------------------------------------------------------------
183
184
185 class wxPrintDialogData : public wxObject {
186 public:
187 wxPrintDialogData();
188 ~wxPrintDialogData();
189
190 void EnableHelp(bool flag);
191 void EnablePageNumbers(bool flag);
192 void EnablePrintToFile(bool flag);
193 void EnableSelection(bool flag);
194 bool GetAllPages();
195 bool GetCollate();
196 int GetFromPage();
197 int GetMaxPage();
198 int GetMinPage();
199 int GetNoCopies();
200 %addmethods {
201 %new wxPrintData* GetPrintData() {
202 return new wxPrintData(self->GetPrintData()); // force a copy
203 }
204 }
205 bool GetPrintToFile();
206 int GetToPage();
207 void SetCollate(bool flag);
208 void SetFromPage(int page);
209 void SetMaxPage(int page);
210 void SetMinPage(int page);
211 void SetNoCopies(int n);
212 void SetPrintData(const wxPrintData& printData);
213 void SetPrintToFile(bool flag);
214 void SetSetupDialog(bool flag);
215 void SetToPage(int page);
216 };
217
218
219 class wxPrintDialog : public wxDialog {
220 public:
221 wxPrintDialog(wxWindow* parent, wxPrintDialogData* data = NULL);
222
223 %pragma(python) addtomethod = "__init__:#wx._StdDialogCallbacks(self)"
224
225 wxPrintDialogData& GetPrintDialogData();
226 %new wxDC* GetPrintDC();
227 int ShowModal();
228 };
229
230 //----------------------------------------------------------------------
231 //----------------------------------------------------------------------
232 // Custom wxPrintout class that knows how to call python
233 %{
234
235
236 // Since this one would be tough and ugly to do with the Macros...
237 void wxPyPrintout::GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) {
238 bool hadErr = FALSE;
239 bool found;
240
241 wxPyBeginBlockThreads();
242 if ((found = m_myInst.findCallback("GetPageInfo"))) {
243 PyObject* result = m_myInst.callCallbackObj(Py_BuildValue("()"));
244 if (result && PyTuple_Check(result) && PyTuple_Size(result) == 4) {
245 PyObject* val;
246
247 val = PyTuple_GetItem(result, 0);
248 if (PyInt_Check(val)) *minPage = PyInt_AsLong(val);
249 else hadErr = TRUE;
250
251 val = PyTuple_GetItem(result, 1);
252 if (PyInt_Check(val)) *maxPage = PyInt_AsLong(val);
253 else hadErr = TRUE;
254
255 val = PyTuple_GetItem(result, 2);
256 if (PyInt_Check(val)) *pageFrom = PyInt_AsLong(val);
257 else hadErr = TRUE;
258
259 val = PyTuple_GetItem(result, 3);
260 if (PyInt_Check(val)) *pageTo = PyInt_AsLong(val);
261 else hadErr = TRUE;
262 }
263 else
264 hadErr = TRUE;
265
266 if (hadErr) {
267 PyErr_SetString(PyExc_TypeError, "GetPageInfo should return a tuple of 4 integers.");
268 PyErr_Print();
269 }
270 Py_DECREF(result);
271 }
272 wxPyEndBlockThreads();
273 if (! found)
274 wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo);
275 }
276
277 void wxPyPrintout::base_GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) {
278 wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo);
279 }
280
281
282 IMP_PYCALLBACK_BOOL_INTINT(wxPyPrintout, wxPrintout, OnBeginDocument);
283 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnEndDocument);
284 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnBeginPrinting);
285 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnEndPrinting);
286 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnPreparePrinting);
287 IMP_PYCALLBACK_BOOL_INT_pure(wxPyPrintout, wxPrintout, OnPrintPage);
288 IMP_PYCALLBACK_BOOL_INT(wxPyPrintout, wxPrintout, HasPage);
289
290
291 %}
292
293
294 // Now define the custom class for SWIGging
295 %name(wxPrintout) class wxPyPrintout : public wxObject {
296 public:
297 wxPyPrintout(const char* title = "Printout");
298
299 void _setCallbackInfo(PyObject* self, PyObject* _class);
300 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPrintout)"
301
302 %addmethods {
303 void Destroy() { delete self; }
304 }
305
306 wxDC* GetDC();
307 void GetPageSizeMM(int *OUTPUT, int *OUTPUT);
308 void GetPageSizePixels(int *OUTPUT, int *OUTPUT);
309 void GetPPIPrinter(int *OUTPUT, int *OUTPUT);
310 void GetPPIScreen(int *OUTPUT, int *OUTPUT);
311 bool IsPreview();
312
313 bool base_OnBeginDocument(int startPage, int endPage);
314 void base_OnEndDocument();
315 void base_OnBeginPrinting();
316 void base_OnEndPrinting();
317 void base_OnPreparePrinting();
318 void base_GetPageInfo(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT);
319 bool base_HasPage(int page);
320 };
321
322 //----------------------------------------------------------------------
323
324 class wxPrinter : public wxObject {
325 public:
326 wxPrinter(wxPrintDialogData* data = NULL);
327 ~wxPrinter();
328
329 // bool Abort();
330 void CreateAbortWindow(wxWindow* parent, wxPyPrintout* printout);
331 wxPrintDialogData& GetPrintDialogData();
332 bool Print(wxWindow *parent, wxPyPrintout *printout, int prompt=TRUE);
333 wxDC* PrintDialog(wxWindow *parent);
334 void ReportError(wxWindow *parent, wxPyPrintout *printout, char* message);
335 bool Setup(wxWindow *parent);
336 };
337
338 //----------------------------------------------------------------------
339
340 class wxPrintPreview : public wxObject {
341 public:
342 wxPrintPreview(wxPyPrintout* printout, wxPyPrintout* printoutForPrinting, wxPrintData* data=NULL);
343 // ~wxPrintPreview(); **** ????
344
345 wxWindow* GetCanvas();
346 int GetCurrentPage();
347 wxFrame * GetFrame();
348 int GetMaxPage();
349 int GetMinPage();
350 wxPrintDialogData& GetPrintDialogData();
351 wxPyPrintout * GetPrintout();
352 wxPyPrintout * GetPrintoutForPrinting();
353 int GetZoom();
354 bool Ok();
355 bool Print(bool prompt);
356 void SetCanvas(wxWindow* window);
357 void SetCurrentPage(int pageNum);
358 void SetFrame(wxFrame *frame);
359 void SetPrintout(wxPyPrintout *printout);
360 void SetZoom(int percent);
361 };
362
363 //----------------------------------------------------------------------
364
365 class wxPreviewFrame : public wxFrame {
366 public:
367 wxPreviewFrame(wxPrintPreview* preview, wxFrame* parent, const wxString& title,
368 const wxPoint& pos = wxDefaultPosition,
369 const wxSize& size = wxDefaultSize,
370 long style = wxDEFAULT_FRAME_STYLE,
371 char* name = "frame");
372
373 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
374
375 void Initialize();
376
377 // **** need to use derived class so these can be properly overridden:
378 //void CreateControlBar()
379 //void CreateCanvas()
380
381 };
382
383 //----------------------------------------------------------------------
384
385 %init %{
386 wxPyPtrTypeMap_Add("wxPrintout", "wxPyPrintout");
387 %}
388
389 //----------------------------------------------------------------------
390 //----------------------------------------------------------------------
391
392
393
394