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