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