]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: postscrp.h | |
3 | // Purpose: wxPostScriptDC class | |
4 | // Author: Julian Smart and others | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart and Markus Holzem | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
34138703 JS |
12 | #ifndef _WX_POSTSCRPH__ |
13 | #define _WX_POSTSCRPH__ | |
c801d85f KB |
14 | |
15 | #ifdef __GNUG__ | |
16 | #pragma interface "postscrp.h" | |
17 | #endif | |
18 | ||
19 | #include "wx/dc.h" | |
20 | #include "wx/dialog.h" | |
21 | ||
22 | #if USE_POSTSCRIPT | |
23 | ||
24 | class WXDLLIMPORT ofstream; | |
25 | class WXDLLEXPORT wxPostScriptDC: public wxDC | |
26 | { | |
27 | DECLARE_DYNAMIC_CLASS(wxPostScriptDC) | |
28 | ||
29 | public: | |
30 | // Create a printer DC | |
31 | wxPostScriptDC(void); | |
32 | wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow *parent = NULL); | |
33 | ||
34 | ~wxPostScriptDC(void); | |
35 | ||
36 | bool Create(const wxString& output, bool interactive = TRUE, wxWindow *parent = NULL); | |
37 | ||
38 | virtual bool PrinterDialog(wxWindow *parent = NULL); | |
39 | ||
40 | inline virtual void BeginDrawing(void) {} ; | |
41 | inline virtual void EndDrawing(void) {} ; | |
42 | ||
43 | void FloodFill(long x1, long y1, wxColour *col, int style=wxFLOOD_SURFACE) ; | |
44 | bool GetPixel(long x1, long y1, wxColour *col) const; | |
45 | ||
46 | void DrawLine(long x1, long y1, long x2, long y2); | |
47 | void CrossHair(long x, long y) ; | |
48 | void DrawArc(long x1,long y1,long x2,long y2,long xc,long yc); | |
49 | void DrawEllipticArc(long x,long y,long w,long h,double sa,double ea); | |
50 | void DrawPoint(long x, long y); | |
51 | // Avoid compiler warning | |
52 | void DrawPoint(wxPoint& point) { wxDC::DrawPoint(point); } | |
53 | void DrawLines(int n, wxPoint points[], long xoffset = 0, long yoffset = 0); | |
54 | // Avoid compiler warning | |
55 | void DrawLines(wxList *lines, long xoffset = 0, long yoffset = 0) | |
56 | { wxDC::DrawLines(lines, xoffset, yoffset); } | |
57 | void DrawPolygon(int n, wxPoint points[], long xoffset = 0, long yoffset = 0, int fillStyle=wxODDEVEN_RULE); | |
58 | // Avoid compiler warning | |
59 | void DrawPolygon(wxList *lines, long xoffset = 0, long yoffset = 0, int fillStyle=wxODDEVEN_RULE) | |
60 | { wxDC::DrawPolygon(lines, xoffset, yoffset, fillStyle); } | |
61 | void DrawRectangle(long x, long y, long width, long height); | |
62 | void DrawRoundedRectangle(long x, long y, long width, long height, double radius = 20); | |
63 | void DrawEllipse(long x, long y, long width, long height); | |
64 | ||
10b959e3 JS |
65 | // RR: I define these in wxDC, after all they all do the same everywhere |
66 | ||
2049ba38 | 67 | #ifdef __WXMSW__ |
c801d85f KB |
68 | // Splines |
69 | // 3-point spline | |
70 | void DrawSpline(long x1, long y1, long x2, long y2, long x3, long y3); | |
71 | // Any number of control points - a list of pointers to wxPoints | |
72 | void DrawSpline(wxList *points); | |
73 | void DrawSpline(int n, wxPoint points[]); | |
10b959e3 JS |
74 | #endif |
75 | ||
c801d85f KB |
76 | void DrawOpenSpline(wxList *points); |
77 | ||
78 | void DrawIcon(const wxIcon& icon, long x, long y); | |
86b29a61 RR |
79 | #ifdef __WXGTK__ |
80 | void DrawIcon(const wxIcon& icon, long x, long y, bool WXUNUSED(usemask) ) | |
81 | { DrawIcon( icon, x, y ); } | |
82 | #endif | |
c801d85f KB |
83 | void DrawText(const wxString& text, long x, long y, bool use16 = FALSE); |
84 | ||
85 | void Clear(void); | |
86 | void SetFont(const wxFont& font); | |
87 | void SetPen(const wxPen& pen); | |
88 | void SetBrush(const wxBrush& brush); | |
89 | void SetLogicalFunction(int function); | |
90 | void SetBackground(const wxBrush& brush); | |
91 | void SetClippingRegion(long x, long y, long width, long height); | |
92 | void DestroyClippingRegion(void); | |
93 | ||
94 | bool StartDoc(const wxString& message); | |
95 | void EndDoc(void); | |
96 | void StartPage(void); | |
97 | void EndPage(void); | |
98 | ||
99 | long GetCharHeight(void); | |
100 | long GetCharWidth(void); | |
101 | void GetTextExtent(const wxString& string, long *x, long *y, | |
102 | long *descent = NULL, long *externalLeading = NULL, | |
103 | wxFont *theFont = NULL, bool use16 = FALSE); | |
104 | virtual void SetLogicalOrigin(long x, long y); | |
105 | virtual void CalcBoundingBox(long x, long y); | |
106 | ||
107 | void SetMapMode(int mode); | |
108 | void SetUserScale(double x, double y); | |
109 | long DeviceToLogicalX(int x) const; | |
110 | long DeviceToLogicalY(int y) const; | |
111 | long DeviceToLogicalXRel(int x) const; | |
112 | long DeviceToLogicalYRel(int y) const; | |
113 | long LogicalToDeviceX(long x) const; | |
114 | long LogicalToDeviceY(long y) const; | |
115 | long LogicalToDeviceXRel(long x) const; | |
116 | long LogicalToDeviceYRel(long y) const; | |
117 | bool Blit(long xdest, long ydest, long width, long height, | |
118 | wxDC *source, long xsrc, long ysrc, int rop = wxCOPY, bool useMask = FALSE); | |
119 | inline bool CanGetTextExtent(void) const { return FALSE; } | |
120 | inline bool CanDrawBitmap(void) const { return FALSE; } | |
121 | ||
122 | void GetSize(int* width, int* height) const; | |
123 | void GetSizeMM(long *width, long *height) const; | |
124 | ||
125 | inline void SetBackgroundMode(int WXUNUSED(mode)) {}; | |
126 | inline void SetPalette(const wxPalette& WXUNUSED(palette)) {} | |
127 | ||
128 | inline ofstream *GetStream(void) const { return m_pstream; } | |
129 | inline int GetYOrigin(void) const { return m_yOrigin; } | |
130 | ||
131 | void SetupCTM(); | |
132 | ||
133 | protected: | |
134 | int m_yOrigin; // For EPS | |
135 | ofstream * m_pstream; // PostScript output stream | |
136 | wxString m_title; | |
137 | unsigned char m_currentRed; | |
138 | unsigned char m_currentGreen; | |
139 | unsigned char m_currentBlue; | |
140 | double m_scaleFactor; | |
141 | }; | |
142 | ||
143 | #define wxID_PRINTER_COMMAND 1 | |
144 | #define wxID_PRINTER_OPTIONS 2 | |
145 | #define wxID_PRINTER_ORIENTATION 3 | |
146 | #define wxID_PRINTER_MODES 4 | |
147 | #define wxID_PRINTER_X_SCALE 5 | |
148 | #define wxID_PRINTER_Y_SCALE 6 | |
149 | #define wxID_PRINTER_X_TRANS 7 | |
150 | #define wxID_PRINTER_Y_TRANS 8 | |
151 | ||
152 | class WXDLLEXPORT wxPostScriptPrintDialog: public wxDialog | |
153 | { | |
154 | DECLARE_CLASS(wxPostScriptPrintDialog) | |
155 | public: | |
156 | wxPostScriptPrintDialog (wxWindow *parent, const wxString& title, | |
157 | const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, | |
debe6624 | 158 | long style = wxDEFAULT_DIALOG_STYLE); |
c801d85f KB |
159 | |
160 | virtual int ShowModal(void) ; | |
161 | }; | |
162 | ||
163 | ||
164 | // Print Orientation (Should also add Left, Right) | |
165 | enum { | |
166 | PS_PORTRAIT = 1, | |
167 | PS_LANDSCAPE = 2 | |
168 | };// ps_orientation = PS_PORTRAIT; | |
169 | ||
170 | // Print Actions | |
171 | enum { | |
172 | PS_PRINTER, | |
173 | PS_FILE, | |
174 | PS_PREVIEW | |
175 | };// ps_action = PS_PREVIEW; | |
176 | ||
177 | // PostScript printer settings | |
1a5a8367 DP |
178 | void WXDLLEXPORT wxSetPrinterCommand(const char *cmd); |
179 | void WXDLLEXPORT wxSetPrintPreviewCommand(const char *cmd); | |
180 | void WXDLLEXPORT wxSetPrinterOptions(const char *flags); | |
c801d85f KB |
181 | void WXDLLEXPORT wxSetPrinterOrientation(int orientation); |
182 | void WXDLLEXPORT wxSetPrinterScaling(double x, double y); | |
183 | void WXDLLEXPORT wxSetPrinterTranslation(long x, long y); | |
184 | void WXDLLEXPORT wxSetPrinterMode(int mode); | |
1a5a8367 DP |
185 | void WXDLLEXPORT wxSetPrinterFile(const char *f); |
186 | void WXDLLEXPORT wxSetAFMPath(const char *f); | |
c801d85f KB |
187 | |
188 | // Get current values | |
189 | char* WXDLLEXPORT wxGetPrinterCommand(void); | |
190 | char* WXDLLEXPORT wxGetPrintPreviewCommand(void); | |
191 | char* WXDLLEXPORT wxGetPrinterOptions(void); | |
192 | int WXDLLEXPORT wxGetPrinterOrientation(void); | |
193 | void WXDLLEXPORT wxGetPrinterScaling(double* x, double* y); | |
194 | void WXDLLEXPORT wxGetPrinterTranslation(long *x, long *y); | |
195 | int WXDLLEXPORT wxGetPrinterMode(void); | |
196 | char* WXDLLEXPORT wxGetPrinterFile(void); | |
197 | char* WXDLLEXPORT wxGetAFMPath(void); | |
198 | ||
199 | /* | |
200 | * PostScript print setup information | |
201 | */ | |
202 | ||
203 | class WXDLLEXPORT wxPrintSetupData: public wxObject | |
204 | { | |
205 | DECLARE_DYNAMIC_CLASS(wxPrintSetupData) | |
206 | ||
207 | public: | |
208 | char *printerCommand; | |
209 | char *previewCommand; | |
210 | char *printerFlags; | |
211 | char *printerFile; | |
212 | int printerOrient; | |
213 | double printerScaleX; | |
214 | double printerScaleY; | |
215 | long printerTranslateX; | |
216 | long printerTranslateY; | |
217 | // 1 = Preview, 2 = print to file, 3 = send to printer | |
218 | int printerMode; | |
219 | char *afmPath; | |
220 | // A name in the paper database (see wx_print.h: the printing framework) | |
221 | char *paperName; | |
222 | bool printColour; | |
223 | public: | |
224 | wxPrintSetupData(void); | |
225 | ~wxPrintSetupData(void); | |
226 | ||
1a5a8367 DP |
227 | void SetPrinterCommand(const char *cmd); |
228 | void SetPaperName(const char *paper); | |
229 | void SetPrintPreviewCommand(const char *cmd); | |
230 | void SetPrinterOptions(const char *flags); | |
231 | void SetPrinterFile(const char *f); | |
c801d85f KB |
232 | void SetPrinterOrientation(int orient); |
233 | void SetPrinterScaling(double x, double y); | |
234 | void SetPrinterTranslation(long x, long y); | |
235 | // 1 = Preview, 2 = print to file, 3 = send to printer | |
236 | void SetPrinterMode(int mode); | |
1a5a8367 | 237 | void SetAFMPath(const char *f); |
c801d85f KB |
238 | void SetColour(bool col); |
239 | ||
240 | // Get current values | |
241 | char *GetPrinterCommand(void); | |
242 | char *GetPrintPreviewCommand(void); | |
243 | char *GetPrinterOptions(void); | |
244 | char *GetPrinterFile(void); | |
245 | char *GetPaperName(void); | |
246 | int GetPrinterOrientation(void); | |
247 | void GetPrinterScaling(double* x, double* y); | |
248 | void GetPrinterTranslation(long *x, long *y); | |
249 | int GetPrinterMode(void); | |
250 | char *GetAFMPath(void); | |
251 | bool GetColour(void); | |
252 | ||
253 | void operator=(wxPrintSetupData& data); | |
254 | }; | |
255 | ||
256 | extern wxPrintSetupData* WXDLLEXPORT wxThePrintSetupData; | |
257 | extern void WXDLLEXPORT wxInitializePrintSetupData(bool init = TRUE); | |
258 | ||
259 | /* | |
260 | * Again, this only really needed for non-Windows platforms | |
261 | * or if you want to test the PostScript printing under Windows. | |
262 | */ | |
263 | ||
264 | class WXDLLEXPORT wxPrintPaperType: public wxObject | |
265 | { | |
266 | DECLARE_DYNAMIC_CLASS(wxPrintPaperType) | |
267 | ||
268 | public: | |
269 | int widthMM; | |
270 | int heightMM; | |
271 | int widthPixels; | |
272 | int heightPixels; | |
273 | char *pageName; | |
274 | ||
1a5a8367 | 275 | wxPrintPaperType(const char *name = NULL, int wmm = 0, int hmm = 0, int wp = 0, int hp = 0); |
c801d85f KB |
276 | ~wxPrintPaperType(void); |
277 | }; | |
278 | ||
279 | class WXDLLEXPORT wxPrintPaperDatabase: public wxList | |
280 | { | |
281 | DECLARE_DYNAMIC_CLASS(wxPrintPaperDatabase) | |
282 | ||
283 | public: | |
284 | wxPrintPaperDatabase(void); | |
285 | ~wxPrintPaperDatabase(void); | |
286 | ||
287 | void CreateDatabase(void); | |
288 | void ClearDatabase(void); | |
289 | ||
1a5a8367 | 290 | void AddPaperType(const char *name, int wmm, int hmm, int wp, int hp); |
85ccdcce | 291 | wxPrintPaperType *FindPaperType(const char *name); |
c801d85f KB |
292 | }; |
293 | ||
294 | WXDLLEXPORT_DATA(extern wxPrintPaperDatabase*) wxThePrintPaperDatabase; | |
295 | ||
296 | #endif // USE_POSTSCRIPT | |
297 | #endif | |
34138703 | 298 | // _WX_POSTSCRPH__ |