]>
Commit | Line | Data |
---|---|---|
32b8ec41 VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: dc.h | |
3 | // Purpose: wxDC class | |
4 | // Author: Vaclav Slavik | |
5 | // Created: 2001/03/09 | |
6 | // RCS-ID: $Id$ | |
52750c2e | 7 | // Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com) |
65571936 | 8 | // Licence: wxWindows licence |
32b8ec41 VZ |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
11 | #ifndef _WX_DC_H_ | |
12 | #define _WX_DC_H_ | |
13 | ||
32b8ec41 | 14 | #include "wx/defs.h" |
32b8ec41 VZ |
15 | #include "wx/region.h" |
16 | ||
17 | //----------------------------------------------------------------------------- | |
18 | // classes | |
19 | //----------------------------------------------------------------------------- | |
20 | ||
b5dbe15d | 21 | class WXDLLIMPEXP_FWD_CORE wxDC; |
32b8ec41 VZ |
22 | |
23 | //----------------------------------------------------------------------------- | |
24 | // constants | |
25 | //----------------------------------------------------------------------------- | |
26 | ||
d2b1753d | 27 | #ifndef MM_TEXT |
32b8ec41 VZ |
28 | #define MM_TEXT 0 |
29 | #define MM_ISOTROPIC 1 | |
30 | #define MM_ANISOTROPIC 2 | |
31 | #define MM_LOMETRIC 3 | |
32 | #define MM_HIMETRIC 4 | |
33 | #define MM_TWIPS 5 | |
34 | #define MM_POINTS 6 | |
35 | #define MM_METRIC 7 | |
d2b1753d | 36 | #endif |
32b8ec41 VZ |
37 | |
38 | //----------------------------------------------------------------------------- | |
39 | // wxDC | |
40 | //----------------------------------------------------------------------------- | |
41 | ||
42 | ||
43 | // MGL fwd declarations: | |
44 | class MGLDevCtx; | |
7bdc1879 | 45 | class MGLRegion; |
32b8ec41 VZ |
46 | struct font_t; |
47 | ||
48 | class WXDLLEXPORT wxDC : public wxDCBase | |
49 | { | |
50 | DECLARE_DYNAMIC_CLASS(wxDC) | |
51 | ||
52 | public: | |
53 | wxDC(); | |
d3c7fc99 | 54 | virtual ~wxDC(); |
32b8ec41 VZ |
55 | |
56 | // implement base class pure virtuals | |
57 | // ---------------------------------- | |
58 | ||
59 | virtual void Clear(); | |
60 | ||
61 | virtual bool StartDoc(const wxString& message); | |
62 | virtual void EndDoc(); | |
63 | ||
64 | virtual void StartPage(); | |
65 | virtual void EndPage(); | |
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, | |
c94f845b | 82 | const wxFont *theFont = NULL) const; |
32b8ec41 VZ |
83 | |
84 | virtual bool CanDrawBitmap() const; | |
85 | virtual bool CanGetTextExtent() const; | |
86 | virtual int GetDepth() const; | |
87 | virtual wxSize GetPPI() const; | |
88 | ||
32b8ec41 VZ |
89 | virtual void SetLogicalFunction(int function); |
90 | ||
91 | // implementation from now on | |
92 | // -------------------------- | |
c5789d15 | 93 | |
32b8ec41 | 94 | virtual void ComputeScaleAndOrigin(); |
04ab8b6d RR |
95 | |
96 | wxCoord XDEV2LOG(wxCoord x) const { return DeviceToLogicalX(x); } | |
97 | wxCoord XDEV2LOGREL(wxCoord x) const { return DeviceToLogicalXRel(x); } | |
98 | wxCoord YDEV2LOG(wxCoord y) const { return DeviceToLogicalY(y); } | |
99 | wxCoord YDEV2LOGREL(wxCoord y) const { return DeviceToLogicalYRel(y); } | |
100 | wxCoord XLOG2DEV(wxCoord x) const { return LogicalToDeviceX(x); } | |
101 | wxCoord XLOG2DEVREL(wxCoord x) const { return LogicalToDeviceXRel(x); } | |
102 | wxCoord YLOG2DEV(wxCoord y) const { return LogicalToDeviceY(y); } | |
103 | wxCoord YLOG2DEVREL(wxCoord y) const { return LogicalToDeviceYRel(y); } | |
32b8ec41 VZ |
104 | |
105 | MGLDevCtx *GetMGLDC() const { return m_MGLDC; } | |
b1263dcf | 106 | void SetMGLDC(MGLDevCtx *mgldc, bool OwnsMGLDC = false); |
32b8ec41 VZ |
107 | |
108 | protected: | |
387ebd3e | 109 | virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, |
32b8ec41 VZ |
110 | int style = wxFLOOD_SURFACE); |
111 | ||
112 | virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const; | |
113 | ||
114 | virtual void DoDrawPoint(wxCoord x, wxCoord y); | |
115 | virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); | |
116 | ||
117 | virtual void DoDrawArc(wxCoord x1, wxCoord y1, | |
118 | wxCoord x2, wxCoord y2, | |
119 | wxCoord xc, wxCoord yc); | |
120 | virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, | |
121 | double sa, double ea); | |
122 | ||
123 | virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
124 | virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y, | |
125 | wxCoord width, wxCoord height, | |
126 | double radius); | |
127 | virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
128 | ||
129 | virtual void DoCrossHair(wxCoord x, wxCoord y); | |
130 | ||
131 | virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y); | |
132 | virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, | |
b1263dcf | 133 | bool useMask = false); |
32b8ec41 VZ |
134 | |
135 | virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y); | |
136 | virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, | |
137 | double angle); | |
138 | ||
139 | virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, | |
140 | wxDC *source, wxCoord xsrc, wxCoord ysrc, | |
b1263dcf | 141 | int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1); |
32b8ec41 VZ |
142 | |
143 | // this is gnarly - we can't even call this function DoSetClippingRegion() | |
144 | // because of virtual function hiding | |
145 | virtual void DoSetClippingRegionAsRegion(const wxRegion& region); | |
146 | virtual void DoSetClippingRegion(wxCoord x, wxCoord y, | |
147 | wxCoord width, wxCoord height); | |
32b8ec41 VZ |
148 | |
149 | virtual void DoGetSize(int *width, int *height) const; | |
150 | virtual void DoGetSizeMM(int* width, int* height) const; | |
151 | ||
152 | virtual void DoDrawLines(int n, wxPoint points[], | |
153 | wxCoord xoffset, wxCoord yoffset); | |
154 | virtual void DoDrawPolygon(int n, wxPoint points[], | |
155 | wxCoord xoffset, wxCoord yoffset, | |
156 | int fillStyle = wxODDEVEN_RULE); | |
157 | ||
158 | // implementation from now on: | |
159 | ||
160 | protected: | |
161 | // setup newly attached MGLDevCtx for wxDC's use | |
162 | // (does things like setting RGB blending mode for antialiased texts): | |
163 | void InitializeMGLDC(); | |
164 | ||
165 | // common part of DoDrawText() and DoDrawRotatedText() | |
166 | void DrawAnyText(const wxString& text, wxCoord x, wxCoord y); | |
c5789d15 | 167 | |
32b8ec41 VZ |
168 | // MGL uses pens as both wxPens and wxBrushes, so we have to |
169 | // switch them as needed: | |
170 | void SelectPen(); | |
171 | void SelectBrush(); | |
172 | void SelectMGLStipplePen(int style); | |
173 | void SelectMGLFatPen(int style, int flag); | |
c5789d15 | 174 | |
32b8ec41 VZ |
175 | // Select m_font into m_MGLDC: |
176 | bool SelectMGLFont(); | |
c5789d15 | 177 | |
32b8ec41 VZ |
178 | // Convert wxWin logical function to MGL rop: |
179 | int LogicalFunctionToMGLRop(int logFunc) const; | |
c5789d15 | 180 | |
32b8ec41 | 181 | // Unified implementation of DrawIcon, DrawBitmap and Blit: |
c5789d15 | 182 | void DoDrawSubBitmap(const wxBitmap &bmp, |
32b8ec41 VZ |
183 | wxCoord x, wxCoord y, wxCoord w, wxCoord h, |
184 | wxCoord destx, wxCoord desty, int rop, bool useMask); | |
185 | ||
186 | // MGL DC class we use: | |
187 | MGLDevCtx *m_MGLDC; | |
188 | bool m_OwnsMGLDC:1; | |
c5789d15 | 189 | |
32b8ec41 VZ |
190 | // helper variables for SelectXXXX(): |
191 | bool m_penSelected; | |
192 | bool m_brushSelected; | |
193 | bool m_downloadedPatterns[2]; | |
194 | ||
c5789d15 | 195 | // MGL does not render lines with width>1 with endings centered |
32b8ec41 VZ |
196 | // at given coords but with top left corner of the pen at them, |
197 | // these offsets are used to correct it. They are computed by | |
198 | // SelectPen. | |
199 | int m_penOfsX, m_penOfsY; | |
200 | ||
201 | double m_mm_to_pix_x, m_mm_to_pix_y; | |
c5789d15 | 202 | |
32b8ec41 | 203 | wxPalette m_oldPalette; |
c5789d15 | 204 | |
32b8ec41 | 205 | wxRegion m_currentClippingRegion; |
ef344ff8 | 206 | wxRegion m_globalClippingRegion; |
32b8ec41 VZ |
207 | |
208 | // wxDC::Blit handles memoryDCs as special cases :( | |
209 | bool m_isMemDC; | |
c5789d15 | 210 | |
32b8ec41 VZ |
211 | font_t *m_mglFont; |
212 | }; | |
213 | ||
214 | #endif | |
215 | // _WX_DC_H_ |