From 395a30002e6195b65e1a87a4372a4f5351c31d9c Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Wed, 11 Dec 2019 23:20:11 +0100 Subject: [PATCH] Always draw text with wxCOPY raster operation mode on wxGCDC It is said in the wxDC::DrawText() documentation that current logical function is ignored by this function (e928566f). This should apply also to wxGCDC implementation for the sake of consistency and text drawing should be always done with wxCOPY mode regardless of the current mode set. --- src/common/dcgraph.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/common/dcgraph.cpp b/src/common/dcgraph.cpp index 7630da8859..fa5a7558be 100644 --- a/src/common/dcgraph.cpp +++ b/src/common/dcgraph.cpp @@ -1196,14 +1196,20 @@ void wxGCDCImpl::DoDrawText(const wxString& str, wxCoord x, wxCoord y) if ( str.empty() ) return; - if ( !m_logicalFunctionSupported ) - return; + // Text drawing shouldn't be affected by the raster operation + // mode set by SetLogicalFunction() and should be always done + // in the default wxCOPY mode (which is wxCOMPOSITION_OVER + // composition mode). + wxCompositionMode curMode = m_graphicContext->GetCompositionMode(); + m_graphicContext->SetCompositionMode(wxCOMPOSITION_OVER); if ( m_backgroundMode == wxBRUSHSTYLE_TRANSPARENT ) m_graphicContext->DrawText( str, x ,y); else m_graphicContext->DrawText( str, x ,y , m_graphicContext->CreateBrush(m_textBackgroundColour) ); + m_graphicContext->SetCompositionMode(curMode); + wxCoord w, h; GetOwner()->GetTextExtent(str, &w, &h); CalcBoundingBox(x, y);