]>
Commit | Line | Data |
---|---|---|
a24aff65 DE |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: dc.h | |
3 | // Purpose: wxDC class | |
4 | // Author: AUTHOR | |
5 | // Modified by: | |
6 | // Created: ??/??/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) AUTHOR | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_DC_H_ | |
13 | #define _WX_DC_H_ | |
14 | ||
15 | #if defined(__GNUG__) && !defined(__APPLE__) | |
16 | #pragma interface "dc.h" | |
17 | #endif | |
18 | ||
19 | #include "wx/pen.h" | |
20 | #include "wx/brush.h" | |
21 | #include "wx/icon.h" | |
22 | #include "wx/font.h" | |
23 | #include "wx/gdicmn.h" | |
24 | ||
25 | //----------------------------------------------------------------------------- | |
26 | // constants | |
27 | //----------------------------------------------------------------------------- | |
28 | ||
29 | #ifndef MM_TEXT | |
30 | #define MM_TEXT 0 | |
31 | #define MM_ISOTROPIC 1 | |
32 | #define MM_ANISOTROPIC 2 | |
33 | #define MM_LOMETRIC 3 | |
34 | #define MM_HIMETRIC 4 | |
35 | #define MM_TWIPS 5 | |
36 | #define MM_POINTS 6 | |
37 | #define MM_METRIC 7 | |
38 | #endif | |
39 | ||
40 | //----------------------------------------------------------------------------- | |
41 | // global variables | |
42 | //----------------------------------------------------------------------------- | |
43 | ||
44 | extern int wxPageNumber; | |
45 | ||
46 | //----------------------------------------------------------------------------- | |
47 | // wxDC | |
48 | //----------------------------------------------------------------------------- | |
49 | ||
50 | class WXDLLEXPORT wxDC: public wxDCBase | |
51 | { | |
52 | DECLARE_DYNAMIC_CLASS(wxDC) | |
53 | DECLARE_NO_COPY_CLASS(wxDC) | |
54 | ||
55 | public: | |
56 | ||
57 | wxDC(); | |
58 | ~wxDC(); | |
59 | ||
60 | ||
61 | // implement base class pure virtuals | |
62 | // ---------------------------------- | |
63 | ||
64 | virtual void Clear(); | |
65 | ||
66 | virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return TRUE; } | |
67 | virtual void EndDoc(void) {}; | |
68 | ||
69 | virtual void StartPage(void) {}; | |
70 | virtual void EndPage(void) {}; | |
71 | ||
72 | virtual void SetFont(const wxFont& font) {} | |
73 | virtual void SetPen(const wxPen& pen); | |
74 | virtual void SetBrush(const wxBrush& brush); | |
75 | virtual void SetBackground(const wxBrush& brush); | |
76 | virtual void SetBackgroundMode(int mode) {} | |
77 | virtual void SetPalette(const wxPalette& palette); | |
78 | ||
79 | virtual void DestroyClippingRegion(); | |
80 | ||
81 | virtual wxCoord GetCharHeight() const; | |
82 | virtual wxCoord GetCharWidth() const; | |
83 | virtual void DoGetTextExtent(const wxString& string, | |
84 | wxCoord *x, wxCoord *y, | |
85 | wxCoord *descent = NULL, | |
86 | wxCoord *externalLeading = NULL, | |
87 | wxFont *theFont = NULL) const; | |
88 | ||
89 | virtual bool CanDrawBitmap() const; | |
90 | virtual bool CanGetTextExtent() const; | |
91 | virtual int GetDepth() const; | |
92 | virtual wxSize GetPPI() const; | |
93 | ||
94 | virtual void SetMapMode(int mode); | |
95 | virtual void SetUserScale(double x, double y); | |
96 | ||
97 | virtual void SetLogicalScale(double x, double y); | |
98 | virtual void SetLogicalOrigin(wxCoord x, wxCoord y); | |
99 | virtual void SetDeviceOrigin(wxCoord x, wxCoord y); | |
100 | virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp); | |
101 | virtual void SetLogicalFunction(int function); | |
102 | ||
103 | virtual void SetTextForeground(const wxColour& colour) ; | |
104 | virtual void SetTextBackground(const wxColour& colour) ; | |
105 | ||
106 | void ComputeScaleAndOrigin(void); | |
107 | public: | |
108 | ||
109 | ||
110 | wxCoord XDEV2LOG(wxCoord x) const | |
111 | { | |
112 | long new_x = x - m_deviceOriginX ; | |
113 | if (new_x > 0) | |
114 | return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX; | |
115 | else | |
116 | return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX; | |
117 | } | |
118 | wxCoord XDEV2LOGREL(wxCoord x) const | |
119 | { | |
120 | if (x > 0) | |
121 | return (wxCoord)((double)(x) / m_scaleX + 0.5); | |
122 | else | |
123 | return (wxCoord)((double)(x) / m_scaleX - 0.5); | |
124 | } | |
125 | wxCoord YDEV2LOG(wxCoord y) const | |
126 | { | |
127 | long new_y = y - m_deviceOriginY ; | |
128 | if (new_y > 0) | |
129 | return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY; | |
130 | else | |
131 | return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY; | |
132 | } | |
133 | wxCoord YDEV2LOGREL(wxCoord y) const | |
134 | { | |
135 | if (y > 0) | |
136 | return (wxCoord)((double)(y) / m_scaleY + 0.5); | |
137 | else | |
138 | return (wxCoord)((double)(y) / m_scaleY - 0.5); | |
139 | } | |
140 | wxCoord XLOG2DEV(wxCoord x) const | |
141 | { | |
142 | long new_x = x - m_logicalOriginX; | |
143 | if (new_x > 0) | |
144 | return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX ; | |
145 | else | |
146 | return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX ; | |
147 | } | |
148 | wxCoord XLOG2DEVREL(wxCoord x) const | |
149 | { | |
150 | if (x > 0) | |
151 | return (wxCoord)((double)(x) * m_scaleX + 0.5); | |
152 | else | |
153 | return (wxCoord)((double)(x) * m_scaleX - 0.5); | |
154 | } | |
155 | wxCoord YLOG2DEV(wxCoord y) const | |
156 | { | |
157 | long new_y = y - m_logicalOriginY ; | |
158 | if (new_y > 0) | |
159 | return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY ; | |
160 | else | |
161 | return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY ; | |
162 | } | |
163 | wxCoord YLOG2DEVREL(wxCoord y) const | |
164 | { | |
165 | if (y > 0) | |
166 | return (wxCoord)((double)(y) * m_scaleY + 0.5); | |
167 | else | |
168 | return (wxCoord)((double)(y) * m_scaleY - 0.5); | |
169 | } | |
170 | ||
171 | protected: | |
172 | virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, | |
173 | int style = wxFLOOD_SURFACE); | |
174 | ||
175 | virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const; | |
176 | ||
177 | virtual void DoDrawPoint(wxCoord x, wxCoord y); | |
178 | virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); | |
179 | ||
180 | virtual void DoDrawArc(wxCoord x1, wxCoord y1, | |
181 | wxCoord x2, wxCoord y2, | |
182 | wxCoord xc, wxCoord yc); | |
183 | ||
184 | virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, | |
185 | double sa, double ea); | |
186 | ||
187 | virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
188 | virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y, | |
189 | wxCoord width, wxCoord height, | |
190 | double radius); | |
191 | virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
192 | ||
193 | virtual void DoCrossHair(wxCoord x, wxCoord y); | |
194 | ||
195 | virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y); | |
196 | virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, | |
197 | bool useMask = FALSE); | |
198 | ||
199 | virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y); | |
200 | virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, | |
201 | double angle); | |
202 | ||
203 | virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, | |
204 | wxDC *source, wxCoord xsrc, wxCoord ysrc, | |
205 | int rop = wxCOPY, bool useMask = FALSE, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1); | |
206 | ||
207 | // this is gnarly - we can't even call this function DoSetClippingRegion() | |
208 | // because of virtual function hiding | |
209 | virtual void DoSetClippingRegionAsRegion(const wxRegion& region); | |
210 | virtual void DoSetClippingRegion(wxCoord x, wxCoord y, | |
211 | wxCoord width, wxCoord height); | |
212 | virtual void DoGetClippingRegion(wxCoord *x, wxCoord *y, | |
213 | wxCoord *width, wxCoord *height) | |
214 | { | |
215 | GetClippingBox(x, y, width, height); | |
216 | } | |
217 | ||
218 | virtual void DoGetSize(int *width, int *height) const; | |
219 | virtual void DoGetSizeMM(int* width, int* height) const; | |
220 | ||
221 | virtual void DoDrawLines(int n, wxPoint points[], | |
222 | wxCoord xoffset, wxCoord yoffset); | |
223 | virtual void DoDrawPolygon(int n, wxPoint points[], | |
224 | wxCoord xoffset, wxCoord yoffset, | |
225 | int fillStyle = wxODDEVEN_RULE); | |
226 | ||
227 | protected: | |
228 | }; | |
229 | ||
230 | #endif | |
231 | // _WX_DC_H_ |