X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/23205be83c2a88b1aa7204d2cee52ca8a755e698..eea4d01c65f9b29baa1193db762b4c6b8144af24:/src/dfb/dc.cpp diff --git a/src/dfb/dc.cpp b/src/dfb/dc.cpp index 8093bec3d2..0f00dfffbf 100644 --- a/src/dfb/dc.cpp +++ b/src/dfb/dc.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // Name: src/dfb/dc.cpp -// Purpose: wxDC class +// Purpose: wxDFBDCImpl class // Author: Vaclav Slavik // Created: 2006-08-07 // RCS-ID: $Id$ @@ -24,11 +24,11 @@ #endif #ifndef WX_PRECOMP - #include "wx/dc.h" #include "wx/dcmemory.h" #include "wx/log.h" #endif +#include "wx/dfb/dc.h" #include "wx/dfb/private.h" // these values are used to initialize newly created DC @@ -41,29 +41,17 @@ // =========================================================================== //----------------------------------------------------------------------------- -// wxDC +// wxDFBDCImpl //----------------------------------------------------------------------------- -IMPLEMENT_ABSTRACT_CLASS(wxDC, wxDCBase) +IMPLEMENT_ABSTRACT_CLASS(wxDFBDCImpl, wxDCImpl) -// Default constructor -wxDC::wxDC() +void wxDFBDCImpl::DFBInit(const wxIDirectFBSurfacePtr& surface) { - m_ok = false; -} - -wxDC::wxDC(const wxIDirectFBSurfacePtr& surface) -{ - DFBInit(surface); -} - -void wxDC::DFBInit(const wxIDirectFBSurfacePtr& surface) -{ - m_ok = (surface != NULL); - wxCHECK_RET( surface != NULL, _T("invalid surface") ); - m_surface = surface; + wxCHECK_RET( surface != NULL, "invalid surface" ); + m_mm_to_pix_x = (double)wxGetDisplaySize().GetWidth() / (double)wxGetDisplaySizeMM().GetWidth(); m_mm_to_pix_y = (double)wxGetDisplaySize().GetHeight() / @@ -79,14 +67,14 @@ void wxDC::DFBInit(const wxIDirectFBSurfacePtr& surface) // clipping // --------------------------------------------------------------------------- -void wxDC::DoSetClippingRegion(wxCoord cx, wxCoord cy, wxCoord cw, wxCoord ch) +void wxDFBDCImpl::DoSetClippingRegion(wxCoord cx, wxCoord cy, wxCoord cw, wxCoord ch) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); wxSize size(GetSize()); wxASSERT_MSG( !m_clipping, - _T("narrowing clipping region not implemented yet") ); + "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 @@ -107,15 +95,24 @@ void wxDC::DoSetClippingRegion(wxCoord cx, wxCoord cy, wxCoord cw, wxCoord ch) m_clipping = true; } -void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region) +void wxDFBDCImpl::DoSetDeviceClippingRegion(const wxRegion& region) { // NB: this can be done because wxDFB only supports rectangular regions - SetClippingRegion(region.AsRect()); + wxRect rect = region.AsRect(); + + // our parameter is in physical coordinates while DoSetClippingRegion() + // takes logical ones + rect.x = XDEV2LOG(rect.x); + rect.y = YDEV2LOG(rect.y); + rect.width = XDEV2LOG(rect.width); + rect.height = YDEV2LOG(rect.height); + + DoSetClippingRegion(rect.x, rect.y, rect.width, rect.height); } -void wxDC::DestroyClippingRegion() +void wxDFBDCImpl::DestroyClippingRegion() { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); m_surface->SetClip(NULL); @@ -126,7 +123,7 @@ void wxDC::DestroyClippingRegion() // query capabilities // --------------------------------------------------------------------------- -int wxDC::GetDepth() const +int wxDFBDCImpl::GetDepth() const { return m_surface->GetDepth(); } @@ -135,9 +132,9 @@ int wxDC::GetDepth() const // drawing // --------------------------------------------------------------------------- -void wxDC::Clear() +void wxDFBDCImpl::Clear() { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); if ( m_backgroundBrush.GetStyle() == wxTRANSPARENT ) return; @@ -151,32 +148,39 @@ void wxDC::Clear() } extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y, - const wxColour & col, int style); + const wxColour & col, wxFloodFillStyle style); -bool wxDC::DoFloodFill(wxCoord x, wxCoord y, - const wxColour& col, int style) +bool wxDFBDCImpl::DoFloodFill(wxCoord x, wxCoord y, + const wxColour& col, wxFloodFillStyle style) { - return wxDoFloodFill(this, x, y, col, style); + return wxDoFloodFill(GetOwner(), x, y, col, style); } -bool wxDC::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const +bool wxDFBDCImpl::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const { - wxCHECK_MSG( col, false, _T("NULL colour parameter in wxDC::GetPixel")); + wxCHECK_MSG( col, false, "NULL colour parameter in wxDFBDCImpl::GetPixel"); + + wxFAIL_MSG( "GetPixel not implemented" ); + + wxUnusedVar(x); + wxUnusedVar(y); - wxFAIL_MSG( _T("GetPixel not implemented") ); return false; } -void wxDC::DoCrossHair(wxCoord x, wxCoord y) +void wxDFBDCImpl::DoCrossHair(wxCoord x, wxCoord y) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); - wxFAIL_MSG( _T("CrossHair not implemented") ); + wxFAIL_MSG( "CrossHair not implemented" ); + + wxUnusedVar(x); + wxUnusedVar(y); } -void wxDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) +void wxDFBDCImpl::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); if ( m_pen.GetStyle() == wxTRANSPARENT ) return; @@ -214,18 +218,18 @@ void wxDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) // Draws an arc of a circle, centred on (xc, yc), with starting point (x1, y1) // and ending at (x2, y2) -void wxDC::DoDrawArc(wxCoord x1, wxCoord y1, - wxCoord x2, wxCoord y2, - wxCoord xc, wxCoord yc) +void wxDFBDCImpl::DoDrawArc(wxCoord WXUNUSED(x1), wxCoord WXUNUSED(y1), + wxCoord WXUNUSED(x2), wxCoord WXUNUSED(y2), + wxCoord WXUNUSED(xc), wxCoord WXUNUSED(yc)) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); - wxFAIL_MSG( _T("DrawArc not implemented") ); + wxFAIL_MSG( "DrawArc not implemented" ); } -void wxDC::DoDrawPoint(wxCoord x, wxCoord y) +void wxDFBDCImpl::DoDrawPoint(wxCoord x, wxCoord y) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); // 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 @@ -235,24 +239,27 @@ void wxDC::DoDrawPoint(wxCoord x, wxCoord 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)) +void wxDFBDCImpl::DoDrawPolygon(int WXUNUSED(n), wxPoint WXUNUSED(points)[], + wxCoord WXUNUSED(xoffset), wxCoord WXUNUSED(yoffset), + wxPolygonFillMode WXUNUSED(fillStyle)) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); - wxFAIL_MSG( _T("DrawPolygon not implemented") ); + wxFAIL_MSG( "DrawPolygon not implemented" ); } -void wxDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset) +void wxDFBDCImpl::DoDrawLines(int WXUNUSED(n), wxPoint WXUNUSED(points)[], + wxCoord WXUNUSED(xoffset), wxCoord WXUNUSED(yoffset)) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); // TODO: impl. using DirectDB's DrawLines - wxFAIL_MSG( _T("DrawLines not implemented") ); + wxFAIL_MSG( "DrawLines not implemented" ); } -void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) +void wxDFBDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); wxCoord xx = XLOG2DEV(x); wxCoord yy = YLOG2DEV(y); @@ -290,30 +297,42 @@ void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) CalcBoundingBox(x + width, y + height); } -void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius) +void wxDFBDCImpl::DoDrawRoundedRectangle(wxCoord WXUNUSED(x), + wxCoord WXUNUSED(y), + wxCoord WXUNUSED(width), + wxCoord WXUNUSED(height), + double WXUNUSED(radius)) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); - wxFAIL_MSG( _T("DrawRoundedRectangle not implemented") ); + wxFAIL_MSG( "DrawRoundedRectangle not implemented" ); } -void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) +void wxDFBDCImpl::DoDrawEllipse(wxCoord WXUNUSED(x), + wxCoord WXUNUSED(y), + wxCoord WXUNUSED(width), + wxCoord WXUNUSED(height)) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); - wxFAIL_MSG( _T("DrawElipse not implemented") ); + wxFAIL_MSG( "DrawElipse not implemented" ); } -void wxDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) +void wxDFBDCImpl::DoDrawEllipticArc(wxCoord WXUNUSED(x), + wxCoord WXUNUSED(y), + wxCoord WXUNUSED(w), + wxCoord WXUNUSED(h), + double WXUNUSED(sa), + double WXUNUSED(ea)) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); - wxFAIL_MSG( _T("DrawElipticArc not implemented") ); + wxFAIL_MSG( "DrawElipticArc not implemented" ); } -void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y) +void wxDFBDCImpl::DoDrawText(const wxString& text, wxCoord x, wxCoord y) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); wxCoord xx = XLOG2DEV(x); wxCoord yy = YLOG2DEV(y); @@ -321,13 +340,13 @@ void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y) // update the bounding box wxCoord w, h; CalcBoundingBox(x, y); - GetTextExtent(text, &w, &h); + DoGetTextExtent(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(), + wxCHECK_RET( m_textBackgroundColour.IsOk(), wxT("invalid background color") ); SelectColour(m_textBackgroundColour); @@ -335,61 +354,61 @@ void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y) } // finally draw the text itself: - wxCHECK_RET( m_textForegroundColour.Ok(), + wxCHECK_RET( m_textForegroundColour.IsOk(), wxT("invalid foreground color") ); SelectColour(m_textForegroundColour); - m_surface->DrawString(wxSTR_TO_DFB(text), -1, xx, yy, DSTF_LEFT | DSTF_TOP); + m_surface->DrawString(text.utf8_str(), -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()); } -void wxDC::DoDrawRotatedText(const wxString& text, - wxCoord x, wxCoord y, - double angle) +void wxDFBDCImpl::DoDrawRotatedText(const wxString& WXUNUSED(text), + wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), + double WXUNUSED(angle)) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); - wxFAIL_MSG( _T("DrawRotatedText not implemented") ); + wxFAIL_MSG( "DrawRotatedText not implemented" ); } // --------------------------------------------------------------------------- // set GDI objects // --------------------------------------------------------------------------- -void wxDC::SetPen(const wxPen& pen) +void wxDFBDCImpl::SetPen(const wxPen& pen) { - m_pen = pen.Ok() ? pen : DEFAULT_PEN; + m_pen = pen.IsOk() ? pen : DEFAULT_PEN; SelectColour(m_pen.GetColour()); } -void wxDC::SetBrush(const wxBrush& brush) +void wxDFBDCImpl::SetBrush(const wxBrush& brush) { - m_brush = brush.Ok() ? brush : DEFAULT_BRUSH; + m_brush = brush.IsOk() ? brush : DEFAULT_BRUSH; } -void wxDC::SelectColour(const wxColour& clr) +void wxDFBDCImpl::SelectColour(const wxColour& clr) { m_surface->SetColor(clr.Red(), clr.Green(), clr.Blue(), clr.Alpha()); #warning "use SetColorIndex?" } #if wxUSE_PALETTE -void wxDC::SetPalette(const wxPalette& WXUNUSED(palette)) +void wxDFBDCImpl::SetPalette(const wxPalette& WXUNUSED(palette)) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); - wxFAIL_MSG( _T("SetPalette not implemented") ); + wxFAIL_MSG( "SetPalette not implemented" ); } #endif // wxUSE_PALETTE -void wxDC::SetFont(const wxFont& font) +void wxDFBDCImpl::SetFont(const wxFont& font) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); - wxFont f(font.Ok() ? font : DEFAULT_FONT); + wxFont f(font.IsOk() ? font : DEFAULT_FONT); wxFont oldfont(m_font); @@ -402,53 +421,53 @@ void wxDC::SetFont(const wxFont& font) } } -wxIDirectFBFontPtr wxDC::GetCurrentFont() const +wxIDirectFBFontPtr wxDFBDCImpl::GetCurrentFont() const { bool aa = (GetDepth() > 8); return m_font.GetDirectFBFont(aa); } -void wxDC::SetBackground(const wxBrush& brush) +void wxDFBDCImpl::SetBackground(const wxBrush& brush) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); - if (!brush.Ok()) return; + if (!brush.IsOk()) return; m_backgroundBrush = brush; } -void wxDC::SetBackgroundMode(int mode) +void wxDFBDCImpl::SetBackgroundMode(int mode) { m_backgroundMode = mode; } -void wxDC::SetLogicalFunction(int function) +void wxDFBDCImpl::SetLogicalFunction(wxRasterOperationMode function) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); // NB: we could also support XOR, but for blitting only (via DSBLIT_XOR); // and possibly others via SetSrc/DstBlendFunction() wxASSERT_MSG( function == wxCOPY, - _T("only wxCOPY logical function supported") ); + "only wxCOPY logical function supported" ); m_logicalFunction = function; } -bool wxDC::StartDoc(const wxString& WXUNUSED(message)) +bool wxDFBDCImpl::StartDoc(const wxString& WXUNUSED(message)) { // We might be previewing, so return true to let it continue. return true; } -void wxDC::EndDoc() +void wxDFBDCImpl::EndDoc() { } -void wxDC::StartPage() +void wxDFBDCImpl::StartPage() { } -void wxDC::EndPage() +void wxDFBDCImpl::EndPage() { } @@ -456,20 +475,20 @@ void wxDC::EndPage() // text metrics // --------------------------------------------------------------------------- -wxCoord wxDC::GetCharHeight() const +wxCoord wxDFBDCImpl::GetCharHeight() const { - wxCHECK_MSG( Ok(), -1, wxT("invalid dc") ); - wxCHECK_MSG( m_font.Ok(), -1, wxT("no font selected") ); + wxCHECK_MSG( IsOk(), -1, wxT("invalid dc") ); + wxCHECK_MSG( m_font.IsOk(), -1, wxT("no font selected") ); int h = -1; GetCurrentFont()->GetHeight(&h); return YDEV2LOGREL(h); } -wxCoord wxDC::GetCharWidth() const +wxCoord wxDFBDCImpl::GetCharWidth() const { - wxCHECK_MSG( Ok(), -1, wxT("invalid dc") ); - wxCHECK_MSG( m_font.Ok(), -1, wxT("no font selected") ); + wxCHECK_MSG( IsOk(), -1, wxT("invalid dc") ); + wxCHECK_MSG( m_font.IsOk(), -1, wxT("no font selected") ); int w = -1; GetCurrentFont()->GetStringWidth("H", 1, &w); @@ -478,26 +497,26 @@ wxCoord wxDC::GetCharWidth() const return YDEV2LOGREL(w); } -void wxDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y, +void wxDFBDCImpl::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y, wxCoord *descent, wxCoord *externalLeading, - wxFont *theFont) const + const wxFont *theFont) const { - wxCHECK_RET( Ok(), wxT("invalid dc") ); - wxCHECK_RET( m_font.Ok(), wxT("no font selected") ); - wxCHECK_RET( !theFont || theFont->Ok(), wxT("invalid font") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); + wxCHECK_RET( m_font.IsOk(), wxT("no font selected") ); + wxCHECK_RET( !theFont || theFont->IsOk(), wxT("invalid font") ); wxFont oldFont; if ( theFont != NULL ) { oldFont = m_font; - wxConstCast(this, wxDC)->SetFont(*theFont); + wxConstCast(this, wxDFBDCImpl)->SetFont(*theFont); } wxCoord xx = 0, yy = 0; DFBRectangle rect; wxIDirectFBFontPtr f = GetCurrentFont(); - if ( f->GetStringExtents(wxSTR_TO_DFB(string), -1, &rect, NULL) ) + if ( f->GetStringExtents(string.utf8_str(), -1, &rect, NULL) ) { // VS: YDEV is corrent, it should *not* be XDEV, because font's are // only scaled according to m_scaleY @@ -519,7 +538,7 @@ void wxDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y, if ( externalLeading ) *externalLeading = 0; if ( theFont != NULL ) - wxConstCast(this, wxDC)->SetFont(oldFont); + wxConstCast(this, wxDFBDCImpl)->SetFont(oldFont); } @@ -528,140 +547,18 @@ void wxDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y, // mapping modes // --------------------------------------------------------------------------- -void wxDC::ComputeScaleAndOrigin() -{ - m_scaleX = m_logicalScaleX * m_userScaleX; - m_scaleY = m_logicalScaleY * m_userScaleY; - - // FIXME_DFB: scaling affects pixel size of font, pens, brushes, which - // is not currently implemented here; probably makes sense to - // switch to Cairo instead of implementing everything for DFB - wxASSERT_MSG( m_scaleX == 1.0 && m_scaleY == 1.0, - _T("scaling is not implemented in wxDFB") ); -} - -void wxDC::SetMapMode(int mode) -{ - #warning "move this to common code, it's shared by almost all ports!" - switch (mode) - { - case wxMM_TWIPS: - SetLogicalScale(twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y); - break; - case wxMM_POINTS: - SetLogicalScale(pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y); - break; - case wxMM_METRIC: - SetLogicalScale(m_mm_to_pix_x, m_mm_to_pix_y); - break; - case wxMM_LOMETRIC: - SetLogicalScale(m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0); - break; - default: - case wxMM_TEXT: - SetLogicalScale(1.0, 1.0); - break; - } - m_mappingMode = mode; -} - -void wxDC::SetUserScale(double x, double y) -{ - #warning "move this to common code?" - // allow negative ? -> no - m_userScaleX = x; - m_userScaleY = y; - ComputeScaleAndOrigin(); -} - -void wxDC::SetLogicalScale(double x, double y) -{ - #warning "move this to common code?" - // allow negative ? - m_logicalScaleX = x; - m_logicalScaleY = y; - ComputeScaleAndOrigin(); -} - -void wxDC::SetLogicalOrigin( wxCoord x, wxCoord y ) -{ - #warning "move this to common code?" - m_logicalOriginX = x * m_signX; // is this still correct ? - m_logicalOriginY = y * m_signY; - ComputeScaleAndOrigin(); -} - -void wxDC::SetDeviceOrigin( wxCoord x, wxCoord y ) -{ - #warning "move this to common code?" - // only wxPostScripDC has m_signX = -1, we override SetDeviceOrigin there - m_deviceOriginX = x; - m_deviceOriginY = y; - ComputeScaleAndOrigin(); -} - -void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) -{ - #warning "move this to common code?" - // only wxPostScripDC has m_signX = -1, we override SetAxisOrientation there - m_signX = (xLeftRight ? 1 : -1); - m_signY = (yBottomUp ? -1 : 1); - ComputeScaleAndOrigin(); -} - -// --------------------------------------------------------------------------- -// coordinates transformations -// --------------------------------------------------------------------------- - -wxCoord wxDCBase::DeviceToLogicalX(wxCoord x) const -{ - return ((wxDC *)this)->XDEV2LOG(x); -} - -wxCoord wxDCBase::DeviceToLogicalY(wxCoord y) const -{ - return ((wxDC *)this)->YDEV2LOG(y); -} - -wxCoord wxDCBase::DeviceToLogicalXRel(wxCoord x) const -{ - return ((wxDC *)this)->XDEV2LOGREL(x); -} - -wxCoord wxDCBase::DeviceToLogicalYRel(wxCoord y) const -{ - return ((wxDC *)this)->YDEV2LOGREL(y); -} - -wxCoord wxDCBase::LogicalToDeviceX(wxCoord x) const -{ - return ((wxDC *)this)->XLOG2DEV(x); -} - -wxCoord wxDCBase::LogicalToDeviceY(wxCoord y) const -{ - return ((wxDC *)this)->YLOG2DEV(y); -} - -wxCoord wxDCBase::LogicalToDeviceXRel(wxCoord x) const -{ - return ((wxDC *)this)->XLOG2DEVREL(x); -} - -wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const -{ - return ((wxDC *)this)->YLOG2DEVREL(y); -} - +// FIXME_DFB: scaling affects pixel size of font, pens, brushes, which +// is not currently implemented here; probably makes sense to +// switch to Cairo instead of implementing everything for DFB -void wxDC::DoGetSize(int *w, int *h) const +void wxDFBDCImpl::DoGetSize(int *w, int *h) const { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); m_surface->GetSize(w, h); } -void wxDC::DoGetSizeMM(int *width, int *height) const +void wxDFBDCImpl::DoGetSizeMM(int *width, int *height) const { #warning "move this to common code?" int w = 0; @@ -671,7 +568,7 @@ void wxDC::DoGetSizeMM(int *width, int *height) const if ( height ) *height = int(double(h) / (m_userScaleY*m_mm_to_pix_y)); } -wxSize wxDC::GetPPI() const +wxSize wxDFBDCImpl::GetPPI() const { #warning "move this to common code?" return wxSize(int(double(m_mm_to_pix_x) * inches2mm), @@ -683,18 +580,18 @@ wxSize wxDC::GetPPI() const // Blitting // --------------------------------------------------------------------------- -bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, - wxCoord width, wxCoord height, - wxDC *source, wxCoord xsrc, wxCoord ysrc, - int rop, bool useMask, - wxCoord xsrcMask, wxCoord ysrcMask) +bool wxDFBDCImpl::DoBlit(wxCoord xdest, wxCoord ydest, + wxCoord width, wxCoord height, + wxDC *source, wxCoord xsrc, wxCoord ysrc, + wxRasterOperationMode rop, bool useMask, + wxCoord xsrcMask, wxCoord ysrcMask) { - wxCHECK_MSG( Ok(), false, _T("invalid dc") ); - wxCHECK_MSG( source, false, _T("invalid source dc") ); + wxCHECK_MSG( IsOk(), false, "invalid dc" ); + wxCHECK_MSG( source, false, "invalid source dc" ); // NB: we could also support XOR here (via DSBLIT_XOR) // and possibly others via SetSrc/DstBlendFunction() - wxCHECK_MSG( rop == wxCOPY, false, _T("only wxCOPY function supported") ); + wxCHECK_MSG( rop == wxCOPY, false, "only wxCOPY function supported" ); // transform the source DC coords to the device ones xsrc = source->LogicalToDeviceX(xsrc); @@ -702,7 +599,7 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, // FIXME_DFB: use the mask origin when drawing transparently wxASSERT_MSG( xsrcMask == -1 && ysrcMask == -1, - _T("non-default source mask offset not implemented") ); + "non-default source mask offset not implemented" ); #if 0 if (xsrcMask == -1 && ysrcMask == -1) { @@ -718,7 +615,7 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxMemoryDC *sourceAsMemDC = wxDynamicCast(source, wxMemoryDC); if ( sourceAsMemDC ) { - DoDrawSubBitmap(sourceAsMemDC->GetSelectedObject(), + DoDrawSubBitmap(sourceAsMemDC->GetSelectedBitmap(), xsrc, ysrc, width, height, xdest, ydest, @@ -727,19 +624,23 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, } else { - return DoBlitFromSurface(source->GetDirectFBSurface(), - xsrc, ysrc, - width, height, - xdest, ydest); + return DoBlitFromSurface + ( + static_cast(source->GetImpl()) + ->GetDirectFBSurface(), + xsrc, ysrc, + width, height, + xdest, ydest + ); } return true; } -void wxDC::DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask) +void wxDFBDCImpl::DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); - wxCHECK_RET( bmp.Ok(), wxT("invalid bitmap") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); + wxCHECK_RET( bmp.IsOk(), wxT("invalid bitmap") ); DoDrawSubBitmap(bmp, 0, 0, bmp.GetWidth(), bmp.GetHeight(), @@ -747,28 +648,28 @@ void wxDC::DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask) m_logicalFunction, useMask); } -void wxDC::DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) +void wxDFBDCImpl::DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) { // VZ: egcs 1.0.3 refuses to compile this without cast, no idea why DoDrawBitmap((const wxBitmap&)icon, x, y, true); } -void wxDC::DoDrawSubBitmap(const wxBitmap &bmp, +void wxDFBDCImpl::DoDrawSubBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, wxCoord w, wxCoord h, wxCoord destx, wxCoord desty, int rop, bool useMask) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); - wxCHECK_RET( bmp.Ok(), wxT("invalid bitmap") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); + wxCHECK_RET( bmp.IsOk(), wxT("invalid bitmap") ); // NB: we could also support XOR here (via DSBLIT_XOR) // and possibly others via SetSrc/DstBlendFunction() - wxCHECK_RET( rop == wxCOPY, _T("only wxCOPY function supported") ); + wxCHECK_RET( rop == wxCOPY, "only wxCOPY function supported" ); if ( bmp.GetDepth() == 1 ) { // Mono bitmaps are handled in special way -- all 1s are drawn in // foreground colours, all 0s in background colour. - wxFAIL_MSG( _T("drawing mono bitmaps not implemented") ); + wxFAIL_MSG( "drawing mono bitmaps not implemented" ); return; } @@ -778,7 +679,7 @@ void wxDC::DoDrawSubBitmap(const wxBitmap &bmp, // applicable because DirectFB doesn't implement ROPs; OTOH, // it has blitting modes that can be useful; finally, see // DFB's SetSrcBlendFunction() and SetSrcColorKey() - wxFAIL_MSG( _T("drawing bitmaps with masks not implemented") ); + wxFAIL_MSG( "drawing bitmaps with masks not implemented" ); return; } @@ -788,10 +689,10 @@ void wxDC::DoDrawSubBitmap(const wxBitmap &bmp, destx, desty); } -bool wxDC::DoBlitFromSurface(const wxIDirectFBSurfacePtr& src, - wxCoord srcx, wxCoord srcy, - wxCoord w, wxCoord h, - wxCoord dstx, wxCoord dsty) +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: @@ -799,7 +700,7 @@ bool wxDC::DoBlitFromSurface(const wxIDirectFBSurfacePtr& src, src->GetSize(&srcsize.x, &srcsize.y); if ( !wxRect(srcx, srcy, w, h).Intersects(wxRect(srcsize)) ) { - wxLogDebug(_T("Blitting from area outside of the source surface, caller code needs fixing.")); + wxLogDebug("Blitting from area outside of the source surface, caller code needs fixing."); return false; } @@ -813,7 +714,10 @@ bool wxDC::DoBlitFromSurface(const wxIDirectFBSurfacePtr& src, wxIDirectFBSurfacePtr dst(m_surface); // FIXME: this will have to be different in useMask case, see above - if ( !dst->SetBlittingFlags(DSBLIT_NOFX) ) + 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 )