]>
Commit | Line | Data |
---|---|---|
2bda0e17 KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: dc.h | |
3 | // Purpose: wxDC class | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
bbcdf8bc | 8 | // Copyright: (c) Julian Smart |
a23fd0e1 | 9 | // Licence: wxWindows licence |
2bda0e17 KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
bbcdf8bc JS |
12 | #ifndef _WX_DC_H_ |
13 | #define _WX_DC_H_ | |
2bda0e17 KB |
14 | |
15 | #ifdef __GNUG__ | |
a23fd0e1 | 16 | #pragma interface "dc.h" |
2bda0e17 KB |
17 | #endif |
18 | ||
2662e49e RR |
19 | #include "wx/defs.h" |
20 | #include "wx/dc.h" | |
21 | ||
e6f1ad22 HH |
22 | // --------------------------------------------------------------------------- |
23 | // macros | |
24 | // --------------------------------------------------------------------------- | |
25 | ||
26 | // Logical to device | |
27 | // Absolute | |
28 | #define XLOG2DEV(x) (x) | |
29 | #define YLOG2DEV(y) (y) | |
30 | ||
31 | // Relative | |
32 | #define XLOG2DEVREL(x) (x) | |
33 | #define YLOG2DEVREL(y) (y) | |
34 | ||
35 | // Device to logical | |
36 | // Absolute | |
37 | #define XDEV2LOG(x) (x) | |
38 | ||
39 | #define YDEV2LOG(y) (y) | |
40 | ||
41 | // Relative | |
42 | #define XDEV2LOGREL(x) (x) | |
43 | #define YDEV2LOGREL(y) (y) | |
44 | ||
45 | /* | |
46 | * Have the same macros as for XView but not for every operation: | |
47 | * just for calculating window/viewport extent (a better way of scaling). | |
48 | */ | |
49 | ||
50 | // Logical to device | |
51 | // Absolute | |
52 | #define MS_XLOG2DEV(x) LogicalToDevice(x) | |
53 | ||
54 | #define MS_YLOG2DEV(y) LogicalToDevice(y) | |
55 | ||
56 | // Relative | |
57 | #define MS_XLOG2DEVREL(x) LogicalToDeviceXRel(x) | |
58 | #define MS_YLOG2DEVREL(y) LogicalToDeviceYRel(y) | |
59 | ||
60 | // Device to logical | |
61 | // Absolute | |
62 | #define MS_XDEV2LOG(x) DeviceToLogicalX(x) | |
63 | ||
64 | #define MS_YDEV2LOG(y) DeviceToLogicalY(y) | |
65 | ||
66 | // Relative | |
67 | #define MS_XDEV2LOGREL(x) DeviceToLogicalXRel(x) | |
68 | #define MS_YDEV2LOGREL(y) DeviceToLogicalYRel(y) | |
69 | ||
70 | #define YSCALE(y) (yorigin - (y)) | |
71 | ||
72 | #define wx_round(a) (int)((a)+.5) | |
73 | ||
a23fd0e1 | 74 | class WXDLLEXPORT wxDC : public wxDCBase |
2bda0e17 | 75 | { |
2bda0e17 | 76 | public: |
a23fd0e1 VZ |
77 | wxDC(); |
78 | ~wxDC(); | |
79 | ||
80 | // implement base class pure virtuals | |
81 | // ---------------------------------- | |
82 | ||
83 | virtual void Clear(); | |
84 | ||
85 | virtual bool StartDoc(const wxString& message); | |
86 | virtual void EndDoc(); | |
87 | ||
88 | virtual void StartPage(); | |
89 | virtual void EndPage(); | |
90 | ||
91 | virtual void SetFont(const wxFont& font); | |
92 | virtual void SetPen(const wxPen& pen); | |
93 | virtual void SetBrush(const wxBrush& brush); | |
94 | virtual void SetBackground(const wxBrush& brush); | |
95 | virtual void SetBackgroundMode(int mode); | |
96 | virtual void SetPalette(const wxPalette& palette); | |
97 | ||
98 | virtual void DestroyClippingRegion(); | |
99 | ||
72cdf4c9 VZ |
100 | virtual wxCoord GetCharHeight() const; |
101 | virtual wxCoord GetCharWidth() const; | |
102 | virtual void DoGetTextExtent(const wxString& string, | |
103 | wxCoord *x, wxCoord *y, | |
104 | wxCoord *descent = NULL, | |
105 | wxCoord *externalLeading = NULL, | |
106 | wxFont *theFont = NULL) const; | |
a23fd0e1 VZ |
107 | |
108 | virtual bool CanDrawBitmap() const; | |
109 | virtual bool CanGetTextExtent() const; | |
110 | virtual int GetDepth() const; | |
111 | virtual wxSize GetPPI() const; | |
112 | ||
113 | virtual void SetMapMode(int mode); | |
114 | virtual void SetUserScale(double x, double y); | |
115 | virtual void SetSystemScale(double x, double y); | |
116 | virtual void SetLogicalScale(double x, double y); | |
72cdf4c9 VZ |
117 | virtual void SetLogicalOrigin(wxCoord x, wxCoord y); |
118 | virtual void SetDeviceOrigin(wxCoord x, wxCoord y); | |
a23fd0e1 VZ |
119 | virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp); |
120 | virtual void SetLogicalFunction(int function); | |
121 | ||
122 | // implementation from now on | |
123 | // -------------------------- | |
124 | ||
125 | virtual void SetRop(WXHDC cdc); | |
a23fd0e1 VZ |
126 | virtual void SelectOldObjects(WXHDC dc); |
127 | ||
128 | wxWindow *GetWindow() const { return m_canvas; } | |
129 | void SetWindow(wxWindow *win) { m_canvas = win; } | |
130 | ||
131 | WXHDC GetHDC() const { return m_hDC; } | |
132 | void SetHDC(WXHDC dc, bool bOwnsDC = FALSE) | |
133 | { | |
134 | m_hDC = dc; | |
135 | m_bOwnsDC = bOwnsDC; | |
136 | } | |
2bda0e17 | 137 | |
4b7f2165 VZ |
138 | const wxBitmap& GetSelectedBitmap() const { return m_selectedBitmap; } |
139 | wxBitmap& GetSelectedBitmap() { return m_selectedBitmap; } | |
140 | ||
1e6feb95 VZ |
141 | // update the internal clip box variables |
142 | void UpdateClipBox(); | |
143 | ||
a23fd0e1 | 144 | protected: |
72cdf4c9 | 145 | virtual void DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, |
a23fd0e1 VZ |
146 | int style = wxFLOOD_SURFACE); |
147 | ||
72cdf4c9 | 148 | virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const; |
a23fd0e1 | 149 | |
72cdf4c9 VZ |
150 | virtual void DoDrawPoint(wxCoord x, wxCoord y); |
151 | virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); | |
a23fd0e1 | 152 | |
72cdf4c9 VZ |
153 | virtual void DoDrawArc(wxCoord x1, wxCoord y1, |
154 | wxCoord x2, wxCoord y2, | |
155 | wxCoord xc, wxCoord yc); | |
cd9da200 VZ |
156 | virtual void DoDrawCheckMark(wxCoord x, wxCoord y, |
157 | wxCoord width, wxCoord height); | |
72cdf4c9 | 158 | virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, |
a23fd0e1 VZ |
159 | double sa, double ea); |
160 | ||
72cdf4c9 VZ |
161 | virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
162 | virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y, | |
163 | wxCoord width, wxCoord height, | |
a23fd0e1 | 164 | double radius); |
72cdf4c9 | 165 | virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
a23fd0e1 | 166 | |
72cdf4c9 | 167 | virtual void DoCrossHair(wxCoord x, wxCoord y); |
a23fd0e1 | 168 | |
72cdf4c9 VZ |
169 | virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y); |
170 | virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, | |
a23fd0e1 VZ |
171 | bool useMask = FALSE); |
172 | ||
72cdf4c9 | 173 | virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y); |
95724b1a VZ |
174 | virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, |
175 | double angle); | |
a23fd0e1 | 176 | |
72cdf4c9 VZ |
177 | virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, |
178 | wxDC *source, wxCoord xsrc, wxCoord ysrc, | |
a23fd0e1 VZ |
179 | int rop = wxCOPY, bool useMask = FALSE); |
180 | ||
181 | // this is gnarly - we can't even call this function DoSetClippingRegion() | |
182 | // because of virtual function hiding | |
183 | virtual void DoSetClippingRegionAsRegion(const wxRegion& region); | |
72cdf4c9 VZ |
184 | virtual void DoSetClippingRegion(wxCoord x, wxCoord y, |
185 | wxCoord width, wxCoord height); | |
186 | virtual void DoGetClippingRegion(wxCoord *x, wxCoord *y, | |
187 | wxCoord *width, wxCoord *height) | |
a23fd0e1 VZ |
188 | { |
189 | GetClippingBox(x, y, width, height); | |
190 | } | |
191 | ||
192 | virtual void DoGetSize(int *width, int *height) const; | |
193 | virtual void DoGetSizeMM(int* width, int* height) const; | |
194 | ||
195 | virtual void DoDrawLines(int n, wxPoint points[], | |
72cdf4c9 | 196 | wxCoord xoffset, wxCoord yoffset); |
a23fd0e1 | 197 | virtual void DoDrawPolygon(int n, wxPoint points[], |
72cdf4c9 | 198 | wxCoord xoffset, wxCoord yoffset, |
a23fd0e1 | 199 | int fillStyle = wxODDEVEN_RULE); |
6a6c0a8b | 200 | |
a23fd0e1 | 201 | |
4314ec48 VZ |
202 | // common part of DoDrawText() and DoDrawRotatedText() |
203 | void DrawAnyText(const wxString& text, wxCoord x, wxCoord y); | |
204 | ||
a23fd0e1 VZ |
205 | // MSW-specific member variables |
206 | int m_windowExtX; | |
207 | int m_windowExtY; | |
208 | ||
209 | // the window associated with this DC (may be NULL) | |
210 | wxWindow *m_canvas; | |
211 | ||
212 | wxBitmap m_selectedBitmap; | |
213 | ||
214 | // TRUE => DeleteDC() in dtor, FALSE => only ReleaseDC() it | |
215 | bool m_bOwnsDC:1; | |
216 | ||
b5badcb5 | 217 | // our HDC |
a23fd0e1 | 218 | WXHDC m_hDC; |
a23fd0e1 VZ |
219 | |
220 | // Store all old GDI objects when do a SelectObject, so we can select them | |
221 | // back in (this unselecting user's objects) so we can safely delete the | |
222 | // DC. | |
223 | WXHBITMAP m_oldBitmap; | |
224 | WXHPEN m_oldPen; | |
225 | WXHBRUSH m_oldBrush; | |
226 | WXHFONT m_oldFont; | |
227 | WXHPALETTE m_oldPalette; | |
7561aacd VZ |
228 | |
229 | DECLARE_DYNAMIC_CLASS(wxDC) | |
230 | }; | |
231 | ||
232 | // ---------------------------------------------------------------------------- | |
233 | // wxDCTemp: a wxDC which doesn't free the given HDC (used by wxWindows | |
234 | // only/mainly) | |
235 | // ---------------------------------------------------------------------------- | |
236 | ||
237 | class WXDLLEXPORT wxDCTemp : public wxDC | |
238 | { | |
239 | public: | |
240 | wxDCTemp(WXHDC hdc) { SetHDC(hdc); } | |
241 | virtual ~wxDCTemp() { SetHDC((WXHDC)NULL); } | |
2bda0e17 KB |
242 | }; |
243 | ||
2bda0e17 | 244 | #endif |
bbcdf8bc | 245 | // _WX_DC_H_ |