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