]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/dc.h
Added possibility of 2-step initialisation, and wxWIZARD_EX_HELPBUTTON style.
[wxWidgets.git] / include / wx / mac / dc.h
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"
24 #include "wx/mac/aga.h"
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
45 extern int wxPageNumber;
46
47 //-----------------------------------------------------------------------------
48 // wxDC
49 //-----------------------------------------------------------------------------
50
51 class WXDLLEXPORT wxMacPortSetter
52 {
53 public :
54 wxMacPortSetter( const wxDC* dc ) ;
55 ~wxMacPortSetter() ;
56 private :
57 AGAPortHelper m_ph ;
58 } ;
59
60 class WXDLLEXPORT wxDC: public wxDCBase
61 {
62 DECLARE_DYNAMIC_CLASS(wxDC)
63
64 public:
65
66 wxDC();
67 ~wxDC();
68
69
70 // implement base class pure virtuals
71 // ----------------------------------
72
73 virtual void Clear();
74
75 virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return TRUE; }
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
115 void ComputeScaleAndOrigin(void);
116 public:
117
118
119 wxCoord XDEV2LOG(wxCoord x) const
120 {
121 long new_x = x - m_deviceOriginX;
122 if (new_x > 0)
123 return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX;
124 else
125 return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX;
126 }
127 wxCoord XDEV2LOGREL(wxCoord x) const
128 {
129 if (x > 0)
130 return (wxCoord)((double)(x) / m_scaleX + 0.5);
131 else
132 return (wxCoord)((double)(x) / m_scaleX - 0.5);
133 }
134 wxCoord YDEV2LOG(wxCoord y) const
135 {
136 long new_y = y - m_deviceOriginY;
137 if (new_y > 0)
138 return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY;
139 else
140 return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY;
141 }
142 wxCoord YDEV2LOGREL(wxCoord y) const
143 {
144 if (y > 0)
145 return (wxCoord)((double)(y) / m_scaleY + 0.5);
146 else
147 return (wxCoord)((double)(y) / m_scaleY - 0.5);
148 }
149 wxCoord XLOG2DEV(wxCoord x) const
150 {
151 long new_x = x - m_logicalOriginX;
152 if (new_x > 0)
153 return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX;
154 else
155 return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX;
156 }
157 wxCoord XLOG2DEVREL(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 YLOG2DEV(wxCoord y) const
165 {
166 long new_y = y - m_logicalOriginY;
167 if (new_y > 0)
168 return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY;
169 else
170 return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY;
171 }
172 wxCoord YLOG2DEVREL(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
180 //
181
182 protected:
183 virtual void DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
184 int style = wxFLOOD_SURFACE);
185
186 virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const;
187
188 virtual void DoDrawPoint(wxCoord x, wxCoord y);
189 virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
190
191 virtual void DoDrawArc(wxCoord x1, wxCoord y1,
192 wxCoord x2, wxCoord y2,
193 wxCoord xc, wxCoord yc);
194
195 virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
196 double sa, double ea);
197
198 virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
199 virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
200 wxCoord width, wxCoord height,
201 double radius);
202 virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
203
204 virtual void DoCrossHair(wxCoord x, wxCoord y);
205
206 virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
207 virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
208 bool useMask = FALSE);
209
210 virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y);
211 virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
212 double angle);
213
214 virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
215 wxDC *source, wxCoord xsrc, wxCoord ysrc,
216 int rop = wxCOPY, bool useMask = FALSE, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
217
218 // this is gnarly - we can't even call this function DoSetClippingRegion()
219 // because of virtual function hiding
220 virtual void DoSetClippingRegionAsRegion(const wxRegion& region);
221 virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
222 wxCoord width, wxCoord height);
223 virtual void DoGetClippingRegion(wxCoord *x, wxCoord *y,
224 wxCoord *width, wxCoord *height)
225 {
226 GetClippingBox(x, y, width, height);
227 }
228
229 virtual void DoGetSize(int *width, int *height) const;
230 virtual void DoGetSizeMM(int* width, int* height) const;
231
232 virtual void DoDrawLines(int n, wxPoint points[],
233 wxCoord xoffset, wxCoord yoffset);
234 virtual void DoDrawPolygon(int n, wxPoint points[],
235 wxCoord xoffset, wxCoord yoffset,
236 int fillStyle = wxODDEVEN_RULE);
237
238 protected:
239 //begin wxmac
240 // Variables used for scaling
241 double m_mm_to_pix_x,m_mm_to_pix_y;
242 // not yet used
243 bool m_needComputeScaleX,m_needComputeScaleY;
244 // If un-scrolled is non-zero or d.o. changes with scrolling.
245 // Set using SetInternalDeviceOrigin().
246 long m_internalDeviceOriginX,m_internalDeviceOriginY;
247 // To be set by external classes such as wxScrolledWindow
248 // using SetDeviceOrigin()
249 long m_externalDeviceOriginX,m_externalDeviceOriginY;
250
251 // Begin implementation for Mac
252 public:
253
254 GrafPtr m_macPort ;
255 GWorldPtr m_macMask ;
256
257 // in order to preserve the const inheritance of the virtual functions, we have to
258 // use mutable variables starting from CWPro 5
259
260 void MacInstallFont() const ;
261 void MacInstallPen() const ;
262 void MacInstallBrush() const ;
263
264 mutable bool m_macFontInstalled ;
265 mutable bool m_macPenInstalled ;
266 mutable bool m_macBrushInstalled ;
267
268 Rect m_macClipRect ;
269 Point m_macLocalOrigin ;
270 void MacSetupPort( AGAPortHelper* ph ) const ;
271 };
272
273 #endif
274 // _WX_DC_H_