Sizers and resizing the main frame question Topic is solved

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
Morat20
Knows some wx things
Knows some wx things
Posts: 41
Joined: Tue Jan 07, 2014 8:43 pm

Sizers and resizing the main frame question

Post 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.
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Sizers and resizing the main frame question

Post 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.
Use the source, Luke!
Morat20
Knows some wx things
Knows some wx things
Posts: 41
Joined: Tue Jan 07, 2014 8:43 pm

Re: Sizers and resizing the main frame question

Post 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.
Post Reply