]> git.saurik.com Git - wxWidgets.git/blob - include/wx/dfb/dc.h
adding measuring contexts, streamlining printing code
[wxWidgets.git] / include / wx / dfb / dc.h
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/dfbptr.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 wxDC(const wxIDirectFBSurfacePtr& surface);
31
32 public:
33 // implement base class pure virtuals
34 // ----------------------------------
35
36 virtual void Clear();
37
38 virtual bool StartDoc(const wxString& message);
39 virtual void EndDoc();
40
41 virtual void StartPage();
42 virtual void EndPage();
43
44 virtual void SetFont(const wxFont& font);
45 virtual void SetPen(const wxPen& pen);
46 virtual void SetBrush(const wxBrush& brush);
47 virtual void SetBackground(const wxBrush& brush);
48 virtual void SetBackgroundMode(int mode);
49 #if wxUSE_PALETTE
50 virtual void SetPalette(const wxPalette& palette);
51 #endif
52
53 virtual void DestroyClippingRegion();
54
55 virtual wxCoord GetCharHeight() const;
56 virtual wxCoord GetCharWidth() const;
57 virtual void DoGetTextExtent(const wxString& string,
58 wxCoord *x, wxCoord *y,
59 wxCoord *descent = NULL,
60 wxCoord *externalLeading = NULL,
61 wxFont *theFont = NULL) const;
62
63 virtual bool CanDrawBitmap() const { return true; }
64 virtual bool CanGetTextExtent() const { return true; }
65 virtual int GetDepth() const;
66 virtual wxSize GetPPI() const;
67
68 virtual void SetMapMode(int mode);
69 virtual void SetUserScale(double x, double y);
70 virtual void SetLogicalScale(double x, double y);
71 virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
72 virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
73 virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
74 virtual void SetLogicalFunction(int function);
75
76 // implementation from now on
77 // --------------------------
78
79 virtual void ComputeScaleAndOrigin();
80
81 wxCoord XDEV2LOG(wxCoord x) const
82 {
83 return wxRound((double)(x - m_deviceOriginX) / m_scaleX) * m_signX + m_logicalOriginX;
84 }
85 wxCoord XDEV2LOGREL(wxCoord x) const
86 {
87 return wxRound((double)(x) / m_scaleX);
88 }
89 wxCoord YDEV2LOG(wxCoord y) const
90 {
91 return wxRound((double)(y - m_deviceOriginY) / m_scaleY) * m_signY + m_logicalOriginY;
92 }
93 wxCoord YDEV2LOGREL(wxCoord y) const
94 {
95 return wxRound((double)(y) / m_scaleY);
96 }
97 wxCoord XLOG2DEV(wxCoord x) const
98 {
99 return wxRound((double)(x - m_logicalOriginX) * m_scaleX) * m_signX + m_deviceOriginX;
100 }
101 wxCoord XLOG2DEVREL(wxCoord x) const
102 {
103 return wxRound((double)(x) * m_scaleX);
104 }
105 wxCoord YLOG2DEV(wxCoord y) const
106 {
107 return wxRound((double)(y - m_logicalOriginY) * m_scaleY) * m_signY + m_deviceOriginY;
108 }
109 wxCoord YLOG2DEVREL(wxCoord y) const
110 {
111 return wxRound((double)(y) * m_scaleY);
112 }
113
114 // Returns the surface (and increases its ref count)
115 wxIDirectFBSurfacePtr GetDirectFBSurface() const { return m_surface; }
116
117 protected:
118 // initializes the DC from a surface, must be called if default ctor
119 // was used
120 void DFBInit(const wxIDirectFBSurfacePtr& surface);
121
122 virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
123 int style = wxFLOOD_SURFACE);
124
125 virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const;
126
127 virtual void DoDrawPoint(wxCoord x, wxCoord y);
128 virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
129
130 virtual void DoDrawArc(wxCoord x1, wxCoord y1,
131 wxCoord x2, wxCoord y2,
132 wxCoord xc, wxCoord yc);
133 virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
134 double sa, double ea);
135
136 virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
137 virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
138 wxCoord width, wxCoord height,
139 double radius);
140 virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
141
142 virtual void DoCrossHair(wxCoord x, wxCoord y);
143
144 virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
145 virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
146 bool useMask = false);
147
148 virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y);
149 virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
150 double angle);
151
152 virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
153 wxDC *source, wxCoord xsrc, wxCoord ysrc,
154 int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
155
156 // this is gnarly - we can't even call this function DoSetClippingRegion()
157 // because of virtual function hiding
158 virtual void DoSetClippingRegionAsRegion(const wxRegion& region);
159 virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
160 wxCoord width, wxCoord height);
161
162 virtual void DoGetSize(int *width, int *height) const;
163 virtual void DoGetSizeMM(int* width, int* height) const;
164
165 virtual void DoDrawLines(int n, wxPoint points[],
166 wxCoord xoffset, wxCoord yoffset);
167 virtual void DoDrawPolygon(int n, wxPoint points[],
168 wxCoord xoffset, wxCoord yoffset,
169 int fillStyle = wxODDEVEN_RULE);
170
171 // implementation from now on:
172
173 private:
174 // Unified implementation of DrawIcon, DrawBitmap and Blit:
175 void DoDrawSubBitmap(const wxBitmap &bmp,
176 wxCoord x, wxCoord y, wxCoord w, wxCoord h,
177 wxCoord destx, wxCoord desty, int rop, bool useMask);
178 bool DoBlitFromSurface(const wxIDirectFBSurfacePtr& src,
179 wxCoord srcx, wxCoord srcy,
180 wxCoord w, wxCoord h,
181 wxCoord dstx, wxCoord dsty);
182
183 // selects colour into surface's state
184 void SelectColour(const wxColour& clr);
185
186 protected:
187 wxIDirectFBSurfacePtr m_surface;
188
189 double m_mm_to_pix_x, m_mm_to_pix_y;
190
191 friend class WXDLLIMPEXP_CORE wxOverlayImpl; // for Init
192
193 DECLARE_DYNAMIC_CLASS(wxDC)
194 };
195
196 #endif // _WX_DFB_DC_H_