]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_printfw.i
Size property conflicts with Size() method
[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
d14a1e28 498 void SetPageSizePixels(int w, int h);
322913ce
RD
499 DocDeclA(
500 void, GetPageSizePixels(int *OUTPUT, int *OUTPUT),
501 "GetPageSizePixels() -> (w, h)");
d14a1e28
RD
502
503 void SetPageSizeMM(int w, int h);
322913ce
RD
504 DocDeclA(
505 void, GetPageSizeMM(int *OUTPUT, int *OUTPUT),
506 "GetPageSizeMM() -> (w, h)");
d14a1e28
RD
507
508 void SetPPIScreen(int x, int y);
322913ce
RD
509 DocDeclA(
510 void, GetPPIScreen(int *OUTPUT, int *OUTPUT),
511 "GetPPIScreen() -> (x,y)");
d14a1e28
RD
512
513 void SetPPIPrinter(int x, int y);
322913ce
RD
514 DocDeclA(
515 void, GetPPIPrinter(int *OUTPUT, int *OUTPUT),
516 "GetPPIPrinter() -> (x,y)");
d14a1e28 517
bb0054cd 518 bool IsPreview();
d14a1e28 519 void SetIsPreview(bool p);
bb0054cd 520
d14a1e28 521
a7a01418
RD
522 bool OnBeginDocument(int startPage, int endPage);
523 void OnEndDocument();
524 void OnBeginPrinting();
525 void OnEndPrinting();
526 void OnPreparePrinting();
527 bool HasPage(int page);
322913ce 528 DocDeclA(
a7a01418
RD
529 void, GetPageInfo(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT),
530 "GetPageInfo() -> (minPage, maxPage, pageFrom, pageTo)");
531
532 %MAKE_BASE_FUNC(Printout, OnBeginDocument);
533 %MAKE_BASE_FUNC(Printout, OnEndDocument);
534 %MAKE_BASE_FUNC(Printout, OnBeginPrinting);
535 %MAKE_BASE_FUNC(Printout, OnEndPrinting);
536 %MAKE_BASE_FUNC(Printout, OnPreparePrinting);
537 %MAKE_BASE_FUNC(Printout, GetPageInfo);
7012bb9f
RD
538
539
540 %property(DC, GetDC, SetDC, doc="See `GetDC` and `SetDC`");
541 %property(PPIPrinter, GetPPIPrinter, SetPPIPrinter, doc="See `GetPPIPrinter` and `SetPPIPrinter`");
542 %property(PPIScreen, GetPPIScreen, SetPPIScreen, doc="See `GetPPIScreen` and `SetPPIScreen`");
543 %property(PageSizeMM, GetPageSizeMM, SetPageSizeMM, doc="See `GetPageSizeMM` and `SetPageSizeMM`");
544 %property(PageSizePixels, GetPageSizePixels, SetPageSizePixels, doc="See `GetPageSizePixels` and `SetPageSizePixels`");
545 %property(Title, GetTitle, doc="See `GetTitle`");
bb0054cd
RD
546};
547
d14a1e28 548//---------------------------------------------------------------------------
1fded56b 549
1fded56b 550
1fded56b 551
ab1f7d2a
RD
552MustHaveApp(wxPreviewCanvas);
553
d14a1e28 554class wxPreviewCanvas: public wxScrolledWindow
1fded56b
RD
555{
556public:
2b9048c5 557 %pythonAppend wxPreviewCanvas "self._setOORInfo(self)"
bb0054cd 558
d14a1e28
RD
559 wxPreviewCanvas(wxPrintPreview *preview,
560 wxWindow *parent,
561 const wxPoint& pos = wxDefaultPosition,
562 const wxSize& size = wxDefaultSize,
563 long style = 0,
564 const wxString& name = wxPyPreviewCanvasNameStr);
bb0054cd
RD
565};
566
bb0054cd 567
ab1f7d2a
RD
568MustHaveApp(wxPreviewFrame);
569
bb0054cd
RD
570class wxPreviewFrame : public wxFrame {
571public:
c5633576
RD
572 %disownarg(wxPrintPreview*);
573
2b9048c5 574 %pythonAppend wxPreviewFrame "self._setOORInfo(self)"
bb0054cd 575 wxPreviewFrame(wxPrintPreview* preview, wxFrame* parent, const wxString& title,
b68dc582
RD
576 const wxPoint& pos = wxDefaultPosition,
577 const wxSize& size = wxDefaultSize,
bb0054cd 578 long style = wxDEFAULT_FRAME_STYLE,
137b5242 579 const wxString& name = wxPyFrameNameStr);
bb0054cd 580
c5633576
RD
581 %cleardisown(wxPrintPreview*);
582
bb0054cd 583 void Initialize();
1fded56b
RD
584 void CreateControlBar();
585 void CreateCanvas();
3ef86e32
RD
586
587 wxPreviewControlBar* GetControlBar() const;
7012bb9f
RD
588
589 %property(ControlBar, GetControlBar, doc="See `GetControlBar`");
1fded56b
RD
590};
591
592
1fded56b
RD
593
594enum {
595 wxPREVIEW_PRINT,
596 wxPREVIEW_PREVIOUS,
597 wxPREVIEW_NEXT,
598 wxPREVIEW_ZOOM,
599 wxPREVIEW_FIRST,
600 wxPREVIEW_LAST,
601 wxPREVIEW_GOTO,
602 wxPREVIEW_DEFAULT,
603
604 wxID_PREVIEW_CLOSE,
605 wxID_PREVIEW_NEXT,
606 wxID_PREVIEW_PREVIOUS,
607 wxID_PREVIEW_PRINT,
608 wxID_PREVIEW_ZOOM,
609 wxID_PREVIEW_FIRST,
610 wxID_PREVIEW_LAST,
611 wxID_PREVIEW_GOTO
612};
613
ab1f7d2a
RD
614MustHaveApp(wxPreviewControlBar);
615
1fded56b
RD
616class wxPreviewControlBar: public wxPanel
617{
618public:
2b9048c5 619 %pythonAppend wxPreviewControlBar "self._setOORInfo(self)"
d14a1e28 620
1fded56b
RD
621 wxPreviewControlBar(wxPrintPreview *preview,
622 long buttons,
623 wxWindow *parent,
624 const wxPoint& pos = wxDefaultPosition,
625 const wxSize& size = wxDefaultSize,
3ef86e32 626 long style = wxTAB_TRAVERSAL,
1fded56b 627 const wxString& name = wxPyPanelNameStr);
1fded56b
RD
628
629 int GetZoomControl();
630 void SetZoomControl(int zoom);
631 wxPrintPreview* GetPrintPreview();
632
633 void OnNext();
634 void OnPrevious();
635 void OnFirst();
636 void OnLast();
637 void OnGoto();
7012bb9f
RD
638
639 %property(PrintPreview, GetPrintPreview, doc="See `GetPrintPreview`");
640 %property(ZoomControl, GetZoomControl, SetZoomControl, doc="See `GetZoomControl` and `SetZoomControl`");
1fded56b
RD
641};
642
643
d14a1e28
RD
644
645//---------------------------------------------------------------------------
646
ab1f7d2a
RD
647MustHaveApp(wxPrintPreview);
648
d14a1e28
RD
649class wxPrintPreview : public wxObject {
650public:
c5633576
RD
651 %disownarg(wxPyPrintout*);
652
d88d4683 653 %nokwargs wxPrintPreview;
d14a1e28
RD
654 wxPrintPreview(wxPyPrintout* printout,
655 wxPyPrintout* printoutForPrinting,
d88d4683
RD
656 wxPrintDialogData *data=NULL);
657 wxPrintPreview(wxPyPrintout* printout,
658 wxPyPrintout* printoutForPrinting,
659 wxPrintData* data);
d14a1e28 660
c5633576
RD
661 ~wxPrintPreview();
662
d14a1e28
RD
663 virtual bool SetCurrentPage(int pageNum);
664 int GetCurrentPage();
665
666 void SetPrintout(wxPyPrintout *printout);
667 wxPyPrintout *GetPrintout();
668 wxPyPrintout *GetPrintoutForPrinting();
669
c5633576
RD
670 %cleardisown(wxPyPrintout*);
671
d14a1e28
RD
672 void SetFrame(wxFrame *frame);
673 void SetCanvas(wxPreviewCanvas *canvas);
674
675 virtual wxFrame *GetFrame();
676 virtual wxPreviewCanvas *GetCanvas();
677
678 // The preview canvas should call this from OnPaint
679 virtual bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc);
680
681 // This draws a blank page onto the preview canvas
682 virtual bool DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc);
683
684 // This is called by wxPrintPreview to render a page into a wxMemoryDC.
685 virtual bool RenderPage(int pageNum);
686
687 // Adjusts the scrollbars for the current scale
688 virtual void AdjustScrollbars(wxPreviewCanvas *canvas);
689
690 wxPrintDialogData& GetPrintDialogData();
691
692 virtual void SetZoom(int percent);
693 int GetZoom();
694
695 int GetMaxPage();
696 int GetMinPage();
697
6c2dd16f
RD
698 bool IsOk();
699 %pythoncode { Ok = IsOk }
d14a1e28
RD
700 void SetOk(bool ok);
701
702 virtual bool Print(bool interactive);
703 virtual void DetermineScaling();
704
6c2dd16f 705 %pythoncode { def __nonzero__(self): return self.IsOk() }
7012bb9f
RD
706
707 %property(Canvas, GetCanvas, SetCanvas, doc="See `GetCanvas` and `SetCanvas`");
708 %property(CurrentPage, GetCurrentPage, SetCurrentPage, doc="See `GetCurrentPage` and `SetCurrentPage`");
709 %property(Frame, GetFrame, SetFrame, doc="See `GetFrame` and `SetFrame`");
710 %property(MaxPage, GetMaxPage, doc="See `GetMaxPage`");
711 %property(MinPage, GetMinPage, doc="See `GetMinPage`");
712 %property(PrintDialogData, GetPrintDialogData, doc="See `GetPrintDialogData`");
713 %property(Printout, GetPrintout, SetPrintout, doc="See `GetPrintout` and `SetPrintout`");
714 %property(PrintoutForPrinting, GetPrintoutForPrinting, doc="See `GetPrintoutForPrinting`");
715 %property(Zoom, GetZoom, SetZoom, doc="See `GetZoom` and `SetZoom`");
d14a1e28
RD
716};
717
718
719
720//---------------------------------------------------------------------------
721
1fded56b
RD
722// Python-derivable versions of the above preview classes
723
724%{
3ef86e32 725
a72f4631 726#define DEC_PYCALLBACK_BOOL_PREWINDC(CBNAME) \
a7a01418 727 bool CBNAME(wxPreviewCanvas* a, wxDC& b)
3ef86e32
RD
728
729
a72f4631
RD
730#define IMP_PYCALLBACK_BOOL_PREWINDC(CLASS, PCLASS, CBNAME) \
731 bool CLASS::CBNAME(wxPreviewCanvas* a, wxDC& b) { \
732 bool rval=false; \
733 bool found; \
893d597c 734 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
a72f4631
RD
735 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
736 PyObject* win = wxPyMake_wxObject(a,false); \
737 PyObject* dc = wxPyMake_wxObject(&b,false); \
738 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc)); \
739 Py_DECREF(win); \
740 Py_DECREF(dc); \
741 } \
742 wxPyEndBlockThreads(blocked); \
743 if (! found) \
744 rval = PCLASS::CBNAME(a, b); \
745 return rval; \
a7a01418 746 }
3ef86e32
RD
747
748
749
750
1fded56b
RD
751class wxPyPrintPreview : public wxPrintPreview
752{
753 DECLARE_CLASS(wxPyPrintPreview)
754public:
d88d4683
RD
755 wxPyPrintPreview(wxPyPrintout* printout,
756 wxPyPrintout* printoutForPrinting,
757 wxPrintDialogData* data=NULL)
758 : wxPrintPreview(printout, printoutForPrinting, data)
759 {}
1fded56b
RD
760 wxPyPrintPreview(wxPyPrintout* printout,
761 wxPyPrintout* printoutForPrinting,
893d597c 762 wxPrintData* data)
1fded56b
RD
763 : wxPrintPreview(printout, printoutForPrinting, data)
764 {}
765
766 DEC_PYCALLBACK_BOOL_INT(SetCurrentPage);
3ef86e32
RD
767 DEC_PYCALLBACK_BOOL_PREWINDC(PaintPage);
768 DEC_PYCALLBACK_BOOL_PREWINDC(DrawBlankPage);
1fded56b
RD
769 DEC_PYCALLBACK_BOOL_INT(RenderPage);
770 DEC_PYCALLBACK_VOID_INT(SetZoom);
771 DEC_PYCALLBACK_BOOL_BOOL(Print);
772 DEC_PYCALLBACK_VOID_(DetermineScaling);
773
774 PYPRIVATE;
775};
776
777// Stupid renamed classes... Fix this in 2.5...
778#if defined(__WXMSW__)
779IMPLEMENT_CLASS( wxPyPrintPreview, wxWindowsPrintPreview );
780#elif defined(__WXMAC__)
781IMPLEMENT_CLASS( wxPyPrintPreview, wxMacPrintPreview );
782#else
783IMPLEMENT_CLASS( wxPyPrintPreview, wxPostScriptPrintPreview );
784#endif
785
3ef86e32
RD
786IMP_PYCALLBACK_BOOL_INT (wxPyPrintPreview, wxPrintPreview, SetCurrentPage);
787IMP_PYCALLBACK_BOOL_PREWINDC(wxPyPrintPreview, wxPrintPreview, PaintPage);
788IMP_PYCALLBACK_BOOL_PREWINDC(wxPyPrintPreview, wxPrintPreview, DrawBlankPage);
789IMP_PYCALLBACK_BOOL_INT (wxPyPrintPreview, wxPrintPreview, RenderPage);
790IMP_PYCALLBACK_VOID_INT (wxPyPrintPreview, wxPrintPreview, SetZoom);
791IMP_PYCALLBACK_BOOL_BOOL (wxPyPrintPreview, wxPrintPreview, Print);
792IMP_PYCALLBACK_VOID_ (wxPyPrintPreview, wxPrintPreview, DetermineScaling);
1fded56b
RD
793%}
794
795
ab1f7d2a
RD
796MustHaveApp(wxPyPrintPreview);
797
1fded56b
RD
798class wxPyPrintPreview : public wxPrintPreview
799{
800public:
c5633576
RD
801 %disownarg(wxPyPrintout*);
802
2b9048c5 803 %pythonAppend wxPyPrintPreview "self._setCallbackInfo(self, PyPrintPreview)"
d88d4683
RD
804 %nokwargs wxPyPrintPreview;
805 wxPyPrintPreview(wxPyPrintout* printout,
806 wxPyPrintout* printoutForPrinting,
807 wxPrintDialogData* data=NULL);
1fded56b
RD
808 wxPyPrintPreview(wxPyPrintout* printout,
809 wxPyPrintout* printoutForPrinting,
d88d4683 810 wxPrintData* data);
1fded56b 811
c5633576
RD
812 %cleardisown(wxPyPrintout*);
813
1fded56b 814 void _setCallbackInfo(PyObject* self, PyObject* _class);
d14a1e28 815
a7a01418
RD
816 bool SetCurrentPage(int pageNum);
817 bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc);
818 bool DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc);
819 bool RenderPage(int pageNum);
820 void SetZoom(int percent);
821 bool Print(bool interactive);
822 void DetermineScaling();
823
824 %MAKE_BASE_FUNC(PyPrintPreview, SetCurrentPage);
825 %MAKE_BASE_FUNC(PyPrintPreview, PaintPage);
826 %MAKE_BASE_FUNC(PyPrintPreview, DrawBlankPage);
827 %MAKE_BASE_FUNC(PyPrintPreview, RenderPage);
828 %MAKE_BASE_FUNC(PyPrintPreview, SetZoom);
829 %MAKE_BASE_FUNC(PyPrintPreview, Print);
830 %MAKE_BASE_FUNC(PyPrintPreview, DetermineScaling);
1fded56b
RD
831};
832
833
bb0054cd 834
bb0054cd 835
1fded56b
RD
836%{
837class wxPyPreviewFrame : public wxPreviewFrame
838{
4617be08 839 DECLARE_CLASS(wxPyPreviewFrame)
1fded56b
RD
840public:
841 wxPyPreviewFrame(wxPrintPreview* preview, wxFrame* parent,
842 const wxString& title,
843 const wxPoint& pos = wxDefaultPosition,
844 const wxSize& size = wxDefaultSize,
845 long style = wxDEFAULT_FRAME_STYLE,
846 const wxString& name = wxPyFrameNameStr)
847 : wxPreviewFrame(preview, parent, title, pos, size, style, name)
848 {}
849
3ef86e32 850 void SetPreviewCanvas(wxPreviewCanvas* canvas) { m_previewCanvas = canvas; }
1fded56b
RD
851 void SetControlBar(wxPreviewControlBar* bar) { m_controlBar = bar; }
852
853 DEC_PYCALLBACK_VOID_(Initialize);
854 DEC_PYCALLBACK_VOID_(CreateCanvas);
855 DEC_PYCALLBACK_VOID_(CreateControlBar);
856
857 PYPRIVATE;
858};
859
860IMPLEMENT_CLASS(wxPyPreviewFrame, wxPreviewFrame);
861
862IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, Initialize);
863IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, CreateCanvas);
864IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, CreateControlBar);
865%}
866
d14a1e28 867
ab1f7d2a
RD
868MustHaveApp(wxPyPreviewFrame);
869
1fded56b
RD
870class wxPyPreviewFrame : public wxPreviewFrame
871{
872public:
2b9048c5 873 %pythonAppend wxPyPreviewFrame "self._setCallbackInfo(self, PyPreviewFrame); self._setOORInfo(self)"
d14a1e28 874
1fded56b
RD
875 wxPyPreviewFrame(wxPrintPreview* preview, wxFrame* parent,
876 const wxString& title,
877 const wxPoint& pos = wxDefaultPosition,
878 const wxSize& size = wxDefaultSize,
879 long style = wxDEFAULT_FRAME_STYLE,
880 const wxString& name = wxPyFrameNameStr);
881
882 void _setCallbackInfo(PyObject* self, PyObject* _class);
1fded56b 883
3ef86e32 884 void SetPreviewCanvas(wxPreviewCanvas* canvas);
1fded56b
RD
885 void SetControlBar(wxPreviewControlBar* bar);
886
a7a01418
RD
887 void Initialize();
888 void CreateCanvas();
889 void CreateControlBar();
890
891 %MAKE_BASE_FUNC(PyPreviewFrame, Initialize);
892 %MAKE_BASE_FUNC(PyPreviewFrame, CreateCanvas);
893 %MAKE_BASE_FUNC(PyPreviewFrame, CreateControlBar);
bb0054cd
RD
894};
895
1fded56b
RD
896
897
898
899%{
900class wxPyPreviewControlBar : public wxPreviewControlBar
901{
4617be08 902 DECLARE_CLASS(wxPyPreviewControlBar)
1fded56b
RD
903public:
904 wxPyPreviewControlBar(wxPrintPreview *preview,
905 long buttons,
906 wxWindow *parent,
907 const wxPoint& pos = wxDefaultPosition,
908 const wxSize& size = wxDefaultSize,
909 long style = 0,
910 const wxString& name = wxPyPanelNameStr)
911 : wxPreviewControlBar(preview, buttons, parent, pos, size, style, name)
912 {}
913
914 void SetPrintPreview(wxPrintPreview* preview) { m_printPreview = preview; }
915
916 DEC_PYCALLBACK_VOID_(CreateButtons);
917 DEC_PYCALLBACK_VOID_INT(SetZoomControl);
918
919 PYPRIVATE;
920};
921
922IMPLEMENT_CLASS(wxPyPreviewControlBar, wxPreviewControlBar);
923IMP_PYCALLBACK_VOID_(wxPyPreviewControlBar, wxPreviewControlBar, CreateButtons);
924IMP_PYCALLBACK_VOID_INT(wxPyPreviewControlBar, wxPreviewControlBar, SetZoomControl);
925%}
926
d14a1e28 927
ab1f7d2a
RD
928MustHaveApp(wxPyPreviewControlBar);
929
1fded56b
RD
930class wxPyPreviewControlBar : public wxPreviewControlBar
931{
932public:
2b9048c5 933 %pythonAppend wxPyPreviewControlBar "self._setCallbackInfo(self, PyPreviewControlBar); self._setOORInfo(self)"
d14a1e28 934
1fded56b
RD
935 wxPyPreviewControlBar(wxPrintPreview *preview,
936 long buttons,
937 wxWindow *parent,
938 const wxPoint& pos = wxDefaultPosition,
939 const wxSize& size = wxDefaultSize,
940 long style = 0,
941 const wxString& name = wxPyPanelNameStr);
942
943 void _setCallbackInfo(PyObject* self, PyObject* _class);
1fded56b
RD
944
945 void SetPrintPreview(wxPrintPreview* preview);
946
a7a01418
RD
947 void CreateButtons();
948 void SetZoomControl(int zoom);
949
950 %MAKE_BASE_FUNC(PreviewControlBar, CreateButtons);
951 %MAKE_BASE_FUNC(PreviewControlBar, SetZoomControl);
1fded56b
RD
952};
953
d14a1e28
RD
954//---------------------------------------------------------------------------
955//---------------------------------------------------------------------------
9416aa89
RD
956%init %{
957 wxPyPtrTypeMap_Add("wxPrintout", "wxPyPrintout");
958%}
d14a1e28 959//---------------------------------------------------------------------------