]> git.saurik.com Git - wxWidgets.git/blob - include/wx/postscrp.h
New PostScript code
[wxWidgets.git] / include / wx / postscrp.h
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
12 #ifdef __WXGTK__
13
14 #include "wx/gtk/dcps.h"
15
16 #else
17
18 #ifndef _WX_POSTSCRPH__
19 #define _WX_POSTSCRPH__
20
21 #ifdef __GNUG__
22 #pragma interface "postscrp.h"
23 #endif
24
25 #include "wx/dc.h"
26 #include "wx/dialog.h"
27 #include "wx/module.h"
28
29 #if wxUSE_POSTSCRIPT
30
31 // A module to allow initialization/cleanup of PostScript-related
32 // things without calling these functions from app.cpp.
33
34 class WXDLLEXPORT wxPostScriptModule: public wxModule
35 {
36 DECLARE_DYNAMIC_CLASS(wxPostScriptModule)
37 public:
38 wxPostScriptModule() {}
39 bool OnInit();
40 void OnExit();
41 };
42
43 #if wxUSE_IOSTREAMH
44 # include <fstream.h>
45 #else
46 # include <fstream>
47 # ifdef _MSC_VER
48 using namespace std;
49 # endif
50 #endif
51
52 class WXDLLEXPORT wxPostScriptDC: public wxDC
53 {
54 DECLARE_DYNAMIC_CLASS(wxPostScriptDC)
55
56 public:
57 // Create a printer DC
58 wxPostScriptDC();
59 wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow *parent = (wxWindow *) NULL);
60
61 ~wxPostScriptDC();
62
63 bool Create(const wxString& output, bool interactive = TRUE, wxWindow *parent = (wxWindow *) NULL);
64
65 virtual bool PrinterDialog(wxWindow *parent = (wxWindow *) NULL);
66
67 inline virtual void BeginDrawing(void) {} ;
68 inline virtual void EndDrawing(void) {} ;
69
70 void FloodFill(long x1, long y1, const wxColour &col, int style=wxFLOOD_SURFACE) ;
71 bool GetPixel(long x1, long y1, wxColour *col) const;
72
73 void DrawLine(long x1, long y1, long x2, long y2);
74 void CrossHair(long x, long y) ;
75 void DrawArc(long x1,long y1,long x2,long y2,long xc,long yc);
76 void DrawEllipticArc(long x,long y,long w,long h,double sa,double ea);
77 void DrawPoint(long x, long y);
78 // Avoid compiler warning
79 void DrawPoint(wxPoint& point) { wxDC::DrawPoint(point); }
80 void DrawLines(int n, wxPoint points[], long xoffset = 0, long yoffset = 0);
81 // Avoid compiler warning
82 void DrawLines(wxList *lines, long xoffset = 0, long yoffset = 0)
83 { wxDC::DrawLines(lines, xoffset, yoffset); }
84 void DrawPolygon(int n, wxPoint points[], long xoffset = 0, long yoffset = 0, int fillStyle=wxODDEVEN_RULE);
85 // Avoid compiler warning
86 void DrawPolygon(wxList *lines, long xoffset = 0, long yoffset = 0, int fillStyle=wxODDEVEN_RULE)
87 { wxDC::DrawPolygon(lines, xoffset, yoffset, fillStyle); }
88 void DrawRectangle(long x, long y, long width, long height);
89 void DrawRoundedRectangle(long x, long y, long width, long height, double radius = 20);
90 void DrawEllipse(long x, long y, long width, long height);
91
92 void DrawSpline(wxList *points);
93
94 void DrawIcon( const wxIcon& icon, long x, long y );
95 void DrawBitmap( const wxBitmap& bitmap, long x, long y, bool useMask=FALSE );
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 void GetTextExtent(const wxString& string, long *x, long *y,
117 long *descent = (long *) NULL,
118 long *externalLeading = (long *) NULL,
119 wxFont *theFont = (wxFont *) NULL, bool use16 = FALSE);
120 virtual void SetLogicalOrigin(long x, long y);
121 virtual void CalcBoundingBox(long x, long y);
122
123 void SetMapMode(int mode);
124 void SetUserScale(double x, double y);
125 long DeviceToLogicalX(int x) const;
126 long DeviceToLogicalY(int y) const;
127 long DeviceToLogicalXRel(int x) const;
128 long DeviceToLogicalYRel(int y) const;
129 long LogicalToDeviceX(long x) const;
130 long LogicalToDeviceY(long y) const;
131 long LogicalToDeviceXRel(long x) const;
132 long LogicalToDeviceYRel(long y) const;
133 bool Blit(long xdest, long ydest, long width, long height,
134 wxDC *source, long xsrc, long ysrc, int rop = wxCOPY, bool useMask = FALSE);
135 inline bool CanGetTextExtent(void) const { return FALSE; }
136 inline bool CanDrawBitmap(void) const { return FALSE; }
137
138 void GetSize(int* width, int* height) const;
139 void GetSizeMM(long *width, long *height) const;
140
141 inline void SetBackgroundMode(int WXUNUSED(mode)) {};
142 inline void SetPalette(const wxPalette& WXUNUSED(palette)) {}
143
144 inline ofstream *GetStream(void) const { return m_pstream; }
145 inline int GetYOrigin(void) const { return m_yOrigin; }
146
147 void SetupCTM();
148
149 protected:
150 int m_yOrigin; // For EPS
151 ofstream * m_pstream; // PostScript output stream
152 wxString m_title;
153 unsigned char m_currentRed;
154 unsigned char m_currentGreen;
155 unsigned char m_currentBlue;
156 double m_scaleFactor;
157 };
158
159 #define wxID_PRINTER_COMMAND 1
160 #define wxID_PRINTER_OPTIONS 2
161 #define wxID_PRINTER_ORIENTATION 3
162 #define wxID_PRINTER_MODES 4
163 #define wxID_PRINTER_X_SCALE 5
164 #define wxID_PRINTER_Y_SCALE 6
165 #define wxID_PRINTER_X_TRANS 7
166 #define wxID_PRINTER_Y_TRANS 8
167
168 class WXDLLEXPORT wxPostScriptPrintDialog: public wxDialog
169 {
170 DECLARE_CLASS(wxPostScriptPrintDialog)
171 public:
172 wxPostScriptPrintDialog (wxWindow *parent, const wxString& title,
173 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
174 long style = wxDEFAULT_DIALOG_STYLE);
175
176 virtual int ShowModal(void) ;
177 };
178
179
180 // Print Orientation (Should also add Left, Right)
181 enum {
182 PS_PORTRAIT = 1,
183 PS_LANDSCAPE = 2
184 };// ps_orientation = PS_PORTRAIT;
185
186 // Print Actions
187 enum {
188 PS_PRINTER,
189 PS_FILE,
190 PS_PREVIEW
191 };// ps_action = PS_PREVIEW;
192
193 // PostScript printer settings
194 WXDLLEXPORT void wxSetPrinterCommand(const char *cmd);
195 WXDLLEXPORT void wxSetPrintPreviewCommand(const char *cmd);
196 WXDLLEXPORT void wxSetPrinterOptions(const char *flags);
197 WXDLLEXPORT void wxSetPrinterOrientation(int orientation);
198 WXDLLEXPORT void wxSetPrinterScaling(double x, double y);
199 WXDLLEXPORT void wxSetPrinterTranslation(long x, long y);
200 WXDLLEXPORT void wxSetPrinterMode(int mode);
201 WXDLLEXPORT void wxSetPrinterFile(const char *f);
202 WXDLLEXPORT void wxSetAFMPath(const char *f);
203
204 // Get current values
205 WXDLLEXPORT char* wxGetPrinterCommand();
206 WXDLLEXPORT char* wxGetPrintPreviewCommand();
207 WXDLLEXPORT char* wxGetPrinterOptions();
208 WXDLLEXPORT int wxGetPrinterOrientation();
209 WXDLLEXPORT void wxGetPrinterScaling(double* x, double* y);
210 WXDLLEXPORT void wxGetPrinterTranslation(long *x, long *y);
211 WXDLLEXPORT int wxGetPrinterMode();
212 WXDLLEXPORT char* wxGetPrinterFile();
213 WXDLLEXPORT char* wxGetAFMPath();
214
215 /*
216 * PostScript print setup information
217 */
218
219 class WXDLLEXPORT wxPrintSetupData: public wxObject
220 {
221 public:
222 char *printerCommand;
223 char *previewCommand;
224 char *printerFlags;
225 char *printerFile;
226 int printerOrient;
227 double printerScaleX;
228 double printerScaleY;
229 long printerTranslateX;
230 long printerTranslateY;
231 // 1 = Preview, 2 = print to file, 3 = send to printer
232 int printerMode;
233 char *afmPath;
234 // A name in the paper database (see wx_print.h: the printing framework)
235 char *paperName;
236 bool printColour;
237
238 public:
239 wxPrintSetupData();
240 ~wxPrintSetupData();
241
242 void SetPrinterCommand(const char *cmd);
243 void SetPaperName(const char *paper);
244 void SetPrintPreviewCommand(const char *cmd);
245 void SetPrinterOptions(const char *flags);
246 void SetPrinterFile(const char *f);
247 void SetPrinterOrientation(int orient);
248 void SetPrinterScaling(double x, double y);
249 void SetPrinterTranslation(long x, long y);
250 // 1 = Preview, 2 = print to file, 3 = send to printer
251 void SetPrinterMode(int mode);
252 void SetAFMPath(const char *f);
253 void SetColour(bool col);
254
255 // Get current values
256 char *GetPrinterCommand();
257 char *GetPrintPreviewCommand();
258 char *GetPrinterOptions();
259 char *GetPrinterFile();
260 char *GetPaperName();
261 int GetPrinterOrientation();
262 void GetPrinterScaling(double* x, double* y);
263 void GetPrinterTranslation(long *x, long *y);
264 int GetPrinterMode();
265 char *GetAFMPath();
266 bool GetColour();
267
268 void operator=(wxPrintSetupData& data);
269
270 private:
271 DECLARE_DYNAMIC_CLASS(wxPrintSetupData)
272 };
273
274 WXDLLEXPORT_DATA(extern wxPrintSetupData*) wxThePrintSetupData;
275 WXDLLEXPORT extern void wxInitializePrintSetupData(bool init = TRUE);
276
277 /*
278 * Again, this only really needed for non-Windows platforms
279 * or if you want to test the PostScript printing under Windows.
280 */
281
282 class WXDLLEXPORT wxPrintPaperType: public wxObject
283 {
284 public:
285 wxPrintPaperType(const char *name = (const char *) NULL, int wmm = 0, int hmm = 0, int wp = 0, int hp = 0);
286 ~wxPrintPaperType();
287
288 public:
289 int widthMM;
290 int heightMM;
291 int widthPixels;
292 int heightPixels;
293 char *pageName;
294
295 private:
296 DECLARE_DYNAMIC_CLASS(wxPrintPaperType)
297 };
298
299 class WXDLLEXPORT wxPrintPaperDatabase: public wxList
300 {
301 public:
302 wxPrintPaperDatabase();
303 ~wxPrintPaperDatabase();
304
305 void CreateDatabase();
306 void ClearDatabase();
307
308 void AddPaperType(const char *name, int wmm, int hmm, int wp, int hp);
309 wxPrintPaperType *FindPaperType(const char *name);
310
311 private:
312 DECLARE_DYNAMIC_CLASS(wxPrintPaperDatabase)
313 };
314
315 WXDLLEXPORT_DATA(extern wxPrintPaperDatabase*) wxThePrintPaperDatabase;
316
317 #endif
318 // wxUSE_POSTSCRIPT
319
320 #endif
321 // _WX_POSTSCRPH__
322
323 #endif
324 // __WXGTK__
325
326