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
JOHI
Knows some wx things
Knows some wx things
Posts: 34
Joined: Fri Jul 20, 2018 8:25 pm

wxAutoBufferedPaintDC stores AxisOrientation, wxPaintDC does not??

Post by JOHI »

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.)

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 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,
Johi.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxAutoBufferedPaintDC stores AxisOrientation, wxPaintDC does not??

Post by PB »

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