Detect the use of incompatible flags for wxGridSizer too.
Complain if wxEXPAND is combined with both horizontal and vertical alignment flags, as this doesn't make sense and, moreover, the behaviour has changed since the last commit: now wxEXPAND is ignored instead of overriding the alignment flags if they are combined.
This commit is contained in:
parent
9aaa38c7c8
commit
58114f22c3
@ -1406,6 +1406,18 @@ wxSizerItem *wxGridSizer::DoInsert(size_t index, wxSizerItem *item)
|
||||
}
|
||||
}
|
||||
|
||||
const int flags = item->GetFlag();
|
||||
if ( flags & wxEXPAND )
|
||||
{
|
||||
// Check that expansion will happen in at least one of the directions.
|
||||
wxASSERT_MSG
|
||||
(
|
||||
!(flags & (wxALIGN_BOTTOM | wxALIGN_CENTRE_VERTICAL)) ||
|
||||
!(flags & (wxALIGN_RIGHT | wxALIGN_CENTRE_HORIZONTAL)),
|
||||
wxS("wxEXPAND flag will be overridden by alignment flags")
|
||||
);
|
||||
}
|
||||
|
||||
return wxSizer::DoInsert(index, item);
|
||||
}
|
||||
|
||||
|
@ -39,9 +39,11 @@ public:
|
||||
private:
|
||||
CPPUNIT_TEST_SUITE( GridSizerTestCase );
|
||||
CPPUNIT_TEST( Expand );
|
||||
CPPUNIT_TEST( IncompatibleFlags );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void Expand();
|
||||
void IncompatibleFlags();
|
||||
|
||||
// Clear the current sizer contents and add the specified windows to it,
|
||||
// using the same flags for all of them.
|
||||
@ -156,3 +158,12 @@ void GridSizerTestCase::Expand()
|
||||
CPPUNIT_ASSERT_EQUAL( wxSize(sizeChild.x, sizeRest.y),
|
||||
children[3]->GetSize() );
|
||||
}
|
||||
|
||||
void GridSizerTestCase::IncompatibleFlags()
|
||||
{
|
||||
WX_ASSERT_FAILS_WITH_ASSERT_MESSAGE
|
||||
(
|
||||
"Combining wxEXPAND and wxCENTRE should assert",
|
||||
m_sizer->Add(10, 10, wxSizerFlags().Expand().Centre())
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user