1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxPostScriptDC class
4 // Author: Julian Smart and others
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_POSTSCRPH__
13 #define _WX_POSTSCRPH__
16 #pragma interface "postscrp.h"
20 #include "wx/dialog.h"
24 class WXDLLIMPORT ofstream
;
25 class WXDLLEXPORT wxPostScriptDC
: public wxDC
27 DECLARE_DYNAMIC_CLASS(wxPostScriptDC
)
30 // Create a printer DC
32 wxPostScriptDC(const wxString
& output
, bool interactive
= TRUE
, wxWindow
*parent
= NULL
);
34 ~wxPostScriptDC(void);
36 bool Create(const wxString
& output
, bool interactive
= TRUE
, wxWindow
*parent
= NULL
);
38 virtual bool PrinterDialog(wxWindow
*parent
= NULL
);
40 inline virtual void BeginDrawing(void) {} ;
41 inline virtual void EndDrawing(void) {} ;
43 void FloodFill(long x1
, long y1
, wxColour
*col
, int style
=wxFLOOD_SURFACE
) ;
44 bool GetPixel(long x1
, long y1
, wxColour
*col
) const;
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
);
65 // RR: I define these in wxDC, after all they all do the same everywhere
70 void DrawSpline(long x1
, long y1
, long x2
, long y2
, long x3
, long y3
);
71 // Any number of control points - a list of pointers to wxPoints
72 void DrawSpline(wxList
*points
);
73 void DrawSpline(int n
, wxPoint points
[]);
76 void DrawOpenSpline(wxList
*points
);
78 void DrawIcon(const wxIcon
& icon
, long x
, long y
);
80 void DrawIcon(const wxIcon
& icon
, long x
, long y
, bool WXUNUSED(usemask
) )
81 { DrawIcon( icon
, x
, y
); }
83 void DrawText(const wxString
& text
, long x
, long y
, bool use16
= FALSE
);
86 void SetFont(const wxFont
& font
);
87 void SetPen(const wxPen
& pen
);
88 void SetBrush(const wxBrush
& brush
);
89 void SetLogicalFunction(int function
);
90 void SetBackground(const wxBrush
& brush
);
91 void SetClippingRegion(long x
, long y
, long width
, long height
);
92 void DestroyClippingRegion(void);
94 bool StartDoc(const wxString
& message
);
99 long GetCharHeight(void);
100 long GetCharWidth(void);
101 void GetTextExtent(const wxString
& string
, long *x
, long *y
,
102 long *descent
= NULL
, long *externalLeading
= NULL
,
103 wxFont
*theFont
= NULL
, bool use16
= FALSE
);
104 virtual void SetLogicalOrigin(long x
, long y
);
105 virtual void CalcBoundingBox(long x
, long y
);
107 void SetMapMode(int mode
);
108 void SetUserScale(double x
, double y
);
109 long DeviceToLogicalX(int x
) const;
110 long DeviceToLogicalY(int y
) const;
111 long DeviceToLogicalXRel(int x
) const;
112 long DeviceToLogicalYRel(int y
) const;
113 long LogicalToDeviceX(long x
) const;
114 long LogicalToDeviceY(long y
) const;
115 long LogicalToDeviceXRel(long x
) const;
116 long LogicalToDeviceYRel(long y
) const;
117 bool Blit(long xdest
, long ydest
, long width
, long height
,
118 wxDC
*source
, long xsrc
, long ysrc
, int rop
= wxCOPY
, bool useMask
= FALSE
);
119 inline bool CanGetTextExtent(void) const { return FALSE
; }
120 inline bool CanDrawBitmap(void) const { return FALSE
; }
122 void GetSize(int* width
, int* height
) const;
123 void GetSizeMM(long *width
, long *height
) const;
125 inline void SetBackgroundMode(int WXUNUSED(mode
)) {};
126 inline void SetPalette(const wxPalette
& WXUNUSED(palette
)) {}
128 inline ofstream
*GetStream(void) const { return m_pstream
; }
129 inline int GetYOrigin(void) const { return m_yOrigin
; }
134 int m_yOrigin
; // For EPS
135 ofstream
* m_pstream
; // PostScript output stream
137 unsigned char m_currentRed
;
138 unsigned char m_currentGreen
;
139 unsigned char m_currentBlue
;
140 double m_scaleFactor
;
143 #define wxID_PRINTER_COMMAND 1
144 #define wxID_PRINTER_OPTIONS 2
145 #define wxID_PRINTER_ORIENTATION 3
146 #define wxID_PRINTER_MODES 4
147 #define wxID_PRINTER_X_SCALE 5
148 #define wxID_PRINTER_Y_SCALE 6
149 #define wxID_PRINTER_X_TRANS 7
150 #define wxID_PRINTER_Y_TRANS 8
152 class WXDLLEXPORT wxPostScriptPrintDialog
: public wxDialog
154 DECLARE_CLASS(wxPostScriptPrintDialog
)
156 wxPostScriptPrintDialog (wxWindow
*parent
, const wxString
& title
,
157 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
158 long style
= wxDEFAULT_DIALOG_STYLE
);
160 virtual int ShowModal(void) ;
164 // Print Orientation (Should also add Left, Right)
168 };// ps_orientation = PS_PORTRAIT;
175 };// ps_action = PS_PREVIEW;
177 // PostScript printer settings
178 void WXDLLEXPORT
wxSetPrinterCommand(const char *cmd
);
179 void WXDLLEXPORT
wxSetPrintPreviewCommand(const char *cmd
);
180 void WXDLLEXPORT
wxSetPrinterOptions(const char *flags
);
181 void WXDLLEXPORT
wxSetPrinterOrientation(int orientation
);
182 void WXDLLEXPORT
wxSetPrinterScaling(double x
, double y
);
183 void WXDLLEXPORT
wxSetPrinterTranslation(long x
, long y
);
184 void WXDLLEXPORT
wxSetPrinterMode(int mode
);
185 void WXDLLEXPORT
wxSetPrinterFile(const char *f
);
186 void WXDLLEXPORT
wxSetAFMPath(const char *f
);
188 // Get current values
189 char* WXDLLEXPORT
wxGetPrinterCommand(void);
190 char* WXDLLEXPORT
wxGetPrintPreviewCommand(void);
191 char* WXDLLEXPORT
wxGetPrinterOptions(void);
192 int WXDLLEXPORT
wxGetPrinterOrientation(void);
193 void WXDLLEXPORT
wxGetPrinterScaling(double* x
, double* y
);
194 void WXDLLEXPORT
wxGetPrinterTranslation(long *x
, long *y
);
195 int WXDLLEXPORT
wxGetPrinterMode(void);
196 char* WXDLLEXPORT
wxGetPrinterFile(void);
197 char* WXDLLEXPORT
wxGetAFMPath(void);
200 * PostScript print setup information
203 class WXDLLEXPORT wxPrintSetupData
: public wxObject
205 DECLARE_DYNAMIC_CLASS(wxPrintSetupData
)
208 char *printerCommand
;
209 char *previewCommand
;
213 double printerScaleX
;
214 double printerScaleY
;
215 long printerTranslateX
;
216 long printerTranslateY
;
217 // 1 = Preview, 2 = print to file, 3 = send to printer
220 // A name in the paper database (see wx_print.h: the printing framework)
224 wxPrintSetupData(void);
225 ~wxPrintSetupData(void);
227 void SetPrinterCommand(const char *cmd
);
228 void SetPaperName(const char *paper
);
229 void SetPrintPreviewCommand(const char *cmd
);
230 void SetPrinterOptions(const char *flags
);
231 void SetPrinterFile(const char *f
);
232 void SetPrinterOrientation(int orient
);
233 void SetPrinterScaling(double x
, double y
);
234 void SetPrinterTranslation(long x
, long y
);
235 // 1 = Preview, 2 = print to file, 3 = send to printer
236 void SetPrinterMode(int mode
);
237 void SetAFMPath(const char *f
);
238 void SetColour(bool col
);
240 // Get current values
241 char *GetPrinterCommand(void);
242 char *GetPrintPreviewCommand(void);
243 char *GetPrinterOptions(void);
244 char *GetPrinterFile(void);
245 char *GetPaperName(void);
246 int GetPrinterOrientation(void);
247 void GetPrinterScaling(double* x
, double* y
);
248 void GetPrinterTranslation(long *x
, long *y
);
249 int GetPrinterMode(void);
250 char *GetAFMPath(void);
251 bool GetColour(void);
253 void operator=(wxPrintSetupData
& data
);
256 extern wxPrintSetupData
* WXDLLEXPORT wxThePrintSetupData
;
257 extern void WXDLLEXPORT
wxInitializePrintSetupData(bool init
= TRUE
);
260 * Again, this only really needed for non-Windows platforms
261 * or if you want to test the PostScript printing under Windows.
264 class WXDLLEXPORT wxPrintPaperType
: public wxObject
266 DECLARE_DYNAMIC_CLASS(wxPrintPaperType
)
275 wxPrintPaperType(const char *name
= NULL
, int wmm
= 0, int hmm
= 0, int wp
= 0, int hp
= 0);
276 ~wxPrintPaperType(void);
279 class WXDLLEXPORT wxPrintPaperDatabase
: public wxList
281 DECLARE_DYNAMIC_CLASS(wxPrintPaperDatabase
)
284 wxPrintPaperDatabase(void);
285 ~wxPrintPaperDatabase(void);
287 void CreateDatabase(void);
288 void ClearDatabase(void);
290 void AddPaperType(const char *name
, int wmm
, int hmm
, int wp
, int hp
);
291 wxPrintPaperType
*FindPaperType(const char *name
);
294 WXDLLEXPORT_DATA(extern wxPrintPaperDatabase
*) wxThePrintPaperDatabase
;
296 #endif // USE_POSTSCRIPT