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