On Thu, 26 May 2016 01:22:56 -0700 (PDT) moki wrote:
m> Since 3.1.0 version of wxWidgets a warning is triggered in debug when using
m> Expand() and CenterHorizontal() at the same time in a vertical wxBoxSizer (and
m> also with CenterVertical() and a horizontal wxBoxSizer):
m>
m> assert "!(flags & (wxALIGN_RIGHT | wxALIGN_CENTRE_HORIZONTAL))" failed in
m> DoInsert(): Horizontal alignment flags are ignored with wxEXPAND
This message is meant to warn you that the flags you specify don't work as
you probably think they do.
m> But when setting a max size to a control, doing the latter has an effect.
Sorry, I don't understand what is "the latter" here?
m> Here a little example that produces a warning, but center the main_window:
m>
m> wxDialog example_dlg(NULL, wxID_ANY, "example", wxDefaultPosition,
m> wxSize(800, 600));
m>
m> wxWindow *main_window = new wxWindow(&example_dlg, wxID_ANY);
m> main_window->SetBackgroundColour(*wxRED);
m> main_window->SetMaxSize(wxSize(400, wxDefaultCoord));
m>
m> wxBoxSizer *main_sizer = new wxBoxSizer(wxVERTICAL);
m> main_sizer->Add(main_window, wxSizerFlags(1).Expand().CenterHorizontal());
How do you expand this to work? You can't both expand and centre the
window. If you want to centre it, just remove Expand().
m> If I remove .CenterHorizontal(), the warning goes away but the main_window
m> is not centered anyway.
Err, of course it isn't. Again, I am just totally failing to see how else
could it possibly behave.
m> Shouldn't this warning be removed ?
IMO the answer is definitely no, but I don't even understand the argument
for removing it. You will really need to explain what do you mean better if
you think there is something wrong with this assert.
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/