]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/dcpsg.h
5be42ac46b2e4c16d28f286e4c6363d024d52d34
[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
26 #include <fstream.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 SetClippingRegion(long x, long y, long width, long height);
98 void SetClippingRegion( const wxRegion &region );
99 void DestroyClippingRegion();
100
101 void DoSetClippingRegionAsRegion( const wxRegion &WXUNUSED(clip) ) {}
102
103 bool StartDoc(const wxString& message);
104 void EndDoc();
105 void StartPage();
106 void EndPage();
107
108 long GetCharHeight() const;
109 long GetCharWidth() const;
110 inline bool CanGetTextExtent(void) const { return FALSE; }
111 void GetTextExtent(const wxString& string, long *x, long *y,
112 long *descent = (long *) NULL,
113 long *externalLeading = (long *) NULL,
114 wxFont *theFont = (wxFont *) NULL ) const;
115
116 void DoGetSize(int* width, int* height) const;
117 void DoGetSizeMM(int *width, int *height) const;
118
119 // Resolution in pixels per logical inch
120 wxSize GetPPI(void) const;
121
122 void SetAxisOrientation( bool xLeftRight, bool yBottomUp );
123 void SetDeviceOrigin( long x, long y );
124
125 inline void SetBackgroundMode(int WXUNUSED(mode)) {}
126 inline void SetPalette(const wxPalette& WXUNUSED(palette)) {}
127
128 ofstream *GetStream(void) const { return m_pstream; }
129
130 wxPrintData& GetPrintData() { return m_printData; }
131 void SetPrintData(const wxPrintData& data) { m_printData = data; }
132
133 virtual int GetDepth() const { return 24; }
134
135 protected:
136
137 ofstream * m_pstream; // PostScript output stream
138 wxString m_title;
139 unsigned char m_currentRed;
140 unsigned char m_currentGreen;
141 unsigned char m_currentBlue;
142 int m_pageNumber;
143 bool m_clipping;
144 double m_underlinePosition;
145 double m_underlineThickness;
146 wxPrintData m_printData;
147 };
148
149 // Deprecated: should use wxGenericPrintDialog instead.
150 #if 1
151 #define wxID_PRINTER_COMMAND 1
152 #define wxID_PRINTER_OPTIONS 2
153 #define wxID_PRINTER_ORIENTATION 3
154 #define wxID_PRINTER_MODES 4
155 #define wxID_PRINTER_X_SCALE 5
156 #define wxID_PRINTER_Y_SCALE 6
157 #define wxID_PRINTER_X_TRANS 7
158 #define wxID_PRINTER_Y_TRANS 8
159
160 class WXDLLEXPORT wxPostScriptPrintDialog: public wxDialog
161 {
162 DECLARE_CLASS(wxPostScriptPrintDialog)
163 public:
164 wxPostScriptPrintDialog (wxWindow *parent, const wxString& title,
165 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
166 long style = wxDEFAULT_DIALOG_STYLE);
167
168 virtual int ShowModal(void) ;
169 };
170 #endif
171
172 // Print Orientation (Should also add Left, Right)
173 enum
174 {
175 PS_PORTRAIT = 1,
176 PS_LANDSCAPE = 2
177 };// ps_orientation = PS_PORTRAIT;
178
179 // Print Actions
180 enum
181 {
182 PS_NONE,
183 PS_PREVIEW,
184 PS_FILE,
185 PS_PRINTER
186 };// ps_action = PS_PREVIEW;
187
188 // PostScript printer settings
189 WXDLLEXPORT void wxSetPrinterCommand(const wxString& cmd);
190 WXDLLEXPORT void wxSetPrintPreviewCommand(const wxString& cmd);
191 WXDLLEXPORT void wxSetPrinterOptions(const wxString& flags);
192 WXDLLEXPORT void wxSetPrinterOrientation(int orientation);
193 WXDLLEXPORT void wxSetPrinterScaling(double x, double y);
194 WXDLLEXPORT void wxSetPrinterTranslation(long x, long y);
195 WXDLLEXPORT void wxSetPrinterMode(int mode);
196 WXDLLEXPORT void wxSetPrinterFile(const wxString& f);
197 WXDLLEXPORT void wxSetAFMPath(const wxString& f);
198
199 // Get current values
200 WXDLLEXPORT wxString wxGetPrinterCommand();
201 WXDLLEXPORT wxString wxGetPrintPreviewCommand();
202 WXDLLEXPORT wxString wxGetPrinterOptions();
203 WXDLLEXPORT int wxGetPrinterOrientation();
204 WXDLLEXPORT void wxGetPrinterScaling(double* x, double* y);
205 WXDLLEXPORT void wxGetPrinterTranslation(long *x, long *y);
206 WXDLLEXPORT int wxGetPrinterMode();
207 WXDLLEXPORT wxString wxGetPrinterFile();
208 WXDLLEXPORT wxString wxGetAFMPath();
209
210 /*
211 * PostScript print setup information.
212 * This is now obsolete, but retained for a while for compatibility
213 */
214
215 class WXDLLEXPORT wxPrintSetupData: public wxObject
216 {
217 public:
218 wxPrintSetupData();
219 ~wxPrintSetupData();
220
221 void SetPrinterCommand(const wxString& cmd) { m_printerCommand = cmd; };
222 void SetPaperName(const wxString& paper) { m_paperName = paper; };
223 void SetPrintPreviewCommand(const wxString& cmd) { m_previewCommand = cmd; };
224 void SetPrinterOptions(const wxString& flags) { m_printerFlags = flags; };
225 void SetPrinterFile(const wxString& f) { m_printerFile = f; };
226 void SetPrinterOrientation(int orient) { m_printerOrient = orient; };
227 void SetPrinterScaling(double x, double y) { m_printerScaleX = x; m_printerScaleY = y; };
228 void SetPrinterTranslation(long x, long y) { m_printerTranslateX = x; m_printerTranslateY = y; };
229 // 1 = Preview, 2 = print to file, 3 = send to printer
230 void SetPrinterMode(int mode) { m_printerMode = mode; };
231 void SetAFMPath(const wxString& f) { m_afmPath = f; };
232 void SetColour(bool col) { m_printColour = col; };
233
234 // Get current values
235 wxString GetPrinterCommand() const { return m_printerCommand; } ;
236 wxString GetPrintPreviewCommand() const { return m_previewCommand; } ;
237 wxString GetPrinterOptions() const { return m_printerFlags; };
238 wxString GetPrinterFile() const { return m_printerFile; };
239 wxString GetPaperName() const { return m_paperName; }
240 int GetPrinterOrientation() const { return m_printerOrient; };
241 void GetPrinterScaling(double* x, double* y) const { *x = m_printerScaleX; *y = m_printerScaleY; };
242 void GetPrinterTranslation(long *x, long *y) const { *x = m_printerTranslateX; *y = m_printerTranslateY; };
243 int GetPrinterMode() const { return m_printerMode; };
244 wxString GetAFMPath() const { return m_afmPath; };
245 bool GetColour() const { return m_printColour; };
246
247 void operator=(wxPrintSetupData& data);
248
249 // Initialize from a wxPrintData object (wxPrintData should now be used instead of wxPrintSetupData).
250 // There is also an operator for initializing a wxPrintData from a wxPrintSetupData.
251 void operator=(const wxPrintData& data);
252
253 public:
254 wxString m_printerCommand;
255 wxString m_previewCommand;
256 wxString m_printerFlags;
257 wxString m_printerFile;
258 int m_printerOrient;
259 double m_printerScaleX;
260 double m_printerScaleY;
261 long m_printerTranslateX;
262 long m_printerTranslateY;
263 // 1 = Preview, 2 = print to file, 3 = send to printer
264 int m_printerMode;
265 wxString m_afmPath;
266 // A name in the paper database (see paper.h)
267 wxString m_paperName;
268 bool m_printColour;
269
270 DECLARE_DYNAMIC_CLASS(wxPrintSetupData)
271 };
272
273 WXDLLEXPORT_DATA(extern wxPrintSetupData*) wxThePrintSetupData;
274 WXDLLEXPORT extern void wxInitializePrintSetupData(bool init = TRUE);
275
276 #endif
277 // wxUSE_POSTSCRIPT
278
279 #endif
280 // _WX_DCPSG_H_