1 ///////////////////////////////////////////////////////////////////////////// 2 // Name: wx/generic/dcpsg.h 3 // Purpose: wxPostScriptDC class 4 // Author: Julian Smart and others 5 // Modified by: 6 // Copyright: (c) Julian Smart and Robert Roebling 7 // Licence: wxWindows licence 8 ///////////////////////////////////////////////////////////////////////////// 9 10 #ifndef _WX_DCPSG_H_ 11 #define _WX_DCPSG_H_ 12 13 #include "wx/defs.h" 14 15 #if wxUSE_PRINTING_ARCHITECTURE && wxUSE_POSTSCRIPT 16 17 #include "wx/dc.h" 18 #include "wx/dcprint.h" 19 #include "wx/dialog.h" 20 #include "wx/module.h" 21 #include "wx/cmndata.h" 22 #include "wx/strvararg.h" 23 24 //----------------------------------------------------------------------------- 25 // wxPostScriptDC 26 //----------------------------------------------------------------------------- 27 28 29 class WXDLLIMPEXP_CORE wxPostScriptDC : public wxDC 30 { 31 public: 32 wxPostScriptDC(); 33 34 // Recommended constructor 35 wxPostScriptDC(const wxPrintData& printData); 36 37 private: 38 DECLARE_DYNAMIC_CLASS(wxPostScriptDC) 39 }; 40 41 class WXDLLIMPEXP_CORE wxPostScriptDCImpl : public wxDCImpl 42 { 43 public: 44 wxPostScriptDCImpl( wxPrinterDC *owner ); 45 wxPostScriptDCImpl( wxPrinterDC *owner, const wxPrintData& data ); 46 wxPostScriptDCImpl( wxPostScriptDC *owner ); 47 wxPostScriptDCImpl( wxPostScriptDC *owner, const wxPrintData& data ); 48 49 void Init(); 50 51 virtual ~wxPostScriptDCImpl(); 52 Ok()53 virtual bool Ok() const { return IsOk(); } 54 virtual bool IsOk() const; 55 CanDrawBitmap()56 bool CanDrawBitmap() const { return true; } 57 58 void Clear(); 59 void SetFont( const wxFont& font ); 60 void SetPen( const wxPen& pen ); 61 void SetBrush( const wxBrush& brush ); 62 void SetLogicalFunction( wxRasterOperationMode function ); 63 void SetBackground( const wxBrush& brush ); 64 65 void DestroyClippingRegion(); 66 67 bool StartDoc(const wxString& message); 68 void EndDoc(); 69 void StartPage(); 70 void EndPage(); 71 72 wxCoord GetCharHeight() const; 73 wxCoord GetCharWidth() const; CanGetTextExtent()74 bool CanGetTextExtent() const { return true; } 75 76 // Resolution in pixels per logical inch 77 wxSize GetPPI() const; 78 79 virtual void ComputeScaleAndOrigin(); 80 SetBackgroundMode(int WXUNUSED (mode))81 void SetBackgroundMode(int WXUNUSED(mode)) { } SetPalette(const wxPalette & WXUNUSED (palette))82 void SetPalette(const wxPalette& WXUNUSED(palette)) { } 83 84 void SetPrintData(const wxPrintData& data); GetPrintData()85 wxPrintData& GetPrintData() { return m_printData; } 86 GetDepth()87 virtual int GetDepth() const { return 24; } 88 89 void PsPrint( const wxString& psdata ); 90 91 // Overrridden for wxPrinterDC Impl 92 93 virtual int GetResolution() const; 94 virtual wxRect GetPaperRect() const; 95 GetHandle()96 virtual void* GetHandle() const { return NULL; } 97 98 protected: 99 bool DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col, 100 wxFloodFillStyle style = wxFLOOD_SURFACE); 101 bool DoGetPixel(wxCoord x1, wxCoord y1, wxColour *col) const; 102 void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); 103 void DoCrossHair(wxCoord x, wxCoord y) ; 104 void DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc); 105 void DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea); 106 void DoDrawPoint(wxCoord x, wxCoord y); 107 void DoDrawLines(int n, const wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0); 108 void DoDrawPolygon(int n, const wxPoint points[], 109 wxCoord xoffset = 0, wxCoord yoffset = 0, 110 wxPolygonFillMode fillStyle = wxODDEVEN_RULE); 111 void DoDrawPolyPolygon(int n, const int count[], const wxPoint points[], 112 wxCoord xoffset = 0, wxCoord yoffset = 0, 113 wxPolygonFillMode fillStyle = wxODDEVEN_RULE); 114 void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); 115 void DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius = 20); 116 void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); 117 #if wxUSE_SPLINES 118 void DoDrawSpline(const wxPointList *points); 119 #endif 120 bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, 121 wxDC *source, wxCoord xsrc, wxCoord ysrc, 122 wxRasterOperationMode rop = wxCOPY, bool useMask = false, 123 wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord); 124 void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y); 125 void DoDrawBitmap(const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask = false); 126 void DoDrawText(const wxString& text, wxCoord x, wxCoord y); 127 void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle); 128 void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height); DoSetDeviceClippingRegion(const wxRegion & WXUNUSED (clip))129 void DoSetDeviceClippingRegion( const wxRegion &WXUNUSED(clip)) 130 { 131 wxFAIL_MSG( "not implemented" ); 132 } 133 void DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y, 134 wxCoord *descent = NULL, 135 wxCoord *externalLeading = NULL, 136 const wxFont *theFont = NULL) const; 137 void DoGetSize(int* width, int* height) const; 138 void DoGetSizeMM(int *width, int *height) const; 139 140 FILE* m_pstream; // PostScript output stream 141 unsigned char m_currentRed; 142 unsigned char m_currentGreen; 143 unsigned char m_currentBlue; 144 int m_pageNumber; 145 bool m_clipping; 146 double m_underlinePosition; 147 double m_underlineThickness; 148 wxPrintData m_printData; 149 double m_pageHeight; 150 151 private: 152 DECLARE_DYNAMIC_CLASS(wxPostScriptDCImpl) 153 }; 154 155 #endif 156 // wxUSE_POSTSCRIPT && wxUSE_PRINTING_ARCHITECTURE 157 158 #endif 159 // _WX_DCPSG_H_ 160