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