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