void wxDC::DoSetClippingRegion(wxCoord cx, wxCoord cy, wxCoord cw, wxCoord ch) { wxCHECK_RET( Ok(), wxT("invalid dc") ); wxSize size(GetSize()); wxASSERT_MSG( !m_clipping, _T("narrowing clipping region not implemented yet") ); // 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 = 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; m_clipX1 = cx; m_clipY1 = cy; m_clipX2 = cx + cw - 1; m_clipY2 = cy + ch -1; m_clipping = true; }
void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y) { wxCHECK_RET( Ok(), wxT("invalid dc") ); wxCoord xx = XLOG2DEV(x); wxCoord yy = YLOG2DEV(y); // update the bounding box wxCoord w, h; CalcBoundingBox(x, y); GetTextExtent(text, &w, &h); CalcBoundingBox(x + w, y + h); // if background mode is solid, DrawText must paint text's background: if ( m_backgroundMode == wxSOLID ) { wxCHECK_RET( m_textBackgroundColour.Ok(), wxT("invalid background color") ); SelectColour(m_textBackgroundColour); m_surface->FillRectangle(xx, yy, XLOG2DEVREL(w), YLOG2DEVREL(h)); } // finally draw the text itself: wxCHECK_RET( m_textForegroundColour.Ok(), wxT("invalid foreground color") ); SelectColour(m_textForegroundColour); m_surface->DrawString(wxSTR_TO_DFB(text), -1, xx, yy, DSTF_LEFT | DSTF_TOP); // restore pen's colour, because other drawing functions expect the colour // to be set to the pen: SelectColour(m_pen.GetColour()); }
bool wxDFBDCImpl::DoBlitFromSurface(const wxIDirectFBSurfacePtr& src, wxCoord srcx, wxCoord srcy, wxCoord w, wxCoord h, wxCoord dstx, wxCoord dsty) { // don't do anything if the source rectangle is outside of source surface, // DirectFB would assert in that case: wxSize srcsize; src->GetSize(&srcsize.x, &srcsize.y); if ( !wxRect(srcx, srcy, w, h).Intersects(wxRect(srcsize)) ) { wxLogDebug("Blitting from area outside of the source surface, caller code needs fixing."); return false; } CalcBoundingBox(dstx, dsty); CalcBoundingBox(dstx + w, dsty + h); DFBRectangle srcRect = { srcx, srcy, w, h }; DFBRectangle dstRect = { XLOG2DEV(dstx), YLOG2DEV(dsty), XLOG2DEVREL(w), YLOG2DEVREL(h) }; wxIDirectFBSurfacePtr dst(m_surface); // FIXME: this will have to be different in useMask case, see above DFBSurfaceBlittingFlags blitFlag = (src->GetPixelFormat() == DSPF_ARGB) ? DSBLIT_BLEND_ALPHACHANNEL : DSBLIT_NOFX; if ( !dst->SetBlittingFlags(blitFlag) ) return false; if ( srcRect.w != dstRect.w || srcRect.h != dstRect.h ) { // the bitmap is drawn stretched: dst->StretchBlit(src, &srcRect, &dstRect); } else { // no stretching, size is preserved: dst->Blit(src, &srcRect, dstRect.x, dstRect.y); } return true; }
void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { wxCHECK_RET( Ok(), wxT("invalid dc") ); wxCoord xx = XLOG2DEV(x); wxCoord yy = YLOG2DEV(y); wxCoord ww = m_signX * XLOG2DEVREL(width); wxCoord hh = m_signY * YLOG2DEVREL(height); if ( ww == 0 || hh == 0 ) return; if ( ww < 0 ) { ww = -ww; xx = xx - ww; } if ( hh < 0 ) { hh = -hh; yy = yy - hh; } if ( m_brush.GetStyle() != wxTRANSPARENT ) { SelectColour(m_brush.GetColour()); m_surface->FillRectangle(xx, yy, ww, hh); // restore pen's colour, because other drawing functions expect the // colour to be set to the pen: SelectColour(m_pen.GetColour()); } if ( m_pen.GetStyle() != wxTRANSPARENT ) { m_surface->DrawRectangle(xx, yy, ww, hh); } CalcBoundingBox(x, y); CalcBoundingBox(x + width, y + height); }
wxCoord wxSVGFileDC::LogicalToDeviceXRel(wxCoord x) const { return XLOG2DEVREL(x); }