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(long x1
, long y1
, const wxColour
&col
, int style
=wxFLOOD_SURFACE
);
66 bool DoGetPixel(long x1
, long y1
, wxColour
*col
) const;
68 void DoDrawLine(long x1
, long y1
, long x2
, long y2
);
69 void DoCrossHair(long x
, long y
) ;
70 void DoDrawArc(long x1
,long y1
,long x2
,long y2
,long xc
,long yc
);
71 void DoDrawEllipticArc(long x
,long y
,long w
,long h
,double sa
,double ea
);
72 void DoDrawPoint(long x
, long y
);
73 void DoDrawLines(int n
, wxPoint points
[], long xoffset
= 0, long yoffset
= 0);
74 void DoDrawPolygon(int n
, wxPoint points
[], long xoffset
= 0, long yoffset
= 0, int fillStyle
=wxODDEVEN_RULE
);
75 void DoDrawRectangle(long x
, long y
, long width
, long height
);
76 void DoDrawRoundedRectangle(long x
, long y
, long width
, long height
, double radius
= 20);
77 void DoDrawEllipse(long x
, long y
, long width
, long height
);
79 void DoDrawSpline(wxList
*points
);
81 bool DoBlit(long xdest
, long ydest
, long width
, long height
,
82 wxDC
*source
, long xsrc
, long ysrc
, int rop
= wxCOPY
, bool useMask
= FALSE
);
83 inline bool CanDrawBitmap(void) const { return TRUE
; }
85 void DoDrawIcon( const wxIcon
& icon
, long x
, long y
);
86 void DoDrawBitmap( const wxBitmap
& bitmap
, long x
, long y
, bool useMask
=FALSE
);
88 void DoDrawText(const wxString
& text
, long x
, long y
);
91 void SetFont( const wxFont
& font
);
92 void SetPen( const wxPen
& pen
);
93 void SetBrush( const wxBrush
& brush
);
94 void SetLogicalFunction( int function
);
95 void SetBackground( const wxBrush
& brush
);
97 void SetClippingRegion(long x
, long y
, long width
, long height
);
98 void SetClippingRegion( const wxRegion
®ion
);
99 void DestroyClippingRegion();
101 void DoSetClippingRegionAsRegion( const wxRegion
&WXUNUSED(clip
) ) {}
103 bool StartDoc(const wxString
& message
);
108 long GetCharHeight() const;
109 long GetCharWidth() const;
110 inline bool CanGetTextExtent(void) const { return FALSE
; }
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
) 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(void) const;
122 void SetAxisOrientation( bool xLeftRight
, bool yBottomUp
);
123 void SetDeviceOrigin( long x
, long y
);
125 inline void SetBackgroundMode(int WXUNUSED(mode
)) {}
126 inline 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; }
135 FILE* m_pstream
; // PostScript output stream
137 unsigned char m_currentRed
;
138 unsigned char m_currentGreen
;
139 unsigned char m_currentBlue
;
142 double m_underlinePosition
;
143 double m_underlineThickness
;
144 wxPrintData m_printData
;
147 // Deprecated: should use wxGenericPrintDialog instead.
149 #define wxID_PRINTER_COMMAND 1
150 #define wxID_PRINTER_OPTIONS 2
151 #define wxID_PRINTER_ORIENTATION 3
152 #define wxID_PRINTER_MODES 4
153 #define wxID_PRINTER_X_SCALE 5
154 #define wxID_PRINTER_Y_SCALE 6
155 #define wxID_PRINTER_X_TRANS 7
156 #define wxID_PRINTER_Y_TRANS 8
158 class WXDLLEXPORT wxPostScriptPrintDialog
: public wxDialog
160 DECLARE_CLASS(wxPostScriptPrintDialog
)
162 wxPostScriptPrintDialog (wxWindow
*parent
, const wxString
& title
,
163 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
164 long style
= wxDEFAULT_DIALOG_STYLE
);
166 virtual int ShowModal(void) ;
170 // Print Orientation (Should also add Left, Right)
175 };// ps_orientation = PS_PORTRAIT;
184 };// ps_action = PS_PREVIEW;
186 // PostScript printer settings
187 WXDLLEXPORT
void wxSetPrinterCommand(const wxString
& cmd
);
188 WXDLLEXPORT
void wxSetPrintPreviewCommand(const wxString
& cmd
);
189 WXDLLEXPORT
void wxSetPrinterOptions(const wxString
& flags
);
190 WXDLLEXPORT
void wxSetPrinterOrientation(int orientation
);
191 WXDLLEXPORT
void wxSetPrinterScaling(double x
, double y
);
192 WXDLLEXPORT
void wxSetPrinterTranslation(long x
, long y
);
193 WXDLLEXPORT
void wxSetPrinterMode(int mode
);
194 WXDLLEXPORT
void wxSetPrinterFile(const wxString
& f
);
195 WXDLLEXPORT
void wxSetAFMPath(const wxString
& f
);
197 // Get current values
198 WXDLLEXPORT wxString
wxGetPrinterCommand();
199 WXDLLEXPORT wxString
wxGetPrintPreviewCommand();
200 WXDLLEXPORT wxString
wxGetPrinterOptions();
201 WXDLLEXPORT
int wxGetPrinterOrientation();
202 WXDLLEXPORT
void wxGetPrinterScaling(double* x
, double* y
);
203 WXDLLEXPORT
void wxGetPrinterTranslation(long *x
, long *y
);
204 WXDLLEXPORT
int wxGetPrinterMode();
205 WXDLLEXPORT wxString
wxGetPrinterFile();
206 WXDLLEXPORT wxString
wxGetAFMPath();
209 * PostScript print setup information.
210 * This is now obsolete, but retained for a while for compatibility
213 class WXDLLEXPORT wxPrintSetupData
: public wxObject
219 void SetPrinterCommand(const wxString
& cmd
) { m_printerCommand
= cmd
; };
220 void SetPaperName(const wxString
& paper
) { m_paperName
= paper
; };
221 void SetPrintPreviewCommand(const wxString
& cmd
) { m_previewCommand
= cmd
; };
222 void SetPrinterOptions(const wxString
& flags
) { m_printerFlags
= flags
; };
223 void SetPrinterFile(const wxString
& f
) { m_printerFile
= f
; };
224 void SetPrinterOrientation(int orient
) { m_printerOrient
= orient
; };
225 void SetPrinterScaling(double x
, double y
) { m_printerScaleX
= x
; m_printerScaleY
= y
; };
226 void SetPrinterTranslation(long x
, long y
) { m_printerTranslateX
= x
; m_printerTranslateY
= y
; };
227 // 1 = Preview, 2 = print to file, 3 = send to printer
228 void SetPrinterMode(int mode
) { m_printerMode
= mode
; };
229 void SetAFMPath(const wxString
& f
) { m_afmPath
= f
; };
230 void SetColour(bool col
) { m_printColour
= col
; };
232 // Get current values
233 wxString
GetPrinterCommand() const { return m_printerCommand
; } ;
234 wxString
GetPrintPreviewCommand() const { return m_previewCommand
; } ;
235 wxString
GetPrinterOptions() const { return m_printerFlags
; };
236 wxString
GetPrinterFile() const { return m_printerFile
; };
237 wxString
GetPaperName() const { return m_paperName
; }
238 int GetPrinterOrientation() const { return m_printerOrient
; };
239 void GetPrinterScaling(double* x
, double* y
) const { *x
= m_printerScaleX
; *y
= m_printerScaleY
; };
240 void GetPrinterTranslation(long *x
, long *y
) const { *x
= m_printerTranslateX
; *y
= m_printerTranslateY
; };
241 int GetPrinterMode() const { return m_printerMode
; };
242 wxString
GetAFMPath() const { return m_afmPath
; };
243 bool GetColour() const { return m_printColour
; };
245 void operator=(wxPrintSetupData
& data
);
247 // Initialize from a wxPrintData object (wxPrintData should now be used instead of wxPrintSetupData).
248 // There is also an operator for initializing a wxPrintData from a wxPrintSetupData.
249 void operator=(const wxPrintData
& data
);
252 wxString m_printerCommand
;
253 wxString m_previewCommand
;
254 wxString m_printerFlags
;
255 wxString m_printerFile
;
257 double m_printerScaleX
;
258 double m_printerScaleY
;
259 long m_printerTranslateX
;
260 long m_printerTranslateY
;
261 // 1 = Preview, 2 = print to file, 3 = send to printer
264 // A name in the paper database (see paper.h)
265 wxString m_paperName
;
268 DECLARE_DYNAMIC_CLASS(wxPrintSetupData
)
271 WXDLLEXPORT_DATA(extern wxPrintSetupData
*) wxThePrintSetupData
;
272 WXDLLEXPORT
extern void wxInitializePrintSetupData(bool init
= TRUE
);
278 // wxUSE_PRINTING_ARCHITECTURE