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
= (wxWindow
*) NULL
);
34 ~wxPostScriptDC(void);
36 bool Create(const wxString
& output
, bool interactive
= TRUE
, wxWindow
*parent
= (wxWindow
*) NULL
);
38 virtual bool PrinterDialog(wxWindow
*parent
= (wxWindow
*) 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
= (long *) NULL
,
103 long *externalLeading
= (long *) NULL
,
104 wxFont
*theFont
= (wxFont
*) NULL
, bool use16
= FALSE
);
105 virtual void SetLogicalOrigin(long x
, long y
);
106 virtual void CalcBoundingBox(long x
, long y
);
108 void SetMapMode(int mode
);
109 void SetUserScale(double x
, double y
);
110 long DeviceToLogicalX(int x
) const;
111 long DeviceToLogicalY(int y
) const;
112 long DeviceToLogicalXRel(int x
) const;
113 long DeviceToLogicalYRel(int y
) const;
114 long LogicalToDeviceX(long x
) const;
115 long LogicalToDeviceY(long y
) const;
116 long LogicalToDeviceXRel(long x
) const;
117 long LogicalToDeviceYRel(long y
) const;
118 bool Blit(long xdest
, long ydest
, long width
, long height
,
119 wxDC
*source
, long xsrc
, long ysrc
, int rop
= wxCOPY
, bool useMask
= FALSE
);
120 inline bool CanGetTextExtent(void) const { return FALSE
; }
121 inline bool CanDrawBitmap(void) const { return FALSE
; }
123 void GetSize(int* width
, int* height
) const;
124 void GetSizeMM(long *width
, long *height
) const;
126 inline void SetBackgroundMode(int WXUNUSED(mode
)) {};
127 inline void SetPalette(const wxPalette
& WXUNUSED(palette
)) {}
129 inline ofstream
*GetStream(void) const { return m_pstream
; }
130 inline int GetYOrigin(void) const { return m_yOrigin
; }
135 int m_yOrigin
; // For EPS
136 ofstream
* m_pstream
; // PostScript output stream
138 unsigned char m_currentRed
;
139 unsigned char m_currentGreen
;
140 unsigned char m_currentBlue
;
141 double m_scaleFactor
;
144 #define wxID_PRINTER_COMMAND 1
145 #define wxID_PRINTER_OPTIONS 2
146 #define wxID_PRINTER_ORIENTATION 3
147 #define wxID_PRINTER_MODES 4
148 #define wxID_PRINTER_X_SCALE 5
149 #define wxID_PRINTER_Y_SCALE 6
150 #define wxID_PRINTER_X_TRANS 7
151 #define wxID_PRINTER_Y_TRANS 8
153 class WXDLLEXPORT wxPostScriptPrintDialog
: public wxDialog
155 DECLARE_CLASS(wxPostScriptPrintDialog
)
157 wxPostScriptPrintDialog (wxWindow
*parent
, const wxString
& title
,
158 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
159 long style
= wxDEFAULT_DIALOG_STYLE
);
161 virtual int ShowModal(void) ;
165 // Print Orientation (Should also add Left, Right)
169 };// ps_orientation = PS_PORTRAIT;
176 };// ps_action = PS_PREVIEW;
178 // PostScript printer settings
179 void WXDLLEXPORT
wxSetPrinterCommand(const char *cmd
);
180 void WXDLLEXPORT
wxSetPrintPreviewCommand(const char *cmd
);
181 void WXDLLEXPORT
wxSetPrinterOptions(const char *flags
);
182 void WXDLLEXPORT
wxSetPrinterOrientation(int orientation
);
183 void WXDLLEXPORT
wxSetPrinterScaling(double x
, double y
);
184 void WXDLLEXPORT
wxSetPrinterTranslation(long x
, long y
);
185 void WXDLLEXPORT
wxSetPrinterMode(int mode
);
186 void WXDLLEXPORT
wxSetPrinterFile(const char *f
);
187 void WXDLLEXPORT
wxSetAFMPath(const char *f
);
189 // Get current values
190 char* WXDLLEXPORT
wxGetPrinterCommand(void);
191 char* WXDLLEXPORT
wxGetPrintPreviewCommand(void);
192 char* WXDLLEXPORT
wxGetPrinterOptions(void);
193 int WXDLLEXPORT
wxGetPrinterOrientation(void);
194 void WXDLLEXPORT
wxGetPrinterScaling(double* x
, double* y
);
195 void WXDLLEXPORT
wxGetPrinterTranslation(long *x
, long *y
);
196 int WXDLLEXPORT
wxGetPrinterMode(void);
197 char* WXDLLEXPORT
wxGetPrinterFile(void);
198 char* WXDLLEXPORT
wxGetAFMPath(void);
201 * PostScript print setup information
204 class WXDLLEXPORT wxPrintSetupData
: public wxObject
206 DECLARE_DYNAMIC_CLASS(wxPrintSetupData
)
209 char *printerCommand
;
210 char *previewCommand
;
214 double printerScaleX
;
215 double printerScaleY
;
216 long printerTranslateX
;
217 long printerTranslateY
;
218 // 1 = Preview, 2 = print to file, 3 = send to printer
221 // A name in the paper database (see wx_print.h: the printing framework)
225 wxPrintSetupData(void);
226 ~wxPrintSetupData(void);
228 void SetPrinterCommand(const char *cmd
);
229 void SetPaperName(const char *paper
);
230 void SetPrintPreviewCommand(const char *cmd
);
231 void SetPrinterOptions(const char *flags
);
232 void SetPrinterFile(const char *f
);
233 void SetPrinterOrientation(int orient
);
234 void SetPrinterScaling(double x
, double y
);
235 void SetPrinterTranslation(long x
, long y
);
236 // 1 = Preview, 2 = print to file, 3 = send to printer
237 void SetPrinterMode(int mode
);
238 void SetAFMPath(const char *f
);
239 void SetColour(bool col
);
241 // Get current values
242 char *GetPrinterCommand(void);
243 char *GetPrintPreviewCommand(void);
244 char *GetPrinterOptions(void);
245 char *GetPrinterFile(void);
246 char *GetPaperName(void);
247 int GetPrinterOrientation(void);
248 void GetPrinterScaling(double* x
, double* y
);
249 void GetPrinterTranslation(long *x
, long *y
);
250 int GetPrinterMode(void);
251 char *GetAFMPath(void);
252 bool GetColour(void);
254 void operator=(wxPrintSetupData
& data
);
257 extern wxPrintSetupData
* WXDLLEXPORT wxThePrintSetupData
;
258 extern void WXDLLEXPORT
wxInitializePrintSetupData(bool init
= TRUE
);
261 * Again, this only really needed for non-Windows platforms
262 * or if you want to test the PostScript printing under Windows.
265 class WXDLLEXPORT wxPrintPaperType
: public wxObject
267 DECLARE_DYNAMIC_CLASS(wxPrintPaperType
)
276 wxPrintPaperType(const char *name
= (const char *) NULL
, int wmm
= 0, int hmm
= 0, int wp
= 0, int hp
= 0);
277 ~wxPrintPaperType(void);
280 class WXDLLEXPORT wxPrintPaperDatabase
: public wxList
282 DECLARE_DYNAMIC_CLASS(wxPrintPaperDatabase
)
285 wxPrintPaperDatabase(void);
286 ~wxPrintPaperDatabase(void);
288 void CreateDatabase(void);
289 void ClearDatabase(void);
291 void AddPaperType(const char *name
, int wmm
, int hmm
, int wp
, int hp
);
292 wxPrintPaperType
*FindPaperType(const char *name
);
295 WXDLLEXPORT_DATA(extern wxPrintPaperDatabase
*) wxThePrintPaperDatabase
;
297 #endif // USE_POSTSCRIPT