1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxPostScriptDC class
4 // Author: Julian Smart and others
7 // Copyright: (c) Julian Smart, Robert Roebling and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
20 #if wxUSE_PRINTING_ARCHITECTURE
24 #include "wx/dialog.h"
25 #include "wx/module.h"
26 #include "wx/cmndata.h"
28 //-----------------------------------------------------------------------------
30 //-----------------------------------------------------------------------------
34 //-----------------------------------------------------------------------------
36 //-----------------------------------------------------------------------------
38 class WXDLLEXPORT wxPostScriptDC
: public wxDC
40 DECLARE_DYNAMIC_CLASS(wxPostScriptDC
)
46 // Deprecated constructor
47 wxPostScriptDC(const wxString
& output
, bool interactive
= TRUE
, wxWindow
*parent
= (wxWindow
*) NULL
);
49 // Recommended constructor
50 wxPostScriptDC(const wxPrintData
& printData
);
55 bool Create(const wxString
& output
, bool interactive
= TRUE
, wxWindow
*parent
= (wxWindow
*) NULL
);
57 virtual bool Ok() const;
59 // Deprecated: use wxGenericPrintDialog instead
60 virtual bool PrinterDialog(wxWindow
*parent
= (wxWindow
*) NULL
);
62 virtual void BeginDrawing() {}
63 virtual void EndDrawing() {}
65 void DoFloodFill(wxCoord x1
, wxCoord y1
, const wxColour
&col
, int style
=wxFLOOD_SURFACE
);
66 bool DoGetPixel(wxCoord x1
, wxCoord y1
, wxColour
*col
) const;
68 void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
);
69 void DoCrossHair(wxCoord x
, wxCoord y
) ;
70 void DoDrawArc(wxCoord x1
,wxCoord y1
,wxCoord x2
,wxCoord y2
,wxCoord xc
,wxCoord yc
);
71 void DoDrawEllipticArc(wxCoord x
,wxCoord y
,wxCoord w
,wxCoord h
,double sa
,double ea
);
72 void DoDrawPoint(wxCoord x
, wxCoord y
);
73 void DoDrawLines(int n
, wxPoint points
[], wxCoord xoffset
= 0, wxCoord yoffset
= 0);
74 void DoDrawPolygon(int n
, wxPoint points
[], wxCoord xoffset
= 0, wxCoord yoffset
= 0, int fillStyle
=wxODDEVEN_RULE
);
75 void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
76 void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, double radius
= 20);
77 void DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
79 void DoDrawSpline(wxList
*points
);
81 bool DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
82 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
, int rop
= wxCOPY
, bool useMask
= FALSE
);
83 bool CanDrawBitmap() const { return TRUE
; }
85 void DoDrawIcon( const wxIcon
& icon
, wxCoord x
, wxCoord y
);
86 void DoDrawBitmap( const wxBitmap
& bitmap
, wxCoord x
, wxCoord y
, bool useMask
=FALSE
);
88 void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
89 void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
);
92 void SetFont( const wxFont
& font
);
93 void SetPen( const wxPen
& pen
);
94 void SetBrush( const wxBrush
& brush
);
95 void SetLogicalFunction( int function
);
96 void SetBackground( const wxBrush
& brush
);
98 void DoSetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
99 void DestroyClippingRegion();
101 void DoSetClippingRegionAsRegion( const wxRegion
&WXUNUSED(clip
) ) { }
103 bool StartDoc(const wxString
& message
);
108 wxCoord
GetCharHeight() const;
109 wxCoord
GetCharWidth() const;
110 bool CanGetTextExtent() const { return TRUE
; }
111 void DoGetTextExtent(const wxString
& string
, wxCoord
*x
, wxCoord
*y
,
112 wxCoord
*descent
= (wxCoord
*) NULL
,
113 wxCoord
*externalLeading
= (wxCoord
*) NULL
,
114 wxFont
*theFont
= (wxFont
*) NULL
) const;
116 void DoGetSize(int* width
, int* height
) const;
117 void DoGetSizeMM(int *width
, int *height
) const;
119 // Resolution in pixels per logical inch
120 wxSize
GetPPI() const;
122 void SetAxisOrientation( bool xLeftRight
, bool yBottomUp
);
123 void SetDeviceOrigin( wxCoord x
, wxCoord y
);
125 void SetBackgroundMode(int WXUNUSED(mode
)) { }
126 void SetPalette(const wxPalette
& WXUNUSED(palette
)) { }
128 wxPrintData
& GetPrintData() { return m_printData
; }
129 void SetPrintData(const wxPrintData
& data
) { m_printData
= data
; }
131 virtual int GetDepth() const { return 24; }
133 static void SetResolution(int ppi
);
134 static int GetResolution();
137 static float ms_PSScaleFactor
;
141 FILE* m_pstream
; // PostScript output stream
143 unsigned char m_currentRed
;
144 unsigned char m_currentGreen
;
145 unsigned char m_currentBlue
;
148 double m_underlinePosition
;
149 double m_underlineThickness
;
150 wxPrintData m_printData
;
153 // Deprecated: should use wxGenericPrintDialog instead.
157 wxID_PRINTER_COMMAND
= 1,
158 wxID_PRINTER_OPTIONS
,
159 wxID_PRINTER_ORIENTATION
,
161 wxID_PRINTER_X_SCALE
,
162 wxID_PRINTER_Y_SCALE
,
163 wxID_PRINTER_X_TRANS
,
167 class WXDLLEXPORT wxPostScriptPrintDialog
: public wxDialog
169 DECLARE_CLASS(wxPostScriptPrintDialog
)
171 wxPostScriptPrintDialog (wxWindow
*parent
, const wxString
& title
,
172 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
173 wxCoord style
= wxDEFAULT_DIALOG_STYLE
);
175 virtual int ShowModal();
179 // Print Orientation (Should also add Left, Right)
184 };// ps_orientation = PS_PORTRAIT;
193 };// ps_action = PS_PREVIEW;
195 // PostScript printer settings
196 WXDLLEXPORT
void wxSetPrinterCommand(const wxString
& cmd
);
197 WXDLLEXPORT
void wxSetPrintPreviewCommand(const wxString
& cmd
);
198 WXDLLEXPORT
void wxSetPrinterOptions(const wxString
& flags
);
199 WXDLLEXPORT
void wxSetPrinterOrientation(int orientation
);
200 WXDLLEXPORT
void wxSetPrinterScaling(double x
, double y
);
201 WXDLLEXPORT
void wxSetPrinterTranslation(wxCoord x
, wxCoord y
);
202 WXDLLEXPORT
void wxSetPrinterMode(int mode
);
203 WXDLLEXPORT
void wxSetPrinterFile(const wxString
& f
);
204 WXDLLEXPORT
void wxSetAFMPath(const wxString
& f
);
206 // Get current values
207 WXDLLEXPORT wxString
wxGetPrinterCommand();
208 WXDLLEXPORT wxString
wxGetPrintPreviewCommand();
209 WXDLLEXPORT wxString
wxGetPrinterOptions();
210 WXDLLEXPORT
int wxGetPrinterOrientation();
211 WXDLLEXPORT
void wxGetPrinterScaling(double* x
, double* y
);
212 WXDLLEXPORT
void wxGetPrinterTranslation(wxCoord
*x
, wxCoord
*y
);
213 WXDLLEXPORT
int wxGetPrinterMode();
214 WXDLLEXPORT wxString
wxGetPrinterFile();
215 WXDLLEXPORT wxString
wxGetAFMPath();
218 * PostScript print setup information.
219 * This is now obsolete, but retained for a while for compatibility
222 class WXDLLEXPORT wxPrintSetupData
: public wxObject
228 void SetPrinterCommand(const wxString
& cmd
) { m_printerCommand
= cmd
; };
229 void SetPaperName(const wxString
& paper
) { m_paperName
= paper
; };
230 void SetPrintPreviewCommand(const wxString
& cmd
) { m_previewCommand
= cmd
; };
231 void SetPrinterOptions(const wxString
& flags
) { m_printerFlags
= flags
; };
232 void SetPrinterFile(const wxString
& f
) { m_printerFile
= f
; };
233 void SetPrinterOrientation(int orient
) { m_printerOrient
= orient
; };
234 void SetPrinterScaling(double x
, double y
) { m_printerScaleX
= x
; m_printerScaleY
= y
; };
235 void SetPrinterTranslation(wxCoord x
, wxCoord y
) { m_printerTranslateX
= x
; m_printerTranslateY
= y
; };
236 // 1 = Preview, 2 = print to file, 3 = send to printer
237 void SetPrinterMode(int mode
) { m_printerMode
= mode
; };
238 void SetAFMPath(const wxString
& f
) { m_afmPath
= f
; };
239 void SetColour(bool col
) { m_printColour
= col
; };
241 // Get current values
242 wxString
GetPrinterCommand() const { return m_printerCommand
; } ;
243 wxString
GetPrintPreviewCommand() const { return m_previewCommand
; } ;
244 wxString
GetPrinterOptions() const { return m_printerFlags
; };
245 wxString
GetPrinterFile() const { return m_printerFile
; };
246 wxString
GetPaperName() const { return m_paperName
; }
247 int GetPrinterOrientation() const { return m_printerOrient
; };
248 void GetPrinterScaling(double* x
, double* y
) const { *x
= m_printerScaleX
; *y
= m_printerScaleY
; };
249 void GetPrinterTranslation(wxCoord
*x
, wxCoord
*y
) const { *x
= m_printerTranslateX
; *y
= m_printerTranslateY
; };
250 int GetPrinterMode() const { return m_printerMode
; };
251 wxString
GetAFMPath() const { return m_afmPath
; };
252 bool GetColour() const { return m_printColour
; };
254 void operator=(wxPrintSetupData
& data
);
256 // Initialize from a wxPrintData object (wxPrintData should now be used instead of wxPrintSetupData).
257 // There is also an operator for initializing a wxPrintData from a wxPrintSetupData.
258 void operator=(const wxPrintData
& data
);
261 void GetPrinterTranslation(long *x
, long *y
) const
262 { *x
= m_printerTranslateX
; *y
= m_printerTranslateY
; }
266 wxString m_printerCommand
;
267 wxString m_previewCommand
;
268 wxString m_printerFlags
;
269 wxString m_printerFile
;
271 double m_printerScaleX
;
272 double m_printerScaleY
;
273 wxCoord m_printerTranslateX
;
274 wxCoord m_printerTranslateY
;
275 // 1 = Preview, 2 = print to file, 3 = send to printer
278 // A name in the paper database (see paper.h)
279 wxString m_paperName
;
282 DECLARE_DYNAMIC_CLASS(wxPrintSetupData
)
285 WXDLLEXPORT_DATA(extern wxPrintSetupData
*) wxThePrintSetupData
;
286 WXDLLEXPORT
extern void wxInitializePrintSetupData(bool init
= TRUE
);
292 // wxUSE_PRINTING_ARCHITECTURE