Page 1 of 1

Sizers and resizing the main frame question

Posted: Thu Mar 21, 2019 9:47 pm
by Morat20
There's something odd I've noticed a few times, and I suspect I'm doing something wrong with sizers to cause it.

I'll create a frame, fill it with controls using sizers, and everything will lay out fine.

Until I resize the frame, even if just a little. Suddenly controls will jump out past the "edge" of the frame (requiring scrollbars on the main frame, or expanding the main frame considerably more to see it). These are obviously controls placed with the "wxExpand" flag, but I don't understand why they'll lay out and fit within the frame, then a resize event will somehow massively alter their size, extending them past the frame's edge.

I unfortunately don't have a simple code example I can give, but I'm hoping the problem is based on a person misunderstanding of sizers or the way wxWidgets handles resizing the main frame.

Re: Sizers and resizing the main frame question

Posted: Thu Mar 21, 2019 10:00 pm
by doublemax
Unfortunately without some code that shows the problem, this will be hard to track down.

Most common problems are:
- frame is too small to display everything. items will overlap and cause all kind of visual artefacts
- wrong parent-child relationship of controls
- bug in sizer hierarchy
I'll create a frame, fill it with controls using sizers, and everything will lay out fine.
Is really every control visible and has at least its minimum size?
Until I resize the frame, even if just a little.
If you keep increasing the frame, does the layout stabilize at some point and look ok?

Are you running a debug build? wxWidgets will show asserts if it detects obvious errors in the sizer usage.

Re: Sizers and resizing the main frame question

Posted: Thu Mar 21, 2019 10:30 pm
by Morat20
I think I may have found the problem. Or rather, realized the problem is not with the wxTextControl or the set of sizers I've been looking at.

I'm using a wxNotebook, and the problem I am diagnosing is on the last tab of the notebook. However, on another tab of the notebook, the same problem is happening. Only the culprit is a wxGrid.

Switching that grid off (hiding it) and the layout of the last tab corrects itself.

I've been looking at the wrong set of sizers, and I know wxGrid's are problematic if their min and max sizes aren't set properly.

It did not occur to me until answering your questions that there might have been a different tab that was the root source. Now I just need to remember how I handled wxGrid sizing and expansion when I've had to mess with it before.