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