]>
Commit | Line | Data |
---|---|---|
b3c86150 VS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/dfb/dc.h | |
3 | // Purpose: wxDC class | |
4 | // Author: Vaclav Slavik | |
5 | // Created: 2006-08-07 | |
6 | // RCS-ID: $Id$ | |
7 | // Copyright: (c) 2006 REA Elektronik GmbH | |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #ifndef _WX_DFB_DC_H_ | |
12 | #define _WX_DFB_DC_H_ | |
13 | ||
14 | #include "wx/defs.h" | |
15 | #include "wx/region.h" | |
16 | #include "wx/dfb/ifacehelpers.h" | |
17 | ||
18 | wxDFB_DECLARE_INTERFACE(IDirectFBSurface); | |
19 | ||
20 | //----------------------------------------------------------------------------- | |
21 | // wxDC | |
22 | //----------------------------------------------------------------------------- | |
23 | ||
24 | class WXDLLIMPEXP_CORE wxDC : public wxDCBase | |
25 | { | |
26 | public: | |
27 | wxDC(); | |
28 | ||
29 | // Ctor. | |
30 | // Takes ownership of the surface, i.e. does not call AddRef() on it | |
31 | // but calls Release() on it from dtor. | |
32 | wxDC(const IDirectFBSurfacePtr& surface); | |
33 | ||
34 | public: | |
35 | // implement base class pure virtuals | |
36 | // ---------------------------------- | |
37 | ||
38 | virtual void Clear(); | |
39 | ||
40 | virtual bool StartDoc(const wxString& message); | |
41 | virtual void EndDoc(); | |
42 | ||
43 | virtual void StartPage(); | |
44 | virtual void EndPage(); | |
45 | ||
46 | virtual void SetFont(const wxFont& font); | |
47 | virtual void SetPen(const wxPen& pen); | |
48 | virtual void SetBrush(const wxBrush& brush); | |
49 | virtual void SetBackground(const wxBrush& brush); | |
50 | virtual void SetBackgroundMode(int mode); | |
51 | #if wxUSE_PALETTE | |
52 | virtual void SetPalette(const wxPalette& palette); | |
53 | #endif | |
54 | ||
55 | virtual void DestroyClippingRegion(); | |
56 | ||
57 | virtual wxCoord GetCharHeight() const; | |
58 | virtual wxCoord GetCharWidth() const; | |
59 | virtual void DoGetTextExtent(const wxString& string, | |
60 | wxCoord *x, wxCoord *y, | |
61 | wxCoord *descent = NULL, | |
62 | wxCoord *externalLeading = NULL, | |
63 | wxFont *theFont = NULL) const; | |
64 | ||
65 | virtual bool CanDrawBitmap() const { return true; } | |
66 | virtual bool CanGetTextExtent() const { return true; } | |
67 | virtual int GetDepth() const; | |
68 | virtual wxSize GetPPI() const; | |
69 | ||
70 | virtual void SetMapMode(int mode); | |
71 | virtual void SetUserScale(double x, double y); | |
72 | virtual void SetLogicalScale(double x, double y); | |
73 | virtual void SetLogicalOrigin(wxCoord x, wxCoord y); | |
74 | virtual void SetDeviceOrigin(wxCoord x, wxCoord y); | |
75 | virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp); | |
76 | virtual void SetLogicalFunction(int function); | |
77 | ||
78 | // implementation from now on | |
79 | // -------------------------- | |
80 | ||
81 | virtual void ComputeScaleAndOrigin(); | |
82 | ||
83 | wxCoord XDEV2LOG(wxCoord x) const | |
84 | { | |
85 | wxCoord new_x = x - m_deviceOriginX; | |
86 | if (new_x > 0) | |
87 | return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX; | |
88 | else | |
89 | return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX; | |
90 | } | |
91 | wxCoord XDEV2LOGREL(wxCoord x) const | |
92 | { | |
93 | if (x > 0) | |
94 | return (wxCoord)((double)(x) / m_scaleX + 0.5); | |
95 | else | |
96 | return (wxCoord)((double)(x) / m_scaleX - 0.5); | |
97 | } | |
98 | wxCoord YDEV2LOG(wxCoord y) const | |
99 | { | |
100 | wxCoord new_y = y - m_deviceOriginY; | |
101 | if (new_y > 0) | |
102 | return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY; | |
103 | else | |
104 | return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY; | |
105 | } | |
106 | wxCoord YDEV2LOGREL(wxCoord y) const | |
107 | { | |
108 | if (y > 0) | |
109 | return (wxCoord)((double)(y) / m_scaleY + 0.5); | |
110 | else | |
111 | return (wxCoord)((double)(y) / m_scaleY - 0.5); | |
112 | } | |
113 | wxCoord XLOG2DEV(wxCoord x) const | |
114 | { | |
115 | wxCoord new_x = x - m_logicalOriginX; | |
116 | if (new_x > 0) | |
117 | return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX; | |
118 | else | |
119 | return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX; | |
120 | } | |
121 | wxCoord XLOG2DEVREL(wxCoord x) const | |
122 | { | |
123 | if (x > 0) | |
124 | return (wxCoord)((double)(x) * m_scaleX + 0.5); | |
125 | else | |
126 | return (wxCoord)((double)(x) * m_scaleX - 0.5); | |
127 | } | |
128 | wxCoord YLOG2DEV(wxCoord y) const | |
129 | { | |
130 | wxCoord new_y = y - m_logicalOriginY; | |
131 | if (new_y > 0) | |
132 | return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY; | |
133 | else | |
134 | return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY; | |
135 | } | |
136 | wxCoord YLOG2DEVREL(wxCoord y) const | |
137 | { | |
138 | if (y > 0) | |
139 | return (wxCoord)((double)(y) * m_scaleY + 0.5); | |
140 | else | |
141 | return (wxCoord)((double)(y) * m_scaleY - 0.5); | |
142 | } | |
143 | ||
144 | // Returns the surface (and increases its ref count) | |
145 | IDirectFBSurfacePtr GetDirectFBSurface() const { return m_surface; } | |
146 | ||
147 | protected: | |
148 | // initializes the DC from a surface, must be called if default ctor | |
149 | // was used | |
150 | void Init(const IDirectFBSurfacePtr& surface); | |
151 | ||
152 | virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, | |
153 | int style = wxFLOOD_SURFACE); | |
154 | ||
155 | virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const; | |
156 | ||
157 | virtual void DoDrawPoint(wxCoord x, wxCoord y); | |
158 | virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); | |
159 | ||
160 | virtual void DoDrawArc(wxCoord x1, wxCoord y1, | |
161 | wxCoord x2, wxCoord y2, | |
162 | wxCoord xc, wxCoord yc); | |
163 | virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, | |
164 | double sa, double ea); | |
165 | ||
166 | virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
167 | virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y, | |
168 | wxCoord width, wxCoord height, | |
169 | double radius); | |
170 | virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
171 | ||
172 | virtual void DoCrossHair(wxCoord x, wxCoord y); | |
173 | ||
174 | virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y); | |
175 | virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, | |
176 | bool useMask = false); | |
177 | ||
178 | virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y); | |
179 | virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, | |
180 | double angle); | |
181 | ||
182 | virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, | |
183 | wxDC *source, wxCoord xsrc, wxCoord ysrc, | |
184 | int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1); | |
185 | ||
186 | // this is gnarly - we can't even call this function DoSetClippingRegion() | |
187 | // because of virtual function hiding | |
188 | virtual void DoSetClippingRegionAsRegion(const wxRegion& region); | |
189 | virtual void DoSetClippingRegion(wxCoord x, wxCoord y, | |
190 | wxCoord width, wxCoord height); | |
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[], | |
196 | wxCoord xoffset, wxCoord yoffset); | |
197 | virtual void DoDrawPolygon(int n, wxPoint points[], | |
198 | wxCoord xoffset, wxCoord yoffset, | |
199 | int fillStyle = wxODDEVEN_RULE); | |
200 | ||
201 | // implementation from now on: | |
202 | ||
203 | private: | |
204 | // Unified implementation of DrawIcon, DrawBitmap and Blit: | |
205 | void DoDrawSubBitmap(const wxBitmap &bmp, | |
206 | wxCoord x, wxCoord y, wxCoord w, wxCoord h, | |
207 | wxCoord destx, wxCoord desty, int rop, bool useMask); | |
208 | ||
209 | // selects colour into surface's state | |
210 | void SelectColour(const wxColour& clr); | |
211 | ||
212 | protected: | |
213 | IDirectFBSurfacePtr m_surface; | |
214 | ||
215 | double m_mm_to_pix_x, m_mm_to_pix_y; | |
216 | ||
217 | DECLARE_DYNAMIC_CLASS(wxDC) | |
218 | }; | |
219 | ||
220 | #endif // _WX_DFB_DC_H_ |