Remove several hack from PS code, use high resolution code from GNOME print, invert...
[wxWidgets.git] / include / wx / generic / dcpsg.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/dcps.h
3 // Purpose: wxPostScriptDC class
4 // Author: Julian Smart and others
5 // Modified by:
6 // RCS-ID: $Id$
7 // Copyright: (c) Julian Smart and Robert Roebling
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_DCPSG_H_
12 #define _WX_DCPSG_H_
13
14 #include "wx/defs.h"
15
16 #if wxUSE_PRINTING_ARCHITECTURE && wxUSE_POSTSCRIPT
17
18 #include "wx/dc.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 class WXDLLEXPORT wxPostScriptDC: public wxDC
29 {
30 public:
31 wxPostScriptDC();
32
33 // Recommended constructor
34 wxPostScriptDC(const wxPrintData& printData);
35
36 virtual ~wxPostScriptDC();
37
38 virtual bool Ok() const { return IsOk(); }
39 virtual bool IsOk() const;
40
41 bool CanDrawBitmap() const { return true; }
42
43 void Clear();
44 void SetFont( const wxFont& font );
45 void SetPen( const wxPen& pen );
46 void SetBrush( const wxBrush& brush );
47 void SetLogicalFunction( int function );
48 void SetBackground( const wxBrush& brush );
49
50 void DestroyClippingRegion();
51
52 bool StartDoc(const wxString& message);
53 void EndDoc();
54 void StartPage();
55 void EndPage();
56
57 wxCoord GetCharHeight() const;
58 wxCoord GetCharWidth() const;
59 bool CanGetTextExtent() const { return true; }
60
61 // Resolution in pixels per logical inch
62 wxSize GetPPI() const;
63
64 #if wxUSE_NEW_DC
65 #else
66 // these need to be overridden as wxPostscriptDC inherits
67 // from the platform dependent wxDC and this we'd call
68 // e.g. wxMSW specific code here.
69 virtual void SetAxisOrientation( bool xLeftRight, bool yBottomUp );
70 virtual void SetMapMode(int mode);
71 virtual void SetUserScale(double x, double y);
72 virtual void SetLogicalScale(double x, double y);
73 virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
74 virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
75 #endif
76
77 void SetBackgroundMode(int WXUNUSED(mode)) { }
78 void SetPalette(const wxPalette& WXUNUSED(palette)) { }
79
80 void SetPrintData(const wxPrintData& data);
81 wxPrintData& GetPrintData() { return m_printData; }
82
83 virtual int GetDepth() const { return 24; }
84
85 static void SetResolution(int ppi);
86 static int GetResolution();
87
88 void PsPrint( const wxString& psdata );
89
90 private:
91
92 protected:
93 bool DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col, int style = wxFLOOD_SURFACE);
94 bool DoGetPixel(wxCoord x1, wxCoord y1, wxColour *col) const;
95 void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
96 void DoCrossHair(wxCoord x, wxCoord y) ;
97 void DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc);
98 void DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea);
99 void DoDrawPoint(wxCoord x, wxCoord y);
100 void DoDrawLines(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0);
101 void DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle = wxODDEVEN_RULE);
102 void DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle = wxODDEVEN_RULE);
103 void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
104 void DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius = 20);
105 void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
106 #if wxUSE_SPLINES
107 void DoDrawSpline(wxList *points);
108 #endif // wxUSE_SPLINES
109 bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
110 wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop = wxCOPY, bool useMask = false,
111 wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord);
112 void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
113 void DoDrawBitmap(const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask = false);
114 void DoDrawText(const wxString& text, wxCoord x, wxCoord y);
115 void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
116 void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
117 void DoSetClippingRegionAsRegion( const wxRegion &WXUNUSED(clip)) { }
118 void DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
119 wxCoord *descent = NULL,
120 wxCoord *externalLeading = NULL,
121 const wxFont *theFont = NULL) const;
122 void DoGetSize(int* width, int* height) const;
123 void DoGetSizeMM(int *width, int *height) const;
124
125 FILE* m_pstream; // PostScript output stream
126 wxString m_title;
127 unsigned char m_currentRed;
128 unsigned char m_currentGreen;
129 unsigned char m_currentBlue;
130 int m_pageNumber;
131 bool m_clipping;
132 double m_underlinePosition;
133 double m_underlineThickness;
134 wxPrintData m_printData;
135 double m_pageHeight;
136
137 private:
138 DECLARE_DYNAMIC_CLASS(wxPostScriptDC)
139 };
140
141 #endif
142 // wxUSE_POSTSCRIPT && wxUSE_PRINTING_ARCHITECTURE
143
144 #endif
145 // _WX_DCPSG_H_