#include "wx/dfb/private.h"
+// these values are used to initialize newly created DC
+#define DEFAULT_FONT (*wxNORMAL_FONT)
+#define DEFAULT_PEN (*wxBLACK_PEN)
+#define DEFAULT_BRUSH (*wxWHITE_BRUSH)
+
// ===========================================================================
// implementation
// ===========================================================================
m_mm_to_pix_y = (double)wxGetDisplaySize().GetHeight() /
(double)wxGetDisplaySizeMM().GetHeight();
- SetFont(*wxNORMAL_FONT);
- SetPen(*wxBLACK_PEN);
- SetBrush(*wxWHITE_BRUSH);
+ SetFont(DEFAULT_FONT);
+ SetPen(DEFAULT_PEN);
+ SetBrush(DEFAULT_BRUSH);
}
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
+ wxSize size(GetSize());
+
+ // NB: We intersect the clipping rectangle with surface's area here because
+ // DirectFB will return an error if you try to set clipping rectangle
+ // that is partially outside of the surface.
DFBRegion r;
- r.x1 = XLOG2DEV(cx);
- r.y1 = YLOG2DEV(cy);
- r.x2 = r.x1 + XLOG2DEVREL(cw) - 1;
- r.y2 = r.y1 + XLOG2DEVREL(ch) - 1;
+ r.x1 = wxMax(0, XLOG2DEV(cx));
+ r.y1 = wxMax(0, YLOG2DEV(cy));
+ r.x2 = wxMin(r.x1 + XLOG2DEVREL(cw), size.x) - 1;
+ r.y2 = wxMin(r.y1 + YLOG2DEVREL(ch), size.y) - 1;
if ( !m_surface->SetClip(&r) )
return;
int wxDC::GetDepth() const
{
- return wxDfbGetSurfaceDepth(m_surface);
+ return m_surface->GetDepth();
}
// ---------------------------------------------------------------------------
wxColour clr = m_backgroundBrush.GetColour();
m_surface->Clear(clr.Red(), clr.Green(), clr.Blue(), clr.Alpha());
+
+ wxSize size(GetSize());
+ CalcBoundingBox(XDEV2LOG(0), YDEV2LOG(0));
+ CalcBoundingBox(XDEV2LOG(size.x), YDEV2LOG(size.y));
}
extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y,
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
- wxFAIL_MSG( _T("DrawPoint not implemented") );
+ // NB: DirectFB API doesn't provide a function for drawing points, so
+ // implement it as 1px long line. This is inefficient, but then, so is
+ // using DrawPoint() for drawing more than a few points.
+ DoDrawLine(x, y, x, y);
+
+ // FIXME_DFB: implement special cases for common formats (RGB24,RGBA/RGB32)
}
void wxDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset,int WXUNUSED(fillStyle))
wxCHECK_RET( Ok(), wxT("invalid dc") );
wxCoord xx = XLOG2DEV(x);
- wxCoord yy = XLOG2DEV(y);
+ wxCoord yy = YLOG2DEV(y);
// update the bounding box
wxCoord w, h;
void wxDC::SetPen(const wxPen& pen)
{
- if ( !pen.Ok() ) return;
- m_pen = pen;
+ m_pen = pen.Ok() ? pen : DEFAULT_PEN;
SelectColour(m_pen.GetColour());
}
void wxDC::SetBrush(const wxBrush& brush)
{
- if ( !brush.Ok() ) return;
- m_brush = brush;
+ m_brush = brush.Ok() ? brush : DEFAULT_BRUSH;
}
void wxDC::SelectColour(const wxColour& clr)
{
wxCHECK_RET( Ok(), wxT("invalid dc") );
- if ( !font.Ok() )
- return;
+ wxFont f(font.Ok() ? font : DEFAULT_FONT);
- if ( !m_surface->SetFont(font.GetDirectFBFont()) )
+ if ( !m_surface->SetFont(f.GetDirectFBFont()) )
return;
- m_font = font;
+ m_font = f;
}
void wxDC::SetBackground(const wxBrush& brush)