X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/389076f14811ac2c7ad5e3ffb3685b54e8f1944b..82972e922e61d323e65370236b18bd042ac8e3ef:/include/wx/gtk/gnome/gprint.h diff --git a/include/wx/gtk/gnome/gprint.h b/include/wx/gtk/gnome/gprint.h index ba03655e6d..52ddb8a356 100644 --- a/include/wx/gtk/gnome/gprint.h +++ b/include/wx/gtk/gnome/gprint.h @@ -11,21 +11,15 @@ #ifndef __gprint_H__ #define __gprint_H__ -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma interface -#endif - // Include wxWindows' headers -#ifndef WX_PRECOMP - #include -#endif +#include "wx/defs.h" #if wxUSE_LIBGNOMEPRINT #include "wx/print.h" -#include "wx/prntbase.h" #include "wx/printdlg.h" +#include "wx/dc.h" typedef struct _GnomePrintJob GnomePrintJob; typedef struct _GnomePrintContext GnomePrintContext; @@ -44,7 +38,8 @@ public: virtual bool TransferTo( wxPrintData &data ); virtual bool TransferFrom( const wxPrintData &data ); - virtual bool Ok() const { return true; } + virtual bool Ok() const { return IsOk(); } + virtual bool IsOk() const { return true; } GnomePrintConfig* GetPrintConfig() { return m_config; } void SetPrintJob( GnomePrintJob *job ) { m_job = job; } @@ -83,6 +78,8 @@ public: virtual wxPageSetupDialogBase *CreatePageSetupDialog( wxWindow *parent, wxPageSetupDialogData * data = NULL ); + virtual wxDC* CreatePrinterDC( const wxPrintData& data ); + virtual bool HasPrintSetupDialog(); virtual wxDialog *CreatePrintSetupDialog( wxWindow *parent, wxPrintData *data ); virtual bool HasOwnPrintToFile(); @@ -104,7 +101,7 @@ public: wxGnomePrintDialog( wxWindow *parent, wxPrintDialogData* data = NULL ); wxGnomePrintDialog( wxWindow *parent, wxPrintData* data); - ~wxGnomePrintDialog(); + virtual ~wxGnomePrintDialog(); wxPrintData& GetPrintData() { return m_printDialogData.GetPrintData(); } @@ -144,7 +141,7 @@ class wxGnomePageSetupDialog: public wxPageSetupDialogBase public: wxGnomePageSetupDialog( wxWindow *parent, wxPageSetupDialogData* data = NULL ); - ~wxGnomePageSetupDialog(); + virtual ~wxGnomePageSetupDialog(); virtual wxPageSetupDialogData& GetPageSetupDialogData(); @@ -204,12 +201,11 @@ class wxGnomePrintDC: public wxDC { public: wxGnomePrintDC( wxGnomePrinter *printer ); - ~wxGnomePrintDC(); - - bool Ok() const; + wxGnomePrintDC( const wxPrintData& data ); + virtual ~wxGnomePrintDC(); - virtual void BeginDrawing() {} - virtual void EndDrawing() {} + bool Ok() const { return IsOk(); } + bool IsOk() const; bool DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col, int style=wxFLOOD_SURFACE ); bool DoGetPixel(wxCoord x1, wxCoord y1, wxColour *col) const; @@ -282,6 +278,7 @@ private: static float ms_PSScaleFactor; private: + wxPrintData m_printData; PangoContext *m_context; PangoLayout *m_layout; PangoFontDescription *m_fontdesc; @@ -289,77 +286,79 @@ private: unsigned char m_currentRed; unsigned char m_currentGreen; unsigned char m_currentBlue; - wxPrintData m_printData; wxGnomePrinter *m_printer; GnomePrintContext *m_gpc; + GnomePrintJob* m_job; // only used and destroyed when created with wxPrintData + void makeEllipticalPath(wxCoord x, wxCoord y, wxCoord width, wxCoord height); + private: wxCoord XDEV2LOG(wxCoord x) const { - wxCoord new_x = x - m_deviceOriginX; - if (new_x > 0) - return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX; - else - return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX; + return wxRound((double)(x - m_deviceOriginX) / m_scaleX) * m_signX + m_logicalOriginX; } wxCoord XDEV2LOGREL(wxCoord x) const { - if (x > 0) - return (wxCoord)((double)(x) / m_scaleX + 0.5); - else - return (wxCoord)((double)(x) / m_scaleX - 0.5); + return wxRound((double)(x) / m_scaleX); } wxCoord YDEV2LOG(wxCoord y) const { - wxCoord new_y = y - m_deviceOriginY; - if (new_y > 0) - return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY; - else - return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY; + return wxRound((double)(y - m_deviceOriginY) / m_scaleY) * m_signY + m_logicalOriginY; } wxCoord YDEV2LOGREL(wxCoord y) const { - if (y > 0) - return (wxCoord)((double)(y) / m_scaleY + 0.5); - else - return (wxCoord)((double)(y) / m_scaleY - 0.5); + return wxRound((double)(y) / m_scaleY); } wxCoord XLOG2DEV(wxCoord x) const { - wxCoord new_x = x - m_logicalOriginX; - if (new_x > 0) - return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX; - else - return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX; + return wxRound((double)(x - m_logicalOriginX) * m_scaleX) * m_signX + m_deviceOriginX; } wxCoord XLOG2DEVREL(wxCoord x) const { - if (x > 0) - return (wxCoord)((double)(x) * m_scaleX + 0.5); - else - return (wxCoord)((double)(x) * m_scaleX - 0.5); + return wxRound((double)(x) * m_scaleX); } wxCoord YLOG2DEV(wxCoord y) const { - wxCoord new_y = y - m_logicalOriginY; - if (new_y > 0) - return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY; - else - return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY; + return wxRound((double)(y - m_logicalOriginY) * m_scaleY) * m_signY + m_deviceOriginY; } wxCoord YLOG2DEVREL(wxCoord y) const { - if (y > 0) - return (wxCoord)((double)(y) * m_scaleY + 0.5); - else - return (wxCoord)((double)(y) * m_scaleY - 0.5); + return wxRound((double)(y) * m_scaleY); } private: DECLARE_DYNAMIC_CLASS(wxGnomePrintDC) DECLARE_NO_COPY_CLASS(wxGnomePrintDC) }; +// ---------------------------------------------------------------------------- +// wxGnomePrintPreview: programmer creates an object of this class to preview a +// wxPrintout. +// ---------------------------------------------------------------------------- + +class wxGnomePrintPreview : public wxPrintPreviewBase +{ +public: + wxGnomePrintPreview(wxPrintout *printout, + wxPrintout *printoutForPrinting = (wxPrintout *) NULL, + wxPrintDialogData *data = (wxPrintDialogData *) NULL); + wxGnomePrintPreview(wxPrintout *printout, + wxPrintout *printoutForPrinting, + wxPrintData *data); + + virtual ~wxGnomePrintPreview(); + + virtual bool Print(bool interactive); + virtual void DetermineScaling(); + +private: + void Init(wxPrintout *printout, wxPrintout *printoutForPrinting); + +private: + DECLARE_CLASS(wxGnomePrintPreview) +}; + + #endif // wxUSE_LIBGNOMEPRINT