1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2006 REA Elektronik GmbH
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
15 #include "wx/region.h"
17 #include "wx/dfb/dfbptr.h"
19 wxDFB_DECLARE_INTERFACE(IDirectFBSurface
);
21 //-----------------------------------------------------------------------------
23 //-----------------------------------------------------------------------------
25 class WXDLLIMPEXP_CORE wxDFBDCImpl
: public wxDCImpl
29 wxDFBDCImpl(wxDC
*owner
) : wxDCImpl(owner
) { m_surface
= NULL
; }
30 wxDFBDCImpl(wxDC
*owner
, const wxIDirectFBSurfacePtr
& surface
)
36 bool IsOk() const { return m_surface
!= NULL
; }
38 // implement base class pure virtuals
39 // ----------------------------------
43 virtual bool StartDoc(const wxString
& message
);
44 virtual void EndDoc();
46 virtual void StartPage();
47 virtual void EndPage();
49 virtual void SetFont(const wxFont
& font
);
50 virtual void SetPen(const wxPen
& pen
);
51 virtual void SetBrush(const wxBrush
& brush
);
52 virtual void SetBackground(const wxBrush
& brush
);
53 virtual void SetBackgroundMode(int mode
);
55 virtual void SetPalette(const wxPalette
& palette
);
58 virtual void SetLogicalFunction(wxRasterOperationMode function
);
60 virtual void DestroyClippingRegion();
62 virtual wxCoord
GetCharHeight() const;
63 virtual wxCoord
GetCharWidth() const;
64 virtual void DoGetTextExtent(const wxString
& string
,
65 wxCoord
*x
, wxCoord
*y
,
66 wxCoord
*descent
= NULL
,
67 wxCoord
*externalLeading
= NULL
,
68 const wxFont
*theFont
= NULL
) const;
70 virtual bool CanDrawBitmap() const { return true; }
71 virtual bool CanGetTextExtent() const { return true; }
72 virtual int GetDepth() const;
73 virtual wxSize
GetPPI() const;
75 // Returns the surface (and increases its ref count)
76 wxIDirectFBSurfacePtr
GetDirectFBSurface() const { return m_surface
; }
80 wxCoord
XDEV2LOG(wxCoord x
) const { return DeviceToLogicalX(x
); }
81 wxCoord
XDEV2LOGREL(wxCoord x
) const { return DeviceToLogicalXRel(x
); }
82 wxCoord
YDEV2LOG(wxCoord y
) const { return DeviceToLogicalY(y
); }
83 wxCoord
YDEV2LOGREL(wxCoord y
) const { return DeviceToLogicalYRel(y
); }
84 wxCoord
XLOG2DEV(wxCoord x
) const { return LogicalToDeviceX(x
); }
85 wxCoord
XLOG2DEVREL(wxCoord x
) const { return LogicalToDeviceXRel(x
); }
86 wxCoord
YLOG2DEV(wxCoord y
) const { return LogicalToDeviceY(y
); }
87 wxCoord
YLOG2DEVREL(wxCoord y
) const { return LogicalToDeviceYRel(y
); }
89 // initializes the DC from a surface, must be called if default ctor
91 void DFBInit(const wxIDirectFBSurfacePtr
& surface
);
93 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
94 wxFloodFillStyle style
= wxFLOOD_SURFACE
);
96 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const;
98 virtual void DoDrawPoint(wxCoord x
, wxCoord y
);
99 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
);
101 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
102 wxCoord x2
, wxCoord y2
,
103 wxCoord xc
, wxCoord yc
);
104 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
105 double sa
, double ea
);
107 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
108 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
109 wxCoord width
, wxCoord height
,
111 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
113 virtual void DoCrossHair(wxCoord x
, wxCoord y
);
115 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
);
116 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
117 bool useMask
= false);
119 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
120 virtual void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
,
123 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
124 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
125 wxRasterOperationMode rop
= wxCOPY
, bool useMask
= false,
126 wxCoord xsrcMask
= -1, wxCoord ysrcMask
= -1);
128 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
129 wxCoord width
, wxCoord height
);
130 virtual void DoSetDeviceClippingRegion(const wxRegion
& region
);
132 virtual void DoGetSize(int *width
, int *height
) const;
133 virtual void DoGetSizeMM(int* width
, int* height
) const;
135 virtual void DoDrawLines(int n
, wxPoint points
[],
136 wxCoord xoffset
, wxCoord yoffset
);
137 virtual void DoDrawPolygon(int n
, wxPoint points
[],
138 wxCoord xoffset
, wxCoord yoffset
,
139 wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
);
141 // implementation from now on:
143 wxIDirectFBFontPtr
GetCurrentFont() const;
146 // Unified implementation of DrawIcon, DrawBitmap and Blit:
147 void DoDrawSubBitmap(const wxBitmap
&bmp
,
148 wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
149 wxCoord destx
, wxCoord desty
, int rop
, bool useMask
);
150 bool DoBlitFromSurface(const wxIDirectFBSurfacePtr
& src
,
151 wxCoord srcx
, wxCoord srcy
,
152 wxCoord w
, wxCoord h
,
153 wxCoord dstx
, wxCoord dsty
);
155 // selects colour into surface's state
156 void SelectColour(const wxColour
& clr
);
159 wxIDirectFBSurfacePtr m_surface
;
161 double m_mm_to_pix_x
, m_mm_to_pix_y
;
163 friend class WXDLLIMPEXP_FWD_CORE wxOverlayImpl
; // for Init
165 DECLARE_ABSTRACT_CLASS(wxDFBDCImpl
)
168 #endif // _WX_DFB_DC_H_