]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/printfw.i
reSWIGged
[wxWidgets.git] / wxPython / src / printfw.i
index 2586d6522933f8ad88d8dd845646c3eda835ae8a..70c69cf84ade8f1989f77d74feb967f75be15b03 100644 (file)
 #include "helpers.h"
 #include <wx/print.h>
 #include <wx/printdlg.h>
+#include <wx/dcps.h>
 
 #include "printfw.h"
 %}
 
 //----------------------------------------------------------------------
 
+%{
+    // Put some wx default wxChar* values into wxStrings.
+    static const wxChar* wxPrintoutTitleStr = wxT("Printout");
+    DECLARE_DEF_STRING(PrintoutTitleStr);
+    static const wxChar* wxPreviewCanvasNameStr = wxT("previewcanvas");
+    DECLARE_DEF_STRING(PreviewCanvasNameStr);
+
+    DECLARE_DEF_STRING(FrameNameStr);
+    DECLARE_DEF_STRING(PanelNameStr);
+    DECLARE_DEF_STRING(DialogNameStr);
+
+%}
+
+//----------------------------------------------------------------------
+
 %include typemaps.i
 %include my_typemaps.i
 
 
 //----------------------------------------------------------------------
 
+enum wxPrintMode
+{
+    wxPRINT_MODE_NONE =    0,
+    wxPRINT_MODE_PREVIEW = 1,   // Preview in external application
+    wxPRINT_MODE_FILE =    2,   // Print to file
+    wxPRINT_MODE_PRINTER = 3    // Send to printer
+};
+
 
 
-class wxPrintData {
+class wxPrintData : public wxObject {
 public:
     wxPrintData();
     ~wxPrintData();
@@ -50,6 +74,8 @@ public:
     bool GetCollate();
     int  GetOrientation();
 
+    bool Ok();
+
     const wxString& GetPrinterName();
     bool GetColour();
     wxDuplexMode GetDuplex();
@@ -69,31 +95,32 @@ public:
     void SetPaperSize(const wxSize& sz);
     void SetQuality(wxPrintQuality quality);
 
-//    // PostScript-specific data
-//      const wxString& GetPrinterCommand();
-//      const wxString& GetPrinterOptions();
-//      const wxString& GetPreviewCommand();
-//      const wxString& GetFilename();
-//      const wxString& GetFontMetricPath();
-//      double GetPrinterScaleX();
-//      double GetPrinterScaleY();
-//      long GetPrinterTranslateX();
-//      long GetPrinterTranslateY();
-//      wxPrintMode GetPrintMode();
-
-//      void SetPrinterCommand(const wxString& command);
-//      void SetPrinterOptions(const wxString& options);
-//      void SetPreviewCommand(const wxString& command);
-//      void SetFilename(const wxString& filename);
-//      void SetFontMetricPath(const wxString& path);
-//      void SetPrinterScaleX(double x);
-//      void SetPrinterScaleY(double y);
-//      void SetPrinterScaling(double x, double y);
-//      void SetPrinterTranslateX(long x);
-//      void SetPrinterTranslateY(long y);
-//      void SetPrinterTranslation(long x, long y);
-//      void SetPrintMode(wxPrintMode printMode);
-
+    // PostScript-specific data
+    const wxString& GetPrinterCommand();
+    const wxString& GetPrinterOptions();
+    const wxString& GetPreviewCommand();
+    const wxString& GetFilename();
+    const wxString& GetFontMetricPath();
+    double GetPrinterScaleX();
+    double GetPrinterScaleY();
+    long GetPrinterTranslateX();
+    long GetPrinterTranslateY();
+    wxPrintMode GetPrintMode();
+
+    void SetPrinterCommand(const wxString& command);
+    void SetPrinterOptions(const wxString& options);
+    void SetPreviewCommand(const wxString& command);
+    void SetFilename(const wxString& filename);
+    void SetFontMetricPath(const wxString& path);
+    void SetPrinterScaleX(double x);
+    void SetPrinterScaleY(double y);
+    void SetPrinterScaling(double x, double y);
+    void SetPrinterTranslateX(long x);
+    void SetPrinterTranslateY(long y);
+    void SetPrinterTranslation(long x, long y);
+    void SetPrintMode(wxPrintMode printMode);
+
+    %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
 };
 
 //----------------------------------------------------------------------
@@ -112,7 +139,23 @@ public:
 
 //---------------------------------------------------------------------------
 
-class wxPageSetupDialogData {
+class wxPostScriptDC : public wxDC {
+public:
+    wxPostScriptDC(const wxPrintData& printData);
+//     %name(wxPostScriptDC2)wxPostScriptDC(const wxString& output,
+//                                          bool interactive = TRUE,
+//                                          wxWindow* parent = NULL);
+
+    wxPrintData& GetPrintData();
+    void SetPrintData(const wxPrintData& data);
+
+    static void SetResolution(int ppi);
+    static int GetResolution();
+};
+
+//---------------------------------------------------------------------------
+
+class wxPageSetupDialogData : public wxObject {
 public:
     wxPageSetupDialogData();
     ~wxPageSetupDialogData();
@@ -140,6 +183,9 @@ public:
             return new wxPrintData(self->GetPrintData());  // force a copy
         }
     }
+
+    bool Ok();
+
     void SetDefaultInfo(bool flag);
     void SetDefaultMinMargins(bool flag);
     void SetMarginTopLeft(const wxPoint& pt);
@@ -149,6 +195,8 @@ public:
     void SetPaperId(wxPaperSize id);
     void SetPaperSize(const wxSize& size);
     void SetPrintData(const wxPrintData& printData);
+
+    %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
 };
 
 
@@ -165,37 +213,54 @@ public:
 //----------------------------------------------------------------------
 
 
-class wxPrintDialogData {
+class wxPrintDialogData : public wxObject {
 public:
     wxPrintDialogData();
     ~wxPrintDialogData();
 
-    void EnableHelp(bool flag);
-    void EnablePageNumbers(bool flag);
+    int GetFromPage() const;
+    int GetToPage() const;
+    int GetMinPage() const;
+    int GetMaxPage() const;
+    int GetNoCopies() const;
+    bool GetAllPages() const;
+    bool GetSelection() const;
+    bool GetCollate() const;
+    bool GetPrintToFile() const;
+    bool GetSetupDialog() const;
+
+    void SetFromPage(int v);
+    void SetToPage(int v);
+    void SetMinPage(int v);
+    void SetMaxPage(int v);
+    void SetNoCopies(int v);
+    void SetAllPages(bool flag);
+    void SetSelection(bool flag);
+    void SetCollate(bool flag);
+    void SetPrintToFile(bool flag);
+    void SetSetupDialog(bool flag);
+
     void EnablePrintToFile(bool flag);
     void EnableSelection(bool flag);
-    bool GetAllPages();
-    bool GetCollate();
-    int GetFromPage();
-    int GetMaxPage();
-    int GetMinPage();
-    int GetNoCopies();
+    void EnablePageNumbers(bool flag);
+    void EnableHelp(bool flag);
+
+    bool GetEnablePrintToFile() const;
+    bool GetEnableSelection() const;
+    bool GetEnablePageNumbers() const;
+    bool GetEnableHelp() const;
+
+    // Is this data OK for showing the print dialog?
+    bool Ok() const;
+
     %addmethods {
         %new wxPrintData* GetPrintData() {
             return new wxPrintData(self->GetPrintData());  // force a copy
         }
     }
-    bool GetPrintToFile();
-    int GetToPage();
-    void SetCollate(bool flag);
-    void SetFromPage(int page);
-    void SetMaxPage(int page);
-    void SetMinPage(int page);
-    void SetNoCopies(int n);
     void SetPrintData(const wxPrintData& printData);
-    void SetPrintToFile(bool flag);
-    void SetSetupDialog(bool flag);
-    void SetToPage(int page);
+
+    %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
 };
 
 
@@ -219,9 +284,10 @@ public:
 // Since this one would be tough and ugly to do with the Macros...
 void wxPyPrintout::GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) {
     bool hadErr = FALSE;
+    bool found;
 
-    bool doSave = wxPyRestoreThread();
-    if (m_myInst.findCallback("GetPageInfo")) {
+    wxPyBeginBlockThreads();
+    if ((found = m_myInst.findCallback("GetPageInfo"))) {
         PyObject* result = m_myInst.callCallbackObj(Py_BuildValue("()"));
         if (result && PyTuple_Check(result) && PyTuple_Size(result) == 4) {
             PyObject* val;
@@ -251,10 +317,9 @@ void wxPyPrintout::GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *p
         }
         Py_DECREF(result);
     }
-    else
+    wxPyEndBlockThreads();
+    if (! found)
         wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo);
-
-    wxPySaveThread(doSave);
 }
 
 void wxPyPrintout::base_GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) {
@@ -275,12 +340,12 @@ IMP_PYCALLBACK_BOOL_INT(wxPyPrintout, wxPrintout, HasPage);
 
 
 // Now define the custom class for SWIGging
-%name(wxPrintout) class wxPyPrintout {
+%name(wxPrintout) class wxPyPrintout  : public wxObject {
 public:
-    wxPyPrintout(const char* title = "Printout");
+    wxPyPrintout(const wxString& title = wxPyPrintoutTitleStr);
 
-    void _setSelf(PyObject* self, PyObject* _class);
-    %pragma(python) addtomethod = "__init__:self._setSelf(self, wxPrintout)"
+    void _setCallbackInfo(PyObject* self, PyObject* _class);
+    %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPrintout)"
 
     %addmethods {
         void Destroy() { delete self; }
@@ -304,46 +369,94 @@ public:
 
 //----------------------------------------------------------------------
 
-class wxPrinter {
+enum wxPrinterError
+{
+    wxPRINTER_NO_ERROR = 0,
+    wxPRINTER_CANCELLED,
+    wxPRINTER_ERROR
+};
+
+
+class wxPrinter : public wxObject {
 public:
     wxPrinter(wxPrintDialogData* data = NULL);
     ~wxPrinter();
 
-//    bool Abort();
     void CreateAbortWindow(wxWindow* parent, wxPyPrintout* printout);
     wxPrintDialogData& GetPrintDialogData();
     bool Print(wxWindow *parent, wxPyPrintout *printout, int prompt=TRUE);
     wxDC* PrintDialog(wxWindow *parent);
-    void ReportError(wxWindow *parent, wxPyPrintout *printout, char* message);
+    void ReportError(wxWindow *parent, wxPyPrintout *printout, const wxString& message);
     bool Setup(wxWindow *parent);
+    bool GetAbort();
+
+    static wxPrinterError GetLastError();
+};
+
+//----------------------------------------------------------------------
+
+class wxPrintAbortDialog: public wxDialog
+{
+public:
+    wxPrintAbortDialog(wxWindow *parent,
+                       const wxString& title,
+                       const wxPoint& pos = wxDefaultPosition,
+                       const wxSize& size = wxDefaultSize,
+                       long style = 0,
+                       const wxString& name = wxPyDialogNameStr);
+
 };
 
 //----------------------------------------------------------------------
 
-class wxPrintPreview {
+class wxPrintPreview : public wxObject {
 public:
-    wxPrintPreview(wxPyPrintout* printout, wxPyPrintout* printoutForPrinting, wxPrintData* data=NULL);
-//    ~wxPrintPreview();   **** ????
+    wxPrintPreview(wxPyPrintout* printout,
+                   wxPyPrintout* printoutForPrinting,
+                   wxPrintData* data=NULL);
 
-    wxWindow* GetCanvas();
+    virtual bool SetCurrentPage(int pageNum);
     int GetCurrentPage();
-    wxFrame * GetFrame();
-    int GetMaxPage();
-    int GetMinPage();
+
+    void SetPrintout(wxPyPrintout *printout);
+    wxPyPrintout *GetPrintout();
+    wxPyPrintout *GetPrintoutForPrinting();
+
+    void SetFrame(wxFrame *frame);
+    void SetCanvas(wxPreviewCanvas *canvas);
+
+    virtual wxFrame *GetFrame();
+    virtual wxPreviewCanvas *GetCanvas();
+
+    // The preview canvas should call this from OnPaint
+    virtual bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc);
+
+    // This draws a blank page onto the preview canvas
+    virtual bool DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc);
+
+    // This is called by wxPrintPreview to render a page into a wxMemoryDC.
+    virtual bool RenderPage(int pageNum);
+
+    // Adjusts the scrollbars for the current scale
+    virtual void AdjustScrollbars(wxPreviewCanvas *canvas);
+
     wxPrintDialogData& GetPrintDialogData();
-    wxPyPrintout * GetPrintout();
-    wxPyPrintout * GetPrintoutForPrinting();
+
+    virtual void SetZoom(int percent);
     int GetZoom();
+
+    int GetMaxPage();
+    int GetMinPage();
+
     bool Ok();
-    bool Print(bool prompt);
-    void SetCanvas(wxWindow* window);
-    void SetCurrentPage(int pageNum);
-    void SetFrame(wxFrame *frame);
-    void SetPrintout(wxPyPrintout *printout);
-    void SetZoom(int percent);
+    void SetOk(bool ok);
+
+    virtual bool Print(bool interactive);
+    virtual void DetermineScaling();
+
+    %pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
 };
 
-//----------------------------------------------------------------------
 
 class wxPreviewFrame : public wxFrame {
 public:
@@ -351,19 +464,284 @@ public:
                    const wxPoint& pos = wxDefaultPosition,
                    const wxSize&  size = wxDefaultSize,
                    long style = wxDEFAULT_FRAME_STYLE,
-                   char* name = "frame");
+                   const wxString& name = wxPyFrameNameStr);
 
-    %pragma(python) addtomethod = "__init__:#wx._StdFrameCallbacks(self)"
+    %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
 
     void Initialize();
+    void CreateControlBar();
+    void CreateCanvas();
+
+    wxPreviewControlBar* GetControlBar() const;
+};
+
+
+class wxPreviewCanvas: public wxScrolledWindow
+{
+public:
+    wxPreviewCanvas(wxPrintPreview *preview,
+                    wxWindow *parent,
+                    const wxPoint& pos = wxDefaultPosition,
+                    const wxSize& size = wxDefaultSize,
+                    long style = 0,
+                    const wxString& name = wxPyPreviewCanvasNameStr);
+    %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
+};
+
+
+
+enum {
+    wxPREVIEW_PRINT,
+    wxPREVIEW_PREVIOUS,
+    wxPREVIEW_NEXT,
+    wxPREVIEW_ZOOM,
+    wxPREVIEW_FIRST,
+    wxPREVIEW_LAST,
+    wxPREVIEW_GOTO,
+    wxPREVIEW_DEFAULT,
+
+    wxID_PREVIEW_CLOSE,
+    wxID_PREVIEW_NEXT,
+    wxID_PREVIEW_PREVIOUS,
+    wxID_PREVIEW_PRINT,
+    wxID_PREVIEW_ZOOM,
+    wxID_PREVIEW_FIRST,
+    wxID_PREVIEW_LAST,
+    wxID_PREVIEW_GOTO
+};
+
+class wxPreviewControlBar: public wxPanel
+{
+public:
+    wxPreviewControlBar(wxPrintPreview *preview,
+                        long buttons,
+                        wxWindow *parent,
+                        const wxPoint& pos = wxDefaultPosition,
+                        const wxSize& size = wxDefaultSize,
+                        long style = wxTAB_TRAVERSAL,
+                        const wxString& name = wxPyPanelNameStr);
+    %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
+
+    int GetZoomControl();
+    void SetZoomControl(int zoom);
+    wxPrintPreview* GetPrintPreview();
+
+    void OnNext();
+    void OnPrevious();
+    void OnFirst();
+    void OnLast();
+    void OnGoto();
+};
+
+
+//----------------------------------------------------------------------
+// Python-derivable versions of the above preview classes
+
+%{
+
+#define DEC_PYCALLBACK_BOOL_PREWINDC(CBNAME)                                    \
+    bool CBNAME(wxPreviewCanvas* a, wxDC& b);                                   \
+    bool base_##CBNAME(wxPreviewCanvas* a, wxDC& b)
+
+
+#define IMP_PYCALLBACK_BOOL_PREWINDC(CLASS, PCLASS, CBNAME)                     \
+    bool CLASS::CBNAME(wxPreviewCanvas* a, wxDC& b) {                           \
+        bool rval=FALSE;                                                        \
+        bool found;                                                             \
+        wxPyBeginBlockThreads();                                                \
+        if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
+            PyObject* win = wxPyMake_wxObject(a);                               \
+            PyObject* dc  = wxPyMake_wxObject(&b);                              \
+            rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc));\
+            Py_DECREF(win);                                                     \
+            Py_DECREF(dc);                                                      \
+        }                                                                       \
+        wxPyEndBlockThreads();                                                  \
+        if (! found)                                                            \
+            rval = PCLASS::CBNAME(a, b);                                        \
+        return rval;                                                            \
+    }                                                                           \
+    bool CLASS::base_##CBNAME(wxPreviewCanvas* a, wxDC& b) {                    \
+        return PCLASS::CBNAME(a, b);                                            \
+    }
+
+
+
+
+class wxPyPrintPreview : public wxPrintPreview
+{
+    DECLARE_CLASS(wxPyPrintPreview)
+public:
+    wxPyPrintPreview(wxPyPrintout* printout,
+                     wxPyPrintout* printoutForPrinting,
+                     wxPrintData* data=NULL)
+        : wxPrintPreview(printout, printoutForPrinting, data)
+    {}
+
+    DEC_PYCALLBACK_BOOL_INT(SetCurrentPage);
+    DEC_PYCALLBACK_BOOL_PREWINDC(PaintPage);
+    DEC_PYCALLBACK_BOOL_PREWINDC(DrawBlankPage);
+    DEC_PYCALLBACK_BOOL_INT(RenderPage);
+    DEC_PYCALLBACK_VOID_INT(SetZoom);
+    DEC_PYCALLBACK_BOOL_BOOL(Print);
+    DEC_PYCALLBACK_VOID_(DetermineScaling);
+
+    PYPRIVATE;
+};
 
-    // ****  need to use derived class so these can be properly overridden:
-    //void CreateControlBar()
-    //void CreateCanvas()
+// Stupid renamed classes...  Fix this in 2.5...
+#if defined(__WXMSW__)
+IMPLEMENT_CLASS( wxPyPrintPreview, wxWindowsPrintPreview );
+#elif defined(__WXMAC__)
+IMPLEMENT_CLASS( wxPyPrintPreview, wxMacPrintPreview );
+#else
+IMPLEMENT_CLASS( wxPyPrintPreview, wxPostScriptPrintPreview );
+#endif
+
+IMP_PYCALLBACK_BOOL_INT     (wxPyPrintPreview, wxPrintPreview, SetCurrentPage);
+IMP_PYCALLBACK_BOOL_PREWINDC(wxPyPrintPreview, wxPrintPreview, PaintPage);
+IMP_PYCALLBACK_BOOL_PREWINDC(wxPyPrintPreview, wxPrintPreview, DrawBlankPage);
+IMP_PYCALLBACK_BOOL_INT     (wxPyPrintPreview, wxPrintPreview, RenderPage);
+IMP_PYCALLBACK_VOID_INT     (wxPyPrintPreview, wxPrintPreview, SetZoom);
+IMP_PYCALLBACK_BOOL_BOOL    (wxPyPrintPreview, wxPrintPreview, Print);
+IMP_PYCALLBACK_VOID_        (wxPyPrintPreview, wxPrintPreview, DetermineScaling);
+%}
+
+
+class wxPyPrintPreview : public wxPrintPreview
+{
+public:
+    wxPyPrintPreview(wxPyPrintout* printout,
+                     wxPyPrintout* printoutForPrinting,
+                     wxPrintData* data=NULL);
+
+    void _setCallbackInfo(PyObject* self, PyObject* _class);
+    %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyPrintPreview)"
+
+    bool base_SetCurrentPage(int pageNum);
+    bool base_PaintPage(wxPreviewCanvas *canvas, wxDC& dc);
+    bool base_DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc);
+    bool base_RenderPage(int pageNum);
+    void base_SetZoom(int percent);
+    bool base_Print(bool interactive);
+    void base_DetermineScaling();
+};
+
+
+
+
+%{
+class wxPyPreviewFrame : public wxPreviewFrame
+{
+    DECLARE_CLASS(wxPyPreviewFrame);
+public:
+    wxPyPreviewFrame(wxPrintPreview* preview, wxFrame* parent,
+                     const wxString& title,
+                     const wxPoint& pos = wxDefaultPosition,
+                     const wxSize&  size = wxDefaultSize,
+                     long style = wxDEFAULT_FRAME_STYLE,
+                     const wxString& name = wxPyFrameNameStr)
+        : wxPreviewFrame(preview, parent, title, pos, size, style, name)
+    {}
+
+    void SetPreviewCanvas(wxPreviewCanvas* canvas) { m_previewCanvas = canvas; }
+    void SetControlBar(wxPreviewControlBar* bar) { m_controlBar = bar; }
+
+    DEC_PYCALLBACK_VOID_(Initialize);
+    DEC_PYCALLBACK_VOID_(CreateCanvas);
+    DEC_PYCALLBACK_VOID_(CreateControlBar);
+
+    PYPRIVATE;
+};
+
+IMPLEMENT_CLASS(wxPyPreviewFrame, wxPreviewFrame);
+
+IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, Initialize);
+IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, CreateCanvas);
+IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, CreateControlBar);
+%}
 
+class wxPyPreviewFrame : public wxPreviewFrame
+{
+public:
+    wxPyPreviewFrame(wxPrintPreview* preview, wxFrame* parent,
+                     const wxString& title,
+                     const wxPoint& pos = wxDefaultPosition,
+                     const wxSize&  size = wxDefaultSize,
+                     long style = wxDEFAULT_FRAME_STYLE,
+                     const wxString& name = wxPyFrameNameStr);
+
+    void _setCallbackInfo(PyObject* self, PyObject* _class);
+    %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyPreviewFrame)"
+    %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
+
+    void SetPreviewCanvas(wxPreviewCanvas* canvas);
+    void SetControlBar(wxPreviewControlBar* bar);
+
+    void base_Initialize();
+    void base_CreateCanvas();
+    void base_CreateControlBar();
 };
 
+
+
+
+%{
+class wxPyPreviewControlBar : public wxPreviewControlBar
+{
+    DECLARE_CLASS(wxPyPreviewControlBar);
+public:
+    wxPyPreviewControlBar(wxPrintPreview *preview,
+                          long buttons,
+                          wxWindow *parent,
+                          const wxPoint& pos = wxDefaultPosition,
+                          const wxSize& size = wxDefaultSize,
+                          long style = 0,
+                          const wxString& name = wxPyPanelNameStr)
+        : wxPreviewControlBar(preview, buttons, parent, pos, size, style, name)
+    {}
+
+    void SetPrintPreview(wxPrintPreview* preview) { m_printPreview = preview; }
+
+    DEC_PYCALLBACK_VOID_(CreateButtons);
+    DEC_PYCALLBACK_VOID_INT(SetZoomControl);
+
+    PYPRIVATE;
+};
+
+IMPLEMENT_CLASS(wxPyPreviewControlBar, wxPreviewControlBar);
+IMP_PYCALLBACK_VOID_(wxPyPreviewControlBar, wxPreviewControlBar, CreateButtons);
+IMP_PYCALLBACK_VOID_INT(wxPyPreviewControlBar, wxPreviewControlBar, SetZoomControl);
+%}
+
+class wxPyPreviewControlBar : public wxPreviewControlBar
+{
+public:
+    wxPyPreviewControlBar(wxPrintPreview *preview,
+                          long buttons,
+                          wxWindow *parent,
+                          const wxPoint& pos = wxDefaultPosition,
+                          const wxSize& size = wxDefaultSize,
+                          long style = 0,
+                          const wxString& name = wxPyPanelNameStr);
+
+    void _setCallbackInfo(PyObject* self, PyObject* _class);
+    %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyPreviewControlBar)"
+    %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
+
+    void SetPrintPreview(wxPrintPreview* preview);
+
+    void base_CreateButtons();
+    void base_SetZoomControl(int zoom);
+};
+
+
 //----------------------------------------------------------------------
+
+%init %{
+    wxPyPtrTypeMap_Add("wxPrintout", "wxPyPrintout");
+%}
+
 //----------------------------------------------------------------------
 //----------------------------------------------------------------------