]>
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 | { |
a23fd0e1 VZ |
76 | DECLARE_DYNAMIC_CLASS(wxDC) |
77 | ||
2bda0e17 | 78 | public: |
a23fd0e1 VZ |
79 | wxDC(); |
80 | ~wxDC(); | |
81 | ||
82 | // implement base class pure virtuals | |
83 | // ---------------------------------- | |
84 | ||
85 | virtual void Clear(); | |
86 | ||
87 | virtual bool StartDoc(const wxString& message); | |
88 | virtual void EndDoc(); | |
89 | ||
90 | virtual void StartPage(); | |
91 | virtual void EndPage(); | |
92 | ||
93 | virtual void SetFont(const wxFont& font); | |
94 | virtual void SetPen(const wxPen& pen); | |
95 | virtual void SetBrush(const wxBrush& brush); | |
96 | virtual void SetBackground(const wxBrush& brush); | |
97 | virtual void SetBackgroundMode(int mode); | |
98 | virtual void SetPalette(const wxPalette& palette); | |
99 | ||
100 | virtual void DestroyClippingRegion(); | |
101 | ||
102 | virtual long GetCharHeight() const; | |
103 | virtual long GetCharWidth() const; | |
104 | virtual void GetTextExtent(const wxString& string, | |
105 | long *x, long *y, | |
106 | long *descent = NULL, | |
107 | long *externalLeading = NULL, | |
108 | wxFont *theFont = NULL) const; | |
109 | ||
110 | virtual bool CanDrawBitmap() const; | |
111 | virtual bool CanGetTextExtent() const; | |
112 | virtual int GetDepth() const; | |
113 | virtual wxSize GetPPI() const; | |
114 | ||
115 | virtual void SetMapMode(int mode); | |
116 | virtual void SetUserScale(double x, double y); | |
117 | virtual void SetSystemScale(double x, double y); | |
118 | virtual void SetLogicalScale(double x, double y); | |
119 | virtual void SetLogicalOrigin(long x, long y); | |
120 | virtual void SetDeviceOrigin(long x, long y); | |
121 | virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp); | |
122 | virtual void SetLogicalFunction(int function); | |
123 | ||
124 | // implementation from now on | |
125 | // -------------------------- | |
126 | ||
127 | virtual void SetRop(WXHDC cdc); | |
128 | virtual void DoClipping(WXHDC cdc); | |
129 | virtual void SelectOldObjects(WXHDC dc); | |
130 | ||
131 | wxWindow *GetWindow() const { return m_canvas; } | |
132 | void SetWindow(wxWindow *win) { m_canvas = win; } | |
133 | ||
134 | WXHDC GetHDC() const { return m_hDC; } | |
135 | void SetHDC(WXHDC dc, bool bOwnsDC = FALSE) | |
136 | { | |
137 | m_hDC = dc; | |
138 | m_bOwnsDC = bOwnsDC; | |
139 | } | |
2bda0e17 | 140 | |
a23fd0e1 VZ |
141 | protected: |
142 | virtual void DoFloodFill(long x, long y, const wxColour& col, | |
143 | int style = wxFLOOD_SURFACE); | |
144 | ||
145 | virtual bool DoGetPixel(long x, long y, wxColour *col) const; | |
146 | ||
147 | virtual void DoDrawPoint(long x, long y); | |
148 | virtual void DoDrawLine(long x1, long y1, long x2, long y2); | |
149 | ||
150 | virtual void DoDrawArc(long x1, long y1, | |
151 | long x2, long y2, | |
152 | long xc, long yc); | |
153 | virtual void DoDrawEllipticArc(long x, long y, long w, long h, | |
154 | double sa, double ea); | |
155 | ||
156 | virtual void DoDrawRectangle(long x, long y, long width, long height); | |
157 | virtual void DoDrawRoundedRectangle(long x, long y, | |
158 | long width, long height, | |
159 | double radius); | |
160 | virtual void DoDrawEllipse(long x, long y, long width, long height); | |
161 | ||
162 | virtual void DoCrossHair(long x, long y); | |
163 | ||
164 | virtual void DoDrawIcon(const wxIcon& icon, long x, long y); | |
165 | virtual void DoDrawBitmap(const wxBitmap &bmp, long x, long y, | |
166 | bool useMask = FALSE); | |
167 | ||
168 | virtual void DoDrawText(const wxString& text, long x, long y); | |
169 | ||
170 | virtual bool DoBlit(long xdest, long ydest, long width, long height, | |
171 | wxDC *source, long xsrc, long ysrc, | |
172 | int rop = wxCOPY, bool useMask = FALSE); | |
173 | ||
174 | // this is gnarly - we can't even call this function DoSetClippingRegion() | |
175 | // because of virtual function hiding | |
176 | virtual void DoSetClippingRegionAsRegion(const wxRegion& region); | |
177 | virtual void DoSetClippingRegion(long x, long y, | |
178 | long width, long height); | |
179 | virtual void DoGetClippingRegion(long *x, long *y, | |
180 | long *width, long *height) | |
181 | { | |
182 | GetClippingBox(x, y, width, height); | |
183 | } | |
184 | ||
185 | virtual void DoGetSize(int *width, int *height) const; | |
186 | virtual void DoGetSizeMM(int* width, int* height) const; | |
187 | ||
188 | virtual void DoDrawLines(int n, wxPoint points[], | |
189 | long xoffset, long yoffset); | |
190 | virtual void DoDrawPolygon(int n, wxPoint points[], | |
191 | long xoffset, long yoffset, | |
192 | int fillStyle = wxODDEVEN_RULE); | |
6a6c0a8b | 193 | |
47d67540 | 194 | #if wxUSE_SPLINES |
a23fd0e1 VZ |
195 | virtual void DoDrawSpline(wxList *points); |
196 | #endif // wxUSE_SPLINES | |
197 | ||
198 | // MSW-specific member variables | |
199 | int m_windowExtX; | |
200 | int m_windowExtY; | |
201 | ||
202 | // the window associated with this DC (may be NULL) | |
203 | wxWindow *m_canvas; | |
204 | ||
205 | wxBitmap m_selectedBitmap; | |
206 | ||
207 | // TRUE => DeleteDC() in dtor, FALSE => only ReleaseDC() it | |
208 | bool m_bOwnsDC:1; | |
209 | ||
210 | // our HDC and its usage count: we only free it when the usage count drops | |
211 | // to 0 | |
212 | WXHDC m_hDC; | |
213 | int m_hDCCount; | |
214 | ||
215 | // Store all old GDI objects when do a SelectObject, so we can select them | |
216 | // back in (this unselecting user's objects) so we can safely delete the | |
217 | // DC. | |
218 | WXHBITMAP m_oldBitmap; | |
219 | WXHPEN m_oldPen; | |
220 | WXHBRUSH m_oldBrush; | |
221 | WXHFONT m_oldFont; | |
222 | WXHPALETTE m_oldPalette; | |
2bda0e17 KB |
223 | }; |
224 | ||
2bda0e17 | 225 | #endif |
bbcdf8bc | 226 | // _WX_DC_H_ |