1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/dcps.h
3 // Purpose: wxPostScriptDC class
4 // Author: Julian Smart and others
7 // Copyright: (c) Julian Smart and Robert Roebling
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
16 #if wxUSE_PRINTING_ARCHITECTURE
21 #include "wx/dialog.h"
22 #include "wx/module.h"
23 #include "wx/cmndata.h"
24 #include "wx/strvararg.h"
26 extern WXDLLIMPEXP_DATA_CORE(int) wxPageNumber
;
28 //-----------------------------------------------------------------------------
30 //-----------------------------------------------------------------------------
34 //-----------------------------------------------------------------------------
36 //-----------------------------------------------------------------------------
38 class WXDLLEXPORT wxPostScriptDC
: public wxDC
43 // Recommended constructor
44 wxPostScriptDC(const wxPrintData
& printData
);
46 virtual ~wxPostScriptDC();
48 virtual bool Ok() const { return IsOk(); }
49 virtual bool IsOk() const;
51 bool CanDrawBitmap() const { return true; }
54 void SetFont( const wxFont
& font
);
55 void SetPen( const wxPen
& pen
);
56 void SetBrush( const wxBrush
& brush
);
57 void SetLogicalFunction( int function
);
58 void SetBackground( const wxBrush
& brush
);
60 void DestroyClippingRegion();
62 bool StartDoc(const wxString
& message
);
67 wxCoord
GetCharHeight() const;
68 wxCoord
GetCharWidth() const;
69 bool CanGetTextExtent() const { return true; }
71 // Resolution in pixels per logical inch
72 wxSize
GetPPI() const;
74 // overridden because origin is bottom left and
76 void SetAxisOrientation( bool xLeftRight
, bool yBottomUp
);
78 // these need to be overridden as wxPostscriptDC inherits
79 // from the platform dependent wxDC and this we'd call
80 // e.g. wxMSW specific code here.
81 virtual void SetMapMode(int mode
);
82 virtual void SetUserScale(double x
, double y
);
83 virtual void SetLogicalScale(double x
, double y
);
84 virtual void SetLogicalOrigin(wxCoord x
, wxCoord y
);
85 virtual void SetDeviceOrigin(wxCoord x
, wxCoord y
);
87 void SetBackgroundMode(int WXUNUSED(mode
)) { }
88 void SetPalette(const wxPalette
& WXUNUSED(palette
)) { }
90 void SetPrintData(const wxPrintData
& data
);
91 wxPrintData
& GetPrintData() { return m_printData
; }
93 virtual int GetDepth() const { return 24; }
95 static void SetResolution(int ppi
);
96 static int GetResolution();
98 WX_DEFINE_VARARG_FUNC_VOID(PsPrintf
, 1, (const wxFormatString
&),
99 DoPsPrintfFormatWchar
, DoPsPrintfFormatUtf8
)
101 // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
102 WX_DEFINE_VARARG_FUNC_VOID(PsPrintf
, 1, (const char*),
103 DoPsPrintfFormatWchar
, DoPsPrintfFormatUtf8
)
104 WX_DEFINE_VARARG_FUNC_VOID(PsPrintf
, 1, (const wchar_t*),
105 DoPsPrintfFormatWchar
, DoPsPrintfFormatUtf8
)
108 void PsPrint( const wxString
& psdata
);
109 void PsPrint( int ch
);
112 #if !wxUSE_UTF8_LOCALE_ONLY
113 void DoPsPrintfFormatWchar(const wxChar
*fmt
, ... );
115 #if wxUSE_UNICODE_UTF8
116 void DoPsPrintfFormatUtf8(const char *fmt
, ... );
119 static float ms_PSScaleFactor
;
122 bool DoFloodFill(wxCoord x1
, wxCoord y1
, const wxColour
&col
, int style
= wxFLOOD_SURFACE
);
123 bool DoGetPixel(wxCoord x1
, wxCoord y1
, wxColour
*col
) const;
124 void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
);
125 void DoCrossHair(wxCoord x
, wxCoord y
) ;
126 void DoDrawArc(wxCoord x1
,wxCoord y1
,wxCoord x2
,wxCoord y2
,wxCoord xc
,wxCoord yc
);
127 void DoDrawEllipticArc(wxCoord x
,wxCoord y
,wxCoord w
,wxCoord h
,double sa
,double ea
);
128 void DoDrawPoint(wxCoord x
, wxCoord y
);
129 void DoDrawLines(int n
, wxPoint points
[], wxCoord xoffset
= 0, wxCoord yoffset
= 0);
130 void DoDrawPolygon(int n
, wxPoint points
[], wxCoord xoffset
= 0, wxCoord yoffset
= 0, int fillStyle
= wxODDEVEN_RULE
);
131 void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[], wxCoord xoffset
= 0, wxCoord yoffset
= 0, int fillStyle
= wxODDEVEN_RULE
);
132 void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
133 void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, double radius
= 20);
134 void DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
136 void DoDrawSpline(wxList
*points
);
137 #endif // wxUSE_SPLINES
138 bool DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
139 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
, int rop
= wxCOPY
, bool useMask
= false,
140 wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
);
141 void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
);
142 void DoDrawBitmap(const wxBitmap
& bitmap
, wxCoord x
, wxCoord y
, bool useMask
= false);
143 void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
144 void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
);
145 void DoSetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
146 void DoSetClippingRegionAsRegion( const wxRegion
&WXUNUSED(clip
)) { }
147 void DoGetTextExtent(const wxString
& string
, wxCoord
*x
, wxCoord
*y
,
148 wxCoord
*descent
= NULL
,
149 wxCoord
*externalLeading
= NULL
,
150 const wxFont
*theFont
= NULL
) const;
151 void DoGetSize(int* width
, int* height
) const;
152 void DoGetSizeMM(int *width
, int *height
) const;
154 FILE* m_pstream
; // PostScript output stream
156 unsigned char m_currentRed
;
157 unsigned char m_currentGreen
;
158 unsigned char m_currentBlue
;
161 double m_underlinePosition
;
162 double m_underlineThickness
;
163 wxPrintData m_printData
;
166 DECLARE_DYNAMIC_CLASS(wxPostScriptDC
)
173 // wxUSE_PRINTING_ARCHITECTURE