X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/147bf2639f28010ad095298941e9eb206328d2c1..4787c92d397bb4849b1248f5ba1875746434f4e2:/include/wx/gtk/gnome/gprint.h?ds=sidebyside diff --git a/include/wx/gtk/gnome/gprint.h b/include/wx/gtk/gnome/gprint.h index 2148bfbe5f..67d4f415c0 100644 --- a/include/wx/gtk/gnome/gprint.h +++ b/include/wx/gtk/gnome/gprint.h @@ -8,10 +8,8 @@ // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// -#ifndef __gprint_H__ -#define __gprint_H__ - -// Include wxWindows' headers +#ifndef _WX_GTK_GPRINT_H_ +#define _WX_GTK_GPRINT_H_ #include "wx/defs.h" @@ -20,11 +18,27 @@ #include "wx/print.h" #include "wx/printdlg.h" #include "wx/dc.h" +#include "wx/module.h" typedef struct _GnomePrintJob GnomePrintJob; typedef struct _GnomePrintContext GnomePrintContext; typedef struct _GnomePrintConfig GnomePrintConfig; +// ---------------------------------------------------------------------------- +// wxGnomePrintModule +// ---------------------------------------------------------------------------- + +class wxGnomePrintModule: public wxModule +{ +public: + wxGnomePrintModule() {} + bool OnInit(); + void OnExit(); + +private: + DECLARE_DYNAMIC_CLASS(wxGnomePrintModule) +}; + //---------------------------------------------------------------------------- // wxGnomePrintNativeData //---------------------------------------------------------------------------- @@ -50,7 +64,6 @@ private: GnomePrintConfig *m_config; GnomePrintJob *m_job; -private: DECLARE_DYNAMIC_CLASS(wxGnomePrintNativeData) }; @@ -78,7 +91,11 @@ public: virtual wxPageSetupDialogBase *CreatePageSetupDialog( wxWindow *parent, wxPageSetupDialogData * data = NULL ); +#if wxUSE_NEW_DC + virtual wxDCImpl* CreatePrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data ); +#else virtual wxDC* CreatePrinterDC( const wxPrintData& data ); +#endif virtual bool HasPrintSetupDialog(); virtual wxDialog *CreatePrintSetupDialog( wxWindow *parent, wxPrintData *data ); @@ -116,7 +133,7 @@ public: virtual bool TransferDataToWindow(); virtual bool TransferDataFromWindow(); -private: +protected: // Implement some base class methods to do nothing to avoid asserts and // GTK warnings, since this is not a real wxDialog. virtual void DoSetSize(int WXUNUSED(x), int WXUNUSED(y), @@ -125,10 +142,10 @@ private: virtual void DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height)) {} +private: void Init(); wxPrintDialogData m_printDialogData; -private: DECLARE_DYNAMIC_CLASS(wxGnomePrintDialog) }; @@ -151,7 +168,7 @@ public: virtual bool TransferDataToWindow(); virtual bool TransferDataFromWindow(); -private: +protected: // Implement some base class methods to do nothing to avoid asserts and // GTK warnings, since this is not a real wxDialog. virtual void DoSetSize(int WXUNUSED(x), int WXUNUSED(y), @@ -160,9 +177,9 @@ private: virtual void DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height)) {} +private: wxPageSetupDialogData m_pageDialogData; -private: DECLARE_DYNAMIC_CLASS(wxGnomePageSetupDialog) }; @@ -182,101 +199,103 @@ public: virtual wxDC* PrintDialog(wxWindow *parent); virtual bool Setup(wxWindow *parent); - GnomePrintContext *GetPrintContext() { return m_gpc; } - private: - GnomePrintContext *m_gpc; bool m_native_preview; private: DECLARE_DYNAMIC_CLASS(wxGnomePrinter) - DECLARE_NO_COPY_CLASS(wxGnomePrinter) + wxDECLARE_NO_COPY_CLASS(wxGnomePrinter); }; //----------------------------------------------------------------------------- -// wxGnomePrintDC +// wxGnomePrinterDC //----------------------------------------------------------------------------- -class wxGnomePrintDC: public wxDC +#if wxUSE_NEW_DC +class wxGnomePrinterDCImpl : public wxDCImpl +#else +#define wxGnomePrinterDCImpl wxGnomePrinterDC +class wxGnomePrinterDC : public wxDC +#endif { public: - wxGnomePrintDC( wxGnomePrinter *printer ); - wxGnomePrintDC( const wxPrintData& data ); - virtual ~wxGnomePrintDC(); +#if wxUSE_NEW_DC + wxGnomePrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data ); +#else + wxGnomePrinterDC( const wxPrintData& data ); +#endif + virtual ~wxGnomePrinterDCImpl(); bool Ok() const { return IsOk(); } bool IsOk() const; - bool DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col, int style=wxFLOOD_SURFACE ); + bool CanDrawBitmap() const { return true; } + void Clear(); + void SetFont( const wxFont& font ); + void SetPen( const wxPen& pen ); + void SetBrush( const wxBrush& brush ); + void SetLogicalFunction( wxRasterOperationMode function ); + void SetBackground( const wxBrush& brush ); + void DestroyClippingRegion(); + bool StartDoc(const wxString& message); + void EndDoc(); + void StartPage(); + void EndPage(); + wxCoord GetCharHeight() const; + wxCoord GetCharWidth() const; + bool CanGetTextExtent() const { return true; } + wxSize GetPPI() const; + virtual int GetDepth() const { return 24; } + void SetBackgroundMode(int WXUNUSED(mode)) { } + void SetPalette(const wxPalette& WXUNUSED(palette)) { } + +protected: + bool DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col, + wxFloodFillStyle style=wxFLOOD_SURFACE ); bool DoGetPixel(wxCoord x1, wxCoord y1, wxColour *col) const; void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); void DoCrossHair(wxCoord x, wxCoord y); void DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc); void DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea); void DoDrawPoint(wxCoord x, wxCoord y); - void DoDrawLines(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0); - void DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle=wxODDEVEN_RULE); - void DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle=wxODDEVEN_RULE); + void DoDrawLines(int n, const wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0); + void DoDrawPolygon(int n, const wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, wxPolygonFillMode fillStyle=wxODDEVEN_RULE); + void DoDrawPolyPolygon(int n, const int count[], const wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, wxPolygonFillMode fillStyle=wxODDEVEN_RULE); void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); void DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius = 20.0); void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); #if wxUSE_SPLINES - void DoDrawSpline(wxList *points); -#endif // wxUSE_SPLINES - + void DoDrawSpline(const wxPointList *points); +#endif bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, - wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop = wxCOPY, bool useMask = false, + wxDC *source, wxCoord xsrc, wxCoord ysrc, + wxRasterOperationMode = wxCOPY, bool useMask = false, wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord); void DoDrawIcon( const wxIcon& icon, wxCoord x, wxCoord y ); void DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask = false ); - bool CanDrawBitmap() const { return true; } - void DoDrawText(const wxString& text, wxCoord x, wxCoord y ); void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle); - void Clear(); - void SetFont( const wxFont& font ); - void SetPen( const wxPen& pen ); - void SetBrush( const wxBrush& brush ); - void SetLogicalFunction( int function ); - void SetBackground( const wxBrush& brush ); - void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height); - void DestroyClippingRegion(); - void DoSetClippingRegionAsRegion( const wxRegion &WXUNUSED(clip) ) { } - - bool StartDoc(const wxString& message); - void EndDoc(); - void StartPage(); - void EndPage(); - - wxCoord GetCharHeight() const; - wxCoord GetCharWidth() const; - bool CanGetTextExtent() const { return true; } + void DoSetDeviceClippingRegion( const wxRegion &WXUNUSED(clip) ) + { + wxFAIL_MSG( "not implemented" ); + } void DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y, - wxCoord *descent = (wxCoord *) NULL, - wxCoord *externalLeading = (wxCoord *) NULL, - wxFont *theFont = (wxFont *) NULL ) const; - + wxCoord *descent = NULL, + wxCoord *externalLeading = NULL, + const wxFont *theFont = NULL ) const; void DoGetSize(int* width, int* height) const; void DoGetSizeMM(int *width, int *height) const; - wxSize GetPPI() const; - void SetAxisOrientation( bool xLeftRight, bool yBottomUp ); - void SetDeviceOrigin( wxCoord x, wxCoord y ); - - virtual int GetDepth() const { return 24; } - - void SetBackgroundMode(int WXUNUSED(mode)) { } - void SetPalette(const wxPalette& WXUNUSED(palette)) { } + void SetPrintData(const wxPrintData& data); wxPrintData& GetPrintData() { return m_printData; } - void SetPrintData(const wxPrintData& data) { m_printData = data; } - - static void SetResolution(int ppi); - static int GetResolution(); -private: - static float ms_PSScaleFactor; + // overridden for wxPrinterDC Impl + virtual wxRect GetPaperRect() const; + virtual int GetResolution() const; + virtual void* GetHandle() const { return (void*)m_gpc; } + private: wxPrintData m_printData; PangoContext *m_context; @@ -286,78 +305,17 @@ private: unsigned char m_currentRed; unsigned char m_currentGreen; unsigned char m_currentBlue; - wxPrintData m_printData; - wxGnomePrinter *m_printer; + double m_pageHeight; + GnomePrintContext *m_gpc; - GnomePrintJob* m_job; // only used and destroyed when created with wxPrintData + GnomePrintJob* m_job; 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; - } - 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); - } - 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; - } - 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); - } - 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; - } - 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); - } - 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; - } - 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); - } + private: - DECLARE_DYNAMIC_CLASS(wxGnomePrintDC) - DECLARE_NO_COPY_CLASS(wxGnomePrintDC) + DECLARE_DYNAMIC_CLASS(wxGnomePrinterDCImpl) + wxDECLARE_NO_COPY_CLASS(wxGnomePrinterDCImpl); }; // ---------------------------------------------------------------------------- @@ -365,12 +323,12 @@ private: // wxPrintout. // ---------------------------------------------------------------------------- -class wxGnomePreview : public wxPrintPreviewBase +class wxGnomePrintPreview : public wxPrintPreviewBase { public: wxGnomePrintPreview(wxPrintout *printout, - wxPrintout *printoutForPrinting = (wxPrintout *) NULL, - wxPrintDialogData *data = (wxPrintDialogData *) NULL); + wxPrintout *printoutForPrinting = NULL, + wxPrintDialogData *data = NULL); wxGnomePrintPreview(wxPrintout *printout, wxPrintout *printoutForPrinting, wxPrintData *data);