1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxPostScriptDC class
4 // Author: Julian Smart and others
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
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
);
79 void DrawText(const wxString
& text
, long x
, long y
, bool use16
= FALSE
);
82 void SetFont(const wxFont
& font
);
83 void SetPen(const wxPen
& pen
);
84 void SetBrush(const wxBrush
& brush
);
85 void SetLogicalFunction(int function
);
86 void SetBackground(const wxBrush
& brush
);
87 void SetClippingRegion(long x
, long y
, long width
, long height
);
88 void DestroyClippingRegion(void);
90 bool StartDoc(const wxString
& message
);
95 long GetCharHeight(void);
96 long GetCharWidth(void);
97 void GetTextExtent(const wxString
& string
, long *x
, long *y
,
98 long *descent
= NULL
, long *externalLeading
= NULL
,
99 wxFont
*theFont
= NULL
, bool use16
= FALSE
);
100 virtual void SetLogicalOrigin(long x
, long y
);
101 virtual void CalcBoundingBox(long x
, long y
);
103 void SetMapMode(int mode
);
104 void SetUserScale(double x
, double y
);
105 long DeviceToLogicalX(int x
) const;
106 long DeviceToLogicalY(int y
) const;
107 long DeviceToLogicalXRel(int x
) const;
108 long DeviceToLogicalYRel(int y
) const;
109 long LogicalToDeviceX(long x
) const;
110 long LogicalToDeviceY(long y
) const;
111 long LogicalToDeviceXRel(long x
) const;
112 long LogicalToDeviceYRel(long y
) const;
113 bool Blit(long xdest
, long ydest
, long width
, long height
,
114 wxDC
*source
, long xsrc
, long ysrc
, int rop
= wxCOPY
, bool useMask
= FALSE
);
115 inline bool CanGetTextExtent(void) const { return FALSE
; }
116 inline bool CanDrawBitmap(void) const { return FALSE
; }
118 void GetSize(int* width
, int* height
) const;
119 void GetSizeMM(long *width
, long *height
) const;
121 inline void SetBackgroundMode(int WXUNUSED(mode
)) {};
122 inline void SetPalette(const wxPalette
& WXUNUSED(palette
)) {}
124 inline ofstream
*GetStream(void) const { return m_pstream
; }
125 inline int GetYOrigin(void) const { return m_yOrigin
; }
130 int m_yOrigin
; // For EPS
131 ofstream
* m_pstream
; // PostScript output stream
133 unsigned char m_currentRed
;
134 unsigned char m_currentGreen
;
135 unsigned char m_currentBlue
;
136 double m_scaleFactor
;
139 #define wxID_PRINTER_COMMAND 1
140 #define wxID_PRINTER_OPTIONS 2
141 #define wxID_PRINTER_ORIENTATION 3
142 #define wxID_PRINTER_MODES 4
143 #define wxID_PRINTER_X_SCALE 5
144 #define wxID_PRINTER_Y_SCALE 6
145 #define wxID_PRINTER_X_TRANS 7
146 #define wxID_PRINTER_Y_TRANS 8
148 class WXDLLEXPORT wxPostScriptPrintDialog
: public wxDialog
150 DECLARE_CLASS(wxPostScriptPrintDialog
)
152 wxPostScriptPrintDialog (wxWindow
*parent
, const wxString
& title
,
153 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
154 long style
= wxDEFAULT_DIALOG_STYLE
);
156 virtual int ShowModal(void) ;
160 // Print Orientation (Should also add Left, Right)
164 };// ps_orientation = PS_PORTRAIT;
171 };// ps_action = PS_PREVIEW;
173 // PostScript printer settings
174 void WXDLLEXPORT
wxSetPrinterCommand(const char *cmd
);
175 void WXDLLEXPORT
wxSetPrintPreviewCommand(const char *cmd
);
176 void WXDLLEXPORT
wxSetPrinterOptions(const char *flags
);
177 void WXDLLEXPORT
wxSetPrinterOrientation(int orientation
);
178 void WXDLLEXPORT
wxSetPrinterScaling(double x
, double y
);
179 void WXDLLEXPORT
wxSetPrinterTranslation(long x
, long y
);
180 void WXDLLEXPORT
wxSetPrinterMode(int mode
);
181 void WXDLLEXPORT
wxSetPrinterFile(const char *f
);
182 void WXDLLEXPORT
wxSetAFMPath(const char *f
);
184 // Get current values
185 char* WXDLLEXPORT
wxGetPrinterCommand(void);
186 char* WXDLLEXPORT
wxGetPrintPreviewCommand(void);
187 char* WXDLLEXPORT
wxGetPrinterOptions(void);
188 int WXDLLEXPORT
wxGetPrinterOrientation(void);
189 void WXDLLEXPORT
wxGetPrinterScaling(double* x
, double* y
);
190 void WXDLLEXPORT
wxGetPrinterTranslation(long *x
, long *y
);
191 int WXDLLEXPORT
wxGetPrinterMode(void);
192 char* WXDLLEXPORT
wxGetPrinterFile(void);
193 char* WXDLLEXPORT
wxGetAFMPath(void);
196 * PostScript print setup information
199 class WXDLLEXPORT wxPrintSetupData
: public wxObject
201 DECLARE_DYNAMIC_CLASS(wxPrintSetupData
)
204 char *printerCommand
;
205 char *previewCommand
;
209 double printerScaleX
;
210 double printerScaleY
;
211 long printerTranslateX
;
212 long printerTranslateY
;
213 // 1 = Preview, 2 = print to file, 3 = send to printer
216 // A name in the paper database (see wx_print.h: the printing framework)
220 wxPrintSetupData(void);
221 ~wxPrintSetupData(void);
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
);
236 // Get current values
237 char *GetPrinterCommand(void);
238 char *GetPrintPreviewCommand(void);
239 char *GetPrinterOptions(void);
240 char *GetPrinterFile(void);
241 char *GetPaperName(void);
242 int GetPrinterOrientation(void);
243 void GetPrinterScaling(double* x
, double* y
);
244 void GetPrinterTranslation(long *x
, long *y
);
245 int GetPrinterMode(void);
246 char *GetAFMPath(void);
247 bool GetColour(void);
249 void operator=(wxPrintSetupData
& data
);
252 extern wxPrintSetupData
* WXDLLEXPORT wxThePrintSetupData
;
253 extern void WXDLLEXPORT
wxInitializePrintSetupData(bool init
= TRUE
);
256 * Again, this only really needed for non-Windows platforms
257 * or if you want to test the PostScript printing under Windows.
260 class WXDLLEXPORT wxPrintPaperType
: public wxObject
262 DECLARE_DYNAMIC_CLASS(wxPrintPaperType
)
271 wxPrintPaperType(const char *name
= NULL
, int wmm
= 0, int hmm
= 0, int wp
= 0, int hp
= 0);
272 ~wxPrintPaperType(void);
275 class WXDLLEXPORT wxPrintPaperDatabase
: public wxList
277 DECLARE_DYNAMIC_CLASS(wxPrintPaperDatabase
)
280 wxPrintPaperDatabase(void);
281 ~wxPrintPaperDatabase(void);
283 void CreateDatabase(void);
284 void ClearDatabase(void);
286 void AddPaperType(const char *name
, int wmm
, int hmm
, int wp
, int hp
);
287 wxPrintPaperType
*FindPaperType(const char *name
);
290 WXDLLEXPORT_DATA(extern wxPrintPaperDatabase
*) wxThePrintPaperDatabase
;
292 #endif // USE_POSTSCRIPT