Moved all the coordinate system calculation to wxDCBase
[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
17
18 #if wxUSE_POSTSCRIPT
19
20 #include "wx/dc.h"
21 #include "wx/dialog.h"
22 #include "wx/module.h"
23 #include "wx/cmndata.h"
24 #include "wx/strvararg.h"
25
26 extern WXDLLIMPEXP_DATA_CORE(int) wxPageNumber;
27
28 //-----------------------------------------------------------------------------
29 // classes
30 //-----------------------------------------------------------------------------
31
32 class wxPostScriptDC;
33
34 //-----------------------------------------------------------------------------
35 // wxPostScriptDC
36 //-----------------------------------------------------------------------------
37
38 class WXDLLEXPORT wxPostScriptDC: public wxDC
39 {
40 public:
41 wxPostScriptDC();
42
43 // Recommended constructor
44 wxPostScriptDC(const wxPrintData& printData);
45
46 virtual ~wxPostScriptDC();
47
48 virtual bool Ok() const { return IsOk(); }
49 virtual bool IsOk() const;
50
51 bool CanDrawBitmap() const { return true; }
52
53 void Clear();
54 void SetFont( const wxFont& font );
55 void SetPen( const wxPen& pen );
56 void SetBrush( const wxBrush& brush );
57 void SetLogicalFunction( int function );
58 void SetBackground( const wxBrush& brush );
59
60 void DestroyClippingRegion();
61
62 bool StartDoc(const wxString& message);
63 void EndDoc();
64 void StartPage();
65 void EndPage();
66
67 wxCoord GetCharHeight() const;
68 wxCoord GetCharWidth() const;
69 bool CanGetTextExtent() const { return true; }
70
71 // Resolution in pixels per logical inch
72 wxSize GetPPI() const;
73
74 // overridden because origin is bottom left and
75 // axes are inverted
76 void SetAxisOrientation( bool xLeftRight, bool yBottomUp );
77
78 // these need to be overridden as wxPostscriptDC inherits
79 // from the platform dependent wxDC and this we'd call
80 // e.g. wxMSW specific code here.
81 virtual void SetMapMode(int mode);
82 virtual void SetUserScale(double x, double y);
83 virtual void SetLogicalScale(double x, double y);
84 virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
85 virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
86
87 void SetBackgroundMode(int WXUNUSED(mode)) { }
88 void SetPalette(const wxPalette& WXUNUSED(palette)) { }
89
90 void SetPrintData(const wxPrintData& data);
91 wxPrintData& GetPrintData() { return m_printData; }
92
93 virtual int GetDepth() const { return 24; }
94
95 static void SetResolution(int ppi);
96 static int GetResolution();
97
98 WX_DEFINE_VARARG_FUNC_VOID(PsPrintf, 1, (const wxString&), DoPsPrintfFormat)
99 #ifdef __WATCOMC__
100 // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
101 WX_DEFINE_VARARG_FUNC_VOID(PsPrintf, 1, (const char*), DoPsPrintfFormat)
102 WX_DEFINE_VARARG_FUNC_VOID(PsPrintf, 1, (const wchar_t*), DoPsPrintfFormat)
103 #endif
104 void PsPrint( const wxString& psdata );
105 void PsPrint( int ch );
106
107 private:
108 void DoPsPrintfFormat(const wxString& fmt, ... );
109
110 static float ms_PSScaleFactor;
111
112 protected:
113 bool DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col, int style = wxFLOOD_SURFACE);
114 bool DoGetPixel(wxCoord x1, wxCoord y1, wxColour *col) const;
115 void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
116 void DoCrossHair(wxCoord x, wxCoord y) ;
117 void DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc);
118 void DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea);
119 void DoDrawPoint(wxCoord x, wxCoord y);
120 void DoDrawLines(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0);
121 void DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle = wxODDEVEN_RULE);
122 void DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle = wxODDEVEN_RULE);
123 void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
124 void DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius = 20);
125 void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
126 #if wxUSE_SPLINES
127 void DoDrawSpline(wxList *points);
128 #endif // wxUSE_SPLINES
129 bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
130 wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop = wxCOPY, bool useMask = false,
131 wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord);
132 void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
133 void DoDrawBitmap(const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask = false);
134 void DoDrawText(const wxString& text, wxCoord x, wxCoord y);
135 void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
136 void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
137 void DoSetClippingRegionAsRegion( const wxRegion &WXUNUSED(clip)) { }
138 void DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
139 wxCoord *descent = NULL,
140 wxCoord *externalLeading = NULL,
141 const wxFont *theFont = NULL) const;
142 void DoGetSize(int* width, int* height) const;
143 void DoGetSizeMM(int *width, int *height) const;
144
145 FILE* m_pstream; // PostScript output stream
146 wxString m_title;
147 unsigned char m_currentRed;
148 unsigned char m_currentGreen;
149 unsigned char m_currentBlue;
150 int m_pageNumber;
151 bool m_clipping;
152 double m_underlinePosition;
153 double m_underlineThickness;
154 wxPrintData m_printData;
155
156 private:
157 DECLARE_DYNAMIC_CLASS(wxPostScriptDC)
158 };
159
160 #endif
161 // wxUSE_POSTSCRIPT
162
163 #endif
164 // wxUSE_PRINTING_ARCHITECTURE
165
166 #endif
167 // _WX_DCPSG_H_