]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_printfw.i
regenned docs
[wxWidgets.git] / wxPython / src / _printfw.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: _????.i
3 // Purpose: SWIG interface for wx????
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 9-Aug-2003
8 // RCS-ID: $Id$
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 // Not a %module
14
15
16 //---------------------------------------------------------------------------
17 %newgroup
18
19 %{
20 #include "wx/wxPython/printfw.h"
21
22 %}
23
24 MAKE_CONST_WXSTRING2(PrintoutTitleStr, wxT("Printout"));
25 MAKE_CONST_WXSTRING2(PreviewCanvasNameStr, wxT("previewcanvas"));
26
27
28 //---------------------------------------------------------------------------
29
30 enum wxPrintMode
31 {
32 wxPRINT_MODE_NONE = 0,
33 wxPRINT_MODE_PREVIEW = 1, // Preview in external application
34 wxPRINT_MODE_FILE = 2, // Print to file
35 wxPRINT_MODE_PRINTER = 3, // Send to printer
36 wxPRINT_MODE_STREAM = 4 // Send postscript data into a stream
37 };
38
39 enum 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 };
59
60
61 class wxPrintData : public wxObject {
62 public:
63 %nokwargs wxPrintData;
64 wxPrintData();
65 wxPrintData(const wxPrintData& data); // for making copies
66
67 ~wxPrintData();
68
69 int GetNoCopies();
70 bool GetCollate();
71 int GetOrientation();
72 bool IsOrientationReversed() const;
73
74 bool IsOk();
75 %pythoncode { Ok = IsOk }
76
77 const wxString& GetPrinterName();
78 bool GetColour();
79 wxDuplexMode GetDuplex();
80 wxPaperSize GetPaperId();
81 const wxSize& GetPaperSize();
82
83 int GetQuality();
84 wxPrintBin GetBin();
85 wxPrintMode GetPrintMode() const;
86 int GetMedia() const;
87
88 void SetNoCopies(int v);
89 void SetCollate(bool flag);
90 void SetOrientation(int orient);
91 void SetOrientationReversed(bool reversed);
92
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);
98 void SetQuality(int quality);
99 void SetBin(wxPrintBin bin);
100 void SetPrintMode(wxPrintMode printMode);
101 void SetMedia(int media);
102
103 wxString GetFilename() const;
104 void SetFilename( const wxString &filename );
105
106 %pythoncode { def __nonzero__(self): return self.IsOk() }
107
108 //char* GetPrivData() const;
109 //int GetPrivDataLen() const;
110 //void SetPrivData( char *privData, int len );
111
112 %extend {
113 PyObject* GetPrivData() {
114 PyObject* data;
115 wxPyBlock_t blocked = wxPyBeginBlockThreads();
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
129 wxPyBlock_t blocked = wxPyBeginBlockThreads();
130 self->SetPrivData(PyString_AS_STRING(data), PyString_GET_SIZE(data));
131 wxPyEndBlockThreads(blocked);
132 }
133 }
134
135
136 // NOTE: These are now inside of #if WXWIN_COMPATIBILITY_2_4, so be
137 // prepared to remove them...
138
139 // PostScript-specific data
140 // WXWIN_COMPATIBILITY_2_4
141 #if 0
142 const wxString& GetPrinterCommand();
143 const wxString& GetPrinterOptions();
144 const wxString& GetPreviewCommand();
145 const wxString& GetFontMetricPath();
146 double GetPrinterScaleX();
147 double GetPrinterScaleY();
148 long GetPrinterTranslateX();
149 long GetPrinterTranslateY();
150 void SetPrinterCommand(const wxString& command);
151 void SetPrinterOptions(const wxString& options);
152 void SetPreviewCommand(const wxString& command);
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);
160 #endif
161
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`");
175 };
176
177 //---------------------------------------------------------------------------
178
179 class wxPageSetupDialogData : public wxObject {
180 public:
181 %nokwargs wxPageSetupDialogData;
182 wxPageSetupDialogData();
183 wxPageSetupDialogData(const wxPageSetupDialogData& data); // for making copies
184 wxPageSetupDialogData(const wxPrintData& data);
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);
192
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();
206
207 wxPrintData& GetPrintData();
208
209 bool IsOk();
210 %pythoncode { Ok = IsOk }
211
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);
218 void SetPaperId(wxPaperSize id);
219 void SetPaperSize(const wxSize& size);
220
221 void SetPrintData(const wxPrintData& printData);
222
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
230 %pythoncode { def __nonzero__(self): return self.IsOk() }
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
249 };
250
251
252
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
257 MustHaveApp(wxPageSetupDialog);
258
259 class wxPageSetupDialog : public wxObject
260 {
261 public:
262 wxPageSetupDialog(wxWindow* parent, wxPageSetupDialogData* data = NULL);
263 ~wxPageSetupDialog();
264
265 wxPageSetupDialogData& GetPageSetupData();
266 wxPageSetupDialogData& GetPageSetupDialogData();
267 int ShowModal();
268
269 %pythoncode { def Destroy(self): pass }
270
271 %property(PageSetupData, GetPageSetupData, doc="See `GetPageSetupData`");
272 %property(PageSetupDialogData, GetPageSetupDialogData, doc="See `GetPageSetupDialogData`");
273
274 };
275
276 //---------------------------------------------------------------------------
277
278
279 class wxPrintDialogData : public wxObject {
280 public:
281 %nokwargs wxPrintDialogData;
282 wxPrintDialogData();
283 wxPrintDialogData(const wxPrintData& printData);
284 wxPrintDialogData(const wxPrintDialogData& printData); // for making copies
285 ~wxPrintDialogData();
286
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;
296
297 // WXWIN_COMPATIBILITY_2_4
298 #if 0
299 bool GetSetupDialog() const;
300 void SetSetupDialog(bool flag);
301 #endif
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);
311
312 void EnablePrintToFile(bool flag);
313 void EnableSelection(bool flag);
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?
323 bool IsOk() const;
324 %pythoncode { Ok = IsOk }
325
326
327 wxPrintData& GetPrintData();
328 void SetPrintData(const wxPrintData& printData);
329
330 %pythoncode { def __nonzero__(self): return self.IsOk() }
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`");
346 };
347
348
349
350 MustHaveApp(wxPrintDialog);
351
352
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
357 class wxPrintDialog : public wxObject {
358 public:
359 wxPrintDialog(wxWindow* parent, wxPrintDialogData* data = NULL);
360
361 // TODO?: wxPrintDialog(wxWindow *parent, wxPrintData* data);
362
363 ~wxPrintDialog();
364
365 virtual int ShowModal();
366
367 virtual wxPrintDialogData& GetPrintDialogData();
368 virtual wxPrintData& GetPrintData();
369
370 %newobject GetPrintDC;
371 virtual wxDC *GetPrintDC();
372
373 %pythoncode { def Destroy(self): pass }
374
375 %property(PrintDC, GetPrintDC, doc="See `GetPrintDC`");
376 %property(PrintData, GetPrintData, doc="See `GetPrintData`");
377 %property(PrintDialogData, GetPrintDialogData, doc="See `GetPrintDialogData`");
378 };
379
380
381 //---------------------------------------------------------------------------
382 //---------------------------------------------------------------------------
383
384
385 enum wxPrinterError
386 {
387 wxPRINTER_NO_ERROR = 0,
388 wxPRINTER_CANCELLED,
389 wxPRINTER_ERROR
390 };
391
392
393 MustHaveApp(wxPrinter);
394
395 class wxPrinter : public wxObject {
396 public:
397 wxPrinter(wxPrintDialogData* data = NULL);
398 ~wxPrinter();
399
400 virtual wxWindow *CreateAbortWindow(wxWindow *parent, wxPyPrintout *printout);
401 virtual void ReportError(wxWindow *parent, wxPyPrintout *printout, const wxString& message);
402
403 virtual bool Setup(wxWindow *parent);
404 virtual bool Print(wxWindow *parent, wxPyPrintout *printout, bool prompt = true);
405 virtual wxDC* PrintDialog(wxWindow *parent);
406
407 virtual wxPrintDialogData& GetPrintDialogData() const;
408
409 bool GetAbort();
410 static wxPrinterError GetLastError();
411
412 %property(Abort, GetAbort, doc="See `GetAbort`");
413 %property(PrintDialogData, GetPrintDialogData, doc="See `GetPrintDialogData`");
414 };
415
416
417 //---------------------------------------------------------------------------
418 // Custom wxPrintout class that knows how to call python, See implementation in
419 // include/sx/wxPython/printfw.h
420
421 %{
422
423 IMPLEMENT_ABSTRACT_CLASS(wxPyPrintout, wxPrintout);
424
425 // Since this one would be tough and ugly to do with the Macros...
426 void wxPyPrintout::GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) {
427 bool hadErr = false;
428 bool found;
429
430 wxPyBlock_t blocked = wxPyBeginBlockThreads();
431 if ((found = wxPyCBH_findCallback(m_myInst, "GetPageInfo"))) {
432 PyObject* result = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));
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);
438 else hadErr = true;
439
440 val = PyTuple_GetItem(result, 1);
441 if (PyInt_Check(val)) *maxPage = PyInt_AsLong(val);
442 else hadErr = true;
443
444 val = PyTuple_GetItem(result, 2);
445 if (PyInt_Check(val)) *pageFrom = PyInt_AsLong(val);
446 else hadErr = true;
447
448 val = PyTuple_GetItem(result, 3);
449 if (PyInt_Check(val)) *pageTo = PyInt_AsLong(val);
450 else hadErr = true;
451 }
452 else
453 hadErr = true;
454
455 if (hadErr) {
456 PyErr_SetString(PyExc_TypeError, "GetPageInfo should return a tuple of 4 integers.");
457 PyErr_Print();
458 }
459 Py_DECREF(result);
460 }
461 wxPyEndBlockThreads(blocked);
462 if (! found)
463 wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo);
464 }
465
466
467
468 IMP_PYCALLBACK_BOOL_INTINT(wxPyPrintout, wxPrintout, OnBeginDocument);
469 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnEndDocument);
470 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnBeginPrinting);
471 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnEndPrinting);
472 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnPreparePrinting);
473 IMP_PYCALLBACK_BOOL_INT_pure(wxPyPrintout, wxPrintout, OnPrintPage);
474 IMP_PYCALLBACK_BOOL_INT(wxPyPrintout, wxPrintout, HasPage);
475
476
477 %}
478
479
480 MustHaveApp(wxPyPrintout);
481
482 // Now define the custom class for SWIGging
483 %rename(Printout) wxPyPrintout;
484 class wxPyPrintout : public wxObject {
485 public:
486 %pythonAppend wxPyPrintout setCallbackInfo(Printout)
487 %typemap(out) wxPyPrintout*; // turn off this typemap
488
489 wxPyPrintout(const wxString& title = wxPyPrintoutTitleStr);
490 ~wxPyPrintout();
491
492 // Turn it back on again
493 %typemap(out) wxPyPrintout* { $result = wxPyMake_wxObject($1, $owner); }
494
495 void _setCallbackInfo(PyObject* self, PyObject* _class);
496
497
498 wxString GetTitle() const;
499 wxDC* GetDC();
500 void SetDC(wxDC *dc);
501
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
519 void SetPageSizePixels(int w, int h);
520 DocDeclA(
521 void, GetPageSizePixels(int *OUTPUT, int *OUTPUT),
522 "GetPageSizePixels() -> (w, h)");
523
524 void SetPageSizeMM(int w, int h);
525 DocDeclA(
526 void, GetPageSizeMM(int *OUTPUT, int *OUTPUT),
527 "GetPageSizeMM() -> (w, h)");
528
529 void SetPPIScreen(int x, int y);
530 DocDeclA(
531 void, GetPPIScreen(int *OUTPUT, int *OUTPUT),
532 "GetPPIScreen() -> (x,y)");
533
534 void SetPPIPrinter(int x, int y);
535 DocDeclA(
536 void, GetPPIPrinter(int *OUTPUT, int *OUTPUT),
537 "GetPPIPrinter() -> (x,y)");
538
539 void SetPaperRectPixels(const wxRect& paperRectPixels);
540 wxRect GetPaperRectPixels() const;
541
542 bool IsPreview();
543 void SetIsPreview(bool p);
544
545
546 bool OnBeginDocument(int startPage, int endPage);
547 void OnEndDocument();
548 void OnBeginPrinting();
549 void OnEndPrinting();
550 void OnPreparePrinting();
551 bool HasPage(int page);
552 DocDeclA(
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);
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`");
570 };
571
572 //---------------------------------------------------------------------------
573
574
575
576 MustHaveApp(wxPreviewCanvas);
577
578 class wxPreviewCanvas: public wxScrolledWindow
579 {
580 public:
581 %pythonAppend wxPreviewCanvas "self._setOORInfo(self)"
582
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);
589 };
590
591
592 MustHaveApp(wxPreviewFrame);
593
594 class wxPreviewFrame : public wxFrame {
595 public:
596 %disownarg(wxPrintPreview*);
597
598 %pythonAppend wxPreviewFrame "self._setOORInfo(self)"
599 wxPreviewFrame(wxPrintPreview* preview, wxFrame* parent, const wxString& title,
600 const wxPoint& pos = wxDefaultPosition,
601 const wxSize& size = wxDefaultSize,
602 long style = wxDEFAULT_FRAME_STYLE,
603 const wxString& name = wxPyFrameNameStr);
604
605 %cleardisown(wxPrintPreview*);
606
607 void Initialize();
608 void CreateControlBar();
609 void CreateCanvas();
610
611 wxPreviewControlBar* GetControlBar() const;
612
613 %property(ControlBar, GetControlBar, doc="See `GetControlBar`");
614 };
615
616
617
618 enum {
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
638 MustHaveApp(wxPreviewControlBar);
639
640 class wxPreviewControlBar: public wxPanel
641 {
642 public:
643 %pythonAppend wxPreviewControlBar "self._setOORInfo(self)"
644
645 wxPreviewControlBar(wxPrintPreview *preview,
646 long buttons,
647 wxWindow *parent,
648 const wxPoint& pos = wxDefaultPosition,
649 const wxSize& size = wxDefaultSize,
650 long style = wxTAB_TRAVERSAL,
651 const wxString& name = wxPyPanelNameStr);
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();
662
663 %property(PrintPreview, GetPrintPreview, doc="See `GetPrintPreview`");
664 %property(ZoomControl, GetZoomControl, SetZoomControl, doc="See `GetZoomControl` and `SetZoomControl`");
665 };
666
667
668
669 //---------------------------------------------------------------------------
670
671 MustHaveApp(wxPrintPreview);
672
673 class wxPrintPreview : public wxObject {
674 public:
675 %disownarg(wxPyPrintout*);
676
677 %nokwargs wxPrintPreview;
678 wxPrintPreview(wxPyPrintout* printout,
679 wxPyPrintout* printoutForPrinting,
680 wxPrintDialogData *data=NULL);
681 wxPrintPreview(wxPyPrintout* printout,
682 wxPyPrintout* printoutForPrinting,
683 wxPrintData* data);
684
685 ~wxPrintPreview();
686
687 virtual bool SetCurrentPage(int pageNum);
688 int GetCurrentPage();
689
690 void SetPrintout(wxPyPrintout *printout);
691 wxPyPrintout *GetPrintout();
692 wxPyPrintout *GetPrintoutForPrinting();
693
694 %cleardisown(wxPyPrintout*);
695
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
722 bool IsOk();
723 %pythoncode { Ok = IsOk }
724 void SetOk(bool ok);
725
726 virtual bool Print(bool interactive);
727 virtual void DetermineScaling();
728
729 %pythoncode { def __nonzero__(self): return self.IsOk() }
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`");
740 };
741
742
743
744 //---------------------------------------------------------------------------
745
746 // Python-derivable versions of the above preview classes
747
748 %{
749
750 #define DEC_PYCALLBACK_BOOL_PREWINDC(CBNAME) \
751 bool CBNAME(wxPreviewCanvas* a, wxDC& b)
752
753
754 #define IMP_PYCALLBACK_BOOL_PREWINDC(CLASS, PCLASS, CBNAME) \
755 bool CLASS::CBNAME(wxPreviewCanvas* a, wxDC& b) { \
756 bool rval=false; \
757 bool found; \
758 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
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; \
770 }
771
772
773
774
775 class wxPyPrintPreview : public wxPrintPreview
776 {
777 DECLARE_CLASS(wxPyPrintPreview)
778 public:
779 wxPyPrintPreview(wxPyPrintout* printout,
780 wxPyPrintout* printoutForPrinting,
781 wxPrintDialogData* data=NULL)
782 : wxPrintPreview(printout, printoutForPrinting, data)
783 {}
784 wxPyPrintPreview(wxPyPrintout* printout,
785 wxPyPrintout* printoutForPrinting,
786 wxPrintData* data)
787 : wxPrintPreview(printout, printoutForPrinting, data)
788 {}
789
790 DEC_PYCALLBACK_BOOL_INT(SetCurrentPage);
791 DEC_PYCALLBACK_BOOL_PREWINDC(PaintPage);
792 DEC_PYCALLBACK_BOOL_PREWINDC(DrawBlankPage);
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__)
803 IMPLEMENT_CLASS( wxPyPrintPreview, wxWindowsPrintPreview );
804 #elif defined(__WXMAC__)
805 IMPLEMENT_CLASS( wxPyPrintPreview, wxMacPrintPreview );
806 #else
807 IMPLEMENT_CLASS( wxPyPrintPreview, wxPostScriptPrintPreview );
808 #endif
809
810 IMP_PYCALLBACK_BOOL_INT (wxPyPrintPreview, wxPrintPreview, SetCurrentPage);
811 IMP_PYCALLBACK_BOOL_PREWINDC(wxPyPrintPreview, wxPrintPreview, PaintPage);
812 IMP_PYCALLBACK_BOOL_PREWINDC(wxPyPrintPreview, wxPrintPreview, DrawBlankPage);
813 IMP_PYCALLBACK_BOOL_INT (wxPyPrintPreview, wxPrintPreview, RenderPage);
814 IMP_PYCALLBACK_VOID_INT (wxPyPrintPreview, wxPrintPreview, SetZoom);
815 IMP_PYCALLBACK_BOOL_BOOL (wxPyPrintPreview, wxPrintPreview, Print);
816 IMP_PYCALLBACK_VOID_ (wxPyPrintPreview, wxPrintPreview, DetermineScaling);
817 %}
818
819
820 MustHaveApp(wxPyPrintPreview);
821
822 class wxPyPrintPreview : public wxPrintPreview
823 {
824 public:
825 %disownarg(wxPyPrintout*);
826
827 %pythonAppend wxPyPrintPreview setCallbackInfo(PyPrintPreview)
828 %nokwargs wxPyPrintPreview;
829 wxPyPrintPreview(wxPyPrintout* printout,
830 wxPyPrintout* printoutForPrinting,
831 wxPrintDialogData* data=NULL);
832 wxPyPrintPreview(wxPyPrintout* printout,
833 wxPyPrintout* printoutForPrinting,
834 wxPrintData* data);
835
836 %cleardisown(wxPyPrintout*);
837
838 void _setCallbackInfo(PyObject* self, PyObject* _class);
839
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);
855 };
856
857
858
859
860 %{
861 class wxPyPreviewFrame : public wxPreviewFrame
862 {
863 DECLARE_CLASS(wxPyPreviewFrame)
864 public:
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
874 void SetPreviewCanvas(wxPreviewCanvas* canvas) { m_previewCanvas = canvas; }
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
884 IMPLEMENT_CLASS(wxPyPreviewFrame, wxPreviewFrame);
885
886 IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, Initialize);
887 IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, CreateCanvas);
888 IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, CreateControlBar);
889 %}
890
891
892 MustHaveApp(wxPyPreviewFrame);
893
894 class wxPyPreviewFrame : public wxPreviewFrame
895 {
896 public:
897 %disownarg(wxPrintPreview*);
898 %pythonAppend wxPyPreviewFrame "self._setOORInfo(self);" setCallbackInfo(PyPreviewFrame)
899
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);
908
909 void SetPreviewCanvas(wxPreviewCanvas* canvas);
910 void SetControlBar(wxPreviewControlBar* bar);
911
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);
919 };
920
921
922
923
924 %{
925 class wxPyPreviewControlBar : public wxPreviewControlBar
926 {
927 DECLARE_CLASS(wxPyPreviewControlBar)
928 public:
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
947 IMPLEMENT_CLASS(wxPyPreviewControlBar, wxPreviewControlBar);
948 IMP_PYCALLBACK_VOID_(wxPyPreviewControlBar, wxPreviewControlBar, CreateButtons);
949 IMP_PYCALLBACK_VOID_INT(wxPyPreviewControlBar, wxPreviewControlBar, SetZoomControl);
950 %}
951
952
953 MustHaveApp(wxPyPreviewControlBar);
954
955 class wxPyPreviewControlBar : public wxPreviewControlBar
956 {
957 public:
958 %pythonAppend wxPyPreviewControlBar "self._setOORInfo(self);" setCallbackInfo(PyPreviewControlBar)
959
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);
969
970 void SetPrintPreview(wxPrintPreview* preview);
971
972 void CreateButtons();
973 void SetZoomControl(int zoom);
974
975 %MAKE_BASE_FUNC(PreviewControlBar, CreateButtons);
976 %MAKE_BASE_FUNC(PreviewControlBar, SetZoomControl);
977 };
978
979 //---------------------------------------------------------------------------
980 //---------------------------------------------------------------------------
981 %init %{
982 wxPyPtrTypeMap_Add("wxPrintout", "wxPyPrintout");
983 %}
984 //---------------------------------------------------------------------------