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"
21 #include "wx/module.h"
25 // A module to allow initialization/cleanup of PostScript-related
26 // things without calling these functions from app.cpp.
28 class WXDLLEXPORT wxPostScriptModule
: public wxModule
30 DECLARE_DYNAMIC_CLASS(wxPostScriptModule
)
32 wxPostScriptModule() {}
46 class WXDLLEXPORT wxPostScriptDC
: public wxDC
48 DECLARE_DYNAMIC_CLASS(wxPostScriptDC
)
51 // Create a printer DC
53 wxPostScriptDC(const wxString
& output
, bool interactive
= TRUE
, wxWindow
*parent
= (wxWindow
*) NULL
);
55 ~wxPostScriptDC(void);
57 bool Create(const wxString
& output
, bool interactive
= TRUE
, wxWindow
*parent
= (wxWindow
*) NULL
);
59 virtual bool PrinterDialog(wxWindow
*parent
= (wxWindow
*) NULL
);
61 inline virtual void BeginDrawing(void) {} ;
62 inline virtual void EndDrawing(void) {} ;
64 void FloodFill(long x1
, long y1
, wxColour
*col
, int style
=wxFLOOD_SURFACE
) ;
65 bool GetPixel(long x1
, long y1
, wxColour
*col
) const;
67 void DrawLine(long x1
, long y1
, long x2
, long y2
);
68 void CrossHair(long x
, long y
) ;
69 void DrawArc(long x1
,long y1
,long x2
,long y2
,long xc
,long yc
);
70 void DrawEllipticArc(long x
,long y
,long w
,long h
,double sa
,double ea
);
71 void DrawPoint(long x
, long y
);
72 // Avoid compiler warning
73 void DrawPoint(wxPoint
& point
) { wxDC::DrawPoint(point
); }
74 void DrawLines(int n
, wxPoint points
[], long xoffset
= 0, long yoffset
= 0);
75 // Avoid compiler warning
76 void DrawLines(wxList
*lines
, long xoffset
= 0, long yoffset
= 0)
77 { wxDC::DrawLines(lines
, xoffset
, yoffset
); }
78 void DrawPolygon(int n
, wxPoint points
[], long xoffset
= 0, long yoffset
= 0, int fillStyle
=wxODDEVEN_RULE
);
79 // Avoid compiler warning
80 void DrawPolygon(wxList
*lines
, long xoffset
= 0, long yoffset
= 0, int fillStyle
=wxODDEVEN_RULE
)
81 { wxDC::DrawPolygon(lines
, xoffset
, yoffset
, fillStyle
); }
82 void DrawRectangle(long x
, long y
, long width
, long height
);
83 void DrawRoundedRectangle(long x
, long y
, long width
, long height
, double radius
= 20);
84 void DrawEllipse(long x
, long y
, long width
, long height
);
86 void DrawSpline(wxList
*points
);
88 void DrawIcon(const wxIcon
& icon
, long x
, long y
);
90 void DrawIcon(const wxIcon
& icon
, long x
, long y
, bool WXUNUSED(usemask
) )
91 { DrawIcon( icon
, x
, y
); }
93 void DrawText(const wxString
& text
, long x
, long y
, bool use16
= FALSE
);
96 void SetFont(const wxFont
& font
);
97 void SetPen(const wxPen
& pen
);
98 void SetBrush(const wxBrush
& brush
);
99 void SetLogicalFunction(int function
);
100 void SetBackground(const wxBrush
& brush
);
101 void SetClippingRegion(long x
, long y
, long width
, long height
);
102 void DestroyClippingRegion(void);
104 bool StartDoc(const wxString
& message
);
106 void StartPage(void);
109 long GetCharHeight(void);
110 long GetCharWidth(void);
111 void GetTextExtent(const wxString
& string
, long *x
, long *y
,
112 long *descent
= (long *) NULL
,
113 long *externalLeading
= (long *) NULL
,
114 wxFont
*theFont
= (wxFont
*) NULL
, bool use16
= FALSE
);
115 virtual void SetLogicalOrigin(long x
, long y
);
116 virtual void CalcBoundingBox(long x
, long y
);
118 void SetMapMode(int mode
);
119 void SetUserScale(double x
, double y
);
120 long DeviceToLogicalX(int x
) const;
121 long DeviceToLogicalY(int y
) const;
122 long DeviceToLogicalXRel(int x
) const;
123 long DeviceToLogicalYRel(int y
) const;
124 long LogicalToDeviceX(long x
) const;
125 long LogicalToDeviceY(long y
) const;
126 long LogicalToDeviceXRel(long x
) const;
127 long LogicalToDeviceYRel(long y
) const;
128 bool Blit(long xdest
, long ydest
, long width
, long height
,
129 wxDC
*source
, long xsrc
, long ysrc
, int rop
= wxCOPY
, bool useMask
= FALSE
);
130 inline bool CanGetTextExtent(void) const { return FALSE
; }
131 inline bool CanDrawBitmap(void) const { return FALSE
; }
133 void GetSize(int* width
, int* height
) const;
134 void GetSizeMM(long *width
, long *height
) const;
136 inline void SetBackgroundMode(int WXUNUSED(mode
)) {};
137 inline void SetPalette(const wxPalette
& WXUNUSED(palette
)) {}
139 inline ofstream
*GetStream(void) const { return m_pstream
; }
140 inline int GetYOrigin(void) const { return m_yOrigin
; }
145 int m_yOrigin
; // For EPS
146 ofstream
* m_pstream
; // PostScript output stream
148 unsigned char m_currentRed
;
149 unsigned char m_currentGreen
;
150 unsigned char m_currentBlue
;
151 double m_scaleFactor
;
154 #define wxID_PRINTER_COMMAND 1
155 #define wxID_PRINTER_OPTIONS 2
156 #define wxID_PRINTER_ORIENTATION 3
157 #define wxID_PRINTER_MODES 4
158 #define wxID_PRINTER_X_SCALE 5
159 #define wxID_PRINTER_Y_SCALE 6
160 #define wxID_PRINTER_X_TRANS 7
161 #define wxID_PRINTER_Y_TRANS 8
163 class WXDLLEXPORT wxPostScriptPrintDialog
: public wxDialog
165 DECLARE_CLASS(wxPostScriptPrintDialog
)
167 wxPostScriptPrintDialog (wxWindow
*parent
, const wxString
& title
,
168 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
169 long style
= wxDEFAULT_DIALOG_STYLE
);
171 virtual int ShowModal(void) ;
175 // Print Orientation (Should also add Left, Right)
179 };// ps_orientation = PS_PORTRAIT;
186 };// ps_action = PS_PREVIEW;
188 // PostScript printer settings
189 void WXDLLEXPORT
wxSetPrinterCommand(const char *cmd
);
190 void WXDLLEXPORT
wxSetPrintPreviewCommand(const char *cmd
);
191 void WXDLLEXPORT
wxSetPrinterOptions(const char *flags
);
192 void WXDLLEXPORT
wxSetPrinterOrientation(int orientation
);
193 void WXDLLEXPORT
wxSetPrinterScaling(double x
, double y
);
194 void WXDLLEXPORT
wxSetPrinterTranslation(long x
, long y
);
195 void WXDLLEXPORT
wxSetPrinterMode(int mode
);
196 void WXDLLEXPORT
wxSetPrinterFile(const char *f
);
197 void WXDLLEXPORT
wxSetAFMPath(const char *f
);
199 // Get current values
200 char* WXDLLEXPORT
wxGetPrinterCommand(void);
201 char* WXDLLEXPORT
wxGetPrintPreviewCommand(void);
202 char* WXDLLEXPORT
wxGetPrinterOptions(void);
203 int WXDLLEXPORT
wxGetPrinterOrientation(void);
204 void WXDLLEXPORT
wxGetPrinterScaling(double* x
, double* y
);
205 void WXDLLEXPORT
wxGetPrinterTranslation(long *x
, long *y
);
206 int WXDLLEXPORT
wxGetPrinterMode(void);
207 char* WXDLLEXPORT
wxGetPrinterFile(void);
208 char* WXDLLEXPORT
wxGetAFMPath(void);
211 * PostScript print setup information
214 class WXDLLEXPORT wxPrintSetupData
: public wxObject
216 DECLARE_DYNAMIC_CLASS(wxPrintSetupData
)
219 char *printerCommand
;
220 char *previewCommand
;
224 double printerScaleX
;
225 double printerScaleY
;
226 long printerTranslateX
;
227 long printerTranslateY
;
228 // 1 = Preview, 2 = print to file, 3 = send to printer
231 // A name in the paper database (see wx_print.h: the printing framework)
235 wxPrintSetupData(void);
236 ~wxPrintSetupData(void);
238 void SetPrinterCommand(const char *cmd
);
239 void SetPaperName(const char *paper
);
240 void SetPrintPreviewCommand(const char *cmd
);
241 void SetPrinterOptions(const char *flags
);
242 void SetPrinterFile(const char *f
);
243 void SetPrinterOrientation(int orient
);
244 void SetPrinterScaling(double x
, double y
);
245 void SetPrinterTranslation(long x
, long y
);
246 // 1 = Preview, 2 = print to file, 3 = send to printer
247 void SetPrinterMode(int mode
);
248 void SetAFMPath(const char *f
);
249 void SetColour(bool col
);
251 // Get current values
252 char *GetPrinterCommand(void);
253 char *GetPrintPreviewCommand(void);
254 char *GetPrinterOptions(void);
255 char *GetPrinterFile(void);
256 char *GetPaperName(void);
257 int GetPrinterOrientation(void);
258 void GetPrinterScaling(double* x
, double* y
);
259 void GetPrinterTranslation(long *x
, long *y
);
260 int GetPrinterMode(void);
261 char *GetAFMPath(void);
262 bool GetColour(void);
264 void operator=(wxPrintSetupData
& data
);
267 extern wxPrintSetupData
* WXDLLEXPORT wxThePrintSetupData
;
268 extern void WXDLLEXPORT
wxInitializePrintSetupData(bool init
= TRUE
);
271 * Again, this only really needed for non-Windows platforms
272 * or if you want to test the PostScript printing under Windows.
275 class WXDLLEXPORT wxPrintPaperType
: public wxObject
277 DECLARE_DYNAMIC_CLASS(wxPrintPaperType
)
286 wxPrintPaperType(const char *name
= (const char *) NULL
, int wmm
= 0, int hmm
= 0, int wp
= 0, int hp
= 0);
287 ~wxPrintPaperType(void);
290 class WXDLLEXPORT wxPrintPaperDatabase
: public wxList
292 DECLARE_DYNAMIC_CLASS(wxPrintPaperDatabase
)
295 wxPrintPaperDatabase(void);
296 ~wxPrintPaperDatabase(void);
298 void CreateDatabase(void);
299 void ClearDatabase(void);
301 void AddPaperType(const char *name
, int wmm
, int hmm
, int wp
, int hp
);
302 wxPrintPaperType
*FindPaperType(const char *name
);
305 WXDLLEXPORT_DATA(extern wxPrintPaperDatabase
*) wxThePrintPaperDatabase
;
307 #endif // wxUSE_POSTSCRIPT