]>
Commit | Line | Data |
---|---|---|
8cf73271 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: dc.h | |
3 | // Purpose: wxDC class | |
4 | // Author: Stefan Csomor | |
5 | // Modified by: | |
6 | // Created: 1998-01-01 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Stefan Csomor | |
65571936 | 9 | // Licence: wxWindows licence |
8cf73271 SC |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_DC_H_ | |
13 | #define _WX_DC_H_ | |
14 | ||
15 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) | |
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 | class wxMacPortStateHelper ; | |
613a24f7 | 47 | class wxMacCGContext ; |
8cf73271 SC |
48 | //----------------------------------------------------------------------------- |
49 | // wxDC | |
50 | //----------------------------------------------------------------------------- | |
51 | ||
52 | class WXDLLEXPORT wxDC: public wxDCBase | |
53 | { | |
54 | DECLARE_DYNAMIC_CLASS(wxDC) | |
55 | DECLARE_NO_COPY_CLASS(wxDC) | |
56 | ||
57 | public: | |
58 | ||
59 | wxDC(); | |
60 | ~wxDC(); | |
c5789d15 | 61 | |
8cf73271 SC |
62 | |
63 | // implement base class pure virtuals | |
64 | // ---------------------------------- | |
65 | ||
66 | virtual void Clear(); | |
67 | ||
b1263dcf | 68 | virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return true; } |
8cf73271 | 69 | virtual void EndDoc(void) {}; |
c5789d15 | 70 | |
8cf73271 SC |
71 | virtual void StartPage(void) {}; |
72 | virtual void EndPage(void) {}; | |
73 | ||
74 | virtual void SetFont(const wxFont& font); | |
75 | virtual void SetPen(const wxPen& pen); | |
76 | virtual void SetBrush(const wxBrush& brush); | |
77 | virtual void SetBackground(const wxBrush& brush); | |
78 | virtual void SetBackgroundMode(int mode); | |
79 | virtual void SetPalette(const wxPalette& palette); | |
80 | ||
81 | virtual void DestroyClippingRegion(); | |
82 | ||
83 | virtual wxCoord GetCharHeight() const; | |
84 | virtual wxCoord GetCharWidth() const; | |
85 | virtual void DoGetTextExtent(const wxString& string, | |
86 | wxCoord *x, wxCoord *y, | |
87 | wxCoord *descent = NULL, | |
88 | wxCoord *externalLeading = NULL, | |
89 | wxFont *theFont = NULL) const; | |
90 | virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const; | |
91 | ||
92 | virtual bool CanDrawBitmap() const; | |
93 | virtual bool CanGetTextExtent() const; | |
94 | virtual int GetDepth() const; | |
95 | virtual wxSize GetPPI() const; | |
96 | ||
97 | virtual void SetMapMode(int mode); | |
98 | virtual void SetUserScale(double x, double y); | |
99 | ||
100 | virtual void SetLogicalScale(double x, double y); | |
101 | virtual void SetLogicalOrigin(wxCoord x, wxCoord y); | |
102 | virtual void SetDeviceOrigin(wxCoord x, wxCoord y); | |
103 | virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp); | |
104 | virtual void SetLogicalFunction(int function); | |
105 | ||
106 | virtual void SetTextForeground(const wxColour& colour) ; | |
107 | virtual void SetTextBackground(const wxColour& colour) ; | |
108 | ||
b1263dcf | 109 | virtual void ComputeScaleAndOrigin(); |
c5789d15 | 110 | |
b1263dcf | 111 | public: |
c5789d15 | 112 | |
8cf73271 SC |
113 | wxCoord XDEV2LOG(wxCoord x) const |
114 | { | |
115 | long new_x = x - m_deviceOriginX ; | |
116 | if (new_x > 0) | |
117 | return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX; | |
118 | else | |
119 | return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX; | |
120 | } | |
121 | wxCoord XDEV2LOGREL(wxCoord x) const | |
c5789d15 | 122 | { |
8cf73271 SC |
123 | if (x > 0) |
124 | return (wxCoord)((double)(x) / m_scaleX + 0.5); | |
125 | else | |
126 | return (wxCoord)((double)(x) / m_scaleX - 0.5); | |
127 | } | |
128 | wxCoord YDEV2LOG(wxCoord y) const | |
129 | { | |
130 | long new_y = y - m_deviceOriginY ; | |
131 | if (new_y > 0) | |
132 | return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY; | |
133 | else | |
134 | return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY; | |
135 | } | |
136 | wxCoord YDEV2LOGREL(wxCoord y) const | |
c5789d15 | 137 | { |
8cf73271 SC |
138 | if (y > 0) |
139 | return (wxCoord)((double)(y) / m_scaleY + 0.5); | |
140 | else | |
141 | return (wxCoord)((double)(y) / m_scaleY - 0.5); | |
142 | } | |
143 | wxCoord XLOG2DEV(wxCoord x) const | |
c5789d15 | 144 | { |
8cf73271 SC |
145 | long new_x = x - m_logicalOriginX; |
146 | if (new_x > 0) | |
147 | return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX ; | |
148 | else | |
149 | return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX ; | |
150 | } | |
151 | wxCoord XLOG2DEVREL(wxCoord x) const | |
c5789d15 | 152 | { |
8cf73271 SC |
153 | if (x > 0) |
154 | return (wxCoord)((double)(x) * m_scaleX + 0.5); | |
155 | else | |
156 | return (wxCoord)((double)(x) * m_scaleX - 0.5); | |
157 | } | |
158 | wxCoord YLOG2DEV(wxCoord y) const | |
159 | { | |
160 | long new_y = y - m_logicalOriginY ; | |
161 | if (new_y > 0) | |
162 | return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY ; | |
163 | else | |
164 | return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY ; | |
165 | } | |
166 | wxCoord YLOG2DEVREL(wxCoord y) const | |
c5789d15 | 167 | { |
8cf73271 SC |
168 | if (y > 0) |
169 | return (wxCoord)((double)(y) * m_scaleY + 0.5); | |
170 | else | |
171 | return (wxCoord)((double)(y) * m_scaleY - 0.5); | |
172 | } | |
173 | wxCoord XLOG2DEVMAC(wxCoord x) const | |
c5789d15 | 174 | { |
8cf73271 SC |
175 | long new_x = x - m_logicalOriginX; |
176 | if (new_x > 0) | |
177 | return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX + m_macLocalOrigin.x ; | |
178 | else | |
179 | return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX + m_macLocalOrigin.x ; | |
180 | } | |
181 | wxCoord YLOG2DEVMAC(wxCoord y) const | |
182 | { | |
183 | long new_y = y - m_logicalOriginY ; | |
184 | if (new_y > 0) | |
185 | return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY + m_macLocalOrigin.y ; | |
186 | else | |
187 | return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY + m_macLocalOrigin.y ; | |
188 | } | |
189 | ||
190 | WXHRGN MacGetCurrentClipRgn() { return m_macCurrentClipRgn ; } | |
191 | static void MacSetupBackgroundForCurrentPort(const wxBrush& background ) ; | |
192 | // | |
193 | ||
194 | protected: | |
195 | virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, | |
196 | int style = wxFLOOD_SURFACE); | |
197 | ||
198 | virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const; | |
199 | ||
200 | virtual void DoDrawPoint(wxCoord x, wxCoord y); | |
201 | virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); | |
202 | ||
203 | virtual void DoDrawArc(wxCoord x1, wxCoord y1, | |
204 | wxCoord x2, wxCoord y2, | |
205 | wxCoord xc, wxCoord yc); | |
c5789d15 | 206 | |
8cf73271 SC |
207 | virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, |
208 | double sa, double ea); | |
209 | ||
210 | virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
211 | virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y, | |
212 | wxCoord width, wxCoord height, | |
213 | double radius); | |
214 | virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
215 | ||
216 | virtual void DoCrossHair(wxCoord x, wxCoord y); | |
217 | ||
218 | virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y); | |
219 | virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, | |
b1263dcf | 220 | bool useMask = false); |
8cf73271 SC |
221 | |
222 | virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y); | |
223 | virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, | |
224 | double angle); | |
225 | ||
226 | virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, | |
227 | wxDC *source, wxCoord xsrc, wxCoord ysrc, | |
b1263dcf | 228 | int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1); |
8cf73271 SC |
229 | |
230 | // this is gnarly - we can't even call this function DoSetClippingRegion() | |
231 | // because of virtual function hiding | |
232 | virtual void DoSetClippingRegionAsRegion(const wxRegion& region); | |
233 | virtual void DoSetClippingRegion(wxCoord x, wxCoord y, | |
234 | wxCoord width, wxCoord height); | |
8cf73271 SC |
235 | |
236 | virtual void DoGetSizeMM(int* width, int* height) const; | |
237 | ||
238 | virtual void DoDrawLines(int n, wxPoint points[], | |
239 | wxCoord xoffset, wxCoord yoffset); | |
240 | virtual void DoDrawPolygon(int n, wxPoint points[], | |
241 | wxCoord xoffset, wxCoord yoffset, | |
242 | int fillStyle = wxODDEVEN_RULE); | |
243 | ||
244 | protected: | |
245 | //begin wxmac | |
246 | // Variables used for scaling | |
c5789d15 | 247 | double m_mm_to_pix_x,m_mm_to_pix_y; |
8cf73271 | 248 | // not yet used |
c5789d15 | 249 | bool m_needComputeScaleX,m_needComputeScaleY; |
8cf73271 SC |
250 | // If un-scrolled is non-zero or d.o. changes with scrolling. |
251 | // Set using SetInternalDeviceOrigin(). | |
252 | long m_internalDeviceOriginX,m_internalDeviceOriginY; | |
253 | // To be set by external classes such as wxScrolledWindow | |
254 | // using SetDeviceOrigin() | |
255 | long m_externalDeviceOriginX,m_externalDeviceOriginY; | |
c5789d15 | 256 | |
8cf73271 SC |
257 | // Begin implementation for Mac |
258 | public: | |
c5789d15 | 259 | |
8cf73271 SC |
260 | WXHDC m_macPort ; |
261 | WXHBITMAP m_macMask ; | |
262 | ||
c5789d15 | 263 | // in order to preserve the const inheritance of the virtual functions, we have to |
8cf73271 SC |
264 | // use mutable variables starting from CWPro 5 |
265 | ||
266 | void MacInstallFont() const ; | |
267 | void MacInstallPen() const ; | |
268 | void MacInstallBrush() const ; | |
269 | ||
270 | mutable bool m_macFontInstalled ; | |
271 | mutable bool m_macPenInstalled ; | |
272 | mutable bool m_macBrushInstalled ; | |
273 | ||
274 | WXHRGN m_macBoundaryClipRgn ; | |
275 | WXHRGN m_macCurrentClipRgn ; | |
276 | wxPoint m_macLocalOrigin ; | |
277 | void MacSetupPort( wxMacPortStateHelper* ph ) const ; | |
278 | void MacCleanupPort( wxMacPortStateHelper* ph ) const ; | |
279 | mutable void* m_macATSUIStyle ; | |
280 | mutable wxMacPortStateHelper* m_macCurrentPortStateHelper ; | |
281 | mutable bool m_macFormerAliasState ; | |
282 | mutable short m_macFormerAliasSize ; | |
283 | mutable bool m_macAliasWasEnabled ; | |
284 | mutable void* m_macForegroundPixMap ; | |
285 | mutable void* m_macBackgroundPixMap ; | |
613a24f7 SC |
286 | |
287 | // CoreGraphics | |
288 | ||
289 | wxMacCGContext * m_macGraphicContext ; | |
290 | void MacSetupGraphicContext() ; | |
8cf73271 SC |
291 | }; |
292 | ||
293 | #endif | |
294 | // _WX_DC_H_ |