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