]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/dcpsg.h
For non-Unicode added #include <ctype.h> and <string.h> to avoid some missing
[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_POSTSCRIPT
21
22 #include "wx/dialog.h"
23 #include "wx/module.h"
24 #include "wx/cmndata.h"
25 #include <fstream.h>
26
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 FloodFill(long x1, long y1, const wxColour &col, int style=wxFLOOD_SURFACE) ;
66 bool GetPixel(long x1, long y1, wxColour *col) const;
67
68 void DrawLine(long x1, long y1, long x2, long y2);
69 void CrossHair(long x, long y) ;
70 void DrawArc(long x1,long y1,long x2,long y2,long xc,long yc);
71 void DrawEllipticArc(long x,long y,long w,long h,double sa,double ea);
72 void DrawPoint(long x, long y);
73 // Avoid compiler warning
74 void DrawPoint(wxPoint& point) { wxDC::DrawPoint(point); }
75 void DrawLines(int n, wxPoint points[], long xoffset = 0, long yoffset = 0);
76 // Avoid compiler warning
77 void DrawLines(wxList *lines, long xoffset = 0, long yoffset = 0)
78 { wxDC::DrawLines(lines, xoffset, yoffset); }
79 void DrawPolygon(int n, wxPoint points[], long xoffset = 0, long yoffset = 0, int fillStyle=wxODDEVEN_RULE);
80 // Avoid compiler warning
81 void DrawPolygon(wxList *lines, long xoffset = 0, long yoffset = 0, int fillStyle=wxODDEVEN_RULE)
82 { wxDC::DrawPolygon(lines, xoffset, yoffset, fillStyle); }
83 void DrawRectangle(long x, long y, long width, long height);
84 void DrawRoundedRectangle(long x, long y, long width, long height, double radius = 20);
85 void DrawEllipse(long x, long y, long width, long height);
86
87 void DrawSpline(wxList *points);
88
89 bool Blit(long xdest, long ydest, long width, long height,
90 wxDC *source, long xsrc, long ysrc, int rop = wxCOPY, bool useMask = FALSE);
91 inline bool CanDrawBitmap(void) const { return TRUE; }
92
93 void DrawIcon( const wxIcon& icon, long x, long y );
94 void DrawBitmap( const wxBitmap& bitmap, long x, long y, bool useMask=FALSE );
95
96 void DrawText(const wxString& text, long x, long y, bool use16 = FALSE);
97
98 void Clear();
99 void SetFont( const wxFont& font );
100 void SetPen( const wxPen& pen );
101 void SetBrush( const wxBrush& brush );
102 void SetLogicalFunction( int function );
103 void SetBackground( const wxBrush& brush );
104
105 void SetClippingRegion(long x, long y, long width, long height);
106 void SetClippingRegion( const wxRegion &region );
107 void DestroyClippingRegion();
108
109 bool StartDoc(const wxString& message);
110 void EndDoc();
111 void StartPage();
112 void EndPage();
113
114 long GetCharHeight();
115 long GetCharWidth();
116 inline bool CanGetTextExtent(void) const { return FALSE; }
117 void GetTextExtent(const wxString& string, long *x, long *y,
118 long *descent = (long *) NULL,
119 long *externalLeading = (long *) NULL,
120 wxFont *theFont = (wxFont *) NULL, bool use16 = FALSE);
121
122 void GetSize(int* width, int* height) const;
123 void GetSizeMM(int *width, int *height) const;
124
125 // Resolution in pixels per logical inch
126 wxSize GetPPI(void) const;
127
128 void SetAxisOrientation( bool xLeftRight, bool yBottomUp );
129 void SetDeviceOrigin( long x, long y );
130
131 inline void SetBackgroundMode(int WXUNUSED(mode)) {}
132 inline void SetPalette(const wxPalette& WXUNUSED(palette)) {}
133
134 inline ofstream *GetStream(void) const { return m_pstream; }
135
136 inline wxPrintData& GetPrintData() { return m_printData; }
137 inline void SetPrintData(const wxPrintData& data) { m_printData = data; }
138
139 protected:
140
141 ofstream * m_pstream; // PostScript output stream
142 wxString m_title;
143 unsigned char m_currentRed;
144 unsigned char m_currentGreen;
145 unsigned char m_currentBlue;
146 int m_pageNumber;
147 bool m_clipping;
148 double m_underlinePosition;
149 double m_underlineThickness;
150 wxPrintData m_printData;
151 };
152
153 // Deprecated: should use wxGenericPrintDialog instead.
154 #if 1
155 #define wxID_PRINTER_COMMAND 1
156 #define wxID_PRINTER_OPTIONS 2
157 #define wxID_PRINTER_ORIENTATION 3
158 #define wxID_PRINTER_MODES 4
159 #define wxID_PRINTER_X_SCALE 5
160 #define wxID_PRINTER_Y_SCALE 6
161 #define wxID_PRINTER_X_TRANS 7
162 #define wxID_PRINTER_Y_TRANS 8
163
164 class WXDLLEXPORT wxPostScriptPrintDialog: public wxDialog
165 {
166 DECLARE_CLASS(wxPostScriptPrintDialog)
167 public:
168 wxPostScriptPrintDialog (wxWindow *parent, const wxString& title,
169 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
170 long style = wxDEFAULT_DIALOG_STYLE);
171
172 virtual int ShowModal(void) ;
173 };
174 #endif
175
176 // Print Orientation (Should also add Left, Right)
177 enum {
178 PS_PORTRAIT = 1,
179 PS_LANDSCAPE = 2
180 };// ps_orientation = PS_PORTRAIT;
181
182 // Print Actions
183 enum {
184 PS_NONE,
185 PS_PREVIEW,
186 PS_FILE,
187 PS_PRINTER
188 };// ps_action = PS_PREVIEW;
189
190 // PostScript printer settings
191 WXDLLEXPORT void wxSetPrinterCommand(const wxString& cmd);
192 WXDLLEXPORT void wxSetPrintPreviewCommand(const wxString& cmd);
193 WXDLLEXPORT void wxSetPrinterOptions(const wxString& flags);
194 WXDLLEXPORT void wxSetPrinterOrientation(int orientation);
195 WXDLLEXPORT void wxSetPrinterScaling(double x, double y);
196 WXDLLEXPORT void wxSetPrinterTranslation(long x, long y);
197 WXDLLEXPORT void wxSetPrinterMode(int mode);
198 WXDLLEXPORT void wxSetPrinterFile(const wxString& f);
199 WXDLLEXPORT void wxSetAFMPath(const wxString& f);
200
201 // Get current values
202 WXDLLEXPORT wxString wxGetPrinterCommand();
203 WXDLLEXPORT wxString wxGetPrintPreviewCommand();
204 WXDLLEXPORT wxString wxGetPrinterOptions();
205 WXDLLEXPORT int wxGetPrinterOrientation();
206 WXDLLEXPORT void wxGetPrinterScaling(double* x, double* y);
207 WXDLLEXPORT void wxGetPrinterTranslation(long *x, long *y);
208 WXDLLEXPORT int wxGetPrinterMode();
209 WXDLLEXPORT wxString wxGetPrinterFile();
210 WXDLLEXPORT wxString wxGetAFMPath();
211
212 /*
213 * PostScript print setup information.
214 * This is now obsolete, but retained for a while for compatibility
215 */
216
217 class WXDLLEXPORT wxPrintSetupData: public wxObject
218 {
219 public:
220 wxPrintSetupData();
221 ~wxPrintSetupData();
222
223 void SetPrinterCommand(const wxString& cmd) { m_printerCommand = cmd; };
224 void SetPaperName(const wxString& paper) { m_paperName = paper; };
225 void SetPrintPreviewCommand(const wxString& cmd) { m_previewCommand = cmd; };
226 void SetPrinterOptions(const wxString& flags) { m_printerFlags = flags; };
227 void SetPrinterFile(const wxString& f) { m_printerFile = f; };
228 void SetPrinterOrientation(int orient) { m_printerOrient = orient; };
229 void SetPrinterScaling(double x, double y) { m_printerScaleX = x; m_printerScaleY = y; };
230 void SetPrinterTranslation(long x, long y) { m_printerTranslateX = x; m_printerTranslateY = y; };
231 // 1 = Preview, 2 = print to file, 3 = send to printer
232 void SetPrinterMode(int mode) { m_printerMode = mode; };
233 void SetAFMPath(const wxString& f) { m_afmPath = f; };
234 void SetColour(bool col) { m_printColour = col; };
235
236 // Get current values
237 wxString GetPrinterCommand() const { return m_printerCommand; } ;
238 wxString GetPrintPreviewCommand() const { return m_previewCommand; } ;
239 wxString GetPrinterOptions() const { return m_printerFlags; };
240 wxString GetPrinterFile() const { return m_printerFile; };
241 wxString GetPaperName() const { return m_paperName; }
242 int GetPrinterOrientation() const { return m_printerOrient; };
243 void GetPrinterScaling(double* x, double* y) const { *x = m_printerScaleX; *y = m_printerScaleY; };
244 void GetPrinterTranslation(long *x, long *y) const { *x = m_printerTranslateX; *y = m_printerTranslateY; };
245 int GetPrinterMode() const { return m_printerMode; };
246 wxString GetAFMPath() const { return m_afmPath; };
247 bool GetColour() const { return m_printColour; };
248
249 void operator=(wxPrintSetupData& data);
250
251 // Initialize from a wxPrintData object (wxPrintData should now be used instead of wxPrintSetupData).
252 // There is also an operator for initializing a wxPrintData from a wxPrintSetupData.
253 void operator=(const wxPrintData& data);
254
255 public:
256 wxString m_printerCommand;
257 wxString m_previewCommand;
258 wxString m_printerFlags;
259 wxString m_printerFile;
260 int m_printerOrient;
261 double m_printerScaleX;
262 double m_printerScaleY;
263 long m_printerTranslateX;
264 long m_printerTranslateY;
265 // 1 = Preview, 2 = print to file, 3 = send to printer
266 int m_printerMode;
267 wxString m_afmPath;
268 // A name in the paper database (see paper.h)
269 wxString m_paperName;
270 bool m_printColour;
271
272 DECLARE_DYNAMIC_CLASS(wxPrintSetupData)
273 };
274
275 WXDLLEXPORT_DATA(extern wxPrintSetupData*) wxThePrintSetupData;
276 WXDLLEXPORT extern void wxInitializePrintSetupData(bool init = TRUE);
277
278 #endif
279 // wxUSE_POSTSCRIPT
280
281 #endif
282 // _WX_DCPSG_H_