If I understand the documentation correctly, changing from wxPaintDC to wxAutoBufferedPaintDC should only yield in added buffered drawing, all other dc functions remain the same.
wxBufferedPaintDC is a buffered version of wxPaintDC . Simply replace wxPaintDC with wxBufferedPaintDC
in your paint event handler, and the graph-ics will be drawn to a bitmap before being drawn all at once on the window,
reducing flicker (Cross_Platform GUI Programming with wxWidgets, J. Smart, p. 136.)
However:
I have a paint handler that does some drawing using axis orientation in default mode Y top to bottom and another part that uses Y bottom to top. Extract below:
Code: Select all
void MyFrame::OnPaint (wxPaintEvent &e)
{
// wxAutoBufferedPaintDC dc(this);
wxPaintDC dc(this);
wxSize sz = GetClientSize();
dc.SetBrush(*wxLIGHT_GREY_BRUSH);
wxRect rectToDraw1(0,0,sz.x,sz.y);
dc.DrawRectangle(rectToDraw1);
int d = 10; // offset from side for drawing rect
dc.SetBrush(*wxWHITE_BRUSH);
wxRect rectToDraw2(d,d,sz.x-2*d,sz.y-2*d);
dc.DrawRectangle(rectToDraw2);
// change orientation of axis to normal math X-Y quadrant 1
dc.SetAxisOrientation(true,true);
// dc.SetAxisOrientation(true,false); // only needed using wxAutoBufferedPaintDC
}
With wxAutoBufferedPaintDC the Y-axis orientation at the end of the paint handler seems to be memorized: if I do not restore the state at the end of the paint handler, the Y bottom to top orientation is kept in the next paint cycle and my drawing is not what it should be (drawing is messed up completely after resizing the window).
To me this might point in the direction of a bug, but since I am very new with wxWidgets, I might oversee something?
(Using VC2008 Professional on Windows 7. wxWidgets 3.0.4.)
Best Regards,
Johi.