]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_printfw.i
remove unneeded include
[wxWidgets.git] / wxPython / src / _printfw.i
CommitLineData
bb0054cd 1/////////////////////////////////////////////////////////////////////////////
d14a1e28
RD
2// Name: _????.i
3// Purpose: SWIG interface for wx????
bb0054cd
RD
4//
5// Author: Robin Dunn
6//
d14a1e28 7// Created: 9-Aug-2003
bb0054cd 8// RCS-ID: $Id$
d14a1e28 9// Copyright: (c) 2003 by Total Control Software
bb0054cd
RD
10// Licence: wxWindows license
11/////////////////////////////////////////////////////////////////////////////
12
d14a1e28 13// Not a %module
bb0054cd 14
bb0054cd 15
d14a1e28
RD
16//---------------------------------------------------------------------------
17%newgroup
bb0054cd 18
137b5242 19%{
d14a1e28
RD
20#include "wx/wxPython/printfw.h"
21
137b5242
RD
22%}
23
b2dc1044
RD
24MAKE_CONST_WXSTRING2(PrintoutTitleStr, wxT("Printout"));
25MAKE_CONST_WXSTRING2(PreviewCanvasNameStr, wxT("previewcanvas"));
26
bb0054cd 27
d14a1e28 28//---------------------------------------------------------------------------
bb0054cd 29
1fded56b
RD
30enum wxPrintMode
31{
32 wxPRINT_MODE_NONE = 0,
33 wxPRINT_MODE_PREVIEW = 1, // Preview in external application
34 wxPRINT_MODE_FILE = 2, // Print to file
4cc5453b
RD
35 wxPRINT_MODE_PRINTER = 3, // Send to printer
36 wxPRINT_MODE_STREAM = 4 // Send postscript data into a stream
1fded56b
RD
37};
38
3077d123
RD
39enum wxPrintBin
40{
41 wxPRINTBIN_DEFAULT,
42
43 wxPRINTBIN_ONLYONE,
44 wxPRINTBIN_LOWER,
45 wxPRINTBIN_MIDDLE,
46 wxPRINTBIN_MANUAL,
47 wxPRINTBIN_ENVELOPE,
48 wxPRINTBIN_ENVMANUAL,
49 wxPRINTBIN_AUTO,
50 wxPRINTBIN_TRACTOR,
51 wxPRINTBIN_SMALLFMT,
52 wxPRINTBIN_LARGEFMT,
53 wxPRINTBIN_LARGECAPACITY,
54 wxPRINTBIN_CASSETTE,
55 wxPRINTBIN_FORMSOURCE,
56
57 wxPRINTBIN_USER,
58};
bb0054cd
RD
59
60
9416aa89 61class wxPrintData : public wxObject {
bb0054cd 62public:
356f3c65 63 %nokwargs wxPrintData;
bb0054cd 64 wxPrintData();
356f3c65
RD
65 wxPrintData(const wxPrintData& data); // for making copies
66
bb0054cd
RD
67 ~wxPrintData();
68
69 int GetNoCopies();
70 bool GetCollate();
71 int GetOrientation();
72
6c2dd16f
RD
73 bool IsOk();
74 %pythoncode { Ok = IsOk }
b7fc54be 75
bb0054cd
RD
76 const wxString& GetPrinterName();
77 bool GetColour();
78 wxDuplexMode GetDuplex();
79 wxPaperSize GetPaperId();
80 const wxSize& GetPaperSize();
81
b2dc1044 82 int GetQuality();
3077d123 83 wxPrintBin GetBin();
7aada1e0 84 wxPrintMode GetPrintMode() const;
3077d123 85
bb0054cd
RD
86 void SetNoCopies(int v);
87 void SetCollate(bool flag);
88 void SetOrientation(int orient);
89
90 void SetPrinterName(const wxString& name);
91 void SetColour(bool colour);
92 void SetDuplex(wxDuplexMode duplex);
93 void SetPaperId(wxPaperSize sizeId);
94 void SetPaperSize(const wxSize& sz);
b2dc1044 95 void SetQuality(int quality);
3077d123 96 void SetBin(wxPrintBin bin);
7aada1e0
RD
97 void SetPrintMode(wxPrintMode printMode);
98
99 wxString GetFilename() const;
100 void SetFilename( const wxString &filename );
101
6c2dd16f 102 %pythoncode { def __nonzero__(self): return self.IsOk() }
7aada1e0 103
a62e4b56
RD
104 //char* GetPrivData() const;
105 //int GetPrivDataLen() const;
106 //void SetPrivData( char *privData, int len );
107
108 %extend {
109 PyObject* GetPrivData() {
110 PyObject* data;
6e6b3557 111 wxPyBlock_t blocked = wxPyBeginBlockThreads();
a62e4b56
RD
112 data = PyString_FromStringAndSize(self->GetPrivData(),
113 self->GetPrivDataLen());
114 wxPyEndBlockThreads(blocked);
115 return data;
116 }
117
118 void SetPrivData(PyObject* data) {
119 if (! PyString_Check(data)) {
120 wxPyBLOCK_THREADS(PyErr_SetString(PyExc_TypeError,
121 "Expected string object"));
122 return /* NULL */ ;
123 }
124
6e6b3557 125 wxPyBlock_t blocked = wxPyBeginBlockThreads();
a62e4b56
RD
126 self->SetPrivData(PyString_AS_STRING(data), PyString_GET_SIZE(data));
127 wxPyEndBlockThreads(blocked);
128 }
129 }
130
7aada1e0
RD
131
132 // NOTE: These are now inside of #if WXWIN_COMPATIBILITY_2_4, so be
133 // prepared to remove them...
134
926bb76c 135 // PostScript-specific data
2f91e3df
KO
136// WXWIN_COMPATIBILITY_2_4
137#if 0
926bb76c
RD
138 const wxString& GetPrinterCommand();
139 const wxString& GetPrinterOptions();
140 const wxString& GetPreviewCommand();
926bb76c
RD
141 const wxString& GetFontMetricPath();
142 double GetPrinterScaleX();
143 double GetPrinterScaleY();
144 long GetPrinterTranslateX();
145 long GetPrinterTranslateY();
926bb76c
RD
146 void SetPrinterCommand(const wxString& command);
147 void SetPrinterOptions(const wxString& options);
148 void SetPreviewCommand(const wxString& command);
926bb76c
RD
149 void SetFontMetricPath(const wxString& path);
150 void SetPrinterScaleX(double x);
151 void SetPrinterScaleY(double y);
152 void SetPrinterScaling(double x, double y);
153 void SetPrinterTranslateX(long x);
154 void SetPrinterTranslateY(long y);
155 void SetPrinterTranslation(long x, long y);
2f91e3df 156#endif
4cc5453b 157
7012bb9f
RD
158 %property(Bin, GetBin, SetBin, doc="See `GetBin` and `SetBin`");
159 %property(Collate, GetCollate, SetCollate, doc="See `GetCollate` and `SetCollate`");
160 %property(Colour, GetColour, SetColour, doc="See `GetColour` and `SetColour`");
161 %property(Duplex, GetDuplex, SetDuplex, doc="See `GetDuplex` and `SetDuplex`");
162 %property(Filename, GetFilename, SetFilename, doc="See `GetFilename` and `SetFilename`");
163 %property(NoCopies, GetNoCopies, SetNoCopies, doc="See `GetNoCopies` and `SetNoCopies`");
164 %property(Orientation, GetOrientation, SetOrientation, doc="See `GetOrientation` and `SetOrientation`");
165 %property(PaperId, GetPaperId, SetPaperId, doc="See `GetPaperId` and `SetPaperId`");
166 %property(PaperSize, GetPaperSize, SetPaperSize, doc="See `GetPaperSize` and `SetPaperSize`");
167 %property(PrintMode, GetPrintMode, SetPrintMode, doc="See `GetPrintMode` and `SetPrintMode`");
168 %property(PrinterName, GetPrinterName, SetPrinterName, doc="See `GetPrinterName` and `SetPrinterName`");
169 %property(PrivData, GetPrivData, SetPrivData, doc="See `GetPrivData` and `SetPrivData`");
170 %property(Quality, GetQuality, SetQuality, doc="See `GetQuality` and `SetQuality`");
eedf876b
RD
171};
172
173//---------------------------------------------------------------------------
174
9416aa89 175class wxPageSetupDialogData : public wxObject {
bb0054cd 176public:
356f3c65 177 %nokwargs wxPageSetupDialogData;
bb0054cd 178 wxPageSetupDialogData();
356f3c65 179 wxPageSetupDialogData(const wxPageSetupDialogData& data); // for making copies
e5bc90ee 180 wxPageSetupDialogData(const wxPrintData& data);
bb0054cd
RD
181 ~wxPageSetupDialogData();
182
183 void EnableHelp(bool flag);
184 void EnableMargins(bool flag);
185 void EnableOrientation(bool flag);
186 void EnablePaper(bool flag);
187 void EnablePrinter(bool flag);
e5bc90ee 188
bb0054cd
RD
189 bool GetDefaultMinMargins();
190 bool GetEnableMargins();
191 bool GetEnableOrientation();
192 bool GetEnablePaper();
193 bool GetEnablePrinter();
194 bool GetEnableHelp();
195 bool GetDefaultInfo();
196 wxPoint GetMarginTopLeft();
197 wxPoint GetMarginBottomRight();
198 wxPoint GetMinMarginTopLeft();
199 wxPoint GetMinMarginBottomRight();
200 wxPaperSize GetPaperId();
201 wxSize GetPaperSize();
d14a1e28
RD
202
203 wxPrintData& GetPrintData();
b7fc54be 204
6c2dd16f
RD
205 bool IsOk();
206 %pythoncode { Ok = IsOk }
b7fc54be 207
bb0054cd
RD
208 void SetDefaultInfo(bool flag);
209 void SetDefaultMinMargins(bool flag);
210 void SetMarginTopLeft(const wxPoint& pt);
211 void SetMarginBottomRight(const wxPoint& pt);
212 void SetMinMarginTopLeft(const wxPoint& pt);
213 void SetMinMarginBottomRight(const wxPoint& pt);
3ca6a5f0 214 void SetPaperId(wxPaperSize id);
bb0054cd 215 void SetPaperSize(const wxSize& size);
e5bc90ee 216
bb0054cd 217 void SetPrintData(const wxPrintData& printData);
1fded56b 218
e5bc90ee
RD
219 // Use paper size defined in this object to set the wxPrintData
220 // paper id
221 void CalculateIdFromPaperSize();
222
223 // Use paper id in wxPrintData to set this object's paper size
224 void CalculatePaperSizeFromId();
225
6c2dd16f 226 %pythoncode { def __nonzero__(self): return self.IsOk() }
7012bb9f
RD
227
228 %property(DefaultInfo, GetDefaultInfo, SetDefaultInfo, doc="See `GetDefaultInfo` and `SetDefaultInfo`");
229 %property(DefaultMinMargins, GetDefaultMinMargins, SetDefaultMinMargins, doc="See `GetDefaultMinMargins` and `SetDefaultMinMargins`");
230
231// %property(EnableHelp, GetEnableHelp, doc="See `GetEnableHelp`");
232// %property(EnableMargins, GetEnableMargins, doc="See `GetEnableMargins`");
233// %property(EnableOrientation, GetEnableOrientation, doc="See `GetEnableOrientation`");
234// %property(EnablePaper, GetEnablePaper, doc="See `GetEnablePaper`");
235// %property(EnablePrinter, GetEnablePrinter, doc="See `GetEnablePrinter`");
236
237 %property(MarginBottomRight, GetMarginBottomRight, SetMarginBottomRight, doc="See `GetMarginBottomRight` and `SetMarginBottomRight`");
238 %property(MarginTopLeft, GetMarginTopLeft, SetMarginTopLeft, doc="See `GetMarginTopLeft` and `SetMarginTopLeft`");
239 %property(MinMarginBottomRight, GetMinMarginBottomRight, SetMinMarginBottomRight, doc="See `GetMinMarginBottomRight` and `SetMinMarginBottomRight`");
240 %property(MinMarginTopLeft, GetMinMarginTopLeft, SetMinMarginTopLeft, doc="See `GetMinMarginTopLeft` and `SetMinMarginTopLeft`");
241 %property(PaperId, GetPaperId, SetPaperId, doc="See `GetPaperId` and `SetPaperId`");
242 %property(PaperSize, GetPaperSize, SetPaperSize, doc="See `GetPaperSize` and `SetPaperSize`");
243 %property(PrintData, GetPrintData, SetPrintData, doc="See `GetPrintData` and `SetPrintData`");
244
bb0054cd
RD
245};
246
247
d14a1e28 248
32bf5e4a
RD
249// NOTE: Contrary to it's name, this class doesn't derive from wxDialog. It
250// is a facade in front of a platform-specific (native dialog) provided by the
251// wxPrintFactory.
252
ab1f7d2a
RD
253MustHaveApp(wxPageSetupDialog);
254
32bf5e4a
RD
255class wxPageSetupDialog : public wxObject
256{
bb0054cd 257public:
d14a1e28 258 wxPageSetupDialog(wxWindow* parent, wxPageSetupDialogData* data = NULL);
7847dc50
RD
259 ~wxPageSetupDialog();
260
bb0054cd 261 wxPageSetupDialogData& GetPageSetupData();
32bf5e4a 262 wxPageSetupDialogData& GetPageSetupDialogData();
bb0054cd 263 int ShowModal();
7847dc50
RD
264
265 %pythoncode { def Destroy(self): pass }
7012bb9f
RD
266
267 %property(PageSetupData, GetPageSetupData, doc="See `GetPageSetupData`");
268 %property(PageSetupDialogData, GetPageSetupDialogData, doc="See `GetPageSetupDialogData`");
269
bb0054cd
RD
270};
271
d14a1e28 272//---------------------------------------------------------------------------
bb0054cd
RD
273
274
9416aa89 275class wxPrintDialogData : public wxObject {
bb0054cd 276public:
d88d4683 277 %nokwargs wxPrintDialogData;
bb0054cd 278 wxPrintDialogData();
e5bc90ee
RD
279 wxPrintDialogData(const wxPrintData& printData);
280 wxPrintDialogData(const wxPrintDialogData& printData); // for making copies
bb0054cd
RD
281 ~wxPrintDialogData();
282
1fded56b
RD
283 int GetFromPage() const;
284 int GetToPage() const;
285 int GetMinPage() const;
286 int GetMaxPage() const;
287 int GetNoCopies() const;
288 bool GetAllPages() const;
289 bool GetSelection() const;
290 bool GetCollate() const;
291 bool GetPrintToFile() const;
7aada1e0
RD
292
293 // WXWIN_COMPATIBILITY_2_4
2f91e3df 294#if 0
1fded56b 295 bool GetSetupDialog() const;
7aada1e0 296 void SetSetupDialog(bool flag);
2f91e3df 297#endif
1fded56b
RD
298 void SetFromPage(int v);
299 void SetToPage(int v);
300 void SetMinPage(int v);
301 void SetMaxPage(int v);
302 void SetNoCopies(int v);
303 void SetAllPages(bool flag);
304 void SetSelection(bool flag);
305 void SetCollate(bool flag);
306 void SetPrintToFile(bool flag);
1fded56b 307
bb0054cd
RD
308 void EnablePrintToFile(bool flag);
309 void EnableSelection(bool flag);
1fded56b
RD
310 void EnablePageNumbers(bool flag);
311 void EnableHelp(bool flag);
312
313 bool GetEnablePrintToFile() const;
314 bool GetEnableSelection() const;
315 bool GetEnablePageNumbers() const;
316 bool GetEnableHelp() const;
317
318 // Is this data OK for showing the print dialog?
6c2dd16f
RD
319 bool IsOk() const;
320 %pythoncode { Ok = IsOk }
1fded56b 321
d14a1e28
RD
322
323 wxPrintData& GetPrintData();
bb0054cd 324 void SetPrintData(const wxPrintData& printData);
1fded56b 325
6c2dd16f 326 %pythoncode { def __nonzero__(self): return self.IsOk() }
7012bb9f
RD
327
328 %property(AllPages, GetAllPages, SetAllPages, doc="See `GetAllPages` and `SetAllPages`");
329 %property(Collate, GetCollate, SetCollate, doc="See `GetCollate` and `SetCollate`");
330// %property(EnableHelp, GetEnableHelp, doc="See `GetEnableHelp`");
331// %property(EnablePageNumbers, GetEnablePageNumbers, doc="See `GetEnablePageNumbers`");
332// %property(EnablePrintToFile, GetEnablePrintToFile, doc="See `GetEnablePrintToFile`");
333// %property(EnableSelection, GetEnableSelection, doc="See `GetEnableSelection`");
334 %property(FromPage, GetFromPage, SetFromPage, doc="See `GetFromPage` and `SetFromPage`");
335 %property(MaxPage, GetMaxPage, SetMaxPage, doc="See `GetMaxPage` and `SetMaxPage`");
336 %property(MinPage, GetMinPage, SetMinPage, doc="See `GetMinPage` and `SetMinPage`");
337 %property(NoCopies, GetNoCopies, SetNoCopies, doc="See `GetNoCopies` and `SetNoCopies`");
338 %property(PrintData, GetPrintData, SetPrintData, doc="See `GetPrintData` and `SetPrintData`");
339 %property(PrintToFile, GetPrintToFile, SetPrintToFile, doc="See `GetPrintToFile` and `SetPrintToFile`");
340 %property(Selection, GetSelection, SetSelection, doc="See `GetSelection` and `SetSelection`");
341 %property(ToPage, GetToPage, SetToPage, doc="See `GetToPage` and `SetToPage`");
bb0054cd
RD
342};
343
344
6b9f434e 345
ab1f7d2a
RD
346MustHaveApp(wxPrintDialog);
347
d14a1e28 348
6b9f434e
RD
349// NOTE: Contrary to it's name, this class doesn't derive from wxDialog. It
350// is a facade in front of a platform-specific (native dialog) provided by the
351// wxPrintFactory.
352
353class wxPrintDialog : public wxObject {
354public:
bb0054cd
RD
355 wxPrintDialog(wxWindow* parent, wxPrintDialogData* data = NULL);
356
7aada1e0 357 // TODO?: wxPrintDialog(wxWindow *parent, wxPrintData* data);
7847dc50
RD
358
359 ~wxPrintDialog();
7aada1e0
RD
360
361 virtual int ShowModal();
362
363 virtual wxPrintDialogData& GetPrintDialogData();
364 virtual wxPrintData& GetPrintData();
d14a1e28
RD
365
366 %newobject GetPrintDC;
7aada1e0
RD
367 virtual wxDC *GetPrintDC();
368
7847dc50 369 %pythoncode { def Destroy(self): pass }
7012bb9f
RD
370
371 %property(PrintDC, GetPrintDC, doc="See `GetPrintDC`");
372 %property(PrintData, GetPrintData, doc="See `GetPrintData`");
373 %property(PrintDialogData, GetPrintDialogData, doc="See `GetPrintDialogData`");
bb0054cd
RD
374};
375
d14a1e28
RD
376
377//---------------------------------------------------------------------------
378//---------------------------------------------------------------------------
379
380
381enum wxPrinterError
382{
383 wxPRINTER_NO_ERROR = 0,
384 wxPRINTER_CANCELLED,
385 wxPRINTER_ERROR
386};
387
388
ab1f7d2a
RD
389MustHaveApp(wxPrinter);
390
d14a1e28
RD
391class wxPrinter : public wxObject {
392public:
393 wxPrinter(wxPrintDialogData* data = NULL);
394 ~wxPrinter();
395
6b9f434e
RD
396 virtual wxWindow *CreateAbortWindow(wxWindow *parent, wxPyPrintout *printout);
397 virtual void ReportError(wxWindow *parent, wxPyPrintout *printout, const wxString& message);
7aada1e0
RD
398
399 virtual bool Setup(wxWindow *parent);
6b9f434e 400 virtual bool Print(wxWindow *parent, wxPyPrintout *printout, bool prompt = true);
7aada1e0
RD
401 virtual wxDC* PrintDialog(wxWindow *parent);
402
403 virtual wxPrintDialogData& GetPrintDialogData() const;
d14a1e28 404
7aada1e0 405 bool GetAbort();
d14a1e28 406 static wxPrinterError GetLastError();
c5633576 407
7012bb9f
RD
408 %property(Abort, GetAbort, doc="See `GetAbort`");
409 %property(PrintDialogData, GetPrintDialogData, doc="See `GetPrintDialogData`");
d14a1e28
RD
410};
411
412
413//---------------------------------------------------------------------------
6b9f434e
RD
414// Custom wxPrintout class that knows how to call python, See implementation in
415// include/sx/wxPython/printfw.h
416
bb0054cd 417%{
2abc0a0f 418
6b9f434e 419IMPLEMENT_ABSTRACT_CLASS(wxPyPrintout, wxPrintout);
2abc0a0f
RD
420
421// Since this one would be tough and ugly to do with the Macros...
422void wxPyPrintout::GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) {
a72f4631 423 bool hadErr = false;
19a97bd6 424 bool found;
2abc0a0f 425
6e6b3557 426 wxPyBlock_t blocked = wxPyBeginBlockThreads();
d14a1e28
RD
427 if ((found = wxPyCBH_findCallback(m_myInst, "GetPageInfo"))) {
428 PyObject* result = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));
2abc0a0f
RD
429 if (result && PyTuple_Check(result) && PyTuple_Size(result) == 4) {
430 PyObject* val;
431
432 val = PyTuple_GetItem(result, 0);
433 if (PyInt_Check(val)) *minPage = PyInt_AsLong(val);
a72f4631 434 else hadErr = true;
2abc0a0f
RD
435
436 val = PyTuple_GetItem(result, 1);
437 if (PyInt_Check(val)) *maxPage = PyInt_AsLong(val);
a72f4631 438 else hadErr = true;
2abc0a0f
RD
439
440 val = PyTuple_GetItem(result, 2);
441 if (PyInt_Check(val)) *pageFrom = PyInt_AsLong(val);
a72f4631 442 else hadErr = true;
2abc0a0f
RD
443
444 val = PyTuple_GetItem(result, 3);
445 if (PyInt_Check(val)) *pageTo = PyInt_AsLong(val);
a72f4631 446 else hadErr = true;
bb0054cd
RD
447 }
448 else
a72f4631 449 hadErr = true;
1afc06c2 450
2abc0a0f
RD
451 if (hadErr) {
452 PyErr_SetString(PyExc_TypeError, "GetPageInfo should return a tuple of 4 integers.");
453 PyErr_Print();
454 }
455 Py_DECREF(result);
bb0054cd 456 }
da32eb53 457 wxPyEndBlockThreads(blocked);
19a97bd6 458 if (! found)
bb0054cd 459 wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo);
2abc0a0f
RD
460}
461
2abc0a0f 462
1afc06c2
RD
463
464IMP_PYCALLBACK_BOOL_INTINT(wxPyPrintout, wxPrintout, OnBeginDocument);
465IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnEndDocument);
466IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnBeginPrinting);
467IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnEndPrinting);
468IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnPreparePrinting);
469IMP_PYCALLBACK_BOOL_INT_pure(wxPyPrintout, wxPrintout, OnPrintPage);
470IMP_PYCALLBACK_BOOL_INT(wxPyPrintout, wxPrintout, HasPage);
471
472
bb0054cd
RD
473%}
474
475
ab1f7d2a
RD
476MustHaveApp(wxPyPrintout);
477
bb0054cd 478// Now define the custom class for SWIGging
1b8c7ba6
RD
479%rename(Printout) wxPyPrintout;
480class wxPyPrintout : public wxObject {
bb0054cd 481public:
2b9048c5 482 %pythonAppend wxPyPrintout "self._setCallbackInfo(self, Printout)"
c5633576 483 %typemap(out) wxPyPrintout*; // turn off this typemap
bb0054cd 484
d14a1e28 485 wxPyPrintout(const wxString& title = wxPyPrintoutTitleStr);
c5633576 486 ~wxPyPrintout();
d14a1e28 487
c5633576
RD
488 // Turn it back on again
489 %typemap(out) wxPyPrintout* { $result = wxPyMake_wxObject($1, $owner); }
490
0122b7e3 491 void _setCallbackInfo(PyObject* self, PyObject* _class);
bb0054cd 492
d14a1e28
RD
493
494 wxString GetTitle() const;
bb0054cd 495 wxDC* GetDC();
d14a1e28
RD
496 void SetDC(wxDC *dc);
497
55811cde
RD
498
499 void FitThisSizeToPaper(const wxSize& imageSize);
500 void FitThisSizeToPage(const wxSize& imageSize);
501 void FitThisSizeToPageMargins(const wxSize& imageSize, const wxPageSetupDialogData& pageSetupData);
502 void MapScreenSizeToPaper();
503 void MapScreenSizeToPage();
504 void MapScreenSizeToPageMargins(const wxPageSetupDialogData& pageSetupData);
505 void MapScreenSizeToDevice();
506
507 wxRect GetLogicalPaperRect() const;
508 wxRect GetLogicalPageRect() const;
509 wxRect GetLogicalPageMarginsRect(const wxPageSetupDialogData& pageSetupData) const;
510
511 void SetLogicalOrigin(wxCoord x, wxCoord y);
512 void OffsetLogicalOrigin(wxCoord xoff, wxCoord yoff);
513
514
d14a1e28 515 void SetPageSizePixels(int w, int h);
322913ce
RD
516 DocDeclA(
517 void, GetPageSizePixels(int *OUTPUT, int *OUTPUT),
518 "GetPageSizePixels() -> (w, h)");
d14a1e28
RD
519
520 void SetPageSizeMM(int w, int h);
322913ce
RD
521 DocDeclA(
522 void, GetPageSizeMM(int *OUTPUT, int *OUTPUT),
523 "GetPageSizeMM() -> (w, h)");
d14a1e28
RD
524
525 void SetPPIScreen(int x, int y);
322913ce
RD
526 DocDeclA(
527 void, GetPPIScreen(int *OUTPUT, int *OUTPUT),
528 "GetPPIScreen() -> (x,y)");
d14a1e28
RD
529
530 void SetPPIPrinter(int x, int y);
322913ce
RD
531 DocDeclA(
532 void, GetPPIPrinter(int *OUTPUT, int *OUTPUT),
533 "GetPPIPrinter() -> (x,y)");
d14a1e28 534
55811cde
RD
535 void SetPaperRectPixels(const wxRect& paperRectPixels);
536 wxRect GetPaperRectPixels() const;
537
bb0054cd 538 bool IsPreview();
d14a1e28 539 void SetIsPreview(bool p);
bb0054cd 540
d14a1e28 541
a7a01418
RD
542 bool OnBeginDocument(int startPage, int endPage);
543 void OnEndDocument();
544 void OnBeginPrinting();
545 void OnEndPrinting();
546 void OnPreparePrinting();
547 bool HasPage(int page);
322913ce 548 DocDeclA(
a7a01418
RD
549 void, GetPageInfo(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT),
550 "GetPageInfo() -> (minPage, maxPage, pageFrom, pageTo)");
551
552 %MAKE_BASE_FUNC(Printout, OnBeginDocument);
553 %MAKE_BASE_FUNC(Printout, OnEndDocument);
554 %MAKE_BASE_FUNC(Printout, OnBeginPrinting);
555 %MAKE_BASE_FUNC(Printout, OnEndPrinting);
556 %MAKE_BASE_FUNC(Printout, OnPreparePrinting);
557 %MAKE_BASE_FUNC(Printout, GetPageInfo);
7012bb9f
RD
558
559
560 %property(DC, GetDC, SetDC, doc="See `GetDC` and `SetDC`");
561 %property(PPIPrinter, GetPPIPrinter, SetPPIPrinter, doc="See `GetPPIPrinter` and `SetPPIPrinter`");
562 %property(PPIScreen, GetPPIScreen, SetPPIScreen, doc="See `GetPPIScreen` and `SetPPIScreen`");
563 %property(PageSizeMM, GetPageSizeMM, SetPageSizeMM, doc="See `GetPageSizeMM` and `SetPageSizeMM`");
564 %property(PageSizePixels, GetPageSizePixels, SetPageSizePixels, doc="See `GetPageSizePixels` and `SetPageSizePixels`");
565 %property(Title, GetTitle, doc="See `GetTitle`");
bb0054cd
RD
566};
567
d14a1e28 568//---------------------------------------------------------------------------
1fded56b 569
1fded56b 570
1fded56b 571
ab1f7d2a
RD
572MustHaveApp(wxPreviewCanvas);
573
d14a1e28 574class wxPreviewCanvas: public wxScrolledWindow
1fded56b
RD
575{
576public:
2b9048c5 577 %pythonAppend wxPreviewCanvas "self._setOORInfo(self)"
bb0054cd 578
d14a1e28
RD
579 wxPreviewCanvas(wxPrintPreview *preview,
580 wxWindow *parent,
581 const wxPoint& pos = wxDefaultPosition,
582 const wxSize& size = wxDefaultSize,
583 long style = 0,
584 const wxString& name = wxPyPreviewCanvasNameStr);
bb0054cd
RD
585};
586
bb0054cd 587
ab1f7d2a
RD
588MustHaveApp(wxPreviewFrame);
589
bb0054cd
RD
590class wxPreviewFrame : public wxFrame {
591public:
c5633576
RD
592 %disownarg(wxPrintPreview*);
593
2b9048c5 594 %pythonAppend wxPreviewFrame "self._setOORInfo(self)"
bb0054cd 595 wxPreviewFrame(wxPrintPreview* preview, wxFrame* parent, const wxString& title,
b68dc582
RD
596 const wxPoint& pos = wxDefaultPosition,
597 const wxSize& size = wxDefaultSize,
bb0054cd 598 long style = wxDEFAULT_FRAME_STYLE,
137b5242 599 const wxString& name = wxPyFrameNameStr);
bb0054cd 600
c5633576
RD
601 %cleardisown(wxPrintPreview*);
602
bb0054cd 603 void Initialize();
1fded56b
RD
604 void CreateControlBar();
605 void CreateCanvas();
3ef86e32
RD
606
607 wxPreviewControlBar* GetControlBar() const;
7012bb9f
RD
608
609 %property(ControlBar, GetControlBar, doc="See `GetControlBar`");
1fded56b
RD
610};
611
612
1fded56b
RD
613
614enum {
615 wxPREVIEW_PRINT,
616 wxPREVIEW_PREVIOUS,
617 wxPREVIEW_NEXT,
618 wxPREVIEW_ZOOM,
619 wxPREVIEW_FIRST,
620 wxPREVIEW_LAST,
621 wxPREVIEW_GOTO,
622 wxPREVIEW_DEFAULT,
623
624 wxID_PREVIEW_CLOSE,
625 wxID_PREVIEW_NEXT,
626 wxID_PREVIEW_PREVIOUS,
627 wxID_PREVIEW_PRINT,
628 wxID_PREVIEW_ZOOM,
629 wxID_PREVIEW_FIRST,
630 wxID_PREVIEW_LAST,
631 wxID_PREVIEW_GOTO
632};
633
ab1f7d2a
RD
634MustHaveApp(wxPreviewControlBar);
635
1fded56b
RD
636class wxPreviewControlBar: public wxPanel
637{
638public:
2b9048c5 639 %pythonAppend wxPreviewControlBar "self._setOORInfo(self)"
d14a1e28 640
1fded56b
RD
641 wxPreviewControlBar(wxPrintPreview *preview,
642 long buttons,
643 wxWindow *parent,
644 const wxPoint& pos = wxDefaultPosition,
645 const wxSize& size = wxDefaultSize,
3ef86e32 646 long style = wxTAB_TRAVERSAL,
1fded56b 647 const wxString& name = wxPyPanelNameStr);
1fded56b
RD
648
649 int GetZoomControl();
650 void SetZoomControl(int zoom);
651 wxPrintPreview* GetPrintPreview();
652
653 void OnNext();
654 void OnPrevious();
655 void OnFirst();
656 void OnLast();
657 void OnGoto();
7012bb9f
RD
658
659 %property(PrintPreview, GetPrintPreview, doc="See `GetPrintPreview`");
660 %property(ZoomControl, GetZoomControl, SetZoomControl, doc="See `GetZoomControl` and `SetZoomControl`");
1fded56b
RD
661};
662
663
d14a1e28
RD
664
665//---------------------------------------------------------------------------
666
ab1f7d2a
RD
667MustHaveApp(wxPrintPreview);
668
d14a1e28
RD
669class wxPrintPreview : public wxObject {
670public:
c5633576
RD
671 %disownarg(wxPyPrintout*);
672
d88d4683 673 %nokwargs wxPrintPreview;
d14a1e28
RD
674 wxPrintPreview(wxPyPrintout* printout,
675 wxPyPrintout* printoutForPrinting,
d88d4683
RD
676 wxPrintDialogData *data=NULL);
677 wxPrintPreview(wxPyPrintout* printout,
678 wxPyPrintout* printoutForPrinting,
679 wxPrintData* data);
d14a1e28 680
c5633576
RD
681 ~wxPrintPreview();
682
d14a1e28
RD
683 virtual bool SetCurrentPage(int pageNum);
684 int GetCurrentPage();
685
686 void SetPrintout(wxPyPrintout *printout);
687 wxPyPrintout *GetPrintout();
688 wxPyPrintout *GetPrintoutForPrinting();
689
c5633576
RD
690 %cleardisown(wxPyPrintout*);
691
d14a1e28
RD
692 void SetFrame(wxFrame *frame);
693 void SetCanvas(wxPreviewCanvas *canvas);
694
695 virtual wxFrame *GetFrame();
696 virtual wxPreviewCanvas *GetCanvas();
697
698 // The preview canvas should call this from OnPaint
699 virtual bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc);
700
701 // This draws a blank page onto the preview canvas
702 virtual bool DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc);
703
704 // This is called by wxPrintPreview to render a page into a wxMemoryDC.
705 virtual bool RenderPage(int pageNum);
706
707 // Adjusts the scrollbars for the current scale
708 virtual void AdjustScrollbars(wxPreviewCanvas *canvas);
709
710 wxPrintDialogData& GetPrintDialogData();
711
712 virtual void SetZoom(int percent);
713 int GetZoom();
714
715 int GetMaxPage();
716 int GetMinPage();
717
6c2dd16f
RD
718 bool IsOk();
719 %pythoncode { Ok = IsOk }
d14a1e28
RD
720 void SetOk(bool ok);
721
722 virtual bool Print(bool interactive);
723 virtual void DetermineScaling();
724
6c2dd16f 725 %pythoncode { def __nonzero__(self): return self.IsOk() }
7012bb9f
RD
726
727 %property(Canvas, GetCanvas, SetCanvas, doc="See `GetCanvas` and `SetCanvas`");
728 %property(CurrentPage, GetCurrentPage, SetCurrentPage, doc="See `GetCurrentPage` and `SetCurrentPage`");
729 %property(Frame, GetFrame, SetFrame, doc="See `GetFrame` and `SetFrame`");
730 %property(MaxPage, GetMaxPage, doc="See `GetMaxPage`");
731 %property(MinPage, GetMinPage, doc="See `GetMinPage`");
732 %property(PrintDialogData, GetPrintDialogData, doc="See `GetPrintDialogData`");
733 %property(Printout, GetPrintout, SetPrintout, doc="See `GetPrintout` and `SetPrintout`");
734 %property(PrintoutForPrinting, GetPrintoutForPrinting, doc="See `GetPrintoutForPrinting`");
735 %property(Zoom, GetZoom, SetZoom, doc="See `GetZoom` and `SetZoom`");
d14a1e28
RD
736};
737
738
739
740//---------------------------------------------------------------------------
741
1fded56b
RD
742// Python-derivable versions of the above preview classes
743
744%{
3ef86e32 745
a72f4631 746#define DEC_PYCALLBACK_BOOL_PREWINDC(CBNAME) \
a7a01418 747 bool CBNAME(wxPreviewCanvas* a, wxDC& b)
3ef86e32
RD
748
749
a72f4631
RD
750#define IMP_PYCALLBACK_BOOL_PREWINDC(CLASS, PCLASS, CBNAME) \
751 bool CLASS::CBNAME(wxPreviewCanvas* a, wxDC& b) { \
752 bool rval=false; \
753 bool found; \
893d597c 754 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
a72f4631
RD
755 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
756 PyObject* win = wxPyMake_wxObject(a,false); \
757 PyObject* dc = wxPyMake_wxObject(&b,false); \
758 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc)); \
759 Py_DECREF(win); \
760 Py_DECREF(dc); \
761 } \
762 wxPyEndBlockThreads(blocked); \
763 if (! found) \
764 rval = PCLASS::CBNAME(a, b); \
765 return rval; \
a7a01418 766 }
3ef86e32
RD
767
768
769
770
1fded56b
RD
771class wxPyPrintPreview : public wxPrintPreview
772{
773 DECLARE_CLASS(wxPyPrintPreview)
774public:
d88d4683
RD
775 wxPyPrintPreview(wxPyPrintout* printout,
776 wxPyPrintout* printoutForPrinting,
777 wxPrintDialogData* data=NULL)
778 : wxPrintPreview(printout, printoutForPrinting, data)
779 {}
1fded56b
RD
780 wxPyPrintPreview(wxPyPrintout* printout,
781 wxPyPrintout* printoutForPrinting,
893d597c 782 wxPrintData* data)
1fded56b
RD
783 : wxPrintPreview(printout, printoutForPrinting, data)
784 {}
785
786 DEC_PYCALLBACK_BOOL_INT(SetCurrentPage);
3ef86e32
RD
787 DEC_PYCALLBACK_BOOL_PREWINDC(PaintPage);
788 DEC_PYCALLBACK_BOOL_PREWINDC(DrawBlankPage);
1fded56b
RD
789 DEC_PYCALLBACK_BOOL_INT(RenderPage);
790 DEC_PYCALLBACK_VOID_INT(SetZoom);
791 DEC_PYCALLBACK_BOOL_BOOL(Print);
792 DEC_PYCALLBACK_VOID_(DetermineScaling);
793
794 PYPRIVATE;
795};
796
797// Stupid renamed classes... Fix this in 2.5...
798#if defined(__WXMSW__)
799IMPLEMENT_CLASS( wxPyPrintPreview, wxWindowsPrintPreview );
800#elif defined(__WXMAC__)
801IMPLEMENT_CLASS( wxPyPrintPreview, wxMacPrintPreview );
802#else
803IMPLEMENT_CLASS( wxPyPrintPreview, wxPostScriptPrintPreview );
804#endif
805
3ef86e32
RD
806IMP_PYCALLBACK_BOOL_INT (wxPyPrintPreview, wxPrintPreview, SetCurrentPage);
807IMP_PYCALLBACK_BOOL_PREWINDC(wxPyPrintPreview, wxPrintPreview, PaintPage);
808IMP_PYCALLBACK_BOOL_PREWINDC(wxPyPrintPreview, wxPrintPreview, DrawBlankPage);
809IMP_PYCALLBACK_BOOL_INT (wxPyPrintPreview, wxPrintPreview, RenderPage);
810IMP_PYCALLBACK_VOID_INT (wxPyPrintPreview, wxPrintPreview, SetZoom);
811IMP_PYCALLBACK_BOOL_BOOL (wxPyPrintPreview, wxPrintPreview, Print);
812IMP_PYCALLBACK_VOID_ (wxPyPrintPreview, wxPrintPreview, DetermineScaling);
1fded56b
RD
813%}
814
815
ab1f7d2a
RD
816MustHaveApp(wxPyPrintPreview);
817
1fded56b
RD
818class wxPyPrintPreview : public wxPrintPreview
819{
820public:
c5633576
RD
821 %disownarg(wxPyPrintout*);
822
2b9048c5 823 %pythonAppend wxPyPrintPreview "self._setCallbackInfo(self, PyPrintPreview)"
d88d4683
RD
824 %nokwargs wxPyPrintPreview;
825 wxPyPrintPreview(wxPyPrintout* printout,
826 wxPyPrintout* printoutForPrinting,
827 wxPrintDialogData* data=NULL);
1fded56b
RD
828 wxPyPrintPreview(wxPyPrintout* printout,
829 wxPyPrintout* printoutForPrinting,
d88d4683 830 wxPrintData* data);
1fded56b 831
c5633576
RD
832 %cleardisown(wxPyPrintout*);
833
1fded56b 834 void _setCallbackInfo(PyObject* self, PyObject* _class);
d14a1e28 835
a7a01418
RD
836 bool SetCurrentPage(int pageNum);
837 bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc);
838 bool DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc);
839 bool RenderPage(int pageNum);
840 void SetZoom(int percent);
841 bool Print(bool interactive);
842 void DetermineScaling();
843
844 %MAKE_BASE_FUNC(PyPrintPreview, SetCurrentPage);
845 %MAKE_BASE_FUNC(PyPrintPreview, PaintPage);
846 %MAKE_BASE_FUNC(PyPrintPreview, DrawBlankPage);
847 %MAKE_BASE_FUNC(PyPrintPreview, RenderPage);
848 %MAKE_BASE_FUNC(PyPrintPreview, SetZoom);
849 %MAKE_BASE_FUNC(PyPrintPreview, Print);
850 %MAKE_BASE_FUNC(PyPrintPreview, DetermineScaling);
1fded56b
RD
851};
852
853
bb0054cd 854
bb0054cd 855
1fded56b
RD
856%{
857class wxPyPreviewFrame : public wxPreviewFrame
858{
4617be08 859 DECLARE_CLASS(wxPyPreviewFrame)
1fded56b
RD
860public:
861 wxPyPreviewFrame(wxPrintPreview* preview, wxFrame* parent,
862 const wxString& title,
863 const wxPoint& pos = wxDefaultPosition,
864 const wxSize& size = wxDefaultSize,
865 long style = wxDEFAULT_FRAME_STYLE,
866 const wxString& name = wxPyFrameNameStr)
867 : wxPreviewFrame(preview, parent, title, pos, size, style, name)
868 {}
869
3ef86e32 870 void SetPreviewCanvas(wxPreviewCanvas* canvas) { m_previewCanvas = canvas; }
1fded56b
RD
871 void SetControlBar(wxPreviewControlBar* bar) { m_controlBar = bar; }
872
873 DEC_PYCALLBACK_VOID_(Initialize);
874 DEC_PYCALLBACK_VOID_(CreateCanvas);
875 DEC_PYCALLBACK_VOID_(CreateControlBar);
876
877 PYPRIVATE;
878};
879
880IMPLEMENT_CLASS(wxPyPreviewFrame, wxPreviewFrame);
881
882IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, Initialize);
883IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, CreateCanvas);
884IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, CreateControlBar);
885%}
886
d14a1e28 887
ab1f7d2a
RD
888MustHaveApp(wxPyPreviewFrame);
889
1fded56b
RD
890class wxPyPreviewFrame : public wxPreviewFrame
891{
892public:
2b9048c5 893 %pythonAppend wxPyPreviewFrame "self._setCallbackInfo(self, PyPreviewFrame); self._setOORInfo(self)"
d14a1e28 894
1fded56b
RD
895 wxPyPreviewFrame(wxPrintPreview* preview, wxFrame* parent,
896 const wxString& title,
897 const wxPoint& pos = wxDefaultPosition,
898 const wxSize& size = wxDefaultSize,
899 long style = wxDEFAULT_FRAME_STYLE,
900 const wxString& name = wxPyFrameNameStr);
901
902 void _setCallbackInfo(PyObject* self, PyObject* _class);
1fded56b 903
3ef86e32 904 void SetPreviewCanvas(wxPreviewCanvas* canvas);
1fded56b
RD
905 void SetControlBar(wxPreviewControlBar* bar);
906
a7a01418
RD
907 void Initialize();
908 void CreateCanvas();
909 void CreateControlBar();
910
911 %MAKE_BASE_FUNC(PyPreviewFrame, Initialize);
912 %MAKE_BASE_FUNC(PyPreviewFrame, CreateCanvas);
913 %MAKE_BASE_FUNC(PyPreviewFrame, CreateControlBar);
bb0054cd
RD
914};
915
1fded56b
RD
916
917
918
919%{
920class wxPyPreviewControlBar : public wxPreviewControlBar
921{
4617be08 922 DECLARE_CLASS(wxPyPreviewControlBar)
1fded56b
RD
923public:
924 wxPyPreviewControlBar(wxPrintPreview *preview,
925 long buttons,
926 wxWindow *parent,
927 const wxPoint& pos = wxDefaultPosition,
928 const wxSize& size = wxDefaultSize,
929 long style = 0,
930 const wxString& name = wxPyPanelNameStr)
931 : wxPreviewControlBar(preview, buttons, parent, pos, size, style, name)
932 {}
933
934 void SetPrintPreview(wxPrintPreview* preview) { m_printPreview = preview; }
935
936 DEC_PYCALLBACK_VOID_(CreateButtons);
937 DEC_PYCALLBACK_VOID_INT(SetZoomControl);
938
939 PYPRIVATE;
940};
941
942IMPLEMENT_CLASS(wxPyPreviewControlBar, wxPreviewControlBar);
943IMP_PYCALLBACK_VOID_(wxPyPreviewControlBar, wxPreviewControlBar, CreateButtons);
944IMP_PYCALLBACK_VOID_INT(wxPyPreviewControlBar, wxPreviewControlBar, SetZoomControl);
945%}
946
d14a1e28 947
ab1f7d2a
RD
948MustHaveApp(wxPyPreviewControlBar);
949
1fded56b
RD
950class wxPyPreviewControlBar : public wxPreviewControlBar
951{
952public:
2b9048c5 953 %pythonAppend wxPyPreviewControlBar "self._setCallbackInfo(self, PyPreviewControlBar); self._setOORInfo(self)"
d14a1e28 954
1fded56b
RD
955 wxPyPreviewControlBar(wxPrintPreview *preview,
956 long buttons,
957 wxWindow *parent,
958 const wxPoint& pos = wxDefaultPosition,
959 const wxSize& size = wxDefaultSize,
960 long style = 0,
961 const wxString& name = wxPyPanelNameStr);
962
963 void _setCallbackInfo(PyObject* self, PyObject* _class);
1fded56b
RD
964
965 void SetPrintPreview(wxPrintPreview* preview);
966
a7a01418
RD
967 void CreateButtons();
968 void SetZoomControl(int zoom);
969
970 %MAKE_BASE_FUNC(PreviewControlBar, CreateButtons);
971 %MAKE_BASE_FUNC(PreviewControlBar, SetZoomControl);
1fded56b
RD
972};
973
d14a1e28
RD
974//---------------------------------------------------------------------------
975//---------------------------------------------------------------------------
9416aa89
RD
976%init %{
977 wxPyPtrTypeMap_Add("wxPrintout", "wxPyPrintout");
978%}
d14a1e28 979//---------------------------------------------------------------------------