]> git.saurik.com Git - wxWidgets.git/blob - include/wx/postscrp.h
More Motif stuff incl. beginnings of wxToolBar
[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(void);
53 wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow *parent = (wxWindow *) NULL);
54
55 ~wxPostScriptDC(void);
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(void);
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(void);
103
104 bool StartDoc(const wxString& message);
105 void EndDoc(void);
106 void StartPage(void);
107 void EndPage(void);
108
109 long GetCharHeight(void);
110 long GetCharWidth(void);
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 void WXDLLEXPORT wxSetPrinterCommand(const char *cmd);
190 void WXDLLEXPORT wxSetPrintPreviewCommand(const char *cmd);
191 void WXDLLEXPORT wxSetPrinterOptions(const char *flags);
192 void WXDLLEXPORT wxSetPrinterOrientation(int orientation);
193 void WXDLLEXPORT wxSetPrinterScaling(double x, double y);
194 void WXDLLEXPORT wxSetPrinterTranslation(long x, long y);
195 void WXDLLEXPORT wxSetPrinterMode(int mode);
196 void WXDLLEXPORT wxSetPrinterFile(const char *f);
197 void WXDLLEXPORT wxSetAFMPath(const char *f);
198
199 // Get current values
200 char* WXDLLEXPORT wxGetPrinterCommand(void);
201 char* WXDLLEXPORT wxGetPrintPreviewCommand(void);
202 char* WXDLLEXPORT wxGetPrinterOptions(void);
203 int WXDLLEXPORT wxGetPrinterOrientation(void);
204 void WXDLLEXPORT wxGetPrinterScaling(double* x, double* y);
205 void WXDLLEXPORT wxGetPrinterTranslation(long *x, long *y);
206 int WXDLLEXPORT wxGetPrinterMode(void);
207 char* WXDLLEXPORT wxGetPrinterFile(void);
208 char* WXDLLEXPORT wxGetAFMPath(void);
209
210 /*
211 * PostScript print setup information
212 */
213
214 class WXDLLEXPORT wxPrintSetupData: public wxObject
215 {
216 DECLARE_DYNAMIC_CLASS(wxPrintSetupData)
217
218 public:
219 char *printerCommand;
220 char *previewCommand;
221 char *printerFlags;
222 char *printerFile;
223 int printerOrient;
224 double printerScaleX;
225 double printerScaleY;
226 long printerTranslateX;
227 long printerTranslateY;
228 // 1 = Preview, 2 = print to file, 3 = send to printer
229 int printerMode;
230 char *afmPath;
231 // A name in the paper database (see wx_print.h: the printing framework)
232 char *paperName;
233 bool printColour;
234 public:
235 wxPrintSetupData(void);
236 ~wxPrintSetupData(void);
237
238 void SetPrinterCommand(const char *cmd);
239 void SetPaperName(const char *paper);
240 void SetPrintPreviewCommand(const char *cmd);
241 void SetPrinterOptions(const char *flags);
242 void SetPrinterFile(const char *f);
243 void SetPrinterOrientation(int orient);
244 void SetPrinterScaling(double x, double y);
245 void SetPrinterTranslation(long x, long y);
246 // 1 = Preview, 2 = print to file, 3 = send to printer
247 void SetPrinterMode(int mode);
248 void SetAFMPath(const char *f);
249 void SetColour(bool col);
250
251 // Get current values
252 char *GetPrinterCommand(void);
253 char *GetPrintPreviewCommand(void);
254 char *GetPrinterOptions(void);
255 char *GetPrinterFile(void);
256 char *GetPaperName(void);
257 int GetPrinterOrientation(void);
258 void GetPrinterScaling(double* x, double* y);
259 void GetPrinterTranslation(long *x, long *y);
260 int GetPrinterMode(void);
261 char *GetAFMPath(void);
262 bool GetColour(void);
263
264 void operator=(wxPrintSetupData& data);
265 };
266
267 extern wxPrintSetupData* WXDLLEXPORT wxThePrintSetupData;
268 extern void WXDLLEXPORT wxInitializePrintSetupData(bool init = TRUE);
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 {
277 DECLARE_DYNAMIC_CLASS(wxPrintPaperType)
278
279 public:
280 int widthMM;
281 int heightMM;
282 int widthPixels;
283 int heightPixels;
284 char *pageName;
285
286 wxPrintPaperType(const char *name = (const char *) NULL, int wmm = 0, int hmm = 0, int wp = 0, int hp = 0);
287 ~wxPrintPaperType(void);
288 };
289
290 class WXDLLEXPORT wxPrintPaperDatabase: public wxList
291 {
292 DECLARE_DYNAMIC_CLASS(wxPrintPaperDatabase)
293
294 public:
295 wxPrintPaperDatabase(void);
296 ~wxPrintPaperDatabase(void);
297
298 void CreateDatabase(void);
299 void ClearDatabase(void);
300
301 void AddPaperType(const char *name, int wmm, int hmm, int wp, int hp);
302 wxPrintPaperType *FindPaperType(const char *name);
303 };
304
305 WXDLLEXPORT_DATA(extern wxPrintPaperDatabase*) wxThePrintPaperDatabase;
306
307 #endif // wxUSE_POSTSCRIPT
308 #endif
309 // _WX_POSTSCRPH__