added wxDC::DrawPolyPolygon() (patch 882189)
[wxWidgets.git] / include / wx / generic / dcpsg.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: 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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
15 #pragma interface "dcpsg.h"
16 #endif
17
18 #include "wx/dc.h"
19
20 #if wxUSE_PRINTING_ARCHITECTURE
21
22 #if wxUSE_POSTSCRIPT
23
24 #include "wx/dialog.h"
25 #include "wx/module.h"
26 #include "wx/cmndata.h"
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 // Recommended destructor :-)
47 ~wxPostScriptDC();
48
49 #if WXWIN_COMPATIBILITY_2_2
50 wxPostScriptDC( const wxString &output, bool interactive = FALSE, wxWindow *parent = NULL )
51 { Create( output, interactive, parent ); }
52 bool Create ( const wxString &output, bool interactive = FALSE, wxWindow *parent = NULL );
53 #endif
54
55 virtual bool Ok() const;
56
57 virtual void BeginDrawing() {}
58 virtual void EndDrawing() {}
59
60 bool DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col, int style=wxFLOOD_SURFACE );
61 bool DoGetPixel(wxCoord x1, wxCoord y1, wxColour *col) const;
62
63 void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
64 void DoCrossHair(wxCoord x, wxCoord y) ;
65 void DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc);
66 void DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea);
67 void DoDrawPoint(wxCoord x, wxCoord y);
68 void DoDrawLines(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0);
69 void DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle=wxODDEVEN_RULE);
70 void DoDrawPolyPolygon(int n, int start[], wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle=wxODDEVEN_RULE);
71 void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
72 void DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius = 20);
73 void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
74
75 void DoDrawSpline(wxList *points);
76
77 bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
78 wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop = wxCOPY, bool useMask = FALSE,
79 wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
80 bool CanDrawBitmap() const { return TRUE; }
81
82 void DoDrawIcon( const wxIcon& icon, wxCoord x, wxCoord y );
83 void DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask=FALSE );
84
85 void DoDrawText(const wxString& text, wxCoord x, wxCoord y );
86 void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
87
88 void Clear();
89 void SetFont( const wxFont& font );
90 void SetPen( const wxPen& pen );
91 void SetBrush( const wxBrush& brush );
92 void SetLogicalFunction( int function );
93 void SetBackground( const wxBrush& brush );
94
95 void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
96 void DestroyClippingRegion();
97
98 void DoSetClippingRegionAsRegion( const wxRegion &WXUNUSED(clip) ) { }
99
100 bool StartDoc(const wxString& message);
101 void EndDoc();
102 void StartPage();
103 void EndPage();
104
105 wxCoord GetCharHeight() const;
106 wxCoord GetCharWidth() const;
107 bool CanGetTextExtent() const { return TRUE; }
108 void DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
109 wxCoord *descent = (wxCoord *) NULL,
110 wxCoord *externalLeading = (wxCoord *) NULL,
111 wxFont *theFont = (wxFont *) NULL ) const;
112
113 void DoGetSize(int* width, int* height) const;
114 void DoGetSizeMM(int *width, int *height) const;
115
116 // Resolution in pixels per logical inch
117 wxSize GetPPI() const;
118
119 void SetAxisOrientation( bool xLeftRight, bool yBottomUp );
120 void SetDeviceOrigin( wxCoord x, wxCoord y );
121
122 void SetBackgroundMode(int WXUNUSED(mode)) { }
123 void SetPalette(const wxPalette& WXUNUSED(palette)) { }
124
125 wxPrintData& GetPrintData() { return m_printData; }
126 void SetPrintData(const wxPrintData& data) { m_printData = data; }
127
128 virtual int GetDepth() const { return 24; }
129
130 static void SetResolution(int ppi);
131 static int GetResolution();
132
133 private:
134 static float ms_PSScaleFactor;
135
136 protected:
137 #if wxUSE_PANGO
138 PangoContext *m_context;
139 PangoLayout *m_layout;
140 PangoFontDescription *m_fontdesc;
141 #endif
142
143 FILE* m_pstream; // PostScript output stream
144 wxString m_title;
145 unsigned char m_currentRed;
146 unsigned char m_currentGreen;
147 unsigned char m_currentBlue;
148 int m_pageNumber;
149 bool m_clipping;
150 double m_underlinePosition;
151 double m_underlineThickness;
152 wxPrintData m_printData;
153
154 private:
155 DECLARE_DYNAMIC_CLASS(wxPostScriptDC)
156 };
157
158
159 #if WXWIN_COMPATIBILITY_2_2
160 // Print Orientation
161 enum
162 {
163 PS_PORTRAIT = wxPORTRAIT,
164 PS_LANDSCAPE = wxLANDSCAPE
165 };
166
167 // Print Actions
168 enum
169 {
170 PS_NONE = wxPRINT_MODE_NONE,
171 PS_PREVIEW = wxPRINT_MODE_PREVIEW,
172 PS_FILE = wxPRINT_MODE_FILE,
173 PS_PRINTER = wxPRINT_MODE_PRINTER
174 };
175
176 class wxPrintSetupData: public wxPrintData
177 {
178 public:
179 wxPrintSetupData() {}
180
181 void SetPrinterOrientation( int orient )
182 { SetOrientation( orient ); }
183 void SetPrinterMode( wxPrintMode mode )
184 { SetPrintMode( mode ); }
185 void SetAFMPath( const wxString &path )
186 { SetFontMetricPath( path ); }
187
188 void SetPaperName(const wxString& paper) { m_paperName = paper; }
189 void SetPrinterFile(const wxString& file) { m_printerFile = file; }
190 wxString GetPaperName() const { return m_paperName; }
191 wxString GetPrinterFile() const { return m_printerFile; };
192
193 wxString m_paperName;
194 wxString m_printerFile;
195 };
196
197 WXDLLEXPORT_DATA(extern wxPrintSetupData*) wxThePrintSetupData;
198 WXDLLEXPORT extern void wxInitializePrintSetupData(bool init = TRUE);
199 #endif
200
201
202 #endif
203 // wxUSE_POSTSCRIPT
204
205 #endif
206 // wxUSE_PRINTING_ARCHITECTURE
207
208 #endif
209 // _WX_DCPSG_H_