]> git.saurik.com Git - wxWidgets.git/blobdiff - src/dfb/dc.cpp
wxStatusBarGeneric is used directly so the header needs to be included too
[wxWidgets.git] / src / dfb / dc.cpp
index 752291010e1073b02f901ae06447eb80b37e5936..f5d6a1691ddcf77cefcdde57a929480a5964f6a2 100644 (file)
@@ -92,11 +92,16 @@ void wxDC::DoSetClippingRegion(wxCoord cx, wxCoord cy, wxCoord cw, wxCoord ch)
 {
     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;
@@ -146,6 +151,10 @@ void wxDC::Clear()
 
     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,
@@ -201,7 +210,12 @@ void wxDC::DoDrawPoint(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))
@@ -284,7 +298,7 @@ void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y)
     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;