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