1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2006 REA Elektronik GmbH
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
15 #include "wx/region.h"
16 #include "wx/dfb/dfbptr.h"
18 wxDFB_DECLARE_INTERFACE(IDirectFBSurface
);
20 //-----------------------------------------------------------------------------
22 //-----------------------------------------------------------------------------
24 class WXDLLIMPEXP_CORE wxDC
: public wxDCBase
30 wxDC(const wxIDirectFBSurfacePtr
& surface
);
33 // implement base class pure virtuals
34 // ----------------------------------
38 virtual bool StartDoc(const wxString
& message
);
39 virtual void EndDoc();
41 virtual void StartPage();
42 virtual void EndPage();
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
);
50 virtual void SetPalette(const wxPalette
& palette
);
53 virtual void DestroyClippingRegion();
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 const wxFont
*theFont
= NULL
) const;
63 virtual bool CanDrawBitmap() const { return true; }
64 virtual bool CanGetTextExtent() const { return true; }
65 virtual int GetDepth() const;
66 virtual wxSize
GetPPI() const;
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
);
76 virtual wxCoord
DeviceToLogicalX(wxCoord x
) const;
77 virtual wxCoord
DeviceToLogicalY(wxCoord y
) const;
78 virtual wxCoord
DeviceToLogicalXRel(wxCoord x
) const;
79 virtual wxCoord
DeviceToLogicalYRel(wxCoord y
) const;
80 virtual wxCoord
LogicalToDeviceX(wxCoord x
) const;
81 virtual wxCoord
LogicalToDeviceY(wxCoord y
) const;
82 virtual wxCoord
LogicalToDeviceXRel(wxCoord x
) const;
83 virtual wxCoord
LogicalToDeviceYRel(wxCoord y
) const ;
85 // implementation from now on
86 // --------------------------
88 virtual void ComputeScaleAndOrigin();
90 wxCoord
XDEV2LOG(wxCoord x
) const
92 return wxRound((double)(x
- m_deviceOriginX
) / m_scaleX
) * m_signX
+ m_logicalOriginX
;
94 wxCoord
XDEV2LOGREL(wxCoord x
) const
96 return wxRound((double)(x
) / m_scaleX
);
98 wxCoord
YDEV2LOG(wxCoord y
) const
100 return wxRound((double)(y
- m_deviceOriginY
) / m_scaleY
) * m_signY
+ m_logicalOriginY
;
102 wxCoord
YDEV2LOGREL(wxCoord y
) const
104 return wxRound((double)(y
) / m_scaleY
);
106 wxCoord
XLOG2DEV(wxCoord x
) const
108 return wxRound((double)(x
- m_logicalOriginX
) * m_scaleX
) * m_signX
+ m_deviceOriginX
;
110 wxCoord
XLOG2DEVREL(wxCoord x
) const
112 return wxRound((double)(x
) * m_scaleX
);
114 wxCoord
YLOG2DEV(wxCoord y
) const
116 return wxRound((double)(y
- m_logicalOriginY
) * m_scaleY
) * m_signY
+ m_deviceOriginY
;
118 wxCoord
YLOG2DEVREL(wxCoord y
) const
120 return wxRound((double)(y
) * m_scaleY
);
123 // Returns the surface (and increases its ref count)
124 wxIDirectFBSurfacePtr
GetDirectFBSurface() const { return m_surface
; }
127 // initializes the DC from a surface, must be called if default ctor
129 void DFBInit(const wxIDirectFBSurfacePtr
& surface
);
131 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
132 int style
= wxFLOOD_SURFACE
);
134 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const;
136 virtual void DoDrawPoint(wxCoord x
, wxCoord y
);
137 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
);
139 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
140 wxCoord x2
, wxCoord y2
,
141 wxCoord xc
, wxCoord yc
);
142 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
143 double sa
, double ea
);
145 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
146 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
147 wxCoord width
, wxCoord height
,
149 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
151 virtual void DoCrossHair(wxCoord x
, wxCoord y
);
153 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
);
154 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
155 bool useMask
= false);
157 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
158 virtual void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
,
161 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
162 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
163 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= -1, wxCoord ysrcMask
= -1);
165 // this is gnarly - we can't even call this function DoSetClippingRegion()
166 // because of virtual function hiding
167 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
);
168 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
169 wxCoord width
, wxCoord height
);
171 virtual void DoGetSize(int *width
, int *height
) const;
172 virtual void DoGetSizeMM(int* width
, int* height
) const;
174 virtual void DoDrawLines(int n
, wxPoint points
[],
175 wxCoord xoffset
, wxCoord yoffset
);
176 virtual void DoDrawPolygon(int n
, wxPoint points
[],
177 wxCoord xoffset
, wxCoord yoffset
,
178 int fillStyle
= wxODDEVEN_RULE
);
180 // implementation from now on:
182 wxIDirectFBFontPtr
GetCurrentFont() const;
185 // Unified implementation of DrawIcon, DrawBitmap and Blit:
186 void DoDrawSubBitmap(const wxBitmap
&bmp
,
187 wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
188 wxCoord destx
, wxCoord desty
, int rop
, bool useMask
);
189 bool DoBlitFromSurface(const wxIDirectFBSurfacePtr
& src
,
190 wxCoord srcx
, wxCoord srcy
,
191 wxCoord w
, wxCoord h
,
192 wxCoord dstx
, wxCoord dsty
);
194 // selects colour into surface's state
195 void SelectColour(const wxColour
& clr
);
198 wxIDirectFBSurfacePtr m_surface
;
200 double m_mm_to_pix_x
, m_mm_to_pix_y
;
202 friend class WXDLLIMPEXP_CORE wxOverlayImpl
; // for Init
204 DECLARE_DYNAMIC_CLASS(wxDC
)
207 #endif // _WX_DFB_DC_H_