]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/dcpsg.h
char handling fixed again
[wxWidgets.git] / include / wx / generic / dcpsg.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_DCPSG_H_
12 #define _WX_DCPSG_H_
13
14 #ifdef __GNUG__
15 #pragma interface
16 #endif
17
18 #include "wx/dc.h"
19
20 #if wxUSE_POSTSCRIPT
21
22 #include "wx/dialog.h"
23 #include "wx/module.h"
24 #include <fstream.h>
25
26
27 //-----------------------------------------------------------------------------
28 // classes
29 //-----------------------------------------------------------------------------
30
31 class wxPostScriptDC;
32
33 //-----------------------------------------------------------------------------
34 // wxPostScriptDC
35 //-----------------------------------------------------------------------------
36
37 class WXDLLEXPORT wxPostScriptDC: public wxDC
38 {
39 DECLARE_DYNAMIC_CLASS(wxPostScriptDC)
40
41 public:
42
43 wxPostScriptDC();
44 wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow *parent = (wxWindow *) NULL);
45
46 ~wxPostScriptDC();
47
48 bool Create(const wxString& output, bool interactive = TRUE, wxWindow *parent = (wxWindow *) NULL);
49
50 virtual bool Ok() const;
51
52 virtual bool PrinterDialog(wxWindow *parent = (wxWindow *) NULL);
53
54 virtual void BeginDrawing() {}
55 virtual void EndDrawing() {}
56
57 void FloodFill(long x1, long y1, const wxColour &col, int style=wxFLOOD_SURFACE) ;
58 bool GetPixel(long x1, long y1, wxColour *col) const;
59
60 void DrawLine(long x1, long y1, long x2, long y2);
61 void CrossHair(long x, long y) ;
62 void DrawArc(long x1,long y1,long x2,long y2,long xc,long yc);
63 void DrawEllipticArc(long x,long y,long w,long h,double sa,double ea);
64 void DrawPoint(long x, long y);
65 // Avoid compiler warning
66 void DrawPoint(wxPoint& point) { wxDC::DrawPoint(point); }
67 void DrawLines(int n, wxPoint points[], long xoffset = 0, long yoffset = 0);
68 // Avoid compiler warning
69 void DrawLines(wxList *lines, long xoffset = 0, long yoffset = 0)
70 { wxDC::DrawLines(lines, xoffset, yoffset); }
71 void DrawPolygon(int n, wxPoint points[], long xoffset = 0, long yoffset = 0, int fillStyle=wxODDEVEN_RULE);
72 // Avoid compiler warning
73 void DrawPolygon(wxList *lines, long xoffset = 0, long yoffset = 0, int fillStyle=wxODDEVEN_RULE)
74 { wxDC::DrawPolygon(lines, xoffset, yoffset, fillStyle); }
75 void DrawRectangle(long x, long y, long width, long height);
76 void DrawRoundedRectangle(long x, long y, long width, long height, double radius = 20);
77 void DrawEllipse(long x, long y, long width, long height);
78
79 void DrawSpline(wxList *points);
80
81 bool Blit(long xdest, long ydest, long width, long height,
82 wxDC *source, long xsrc, long ysrc, int rop = wxCOPY, bool useMask = FALSE);
83 inline bool CanDrawBitmap(void) const { return TRUE; }
84
85 void DrawIcon( const wxIcon& icon, long x, long y );
86 void DrawBitmap( const wxBitmap& bitmap, long x, long y, bool useMask=FALSE );
87
88 void DrawText(const wxString& text, long x, long y, bool use16 = FALSE);
89
90 void Clear();
91 void SetFont( const wxFont& font );
92 void SetPen( const wxPen& pen );
93 void SetBrush( const wxBrush& brush );
94 void SetLogicalFunction( int function );
95 void SetBackground( const wxBrush& brush );
96
97 void SetClippingRegion(long x, long y, long width, long height);
98 void SetClippingRegion( const wxRegion &region );
99 void DestroyClippingRegion();
100
101 bool StartDoc(const wxString& message);
102 void EndDoc();
103 void StartPage();
104 void EndPage();
105
106 long GetCharHeight();
107 long GetCharWidth();
108 inline bool CanGetTextExtent(void) const { return FALSE; }
109 void GetTextExtent(const wxString& string, long *x, long *y,
110 long *descent = (long *) NULL,
111 long *externalLeading = (long *) NULL,
112 wxFont *theFont = (wxFont *) NULL, bool use16 = FALSE);
113
114 void GetSize(int* width, int* height) const;
115 void GetSizeMM(long *width, long *height) const;
116
117 void SetAxisOrientation( bool xLeftRight, bool yBottomUp );
118 void SetDeviceOrigin( long x, long y );
119
120 inline void SetBackgroundMode(int WXUNUSED(mode)) {}
121 inline void SetPalette(const wxPalette& WXUNUSED(palette)) {}
122
123 inline ofstream *GetStream(void) const { return m_pstream; }
124
125 protected:
126
127 ofstream * m_pstream; // PostScript output stream
128 wxString m_title;
129 unsigned char m_currentRed;
130 unsigned char m_currentGreen;
131 unsigned char m_currentBlue;
132 int m_pageNumber;
133 bool m_clipping;
134 double m_underlinePosition;
135 double m_underlineThickness;
136 };
137
138 // TODO Needed? Should perhaps use wxGenericPrintDialog instead.
139 #if 1
140 #define wxID_PRINTER_COMMAND 1
141 #define wxID_PRINTER_OPTIONS 2
142 #define wxID_PRINTER_ORIENTATION 3
143 #define wxID_PRINTER_MODES 4
144 #define wxID_PRINTER_X_SCALE 5
145 #define wxID_PRINTER_Y_SCALE 6
146 #define wxID_PRINTER_X_TRANS 7
147 #define wxID_PRINTER_Y_TRANS 8
148
149 class WXDLLEXPORT wxPostScriptPrintDialog: public wxDialog
150 {
151 DECLARE_CLASS(wxPostScriptPrintDialog)
152 public:
153 wxPostScriptPrintDialog (wxWindow *parent, const wxString& title,
154 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
155 long style = wxDEFAULT_DIALOG_STYLE);
156
157 virtual int ShowModal(void) ;
158 };
159 #endif
160
161 // Print Orientation (Should also add Left, Right)
162 enum {
163 PS_PORTRAIT = 1,
164 PS_LANDSCAPE = 2
165 };// ps_orientation = PS_PORTRAIT;
166
167 // Print Actions
168 enum {
169 PS_PRINTER,
170 PS_FILE,
171 PS_PREVIEW
172 };// ps_action = PS_PREVIEW;
173
174 // PostScript printer settings
175 WXDLLEXPORT void wxSetPrinterCommand(const char *cmd);
176 WXDLLEXPORT void wxSetPrintPreviewCommand(const char *cmd);
177 WXDLLEXPORT void wxSetPrinterOptions(const char *flags);
178 WXDLLEXPORT void wxSetPrinterOrientation(int orientation);
179 WXDLLEXPORT void wxSetPrinterScaling(double x, double y);
180 WXDLLEXPORT void wxSetPrinterTranslation(long x, long y);
181 WXDLLEXPORT void wxSetPrinterMode(int mode);
182 WXDLLEXPORT void wxSetPrinterFile(const char *f);
183 WXDLLEXPORT void wxSetAFMPath(const char *f);
184
185 // Get current values
186 WXDLLEXPORT char* wxGetPrinterCommand();
187 WXDLLEXPORT char* wxGetPrintPreviewCommand();
188 WXDLLEXPORT char* wxGetPrinterOptions();
189 WXDLLEXPORT int wxGetPrinterOrientation();
190 WXDLLEXPORT void wxGetPrinterScaling(double* x, double* y);
191 WXDLLEXPORT void wxGetPrinterTranslation(long *x, long *y);
192 WXDLLEXPORT int wxGetPrinterMode();
193 WXDLLEXPORT char* wxGetPrinterFile();
194 WXDLLEXPORT char* wxGetAFMPath();
195
196 /*
197 * PostScript print setup information
198 */
199
200 class WXDLLEXPORT wxPrintSetupData: public wxObject
201 {
202 public:
203 char *printerCommand;
204 char *previewCommand;
205 char *printerFlags;
206 char *printerFile;
207 int printerOrient;
208 double printerScaleX;
209 double printerScaleY;
210 long printerTranslateX;
211 long printerTranslateY;
212 // 1 = Preview, 2 = print to file, 3 = send to printer
213 int printerMode;
214 char *afmPath;
215 // A name in the paper database (see wx_print.h: the printing framework)
216 char *paperName;
217 bool printColour;
218
219 public:
220 wxPrintSetupData();
221 ~wxPrintSetupData();
222
223 void SetPrinterCommand(const char *cmd);
224 void SetPaperName(const char *paper);
225 void SetPrintPreviewCommand(const char *cmd);
226 void SetPrinterOptions(const char *flags);
227 void SetPrinterFile(const 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(const char *f);
234 void SetColour(bool col);
235
236 // Get current values
237 char *GetPrinterCommand();
238 char *GetPrintPreviewCommand();
239 char *GetPrinterOptions();
240 char *GetPrinterFile();
241 char *GetPaperName();
242 int GetPrinterOrientation();
243 void GetPrinterScaling(double* x, double* y);
244 void GetPrinterTranslation(long *x, long *y);
245 int GetPrinterMode();
246 char *GetAFMPath();
247 bool GetColour();
248
249 void operator=(wxPrintSetupData& data);
250
251 private:
252 DECLARE_DYNAMIC_CLASS(wxPrintSetupData)
253 };
254
255 WXDLLEXPORT_DATA(extern wxPrintSetupData*) wxThePrintSetupData;
256 WXDLLEXPORT extern void wxInitializePrintSetupData(bool init = TRUE);
257
258 #endif
259 // wxUSE_POSTSCRIPT
260
261 #endif
262 // _WX_DCPSG_H_