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
 
  72     bool IsOrientationReversed() const;
 
  75     %pythoncode { Ok = IsOk }
 
  77     const wxString& GetPrinterName();
 
  79     wxDuplexMode GetDuplex();
 
  80     wxPaperSize GetPaperId();
 
  81     const wxSize& GetPaperSize();
 
  85     wxPrintMode GetPrintMode() const;
 
  88     void SetNoCopies(int v);
 
  89     void SetCollate(bool flag);
 
  90     void SetOrientation(int orient);
 
  91     void SetOrientationReversed(bool reversed);
 
  93     void SetPrinterName(const wxString& name);
 
  94     void SetColour(bool colour);
 
  95     void SetDuplex(wxDuplexMode duplex);
 
  96     void SetPaperId(wxPaperSize sizeId);
 
  97     void SetPaperSize(const wxSize& sz);
 
  98     void SetQuality(int quality);
 
  99     void SetBin(wxPrintBin bin);
 
 100     void SetPrintMode(wxPrintMode printMode);
 
 101     void SetMedia(int media);
 
 103     wxString GetFilename() const;
 
 104     void SetFilename( const wxString &filename );
 
 106     %pythoncode { def __nonzero__(self): return self.IsOk() }
 
 108     //char* GetPrivData() const;
 
 109     //int GetPrivDataLen() const;
 
 110     //void SetPrivData( char *privData, int len );
 
 113         PyObject* GetPrivData() {
 
 115             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 116             data = PyString_FromStringAndSize(self->GetPrivData(),
 
 117                                               self->GetPrivDataLen());
 
 118             wxPyEndBlockThreads(blocked);
 
 122         void SetPrivData(PyObject* data) {
 
 123             if (! PyString_Check(data)) {
 
 124                 wxPyBLOCK_THREADS(PyErr_SetString(PyExc_TypeError,
 
 125                                                   "Expected string object"));
 
 129             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 130             self->SetPrivData(PyString_AS_STRING(data), PyString_GET_SIZE(data));
 
 131             wxPyEndBlockThreads(blocked);
 
 136     // NOTE: These are now inside of #if WXWIN_COMPATIBILITY_2_4, so be
 
 137     //       prepared to remove them...
 
 139     // PostScript-specific data
 
 140 // WXWIN_COMPATIBILITY_2_4
 
 142     const wxString& GetPrinterCommand();
 
 143     const wxString& GetPrinterOptions();
 
 144     const wxString& GetPreviewCommand();
 
 145     const wxString& GetFontMetricPath();
 
 146     double GetPrinterScaleX();
 
 147     double GetPrinterScaleY();
 
 148     long GetPrinterTranslateX();
 
 149     long GetPrinterTranslateY();
 
 150     void SetPrinterCommand(const wxString& command);
 
 151     void SetPrinterOptions(const wxString& options);
 
 152     void SetPreviewCommand(const wxString& command);
 
 153     void SetFontMetricPath(const wxString& path);
 
 154     void SetPrinterScaleX(double x);
 
 155     void SetPrinterScaleY(double y);
 
 156     void SetPrinterScaling(double x, double y);
 
 157     void SetPrinterTranslateX(long x);
 
 158     void SetPrinterTranslateY(long y);
 
 159     void SetPrinterTranslation(long x, long y);
 
 162     %property(Bin, GetBin, SetBin, doc="See `GetBin` and `SetBin`");
 
 163     %property(Collate, GetCollate, SetCollate, doc="See `GetCollate` and `SetCollate`");
 
 164     %property(Colour, GetColour, SetColour, doc="See `GetColour` and `SetColour`");
 
 165     %property(Duplex, GetDuplex, SetDuplex, doc="See `GetDuplex` and `SetDuplex`");
 
 166     %property(Filename, GetFilename, SetFilename, doc="See `GetFilename` and `SetFilename`");
 
 167     %property(NoCopies, GetNoCopies, SetNoCopies, doc="See `GetNoCopies` and `SetNoCopies`");
 
 168     %property(Orientation, GetOrientation, SetOrientation, doc="See `GetOrientation` and `SetOrientation`");
 
 169     %property(PaperId, GetPaperId, SetPaperId, doc="See `GetPaperId` and `SetPaperId`");
 
 170     %property(PaperSize, GetPaperSize, SetPaperSize, doc="See `GetPaperSize` and `SetPaperSize`");
 
 171     %property(PrintMode, GetPrintMode, SetPrintMode, doc="See `GetPrintMode` and `SetPrintMode`");
 
 172     %property(PrinterName, GetPrinterName, SetPrinterName, doc="See `GetPrinterName` and `SetPrinterName`");
 
 173     %property(PrivData, GetPrivData, SetPrivData, doc="See `GetPrivData` and `SetPrivData`");
 
 174     %property(Quality, GetQuality, SetQuality, doc="See `GetQuality` and `SetQuality`");   
 
 177 //---------------------------------------------------------------------------
 
 179 class wxPageSetupDialogData : public wxObject {
 
 181     %nokwargs wxPageSetupDialogData;
 
 182     wxPageSetupDialogData();
 
 183     wxPageSetupDialogData(const wxPageSetupDialogData& data);  // for making copies
 
 184     wxPageSetupDialogData(const wxPrintData& data); 
 
 185     ~wxPageSetupDialogData();
 
 187     void EnableHelp(bool flag);
 
 188     void EnableMargins(bool flag);
 
 189     void EnableOrientation(bool flag);
 
 190     void EnablePaper(bool flag);
 
 191     void EnablePrinter(bool flag);
 
 193     bool GetDefaultMinMargins();
 
 194     bool GetEnableMargins();
 
 195     bool GetEnableOrientation();
 
 196     bool GetEnablePaper();
 
 197     bool GetEnablePrinter();
 
 198     bool GetEnableHelp();
 
 199     bool GetDefaultInfo();
 
 200     wxPoint GetMarginTopLeft();
 
 201     wxPoint GetMarginBottomRight();
 
 202     wxPoint GetMinMarginTopLeft();
 
 203     wxPoint GetMinMarginBottomRight();
 
 204     wxPaperSize GetPaperId();
 
 205     wxSize GetPaperSize();
 
 207     wxPrintData& GetPrintData();
 
 210     %pythoncode { Ok = IsOk }
 
 212     void SetDefaultInfo(bool flag);
 
 213     void SetDefaultMinMargins(bool flag);
 
 214     void SetMarginTopLeft(const wxPoint& pt);
 
 215     void SetMarginBottomRight(const wxPoint& pt);
 
 216     void SetMinMarginTopLeft(const wxPoint& pt);
 
 217     void SetMinMarginBottomRight(const wxPoint& pt);
 
 218     void SetPaperId(wxPaperSize id);
 
 219     void SetPaperSize(const wxSize& size);
 
 221     void SetPrintData(const wxPrintData& printData);
 
 223     // Use paper size defined in this object to set the wxPrintData
 
 225     void CalculateIdFromPaperSize();
 
 227     // Use paper id in wxPrintData to set this object's paper size
 
 228     void CalculatePaperSizeFromId();
 
 230     %pythoncode { def __nonzero__(self): return self.IsOk() }
 
 232     %property(DefaultInfo, GetDefaultInfo, SetDefaultInfo, doc="See `GetDefaultInfo` and `SetDefaultInfo`");
 
 233     %property(DefaultMinMargins, GetDefaultMinMargins, SetDefaultMinMargins, doc="See `GetDefaultMinMargins` and `SetDefaultMinMargins`");
 
 235 //     %property(EnableHelp, GetEnableHelp, doc="See `GetEnableHelp`");
 
 236 //     %property(EnableMargins, GetEnableMargins, doc="See `GetEnableMargins`");
 
 237 //     %property(EnableOrientation, GetEnableOrientation, doc="See `GetEnableOrientation`");
 
 238 //     %property(EnablePaper, GetEnablePaper, doc="See `GetEnablePaper`");
 
 239 //     %property(EnablePrinter, GetEnablePrinter, doc="See `GetEnablePrinter`");
 
 241     %property(MarginBottomRight, GetMarginBottomRight, SetMarginBottomRight, doc="See `GetMarginBottomRight` and `SetMarginBottomRight`");
 
 242     %property(MarginTopLeft, GetMarginTopLeft, SetMarginTopLeft, doc="See `GetMarginTopLeft` and `SetMarginTopLeft`");
 
 243     %property(MinMarginBottomRight, GetMinMarginBottomRight, SetMinMarginBottomRight, doc="See `GetMinMarginBottomRight` and `SetMinMarginBottomRight`");
 
 244     %property(MinMarginTopLeft, GetMinMarginTopLeft, SetMinMarginTopLeft, doc="See `GetMinMarginTopLeft` and `SetMinMarginTopLeft`");
 
 245     %property(PaperId, GetPaperId, SetPaperId, doc="See `GetPaperId` and `SetPaperId`");
 
 246     %property(PaperSize, GetPaperSize, SetPaperSize, doc="See `GetPaperSize` and `SetPaperSize`");
 
 247     %property(PrintData, GetPrintData, SetPrintData, doc="See `GetPrintData` and `SetPrintData`");
 
 253 // NOTE: Contrary to it's name, this class doesn't derive from wxDialog.  It
 
 254 // is a facade in front of a platform-specific (native dialog) provided by the
 
 257 MustHaveApp(wxPageSetupDialog);
 
 259 class wxPageSetupDialog : public wxObject
 
 262     wxPageSetupDialog(wxWindow* parent, wxPageSetupDialogData* data = NULL);
 
 263     ~wxPageSetupDialog();
 
 265     wxPageSetupDialogData& GetPageSetupData();
 
 266     wxPageSetupDialogData& GetPageSetupDialogData();
 
 269     %pythoncode { def Destroy(self): pass }
 
 271     %property(PageSetupData, GetPageSetupData, doc="See `GetPageSetupData`");
 
 272     %property(PageSetupDialogData, GetPageSetupDialogData, doc="See `GetPageSetupDialogData`");
 
 276 //---------------------------------------------------------------------------
 
 279 class wxPrintDialogData : public wxObject {
 
 281     %nokwargs wxPrintDialogData;
 
 283     wxPrintDialogData(const wxPrintData& printData);
 
 284     wxPrintDialogData(const wxPrintDialogData& printData);  // for making copies
 
 285     ~wxPrintDialogData();
 
 287     int GetFromPage() const;
 
 288     int GetToPage() const;
 
 289     int GetMinPage() const;
 
 290     int GetMaxPage() const;
 
 291     int GetNoCopies() const;
 
 292     bool GetAllPages() const;
 
 293     bool GetSelection() const;
 
 294     bool GetCollate() const;
 
 295     bool GetPrintToFile() const;
 
 297     // WXWIN_COMPATIBILITY_2_4
 
 299     bool GetSetupDialog() const;
 
 300     void SetSetupDialog(bool flag);
 
 302     void SetFromPage(int v);
 
 303     void SetToPage(int v);
 
 304     void SetMinPage(int v);
 
 305     void SetMaxPage(int v);
 
 306     void SetNoCopies(int v);
 
 307     void SetAllPages(bool flag);
 
 308     void SetSelection(bool flag);
 
 309     void SetCollate(bool flag);
 
 310     void SetPrintToFile(bool flag);
 
 312     void EnablePrintToFile(bool flag);
 
 313     void EnableSelection(bool flag);
 
 314     void EnablePageNumbers(bool flag);
 
 315     void EnableHelp(bool flag);
 
 317     bool GetEnablePrintToFile() const;
 
 318     bool GetEnableSelection() const;
 
 319     bool GetEnablePageNumbers() const;
 
 320     bool GetEnableHelp() const;
 
 322     // Is this data OK for showing the print dialog?
 
 324     %pythoncode { Ok = IsOk }
 
 327     wxPrintData& GetPrintData();
 
 328     void SetPrintData(const wxPrintData& printData);
 
 330     %pythoncode { def __nonzero__(self): return self.IsOk() }
 
 332     %property(AllPages, GetAllPages, SetAllPages, doc="See `GetAllPages` and `SetAllPages`");
 
 333     %property(Collate, GetCollate, SetCollate, doc="See `GetCollate` and `SetCollate`");
 
 334 //     %property(EnableHelp, GetEnableHelp, doc="See `GetEnableHelp`");
 
 335 //     %property(EnablePageNumbers, GetEnablePageNumbers, doc="See `GetEnablePageNumbers`");
 
 336 //     %property(EnablePrintToFile, GetEnablePrintToFile, doc="See `GetEnablePrintToFile`");
 
 337 //     %property(EnableSelection, GetEnableSelection, doc="See `GetEnableSelection`");
 
 338     %property(FromPage, GetFromPage, SetFromPage, doc="See `GetFromPage` and `SetFromPage`");
 
 339     %property(MaxPage, GetMaxPage, SetMaxPage, doc="See `GetMaxPage` and `SetMaxPage`");
 
 340     %property(MinPage, GetMinPage, SetMinPage, doc="See `GetMinPage` and `SetMinPage`");
 
 341     %property(NoCopies, GetNoCopies, SetNoCopies, doc="See `GetNoCopies` and `SetNoCopies`");
 
 342     %property(PrintData, GetPrintData, SetPrintData, doc="See `GetPrintData` and `SetPrintData`");
 
 343     %property(PrintToFile, GetPrintToFile, SetPrintToFile, doc="See `GetPrintToFile` and `SetPrintToFile`");
 
 344     %property(Selection, GetSelection, SetSelection, doc="See `GetSelection` and `SetSelection`");
 
 345     %property(ToPage, GetToPage, SetToPage, doc="See `GetToPage` and `SetToPage`");
 
 350 MustHaveApp(wxPrintDialog);
 
 353 // NOTE: Contrary to it's name, this class doesn't derive from wxDialog.  It
 
 354 // is a facade in front of a platform-specific (native dialog) provided by the
 
 357 class wxPrintDialog : public wxObject {
 
 359     wxPrintDialog(wxWindow* parent, wxPrintDialogData* data = NULL);
 
 361     // TODO?: wxPrintDialog(wxWindow *parent, wxPrintData* data);
 
 365     virtual int ShowModal();
 
 367     virtual wxPrintDialogData& GetPrintDialogData();
 
 368     virtual wxPrintData& GetPrintData();
 
 370     %newobject GetPrintDC;
 
 371     virtual wxDC *GetPrintDC();
 
 373     %pythoncode { def Destroy(self): pass }
 
 375     %property(PrintDC, GetPrintDC, doc="See `GetPrintDC`");
 
 376     %property(PrintData, GetPrintData, doc="See `GetPrintData`");
 
 377     %property(PrintDialogData, GetPrintDialogData, doc="See `GetPrintDialogData`");
 
 381 //---------------------------------------------------------------------------
 
 382 //---------------------------------------------------------------------------
 
 387     wxPRINTER_NO_ERROR = 0,
 
 393 MustHaveApp(wxPrinter);
 
 395 class wxPrinter : public wxObject {
 
 397     wxPrinter(wxPrintDialogData* data = NULL);
 
 400     virtual wxWindow *CreateAbortWindow(wxWindow *parent, wxPyPrintout *printout);
 
 401     virtual void ReportError(wxWindow *parent, wxPyPrintout *printout, const wxString& message);
 
 403     virtual bool Setup(wxWindow *parent);
 
 404     virtual bool Print(wxWindow *parent, wxPyPrintout *printout, bool prompt = true);
 
 405     virtual wxDC* PrintDialog(wxWindow *parent);
 
 407     virtual wxPrintDialogData& GetPrintDialogData() const;
 
 410     static wxPrinterError GetLastError();
 
 412     %property(Abort, GetAbort, doc="See `GetAbort`");
 
 413     %property(PrintDialogData, GetPrintDialogData, doc="See `GetPrintDialogData`");
 
 417 //---------------------------------------------------------------------------
 
 418 // Custom wxPrintout class that knows how to call python, See implementation in
 
 419 // include/sx/wxPython/printfw.h
 
 423 IMPLEMENT_ABSTRACT_CLASS(wxPyPrintout, wxPrintout);
 
 425 // Since this one would be tough and ugly to do with the Macros...
 
 426 void wxPyPrintout::GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) {
 
 430     wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 431     if ((found = wxPyCBH_findCallback(m_myInst, "GetPageInfo"))) {
 
 432         PyObject* result = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));
 
 433         if (result && PyTuple_Check(result) && PyTuple_Size(result) == 4) {
 
 436             val = PyTuple_GetItem(result, 0);
 
 437             if (PyInt_Check(val))    *minPage = PyInt_AsLong(val);
 
 440             val = PyTuple_GetItem(result, 1);
 
 441             if (PyInt_Check(val))    *maxPage = PyInt_AsLong(val);
 
 444             val = PyTuple_GetItem(result, 2);
 
 445             if (PyInt_Check(val))    *pageFrom = PyInt_AsLong(val);
 
 448             val = PyTuple_GetItem(result, 3);
 
 449             if (PyInt_Check(val))    *pageTo = PyInt_AsLong(val);
 
 456             PyErr_SetString(PyExc_TypeError, "GetPageInfo should return a tuple of 4 integers.");
 
 461     wxPyEndBlockThreads(blocked);
 
 463         wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo);
 
 468 IMP_PYCALLBACK_BOOL_INTINT(wxPyPrintout, wxPrintout, OnBeginDocument);
 
 469 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnEndDocument);
 
 470 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnBeginPrinting);
 
 471 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnEndPrinting);
 
 472 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnPreparePrinting);
 
 473 IMP_PYCALLBACK_BOOL_INT_pure(wxPyPrintout, wxPrintout, OnPrintPage);
 
 474 IMP_PYCALLBACK_BOOL_INT(wxPyPrintout, wxPrintout, HasPage);
 
 480 MustHaveApp(wxPyPrintout);
 
 482 // Now define the custom class for SWIGging
 
 483 %rename(Printout) wxPyPrintout;
 
 484 class wxPyPrintout  : public wxObject {
 
 486     %pythonAppend wxPyPrintout   setCallbackInfo(Printout)
 
 487     %typemap(out) wxPyPrintout*;    // turn off this typemap
 
 489     wxPyPrintout(const wxString& title = wxPyPrintoutTitleStr);
 
 492     // Turn it back on again
 
 493     %typemap(out) wxPyPrintout* { $result = wxPyMake_wxObject($1, $owner); }
 
 495     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 498     wxString GetTitle() const;
 
 500     void SetDC(wxDC *dc);
 
 503     void FitThisSizeToPaper(const wxSize& imageSize);
 
 504     void FitThisSizeToPage(const wxSize& imageSize);
 
 505     void FitThisSizeToPageMargins(const wxSize& imageSize, const wxPageSetupDialogData& pageSetupData);
 
 506     void MapScreenSizeToPaper();
 
 507     void MapScreenSizeToPage();
 
 508     void MapScreenSizeToPageMargins(const wxPageSetupDialogData& pageSetupData);
 
 509     void MapScreenSizeToDevice();
 
 511     wxRect GetLogicalPaperRect() const;
 
 512     wxRect GetLogicalPageRect() const;
 
 513     wxRect GetLogicalPageMarginsRect(const wxPageSetupDialogData& pageSetupData) const;
 
 515     void SetLogicalOrigin(wxCoord x, wxCoord y);
 
 516     void OffsetLogicalOrigin(wxCoord xoff, wxCoord yoff);
 
 519     void SetPageSizePixels(int w, int  h);
 
 521         void, GetPageSizePixels(int *OUTPUT, int *OUTPUT),
 
 522         "GetPageSizePixels() -> (w, h)");
 
 524     void SetPageSizeMM(int w, int  h);
 
 526         void, GetPageSizeMM(int *OUTPUT, int *OUTPUT),
 
 527         "GetPageSizeMM() -> (w, h)");
 
 529     void SetPPIScreen(int x, int y);
 
 531         void, GetPPIScreen(int *OUTPUT, int *OUTPUT),
 
 532         "GetPPIScreen() -> (x,y)");
 
 534     void SetPPIPrinter(int x, int y);
 
 536         void, GetPPIPrinter(int *OUTPUT, int *OUTPUT),
 
 537         "GetPPIPrinter() -> (x,y)");
 
 539     void SetPaperRectPixels(const wxRect& paperRectPixels);
 
 540     wxRect GetPaperRectPixels() const;
 
 543     void SetIsPreview(bool p);
 
 546     bool OnBeginDocument(int startPage, int endPage);
 
 547     void OnEndDocument();
 
 548     void OnBeginPrinting();
 
 549     void OnEndPrinting();
 
 550     void OnPreparePrinting();
 
 551     bool HasPage(int page);
 
 553         void, GetPageInfo(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT),
 
 554         "GetPageInfo() -> (minPage, maxPage, pageFrom, pageTo)");
 
 556     %MAKE_BASE_FUNC(Printout, OnBeginDocument);
 
 557     %MAKE_BASE_FUNC(Printout, OnEndDocument);
 
 558     %MAKE_BASE_FUNC(Printout, OnBeginPrinting);
 
 559     %MAKE_BASE_FUNC(Printout, OnEndPrinting);
 
 560     %MAKE_BASE_FUNC(Printout, OnPreparePrinting);
 
 561     %MAKE_BASE_FUNC(Printout, GetPageInfo);
 
 564     %property(DC, GetDC, SetDC, doc="See `GetDC` and `SetDC`");
 
 565     %property(PPIPrinter, GetPPIPrinter, SetPPIPrinter, doc="See `GetPPIPrinter` and `SetPPIPrinter`");
 
 566     %property(PPIScreen, GetPPIScreen, SetPPIScreen, doc="See `GetPPIScreen` and `SetPPIScreen`");
 
 567     %property(PageSizeMM, GetPageSizeMM, SetPageSizeMM, doc="See `GetPageSizeMM` and `SetPageSizeMM`");
 
 568     %property(PageSizePixels, GetPageSizePixels, SetPageSizePixels, doc="See `GetPageSizePixels` and `SetPageSizePixels`");
 
 569     %property(Title, GetTitle, doc="See `GetTitle`");
 
 572 //---------------------------------------------------------------------------
 
 576 MustHaveApp(wxPreviewCanvas);
 
 578 class wxPreviewCanvas: public wxScrolledWindow
 
 581     %pythonAppend wxPreviewCanvas   "self._setOORInfo(self)"
 
 583     wxPreviewCanvas(wxPrintPreview *preview,
 
 585                     const wxPoint& pos = wxDefaultPosition,
 
 586                     const wxSize& size = wxDefaultSize,
 
 588                     const wxString& name = wxPyPreviewCanvasNameStr);
 
 592 MustHaveApp(wxPreviewFrame);
 
 594 class wxPreviewFrame : public wxFrame {
 
 596     %disownarg(wxPrintPreview*);
 
 598     %pythonAppend wxPreviewFrame   "self._setOORInfo(self)"
 
 599     wxPreviewFrame(wxPrintPreview* preview, wxFrame* parent, const wxString& title,
 
 600                    const wxPoint& pos = wxDefaultPosition,
 
 601                    const wxSize&  size = wxDefaultSize,
 
 602                    long style = wxDEFAULT_FRAME_STYLE,
 
 603                    const wxString& name = wxPyFrameNameStr);
 
 605     %cleardisown(wxPrintPreview*);
 
 608     void CreateControlBar();
 
 611     wxPreviewControlBar* GetControlBar() const;
 
 613     %property(ControlBar, GetControlBar, doc="See `GetControlBar`");
 
 630     wxID_PREVIEW_PREVIOUS,
 
 638 MustHaveApp(wxPreviewControlBar);
 
 640 class wxPreviewControlBar: public wxPanel
 
 643     %pythonAppend wxPreviewControlBar   "self._setOORInfo(self)"
 
 645     wxPreviewControlBar(wxPrintPreview *preview,
 
 648                         const wxPoint& pos = wxDefaultPosition,
 
 649                         const wxSize& size = wxDefaultSize,
 
 650                         long style = wxTAB_TRAVERSAL,
 
 651                         const wxString& name = wxPyPanelNameStr);
 
 653     int GetZoomControl();
 
 654     void SetZoomControl(int zoom);
 
 655     wxPrintPreview* GetPrintPreview();
 
 663     %property(PrintPreview, GetPrintPreview, doc="See `GetPrintPreview`");
 
 664     %property(ZoomControl, GetZoomControl, SetZoomControl, doc="See `GetZoomControl` and `SetZoomControl`");    
 
 669 //---------------------------------------------------------------------------
 
 671 MustHaveApp(wxPrintPreview);
 
 673 class wxPrintPreview : public wxObject {
 
 675     %disownarg(wxPyPrintout*);
 
 677     %nokwargs wxPrintPreview;
 
 678     wxPrintPreview(wxPyPrintout* printout,
 
 679                    wxPyPrintout* printoutForPrinting,
 
 680                    wxPrintDialogData *data=NULL);
 
 681     wxPrintPreview(wxPyPrintout* printout,
 
 682                   wxPyPrintout* printoutForPrinting,
 
 687     virtual bool SetCurrentPage(int pageNum);
 
 688     int GetCurrentPage();
 
 690     void SetPrintout(wxPyPrintout *printout);
 
 691     wxPyPrintout *GetPrintout();
 
 692     wxPyPrintout *GetPrintoutForPrinting();
 
 694     %cleardisown(wxPyPrintout*);
 
 696     void SetFrame(wxFrame *frame);
 
 697     void SetCanvas(wxPreviewCanvas *canvas);
 
 699     virtual wxFrame *GetFrame();
 
 700     virtual wxPreviewCanvas *GetCanvas();
 
 702     // The preview canvas should call this from OnPaint
 
 703     virtual bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc);
 
 705     // This draws a blank page onto the preview canvas
 
 706     virtual bool DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc);
 
 708     // This is called by wxPrintPreview to render a page into a wxMemoryDC.
 
 709     virtual bool RenderPage(int pageNum);
 
 711     // Adjusts the scrollbars for the current scale
 
 712     virtual void AdjustScrollbars(wxPreviewCanvas *canvas);
 
 714     wxPrintDialogData& GetPrintDialogData();
 
 716     virtual void SetZoom(int percent);
 
 723     %pythoncode { Ok = IsOk }
 
 726     virtual bool Print(bool interactive);
 
 727     virtual void DetermineScaling();
 
 729     %pythoncode { def __nonzero__(self): return self.IsOk() }
 
 731     %property(Canvas, GetCanvas, SetCanvas, doc="See `GetCanvas` and `SetCanvas`");
 
 732     %property(CurrentPage, GetCurrentPage, SetCurrentPage, doc="See `GetCurrentPage` and `SetCurrentPage`");
 
 733     %property(Frame, GetFrame, SetFrame, doc="See `GetFrame` and `SetFrame`");
 
 734     %property(MaxPage, GetMaxPage, doc="See `GetMaxPage`");
 
 735     %property(MinPage, GetMinPage, doc="See `GetMinPage`");
 
 736     %property(PrintDialogData, GetPrintDialogData, doc="See `GetPrintDialogData`");
 
 737     %property(Printout, GetPrintout, SetPrintout, doc="See `GetPrintout` and `SetPrintout`");
 
 738     %property(PrintoutForPrinting, GetPrintoutForPrinting, doc="See `GetPrintoutForPrinting`");
 
 739     %property(Zoom, GetZoom, SetZoom, doc="See `GetZoom` and `SetZoom`");
 
 744 //---------------------------------------------------------------------------
 
 746 // Python-derivable versions of the above preview classes
 
 750 #define DEC_PYCALLBACK_BOOL_PREWINDC(CBNAME)                                            \
 
 751     bool CBNAME(wxPreviewCanvas* a, wxDC& b)
 
 754 #define IMP_PYCALLBACK_BOOL_PREWINDC(CLASS, PCLASS, CBNAME)                             \
 
 755     bool CLASS::CBNAME(wxPreviewCanvas* a, wxDC& b) {                                   \
 
 758         wxPyBlock_t blocked = wxPyBeginBlockThreads();                                  \
 
 759         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                        \
 
 760             PyObject* win = wxPyMake_wxObject(a,false);                                 \
 
 761             PyObject* dc  = wxPyMake_wxObject(&b,false);                                \
 
 762             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc));      \
 
 766         wxPyEndBlockThreads(blocked);                                                   \
 
 768             rval = PCLASS::CBNAME(a, b);                                                \
 
 775 class wxPyPrintPreview : public wxPrintPreview
 
 777     DECLARE_CLASS(wxPyPrintPreview)
 
 779     wxPyPrintPreview(wxPyPrintout* printout,
 
 780                      wxPyPrintout* printoutForPrinting,
 
 781                      wxPrintDialogData* data=NULL)
 
 782         : wxPrintPreview(printout, printoutForPrinting, data)
 
 784     wxPyPrintPreview(wxPyPrintout* printout,
 
 785                      wxPyPrintout* printoutForPrinting,
 
 787         : wxPrintPreview(printout, printoutForPrinting, data)
 
 790     DEC_PYCALLBACK_BOOL_INT(SetCurrentPage);
 
 791     DEC_PYCALLBACK_BOOL_PREWINDC(PaintPage);
 
 792     DEC_PYCALLBACK_BOOL_PREWINDC(DrawBlankPage);
 
 793     DEC_PYCALLBACK_BOOL_INT(RenderPage);
 
 794     DEC_PYCALLBACK_VOID_INT(SetZoom);
 
 795     DEC_PYCALLBACK_BOOL_BOOL(Print);
 
 796     DEC_PYCALLBACK_VOID_(DetermineScaling);
 
 801 // Stupid renamed classes...  Fix this in 2.5...
 
 802 #if defined(__WXMSW__)
 
 803 IMPLEMENT_CLASS( wxPyPrintPreview, wxWindowsPrintPreview );
 
 804 #elif defined(__WXMAC__)
 
 805 IMPLEMENT_CLASS( wxPyPrintPreview, wxMacPrintPreview );
 
 807 IMPLEMENT_CLASS( wxPyPrintPreview, wxPostScriptPrintPreview );
 
 810 IMP_PYCALLBACK_BOOL_INT     (wxPyPrintPreview, wxPrintPreview, SetCurrentPage);
 
 811 IMP_PYCALLBACK_BOOL_PREWINDC(wxPyPrintPreview, wxPrintPreview, PaintPage);
 
 812 IMP_PYCALLBACK_BOOL_PREWINDC(wxPyPrintPreview, wxPrintPreview, DrawBlankPage);
 
 813 IMP_PYCALLBACK_BOOL_INT     (wxPyPrintPreview, wxPrintPreview, RenderPage);
 
 814 IMP_PYCALLBACK_VOID_INT     (wxPyPrintPreview, wxPrintPreview, SetZoom);
 
 815 IMP_PYCALLBACK_BOOL_BOOL    (wxPyPrintPreview, wxPrintPreview, Print);
 
 816 IMP_PYCALLBACK_VOID_        (wxPyPrintPreview, wxPrintPreview, DetermineScaling);
 
 820 MustHaveApp(wxPyPrintPreview);
 
 822 class wxPyPrintPreview : public wxPrintPreview
 
 825     %disownarg(wxPyPrintout*);
 
 827     %pythonAppend wxPyPrintPreview   setCallbackInfo(PyPrintPreview)
 
 828     %nokwargs wxPyPrintPreview;
 
 829     wxPyPrintPreview(wxPyPrintout* printout,
 
 830                      wxPyPrintout* printoutForPrinting,
 
 831                      wxPrintDialogData* data=NULL);
 
 832     wxPyPrintPreview(wxPyPrintout* printout,
 
 833                      wxPyPrintout* printoutForPrinting,
 
 836     %cleardisown(wxPyPrintout*);
 
 838     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 840     bool SetCurrentPage(int pageNum);
 
 841     bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc);
 
 842     bool DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc);
 
 843     bool RenderPage(int pageNum);
 
 844     void SetZoom(int percent);
 
 845     bool Print(bool interactive);
 
 846     void DetermineScaling();
 
 848     %MAKE_BASE_FUNC(PyPrintPreview, SetCurrentPage);
 
 849     %MAKE_BASE_FUNC(PyPrintPreview, PaintPage);
 
 850     %MAKE_BASE_FUNC(PyPrintPreview, DrawBlankPage);
 
 851     %MAKE_BASE_FUNC(PyPrintPreview, RenderPage);
 
 852     %MAKE_BASE_FUNC(PyPrintPreview, SetZoom);
 
 853     %MAKE_BASE_FUNC(PyPrintPreview, Print);
 
 854     %MAKE_BASE_FUNC(PyPrintPreview, DetermineScaling);
 
 861 class wxPyPreviewFrame : public wxPreviewFrame
 
 863     DECLARE_CLASS(wxPyPreviewFrame)
 
 865     wxPyPreviewFrame(wxPrintPreview* preview, wxFrame* parent,
 
 866                      const wxString& title,
 
 867                      const wxPoint& pos = wxDefaultPosition,
 
 868                      const wxSize&  size = wxDefaultSize,
 
 869                      long style = wxDEFAULT_FRAME_STYLE,
 
 870                      const wxString& name = wxPyFrameNameStr)
 
 871         : wxPreviewFrame(preview, parent, title, pos, size, style, name)
 
 874     void SetPreviewCanvas(wxPreviewCanvas* canvas) { m_previewCanvas = canvas; }
 
 875     void SetControlBar(wxPreviewControlBar* bar) { m_controlBar = bar; }
 
 877     DEC_PYCALLBACK_VOID_(Initialize);
 
 878     DEC_PYCALLBACK_VOID_(CreateCanvas);
 
 879     DEC_PYCALLBACK_VOID_(CreateControlBar);
 
 884 IMPLEMENT_CLASS(wxPyPreviewFrame, wxPreviewFrame);
 
 886 IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, Initialize);
 
 887 IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, CreateCanvas);
 
 888 IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, CreateControlBar);
 
 892 MustHaveApp(wxPyPreviewFrame);
 
 894 class wxPyPreviewFrame : public wxPreviewFrame
 
 897     %disownarg(wxPrintPreview*);
 
 898     %pythonAppend wxPyPreviewFrame "self._setOORInfo(self);" setCallbackInfo(PyPreviewFrame) 
 
 900     wxPyPreviewFrame(wxPrintPreview* preview, wxFrame* parent,
 
 901                      const wxString& title,
 
 902                      const wxPoint& pos = wxDefaultPosition,
 
 903                      const wxSize&  size = wxDefaultSize,
 
 904                      long style = wxDEFAULT_FRAME_STYLE,
 
 905                      const wxString& name = wxPyFrameNameStr);
 
 907     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 909     void SetPreviewCanvas(wxPreviewCanvas* canvas);
 
 910     void SetControlBar(wxPreviewControlBar* bar);
 
 914     void CreateControlBar();
 
 916     %MAKE_BASE_FUNC(PyPreviewFrame, Initialize);
 
 917     %MAKE_BASE_FUNC(PyPreviewFrame, CreateCanvas);
 
 918     %MAKE_BASE_FUNC(PyPreviewFrame, CreateControlBar);
 
 925 class wxPyPreviewControlBar : public wxPreviewControlBar
 
 927     DECLARE_CLASS(wxPyPreviewControlBar)
 
 929     wxPyPreviewControlBar(wxPrintPreview *preview,
 
 932                           const wxPoint& pos = wxDefaultPosition,
 
 933                           const wxSize& size = wxDefaultSize,
 
 935                           const wxString& name = wxPyPanelNameStr)
 
 936         : wxPreviewControlBar(preview, buttons, parent, pos, size, style, name)
 
 939     void SetPrintPreview(wxPrintPreview* preview) { m_printPreview = preview; }
 
 941     DEC_PYCALLBACK_VOID_(CreateButtons);
 
 942     DEC_PYCALLBACK_VOID_INT(SetZoomControl);
 
 947 IMPLEMENT_CLASS(wxPyPreviewControlBar, wxPreviewControlBar);
 
 948 IMP_PYCALLBACK_VOID_(wxPyPreviewControlBar, wxPreviewControlBar, CreateButtons);
 
 949 IMP_PYCALLBACK_VOID_INT(wxPyPreviewControlBar, wxPreviewControlBar, SetZoomControl);
 
 953 MustHaveApp(wxPyPreviewControlBar);
 
 955 class wxPyPreviewControlBar : public wxPreviewControlBar
 
 958     %pythonAppend wxPyPreviewControlBar   "self._setOORInfo(self);" setCallbackInfo(PyPreviewControlBar)
 
 960     wxPyPreviewControlBar(wxPrintPreview *preview,
 
 963                           const wxPoint& pos = wxDefaultPosition,
 
 964                           const wxSize& size = wxDefaultSize,
 
 966                           const wxString& name = wxPyPanelNameStr);
 
 968     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 970     void SetPrintPreview(wxPrintPreview* preview);
 
 972     void CreateButtons();
 
 973     void SetZoomControl(int zoom);
 
 975     %MAKE_BASE_FUNC(PreviewControlBar, CreateButtons);
 
 976     %MAKE_BASE_FUNC(PreviewControlBar, SetZoomControl);
 
 979 //---------------------------------------------------------------------------
 
 980 //---------------------------------------------------------------------------
 
 982     wxPyPtrTypeMap_Add("wxPrintout", "wxPyPrintout");
 
 984 //---------------------------------------------------------------------------