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