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