]>
Commit | Line | Data |
---|---|---|
c801d85f | 1 | ///////////////////////////////////////////////////////////////////////////// |
bf38cbff | 2 | // Name: dcps.h |
c801d85f KB |
3 | // Purpose: wxPostScriptDC class |
4 | // Author: Julian Smart and others | |
5 | // Modified by: | |
c801d85f | 6 | // RCS-ID: $Id$ |
bf38cbff | 7 | // Copyright: (c) Julian Smart, Robert Roebling and Markus Holzem |
a6f6393c | 8 | // Licence: wxWindows licence |
c801d85f KB |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
bf38cbff JS |
11 | #ifndef _WX_DCPSG_H_ |
12 | #define _WX_DCPSG_H_ | |
c801d85f KB |
13 | |
14 | #ifdef __GNUG__ | |
bf38cbff | 15 | #pragma interface |
c801d85f KB |
16 | #endif |
17 | ||
18 | #include "wx/dc.h" | |
c801d85f | 19 | |
47d67540 | 20 | #if wxUSE_POSTSCRIPT |
c801d85f | 21 | |
bf38cbff JS |
22 | #include "wx/dialog.h" |
23 | #include "wx/module.h" | |
24 | #include <fstream.h> | |
fbc535ff | 25 | |
f04371f0 | 26 | |
bf38cbff JS |
27 | //----------------------------------------------------------------------------- |
28 | // classes | |
29 | //----------------------------------------------------------------------------- | |
f04371f0 | 30 | |
bf38cbff | 31 | class wxPostScriptDC; |
f04371f0 | 32 | |
bf38cbff JS |
33 | //----------------------------------------------------------------------------- |
34 | // wxPostScriptDC | |
35 | //----------------------------------------------------------------------------- | |
f04371f0 | 36 | |
c801d85f KB |
37 | class WXDLLEXPORT wxPostScriptDC: public wxDC |
38 | { | |
39 | DECLARE_DYNAMIC_CLASS(wxPostScriptDC) | |
40 | ||
bf38cbff JS |
41 | public: |
42 | ||
a6f6393c | 43 | wxPostScriptDC(); |
c67daf87 | 44 | wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow *parent = (wxWindow *) NULL); |
c801d85f | 45 | |
a6f6393c | 46 | ~wxPostScriptDC(); |
c801d85f | 47 | |
c67daf87 | 48 | bool Create(const wxString& output, bool interactive = TRUE, wxWindow *parent = (wxWindow *) NULL); |
c801d85f | 49 | |
bf38cbff JS |
50 | virtual bool Ok() const; |
51 | ||
c67daf87 | 52 | virtual bool PrinterDialog(wxWindow *parent = (wxWindow *) NULL); |
c801d85f | 53 | |
bf38cbff JS |
54 | virtual void BeginDrawing() {} |
55 | virtual void EndDrawing() {} | |
c801d85f | 56 | |
463c1fa1 | 57 | void FloodFill(long x1, long y1, const wxColour &col, int style=wxFLOOD_SURFACE) ; |
c801d85f KB |
58 | bool GetPixel(long x1, long y1, wxColour *col) const; |
59 | ||
60 | void DrawLine(long x1, long y1, long x2, long y2); | |
61 | void CrossHair(long x, long y) ; | |
62 | void DrawArc(long x1,long y1,long x2,long y2,long xc,long yc); | |
63 | void DrawEllipticArc(long x,long y,long w,long h,double sa,double ea); | |
64 | void DrawPoint(long x, long y); | |
65 | // Avoid compiler warning | |
66 | void DrawPoint(wxPoint& point) { wxDC::DrawPoint(point); } | |
67 | void DrawLines(int n, wxPoint points[], long xoffset = 0, long yoffset = 0); | |
68 | // Avoid compiler warning | |
69 | void DrawLines(wxList *lines, long xoffset = 0, long yoffset = 0) | |
70 | { wxDC::DrawLines(lines, xoffset, yoffset); } | |
71 | void DrawPolygon(int n, wxPoint points[], long xoffset = 0, long yoffset = 0, int fillStyle=wxODDEVEN_RULE); | |
72 | // Avoid compiler warning | |
73 | void DrawPolygon(wxList *lines, long xoffset = 0, long yoffset = 0, int fillStyle=wxODDEVEN_RULE) | |
74 | { wxDC::DrawPolygon(lines, xoffset, yoffset, fillStyle); } | |
75 | void DrawRectangle(long x, long y, long width, long height); | |
76 | void DrawRoundedRectangle(long x, long y, long width, long height, double radius = 20); | |
77 | void DrawEllipse(long x, long y, long width, long height); | |
78 | ||
c801d85f | 79 | void DrawSpline(wxList *points); |
c801d85f | 80 | |
bf38cbff JS |
81 | bool Blit(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 | ||
463c1fa1 RR |
85 | void DrawIcon( const wxIcon& icon, long x, long y ); |
86 | void DrawBitmap( const wxBitmap& bitmap, long x, long y, bool useMask=FALSE ); | |
bf38cbff | 87 | |
c801d85f KB |
88 | void DrawText(const wxString& text, long x, long y, bool use16 = FALSE); |
89 | ||
a6f6393c | 90 | void Clear(); |
bf38cbff JS |
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 | ||
c801d85f | 97 | void SetClippingRegion(long x, long y, long width, long height); |
463c1fa1 | 98 | void SetClippingRegion( const wxRegion ®ion ); |
a6f6393c | 99 | void DestroyClippingRegion(); |
c801d85f KB |
100 | |
101 | bool StartDoc(const wxString& message); | |
a6f6393c VZ |
102 | void EndDoc(); |
103 | void StartPage(); | |
104 | void EndPage(); | |
c801d85f | 105 | |
a6f6393c VZ |
106 | long GetCharHeight(); |
107 | long GetCharWidth(); | |
bf38cbff | 108 | inline bool CanGetTextExtent(void) const { return FALSE; } |
c801d85f | 109 | void GetTextExtent(const wxString& string, long *x, long *y, |
a6f6393c VZ |
110 | long *descent = (long *) NULL, |
111 | long *externalLeading = (long *) NULL, | |
c67daf87 | 112 | wxFont *theFont = (wxFont *) NULL, bool use16 = FALSE); |
c801d85f KB |
113 | |
114 | void GetSize(int* width, int* height) const; | |
115 | void GetSizeMM(long *width, long *height) const; | |
116 | ||
bf38cbff JS |
117 | void SetAxisOrientation( bool xLeftRight, bool yBottomUp ); |
118 | void SetDeviceOrigin( long x, long y ); | |
119 | ||
120 | inline void SetBackgroundMode(int WXUNUSED(mode)) {} | |
c801d85f | 121 | inline void SetPalette(const wxPalette& WXUNUSED(palette)) {} |
c801d85f | 122 | |
bf38cbff | 123 | inline ofstream *GetStream(void) const { return m_pstream; } |
c801d85f KB |
124 | |
125 | protected: | |
bf38cbff | 126 | |
c801d85f KB |
127 | ofstream * m_pstream; // PostScript output stream |
128 | wxString m_title; | |
129 | unsigned char m_currentRed; | |
130 | unsigned char m_currentGreen; | |
131 | unsigned char m_currentBlue; | |
bf38cbff JS |
132 | int m_pageNumber; |
133 | bool m_clipping; | |
134 | double m_underlinePosition; | |
135 | double m_underlineThickness; | |
136 | }; | |
137 | ||
138 | // A module to allow initialization/cleanup of PostScript-related | |
139 | // things without calling these functions from app.cpp. | |
140 | ||
141 | class WXDLLEXPORT wxPostScriptModule: public wxModule | |
142 | { | |
143 | DECLARE_DYNAMIC_CLASS(wxPostScriptModule) | |
144 | public: | |
145 | wxPostScriptModule() {} | |
146 | bool OnInit(); | |
147 | void OnExit(); | |
c801d85f KB |
148 | }; |
149 | ||
bf38cbff JS |
150 | // TODO Needed? Should perhaps use wxGenericPrintDialog instead. |
151 | #if 1 | |
c801d85f KB |
152 | #define wxID_PRINTER_COMMAND 1 |
153 | #define wxID_PRINTER_OPTIONS 2 | |
154 | #define wxID_PRINTER_ORIENTATION 3 | |
155 | #define wxID_PRINTER_MODES 4 | |
156 | #define wxID_PRINTER_X_SCALE 5 | |
157 | #define wxID_PRINTER_Y_SCALE 6 | |
158 | #define wxID_PRINTER_X_TRANS 7 | |
159 | #define wxID_PRINTER_Y_TRANS 8 | |
160 | ||
161 | class WXDLLEXPORT wxPostScriptPrintDialog: public wxDialog | |
162 | { | |
163 | DECLARE_CLASS(wxPostScriptPrintDialog) | |
164 | public: | |
165 | wxPostScriptPrintDialog (wxWindow *parent, const wxString& title, | |
a6f6393c VZ |
166 | const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, |
167 | long style = wxDEFAULT_DIALOG_STYLE); | |
c801d85f KB |
168 | |
169 | virtual int ShowModal(void) ; | |
170 | }; | |
bf38cbff | 171 | #endif |
c801d85f KB |
172 | |
173 | // Print Orientation (Should also add Left, Right) | |
174 | enum { | |
175 | PS_PORTRAIT = 1, | |
176 | PS_LANDSCAPE = 2 | |
177 | };// ps_orientation = PS_PORTRAIT; | |
178 | ||
179 | // Print Actions | |
180 | enum { | |
181 | PS_PRINTER, | |
182 | PS_FILE, | |
183 | PS_PREVIEW | |
184 | };// ps_action = PS_PREVIEW; | |
185 | ||
186 | // PostScript printer settings | |
184b5d99 JS |
187 | WXDLLEXPORT void wxSetPrinterCommand(const char *cmd); |
188 | WXDLLEXPORT void wxSetPrintPreviewCommand(const char *cmd); | |
189 | WXDLLEXPORT void wxSetPrinterOptions(const char *flags); | |
190 | WXDLLEXPORT void wxSetPrinterOrientation(int orientation); | |
191 | WXDLLEXPORT void wxSetPrinterScaling(double x, double y); | |
192 | WXDLLEXPORT void wxSetPrinterTranslation(long x, long y); | |
193 | WXDLLEXPORT void wxSetPrinterMode(int mode); | |
194 | WXDLLEXPORT void wxSetPrinterFile(const char *f); | |
195 | WXDLLEXPORT void wxSetAFMPath(const char *f); | |
c801d85f KB |
196 | |
197 | // Get current values | |
a6f6393c VZ |
198 | WXDLLEXPORT char* wxGetPrinterCommand(); |
199 | WXDLLEXPORT char* wxGetPrintPreviewCommand(); | |
200 | WXDLLEXPORT char* wxGetPrinterOptions(); | |
201 | WXDLLEXPORT int wxGetPrinterOrientation(); | |
184b5d99 JS |
202 | WXDLLEXPORT void wxGetPrinterScaling(double* x, double* y); |
203 | WXDLLEXPORT void wxGetPrinterTranslation(long *x, long *y); | |
a6f6393c VZ |
204 | WXDLLEXPORT int wxGetPrinterMode(); |
205 | WXDLLEXPORT char* wxGetPrinterFile(); | |
206 | WXDLLEXPORT char* wxGetAFMPath(); | |
c801d85f KB |
207 | |
208 | /* | |
209 | * PostScript print setup information | |
210 | */ | |
211 | ||
212 | class WXDLLEXPORT wxPrintSetupData: public wxObject | |
213 | { | |
a6f6393c VZ |
214 | public: |
215 | char *printerCommand; | |
216 | char *previewCommand; | |
217 | char *printerFlags; | |
218 | char *printerFile; | |
219 | int printerOrient; | |
220 | double printerScaleX; | |
221 | double printerScaleY; | |
222 | long printerTranslateX; | |
223 | long printerTranslateY; | |
224 | // 1 = Preview, 2 = print to file, 3 = send to printer | |
225 | int printerMode; | |
226 | char *afmPath; | |
227 | // A name in the paper database (see wx_print.h: the printing framework) | |
228 | char *paperName; | |
229 | bool printColour; | |
c801d85f | 230 | |
a6f6393c VZ |
231 | public: |
232 | wxPrintSetupData(); | |
233 | ~wxPrintSetupData(); | |
234 | ||
235 | void SetPrinterCommand(const char *cmd); | |
236 | void SetPaperName(const char *paper); | |
237 | void SetPrintPreviewCommand(const char *cmd); | |
238 | void SetPrinterOptions(const char *flags); | |
239 | void SetPrinterFile(const char *f); | |
240 | void SetPrinterOrientation(int orient); | |
241 | void SetPrinterScaling(double x, double y); | |
242 | void SetPrinterTranslation(long x, long y); | |
243 | // 1 = Preview, 2 = print to file, 3 = send to printer | |
244 | void SetPrinterMode(int mode); | |
245 | void SetAFMPath(const char *f); | |
246 | void SetColour(bool col); | |
247 | ||
248 | // Get current values | |
249 | char *GetPrinterCommand(); | |
250 | char *GetPrintPreviewCommand(); | |
251 | char *GetPrinterOptions(); | |
252 | char *GetPrinterFile(); | |
253 | char *GetPaperName(); | |
254 | int GetPrinterOrientation(); | |
255 | void GetPrinterScaling(double* x, double* y); | |
256 | void GetPrinterTranslation(long *x, long *y); | |
257 | int GetPrinterMode(); | |
258 | char *GetAFMPath(); | |
259 | bool GetColour(); | |
260 | ||
261 | void operator=(wxPrintSetupData& data); | |
262 | ||
263 | private: | |
264 | DECLARE_DYNAMIC_CLASS(wxPrintSetupData) | |
c801d85f KB |
265 | }; |
266 | ||
184b5d99 JS |
267 | WXDLLEXPORT_DATA(extern wxPrintSetupData*) wxThePrintSetupData; |
268 | WXDLLEXPORT extern void wxInitializePrintSetupData(bool init = TRUE); | |
c801d85f KB |
269 | |
270 | /* | |
271 | * Again, this only really needed for non-Windows platforms | |
272 | * or if you want to test the PostScript printing under Windows. | |
273 | */ | |
274 | ||
275 | class WXDLLEXPORT wxPrintPaperType: public wxObject | |
276 | { | |
a6f6393c VZ |
277 | public: |
278 | wxPrintPaperType(const char *name = (const char *) NULL, int wmm = 0, int hmm = 0, int wp = 0, int hp = 0); | |
279 | ~wxPrintPaperType(); | |
c801d85f | 280 | |
a6f6393c VZ |
281 | public: |
282 | int widthMM; | |
283 | int heightMM; | |
284 | int widthPixels; | |
285 | int heightPixels; | |
286 | char *pageName; | |
287 | ||
288 | private: | |
289 | DECLARE_DYNAMIC_CLASS(wxPrintPaperType) | |
c801d85f KB |
290 | }; |
291 | ||
292 | class WXDLLEXPORT wxPrintPaperDatabase: public wxList | |
293 | { | |
a6f6393c VZ |
294 | public: |
295 | wxPrintPaperDatabase(); | |
296 | ~wxPrintPaperDatabase(); | |
c801d85f | 297 | |
a6f6393c VZ |
298 | void CreateDatabase(); |
299 | void ClearDatabase(); | |
c801d85f | 300 | |
a6f6393c VZ |
301 | void AddPaperType(const char *name, int wmm, int hmm, int wp, int hp); |
302 | wxPrintPaperType *FindPaperType(const char *name); | |
c801d85f | 303 | |
a6f6393c VZ |
304 | private: |
305 | DECLARE_DYNAMIC_CLASS(wxPrintPaperDatabase) | |
c801d85f KB |
306 | }; |
307 | ||
308 | WXDLLEXPORT_DATA(extern wxPrintPaperDatabase*) wxThePrintPaperDatabase; | |
309 | ||
bf38cbff JS |
310 | #endif |
311 | // wxUSE_POSTSCRIPT | |
ed880dd4 | 312 | |
c801d85f | 313 | #endif |
bf38cbff | 314 | // _WX_DCPSG_H_ |