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