1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface for wx????
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
16 //---------------------------------------------------------------------------
20 #include "wx/wxPython/printfw.h"
24 MAKE_CONST_WXSTRING2(PrintoutTitleStr, wxT("Printout"));
25 MAKE_CONST_WXSTRING2(PreviewCanvasNameStr, wxT("previewcanvas"));
28 //---------------------------------------------------------------------------
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
53 wxPRINTBIN_LARGECAPACITY,
55 wxPRINTBIN_FORMSOURCE,
61 class wxPrintData : public wxObject {
63 %nokwargs wxPrintData;
65 wxPrintData(const wxPrintData& data); // for making copies
75 const wxString& GetPrinterName();
77 wxDuplexMode GetDuplex();
78 wxPaperSize GetPaperId();
79 const wxSize& GetPaperSize();
83 wxPrintMode GetPrintMode() const;
85 void SetNoCopies(int v);
86 void SetCollate(bool flag);
87 void SetOrientation(int orient);
89 void SetPrinterName(const wxString& name);
90 void SetColour(bool colour);
91 void SetDuplex(wxDuplexMode duplex);
92 void SetPaperId(wxPaperSize sizeId);
93 void SetPaperSize(const wxSize& sz);
94 void SetQuality(int quality);
95 void SetBin(wxPrintBin bin);
96 void SetPrintMode(wxPrintMode printMode);
98 wxString GetFilename() const;
99 void SetFilename( const wxString &filename );
101 %pythoncode { def __nonzero__(self): return self.Ok() }
103 //char* GetPrivData() const;
104 //int GetPrivDataLen() const;
105 //void SetPrivData( char *privData, int len );
108 PyObject* GetPrivData() {
110 wxPyBlock_t blocked = wxPyBeginBlockThreads();
111 data = PyString_FromStringAndSize(self->GetPrivData(),
112 self->GetPrivDataLen());
113 wxPyEndBlockThreads(blocked);
117 void SetPrivData(PyObject* data) {
118 if (! PyString_Check(data)) {
119 wxPyBLOCK_THREADS(PyErr_SetString(PyExc_TypeError,
120 "Expected string object"));
124 wxPyBlock_t blocked = wxPyBeginBlockThreads();
125 self->SetPrivData(PyString_AS_STRING(data), PyString_GET_SIZE(data));
126 wxPyEndBlockThreads(blocked);
131 // NOTE: These are now inside of #if WXWIN_COMPATIBILITY_2_4, so be
132 // prepared to remove them...
134 // PostScript-specific data
135 // WXWIN_COMPATIBILITY_2_4
137 const wxString& GetPrinterCommand();
138 const wxString& GetPrinterOptions();
139 const wxString& GetPreviewCommand();
140 const wxString& GetFontMetricPath();
141 double GetPrinterScaleX();
142 double GetPrinterScaleY();
143 long GetPrinterTranslateX();
144 long GetPrinterTranslateY();
145 void SetPrinterCommand(const wxString& command);
146 void SetPrinterOptions(const wxString& options);
147 void SetPreviewCommand(const wxString& command);
148 void SetFontMetricPath(const wxString& path);
149 void SetPrinterScaleX(double x);
150 void SetPrinterScaleY(double y);
151 void SetPrinterScaling(double x, double y);
152 void SetPrinterTranslateX(long x);
153 void SetPrinterTranslateY(long y);
154 void SetPrinterTranslation(long x, long y);
157 %property(Bin, GetBin, SetBin, doc="See `GetBin` and `SetBin`");
158 %property(Collate, GetCollate, SetCollate, doc="See `GetCollate` and `SetCollate`");
159 %property(Colour, GetColour, SetColour, doc="See `GetColour` and `SetColour`");
160 %property(Duplex, GetDuplex, SetDuplex, doc="See `GetDuplex` and `SetDuplex`");
161 %property(Filename, GetFilename, SetFilename, doc="See `GetFilename` and `SetFilename`");
162 %property(NoCopies, GetNoCopies, SetNoCopies, doc="See `GetNoCopies` and `SetNoCopies`");
163 %property(Orientation, GetOrientation, SetOrientation, doc="See `GetOrientation` and `SetOrientation`");
164 %property(PaperId, GetPaperId, SetPaperId, doc="See `GetPaperId` and `SetPaperId`");
165 %property(PaperSize, GetPaperSize, SetPaperSize, doc="See `GetPaperSize` and `SetPaperSize`");
166 %property(PrintMode, GetPrintMode, SetPrintMode, doc="See `GetPrintMode` and `SetPrintMode`");
167 %property(PrinterName, GetPrinterName, SetPrinterName, doc="See `GetPrinterName` and `SetPrinterName`");
168 %property(PrivData, GetPrivData, SetPrivData, doc="See `GetPrivData` and `SetPrivData`");
169 %property(Quality, GetQuality, SetQuality, doc="See `GetQuality` and `SetQuality`");
172 //---------------------------------------------------------------------------
174 class wxPageSetupDialogData : public wxObject {
176 %nokwargs wxPageSetupDialogData;
177 wxPageSetupDialogData();
178 wxPageSetupDialogData(const wxPageSetupDialogData& data); // for making copies
179 wxPageSetupDialogData(const wxPrintData& data);
180 ~wxPageSetupDialogData();
182 void EnableHelp(bool flag);
183 void EnableMargins(bool flag);
184 void EnableOrientation(bool flag);
185 void EnablePaper(bool flag);
186 void EnablePrinter(bool flag);
188 bool GetDefaultMinMargins();
189 bool GetEnableMargins();
190 bool GetEnableOrientation();
191 bool GetEnablePaper();
192 bool GetEnablePrinter();
193 bool GetEnableHelp();
194 bool GetDefaultInfo();
195 wxPoint GetMarginTopLeft();
196 wxPoint GetMarginBottomRight();
197 wxPoint GetMinMarginTopLeft();
198 wxPoint GetMinMarginBottomRight();
199 wxPaperSize GetPaperId();
200 wxSize GetPaperSize();
202 wxPrintData& GetPrintData();
206 void SetDefaultInfo(bool flag);
207 void SetDefaultMinMargins(bool flag);
208 void SetMarginTopLeft(const wxPoint& pt);
209 void SetMarginBottomRight(const wxPoint& pt);
210 void SetMinMarginTopLeft(const wxPoint& pt);
211 void SetMinMarginBottomRight(const wxPoint& pt);
212 void SetPaperId(wxPaperSize id);
213 void SetPaperSize(const wxSize& size);
215 void SetPrintData(const wxPrintData& printData);
217 // Use paper size defined in this object to set the wxPrintData
219 void CalculateIdFromPaperSize();
221 // Use paper id in wxPrintData to set this object's paper size
222 void CalculatePaperSizeFromId();
224 %pythoncode { def __nonzero__(self): return self.Ok() }
226 %property(DefaultInfo, GetDefaultInfo, SetDefaultInfo, doc="See `GetDefaultInfo` and `SetDefaultInfo`");
227 %property(DefaultMinMargins, GetDefaultMinMargins, SetDefaultMinMargins, doc="See `GetDefaultMinMargins` and `SetDefaultMinMargins`");
229 // %property(EnableHelp, GetEnableHelp, doc="See `GetEnableHelp`");
230 // %property(EnableMargins, GetEnableMargins, doc="See `GetEnableMargins`");
231 // %property(EnableOrientation, GetEnableOrientation, doc="See `GetEnableOrientation`");
232 // %property(EnablePaper, GetEnablePaper, doc="See `GetEnablePaper`");
233 // %property(EnablePrinter, GetEnablePrinter, doc="See `GetEnablePrinter`");
235 %property(MarginBottomRight, GetMarginBottomRight, SetMarginBottomRight, doc="See `GetMarginBottomRight` and `SetMarginBottomRight`");
236 %property(MarginTopLeft, GetMarginTopLeft, SetMarginTopLeft, doc="See `GetMarginTopLeft` and `SetMarginTopLeft`");
237 %property(MinMarginBottomRight, GetMinMarginBottomRight, SetMinMarginBottomRight, doc="See `GetMinMarginBottomRight` and `SetMinMarginBottomRight`");
238 %property(MinMarginTopLeft, GetMinMarginTopLeft, SetMinMarginTopLeft, doc="See `GetMinMarginTopLeft` and `SetMinMarginTopLeft`");
239 %property(PaperId, GetPaperId, SetPaperId, doc="See `GetPaperId` and `SetPaperId`");
240 %property(PaperSize, GetPaperSize, SetPaperSize, doc="See `GetPaperSize` and `SetPaperSize`");
241 %property(PrintData, GetPrintData, SetPrintData, doc="See `GetPrintData` and `SetPrintData`");
247 // NOTE: Contrary to it's name, this class doesn't derive from wxDialog. It
248 // is a facade in front of a platform-specific (native dialog) provided by the
251 MustHaveApp(wxPageSetupDialog);
253 class wxPageSetupDialog : public wxObject
256 wxPageSetupDialog(wxWindow* parent, wxPageSetupDialogData* data = NULL);
257 ~wxPageSetupDialog();
259 wxPageSetupDialogData& GetPageSetupData();
260 wxPageSetupDialogData& GetPageSetupDialogData();
263 %pythoncode { def Destroy(self): pass }
265 %property(PageSetupData, GetPageSetupData, doc="See `GetPageSetupData`");
266 %property(PageSetupDialogData, GetPageSetupDialogData, doc="See `GetPageSetupDialogData`");
270 //---------------------------------------------------------------------------
273 class wxPrintDialogData : public wxObject {
275 %nokwargs wxPrintDialogData;
277 wxPrintDialogData(const wxPrintData& printData);
278 wxPrintDialogData(const wxPrintDialogData& printData); // for making copies
279 ~wxPrintDialogData();
281 int GetFromPage() const;
282 int GetToPage() const;
283 int GetMinPage() const;
284 int GetMaxPage() const;
285 int GetNoCopies() const;
286 bool GetAllPages() const;
287 bool GetSelection() const;
288 bool GetCollate() const;
289 bool GetPrintToFile() const;
291 // WXWIN_COMPATIBILITY_2_4
293 bool GetSetupDialog() const;
294 void SetSetupDialog(bool flag);
296 void SetFromPage(int v);
297 void SetToPage(int v);
298 void SetMinPage(int v);
299 void SetMaxPage(int v);
300 void SetNoCopies(int v);
301 void SetAllPages(bool flag);
302 void SetSelection(bool flag);
303 void SetCollate(bool flag);
304 void SetPrintToFile(bool flag);
306 void EnablePrintToFile(bool flag);
307 void EnableSelection(bool flag);
308 void EnablePageNumbers(bool flag);
309 void EnableHelp(bool flag);
311 bool GetEnablePrintToFile() const;
312 bool GetEnableSelection() const;
313 bool GetEnablePageNumbers() const;
314 bool GetEnableHelp() const;
316 // Is this data OK for showing the print dialog?
320 wxPrintData& GetPrintData();
321 void SetPrintData(const wxPrintData& printData);
323 %pythoncode { def __nonzero__(self): return self.Ok() }
325 %property(AllPages, GetAllPages, SetAllPages, doc="See `GetAllPages` and `SetAllPages`");
326 %property(Collate, GetCollate, SetCollate, doc="See `GetCollate` and `SetCollate`");
327 // %property(EnableHelp, GetEnableHelp, doc="See `GetEnableHelp`");
328 // %property(EnablePageNumbers, GetEnablePageNumbers, doc="See `GetEnablePageNumbers`");
329 // %property(EnablePrintToFile, GetEnablePrintToFile, doc="See `GetEnablePrintToFile`");
330 // %property(EnableSelection, GetEnableSelection, doc="See `GetEnableSelection`");
331 %property(FromPage, GetFromPage, SetFromPage, doc="See `GetFromPage` and `SetFromPage`");
332 %property(MaxPage, GetMaxPage, SetMaxPage, doc="See `GetMaxPage` and `SetMaxPage`");
333 %property(MinPage, GetMinPage, SetMinPage, doc="See `GetMinPage` and `SetMinPage`");
334 %property(NoCopies, GetNoCopies, SetNoCopies, doc="See `GetNoCopies` and `SetNoCopies`");
335 %property(PrintData, GetPrintData, SetPrintData, doc="See `GetPrintData` and `SetPrintData`");
336 %property(PrintToFile, GetPrintToFile, SetPrintToFile, doc="See `GetPrintToFile` and `SetPrintToFile`");
337 %property(Selection, GetSelection, SetSelection, doc="See `GetSelection` and `SetSelection`");
338 %property(ToPage, GetToPage, SetToPage, doc="See `GetToPage` and `SetToPage`");
343 MustHaveApp(wxPrintDialog);
346 // NOTE: Contrary to it's name, this class doesn't derive from wxDialog. It
347 // is a facade in front of a platform-specific (native dialog) provided by the
350 class wxPrintDialog : public wxObject {
352 wxPrintDialog(wxWindow* parent, wxPrintDialogData* data = NULL);
354 // TODO?: wxPrintDialog(wxWindow *parent, wxPrintData* data);
358 virtual int ShowModal();
360 virtual wxPrintDialogData& GetPrintDialogData();
361 virtual wxPrintData& GetPrintData();
363 %newobject GetPrintDC;
364 virtual wxDC *GetPrintDC();
366 %pythoncode { def Destroy(self): pass }
368 %property(PrintDC, GetPrintDC, doc="See `GetPrintDC`");
369 %property(PrintData, GetPrintData, doc="See `GetPrintData`");
370 %property(PrintDialogData, GetPrintDialogData, doc="See `GetPrintDialogData`");
374 //---------------------------------------------------------------------------
375 //---------------------------------------------------------------------------
380 wxPRINTER_NO_ERROR = 0,
386 MustHaveApp(wxPrinter);
388 class wxPrinter : public wxObject {
390 wxPrinter(wxPrintDialogData* data = NULL);
393 virtual wxWindow *CreateAbortWindow(wxWindow *parent, wxPyPrintout *printout);
394 virtual void ReportError(wxWindow *parent, wxPyPrintout *printout, const wxString& message);
396 virtual bool Setup(wxWindow *parent);
397 virtual bool Print(wxWindow *parent, wxPyPrintout *printout, bool prompt = true);
398 virtual wxDC* PrintDialog(wxWindow *parent);
400 virtual wxPrintDialogData& GetPrintDialogData() const;
403 static wxPrinterError GetLastError();
405 %property(Abort, GetAbort, doc="See `GetAbort`");
406 %property(PrintDialogData, GetPrintDialogData, doc="See `GetPrintDialogData`");
410 //---------------------------------------------------------------------------
411 // Custom wxPrintout class that knows how to call python, See implementation in
412 // include/sx/wxPython/printfw.h
416 IMPLEMENT_ABSTRACT_CLASS(wxPyPrintout, wxPrintout);
418 // Since this one would be tough and ugly to do with the Macros...
419 void wxPyPrintout::GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) {
423 wxPyBlock_t blocked = wxPyBeginBlockThreads();
424 if ((found = wxPyCBH_findCallback(m_myInst, "GetPageInfo"))) {
425 PyObject* result = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));
426 if (result && PyTuple_Check(result) && PyTuple_Size(result) == 4) {
429 val = PyTuple_GetItem(result, 0);
430 if (PyInt_Check(val)) *minPage = PyInt_AsLong(val);
433 val = PyTuple_GetItem(result, 1);
434 if (PyInt_Check(val)) *maxPage = PyInt_AsLong(val);
437 val = PyTuple_GetItem(result, 2);
438 if (PyInt_Check(val)) *pageFrom = PyInt_AsLong(val);
441 val = PyTuple_GetItem(result, 3);
442 if (PyInt_Check(val)) *pageTo = PyInt_AsLong(val);
449 PyErr_SetString(PyExc_TypeError, "GetPageInfo should return a tuple of 4 integers.");
454 wxPyEndBlockThreads(blocked);
456 wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo);
461 IMP_PYCALLBACK_BOOL_INTINT(wxPyPrintout, wxPrintout, OnBeginDocument);
462 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnEndDocument);
463 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnBeginPrinting);
464 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnEndPrinting);
465 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnPreparePrinting);
466 IMP_PYCALLBACK_BOOL_INT_pure(wxPyPrintout, wxPrintout, OnPrintPage);
467 IMP_PYCALLBACK_BOOL_INT(wxPyPrintout, wxPrintout, HasPage);
473 MustHaveApp(wxPyPrintout);
475 // Now define the custom class for SWIGging
476 %rename(Printout) wxPyPrintout;
477 class wxPyPrintout : public wxObject {
479 %pythonAppend wxPyPrintout "self._setCallbackInfo(self, Printout)"
480 %typemap(out) wxPyPrintout*; // turn off this typemap
482 wxPyPrintout(const wxString& title = wxPyPrintoutTitleStr);
485 // Turn it back on again
486 %typemap(out) wxPyPrintout* { $result = wxPyMake_wxObject($1, $owner); }
488 void _setCallbackInfo(PyObject* self, PyObject* _class);
491 wxString GetTitle() const;
493 void SetDC(wxDC *dc);
495 void SetPageSizePixels(int w, int h);
497 void, GetPageSizePixels(int *OUTPUT, int *OUTPUT),
498 "GetPageSizePixels() -> (w, h)");
500 void SetPageSizeMM(int w, int h);
502 void, GetPageSizeMM(int *OUTPUT, int *OUTPUT),
503 "GetPageSizeMM() -> (w, h)");
505 void SetPPIScreen(int x, int y);
507 void, GetPPIScreen(int *OUTPUT, int *OUTPUT),
508 "GetPPIScreen() -> (x,y)");
510 void SetPPIPrinter(int x, int y);
512 void, GetPPIPrinter(int *OUTPUT, int *OUTPUT),
513 "GetPPIPrinter() -> (x,y)");
516 void SetIsPreview(bool p);
519 bool OnBeginDocument(int startPage, int endPage);
520 void OnEndDocument();
521 void OnBeginPrinting();
522 void OnEndPrinting();
523 void OnPreparePrinting();
524 bool HasPage(int page);
526 void, GetPageInfo(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT),
527 "GetPageInfo() -> (minPage, maxPage, pageFrom, pageTo)");
529 %MAKE_BASE_FUNC(Printout, OnBeginDocument);
530 %MAKE_BASE_FUNC(Printout, OnEndDocument);
531 %MAKE_BASE_FUNC(Printout, OnBeginPrinting);
532 %MAKE_BASE_FUNC(Printout, OnEndPrinting);
533 %MAKE_BASE_FUNC(Printout, OnPreparePrinting);
534 %MAKE_BASE_FUNC(Printout, GetPageInfo);
537 %property(DC, GetDC, SetDC, doc="See `GetDC` and `SetDC`");
538 %property(PPIPrinter, GetPPIPrinter, SetPPIPrinter, doc="See `GetPPIPrinter` and `SetPPIPrinter`");
539 %property(PPIScreen, GetPPIScreen, SetPPIScreen, doc="See `GetPPIScreen` and `SetPPIScreen`");
540 %property(PageSizeMM, GetPageSizeMM, SetPageSizeMM, doc="See `GetPageSizeMM` and `SetPageSizeMM`");
541 %property(PageSizePixels, GetPageSizePixels, SetPageSizePixels, doc="See `GetPageSizePixels` and `SetPageSizePixels`");
542 %property(Title, GetTitle, doc="See `GetTitle`");
545 //---------------------------------------------------------------------------
549 MustHaveApp(wxPreviewCanvas);
551 class wxPreviewCanvas: public wxScrolledWindow
554 %pythonAppend wxPreviewCanvas "self._setOORInfo(self)"
556 wxPreviewCanvas(wxPrintPreview *preview,
558 const wxPoint& pos = wxDefaultPosition,
559 const wxSize& size = wxDefaultSize,
561 const wxString& name = wxPyPreviewCanvasNameStr);
565 MustHaveApp(wxPreviewFrame);
567 class wxPreviewFrame : public wxFrame {
569 %disownarg(wxPrintPreview*);
571 %pythonAppend wxPreviewFrame "self._setOORInfo(self)"
572 wxPreviewFrame(wxPrintPreview* preview, wxFrame* parent, const wxString& title,
573 const wxPoint& pos = wxDefaultPosition,
574 const wxSize& size = wxDefaultSize,
575 long style = wxDEFAULT_FRAME_STYLE,
576 const wxString& name = wxPyFrameNameStr);
578 %cleardisown(wxPrintPreview*);
581 void CreateControlBar();
584 wxPreviewControlBar* GetControlBar() const;
586 %property(ControlBar, GetControlBar, doc="See `GetControlBar`");
603 wxID_PREVIEW_PREVIOUS,
611 MustHaveApp(wxPreviewControlBar);
613 class wxPreviewControlBar: public wxPanel
616 %pythonAppend wxPreviewControlBar "self._setOORInfo(self)"
618 wxPreviewControlBar(wxPrintPreview *preview,
621 const wxPoint& pos = wxDefaultPosition,
622 const wxSize& size = wxDefaultSize,
623 long style = wxTAB_TRAVERSAL,
624 const wxString& name = wxPyPanelNameStr);
626 int GetZoomControl();
627 void SetZoomControl(int zoom);
628 wxPrintPreview* GetPrintPreview();
636 %property(PrintPreview, GetPrintPreview, doc="See `GetPrintPreview`");
637 %property(ZoomControl, GetZoomControl, SetZoomControl, doc="See `GetZoomControl` and `SetZoomControl`");
642 //---------------------------------------------------------------------------
644 MustHaveApp(wxPrintPreview);
646 class wxPrintPreview : public wxObject {
648 %disownarg(wxPyPrintout*);
650 %nokwargs wxPrintPreview;
651 wxPrintPreview(wxPyPrintout* printout,
652 wxPyPrintout* printoutForPrinting,
653 wxPrintDialogData *data=NULL);
654 wxPrintPreview(wxPyPrintout* printout,
655 wxPyPrintout* printoutForPrinting,
660 virtual bool SetCurrentPage(int pageNum);
661 int GetCurrentPage();
663 void SetPrintout(wxPyPrintout *printout);
664 wxPyPrintout *GetPrintout();
665 wxPyPrintout *GetPrintoutForPrinting();
667 %cleardisown(wxPyPrintout*);
669 void SetFrame(wxFrame *frame);
670 void SetCanvas(wxPreviewCanvas *canvas);
672 virtual wxFrame *GetFrame();
673 virtual wxPreviewCanvas *GetCanvas();
675 // The preview canvas should call this from OnPaint
676 virtual bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc);
678 // This draws a blank page onto the preview canvas
679 virtual bool DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc);
681 // This is called by wxPrintPreview to render a page into a wxMemoryDC.
682 virtual bool RenderPage(int pageNum);
684 // Adjusts the scrollbars for the current scale
685 virtual void AdjustScrollbars(wxPreviewCanvas *canvas);
687 wxPrintDialogData& GetPrintDialogData();
689 virtual void SetZoom(int percent);
698 virtual bool Print(bool interactive);
699 virtual void DetermineScaling();
701 %pythoncode { def __nonzero__(self): return self.Ok() }
703 %property(Canvas, GetCanvas, SetCanvas, doc="See `GetCanvas` and `SetCanvas`");
704 %property(CurrentPage, GetCurrentPage, SetCurrentPage, doc="See `GetCurrentPage` and `SetCurrentPage`");
705 %property(Frame, GetFrame, SetFrame, doc="See `GetFrame` and `SetFrame`");
706 %property(MaxPage, GetMaxPage, doc="See `GetMaxPage`");
707 %property(MinPage, GetMinPage, doc="See `GetMinPage`");
708 %property(PrintDialogData, GetPrintDialogData, doc="See `GetPrintDialogData`");
709 %property(Printout, GetPrintout, SetPrintout, doc="See `GetPrintout` and `SetPrintout`");
710 %property(PrintoutForPrinting, GetPrintoutForPrinting, doc="See `GetPrintoutForPrinting`");
711 %property(Zoom, GetZoom, SetZoom, doc="See `GetZoom` and `SetZoom`");
716 //---------------------------------------------------------------------------
718 // Python-derivable versions of the above preview classes
722 #define DEC_PYCALLBACK_BOOL_PREWINDC(CBNAME) \
723 bool CBNAME(wxPreviewCanvas* a, wxDC& b)
726 #define IMP_PYCALLBACK_BOOL_PREWINDC(CLASS, PCLASS, CBNAME) \
727 bool CLASS::CBNAME(wxPreviewCanvas* a, wxDC& b) { \
730 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
731 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
732 PyObject* win = wxPyMake_wxObject(a,false); \
733 PyObject* dc = wxPyMake_wxObject(&b,false); \
734 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc)); \
738 wxPyEndBlockThreads(blocked); \
740 rval = PCLASS::CBNAME(a, b); \
747 class wxPyPrintPreview : public wxPrintPreview
749 DECLARE_CLASS(wxPyPrintPreview)
751 wxPyPrintPreview(wxPyPrintout* printout,
752 wxPyPrintout* printoutForPrinting,
753 wxPrintDialogData* data=NULL)
754 : wxPrintPreview(printout, printoutForPrinting, data)
756 wxPyPrintPreview(wxPyPrintout* printout,
757 wxPyPrintout* printoutForPrinting,
759 : wxPrintPreview(printout, printoutForPrinting, data)
762 DEC_PYCALLBACK_BOOL_INT(SetCurrentPage);
763 DEC_PYCALLBACK_BOOL_PREWINDC(PaintPage);
764 DEC_PYCALLBACK_BOOL_PREWINDC(DrawBlankPage);
765 DEC_PYCALLBACK_BOOL_INT(RenderPage);
766 DEC_PYCALLBACK_VOID_INT(SetZoom);
767 DEC_PYCALLBACK_BOOL_BOOL(Print);
768 DEC_PYCALLBACK_VOID_(DetermineScaling);
773 // Stupid renamed classes... Fix this in 2.5...
774 #if defined(__WXMSW__)
775 IMPLEMENT_CLASS( wxPyPrintPreview, wxWindowsPrintPreview );
776 #elif defined(__WXMAC__)
777 IMPLEMENT_CLASS( wxPyPrintPreview, wxMacPrintPreview );
779 IMPLEMENT_CLASS( wxPyPrintPreview, wxPostScriptPrintPreview );
782 IMP_PYCALLBACK_BOOL_INT (wxPyPrintPreview, wxPrintPreview, SetCurrentPage);
783 IMP_PYCALLBACK_BOOL_PREWINDC(wxPyPrintPreview, wxPrintPreview, PaintPage);
784 IMP_PYCALLBACK_BOOL_PREWINDC(wxPyPrintPreview, wxPrintPreview, DrawBlankPage);
785 IMP_PYCALLBACK_BOOL_INT (wxPyPrintPreview, wxPrintPreview, RenderPage);
786 IMP_PYCALLBACK_VOID_INT (wxPyPrintPreview, wxPrintPreview, SetZoom);
787 IMP_PYCALLBACK_BOOL_BOOL (wxPyPrintPreview, wxPrintPreview, Print);
788 IMP_PYCALLBACK_VOID_ (wxPyPrintPreview, wxPrintPreview, DetermineScaling);
792 MustHaveApp(wxPyPrintPreview);
794 class wxPyPrintPreview : public wxPrintPreview
797 %disownarg(wxPyPrintout*);
799 %pythonAppend wxPyPrintPreview "self._setCallbackInfo(self, PyPrintPreview)"
800 %nokwargs wxPyPrintPreview;
801 wxPyPrintPreview(wxPyPrintout* printout,
802 wxPyPrintout* printoutForPrinting,
803 wxPrintDialogData* data=NULL);
804 wxPyPrintPreview(wxPyPrintout* printout,
805 wxPyPrintout* printoutForPrinting,
808 %cleardisown(wxPyPrintout*);
810 void _setCallbackInfo(PyObject* self, PyObject* _class);
812 bool SetCurrentPage(int pageNum);
813 bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc);
814 bool DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc);
815 bool RenderPage(int pageNum);
816 void SetZoom(int percent);
817 bool Print(bool interactive);
818 void DetermineScaling();
820 %MAKE_BASE_FUNC(PyPrintPreview, SetCurrentPage);
821 %MAKE_BASE_FUNC(PyPrintPreview, PaintPage);
822 %MAKE_BASE_FUNC(PyPrintPreview, DrawBlankPage);
823 %MAKE_BASE_FUNC(PyPrintPreview, RenderPage);
824 %MAKE_BASE_FUNC(PyPrintPreview, SetZoom);
825 %MAKE_BASE_FUNC(PyPrintPreview, Print);
826 %MAKE_BASE_FUNC(PyPrintPreview, DetermineScaling);
833 class wxPyPreviewFrame : public wxPreviewFrame
835 DECLARE_CLASS(wxPyPreviewFrame)
837 wxPyPreviewFrame(wxPrintPreview* preview, wxFrame* parent,
838 const wxString& title,
839 const wxPoint& pos = wxDefaultPosition,
840 const wxSize& size = wxDefaultSize,
841 long style = wxDEFAULT_FRAME_STYLE,
842 const wxString& name = wxPyFrameNameStr)
843 : wxPreviewFrame(preview, parent, title, pos, size, style, name)
846 void SetPreviewCanvas(wxPreviewCanvas* canvas) { m_previewCanvas = canvas; }
847 void SetControlBar(wxPreviewControlBar* bar) { m_controlBar = bar; }
849 DEC_PYCALLBACK_VOID_(Initialize);
850 DEC_PYCALLBACK_VOID_(CreateCanvas);
851 DEC_PYCALLBACK_VOID_(CreateControlBar);
856 IMPLEMENT_CLASS(wxPyPreviewFrame, wxPreviewFrame);
858 IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, Initialize);
859 IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, CreateCanvas);
860 IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, CreateControlBar);
864 MustHaveApp(wxPyPreviewFrame);
866 class wxPyPreviewFrame : public wxPreviewFrame
869 %pythonAppend wxPyPreviewFrame "self._setCallbackInfo(self, PyPreviewFrame); self._setOORInfo(self)"
871 wxPyPreviewFrame(wxPrintPreview* preview, wxFrame* parent,
872 const wxString& title,
873 const wxPoint& pos = wxDefaultPosition,
874 const wxSize& size = wxDefaultSize,
875 long style = wxDEFAULT_FRAME_STYLE,
876 const wxString& name = wxPyFrameNameStr);
878 void _setCallbackInfo(PyObject* self, PyObject* _class);
880 void SetPreviewCanvas(wxPreviewCanvas* canvas);
881 void SetControlBar(wxPreviewControlBar* bar);
885 void CreateControlBar();
887 %MAKE_BASE_FUNC(PyPreviewFrame, Initialize);
888 %MAKE_BASE_FUNC(PyPreviewFrame, CreateCanvas);
889 %MAKE_BASE_FUNC(PyPreviewFrame, CreateControlBar);
896 class wxPyPreviewControlBar : public wxPreviewControlBar
898 DECLARE_CLASS(wxPyPreviewControlBar)
900 wxPyPreviewControlBar(wxPrintPreview *preview,
903 const wxPoint& pos = wxDefaultPosition,
904 const wxSize& size = wxDefaultSize,
906 const wxString& name = wxPyPanelNameStr)
907 : wxPreviewControlBar(preview, buttons, parent, pos, size, style, name)
910 void SetPrintPreview(wxPrintPreview* preview) { m_printPreview = preview; }
912 DEC_PYCALLBACK_VOID_(CreateButtons);
913 DEC_PYCALLBACK_VOID_INT(SetZoomControl);
918 IMPLEMENT_CLASS(wxPyPreviewControlBar, wxPreviewControlBar);
919 IMP_PYCALLBACK_VOID_(wxPyPreviewControlBar, wxPreviewControlBar, CreateButtons);
920 IMP_PYCALLBACK_VOID_INT(wxPyPreviewControlBar, wxPreviewControlBar, SetZoomControl);
924 MustHaveApp(wxPyPreviewControlBar);
926 class wxPyPreviewControlBar : public wxPreviewControlBar
929 %pythonAppend wxPyPreviewControlBar "self._setCallbackInfo(self, PyPreviewControlBar); self._setOORInfo(self)"
931 wxPyPreviewControlBar(wxPrintPreview *preview,
934 const wxPoint& pos = wxDefaultPosition,
935 const wxSize& size = wxDefaultSize,
937 const wxString& name = wxPyPanelNameStr);
939 void _setCallbackInfo(PyObject* self, PyObject* _class);
941 void SetPrintPreview(wxPrintPreview* preview);
943 void CreateButtons();
944 void SetZoomControl(int zoom);
946 %MAKE_BASE_FUNC(PreviewControlBar, CreateButtons);
947 %MAKE_BASE_FUNC(PreviewControlBar, SetZoomControl);
950 //---------------------------------------------------------------------------
951 //---------------------------------------------------------------------------
953 wxPyPtrTypeMap_Add("wxPrintout", "wxPyPrintout");
955 //---------------------------------------------------------------------------