Assert if incompatible sizer flags are used.
We can't check for all the invalid combinations, but at least check for wxALIGN_CENTER_HORIZONTAL+wxALIGN_RIGHT and wxALIGN_CENTER_VERTICAL+ wxALIGN_BOTTOM which never make sense and can be detected.
This commit is contained in:
parent
66cfa40643
commit
636d08323f
@ -114,7 +114,17 @@ static const int SIZER_FLAGS_MASK =
|
||||
|
||||
#endif // wxDEBUG_LEVEL
|
||||
|
||||
#define ASSERT_VALID_SIZER_FLAGS(f) wxASSERT_VALID_FLAGS(f, SIZER_FLAGS_MASK)
|
||||
#define ASSERT_INCOMPATIBLE_NOT_USED_IMPL(f, f1, n1, f2, n2) \
|
||||
wxASSERT_MSG(((f) & (f1 | f2)) != (f1 | f2), \
|
||||
n1 " and " n2 " can't be used together")
|
||||
|
||||
#define ASSERT_INCOMPATIBLE_NOT_USED(f, f1, f2) \
|
||||
ASSERT_INCOMPATIBLE_NOT_USED_IMPL(f, f1, #f1, f2, #f2)
|
||||
|
||||
#define ASSERT_VALID_SIZER_FLAGS(f) \
|
||||
wxASSERT_VALID_FLAGS(f, SIZER_FLAGS_MASK); \
|
||||
ASSERT_INCOMPATIBLE_NOT_USED(f, wxALIGN_CENTRE_HORIZONTAL, wxALIGN_RIGHT); \
|
||||
ASSERT_INCOMPATIBLE_NOT_USED(f, wxALIGN_CENTRE_VERTICAL, wxALIGN_BOTTOM)
|
||||
|
||||
|
||||
void wxSizerItem::Init(const wxSizerFlags& flags)
|
||||
|
@ -44,6 +44,7 @@ private:
|
||||
CPPUNIT_TEST( BestSizeRespectsMaxSize );
|
||||
CPPUNIT_TEST( RecalcSizesRespectsMaxSize1 );
|
||||
CPPUNIT_TEST( RecalcSizesRespectsMaxSize2 );
|
||||
CPPUNIT_TEST( IncompatibleFlags );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void Size1();
|
||||
@ -52,6 +53,7 @@ private:
|
||||
void BestSizeRespectsMaxSize();
|
||||
void RecalcSizesRespectsMaxSize1();
|
||||
void RecalcSizesRespectsMaxSize2();
|
||||
void IncompatibleFlags();
|
||||
|
||||
wxWindow *m_win;
|
||||
wxSizer *m_sizer;
|
||||
@ -376,3 +378,10 @@ void BoxSizerTestCase::RecalcSizesRespectsMaxSize2()
|
||||
CPPUNIT_ASSERT_EQUAL(50, child2->GetSize().GetHeight());
|
||||
CPPUNIT_ASSERT_EQUAL(125, child3->GetSize().GetHeight());
|
||||
}
|
||||
|
||||
void BoxSizerTestCase::IncompatibleFlags()
|
||||
{
|
||||
WX_ASSERT_FAILS_WITH_ASSERT(
|
||||
m_sizer->Add(10, 10, 0, wxALIGN_BOTTOM | wxALIGN_CENTRE_VERTICAL)
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user