Honour window min and max sizes in wxWindow::GetBestSize().
The best size of the window should be at least as large as its min size and less than its max size. This allows to override the windows own best size determination with an explicit SetMinSize() or SetMaxSize() call. See #11497. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72343 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -40,10 +40,25 @@ private:
|
||||
CPPUNIT_TEST_SUITE( SetSizeTestCase );
|
||||
CPPUNIT_TEST( SetSize );
|
||||
CPPUNIT_TEST( SetSizeLessThanMinSize );
|
||||
CPPUNIT_TEST( BestSize );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void SetSize();
|
||||
void SetSizeLessThanMinSize();
|
||||
void BestSize();
|
||||
|
||||
// Helper class overriding DoGetBestSize() for testing purposes.
|
||||
class MyWindow : public wxWindow
|
||||
{
|
||||
public:
|
||||
MyWindow(wxWindow* parent)
|
||||
: wxWindow(parent, wxID_ANY)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual wxSize DoGetBestSize() const { return wxSize(50, 250); }
|
||||
};
|
||||
|
||||
wxWindow *m_win;
|
||||
|
||||
@@ -62,7 +77,7 @@ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SetSizeTestCase, "SetSizeTestCase" );
|
||||
|
||||
void SetSizeTestCase::setUp()
|
||||
{
|
||||
m_win = new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
m_win = new MyWindow(wxTheApp->GetTopWindow());
|
||||
}
|
||||
|
||||
void SetSizeTestCase::tearDown()
|
||||
@@ -91,3 +106,13 @@ void SetSizeTestCase::SetSizeLessThanMinSize()
|
||||
CPPUNIT_ASSERT_EQUAL( size, m_win->GetSize() );
|
||||
}
|
||||
|
||||
void SetSizeTestCase::BestSize()
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL( wxSize(50, 250), m_win->GetBestSize() );
|
||||
|
||||
m_win->SetMinSize(wxSize(100, 100));
|
||||
CPPUNIT_ASSERT_EQUAL( wxSize(100, 250), m_win->GetBestSize() );
|
||||
|
||||
m_win->SetMaxSize(wxSize(200, 200));
|
||||
CPPUNIT_ASSERT_EQUAL( wxSize(100, 200), m_win->GetBestSize() );
|
||||
}
|
||||
|
Reference in New Issue
Block a user