wxAutoBufferedPaintDC stores AxisOrientation, wxPaintDC does not??

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
In need of some credit
In need of some credit
Posts: 3
Joined: Fri Jul 20, 2018 8:25 pm

wxAutoBufferedPaintDC stores AxisOrientation, wxPaintDC does not??

Post by JOHI » Fri Aug 10, 2018 7:27 am

Hello forum members,
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.)

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();

	wxRect rectToDraw1(0,0,sz.x,sz.y);

	int d = 10; // offset from side for drawing rect
	wxRect rectToDraw2(d,d,sz.x-2*d,sz.y-2*d);

	// change orientation of axis to normal math X-Y quadrant 1
	// dc.SetAxisOrientation(true,false); // only needed using wxAutoBufferedPaintDC
With wxPaint there is no issue: the Y-axis orientation is stateless, if I do not restore the Y top to bottom orientation at the end of my paint handler, all is ok and the default orientation is available in the next paint cycle.

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,

Part Of The Furniture
Part Of The Furniture
Posts: 1868
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxAutoBufferedPaintDC stores AxisOrientation, wxPaintDC does not??

Post by PB » Fri Aug 10, 2018 7:41 am

Sorry I cannot help you except confirm that there are certainly issues with the buffered paint DC (which AFAIK is basically a wxMemoryDC).

See e.g. my findings here: viewtopic.php?f=1&t=44508#p183739

I would suggest asking the developers in wx-users or create a ticket on wxTrac.

Post Reply