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 // Returns the surface (and increases its ref count)
69 wxIDirectFBSurfacePtr
GetDirectFBSurface() const { return m_surface
; }
73 wxCoord
XDEV2LOG(wxCoord x
) const { return DeviceToLogicalX(x
); }
74 wxCoord
XDEV2LOGREL(wxCoord x
) const { return DeviceToLogicalXRel(x
); }
75 wxCoord
YDEV2LOG(wxCoord y
) const { return DeviceToLogicalY(y
); }
76 wxCoord
YDEV2LOGREL(wxCoord y
) const { return DeviceToLogicalYRel(y
); }
77 wxCoord
XLOG2DEV(wxCoord x
) const { return LogicalToDeviceX(x
); }
78 wxCoord
XLOG2DEVREL(wxCoord x
) const { return LogicalToDeviceXRel(x
); }
79 wxCoord
YLOG2DEV(wxCoord y
) const { return LogicalToDeviceY(y
); }
80 wxCoord
YLOG2DEVREL(wxCoord y
) const { return LogicalToDeviceYRel(y
); }
82 // initializes the DC from a surface, must be called if default ctor
84 void DFBInit(const wxIDirectFBSurfacePtr
& surface
);
86 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
87 int style
= wxFLOOD_SURFACE
);
89 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const;
91 virtual void DoDrawPoint(wxCoord x
, wxCoord y
);
92 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
);
94 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
95 wxCoord x2
, wxCoord y2
,
96 wxCoord xc
, wxCoord yc
);
97 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
98 double sa
, double ea
);
100 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
101 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
102 wxCoord width
, wxCoord height
,
104 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
106 virtual void DoCrossHair(wxCoord x
, wxCoord y
);
108 virtual void DoDrawIcon(const wxIcon
& icon
, wxCoord x
, wxCoord y
);
109 virtual void DoDrawBitmap(const wxBitmap
&bmp
, wxCoord x
, wxCoord y
,
110 bool useMask
= false);
112 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
113 virtual void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
,
116 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
117 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
118 int rop
= wxCOPY
, bool useMask
= false, wxCoord xsrcMask
= -1, wxCoord ysrcMask
= -1);
120 // this is gnarly - we can't even call this function DoSetClippingRegion()
121 // because of virtual function hiding
122 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
);
123 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
124 wxCoord width
, wxCoord height
);
126 virtual void DoGetSize(int *width
, int *height
) const;
127 virtual void DoGetSizeMM(int* width
, int* height
) const;
129 virtual void DoDrawLines(int n
, wxPoint points
[],
130 wxCoord xoffset
, wxCoord yoffset
);
131 virtual void DoDrawPolygon(int n
, wxPoint points
[],
132 wxCoord xoffset
, wxCoord yoffset
,
133 int fillStyle
= wxODDEVEN_RULE
);
135 // implementation from now on:
137 wxIDirectFBFontPtr
GetCurrentFont() const;
140 // Unified implementation of DrawIcon, DrawBitmap and Blit:
141 void DoDrawSubBitmap(const wxBitmap
&bmp
,
142 wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
143 wxCoord destx
, wxCoord desty
, int rop
, bool useMask
);
144 bool DoBlitFromSurface(const wxIDirectFBSurfacePtr
& src
,
145 wxCoord srcx
, wxCoord srcy
,
146 wxCoord w
, wxCoord h
,
147 wxCoord dstx
, wxCoord dsty
);
149 // selects colour into surface's state
150 void SelectColour(const wxColour
& clr
);
153 wxIDirectFBSurfacePtr m_surface
;
155 double m_mm_to_pix_x
, m_mm_to_pix_y
;
157 friend class WXDLLIMPEXP_CORE wxOverlayImpl
; // for Init
159 DECLARE_DYNAMIC_CLASS(wxDC
)
162 #endif // _WX_DFB_DC_H_