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;
 
  87     void SetNoCopies(int v);
 
  88     void SetCollate(bool flag);
 
  89     void SetOrientation(int orient);
 
  91     void SetPrinterName(const wxString& name);
 
  92     void SetColour(bool colour);
 
  93     void SetDuplex(wxDuplexMode duplex);
 
  94     void SetPaperId(wxPaperSize sizeId);
 
  95     void SetPaperSize(const wxSize& sz);
 
  96     void SetQuality(int quality);
 
  97     void SetBin(wxPrintBin bin);
 
  98     void SetPrintMode(wxPrintMode printMode);
 
  99     void SetMedia(int media);
 
 101     wxString GetFilename() const;
 
 102     void SetFilename( const wxString &filename );
 
 104     %pythoncode { def __nonzero__(self): return self.IsOk() }
 
 106     //char* GetPrivData() const;
 
 107     //int GetPrivDataLen() const;
 
 108     //void SetPrivData( char *privData, int len );
 
 111         PyObject* GetPrivData() {
 
 113             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 114             data = PyString_FromStringAndSize(self->GetPrivData(),
 
 115                                               self->GetPrivDataLen());
 
 116             wxPyEndBlockThreads(blocked);
 
 120         void SetPrivData(PyObject* data) {
 
 121             if (! PyString_Check(data)) {
 
 122                 wxPyBLOCK_THREADS(PyErr_SetString(PyExc_TypeError,
 
 123                                                   "Expected string object"));
 
 127             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 128             self->SetPrivData(PyString_AS_STRING(data), PyString_GET_SIZE(data));
 
 129             wxPyEndBlockThreads(blocked);
 
 134     // NOTE: These are now inside of #if WXWIN_COMPATIBILITY_2_4, so be
 
 135     //       prepared to remove them...
 
 137     // PostScript-specific data
 
 138 // WXWIN_COMPATIBILITY_2_4
 
 140     const wxString& GetPrinterCommand();
 
 141     const wxString& GetPrinterOptions();
 
 142     const wxString& GetPreviewCommand();
 
 143     const wxString& GetFontMetricPath();
 
 144     double GetPrinterScaleX();
 
 145     double GetPrinterScaleY();
 
 146     long GetPrinterTranslateX();
 
 147     long GetPrinterTranslateY();
 
 148     void SetPrinterCommand(const wxString& command);
 
 149     void SetPrinterOptions(const wxString& options);
 
 150     void SetPreviewCommand(const wxString& command);
 
 151     void SetFontMetricPath(const wxString& path);
 
 152     void SetPrinterScaleX(double x);
 
 153     void SetPrinterScaleY(double y);
 
 154     void SetPrinterScaling(double x, double y);
 
 155     void SetPrinterTranslateX(long x);
 
 156     void SetPrinterTranslateY(long y);
 
 157     void SetPrinterTranslation(long x, long y);
 
 160     %property(Bin, GetBin, SetBin, doc="See `GetBin` and `SetBin`");
 
 161     %property(Collate, GetCollate, SetCollate, doc="See `GetCollate` and `SetCollate`");
 
 162     %property(Colour, GetColour, SetColour, doc="See `GetColour` and `SetColour`");
 
 163     %property(Duplex, GetDuplex, SetDuplex, doc="See `GetDuplex` and `SetDuplex`");
 
 164     %property(Filename, GetFilename, SetFilename, doc="See `GetFilename` and `SetFilename`");
 
 165     %property(NoCopies, GetNoCopies, SetNoCopies, doc="See `GetNoCopies` and `SetNoCopies`");
 
 166     %property(Orientation, GetOrientation, SetOrientation, doc="See `GetOrientation` and `SetOrientation`");
 
 167     %property(PaperId, GetPaperId, SetPaperId, doc="See `GetPaperId` and `SetPaperId`");
 
 168     %property(PaperSize, GetPaperSize, SetPaperSize, doc="See `GetPaperSize` and `SetPaperSize`");
 
 169     %property(PrintMode, GetPrintMode, SetPrintMode, doc="See `GetPrintMode` and `SetPrintMode`");
 
 170     %property(PrinterName, GetPrinterName, SetPrinterName, doc="See `GetPrinterName` and `SetPrinterName`");
 
 171     %property(PrivData, GetPrivData, SetPrivData, doc="See `GetPrivData` and `SetPrivData`");
 
 172     %property(Quality, GetQuality, SetQuality, doc="See `GetQuality` and `SetQuality`");   
 
 175 //---------------------------------------------------------------------------
 
 177 class wxPageSetupDialogData : public wxObject {
 
 179     %nokwargs wxPageSetupDialogData;
 
 180     wxPageSetupDialogData();
 
 181     wxPageSetupDialogData(const wxPageSetupDialogData& data);  // for making copies
 
 182     wxPageSetupDialogData(const wxPrintData& data); 
 
 183     ~wxPageSetupDialogData();
 
 185     void EnableHelp(bool flag);
 
 186     void EnableMargins(bool flag);
 
 187     void EnableOrientation(bool flag);
 
 188     void EnablePaper(bool flag);
 
 189     void EnablePrinter(bool flag);
 
 191     bool GetDefaultMinMargins();
 
 192     bool GetEnableMargins();
 
 193     bool GetEnableOrientation();
 
 194     bool GetEnablePaper();
 
 195     bool GetEnablePrinter();
 
 196     bool GetEnableHelp();
 
 197     bool GetDefaultInfo();
 
 198     wxPoint GetMarginTopLeft();
 
 199     wxPoint GetMarginBottomRight();
 
 200     wxPoint GetMinMarginTopLeft();
 
 201     wxPoint GetMinMarginBottomRight();
 
 202     wxPaperSize GetPaperId();
 
 203     wxSize GetPaperSize();
 
 205     wxPrintData& GetPrintData();
 
 208     %pythoncode { Ok = IsOk }
 
 210     void SetDefaultInfo(bool flag);
 
 211     void SetDefaultMinMargins(bool flag);
 
 212     void SetMarginTopLeft(const wxPoint& pt);
 
 213     void SetMarginBottomRight(const wxPoint& pt);
 
 214     void SetMinMarginTopLeft(const wxPoint& pt);
 
 215     void SetMinMarginBottomRight(const wxPoint& pt);
 
 216     void SetPaperId(wxPaperSize id);
 
 217     void SetPaperSize(const wxSize& size);
 
 219     void SetPrintData(const wxPrintData& printData);
 
 221     // Use paper size defined in this object to set the wxPrintData
 
 223     void CalculateIdFromPaperSize();
 
 225     // Use paper id in wxPrintData to set this object's paper size
 
 226     void CalculatePaperSizeFromId();
 
 228     %pythoncode { def __nonzero__(self): return self.IsOk() }
 
 230     %property(DefaultInfo, GetDefaultInfo, SetDefaultInfo, doc="See `GetDefaultInfo` and `SetDefaultInfo`");
 
 231     %property(DefaultMinMargins, GetDefaultMinMargins, SetDefaultMinMargins, doc="See `GetDefaultMinMargins` and `SetDefaultMinMargins`");
 
 233 //     %property(EnableHelp, GetEnableHelp, doc="See `GetEnableHelp`");
 
 234 //     %property(EnableMargins, GetEnableMargins, doc="See `GetEnableMargins`");
 
 235 //     %property(EnableOrientation, GetEnableOrientation, doc="See `GetEnableOrientation`");
 
 236 //     %property(EnablePaper, GetEnablePaper, doc="See `GetEnablePaper`");
 
 237 //     %property(EnablePrinter, GetEnablePrinter, doc="See `GetEnablePrinter`");
 
 239     %property(MarginBottomRight, GetMarginBottomRight, SetMarginBottomRight, doc="See `GetMarginBottomRight` and `SetMarginBottomRight`");
 
 240     %property(MarginTopLeft, GetMarginTopLeft, SetMarginTopLeft, doc="See `GetMarginTopLeft` and `SetMarginTopLeft`");
 
 241     %property(MinMarginBottomRight, GetMinMarginBottomRight, SetMinMarginBottomRight, doc="See `GetMinMarginBottomRight` and `SetMinMarginBottomRight`");
 
 242     %property(MinMarginTopLeft, GetMinMarginTopLeft, SetMinMarginTopLeft, doc="See `GetMinMarginTopLeft` and `SetMinMarginTopLeft`");
 
 243     %property(PaperId, GetPaperId, SetPaperId, doc="See `GetPaperId` and `SetPaperId`");
 
 244     %property(PaperSize, GetPaperSize, SetPaperSize, doc="See `GetPaperSize` and `SetPaperSize`");
 
 245     %property(PrintData, GetPrintData, SetPrintData, doc="See `GetPrintData` and `SetPrintData`");
 
 251 // NOTE: Contrary to it's name, this class doesn't derive from wxDialog.  It
 
 252 // is a facade in front of a platform-specific (native dialog) provided by the
 
 255 MustHaveApp(wxPageSetupDialog);
 
 257 class wxPageSetupDialog : public wxObject
 
 260     wxPageSetupDialog(wxWindow* parent, wxPageSetupDialogData* data = NULL);
 
 261     ~wxPageSetupDialog();
 
 263     wxPageSetupDialogData& GetPageSetupData();
 
 264     wxPageSetupDialogData& GetPageSetupDialogData();
 
 267     %pythoncode { def Destroy(self): pass }
 
 269     %property(PageSetupData, GetPageSetupData, doc="See `GetPageSetupData`");
 
 270     %property(PageSetupDialogData, GetPageSetupDialogData, doc="See `GetPageSetupDialogData`");
 
 274 //---------------------------------------------------------------------------
 
 277 class wxPrintDialogData : public wxObject {
 
 279     %nokwargs wxPrintDialogData;
 
 281     wxPrintDialogData(const wxPrintData& printData);
 
 282     wxPrintDialogData(const wxPrintDialogData& printData);  // for making copies
 
 283     ~wxPrintDialogData();
 
 285     int GetFromPage() const;
 
 286     int GetToPage() const;
 
 287     int GetMinPage() const;
 
 288     int GetMaxPage() const;
 
 289     int GetNoCopies() const;
 
 290     bool GetAllPages() const;
 
 291     bool GetSelection() const;
 
 292     bool GetCollate() const;
 
 293     bool GetPrintToFile() const;
 
 295     // WXWIN_COMPATIBILITY_2_4
 
 297     bool GetSetupDialog() const;
 
 298     void SetSetupDialog(bool flag);
 
 300     void SetFromPage(int v);
 
 301     void SetToPage(int v);
 
 302     void SetMinPage(int v);
 
 303     void SetMaxPage(int v);
 
 304     void SetNoCopies(int v);
 
 305     void SetAllPages(bool flag);
 
 306     void SetSelection(bool flag);
 
 307     void SetCollate(bool flag);
 
 308     void SetPrintToFile(bool flag);
 
 310     void EnablePrintToFile(bool flag);
 
 311     void EnableSelection(bool flag);
 
 312     void EnablePageNumbers(bool flag);
 
 313     void EnableHelp(bool flag);
 
 315     bool GetEnablePrintToFile() const;
 
 316     bool GetEnableSelection() const;
 
 317     bool GetEnablePageNumbers() const;
 
 318     bool GetEnableHelp() const;
 
 320     // Is this data OK for showing the print dialog?
 
 322     %pythoncode { Ok = IsOk }
 
 325     wxPrintData& GetPrintData();
 
 326     void SetPrintData(const wxPrintData& printData);
 
 328     %pythoncode { def __nonzero__(self): return self.IsOk() }
 
 330     %property(AllPages, GetAllPages, SetAllPages, doc="See `GetAllPages` and `SetAllPages`");
 
 331     %property(Collate, GetCollate, SetCollate, doc="See `GetCollate` and `SetCollate`");
 
 332 //     %property(EnableHelp, GetEnableHelp, doc="See `GetEnableHelp`");
 
 333 //     %property(EnablePageNumbers, GetEnablePageNumbers, doc="See `GetEnablePageNumbers`");
 
 334 //     %property(EnablePrintToFile, GetEnablePrintToFile, doc="See `GetEnablePrintToFile`");
 
 335 //     %property(EnableSelection, GetEnableSelection, doc="See `GetEnableSelection`");
 
 336     %property(FromPage, GetFromPage, SetFromPage, doc="See `GetFromPage` and `SetFromPage`");
 
 337     %property(MaxPage, GetMaxPage, SetMaxPage, doc="See `GetMaxPage` and `SetMaxPage`");
 
 338     %property(MinPage, GetMinPage, SetMinPage, doc="See `GetMinPage` and `SetMinPage`");
 
 339     %property(NoCopies, GetNoCopies, SetNoCopies, doc="See `GetNoCopies` and `SetNoCopies`");
 
 340     %property(PrintData, GetPrintData, SetPrintData, doc="See `GetPrintData` and `SetPrintData`");
 
 341     %property(PrintToFile, GetPrintToFile, SetPrintToFile, doc="See `GetPrintToFile` and `SetPrintToFile`");
 
 342     %property(Selection, GetSelection, SetSelection, doc="See `GetSelection` and `SetSelection`");
 
 343     %property(ToPage, GetToPage, SetToPage, doc="See `GetToPage` and `SetToPage`");
 
 348 MustHaveApp(wxPrintDialog);
 
 351 // NOTE: Contrary to it's name, this class doesn't derive from wxDialog.  It
 
 352 // is a facade in front of a platform-specific (native dialog) provided by the
 
 355 class wxPrintDialog : public wxObject {
 
 357     wxPrintDialog(wxWindow* parent, wxPrintDialogData* data = NULL);
 
 359     // TODO?: wxPrintDialog(wxWindow *parent, wxPrintData* data);
 
 363     virtual int ShowModal();
 
 365     virtual wxPrintDialogData& GetPrintDialogData();
 
 366     virtual wxPrintData& GetPrintData();
 
 368     %newobject GetPrintDC;
 
 369     virtual wxDC *GetPrintDC();
 
 371     %pythoncode { def Destroy(self): pass }
 
 373     %property(PrintDC, GetPrintDC, doc="See `GetPrintDC`");
 
 374     %property(PrintData, GetPrintData, doc="See `GetPrintData`");
 
 375     %property(PrintDialogData, GetPrintDialogData, doc="See `GetPrintDialogData`");
 
 379 //---------------------------------------------------------------------------
 
 380 //---------------------------------------------------------------------------
 
 385     wxPRINTER_NO_ERROR = 0,
 
 391 MustHaveApp(wxPrinter);
 
 393 class wxPrinter : public wxObject {
 
 395     wxPrinter(wxPrintDialogData* data = NULL);
 
 398     virtual wxWindow *CreateAbortWindow(wxWindow *parent, wxPyPrintout *printout);
 
 399     virtual void ReportError(wxWindow *parent, wxPyPrintout *printout, const wxString& message);
 
 401     virtual bool Setup(wxWindow *parent);
 
 402     virtual bool Print(wxWindow *parent, wxPyPrintout *printout, bool prompt = true);
 
 403     virtual wxDC* PrintDialog(wxWindow *parent);
 
 405     virtual wxPrintDialogData& GetPrintDialogData() const;
 
 408     static wxPrinterError GetLastError();
 
 410     %property(Abort, GetAbort, doc="See `GetAbort`");
 
 411     %property(PrintDialogData, GetPrintDialogData, doc="See `GetPrintDialogData`");
 
 415 //---------------------------------------------------------------------------
 
 416 // Custom wxPrintout class that knows how to call python, See implementation in
 
 417 // include/sx/wxPython/printfw.h
 
 421 IMPLEMENT_ABSTRACT_CLASS(wxPyPrintout, wxPrintout);
 
 423 // Since this one would be tough and ugly to do with the Macros...
 
 424 void wxPyPrintout::GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) {
 
 428     wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 429     if ((found = wxPyCBH_findCallback(m_myInst, "GetPageInfo"))) {
 
 430         PyObject* result = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));
 
 431         if (result && PyTuple_Check(result) && PyTuple_Size(result) == 4) {
 
 434             val = PyTuple_GetItem(result, 0);
 
 435             if (PyInt_Check(val))    *minPage = PyInt_AsLong(val);
 
 438             val = PyTuple_GetItem(result, 1);
 
 439             if (PyInt_Check(val))    *maxPage = PyInt_AsLong(val);
 
 442             val = PyTuple_GetItem(result, 2);
 
 443             if (PyInt_Check(val))    *pageFrom = PyInt_AsLong(val);
 
 446             val = PyTuple_GetItem(result, 3);
 
 447             if (PyInt_Check(val))    *pageTo = PyInt_AsLong(val);
 
 454             PyErr_SetString(PyExc_TypeError, "GetPageInfo should return a tuple of 4 integers.");
 
 459     wxPyEndBlockThreads(blocked);
 
 461         wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo);
 
 466 IMP_PYCALLBACK_BOOL_INTINT(wxPyPrintout, wxPrintout, OnBeginDocument);
 
 467 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnEndDocument);
 
 468 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnBeginPrinting);
 
 469 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnEndPrinting);
 
 470 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnPreparePrinting);
 
 471 IMP_PYCALLBACK_BOOL_INT_pure(wxPyPrintout, wxPrintout, OnPrintPage);
 
 472 IMP_PYCALLBACK_BOOL_INT(wxPyPrintout, wxPrintout, HasPage);
 
 478 MustHaveApp(wxPyPrintout);
 
 480 // Now define the custom class for SWIGging
 
 481 %rename(Printout) wxPyPrintout;
 
 482 class wxPyPrintout  : public wxObject {
 
 484     %pythonAppend wxPyPrintout   "self._setCallbackInfo(self, Printout)"
 
 485     %typemap(out) wxPyPrintout*;    // turn off this typemap
 
 487     wxPyPrintout(const wxString& title = wxPyPrintoutTitleStr);
 
 490     // Turn it back on again
 
 491     %typemap(out) wxPyPrintout* { $result = wxPyMake_wxObject($1, $owner); }
 
 493     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 496     wxString GetTitle() const;
 
 498     void SetDC(wxDC *dc);
 
 501     void FitThisSizeToPaper(const wxSize& imageSize);
 
 502     void FitThisSizeToPage(const wxSize& imageSize);
 
 503     void FitThisSizeToPageMargins(const wxSize& imageSize, const wxPageSetupDialogData& pageSetupData);
 
 504     void MapScreenSizeToPaper();
 
 505     void MapScreenSizeToPage();
 
 506     void MapScreenSizeToPageMargins(const wxPageSetupDialogData& pageSetupData);
 
 507     void MapScreenSizeToDevice();
 
 509     wxRect GetLogicalPaperRect() const;
 
 510     wxRect GetLogicalPageRect() const;
 
 511     wxRect GetLogicalPageMarginsRect(const wxPageSetupDialogData& pageSetupData) const;
 
 513     void SetLogicalOrigin(wxCoord x, wxCoord y);
 
 514     void OffsetLogicalOrigin(wxCoord xoff, wxCoord yoff);
 
 517     void SetPageSizePixels(int w, int  h);
 
 519         void, GetPageSizePixels(int *OUTPUT, int *OUTPUT),
 
 520         "GetPageSizePixels() -> (w, h)");
 
 522     void SetPageSizeMM(int w, int  h);
 
 524         void, GetPageSizeMM(int *OUTPUT, int *OUTPUT),
 
 525         "GetPageSizeMM() -> (w, h)");
 
 527     void SetPPIScreen(int x, int y);
 
 529         void, GetPPIScreen(int *OUTPUT, int *OUTPUT),
 
 530         "GetPPIScreen() -> (x,y)");
 
 532     void SetPPIPrinter(int x, int y);
 
 534         void, GetPPIPrinter(int *OUTPUT, int *OUTPUT),
 
 535         "GetPPIPrinter() -> (x,y)");
 
 537     void SetPaperRectPixels(const wxRect& paperRectPixels);
 
 538     wxRect GetPaperRectPixels() const;
 
 541     void SetIsPreview(bool p);
 
 544     bool OnBeginDocument(int startPage, int endPage);
 
 545     void OnEndDocument();
 
 546     void OnBeginPrinting();
 
 547     void OnEndPrinting();
 
 548     void OnPreparePrinting();
 
 549     bool HasPage(int page);
 
 551         void, GetPageInfo(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT),
 
 552         "GetPageInfo() -> (minPage, maxPage, pageFrom, pageTo)");
 
 554     %MAKE_BASE_FUNC(Printout, OnBeginDocument);
 
 555     %MAKE_BASE_FUNC(Printout, OnEndDocument);
 
 556     %MAKE_BASE_FUNC(Printout, OnBeginPrinting);
 
 557     %MAKE_BASE_FUNC(Printout, OnEndPrinting);
 
 558     %MAKE_BASE_FUNC(Printout, OnPreparePrinting);
 
 559     %MAKE_BASE_FUNC(Printout, GetPageInfo);
 
 562     %property(DC, GetDC, SetDC, doc="See `GetDC` and `SetDC`");
 
 563     %property(PPIPrinter, GetPPIPrinter, SetPPIPrinter, doc="See `GetPPIPrinter` and `SetPPIPrinter`");
 
 564     %property(PPIScreen, GetPPIScreen, SetPPIScreen, doc="See `GetPPIScreen` and `SetPPIScreen`");
 
 565     %property(PageSizeMM, GetPageSizeMM, SetPageSizeMM, doc="See `GetPageSizeMM` and `SetPageSizeMM`");
 
 566     %property(PageSizePixels, GetPageSizePixels, SetPageSizePixels, doc="See `GetPageSizePixels` and `SetPageSizePixels`");
 
 567     %property(Title, GetTitle, doc="See `GetTitle`");
 
 570 //---------------------------------------------------------------------------
 
 574 MustHaveApp(wxPreviewCanvas);
 
 576 class wxPreviewCanvas: public wxScrolledWindow
 
 579     %pythonAppend wxPreviewCanvas   "self._setOORInfo(self)"
 
 581     wxPreviewCanvas(wxPrintPreview *preview,
 
 583                     const wxPoint& pos = wxDefaultPosition,
 
 584                     const wxSize& size = wxDefaultSize,
 
 586                     const wxString& name = wxPyPreviewCanvasNameStr);
 
 590 MustHaveApp(wxPreviewFrame);
 
 592 class wxPreviewFrame : public wxFrame {
 
 594     %disownarg(wxPrintPreview*);
 
 596     %pythonAppend wxPreviewFrame   "self._setOORInfo(self)"
 
 597     wxPreviewFrame(wxPrintPreview* preview, wxFrame* parent, const wxString& title,
 
 598                    const wxPoint& pos = wxDefaultPosition,
 
 599                    const wxSize&  size = wxDefaultSize,
 
 600                    long style = wxDEFAULT_FRAME_STYLE,
 
 601                    const wxString& name = wxPyFrameNameStr);
 
 603     %cleardisown(wxPrintPreview*);
 
 606     void CreateControlBar();
 
 609     wxPreviewControlBar* GetControlBar() const;
 
 611     %property(ControlBar, GetControlBar, doc="See `GetControlBar`");
 
 628     wxID_PREVIEW_PREVIOUS,
 
 636 MustHaveApp(wxPreviewControlBar);
 
 638 class wxPreviewControlBar: public wxPanel
 
 641     %pythonAppend wxPreviewControlBar   "self._setOORInfo(self)"
 
 643     wxPreviewControlBar(wxPrintPreview *preview,
 
 646                         const wxPoint& pos = wxDefaultPosition,
 
 647                         const wxSize& size = wxDefaultSize,
 
 648                         long style = wxTAB_TRAVERSAL,
 
 649                         const wxString& name = wxPyPanelNameStr);
 
 651     int GetZoomControl();
 
 652     void SetZoomControl(int zoom);
 
 653     wxPrintPreview* GetPrintPreview();
 
 661     %property(PrintPreview, GetPrintPreview, doc="See `GetPrintPreview`");
 
 662     %property(ZoomControl, GetZoomControl, SetZoomControl, doc="See `GetZoomControl` and `SetZoomControl`");    
 
 667 //---------------------------------------------------------------------------
 
 669 MustHaveApp(wxPrintPreview);
 
 671 class wxPrintPreview : public wxObject {
 
 673     %disownarg(wxPyPrintout*);
 
 675     %nokwargs wxPrintPreview;
 
 676     wxPrintPreview(wxPyPrintout* printout,
 
 677                    wxPyPrintout* printoutForPrinting,
 
 678                    wxPrintDialogData *data=NULL);
 
 679     wxPrintPreview(wxPyPrintout* printout,
 
 680                   wxPyPrintout* printoutForPrinting,
 
 685     virtual bool SetCurrentPage(int pageNum);
 
 686     int GetCurrentPage();
 
 688     void SetPrintout(wxPyPrintout *printout);
 
 689     wxPyPrintout *GetPrintout();
 
 690     wxPyPrintout *GetPrintoutForPrinting();
 
 692     %cleardisown(wxPyPrintout*);
 
 694     void SetFrame(wxFrame *frame);
 
 695     void SetCanvas(wxPreviewCanvas *canvas);
 
 697     virtual wxFrame *GetFrame();
 
 698     virtual wxPreviewCanvas *GetCanvas();
 
 700     // The preview canvas should call this from OnPaint
 
 701     virtual bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc);
 
 703     // This draws a blank page onto the preview canvas
 
 704     virtual bool DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc);
 
 706     // This is called by wxPrintPreview to render a page into a wxMemoryDC.
 
 707     virtual bool RenderPage(int pageNum);
 
 709     // Adjusts the scrollbars for the current scale
 
 710     virtual void AdjustScrollbars(wxPreviewCanvas *canvas);
 
 712     wxPrintDialogData& GetPrintDialogData();
 
 714     virtual void SetZoom(int percent);
 
 721     %pythoncode { Ok = IsOk }
 
 724     virtual bool Print(bool interactive);
 
 725     virtual void DetermineScaling();
 
 727     %pythoncode { def __nonzero__(self): return self.IsOk() }
 
 729     %property(Canvas, GetCanvas, SetCanvas, doc="See `GetCanvas` and `SetCanvas`");
 
 730     %property(CurrentPage, GetCurrentPage, SetCurrentPage, doc="See `GetCurrentPage` and `SetCurrentPage`");
 
 731     %property(Frame, GetFrame, SetFrame, doc="See `GetFrame` and `SetFrame`");
 
 732     %property(MaxPage, GetMaxPage, doc="See `GetMaxPage`");
 
 733     %property(MinPage, GetMinPage, doc="See `GetMinPage`");
 
 734     %property(PrintDialogData, GetPrintDialogData, doc="See `GetPrintDialogData`");
 
 735     %property(Printout, GetPrintout, SetPrintout, doc="See `GetPrintout` and `SetPrintout`");
 
 736     %property(PrintoutForPrinting, GetPrintoutForPrinting, doc="See `GetPrintoutForPrinting`");
 
 737     %property(Zoom, GetZoom, SetZoom, doc="See `GetZoom` and `SetZoom`");
 
 742 //---------------------------------------------------------------------------
 
 744 // Python-derivable versions of the above preview classes
 
 748 #define DEC_PYCALLBACK_BOOL_PREWINDC(CBNAME)                                            \
 
 749     bool CBNAME(wxPreviewCanvas* a, wxDC& b)
 
 752 #define IMP_PYCALLBACK_BOOL_PREWINDC(CLASS, PCLASS, CBNAME)                             \
 
 753     bool CLASS::CBNAME(wxPreviewCanvas* a, wxDC& b) {                                   \
 
 756         wxPyBlock_t blocked = wxPyBeginBlockThreads();                                  \
 
 757         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                        \
 
 758             PyObject* win = wxPyMake_wxObject(a,false);                                 \
 
 759             PyObject* dc  = wxPyMake_wxObject(&b,false);                                \
 
 760             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc));      \
 
 764         wxPyEndBlockThreads(blocked);                                                   \
 
 766             rval = PCLASS::CBNAME(a, b);                                                \
 
 773 class wxPyPrintPreview : public wxPrintPreview
 
 775     DECLARE_CLASS(wxPyPrintPreview)
 
 777     wxPyPrintPreview(wxPyPrintout* printout,
 
 778                      wxPyPrintout* printoutForPrinting,
 
 779                      wxPrintDialogData* data=NULL)
 
 780         : wxPrintPreview(printout, printoutForPrinting, data)
 
 782     wxPyPrintPreview(wxPyPrintout* printout,
 
 783                      wxPyPrintout* printoutForPrinting,
 
 785         : wxPrintPreview(printout, printoutForPrinting, data)
 
 788     DEC_PYCALLBACK_BOOL_INT(SetCurrentPage);
 
 789     DEC_PYCALLBACK_BOOL_PREWINDC(PaintPage);
 
 790     DEC_PYCALLBACK_BOOL_PREWINDC(DrawBlankPage);
 
 791     DEC_PYCALLBACK_BOOL_INT(RenderPage);
 
 792     DEC_PYCALLBACK_VOID_INT(SetZoom);
 
 793     DEC_PYCALLBACK_BOOL_BOOL(Print);
 
 794     DEC_PYCALLBACK_VOID_(DetermineScaling);
 
 799 // Stupid renamed classes...  Fix this in 2.5...
 
 800 #if defined(__WXMSW__)
 
 801 IMPLEMENT_CLASS( wxPyPrintPreview, wxWindowsPrintPreview );
 
 802 #elif defined(__WXMAC__)
 
 803 IMPLEMENT_CLASS( wxPyPrintPreview, wxMacPrintPreview );
 
 805 IMPLEMENT_CLASS( wxPyPrintPreview, wxPostScriptPrintPreview );
 
 808 IMP_PYCALLBACK_BOOL_INT     (wxPyPrintPreview, wxPrintPreview, SetCurrentPage);
 
 809 IMP_PYCALLBACK_BOOL_PREWINDC(wxPyPrintPreview, wxPrintPreview, PaintPage);
 
 810 IMP_PYCALLBACK_BOOL_PREWINDC(wxPyPrintPreview, wxPrintPreview, DrawBlankPage);
 
 811 IMP_PYCALLBACK_BOOL_INT     (wxPyPrintPreview, wxPrintPreview, RenderPage);
 
 812 IMP_PYCALLBACK_VOID_INT     (wxPyPrintPreview, wxPrintPreview, SetZoom);
 
 813 IMP_PYCALLBACK_BOOL_BOOL    (wxPyPrintPreview, wxPrintPreview, Print);
 
 814 IMP_PYCALLBACK_VOID_        (wxPyPrintPreview, wxPrintPreview, DetermineScaling);
 
 818 MustHaveApp(wxPyPrintPreview);
 
 820 class wxPyPrintPreview : public wxPrintPreview
 
 823     %disownarg(wxPyPrintout*);
 
 825     %pythonAppend wxPyPrintPreview   "self._setCallbackInfo(self, PyPrintPreview)"
 
 826     %nokwargs wxPyPrintPreview;
 
 827     wxPyPrintPreview(wxPyPrintout* printout,
 
 828                      wxPyPrintout* printoutForPrinting,
 
 829                      wxPrintDialogData* data=NULL);
 
 830     wxPyPrintPreview(wxPyPrintout* printout,
 
 831                      wxPyPrintout* printoutForPrinting,
 
 834     %cleardisown(wxPyPrintout*);
 
 836     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 838     bool SetCurrentPage(int pageNum);
 
 839     bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc);
 
 840     bool DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc);
 
 841     bool RenderPage(int pageNum);
 
 842     void SetZoom(int percent);
 
 843     bool Print(bool interactive);
 
 844     void DetermineScaling();
 
 846     %MAKE_BASE_FUNC(PyPrintPreview, SetCurrentPage);
 
 847     %MAKE_BASE_FUNC(PyPrintPreview, PaintPage);
 
 848     %MAKE_BASE_FUNC(PyPrintPreview, DrawBlankPage);
 
 849     %MAKE_BASE_FUNC(PyPrintPreview, RenderPage);
 
 850     %MAKE_BASE_FUNC(PyPrintPreview, SetZoom);
 
 851     %MAKE_BASE_FUNC(PyPrintPreview, Print);
 
 852     %MAKE_BASE_FUNC(PyPrintPreview, DetermineScaling);
 
 859 class wxPyPreviewFrame : public wxPreviewFrame
 
 861     DECLARE_CLASS(wxPyPreviewFrame)
 
 863     wxPyPreviewFrame(wxPrintPreview* preview, wxFrame* parent,
 
 864                      const wxString& title,
 
 865                      const wxPoint& pos = wxDefaultPosition,
 
 866                      const wxSize&  size = wxDefaultSize,
 
 867                      long style = wxDEFAULT_FRAME_STYLE,
 
 868                      const wxString& name = wxPyFrameNameStr)
 
 869         : wxPreviewFrame(preview, parent, title, pos, size, style, name)
 
 872     void SetPreviewCanvas(wxPreviewCanvas* canvas) { m_previewCanvas = canvas; }
 
 873     void SetControlBar(wxPreviewControlBar* bar) { m_controlBar = bar; }
 
 875     DEC_PYCALLBACK_VOID_(Initialize);
 
 876     DEC_PYCALLBACK_VOID_(CreateCanvas);
 
 877     DEC_PYCALLBACK_VOID_(CreateControlBar);
 
 882 IMPLEMENT_CLASS(wxPyPreviewFrame, wxPreviewFrame);
 
 884 IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, Initialize);
 
 885 IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, CreateCanvas);
 
 886 IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, CreateControlBar);
 
 890 MustHaveApp(wxPyPreviewFrame);
 
 892 class wxPyPreviewFrame : public wxPreviewFrame
 
 895     %disownarg(wxPrintPreview*);
 
 896     %pythonAppend wxPyPreviewFrame "self._setCallbackInfo(self, PyPreviewFrame); self._setOORInfo(self)"
 
 898     wxPyPreviewFrame(wxPrintPreview* preview, wxFrame* parent,
 
 899                      const wxString& title,
 
 900                      const wxPoint& pos = wxDefaultPosition,
 
 901                      const wxSize&  size = wxDefaultSize,
 
 902                      long style = wxDEFAULT_FRAME_STYLE,
 
 903                      const wxString& name = wxPyFrameNameStr);
 
 905     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 907     void SetPreviewCanvas(wxPreviewCanvas* canvas);
 
 908     void SetControlBar(wxPreviewControlBar* bar);
 
 912     void CreateControlBar();
 
 914     %MAKE_BASE_FUNC(PyPreviewFrame, Initialize);
 
 915     %MAKE_BASE_FUNC(PyPreviewFrame, CreateCanvas);
 
 916     %MAKE_BASE_FUNC(PyPreviewFrame, CreateControlBar);
 
 923 class wxPyPreviewControlBar : public wxPreviewControlBar
 
 925     DECLARE_CLASS(wxPyPreviewControlBar)
 
 927     wxPyPreviewControlBar(wxPrintPreview *preview,
 
 930                           const wxPoint& pos = wxDefaultPosition,
 
 931                           const wxSize& size = wxDefaultSize,
 
 933                           const wxString& name = wxPyPanelNameStr)
 
 934         : wxPreviewControlBar(preview, buttons, parent, pos, size, style, name)
 
 937     void SetPrintPreview(wxPrintPreview* preview) { m_printPreview = preview; }
 
 939     DEC_PYCALLBACK_VOID_(CreateButtons);
 
 940     DEC_PYCALLBACK_VOID_INT(SetZoomControl);
 
 945 IMPLEMENT_CLASS(wxPyPreviewControlBar, wxPreviewControlBar);
 
 946 IMP_PYCALLBACK_VOID_(wxPyPreviewControlBar, wxPreviewControlBar, CreateButtons);
 
 947 IMP_PYCALLBACK_VOID_INT(wxPyPreviewControlBar, wxPreviewControlBar, SetZoomControl);
 
 951 MustHaveApp(wxPyPreviewControlBar);
 
 953 class wxPyPreviewControlBar : public wxPreviewControlBar
 
 956     %pythonAppend wxPyPreviewControlBar   "self._setCallbackInfo(self, PyPreviewControlBar); self._setOORInfo(self)"
 
 958     wxPyPreviewControlBar(wxPrintPreview *preview,
 
 961                           const wxPoint& pos = wxDefaultPosition,
 
 962                           const wxSize& size = wxDefaultSize,
 
 964                           const wxString& name = wxPyPanelNameStr);
 
 966     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 968     void SetPrintPreview(wxPrintPreview* preview);
 
 970     void CreateButtons();
 
 971     void SetZoomControl(int zoom);
 
 973     %MAKE_BASE_FUNC(PreviewControlBar, CreateButtons);
 
 974     %MAKE_BASE_FUNC(PreviewControlBar, SetZoomControl);
 
 977 //---------------------------------------------------------------------------
 
 978 //---------------------------------------------------------------------------
 
 980     wxPyPtrTypeMap_Add("wxPrintout", "wxPyPrintout");
 
 982 //---------------------------------------------------------------------------