I've got a very frustrating sizer problem.
I have two wxFlexGridSizer
s (and a few other things) inside a vertical wxBoxSizer
, like so:
mMainSizer->Add(topsizer, wxSizerFlags(0).Expand());
mMainSizer->Add(1, lineheight);
mMainSizer->Add(mTypeLabel);
mMainSizer->Add(mTypeSizer, wxSizerFlags(0).Expand());
mMainSizer->Add(1, lineheight);
Each wxFlexGridSizer
is filled using the same code:
sizer->Add(label, wxSizerFlags(1).Expand());
sizer->Add(fieldwidth, 1); // To separate label and data
sizer->Add(data, wxSizerFlags(0).Border(wxRIGHT, rborder).Right());开发者_JS百科
But the wxFlexGridSizer
s aren't being Expand
ed to the same width, as I intend. The lower one, with smaller label
s, is always narrower than the upper one, leaving the data
fields misaligned between them. Since they were both added with the Expand()
flag, the narrower one should expand to the same width as the wider one, right?
(I've even tried adding the Right()
flag to the lower one too, when adding it to the wxBoxSizer
, but it did nothing, which really confused me.)
Can anyone save my sanity by pointing out where I'm going wrong?
EDIT: As far as I can tell, this is a wxWidgets bug. The Expand
flag should tell items in a vertical sizer to expand themselves to their maximum width. If I'm wrong, someone please correct me.
As it turns out, the bug was mine. I thought I'd given the wxFlexGridSizer
s a growable column, with wxFlexGridSizer::AddGrowableCol
, but that must have been in an earlier iteration of the code. Once I'd done that, they expanded just as I wanted them to.
精彩评论