]>
Commit | Line | Data |
---|---|---|
0dbd6262 SC |
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 | #ifdef __GNUG__ | |
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 | ||
5273bf2f | 46 | class wxMacPortStateHelper ; |
0dbd6262 SC |
47 | //----------------------------------------------------------------------------- |
48 | // wxDC | |
49 | //----------------------------------------------------------------------------- | |
50 | ||
05adb9d2 | 51 | class WXDLLEXPORT wxDC: public wxDCBase |
0dbd6262 | 52 | { |
05adb9d2 | 53 | DECLARE_DYNAMIC_CLASS(wxDC) |
0dbd6262 SC |
54 | |
55 | public: | |
56 | ||
05adb9d2 SC |
57 | wxDC(); |
58 | ~wxDC(); | |
0dbd6262 | 59 | |
05adb9d2 SC |
60 | |
61 | // implement base class pure virtuals | |
62 | // ---------------------------------- | |
63 | ||
64 | virtual void Clear(); | |
65 | ||
3dec57ad | 66 | virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return TRUE; } |
05adb9d2 SC |
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 | ||
0dbd6262 | 106 | void ComputeScaleAndOrigin(void); |
05adb9d2 SC |
107 | public: |
108 | ||
0dbd6262 | 109 | |
03e11df5 | 110 | wxCoord XDEV2LOG(wxCoord x) const |
0dbd6262 | 111 | { |
5b36f53b | 112 | long new_x = x - m_deviceOriginX ; |
0dbd6262 | 113 | if (new_x > 0) |
03e11df5 | 114 | return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX; |
0dbd6262 | 115 | else |
03e11df5 | 116 | return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX; |
0dbd6262 | 117 | } |
03e11df5 | 118 | wxCoord XDEV2LOGREL(wxCoord x) const |
0dbd6262 SC |
119 | { |
120 | if (x > 0) | |
03e11df5 | 121 | return (wxCoord)((double)(x) / m_scaleX + 0.5); |
0dbd6262 | 122 | else |
03e11df5 | 123 | return (wxCoord)((double)(x) / m_scaleX - 0.5); |
0dbd6262 | 124 | } |
03e11df5 | 125 | wxCoord YDEV2LOG(wxCoord y) const |
0dbd6262 | 126 | { |
5b36f53b | 127 | long new_y = y - m_deviceOriginY ; |
0dbd6262 | 128 | if (new_y > 0) |
03e11df5 | 129 | return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY; |
0dbd6262 | 130 | else |
03e11df5 | 131 | return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY; |
0dbd6262 | 132 | } |
03e11df5 | 133 | wxCoord YDEV2LOGREL(wxCoord y) const |
0dbd6262 SC |
134 | { |
135 | if (y > 0) | |
03e11df5 | 136 | return (wxCoord)((double)(y) / m_scaleY + 0.5); |
0dbd6262 | 137 | else |
03e11df5 | 138 | return (wxCoord)((double)(y) / m_scaleY - 0.5); |
0dbd6262 | 139 | } |
03e11df5 | 140 | wxCoord XLOG2DEV(wxCoord x) const |
0dbd6262 SC |
141 | { |
142 | long new_x = x - m_logicalOriginX; | |
143 | if (new_x > 0) | |
5b36f53b | 144 | return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX ; |
0dbd6262 | 145 | else |
5b36f53b | 146 | return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX ; |
0dbd6262 | 147 | } |
03e11df5 | 148 | wxCoord XLOG2DEVREL(wxCoord x) const |
0dbd6262 SC |
149 | { |
150 | if (x > 0) | |
03e11df5 | 151 | return (wxCoord)((double)(x) * m_scaleX + 0.5); |
0dbd6262 | 152 | else |
03e11df5 | 153 | return (wxCoord)((double)(x) * m_scaleX - 0.5); |
0dbd6262 | 154 | } |
03e11df5 | 155 | wxCoord YLOG2DEV(wxCoord y) const |
0dbd6262 | 156 | { |
5b36f53b | 157 | long new_y = y - m_logicalOriginY ; |
0dbd6262 | 158 | if (new_y > 0) |
5b36f53b | 159 | return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY ; |
0dbd6262 | 160 | else |
5b36f53b | 161 | return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY ; |
0dbd6262 | 162 | } |
03e11df5 | 163 | wxCoord YLOG2DEVREL(wxCoord y) const |
0dbd6262 SC |
164 | { |
165 | if (y > 0) | |
03e11df5 | 166 | return (wxCoord)((double)(y) * m_scaleY + 0.5); |
0dbd6262 | 167 | else |
03e11df5 | 168 | return (wxCoord)((double)(y) * m_scaleY - 0.5); |
0dbd6262 | 169 | } |
5b36f53b SC |
170 | wxCoord XLOG2DEVMAC(wxCoord x) const |
171 | { | |
172 | long new_x = x - m_logicalOriginX; | |
173 | if (new_x > 0) | |
5273bf2f | 174 | return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX + m_macLocalOrigin.x ; |
5b36f53b | 175 | else |
5273bf2f | 176 | return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX + m_macLocalOrigin.x ; |
5b36f53b SC |
177 | } |
178 | wxCoord YLOG2DEVMAC(wxCoord y) const | |
179 | { | |
180 | long new_y = y - m_logicalOriginY ; | |
181 | if (new_y > 0) | |
5273bf2f | 182 | return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY + m_macLocalOrigin.y ; |
5b36f53b | 183 | else |
5273bf2f | 184 | return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY + m_macLocalOrigin.y ; |
5b36f53b | 185 | } |
0dbd6262 | 186 | |
5273bf2f | 187 | WXHRGN MacGetCurrentClipRgn() { return m_macCurrentClipRgn ; } |
5b36f53b | 188 | static void MacSetupBackgroundForCurrentPort(const wxBrush& background ) ; |
05adb9d2 SC |
189 | // |
190 | ||
191 | protected: | |
387ebd3e | 192 | virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, |
05adb9d2 SC |
193 | int style = wxFLOOD_SURFACE); |
194 | ||
195 | virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const; | |
196 | ||
197 | virtual void DoDrawPoint(wxCoord x, wxCoord y); | |
198 | virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); | |
199 | ||
200 | virtual void DoDrawArc(wxCoord x1, wxCoord y1, | |
201 | wxCoord x2, wxCoord y2, | |
202 | wxCoord xc, wxCoord yc); | |
203 | ||
204 | virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, | |
205 | double sa, double ea); | |
206 | ||
207 | virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
208 | virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y, | |
209 | wxCoord width, wxCoord height, | |
210 | double radius); | |
211 | virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
212 | ||
213 | virtual void DoCrossHair(wxCoord x, wxCoord y); | |
214 | ||
215 | virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y); | |
216 | virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, | |
217 | bool useMask = FALSE); | |
218 | ||
219 | virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y); | |
220 | virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, | |
221 | double angle); | |
222 | ||
223 | virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, | |
224 | wxDC *source, wxCoord xsrc, wxCoord ysrc, | |
0cbff120 | 225 | int rop = wxCOPY, bool useMask = FALSE, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1); |
05adb9d2 SC |
226 | |
227 | // this is gnarly - we can't even call this function DoSetClippingRegion() | |
228 | // because of virtual function hiding | |
229 | virtual void DoSetClippingRegionAsRegion(const wxRegion& region); | |
230 | virtual void DoSetClippingRegion(wxCoord x, wxCoord y, | |
231 | wxCoord width, wxCoord height); | |
232 | virtual void DoGetClippingRegion(wxCoord *x, wxCoord *y, | |
233 | wxCoord *width, wxCoord *height) | |
234 | { | |
235 | GetClippingBox(x, y, width, height); | |
236 | } | |
237 | ||
238 | virtual void DoGetSize(int *width, int *height) const; | |
239 | virtual void DoGetSizeMM(int* width, int* height) const; | |
240 | ||
241 | virtual void DoDrawLines(int n, wxPoint points[], | |
242 | wxCoord xoffset, wxCoord yoffset); | |
243 | virtual void DoDrawPolygon(int n, wxPoint points[], | |
244 | wxCoord xoffset, wxCoord yoffset, | |
245 | int fillStyle = wxODDEVEN_RULE); | |
246 | ||
3dec57ad SC |
247 | protected: |
248 | //begin wxmac | |
249 | // Variables used for scaling | |
0dbd6262 | 250 | double m_mm_to_pix_x,m_mm_to_pix_y; |
3dec57ad SC |
251 | // not yet used |
252 | bool m_needComputeScaleX,m_needComputeScaleY; | |
253 | // If un-scrolled is non-zero or d.o. changes with scrolling. | |
254 | // Set using SetInternalDeviceOrigin(). | |
255 | long m_internalDeviceOriginX,m_internalDeviceOriginY; | |
256 | // To be set by external classes such as wxScrolledWindow | |
257 | // using SetDeviceOrigin() | |
258 | long m_externalDeviceOriginX,m_externalDeviceOriginY; | |
259 | ||
260 | // Begin implementation for Mac | |
261 | public: | |
0dbd6262 | 262 | |
5273bf2f SC |
263 | WXHDC m_macPort ; |
264 | WXHBITMAP m_macMask ; | |
519cb848 SC |
265 | |
266 | // in order to preserve the const inheritance of the virtual functions, we have to | |
267 | // use mutable variables starting from CWPro 5 | |
268 | ||
269 | void MacInstallFont() const ; | |
270 | void MacInstallPen() const ; | |
271 | void MacInstallBrush() const ; | |
272 | ||
273 | mutable bool m_macFontInstalled ; | |
274 | mutable bool m_macPenInstalled ; | |
275 | mutable bool m_macBrushInstalled ; | |
276 | ||
477594f7 SC |
277 | WXHRGN m_macBoundaryClipRgn ; |
278 | WXHRGN m_macCurrentClipRgn ; | |
5273bf2f SC |
279 | wxPoint m_macLocalOrigin ; |
280 | void MacSetupPort( wxMacPortStateHelper* ph ) const ; | |
477594f7 SC |
281 | void MacCleanupPort( wxMacPortStateHelper* ph ) const ; |
282 | mutable void* m_macATSUIStyle ; | |
283 | mutable wxMacPortStateHelper* m_macCurrentPortStateHelper ; | |
284 | mutable bool m_macFormerAliasState ; | |
285 | mutable short m_macFormerAliasSize ; | |
286 | mutable bool m_macAliasWasEnabled ; | |
287 | mutable void* m_macForegroundPixMap ; | |
288 | mutable void* m_macBackgroundPixMap ; | |
0dbd6262 SC |
289 | }; |
290 | ||
291 | #endif | |
292 | // _WX_DC_H_ |