]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/dc.h
not needed anymore
[wxWidgets.git] / include / wx / mac / dc.h
CommitLineData
0dbd6262
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: dc.h
3// Purpose: wxDC class
4// Author: AUTHOR
5// Modified by:
6// Created: ??/??/98
7// RCS-ID: $Id$
8// Copyright: (c) AUTHOR
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_DC_H_
13#define _WX_DC_H_
14
af49c4b8 15#if defined(__GNUG__) && !defined(__APPLE__)
0dbd6262
SC
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
5273bf2f 46class wxMacPortStateHelper ;
0dbd6262
SC
47//-----------------------------------------------------------------------------
48// wxDC
49//-----------------------------------------------------------------------------
50
05adb9d2 51class WXDLLEXPORT wxDC: public wxDCBase
0dbd6262 52{
be52b341
GD
53 DECLARE_DYNAMIC_CLASS(wxDC)
54 DECLARE_NO_COPY_CLASS(wxDC)
0dbd6262
SC
55
56 public:
57
05adb9d2
SC
58 wxDC();
59 ~wxDC();
0dbd6262 60
05adb9d2
SC
61
62 // implement base class pure virtuals
63 // ----------------------------------
64
65 virtual void Clear();
66
3dec57ad 67 virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return TRUE; }
05adb9d2
SC
68 virtual void EndDoc(void) {};
69
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
90 virtual bool CanDrawBitmap() const;
91 virtual bool CanGetTextExtent() const;
92 virtual int GetDepth() const;
93 virtual wxSize GetPPI() const;
94
95 virtual void SetMapMode(int mode);
96 virtual void SetUserScale(double x, double y);
97
98 virtual void SetLogicalScale(double x, double y);
99 virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
100 virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
101 virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
102 virtual void SetLogicalFunction(int function);
103
104 virtual void SetTextForeground(const wxColour& colour) ;
105 virtual void SetTextBackground(const wxColour& colour) ;
106
0dbd6262 107 void ComputeScaleAndOrigin(void);
05adb9d2
SC
108 public:
109
0dbd6262 110
03e11df5 111 wxCoord XDEV2LOG(wxCoord x) const
0dbd6262 112 {
5b36f53b 113 long new_x = x - m_deviceOriginX ;
0dbd6262 114 if (new_x > 0)
03e11df5 115 return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX;
0dbd6262 116 else
03e11df5 117 return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX;
0dbd6262 118 }
03e11df5 119 wxCoord XDEV2LOGREL(wxCoord x) const
0dbd6262
SC
120 {
121 if (x > 0)
03e11df5 122 return (wxCoord)((double)(x) / m_scaleX + 0.5);
0dbd6262 123 else
03e11df5 124 return (wxCoord)((double)(x) / m_scaleX - 0.5);
0dbd6262 125 }
03e11df5 126 wxCoord YDEV2LOG(wxCoord y) const
0dbd6262 127 {
5b36f53b 128 long new_y = y - m_deviceOriginY ;
0dbd6262 129 if (new_y > 0)
03e11df5 130 return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY;
0dbd6262 131 else
03e11df5 132 return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY;
0dbd6262 133 }
03e11df5 134 wxCoord YDEV2LOGREL(wxCoord y) const
0dbd6262
SC
135 {
136 if (y > 0)
03e11df5 137 return (wxCoord)((double)(y) / m_scaleY + 0.5);
0dbd6262 138 else
03e11df5 139 return (wxCoord)((double)(y) / m_scaleY - 0.5);
0dbd6262 140 }
03e11df5 141 wxCoord XLOG2DEV(wxCoord x) const
0dbd6262
SC
142 {
143 long new_x = x - m_logicalOriginX;
144 if (new_x > 0)
5b36f53b 145 return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX ;
0dbd6262 146 else
5b36f53b 147 return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX ;
0dbd6262 148 }
03e11df5 149 wxCoord XLOG2DEVREL(wxCoord x) const
0dbd6262
SC
150 {
151 if (x > 0)
03e11df5 152 return (wxCoord)((double)(x) * m_scaleX + 0.5);
0dbd6262 153 else
03e11df5 154 return (wxCoord)((double)(x) * m_scaleX - 0.5);
0dbd6262 155 }
03e11df5 156 wxCoord YLOG2DEV(wxCoord y) const
0dbd6262 157 {
5b36f53b 158 long new_y = y - m_logicalOriginY ;
0dbd6262 159 if (new_y > 0)
5b36f53b 160 return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY ;
0dbd6262 161 else
5b36f53b 162 return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY ;
0dbd6262 163 }
03e11df5 164 wxCoord YLOG2DEVREL(wxCoord y) const
0dbd6262
SC
165 {
166 if (y > 0)
03e11df5 167 return (wxCoord)((double)(y) * m_scaleY + 0.5);
0dbd6262 168 else
03e11df5 169 return (wxCoord)((double)(y) * m_scaleY - 0.5);
0dbd6262 170 }
5b36f53b
SC
171 wxCoord XLOG2DEVMAC(wxCoord x) const
172 {
173 long new_x = x - m_logicalOriginX;
174 if (new_x > 0)
5273bf2f 175 return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX + m_macLocalOrigin.x ;
5b36f53b 176 else
5273bf2f 177 return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX + m_macLocalOrigin.x ;
5b36f53b
SC
178 }
179 wxCoord YLOG2DEVMAC(wxCoord y) const
180 {
181 long new_y = y - m_logicalOriginY ;
182 if (new_y > 0)
5273bf2f 183 return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY + m_macLocalOrigin.y ;
5b36f53b 184 else
5273bf2f 185 return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY + m_macLocalOrigin.y ;
5b36f53b 186 }
0dbd6262 187
5273bf2f 188 WXHRGN MacGetCurrentClipRgn() { return m_macCurrentClipRgn ; }
5b36f53b 189 static void MacSetupBackgroundForCurrentPort(const wxBrush& background ) ;
05adb9d2
SC
190//
191
192protected:
387ebd3e 193 virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
05adb9d2
SC
194 int style = wxFLOOD_SURFACE);
195
196 virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const;
197
198 virtual void DoDrawPoint(wxCoord x, wxCoord y);
199 virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
200
201 virtual void DoDrawArc(wxCoord x1, wxCoord y1,
202 wxCoord x2, wxCoord y2,
203 wxCoord xc, wxCoord yc);
204
205 virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
206 double sa, double ea);
207
208 virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
209 virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
210 wxCoord width, wxCoord height,
211 double radius);
212 virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
213
214 virtual void DoCrossHair(wxCoord x, wxCoord y);
215
216 virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
217 virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
218 bool useMask = FALSE);
219
220 virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y);
221 virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
222 double angle);
223
224 virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
225 wxDC *source, wxCoord xsrc, wxCoord ysrc,
0cbff120 226 int rop = wxCOPY, bool useMask = FALSE, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
05adb9d2
SC
227
228 // this is gnarly - we can't even call this function DoSetClippingRegion()
229 // because of virtual function hiding
230 virtual void DoSetClippingRegionAsRegion(const wxRegion& region);
231 virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
232 wxCoord width, wxCoord height);
233 virtual void DoGetClippingRegion(wxCoord *x, wxCoord *y,
234 wxCoord *width, wxCoord *height)
235 {
236 GetClippingBox(x, y, width, height);
237 }
238
239 virtual void DoGetSize(int *width, int *height) const;
240 virtual void DoGetSizeMM(int* width, int* height) const;
241
242 virtual void DoDrawLines(int n, wxPoint points[],
243 wxCoord xoffset, wxCoord yoffset);
244 virtual void DoDrawPolygon(int n, wxPoint points[],
245 wxCoord xoffset, wxCoord yoffset,
246 int fillStyle = wxODDEVEN_RULE);
247
3dec57ad
SC
248 protected:
249 //begin wxmac
250 // Variables used for scaling
0dbd6262 251 double m_mm_to_pix_x,m_mm_to_pix_y;
3dec57ad
SC
252 // not yet used
253 bool m_needComputeScaleX,m_needComputeScaleY;
254 // If un-scrolled is non-zero or d.o. changes with scrolling.
255 // Set using SetInternalDeviceOrigin().
256 long m_internalDeviceOriginX,m_internalDeviceOriginY;
257 // To be set by external classes such as wxScrolledWindow
258 // using SetDeviceOrigin()
259 long m_externalDeviceOriginX,m_externalDeviceOriginY;
260
261 // Begin implementation for Mac
262 public:
0dbd6262 263
5273bf2f
SC
264 WXHDC m_macPort ;
265 WXHBITMAP m_macMask ;
519cb848
SC
266
267 // in order to preserve the const inheritance of the virtual functions, we have to
268 // use mutable variables starting from CWPro 5
269
270 void MacInstallFont() const ;
271 void MacInstallPen() const ;
272 void MacInstallBrush() const ;
273
274 mutable bool m_macFontInstalled ;
275 mutable bool m_macPenInstalled ;
276 mutable bool m_macBrushInstalled ;
277
477594f7
SC
278 WXHRGN m_macBoundaryClipRgn ;
279 WXHRGN m_macCurrentClipRgn ;
5273bf2f
SC
280 wxPoint m_macLocalOrigin ;
281 void MacSetupPort( wxMacPortStateHelper* ph ) const ;
477594f7
SC
282 void MacCleanupPort( wxMacPortStateHelper* ph ) const ;
283 mutable void* m_macATSUIStyle ;
284 mutable wxMacPortStateHelper* m_macCurrentPortStateHelper ;
285 mutable bool m_macFormerAliasState ;
286 mutable short m_macFormerAliasSize ;
287 mutable bool m_macAliasWasEnabled ;
288 mutable void* m_macForegroundPixMap ;
289 mutable void* m_macBackgroundPixMap ;
0dbd6262
SC
290};
291
292#endif
293 // _WX_DC_H_