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