fixed bug in PS clipping (non-virtual SetClippingRegion was overloaded)
[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, Robert Roebling and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_DCPSG_H_
12 #define _WX_DCPSG_H_
13
14 #ifdef __GNUG__
15 #pragma interface
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 DECLARE_DYNAMIC_CLASS(wxPostScriptDC)
41
42 public:
43
44 wxPostScriptDC();
45
46 // Deprecated constructor
47 wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow *parent = (wxWindow *) NULL);
48
49 // Recommended constructor
50 wxPostScriptDC(const wxPrintData& printData);
51
52 ~wxPostScriptDC();
53
54 // Deprecated
55 bool Create(const wxString& output, bool interactive = TRUE, wxWindow *parent = (wxWindow *) NULL);
56
57 virtual bool Ok() const;
58
59 // Deprecated: use wxGenericPrintDialog instead
60 virtual bool PrinterDialog(wxWindow *parent = (wxWindow *) NULL);
61
62 virtual void BeginDrawing() {}
63 virtual void EndDrawing() {}
64
65 void DoFloodFill(long x1, long y1, const wxColour &col, int style=wxFLOOD_SURFACE );
66 bool DoGetPixel(long x1, long y1, wxColour *col) const;
67
68 void DoDrawLine(long x1, long y1, long x2, long y2);
69 void DoCrossHair(long x, long y) ;
70 void DoDrawArc(long x1,long y1,long x2,long y2,long xc,long yc);
71 void DoDrawEllipticArc(long x,long y,long w,long h,double sa,double ea);
72 void DoDrawPoint(long x, long y);
73 void DoDrawLines(int n, wxPoint points[], long xoffset = 0, long yoffset = 0);
74 void DoDrawPolygon(int n, wxPoint points[], long xoffset = 0, long yoffset = 0, int fillStyle=wxODDEVEN_RULE);
75 void DoDrawRectangle(long x, long y, long width, long height);
76 void DoDrawRoundedRectangle(long x, long y, long width, long height, double radius = 20);
77 void DoDrawEllipse(long x, long y, long width, long height);
78
79 void DoDrawSpline(wxList *points);
80
81 bool DoBlit(long xdest, long ydest, long width, long height,
82 wxDC *source, long xsrc, long ysrc, int rop = wxCOPY, bool useMask = FALSE);
83 inline bool CanDrawBitmap(void) const { return TRUE; }
84
85 void DoDrawIcon( const wxIcon& icon, long x, long y );
86 void DoDrawBitmap( const wxBitmap& bitmap, long x, long y, bool useMask=FALSE );
87
88 void DoDrawText(const wxString& text, long x, long y );
89
90 void Clear();
91 void SetFont( const wxFont& font );
92 void SetPen( const wxPen& pen );
93 void SetBrush( const wxBrush& brush );
94 void SetLogicalFunction( int function );
95 void SetBackground( const wxBrush& brush );
96
97 void DoSetClippingRegion(long x, long y, long width, long height);
98 void DestroyClippingRegion();
99
100 void DoSetClippingRegionAsRegion( const wxRegion &WXUNUSED(clip) ) {}
101
102 bool StartDoc(const wxString& message);
103 void EndDoc();
104 void StartPage();
105 void EndPage();
106
107 long GetCharHeight() const;
108 long GetCharWidth() const;
109 inline bool CanGetTextExtent(void) const { return FALSE; }
110 void GetTextExtent(const wxString& string, long *x, long *y,
111 long *descent = (long *) NULL,
112 long *externalLeading = (long *) NULL,
113 wxFont *theFont = (wxFont *) NULL ) const;
114
115 void DoGetSize(int* width, int* height) const;
116 void DoGetSizeMM(int *width, int *height) const;
117
118 // Resolution in pixels per logical inch
119 wxSize GetPPI(void) const;
120
121 void SetAxisOrientation( bool xLeftRight, bool yBottomUp );
122 void SetDeviceOrigin( long x, long y );
123
124 inline void SetBackgroundMode(int WXUNUSED(mode)) {}
125 inline void SetPalette(const wxPalette& WXUNUSED(palette)) {}
126
127 wxPrintData& GetPrintData() { return m_printData; }
128 void SetPrintData(const wxPrintData& data) { m_printData = data; }
129
130 virtual int GetDepth() const { return 24; }
131
132 protected:
133
134 FILE* m_pstream; // PostScript output stream
135 wxString m_title;
136 unsigned char m_currentRed;
137 unsigned char m_currentGreen;
138 unsigned char m_currentBlue;
139 int m_pageNumber;
140 bool m_clipping;
141 double m_underlinePosition;
142 double m_underlineThickness;
143 wxPrintData m_printData;
144 };
145
146 // Deprecated: should use wxGenericPrintDialog instead.
147 #if 1
148 #define wxID_PRINTER_COMMAND 1
149 #define wxID_PRINTER_OPTIONS 2
150 #define wxID_PRINTER_ORIENTATION 3
151 #define wxID_PRINTER_MODES 4
152 #define wxID_PRINTER_X_SCALE 5
153 #define wxID_PRINTER_Y_SCALE 6
154 #define wxID_PRINTER_X_TRANS 7
155 #define wxID_PRINTER_Y_TRANS 8
156
157 class WXDLLEXPORT wxPostScriptPrintDialog: public wxDialog
158 {
159 DECLARE_CLASS(wxPostScriptPrintDialog)
160 public:
161 wxPostScriptPrintDialog (wxWindow *parent, const wxString& title,
162 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
163 long style = wxDEFAULT_DIALOG_STYLE);
164
165 virtual int ShowModal(void) ;
166 };
167 #endif
168
169 // Print Orientation (Should also add Left, Right)
170 enum
171 {
172 PS_PORTRAIT = 1,
173 PS_LANDSCAPE = 2
174 };// ps_orientation = PS_PORTRAIT;
175
176 // Print Actions
177 enum
178 {
179 PS_NONE,
180 PS_PREVIEW,
181 PS_FILE,
182 PS_PRINTER
183 };// ps_action = PS_PREVIEW;
184
185 // PostScript printer settings
186 WXDLLEXPORT void wxSetPrinterCommand(const wxString& cmd);
187 WXDLLEXPORT void wxSetPrintPreviewCommand(const wxString& cmd);
188 WXDLLEXPORT void wxSetPrinterOptions(const wxString& flags);
189 WXDLLEXPORT void wxSetPrinterOrientation(int orientation);
190 WXDLLEXPORT void wxSetPrinterScaling(double x, double y);
191 WXDLLEXPORT void wxSetPrinterTranslation(long x, long y);
192 WXDLLEXPORT void wxSetPrinterMode(int mode);
193 WXDLLEXPORT void wxSetPrinterFile(const wxString& f);
194 WXDLLEXPORT void wxSetAFMPath(const wxString& f);
195
196 // Get current values
197 WXDLLEXPORT wxString wxGetPrinterCommand();
198 WXDLLEXPORT wxString wxGetPrintPreviewCommand();
199 WXDLLEXPORT wxString wxGetPrinterOptions();
200 WXDLLEXPORT int wxGetPrinterOrientation();
201 WXDLLEXPORT void wxGetPrinterScaling(double* x, double* y);
202 WXDLLEXPORT void wxGetPrinterTranslation(long *x, long *y);
203 WXDLLEXPORT int wxGetPrinterMode();
204 WXDLLEXPORT wxString wxGetPrinterFile();
205 WXDLLEXPORT wxString wxGetAFMPath();
206
207 /*
208 * PostScript print setup information.
209 * This is now obsolete, but retained for a while for compatibility
210 */
211
212 class WXDLLEXPORT wxPrintSetupData: public wxObject
213 {
214 public:
215 wxPrintSetupData();
216 ~wxPrintSetupData();
217
218 void SetPrinterCommand(const wxString& cmd) { m_printerCommand = cmd; };
219 void SetPaperName(const wxString& paper) { m_paperName = paper; };
220 void SetPrintPreviewCommand(const wxString& cmd) { m_previewCommand = cmd; };
221 void SetPrinterOptions(const wxString& flags) { m_printerFlags = flags; };
222 void SetPrinterFile(const wxString& f) { m_printerFile = f; };
223 void SetPrinterOrientation(int orient) { m_printerOrient = orient; };
224 void SetPrinterScaling(double x, double y) { m_printerScaleX = x; m_printerScaleY = y; };
225 void SetPrinterTranslation(long x, long y) { m_printerTranslateX = x; m_printerTranslateY = y; };
226 // 1 = Preview, 2 = print to file, 3 = send to printer
227 void SetPrinterMode(int mode) { m_printerMode = mode; };
228 void SetAFMPath(const wxString& f) { m_afmPath = f; };
229 void SetColour(bool col) { m_printColour = col; };
230
231 // Get current values
232 wxString GetPrinterCommand() const { return m_printerCommand; } ;
233 wxString GetPrintPreviewCommand() const { return m_previewCommand; } ;
234 wxString GetPrinterOptions() const { return m_printerFlags; };
235 wxString GetPrinterFile() const { return m_printerFile; };
236 wxString GetPaperName() const { return m_paperName; }
237 int GetPrinterOrientation() const { return m_printerOrient; };
238 void GetPrinterScaling(double* x, double* y) const { *x = m_printerScaleX; *y = m_printerScaleY; };
239 void GetPrinterTranslation(long *x, long *y) const { *x = m_printerTranslateX; *y = m_printerTranslateY; };
240 int GetPrinterMode() const { return m_printerMode; };
241 wxString GetAFMPath() const { return m_afmPath; };
242 bool GetColour() const { return m_printColour; };
243
244 void operator=(wxPrintSetupData& data);
245
246 // Initialize from a wxPrintData object (wxPrintData should now be used instead of wxPrintSetupData).
247 // There is also an operator for initializing a wxPrintData from a wxPrintSetupData.
248 void operator=(const wxPrintData& data);
249
250 public:
251 wxString m_printerCommand;
252 wxString m_previewCommand;
253 wxString m_printerFlags;
254 wxString m_printerFile;
255 int m_printerOrient;
256 double m_printerScaleX;
257 double m_printerScaleY;
258 long m_printerTranslateX;
259 long m_printerTranslateY;
260 // 1 = Preview, 2 = print to file, 3 = send to printer
261 int m_printerMode;
262 wxString m_afmPath;
263 // A name in the paper database (see paper.h)
264 wxString m_paperName;
265 bool m_printColour;
266
267 DECLARE_DYNAMIC_CLASS(wxPrintSetupData)
268 };
269
270 WXDLLEXPORT_DATA(extern wxPrintSetupData*) wxThePrintSetupData;
271 WXDLLEXPORT extern void wxInitializePrintSetupData(bool init = TRUE);
272
273 #endif
274 // wxUSE_POSTSCRIPT
275
276 #endif
277 // wxUSE_PRINTING_ARCHITECTURE
278
279 #endif
280 // _WX_DCPSG_H_