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