1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxPostScriptDC class
4 // Author: Julian Smart and others
7 // Copyright: (c) Julian Smart and Robert Roebling
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
14 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
15 #pragma interface "dcpsg.h"
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
43 // Recommended constructor
44 wxPostScriptDC(const wxPrintData
& printData
);
46 // Recommended destructor :-)
49 virtual bool Ok() const;
51 virtual void BeginDrawing() {}
52 virtual void EndDrawing() {}
54 bool DoFloodFill(wxCoord x1
, wxCoord y1
, const wxColour
&col
, int style
=wxFLOOD_SURFACE
);
55 bool DoGetPixel(wxCoord x1
, wxCoord y1
, wxColour
*col
) const;
57 void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
);
58 void DoCrossHair(wxCoord x
, wxCoord y
) ;
59 void DoDrawArc(wxCoord x1
,wxCoord y1
,wxCoord x2
,wxCoord y2
,wxCoord xc
,wxCoord yc
);
60 void DoDrawEllipticArc(wxCoord x
,wxCoord y
,wxCoord w
,wxCoord h
,double sa
,double ea
);
61 void DoDrawPoint(wxCoord x
, wxCoord y
);
62 void DoDrawLines(int n
, wxPoint points
[], wxCoord xoffset
= 0, wxCoord yoffset
= 0);
63 void DoDrawPolygon(int n
, wxPoint points
[], wxCoord xoffset
= 0, wxCoord yoffset
= 0, int fillStyle
=wxODDEVEN_RULE
);
64 void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[], wxCoord xoffset
= 0, wxCoord yoffset
= 0, int fillStyle
=wxODDEVEN_RULE
);
65 void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
66 void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, double radius
= 20);
67 void DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
69 void DoDrawSpline(wxList
*points
);
71 bool DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
72 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
, int rop
= wxCOPY
, bool useMask
= false,
73 wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
);
74 bool CanDrawBitmap() const { return true; }
76 void DoDrawIcon( const wxIcon
& icon
, wxCoord x
, wxCoord y
);
77 void DoDrawBitmap( const wxBitmap
& bitmap
, wxCoord x
, wxCoord y
, bool useMask
= false );
79 void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
80 void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
);
83 void SetFont( const wxFont
& font
);
84 void SetPen( const wxPen
& pen
);
85 void SetBrush( const wxBrush
& brush
);
86 void SetLogicalFunction( int function
);
87 void SetBackground( const wxBrush
& brush
);
89 void DoSetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
90 void DestroyClippingRegion();
92 void DoSetClippingRegionAsRegion( const wxRegion
&WXUNUSED(clip
) ) { }
94 bool StartDoc(const wxString
& message
);
99 wxCoord
GetCharHeight() const;
100 wxCoord
GetCharWidth() const;
101 bool CanGetTextExtent() const { return true; }
102 void DoGetTextExtent(const wxString
& string
, wxCoord
*x
, wxCoord
*y
,
103 wxCoord
*descent
= (wxCoord
*) NULL
,
104 wxCoord
*externalLeading
= (wxCoord
*) NULL
,
105 wxFont
*theFont
= (wxFont
*) NULL
) const;
107 void DoGetSize(int* width
, int* height
) const;
108 void DoGetSizeMM(int *width
, int *height
) const;
110 // Resolution in pixels per logical inch
111 wxSize
GetPPI() const;
113 void SetAxisOrientation( bool xLeftRight
, bool yBottomUp
);
114 void SetDeviceOrigin( wxCoord x
, wxCoord y
);
116 void SetBackgroundMode(int WXUNUSED(mode
)) { }
117 void SetPalette(const wxPalette
& WXUNUSED(palette
)) { }
119 wxPrintData
& GetPrintData() { return m_printData
; }
120 void SetPrintData(const wxPrintData
& data
) { m_printData
= data
; }
122 virtual int GetDepth() const { return 24; }
124 static void SetResolution(int ppi
);
125 static int GetResolution();
127 void PsPrintf( const wxChar
* fmt
, ... );
128 void PsPrint( const char* psdata
);
129 void PsPrint( int ch
);
132 void PsPrint( const wxChar
* psdata
) { PsPrint( wxConvUTF8
.cWX2MB( psdata
) ); }
136 static float ms_PSScaleFactor
;
140 FILE* m_pstream
; // PostScript output stream
142 unsigned char m_currentRed
;
143 unsigned char m_currentGreen
;
144 unsigned char m_currentBlue
;
147 double m_underlinePosition
;
148 double m_underlineThickness
;
149 wxPrintData m_printData
;
152 DECLARE_DYNAMIC_CLASS(wxPostScriptDC
)
159 // wxUSE_PRINTING_ARCHITECTURE