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