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() {}
37 class WXDLLIMPORT ofstream
;
38 class WXDLLEXPORT wxPostScriptDC
: public wxDC
40 DECLARE_DYNAMIC_CLASS(wxPostScriptDC
)
43 // Create a printer DC
45 wxPostScriptDC(const wxString
& output
, bool interactive
= TRUE
, wxWindow
*parent
= (wxWindow
*) NULL
);
47 ~wxPostScriptDC(void);
49 bool Create(const wxString
& output
, bool interactive
= TRUE
, wxWindow
*parent
= (wxWindow
*) NULL
);
51 virtual bool PrinterDialog(wxWindow
*parent
= (wxWindow
*) NULL
);
53 inline virtual void BeginDrawing(void) {} ;
54 inline virtual void EndDrawing(void) {} ;
56 void FloodFill(long x1
, long y1
, wxColour
*col
, int style
=wxFLOOD_SURFACE
) ;
57 bool GetPixel(long x1
, long y1
, wxColour
*col
) const;
59 void DrawLine(long x1
, long y1
, long x2
, long y2
);
60 void CrossHair(long x
, long y
) ;
61 void DrawArc(long x1
,long y1
,long x2
,long y2
,long xc
,long yc
);
62 void DrawEllipticArc(long x
,long y
,long w
,long h
,double sa
,double ea
);
63 void DrawPoint(long x
, long y
);
64 // Avoid compiler warning
65 void DrawPoint(wxPoint
& point
) { wxDC::DrawPoint(point
); }
66 void DrawLines(int n
, wxPoint points
[], long xoffset
= 0, long yoffset
= 0);
67 // Avoid compiler warning
68 void DrawLines(wxList
*lines
, long xoffset
= 0, long yoffset
= 0)
69 { wxDC::DrawLines(lines
, xoffset
, yoffset
); }
70 void DrawPolygon(int n
, wxPoint points
[], long xoffset
= 0, long yoffset
= 0, int fillStyle
=wxODDEVEN_RULE
);
71 // Avoid compiler warning
72 void DrawPolygon(wxList
*lines
, long xoffset
= 0, long yoffset
= 0, int fillStyle
=wxODDEVEN_RULE
)
73 { wxDC::DrawPolygon(lines
, xoffset
, yoffset
, fillStyle
); }
74 void DrawRectangle(long x
, long y
, long width
, long height
);
75 void DrawRoundedRectangle(long x
, long y
, long width
, long height
, double radius
= 20);
76 void DrawEllipse(long x
, long y
, long width
, long height
);
78 void DrawSpline(wxList
*points
);
80 void DrawIcon(const wxIcon
& icon
, long x
, long y
);
82 void DrawIcon(const wxIcon
& icon
, long x
, long y
, bool WXUNUSED(usemask
) )
83 { DrawIcon( icon
, x
, y
); }
85 void DrawText(const wxString
& text
, long x
, long y
, bool use16
= FALSE
);
88 void SetFont(const wxFont
& font
);
89 void SetPen(const wxPen
& pen
);
90 void SetBrush(const wxBrush
& brush
);
91 void SetLogicalFunction(int function
);
92 void SetBackground(const wxBrush
& brush
);
93 void SetClippingRegion(long x
, long y
, long width
, long height
);
94 void DestroyClippingRegion(void);
96 bool StartDoc(const wxString
& message
);
101 long GetCharHeight(void);
102 long GetCharWidth(void);
103 void GetTextExtent(const wxString
& string
, long *x
, long *y
,
104 long *descent
= (long *) NULL
,
105 long *externalLeading
= (long *) NULL
,
106 wxFont
*theFont
= (wxFont
*) NULL
, bool use16
= FALSE
);
107 virtual void SetLogicalOrigin(long x
, long y
);
108 virtual void CalcBoundingBox(long x
, long y
);
110 void SetMapMode(int mode
);
111 void SetUserScale(double x
, double y
);
112 long DeviceToLogicalX(int x
) const;
113 long DeviceToLogicalY(int y
) const;
114 long DeviceToLogicalXRel(int x
) const;
115 long DeviceToLogicalYRel(int y
) const;
116 long LogicalToDeviceX(long x
) const;
117 long LogicalToDeviceY(long y
) const;
118 long LogicalToDeviceXRel(long x
) const;
119 long LogicalToDeviceYRel(long y
) const;
120 bool Blit(long xdest
, long ydest
, long width
, long height
,
121 wxDC
*source
, long xsrc
, long ysrc
, int rop
= wxCOPY
, bool useMask
= FALSE
);
122 inline bool CanGetTextExtent(void) const { return FALSE
; }
123 inline bool CanDrawBitmap(void) const { return FALSE
; }
125 void GetSize(int* width
, int* height
) const;
126 void GetSizeMM(long *width
, long *height
) const;
128 inline void SetBackgroundMode(int WXUNUSED(mode
)) {};
129 inline void SetPalette(const wxPalette
& WXUNUSED(palette
)) {}
131 inline ofstream
*GetStream(void) const { return m_pstream
; }
132 inline int GetYOrigin(void) const { return m_yOrigin
; }
137 int m_yOrigin
; // For EPS
138 ofstream
* m_pstream
; // PostScript output stream
140 unsigned char m_currentRed
;
141 unsigned char m_currentGreen
;
142 unsigned char m_currentBlue
;
143 double m_scaleFactor
;
146 #define wxID_PRINTER_COMMAND 1
147 #define wxID_PRINTER_OPTIONS 2
148 #define wxID_PRINTER_ORIENTATION 3
149 #define wxID_PRINTER_MODES 4
150 #define wxID_PRINTER_X_SCALE 5
151 #define wxID_PRINTER_Y_SCALE 6
152 #define wxID_PRINTER_X_TRANS 7
153 #define wxID_PRINTER_Y_TRANS 8
155 class WXDLLEXPORT wxPostScriptPrintDialog
: public wxDialog
157 DECLARE_CLASS(wxPostScriptPrintDialog
)
159 wxPostScriptPrintDialog (wxWindow
*parent
, const wxString
& title
,
160 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
161 long style
= wxDEFAULT_DIALOG_STYLE
);
163 virtual int ShowModal(void) ;
167 // Print Orientation (Should also add Left, Right)
171 };// ps_orientation = PS_PORTRAIT;
178 };// ps_action = PS_PREVIEW;
180 // PostScript printer settings
181 void WXDLLEXPORT
wxSetPrinterCommand(const char *cmd
);
182 void WXDLLEXPORT
wxSetPrintPreviewCommand(const char *cmd
);
183 void WXDLLEXPORT
wxSetPrinterOptions(const char *flags
);
184 void WXDLLEXPORT
wxSetPrinterOrientation(int orientation
);
185 void WXDLLEXPORT
wxSetPrinterScaling(double x
, double y
);
186 void WXDLLEXPORT
wxSetPrinterTranslation(long x
, long y
);
187 void WXDLLEXPORT
wxSetPrinterMode(int mode
);
188 void WXDLLEXPORT
wxSetPrinterFile(const char *f
);
189 void WXDLLEXPORT
wxSetAFMPath(const char *f
);
191 // Get current values
192 char* WXDLLEXPORT
wxGetPrinterCommand(void);
193 char* WXDLLEXPORT
wxGetPrintPreviewCommand(void);
194 char* WXDLLEXPORT
wxGetPrinterOptions(void);
195 int WXDLLEXPORT
wxGetPrinterOrientation(void);
196 void WXDLLEXPORT
wxGetPrinterScaling(double* x
, double* y
);
197 void WXDLLEXPORT
wxGetPrinterTranslation(long *x
, long *y
);
198 int WXDLLEXPORT
wxGetPrinterMode(void);
199 char* WXDLLEXPORT
wxGetPrinterFile(void);
200 char* WXDLLEXPORT
wxGetAFMPath(void);
203 * PostScript print setup information
206 class WXDLLEXPORT wxPrintSetupData
: public wxObject
208 DECLARE_DYNAMIC_CLASS(wxPrintSetupData
)
211 char *printerCommand
;
212 char *previewCommand
;
216 double printerScaleX
;
217 double printerScaleY
;
218 long printerTranslateX
;
219 long printerTranslateY
;
220 // 1 = Preview, 2 = print to file, 3 = send to printer
223 // A name in the paper database (see wx_print.h: the printing framework)
227 wxPrintSetupData(void);
228 ~wxPrintSetupData(void);
230 void SetPrinterCommand(const char *cmd
);
231 void SetPaperName(const char *paper
);
232 void SetPrintPreviewCommand(const char *cmd
);
233 void SetPrinterOptions(const char *flags
);
234 void SetPrinterFile(const char *f
);
235 void SetPrinterOrientation(int orient
);
236 void SetPrinterScaling(double x
, double y
);
237 void SetPrinterTranslation(long x
, long y
);
238 // 1 = Preview, 2 = print to file, 3 = send to printer
239 void SetPrinterMode(int mode
);
240 void SetAFMPath(const char *f
);
241 void SetColour(bool col
);
243 // Get current values
244 char *GetPrinterCommand(void);
245 char *GetPrintPreviewCommand(void);
246 char *GetPrinterOptions(void);
247 char *GetPrinterFile(void);
248 char *GetPaperName(void);
249 int GetPrinterOrientation(void);
250 void GetPrinterScaling(double* x
, double* y
);
251 void GetPrinterTranslation(long *x
, long *y
);
252 int GetPrinterMode(void);
253 char *GetAFMPath(void);
254 bool GetColour(void);
256 void operator=(wxPrintSetupData
& data
);
259 extern wxPrintSetupData
* WXDLLEXPORT wxThePrintSetupData
;
260 extern void WXDLLEXPORT
wxInitializePrintSetupData(bool init
= TRUE
);
263 * Again, this only really needed for non-Windows platforms
264 * or if you want to test the PostScript printing under Windows.
267 class WXDLLEXPORT wxPrintPaperType
: public wxObject
269 DECLARE_DYNAMIC_CLASS(wxPrintPaperType
)
278 wxPrintPaperType(const char *name
= (const char *) NULL
, int wmm
= 0, int hmm
= 0, int wp
= 0, int hp
= 0);
279 ~wxPrintPaperType(void);
282 class WXDLLEXPORT wxPrintPaperDatabase
: public wxList
284 DECLARE_DYNAMIC_CLASS(wxPrintPaperDatabase
)
287 wxPrintPaperDatabase(void);
288 ~wxPrintPaperDatabase(void);
290 void CreateDatabase(void);
291 void ClearDatabase(void);
293 void AddPaperType(const char *name
, int wmm
, int hmm
, int wp
, int hp
);
294 wxPrintPaperType
*FindPaperType(const char *name
);
297 WXDLLEXPORT_DATA(extern wxPrintPaperDatabase
*) wxThePrintPaperDatabase
;
299 #endif // wxUSE_POSTSCRIPT