]>
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 | ||
e6f1ad22 HH |
19 | // --------------------------------------------------------------------------- |
20 | // macros | |
21 | // --------------------------------------------------------------------------- | |
22 | ||
23 | // Logical to device | |
24 | // Absolute | |
25 | #define XLOG2DEV(x) (x) | |
26 | #define YLOG2DEV(y) (y) | |
27 | ||
28 | // Relative | |
29 | #define XLOG2DEVREL(x) (x) | |
30 | #define YLOG2DEVREL(y) (y) | |
31 | ||
32 | // Device to logical | |
33 | // Absolute | |
34 | #define XDEV2LOG(x) (x) | |
35 | ||
36 | #define YDEV2LOG(y) (y) | |
37 | ||
38 | // Relative | |
39 | #define XDEV2LOGREL(x) (x) | |
40 | #define YDEV2LOGREL(y) (y) | |
41 | ||
42 | /* | |
43 | * Have the same macros as for XView but not for every operation: | |
44 | * just for calculating window/viewport extent (a better way of scaling). | |
45 | */ | |
46 | ||
47 | // Logical to device | |
48 | // Absolute | |
49 | #define MS_XLOG2DEV(x) LogicalToDevice(x) | |
50 | ||
51 | #define MS_YLOG2DEV(y) LogicalToDevice(y) | |
52 | ||
53 | // Relative | |
54 | #define MS_XLOG2DEVREL(x) LogicalToDeviceXRel(x) | |
55 | #define MS_YLOG2DEVREL(y) LogicalToDeviceYRel(y) | |
56 | ||
57 | // Device to logical | |
58 | // Absolute | |
59 | #define MS_XDEV2LOG(x) DeviceToLogicalX(x) | |
60 | ||
61 | #define MS_YDEV2LOG(y) DeviceToLogicalY(y) | |
62 | ||
63 | // Relative | |
64 | #define MS_XDEV2LOGREL(x) DeviceToLogicalXRel(x) | |
65 | #define MS_YDEV2LOGREL(y) DeviceToLogicalYRel(y) | |
66 | ||
67 | #define YSCALE(y) (yorigin - (y)) | |
68 | ||
69 | #define wx_round(a) (int)((a)+.5) | |
70 | ||
a23fd0e1 | 71 | class WXDLLEXPORT wxDC : public wxDCBase |
2bda0e17 | 72 | { |
a23fd0e1 VZ |
73 | DECLARE_DYNAMIC_CLASS(wxDC) |
74 | ||
2bda0e17 | 75 | public: |
a23fd0e1 VZ |
76 | wxDC(); |
77 | ~wxDC(); | |
78 | ||
79 | // implement base class pure virtuals | |
80 | // ---------------------------------- | |
81 | ||
82 | virtual void Clear(); | |
83 | ||
84 | virtual bool StartDoc(const wxString& message); | |
85 | virtual void EndDoc(); | |
86 | ||
87 | virtual void StartPage(); | |
88 | virtual void EndPage(); | |
89 | ||
90 | virtual void SetFont(const wxFont& font); | |
91 | virtual void SetPen(const wxPen& pen); | |
92 | virtual void SetBrush(const wxBrush& brush); | |
93 | virtual void SetBackground(const wxBrush& brush); | |
94 | virtual void SetBackgroundMode(int mode); | |
95 | virtual void SetPalette(const wxPalette& palette); | |
96 | ||
97 | virtual void DestroyClippingRegion(); | |
98 | ||
99 | virtual long GetCharHeight() const; | |
100 | virtual long GetCharWidth() const; | |
101 | virtual void GetTextExtent(const wxString& string, | |
102 | long *x, long *y, | |
103 | long *descent = NULL, | |
104 | long *externalLeading = NULL, | |
105 | wxFont *theFont = NULL) const; | |
106 | ||
107 | virtual bool CanDrawBitmap() const; | |
108 | virtual bool CanGetTextExtent() const; | |
109 | virtual int GetDepth() const; | |
110 | virtual wxSize GetPPI() const; | |
111 | ||
112 | virtual void SetMapMode(int mode); | |
113 | virtual void SetUserScale(double x, double y); | |
114 | virtual void SetSystemScale(double x, double y); | |
115 | virtual void SetLogicalScale(double x, double y); | |
116 | virtual void SetLogicalOrigin(long x, long y); | |
117 | virtual void SetDeviceOrigin(long x, long y); | |
118 | virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp); | |
119 | virtual void SetLogicalFunction(int function); | |
120 | ||
121 | // implementation from now on | |
122 | // -------------------------- | |
123 | ||
124 | virtual void SetRop(WXHDC cdc); | |
125 | virtual void DoClipping(WXHDC cdc); | |
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 | |
a23fd0e1 VZ |
138 | protected: |
139 | virtual void DoFloodFill(long x, long y, const wxColour& col, | |
140 | int style = wxFLOOD_SURFACE); | |
141 | ||
142 | virtual bool DoGetPixel(long x, long y, wxColour *col) const; | |
143 | ||
144 | virtual void DoDrawPoint(long x, long y); | |
145 | virtual void DoDrawLine(long x1, long y1, long x2, long y2); | |
146 | ||
147 | virtual void DoDrawArc(long x1, long y1, | |
148 | long x2, long y2, | |
149 | long xc, long yc); | |
150 | virtual void DoDrawEllipticArc(long x, long y, long w, long h, | |
151 | double sa, double ea); | |
152 | ||
153 | virtual void DoDrawRectangle(long x, long y, long width, long height); | |
154 | virtual void DoDrawRoundedRectangle(long x, long y, | |
155 | long width, long height, | |
156 | double radius); | |
157 | virtual void DoDrawEllipse(long x, long y, long width, long height); | |
158 | ||
159 | virtual void DoCrossHair(long x, long y); | |
160 | ||
161 | virtual void DoDrawIcon(const wxIcon& icon, long x, long y); | |
162 | virtual void DoDrawBitmap(const wxBitmap &bmp, long x, long y, | |
163 | bool useMask = FALSE); | |
164 | ||
165 | virtual void DoDrawText(const wxString& text, long x, long y); | |
166 | ||
167 | virtual bool DoBlit(long xdest, long ydest, long width, long height, | |
168 | wxDC *source, long xsrc, long ysrc, | |
169 | int rop = wxCOPY, bool useMask = FALSE); | |
170 | ||
171 | // this is gnarly - we can't even call this function DoSetClippingRegion() | |
172 | // because of virtual function hiding | |
173 | virtual void DoSetClippingRegionAsRegion(const wxRegion& region); | |
174 | virtual void DoSetClippingRegion(long x, long y, | |
175 | long width, long height); | |
176 | virtual void DoGetClippingRegion(long *x, long *y, | |
177 | long *width, long *height) | |
178 | { | |
179 | GetClippingBox(x, y, width, height); | |
180 | } | |
181 | ||
182 | virtual void DoGetSize(int *width, int *height) const; | |
183 | virtual void DoGetSizeMM(int* width, int* height) const; | |
184 | ||
185 | virtual void DoDrawLines(int n, wxPoint points[], | |
186 | long xoffset, long yoffset); | |
187 | virtual void DoDrawPolygon(int n, wxPoint points[], | |
188 | long xoffset, long yoffset, | |
189 | int fillStyle = wxODDEVEN_RULE); | |
6a6c0a8b | 190 | |
47d67540 | 191 | #if wxUSE_SPLINES |
a23fd0e1 VZ |
192 | virtual void DoDrawSpline(wxList *points); |
193 | #endif // wxUSE_SPLINES | |
194 | ||
195 | // MSW-specific member variables | |
196 | int m_windowExtX; | |
197 | int m_windowExtY; | |
198 | ||
199 | // the window associated with this DC (may be NULL) | |
200 | wxWindow *m_canvas; | |
201 | ||
202 | wxBitmap m_selectedBitmap; | |
203 | ||
204 | // TRUE => DeleteDC() in dtor, FALSE => only ReleaseDC() it | |
205 | bool m_bOwnsDC:1; | |
206 | ||
207 | // our HDC and its usage count: we only free it when the usage count drops | |
208 | // to 0 | |
209 | WXHDC m_hDC; | |
210 | int m_hDCCount; | |
211 | ||
212 | // Store all old GDI objects when do a SelectObject, so we can select them | |
213 | // back in (this unselecting user's objects) so we can safely delete the | |
214 | // DC. | |
215 | WXHBITMAP m_oldBitmap; | |
216 | WXHPEN m_oldPen; | |
217 | WXHBRUSH m_oldBrush; | |
218 | WXHFONT m_oldFont; | |
219 | WXHPALETTE m_oldPalette; | |
2bda0e17 KB |
220 | }; |
221 | ||
2bda0e17 | 222 | #endif |
bbcdf8bc | 223 | // _WX_DC_H_ |