]>
Commit | Line | Data |
---|---|---|
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 | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_DC_H_ | |
13 | #define _WX_DC_H_ | |
14 | ||
15 | #include "wx/pen.h" | |
16 | #include "wx/brush.h" | |
17 | #include "wx/icon.h" | |
18 | #include "wx/font.h" | |
19 | #include "wx/gdicmn.h" | |
20 | ||
21 | //----------------------------------------------------------------------------- | |
22 | // constants | |
23 | //----------------------------------------------------------------------------- | |
24 | ||
25 | #ifndef MM_TEXT | |
26 | #define MM_TEXT 0 | |
27 | #define MM_ISOTROPIC 1 | |
28 | #define MM_ANISOTROPIC 2 | |
29 | #define MM_LOMETRIC 3 | |
30 | #define MM_HIMETRIC 4 | |
31 | #define MM_TWIPS 5 | |
32 | #define MM_POINTS 6 | |
33 | #define MM_METRIC 7 | |
34 | #endif | |
35 | ||
36 | //----------------------------------------------------------------------------- | |
37 | // global variables | |
38 | //----------------------------------------------------------------------------- | |
39 | ||
40 | class wxMacPortStateHelper ; | |
41 | //----------------------------------------------------------------------------- | |
42 | // wxDC | |
43 | //----------------------------------------------------------------------------- | |
44 | ||
45 | class WXDLLEXPORT wxDC: public wxDCBase | |
46 | { | |
47 | DECLARE_DYNAMIC_CLASS(wxDC) | |
48 | DECLARE_NO_COPY_CLASS(wxDC) | |
49 | ||
50 | public: | |
51 | ||
52 | wxDC(); | |
53 | virtual ~wxDC(); | |
54 | ||
55 | ||
56 | // implement base class pure virtuals | |
57 | // ---------------------------------- | |
58 | ||
59 | virtual void Clear(); | |
60 | ||
61 | virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return true; } | |
62 | virtual void EndDoc(void) {}; | |
63 | ||
64 | virtual void StartPage(void) {}; | |
65 | virtual void EndPage(void) {}; | |
66 | ||
67 | virtual void SetFont(const wxFont& font); | |
68 | virtual void SetPen(const wxPen& pen); | |
69 | virtual void SetBrush(const wxBrush& brush); | |
70 | virtual void SetBackground(const wxBrush& brush); | |
71 | virtual void SetBackgroundMode(int mode); | |
72 | virtual void SetPalette(const wxPalette& palette); | |
73 | ||
74 | virtual void DestroyClippingRegion(); | |
75 | ||
76 | virtual wxCoord GetCharHeight() const; | |
77 | virtual wxCoord GetCharWidth() const; | |
78 | virtual void DoGetTextExtent(const wxString& string, | |
79 | wxCoord *x, wxCoord *y, | |
80 | wxCoord *descent = NULL, | |
81 | wxCoord *externalLeading = NULL, | |
82 | wxFont *theFont = NULL) const; | |
83 | virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const; | |
84 | ||
85 | virtual bool CanDrawBitmap() const; | |
86 | virtual bool CanGetTextExtent() const; | |
87 | virtual int GetDepth() const; | |
88 | virtual wxSize GetPPI() const; | |
89 | ||
90 | virtual void SetMapMode(int mode); | |
91 | virtual void SetUserScale(double x, double y); | |
92 | ||
93 | virtual void SetLogicalScale(double x, double y); | |
94 | virtual void SetLogicalOrigin(wxCoord x, wxCoord y); | |
95 | virtual void SetDeviceOrigin(wxCoord x, wxCoord y); | |
96 | virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp); | |
97 | virtual void SetLogicalFunction(int function); | |
98 | ||
99 | virtual void SetTextForeground(const wxColour& colour) ; | |
100 | virtual void SetTextBackground(const wxColour& colour) ; | |
101 | ||
102 | virtual void ComputeScaleAndOrigin(); | |
103 | ||
104 | public: | |
105 | ||
106 | wxCoord XDEV2LOG(wxCoord x) const | |
107 | { | |
108 | return wxRound((double)(x - m_deviceOriginX) / m_scaleX) * m_signX + m_logicalOriginX; | |
109 | } | |
110 | wxCoord XDEV2LOGREL(wxCoord x) const | |
111 | { | |
112 | return wxRound((double)(x) / m_scaleX); | |
113 | } | |
114 | wxCoord YDEV2LOG(wxCoord y) const | |
115 | { | |
116 | return wxRound((double)(y - m_deviceOriginY) / m_scaleY) * m_signY + m_logicalOriginY; | |
117 | } | |
118 | wxCoord YDEV2LOGREL(wxCoord y) const | |
119 | { | |
120 | return wxRound((double)(y) / m_scaleY); | |
121 | } | |
122 | wxCoord XLOG2DEV(wxCoord x) const | |
123 | { | |
124 | return wxRound((double)(x - m_logicalOriginX) * m_scaleX) * m_signX + m_deviceOriginX; | |
125 | } | |
126 | wxCoord XLOG2DEVREL(wxCoord x) const | |
127 | { | |
128 | return wxRound((double)(x) * m_scaleX); | |
129 | } | |
130 | wxCoord YLOG2DEV(wxCoord y) const | |
131 | { | |
132 | return wxRound((double)(y - m_logicalOriginY) * m_scaleY) * m_signY + m_deviceOriginY; | |
133 | } | |
134 | wxCoord YLOG2DEVREL(wxCoord y) const | |
135 | { | |
136 | return wxRound((double)(y) * m_scaleY); | |
137 | } | |
138 | ||
139 | wxCoord XLOG2DEVMAC(wxCoord x) const | |
140 | { | |
141 | return wxRound((double)(x - m_logicalOriginX) * m_scaleX) * m_signX + m_deviceOriginX + m_macLocalOrigin.x; | |
142 | } | |
143 | ||
144 | wxCoord YLOG2DEVMAC(wxCoord y) const | |
145 | { | |
146 | return wxRound((double)(y - m_logicalOriginY) * m_scaleY) * m_signY + m_deviceOriginY + m_macLocalOrigin.y; | |
147 | } | |
148 | ||
149 | WXHRGN MacGetCurrentClipRgn() { return m_macCurrentClipRgn ; } | |
150 | static void MacSetupBackgroundForCurrentPort(const wxBrush& background ) ; | |
151 | // | |
152 | ||
153 | protected: | |
154 | virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, | |
155 | int style = wxFLOOD_SURFACE); | |
156 | ||
157 | virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const; | |
158 | ||
159 | virtual void DoDrawPoint(wxCoord x, wxCoord y); | |
160 | virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); | |
161 | ||
162 | virtual void DoDrawArc(wxCoord x1, wxCoord y1, | |
163 | wxCoord x2, wxCoord y2, | |
164 | wxCoord xc, wxCoord yc); | |
165 | ||
166 | virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, | |
167 | double sa, double ea); | |
168 | ||
169 | virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
170 | virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y, | |
171 | wxCoord width, wxCoord height, | |
172 | double radius); | |
173 | virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
174 | ||
175 | virtual void DoCrossHair(wxCoord x, wxCoord y); | |
176 | ||
177 | virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y); | |
178 | virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, | |
179 | bool useMask = false); | |
180 | ||
181 | virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y); | |
182 | virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, | |
183 | double angle); | |
184 | ||
185 | virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, | |
186 | wxDC *source, wxCoord xsrc, wxCoord ysrc, | |
187 | int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1); | |
188 | ||
189 | // this is gnarly - we can't even call this function DoSetClippingRegion() | |
190 | // because of virtual function hiding | |
191 | virtual void DoSetClippingRegionAsRegion(const wxRegion& region); | |
192 | virtual void DoSetClippingRegion(wxCoord x, wxCoord y, | |
193 | wxCoord width, wxCoord height); | |
194 | ||
195 | virtual void DoGetSizeMM(int* width, int* height) const; | |
196 | ||
197 | virtual void DoDrawLines(int n, wxPoint points[], | |
198 | wxCoord xoffset, wxCoord yoffset); | |
199 | virtual void DoDrawPolygon(int n, wxPoint points[], | |
200 | wxCoord xoffset, wxCoord yoffset, | |
201 | int fillStyle = wxODDEVEN_RULE); | |
202 | ||
203 | protected: | |
204 | //begin wxmac | |
205 | // Variables used for scaling | |
206 | double m_mm_to_pix_x,m_mm_to_pix_y; | |
207 | // not yet used | |
208 | bool m_needComputeScaleX,m_needComputeScaleY; | |
209 | // If un-scrolled is non-zero or d.o. changes with scrolling. | |
210 | // Set using SetInternalDeviceOrigin(). | |
211 | long m_internalDeviceOriginX,m_internalDeviceOriginY; | |
212 | // To be set by external classes such as wxScrolledWindow | |
213 | // using SetDeviceOrigin() | |
214 | long m_externalDeviceOriginX,m_externalDeviceOriginY; | |
215 | ||
216 | // Begin implementation for Mac | |
217 | public: | |
218 | ||
219 | WXHDC m_macPort ; | |
220 | WXHBITMAP m_macMask ; | |
221 | ||
222 | // in order to preserve the const inheritance of the virtual functions, we have to | |
223 | // use mutable variables starting from CWPro 5 | |
224 | ||
225 | void MacInstallFont() const ; | |
226 | void MacInstallPen() const ; | |
227 | void MacInstallBrush() const ; | |
228 | ||
229 | mutable bool m_macFontInstalled ; | |
230 | mutable bool m_macPenInstalled ; | |
231 | mutable bool m_macBrushInstalled ; | |
232 | ||
233 | WXHRGN m_macBoundaryClipRgn ; | |
234 | WXHRGN m_macCurrentClipRgn ; | |
235 | wxPoint m_macLocalOrigin ; | |
236 | void MacSetupPort( wxMacPortStateHelper* ph ) const ; | |
237 | void MacCleanupPort( wxMacPortStateHelper* ph ) const ; | |
238 | mutable void* m_macATSUIStyle ; | |
239 | mutable wxMacPortStateHelper* m_macCurrentPortStateHelper ; | |
240 | mutable bool m_macFormerAliasState ; | |
241 | mutable short m_macFormerAliasSize ; | |
242 | mutable bool m_macAliasWasEnabled ; | |
243 | mutable void* m_macForegroundPixMap ; | |
244 | mutable void* m_macBackgroundPixMap ; | |
245 | }; | |
246 | ||
247 | #endif | |
248 | // _WX_DC_H_ |