Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Clearing background with wxGraphicsContext enabled

Help
iwbnwif
2013-08-09
2013-09-10
  • iwbnwif
    iwbnwif
    2013-08-09

    If I enable wxGraphicsContext then the background is not cleared using SetCanvasColour, it is only cleared with a gradient background.

    I think this is because of the following lines in wxSFShapeCanvas::DrawContent:
    dc.SetBackground(wxBrush(m_Settings.m_nBackgroundColor));
    dc.Clear();

    If I change them to:
    wxSize nBcgSize = GetVirtualSize() + wxSize(m_Settings.m_nGridSize.x, m_Settings.m_nGridSize.y);
    dc.SetBrush(wxBrush(m_Settings.m_nBackgroundColor));
    if( m_Settings.m_nScale != 1.f )
    dc.DrawRectangle(wxRect(wxPoint(0, 0), wxSize( nBcgSize.x/m_Settings.m_nScale, nBcgSize.y/m_Settings.m_nScale)));
    else
    dc.DrawRectangle(wxRect(wxPoint(0, 0), GetVirtualSize() + wxSize(m_Settings.m_nGridSize.x, m_Settings.m_nGridSize.y)));

    Then it works, but I am not sure if this is the best way?

     
  • Hmmm, It works for me at least with the latest trunk (rev 418), wxWidgets 2.9.5 and integrated Intel graphics (Ubuntu 12.04.2 LTS). Please, could you test whether the lates changes in wxSF trunk fixed the issue?

     
  • iwbnwif
    iwbnwif
    2013-09-04

    Sorry I should have mentioned that I am using Windows 8.

    I tested on Ubuntu 13.04 and it works fine, but I still see the problem on Windows 8.

    The best way to reproduce the problem is to change the lines around 32 - 40 in wxSFDemo as follows:

    // the canvas background can be filled with a solid colour ...
    RemoveStyle(sfsGRADIENT_BACKGROUND);
    SetBackgroundColour(sfdvSHAPECANVAS_BACKGROUNDCOLOR);
    // ... or by a gradient fill
    // AddStyle(sfsGRADIENT_BACKGROUND);
    // SetGradientFrom(sfdvSHAPECANVAS_GRADIENT_FROM);
    // SetGradientTo(sfdvSHAPECANVAS_GRADIENT_TO);
    

    Place a rectangle object in the lower right corner and then start zooming in.

     
    Last edit: iwbnwif 2013-09-04
  • Which wxWidgets version do you use? wxGraphicsContext's implementation differs between 2.8 and 2.9 a lot so wxSF must implement many things differently as well... :(

     
  • iwbnwif
    iwbnwif
    2013-09-10

    I have upped version to 2.9.5 for this test