use UTF8-encoded char* strings in UTF8 build instead of wchar_t* if the current local...
[wxWidgets.git] / include / wx / generic / dcpsg.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/dcps.h
3 // Purpose: wxPostScriptDC class
4 // Author: Julian Smart and others
5 // Modified by:
6 // RCS-ID: $Id$
7 // Copyright: (c) Julian Smart and Robert Roebling
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_DCPSG_H_
12 #define _WX_DCPSG_H_
13
14 #include "wx/defs.h"
15
16 #if wxUSE_PRINTING_ARCHITECTURE
17
18 #if wxUSE_POSTSCRIPT
19
20 #include "wx/dc.h"
21 #include "wx/dialog.h"
22 #include "wx/module.h"
23 #include "wx/cmndata.h"
24 #include "wx/strvararg.h"
25
26 extern WXDLLIMPEXP_DATA_CORE(int) wxPageNumber;
27
28 //-----------------------------------------------------------------------------
29 // classes
30 //-----------------------------------------------------------------------------
31
32 class wxPostScriptDC;
33
34 //-----------------------------------------------------------------------------
35 // wxPostScriptDC
36 //-----------------------------------------------------------------------------
37
38 class WXDLLEXPORT wxPostScriptDC: public wxDC
39 {
40 public:
41 wxPostScriptDC();
42
43 // Recommended constructor
44 wxPostScriptDC(const wxPrintData& printData);
45
46 // Recommended destructor :-)
47 virtual ~wxPostScriptDC();
48
49 virtual bool Ok() const { return IsOk(); }
50 virtual bool IsOk() const;
51
52 bool CanDrawBitmap() const { return true; }
53
54 void Clear();
55 void SetFont( const wxFont& font );
56 void SetPen( const wxPen& pen );
57 void SetBrush( const wxBrush& brush );
58 void SetLogicalFunction( int function );
59 void SetBackground( const wxBrush& brush );
60
61 void DestroyClippingRegion();
62
63 bool StartDoc(const wxString& message);
64 void EndDoc();
65 void StartPage();
66 void EndPage();
67
68 wxCoord GetCharHeight() const;
69 wxCoord GetCharWidth() const;
70 bool CanGetTextExtent() const { return true; }
71
72 // Resolution in pixels per logical inch
73 wxSize GetPPI() const;
74
75 void SetAxisOrientation( bool xLeftRight, bool yBottomUp );
76 void SetDeviceOrigin( wxCoord x, wxCoord y );
77
78 void SetBackgroundMode(int WXUNUSED(mode)) { }
79 void SetPalette(const wxPalette& WXUNUSED(palette)) { }
80
81 wxPrintData& GetPrintData() { return m_printData; }
82 void SetPrintData(const wxPrintData& data) { m_printData = data; }
83
84 virtual int GetDepth() const { return 24; }
85
86 static void SetResolution(int ppi);
87 static int GetResolution();
88
89 WX_DEFINE_VARARG_FUNC_VOID(PsPrintf, 1, (const wxString&), DoPsPrintfFormat)
90 #ifdef __WATCOMC__
91 // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
92 WX_DEFINE_VARARG_FUNC_VOID(PsPrintf, 1, (const char*), DoPsPrintfFormat)
93 WX_DEFINE_VARARG_FUNC_VOID(PsPrintf, 1, (const wchar_t*), DoPsPrintfFormat)
94 #endif
95
96 void PsPrint( const wxString& psdata );
97 void PsPrint( int ch );
98
99 private:
100 void DoPsPrintfFormat(const wxString& fmt, ... );
101
102 static float ms_PSScaleFactor;
103
104 protected:
105 bool DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col, int style = wxFLOOD_SURFACE);
106 bool DoGetPixel(wxCoord x1, wxCoord y1, wxColour *col) const;
107 void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
108 void DoCrossHair(wxCoord x, wxCoord y) ;
109 void DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc);
110 void DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea);
111 void DoDrawPoint(wxCoord x, wxCoord y);
112 void DoDrawLines(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0);
113 void DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle = wxODDEVEN_RULE);
114 void DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle = wxODDEVEN_RULE);
115 void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
116 void DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius = 20);
117 void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
118 #if wxUSE_SPLINES
119 void DoDrawSpline(wxList *points);
120 #endif // wxUSE_SPLINES
121 bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
122 wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop = wxCOPY, bool useMask = false,
123 wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord);
124 void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
125 void DoDrawBitmap(const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask = false);
126 void DoDrawText(const wxString& text, wxCoord x, wxCoord y);
127 void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
128 void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
129 void DoSetClippingRegionAsRegion( const wxRegion &WXUNUSED(clip)) { }
130 void DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
131 wxCoord *descent = NULL,
132 wxCoord *externalLeading = NULL,
133 const wxFont *theFont = NULL) const;
134 void DoGetSize(int* width, int* height) const;
135 void DoGetSizeMM(int *width, int *height) const;
136
137 FILE* m_pstream; // PostScript output stream
138 wxString m_title;
139 unsigned char m_currentRed;
140 unsigned char m_currentGreen;
141 unsigned char m_currentBlue;
142 int m_pageNumber;
143 bool m_clipping;
144 double m_underlinePosition;
145 double m_underlineThickness;
146 wxPrintData m_printData;
147
148 private:
149 DECLARE_DYNAMIC_CLASS(wxPostScriptDC)
150 };
151
152 #endif
153 // wxUSE_POSTSCRIPT
154
155 #endif
156 // wxUSE_PRINTING_ARCHITECTURE
157
158 #endif
159 // _WX_DCPSG_H_