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
 
  74     %pythoncode { Ok = IsOk }
 
  76     const wxString& GetPrinterName();
 
  78     wxDuplexMode GetDuplex();
 
  79     wxPaperSize GetPaperId();
 
  80     const wxSize& GetPaperSize();
 
  84     wxPrintMode GetPrintMode() const;
 
  86     void SetNoCopies(int v);
 
  87     void SetCollate(bool flag);
 
  88     void SetOrientation(int orient);
 
  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);
 
  95     void SetQuality(int quality);
 
  96     void SetBin(wxPrintBin bin);
 
  97     void SetPrintMode(wxPrintMode printMode);
 
  99     wxString GetFilename() const;
 
 100     void SetFilename( const wxString &filename );
 
 102     %pythoncode { def __nonzero__(self): return self.IsOk() }
 
 104     //char* GetPrivData() const;
 
 105     //int GetPrivDataLen() const;
 
 106     //void SetPrivData( char *privData, int len );
 
 109         PyObject* GetPrivData() {
 
 111             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 112             data = PyString_FromStringAndSize(self->GetPrivData(),
 
 113                                               self->GetPrivDataLen());
 
 114             wxPyEndBlockThreads(blocked);
 
 118         void SetPrivData(PyObject* data) {
 
 119             if (! PyString_Check(data)) {
 
 120                 wxPyBLOCK_THREADS(PyErr_SetString(PyExc_TypeError,
 
 121                                                   "Expected string object"));
 
 125             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 126             self->SetPrivData(PyString_AS_STRING(data), PyString_GET_SIZE(data));
 
 127             wxPyEndBlockThreads(blocked);
 
 132     // NOTE: These are now inside of #if WXWIN_COMPATIBILITY_2_4, so be
 
 133     //       prepared to remove them...
 
 135     // PostScript-specific data
 
 136 // WXWIN_COMPATIBILITY_2_4
 
 138     const wxString& GetPrinterCommand();
 
 139     const wxString& GetPrinterOptions();
 
 140     const wxString& GetPreviewCommand();
 
 141     const wxString& GetFontMetricPath();
 
 142     double GetPrinterScaleX();
 
 143     double GetPrinterScaleY();
 
 144     long GetPrinterTranslateX();
 
 145     long GetPrinterTranslateY();
 
 146     void SetPrinterCommand(const wxString& command);
 
 147     void SetPrinterOptions(const wxString& options);
 
 148     void SetPreviewCommand(const wxString& command);
 
 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);
 
 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`");   
 
 173 //---------------------------------------------------------------------------
 
 175 class wxPageSetupDialogData : public wxObject {
 
 177     %nokwargs wxPageSetupDialogData;
 
 178     wxPageSetupDialogData();
 
 179     wxPageSetupDialogData(const wxPageSetupDialogData& data);  // for making copies
 
 180     wxPageSetupDialogData(const wxPrintData& data); 
 
 181     ~wxPageSetupDialogData();
 
 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);
 
 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();
 
 203     wxPrintData& GetPrintData();
 
 206     %pythoncode { Ok = IsOk }
 
 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);
 
 214     void SetPaperId(wxPaperSize id);
 
 215     void SetPaperSize(const wxSize& size);
 
 217     void SetPrintData(const wxPrintData& printData);
 
 219     // Use paper size defined in this object to set the wxPrintData
 
 221     void CalculateIdFromPaperSize();
 
 223     // Use paper id in wxPrintData to set this object's paper size
 
 224     void CalculatePaperSizeFromId();
 
 226     %pythoncode { def __nonzero__(self): return self.IsOk() }
 
 228     %property(DefaultInfo, GetDefaultInfo, SetDefaultInfo, doc="See `GetDefaultInfo` and `SetDefaultInfo`");
 
 229     %property(DefaultMinMargins, GetDefaultMinMargins, SetDefaultMinMargins, doc="See `GetDefaultMinMargins` and `SetDefaultMinMargins`");
 
 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`");
 
 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`");
 
 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
 
 253 MustHaveApp(wxPageSetupDialog);
 
 255 class wxPageSetupDialog : public wxObject
 
 258     wxPageSetupDialog(wxWindow* parent, wxPageSetupDialogData* data = NULL);
 
 259     ~wxPageSetupDialog();
 
 261     wxPageSetupDialogData& GetPageSetupData();
 
 262     wxPageSetupDialogData& GetPageSetupDialogData();
 
 265     %pythoncode { def Destroy(self): pass }
 
 267     %property(PageSetupData, GetPageSetupData, doc="See `GetPageSetupData`");
 
 268     %property(PageSetupDialogData, GetPageSetupDialogData, doc="See `GetPageSetupDialogData`");
 
 272 //---------------------------------------------------------------------------
 
 275 class wxPrintDialogData : public wxObject {
 
 277     %nokwargs wxPrintDialogData;
 
 279     wxPrintDialogData(const wxPrintData& printData);
 
 280     wxPrintDialogData(const wxPrintDialogData& printData);  // for making copies
 
 281     ~wxPrintDialogData();
 
 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;
 
 293     // WXWIN_COMPATIBILITY_2_4
 
 295     bool GetSetupDialog() const;
 
 296     void SetSetupDialog(bool flag);
 
 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);
 
 308     void EnablePrintToFile(bool flag);
 
 309     void EnableSelection(bool flag);
 
 310     void EnablePageNumbers(bool flag);
 
 311     void EnableHelp(bool flag);
 
 313     bool GetEnablePrintToFile() const;
 
 314     bool GetEnableSelection() const;
 
 315     bool GetEnablePageNumbers() const;
 
 316     bool GetEnableHelp() const;
 
 318     // Is this data OK for showing the print dialog?
 
 320     %pythoncode { Ok = IsOk }
 
 323     wxPrintData& GetPrintData();
 
 324     void SetPrintData(const wxPrintData& printData);
 
 326     %pythoncode { def __nonzero__(self): return self.IsOk() }
 
 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`");
 
 346 MustHaveApp(wxPrintDialog);
 
 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
 
 353 class wxPrintDialog : public wxObject {
 
 355     wxPrintDialog(wxWindow* parent, wxPrintDialogData* data = NULL);
 
 357     // TODO?: wxPrintDialog(wxWindow *parent, wxPrintData* data);
 
 361     virtual int ShowModal();
 
 363     virtual wxPrintDialogData& GetPrintDialogData();
 
 364     virtual wxPrintData& GetPrintData();
 
 366     %newobject GetPrintDC;
 
 367     virtual wxDC *GetPrintDC();
 
 369     %pythoncode { def Destroy(self): pass }
 
 371     %property(PrintDC, GetPrintDC, doc="See `GetPrintDC`");
 
 372     %property(PrintData, GetPrintData, doc="See `GetPrintData`");
 
 373     %property(PrintDialogData, GetPrintDialogData, doc="See `GetPrintDialogData`");
 
 377 //---------------------------------------------------------------------------
 
 378 //---------------------------------------------------------------------------
 
 383     wxPRINTER_NO_ERROR = 0,
 
 389 MustHaveApp(wxPrinter);
 
 391 class wxPrinter : public wxObject {
 
 393     wxPrinter(wxPrintDialogData* data = NULL);
 
 396     virtual wxWindow *CreateAbortWindow(wxWindow *parent, wxPyPrintout *printout);
 
 397     virtual void ReportError(wxWindow *parent, wxPyPrintout *printout, const wxString& message);
 
 399     virtual bool Setup(wxWindow *parent);
 
 400     virtual bool Print(wxWindow *parent, wxPyPrintout *printout, bool prompt = true);
 
 401     virtual wxDC* PrintDialog(wxWindow *parent);
 
 403     virtual wxPrintDialogData& GetPrintDialogData() const;
 
 406     static wxPrinterError GetLastError();
 
 408     %property(Abort, GetAbort, doc="See `GetAbort`");
 
 409     %property(PrintDialogData, GetPrintDialogData, doc="See `GetPrintDialogData`");
 
 413 //---------------------------------------------------------------------------
 
 414 // Custom wxPrintout class that knows how to call python, See implementation in
 
 415 // include/sx/wxPython/printfw.h
 
 419 IMPLEMENT_ABSTRACT_CLASS(wxPyPrintout, wxPrintout);
 
 421 // Since this one would be tough and ugly to do with the Macros...
 
 422 void wxPyPrintout::GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) {
 
 426     wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 427     if ((found = wxPyCBH_findCallback(m_myInst, "GetPageInfo"))) {
 
 428         PyObject* result = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));
 
 429         if (result && PyTuple_Check(result) && PyTuple_Size(result) == 4) {
 
 432             val = PyTuple_GetItem(result, 0);
 
 433             if (PyInt_Check(val))    *minPage = PyInt_AsLong(val);
 
 436             val = PyTuple_GetItem(result, 1);
 
 437             if (PyInt_Check(val))    *maxPage = PyInt_AsLong(val);
 
 440             val = PyTuple_GetItem(result, 2);
 
 441             if (PyInt_Check(val))    *pageFrom = PyInt_AsLong(val);
 
 444             val = PyTuple_GetItem(result, 3);
 
 445             if (PyInt_Check(val))    *pageTo = PyInt_AsLong(val);
 
 452             PyErr_SetString(PyExc_TypeError, "GetPageInfo should return a tuple of 4 integers.");
 
 457     wxPyEndBlockThreads(blocked);
 
 459         wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo);
 
 464 IMP_PYCALLBACK_BOOL_INTINT(wxPyPrintout, wxPrintout, OnBeginDocument);
 
 465 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnEndDocument);
 
 466 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnBeginPrinting);
 
 467 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnEndPrinting);
 
 468 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnPreparePrinting);
 
 469 IMP_PYCALLBACK_BOOL_INT_pure(wxPyPrintout, wxPrintout, OnPrintPage);
 
 470 IMP_PYCALLBACK_BOOL_INT(wxPyPrintout, wxPrintout, HasPage);
 
 476 MustHaveApp(wxPyPrintout);
 
 478 // Now define the custom class for SWIGging
 
 479 %rename(Printout) wxPyPrintout;
 
 480 class wxPyPrintout  : public wxObject {
 
 482     %pythonAppend wxPyPrintout   "self._setCallbackInfo(self, Printout)"
 
 483     %typemap(out) wxPyPrintout*;    // turn off this typemap
 
 485     wxPyPrintout(const wxString& title = wxPyPrintoutTitleStr);
 
 488     // Turn it back on again
 
 489     %typemap(out) wxPyPrintout* { $result = wxPyMake_wxObject($1, $owner); }
 
 491     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 494     wxString GetTitle() const;
 
 496     void SetDC(wxDC *dc);
 
 498     void SetPageSizePixels(int w, int  h);
 
 500         void, GetPageSizePixels(int *OUTPUT, int *OUTPUT),
 
 501         "GetPageSizePixels() -> (w, h)");
 
 503     void SetPageSizeMM(int w, int  h);
 
 505         void, GetPageSizeMM(int *OUTPUT, int *OUTPUT),
 
 506         "GetPageSizeMM() -> (w, h)");
 
 508     void SetPPIScreen(int x, int y);
 
 510         void, GetPPIScreen(int *OUTPUT, int *OUTPUT),
 
 511         "GetPPIScreen() -> (x,y)");
 
 513     void SetPPIPrinter(int x, int y);
 
 515         void, GetPPIPrinter(int *OUTPUT, int *OUTPUT),
 
 516         "GetPPIPrinter() -> (x,y)");
 
 519     void SetIsPreview(bool p);
 
 522     bool OnBeginDocument(int startPage, int endPage);
 
 523     void OnEndDocument();
 
 524     void OnBeginPrinting();
 
 525     void OnEndPrinting();
 
 526     void OnPreparePrinting();
 
 527     bool HasPage(int page);
 
 529         void, GetPageInfo(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT),
 
 530         "GetPageInfo() -> (minPage, maxPage, pageFrom, pageTo)");
 
 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);
 
 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`");
 
 548 //---------------------------------------------------------------------------
 
 552 MustHaveApp(wxPreviewCanvas);
 
 554 class wxPreviewCanvas: public wxScrolledWindow
 
 557     %pythonAppend wxPreviewCanvas   "self._setOORInfo(self)"
 
 559     wxPreviewCanvas(wxPrintPreview *preview,
 
 561                     const wxPoint& pos = wxDefaultPosition,
 
 562                     const wxSize& size = wxDefaultSize,
 
 564                     const wxString& name = wxPyPreviewCanvasNameStr);
 
 568 MustHaveApp(wxPreviewFrame);
 
 570 class wxPreviewFrame : public wxFrame {
 
 572     %disownarg(wxPrintPreview*);
 
 574     %pythonAppend wxPreviewFrame   "self._setOORInfo(self)"
 
 575     wxPreviewFrame(wxPrintPreview* preview, wxFrame* parent, const wxString& title,
 
 576                    const wxPoint& pos = wxDefaultPosition,
 
 577                    const wxSize&  size = wxDefaultSize,
 
 578                    long style = wxDEFAULT_FRAME_STYLE,
 
 579                    const wxString& name = wxPyFrameNameStr);
 
 581     %cleardisown(wxPrintPreview*);
 
 584     void CreateControlBar();
 
 587     wxPreviewControlBar* GetControlBar() const;
 
 589     %property(ControlBar, GetControlBar, doc="See `GetControlBar`");
 
 606     wxID_PREVIEW_PREVIOUS,
 
 614 MustHaveApp(wxPreviewControlBar);
 
 616 class wxPreviewControlBar: public wxPanel
 
 619     %pythonAppend wxPreviewControlBar   "self._setOORInfo(self)"
 
 621     wxPreviewControlBar(wxPrintPreview *preview,
 
 624                         const wxPoint& pos = wxDefaultPosition,
 
 625                         const wxSize& size = wxDefaultSize,
 
 626                         long style = wxTAB_TRAVERSAL,
 
 627                         const wxString& name = wxPyPanelNameStr);
 
 629     int GetZoomControl();
 
 630     void SetZoomControl(int zoom);
 
 631     wxPrintPreview* GetPrintPreview();
 
 639     %property(PrintPreview, GetPrintPreview, doc="See `GetPrintPreview`");
 
 640     %property(ZoomControl, GetZoomControl, SetZoomControl, doc="See `GetZoomControl` and `SetZoomControl`");    
 
 645 //---------------------------------------------------------------------------
 
 647 MustHaveApp(wxPrintPreview);
 
 649 class wxPrintPreview : public wxObject {
 
 651     %disownarg(wxPyPrintout*);
 
 653     %nokwargs wxPrintPreview;
 
 654     wxPrintPreview(wxPyPrintout* printout,
 
 655                    wxPyPrintout* printoutForPrinting,
 
 656                    wxPrintDialogData *data=NULL);
 
 657     wxPrintPreview(wxPyPrintout* printout,
 
 658                   wxPyPrintout* printoutForPrinting,
 
 663     virtual bool SetCurrentPage(int pageNum);
 
 664     int GetCurrentPage();
 
 666     void SetPrintout(wxPyPrintout *printout);
 
 667     wxPyPrintout *GetPrintout();
 
 668     wxPyPrintout *GetPrintoutForPrinting();
 
 670     %cleardisown(wxPyPrintout*);
 
 672     void SetFrame(wxFrame *frame);
 
 673     void SetCanvas(wxPreviewCanvas *canvas);
 
 675     virtual wxFrame *GetFrame();
 
 676     virtual wxPreviewCanvas *GetCanvas();
 
 678     // The preview canvas should call this from OnPaint
 
 679     virtual bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc);
 
 681     // This draws a blank page onto the preview canvas
 
 682     virtual bool DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc);
 
 684     // This is called by wxPrintPreview to render a page into a wxMemoryDC.
 
 685     virtual bool RenderPage(int pageNum);
 
 687     // Adjusts the scrollbars for the current scale
 
 688     virtual void AdjustScrollbars(wxPreviewCanvas *canvas);
 
 690     wxPrintDialogData& GetPrintDialogData();
 
 692     virtual void SetZoom(int percent);
 
 699     %pythoncode { Ok = IsOk }
 
 702     virtual bool Print(bool interactive);
 
 703     virtual void DetermineScaling();
 
 705     %pythoncode { def __nonzero__(self): return self.IsOk() }
 
 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`");
 
 720 //---------------------------------------------------------------------------
 
 722 // Python-derivable versions of the above preview classes
 
 726 #define DEC_PYCALLBACK_BOOL_PREWINDC(CBNAME)                                            \
 
 727     bool CBNAME(wxPreviewCanvas* a, wxDC& b)
 
 730 #define IMP_PYCALLBACK_BOOL_PREWINDC(CLASS, PCLASS, CBNAME)                             \
 
 731     bool CLASS::CBNAME(wxPreviewCanvas* a, wxDC& b) {                                   \
 
 734         wxPyBlock_t blocked = wxPyBeginBlockThreads();                                  \
 
 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));      \
 
 742         wxPyEndBlockThreads(blocked);                                                   \
 
 744             rval = PCLASS::CBNAME(a, b);                                                \
 
 751 class wxPyPrintPreview : public wxPrintPreview
 
 753     DECLARE_CLASS(wxPyPrintPreview)
 
 755     wxPyPrintPreview(wxPyPrintout* printout,
 
 756                      wxPyPrintout* printoutForPrinting,
 
 757                      wxPrintDialogData* data=NULL)
 
 758         : wxPrintPreview(printout, printoutForPrinting, data)
 
 760     wxPyPrintPreview(wxPyPrintout* printout,
 
 761                      wxPyPrintout* printoutForPrinting,
 
 763         : wxPrintPreview(printout, printoutForPrinting, data)
 
 766     DEC_PYCALLBACK_BOOL_INT(SetCurrentPage);
 
 767     DEC_PYCALLBACK_BOOL_PREWINDC(PaintPage);
 
 768     DEC_PYCALLBACK_BOOL_PREWINDC(DrawBlankPage);
 
 769     DEC_PYCALLBACK_BOOL_INT(RenderPage);
 
 770     DEC_PYCALLBACK_VOID_INT(SetZoom);
 
 771     DEC_PYCALLBACK_BOOL_BOOL(Print);
 
 772     DEC_PYCALLBACK_VOID_(DetermineScaling);
 
 777 // Stupid renamed classes...  Fix this in 2.5...
 
 778 #if defined(__WXMSW__)
 
 779 IMPLEMENT_CLASS( wxPyPrintPreview, wxWindowsPrintPreview );
 
 780 #elif defined(__WXMAC__)
 
 781 IMPLEMENT_CLASS( wxPyPrintPreview, wxMacPrintPreview );
 
 783 IMPLEMENT_CLASS( wxPyPrintPreview, wxPostScriptPrintPreview );
 
 786 IMP_PYCALLBACK_BOOL_INT     (wxPyPrintPreview, wxPrintPreview, SetCurrentPage);
 
 787 IMP_PYCALLBACK_BOOL_PREWINDC(wxPyPrintPreview, wxPrintPreview, PaintPage);
 
 788 IMP_PYCALLBACK_BOOL_PREWINDC(wxPyPrintPreview, wxPrintPreview, DrawBlankPage);
 
 789 IMP_PYCALLBACK_BOOL_INT     (wxPyPrintPreview, wxPrintPreview, RenderPage);
 
 790 IMP_PYCALLBACK_VOID_INT     (wxPyPrintPreview, wxPrintPreview, SetZoom);
 
 791 IMP_PYCALLBACK_BOOL_BOOL    (wxPyPrintPreview, wxPrintPreview, Print);
 
 792 IMP_PYCALLBACK_VOID_        (wxPyPrintPreview, wxPrintPreview, DetermineScaling);
 
 796 MustHaveApp(wxPyPrintPreview);
 
 798 class wxPyPrintPreview : public wxPrintPreview
 
 801     %disownarg(wxPyPrintout*);
 
 803     %pythonAppend wxPyPrintPreview   "self._setCallbackInfo(self, PyPrintPreview)"
 
 804     %nokwargs wxPyPrintPreview;
 
 805     wxPyPrintPreview(wxPyPrintout* printout,
 
 806                      wxPyPrintout* printoutForPrinting,
 
 807                      wxPrintDialogData* data=NULL);
 
 808     wxPyPrintPreview(wxPyPrintout* printout,
 
 809                      wxPyPrintout* printoutForPrinting,
 
 812     %cleardisown(wxPyPrintout*);
 
 814     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 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();
 
 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);
 
 837 class wxPyPreviewFrame : public wxPreviewFrame
 
 839     DECLARE_CLASS(wxPyPreviewFrame)
 
 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)
 
 850     void SetPreviewCanvas(wxPreviewCanvas* canvas) { m_previewCanvas = canvas; }
 
 851     void SetControlBar(wxPreviewControlBar* bar) { m_controlBar = bar; }
 
 853     DEC_PYCALLBACK_VOID_(Initialize);
 
 854     DEC_PYCALLBACK_VOID_(CreateCanvas);
 
 855     DEC_PYCALLBACK_VOID_(CreateControlBar);
 
 860 IMPLEMENT_CLASS(wxPyPreviewFrame, wxPreviewFrame);
 
 862 IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, Initialize);
 
 863 IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, CreateCanvas);
 
 864 IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, CreateControlBar);
 
 868 MustHaveApp(wxPyPreviewFrame);
 
 870 class wxPyPreviewFrame : public wxPreviewFrame
 
 873     %pythonAppend wxPyPreviewFrame "self._setCallbackInfo(self, PyPreviewFrame); self._setOORInfo(self)"
 
 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);
 
 882     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 884     void SetPreviewCanvas(wxPreviewCanvas* canvas);
 
 885     void SetControlBar(wxPreviewControlBar* bar);
 
 889     void CreateControlBar();
 
 891     %MAKE_BASE_FUNC(PyPreviewFrame, Initialize);
 
 892     %MAKE_BASE_FUNC(PyPreviewFrame, CreateCanvas);
 
 893     %MAKE_BASE_FUNC(PyPreviewFrame, CreateControlBar);
 
 900 class wxPyPreviewControlBar : public wxPreviewControlBar
 
 902     DECLARE_CLASS(wxPyPreviewControlBar)
 
 904     wxPyPreviewControlBar(wxPrintPreview *preview,
 
 907                           const wxPoint& pos = wxDefaultPosition,
 
 908                           const wxSize& size = wxDefaultSize,
 
 910                           const wxString& name = wxPyPanelNameStr)
 
 911         : wxPreviewControlBar(preview, buttons, parent, pos, size, style, name)
 
 914     void SetPrintPreview(wxPrintPreview* preview) { m_printPreview = preview; }
 
 916     DEC_PYCALLBACK_VOID_(CreateButtons);
 
 917     DEC_PYCALLBACK_VOID_INT(SetZoomControl);
 
 922 IMPLEMENT_CLASS(wxPyPreviewControlBar, wxPreviewControlBar);
 
 923 IMP_PYCALLBACK_VOID_(wxPyPreviewControlBar, wxPreviewControlBar, CreateButtons);
 
 924 IMP_PYCALLBACK_VOID_INT(wxPyPreviewControlBar, wxPreviewControlBar, SetZoomControl);
 
 928 MustHaveApp(wxPyPreviewControlBar);
 
 930 class wxPyPreviewControlBar : public wxPreviewControlBar
 
 933     %pythonAppend wxPyPreviewControlBar   "self._setCallbackInfo(self, PyPreviewControlBar); self._setOORInfo(self)"
 
 935     wxPyPreviewControlBar(wxPrintPreview *preview,
 
 938                           const wxPoint& pos = wxDefaultPosition,
 
 939                           const wxSize& size = wxDefaultSize,
 
 941                           const wxString& name = wxPyPanelNameStr);
 
 943     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 945     void SetPrintPreview(wxPrintPreview* preview);
 
 947     void CreateButtons();
 
 948     void SetZoomControl(int zoom);
 
 950     %MAKE_BASE_FUNC(PreviewControlBar, CreateButtons);
 
 951     %MAKE_BASE_FUNC(PreviewControlBar, SetZoomControl);
 
 954 //---------------------------------------------------------------------------
 
 955 //---------------------------------------------------------------------------
 
 957     wxPyPtrTypeMap_Add("wxPrintout", "wxPyPrintout");
 
 959 //---------------------------------------------------------------------------