]> git.saurik.com Git - wxWidgets.git/blob - include/wx/postscrp.h
wxProp now intercepts EVT_TEXT_ENTER instead of EVT_TEXT
[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
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 = (wxWindow *) NULL);
33
34 ~wxPostScriptDC(void);
35
36 bool Create(const wxString& output, bool interactive = TRUE, wxWindow *parent = (wxWindow *) NULL);
37
38 virtual bool PrinterDialog(wxWindow *parent = (wxWindow *) 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
65 // RR: I define these in wxDC, after all they all do the same everywhere
66
67 #ifdef __WXMSW__
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[]);
74 #endif
75
76 void DrawOpenSpline(wxList *points);
77
78 void DrawIcon(const wxIcon& icon, long x, long y);
79 #ifdef __WXGTK__
80 void DrawIcon(const wxIcon& icon, long x, long y, bool WXUNUSED(usemask) )
81 { DrawIcon( icon, x, y ); }
82 #endif
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 = (long *) NULL,
103 long *externalLeading = (long *) NULL,
104 wxFont *theFont = (wxFont *) NULL, bool use16 = FALSE);
105 virtual void SetLogicalOrigin(long x, long y);
106 virtual void CalcBoundingBox(long x, long y);
107
108 void SetMapMode(int mode);
109 void SetUserScale(double x, double y);
110 long DeviceToLogicalX(int x) const;
111 long DeviceToLogicalY(int y) const;
112 long DeviceToLogicalXRel(int x) const;
113 long DeviceToLogicalYRel(int y) const;
114 long LogicalToDeviceX(long x) const;
115 long LogicalToDeviceY(long y) const;
116 long LogicalToDeviceXRel(long x) const;
117 long LogicalToDeviceYRel(long y) const;
118 bool Blit(long xdest, long ydest, long width, long height,
119 wxDC *source, long xsrc, long ysrc, int rop = wxCOPY, bool useMask = FALSE);
120 inline bool CanGetTextExtent(void) const { return FALSE; }
121 inline bool CanDrawBitmap(void) const { return FALSE; }
122
123 void GetSize(int* width, int* height) const;
124 void GetSizeMM(long *width, long *height) const;
125
126 inline void SetBackgroundMode(int WXUNUSED(mode)) {};
127 inline void SetPalette(const wxPalette& WXUNUSED(palette)) {}
128
129 inline ofstream *GetStream(void) const { return m_pstream; }
130 inline int GetYOrigin(void) const { return m_yOrigin; }
131
132 void SetupCTM();
133
134 protected:
135 int m_yOrigin; // For EPS
136 ofstream * m_pstream; // PostScript output stream
137 wxString m_title;
138 unsigned char m_currentRed;
139 unsigned char m_currentGreen;
140 unsigned char m_currentBlue;
141 double m_scaleFactor;
142 };
143
144 #define wxID_PRINTER_COMMAND 1
145 #define wxID_PRINTER_OPTIONS 2
146 #define wxID_PRINTER_ORIENTATION 3
147 #define wxID_PRINTER_MODES 4
148 #define wxID_PRINTER_X_SCALE 5
149 #define wxID_PRINTER_Y_SCALE 6
150 #define wxID_PRINTER_X_TRANS 7
151 #define wxID_PRINTER_Y_TRANS 8
152
153 class WXDLLEXPORT wxPostScriptPrintDialog: public wxDialog
154 {
155 DECLARE_CLASS(wxPostScriptPrintDialog)
156 public:
157 wxPostScriptPrintDialog (wxWindow *parent, const wxString& title,
158 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
159 long style = wxDEFAULT_DIALOG_STYLE);
160
161 virtual int ShowModal(void) ;
162 };
163
164
165 // Print Orientation (Should also add Left, Right)
166 enum {
167 PS_PORTRAIT = 1,
168 PS_LANDSCAPE = 2
169 };// ps_orientation = PS_PORTRAIT;
170
171 // Print Actions
172 enum {
173 PS_PRINTER,
174 PS_FILE,
175 PS_PREVIEW
176 };// ps_action = PS_PREVIEW;
177
178 // PostScript printer settings
179 void WXDLLEXPORT wxSetPrinterCommand(const char *cmd);
180 void WXDLLEXPORT wxSetPrintPreviewCommand(const char *cmd);
181 void WXDLLEXPORT wxSetPrinterOptions(const char *flags);
182 void WXDLLEXPORT wxSetPrinterOrientation(int orientation);
183 void WXDLLEXPORT wxSetPrinterScaling(double x, double y);
184 void WXDLLEXPORT wxSetPrinterTranslation(long x, long y);
185 void WXDLLEXPORT wxSetPrinterMode(int mode);
186 void WXDLLEXPORT wxSetPrinterFile(const char *f);
187 void WXDLLEXPORT wxSetAFMPath(const char *f);
188
189 // Get current values
190 char* WXDLLEXPORT wxGetPrinterCommand(void);
191 char* WXDLLEXPORT wxGetPrintPreviewCommand(void);
192 char* WXDLLEXPORT wxGetPrinterOptions(void);
193 int WXDLLEXPORT wxGetPrinterOrientation(void);
194 void WXDLLEXPORT wxGetPrinterScaling(double* x, double* y);
195 void WXDLLEXPORT wxGetPrinterTranslation(long *x, long *y);
196 int WXDLLEXPORT wxGetPrinterMode(void);
197 char* WXDLLEXPORT wxGetPrinterFile(void);
198 char* WXDLLEXPORT wxGetAFMPath(void);
199
200 /*
201 * PostScript print setup information
202 */
203
204 class WXDLLEXPORT wxPrintSetupData: public wxObject
205 {
206 DECLARE_DYNAMIC_CLASS(wxPrintSetupData)
207
208 public:
209 char *printerCommand;
210 char *previewCommand;
211 char *printerFlags;
212 char *printerFile;
213 int printerOrient;
214 double printerScaleX;
215 double printerScaleY;
216 long printerTranslateX;
217 long printerTranslateY;
218 // 1 = Preview, 2 = print to file, 3 = send to printer
219 int printerMode;
220 char *afmPath;
221 // A name in the paper database (see wx_print.h: the printing framework)
222 char *paperName;
223 bool printColour;
224 public:
225 wxPrintSetupData(void);
226 ~wxPrintSetupData(void);
227
228 void SetPrinterCommand(const char *cmd);
229 void SetPaperName(const char *paper);
230 void SetPrintPreviewCommand(const char *cmd);
231 void SetPrinterOptions(const char *flags);
232 void SetPrinterFile(const char *f);
233 void SetPrinterOrientation(int orient);
234 void SetPrinterScaling(double x, double y);
235 void SetPrinterTranslation(long x, long y);
236 // 1 = Preview, 2 = print to file, 3 = send to printer
237 void SetPrinterMode(int mode);
238 void SetAFMPath(const char *f);
239 void SetColour(bool col);
240
241 // Get current values
242 char *GetPrinterCommand(void);
243 char *GetPrintPreviewCommand(void);
244 char *GetPrinterOptions(void);
245 char *GetPrinterFile(void);
246 char *GetPaperName(void);
247 int GetPrinterOrientation(void);
248 void GetPrinterScaling(double* x, double* y);
249 void GetPrinterTranslation(long *x, long *y);
250 int GetPrinterMode(void);
251 char *GetAFMPath(void);
252 bool GetColour(void);
253
254 void operator=(wxPrintSetupData& data);
255 };
256
257 extern wxPrintSetupData* WXDLLEXPORT wxThePrintSetupData;
258 extern void WXDLLEXPORT wxInitializePrintSetupData(bool init = TRUE);
259
260 /*
261 * Again, this only really needed for non-Windows platforms
262 * or if you want to test the PostScript printing under Windows.
263 */
264
265 class WXDLLEXPORT wxPrintPaperType: public wxObject
266 {
267 DECLARE_DYNAMIC_CLASS(wxPrintPaperType)
268
269 public:
270 int widthMM;
271 int heightMM;
272 int widthPixels;
273 int heightPixels;
274 char *pageName;
275
276 wxPrintPaperType(const char *name = (const char *) NULL, int wmm = 0, int hmm = 0, int wp = 0, int hp = 0);
277 ~wxPrintPaperType(void);
278 };
279
280 class WXDLLEXPORT wxPrintPaperDatabase: public wxList
281 {
282 DECLARE_DYNAMIC_CLASS(wxPrintPaperDatabase)
283
284 public:
285 wxPrintPaperDatabase(void);
286 ~wxPrintPaperDatabase(void);
287
288 void CreateDatabase(void);
289 void ClearDatabase(void);
290
291 void AddPaperType(const char *name, int wmm, int hmm, int wp, int hp);
292 wxPrintPaperType *FindPaperType(const char *name);
293 };
294
295 WXDLLEXPORT_DATA(extern wxPrintPaperDatabase*) wxThePrintPaperDatabase;
296
297 #endif // USE_POSTSCRIPT
298 #endif
299 // _WX_POSTSCRPH__