don't take the min size into account when setting the window size explicitly in wxGTK, just as wxMSW doesn't do it; mention this in the docs and added a unit test to enforce this

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53741 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-05-25 03:08:31 +00:00
parent 1a86d2e52c
commit 5af86f4df5
12 changed files with 152 additions and 16 deletions

View File

@@ -927,10 +927,10 @@ public:
/** /**
Returns the minimum size of the window, an indication to the sizer layout Returns the minimum size of the window, an indication to the sizer layout
mechanism mechanism that this is the minimum required size.
that this is the minimum required size. It normally just returns the value set
by SetMinSize(), but it can be overridden to do the This method normally just returns the value set by SetMinSize(), but it
calculation on demand. can be overridden to do the calculation on demand.
@see GetMinClientSize() @see GetMinClientSize()
*/ */
@@ -2122,18 +2122,30 @@ public:
/** /**
Sets the minimum client size of the window, to indicate to the sizer Sets the minimum client size of the window, to indicate to the sizer
layout mechanism that this is the minimum required size of window's client layout mechanism that this is the minimum required size of window's client
area. You may need to call this if you change the window size after area.
You may need to call this if you change the window size after
construction and before adding to its parent sizer. construction and before adding to its parent sizer.
Note, that just as with SetMinSize(), calling this method doesn't
prevent the program from explicitly making the window smaller than the
specified size.
@see SetMinSize() @see SetMinSize()
*/ */
void SetMinClientSize(const wxSize& size); void SetMinClientSize(const wxSize& size);
/** /**
Sets the minimum size of the window, to indicate to the sizer layout mechanism Sets the minimum size of the window, to indicate to the sizer layout
that this is the minimum required size. You may need to call this mechanism that this is the minimum required size.
if you change the window size after construction and before adding
to its parent sizer. You may need to call this if you change the window size after
construction and before adding to its parent sizer.
Notice that calling this method doesn't prevent the program from making
the window explicitly smaller than the specified size by calling
SetSize(), it just ensures that it won't become smaller than this size
during the automatic layout.
@see SetMinClientSize() @see SetMinClientSize()
*/ */

View File

@@ -2419,8 +2419,6 @@ void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags
if (height != -1) if (height != -1)
m_height = height; m_height = height;
ConstrainSize();
if (m_parent->m_wxwindow) if (m_parent->m_wxwindow)
{ {
wxPizza* pizza = WX_PIZZA(m_parent->m_wxwindow); wxPizza* pizza = WX_PIZZA(m_parent->m_wxwindow);

View File

@@ -118,7 +118,8 @@ TEST_GUI_OBJECTS = \
test_gui_config.o \ test_gui_config.o \
test_gui_textctrltest.o \ test_gui_textctrltest.o \
test_gui_selstoretest.o \ test_gui_selstoretest.o \
test_gui_clientsize.o test_gui_clientsize.o \
test_gui_setsize.o
TEST_GUI_ODEP = $(___pch_testprec_test_gui_testprec_h_gch___depname) TEST_GUI_ODEP = $(___pch_testprec_test_gui_testprec_h_gch___depname)
PRINTFBENCH_CXXFLAGS = $(__printfbench_PCH_INC) -D__WX$(TOOLKIT)__ \ PRINTFBENCH_CXXFLAGS = $(__printfbench_PCH_INC) -D__WX$(TOOLKIT)__ \
$(__WXUNIV_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \ $(__WXUNIV_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \
@@ -510,6 +511,9 @@ test_gui_selstoretest.o: $(srcdir)/misc/selstoretest.cpp $(TEST_GUI_ODEP)
test_gui_clientsize.o: $(srcdir)/window/clientsize.cpp $(TEST_GUI_ODEP) test_gui_clientsize.o: $(srcdir)/window/clientsize.cpp $(TEST_GUI_ODEP)
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/window/clientsize.cpp $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/window/clientsize.cpp
test_gui_setsize.o: $(srcdir)/window/setsize.cpp $(TEST_GUI_ODEP)
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/window/setsize.cpp
printfbench_printfbench.o: $(srcdir)/benchmarks/printfbench.cpp $(PRINTFBENCH_ODEP) printfbench_printfbench.o: $(srcdir)/benchmarks/printfbench.cpp $(PRINTFBENCH_ODEP)
$(CXXC) -c -o $@ $(PRINTFBENCH_CXXFLAGS) $(srcdir)/benchmarks/printfbench.cpp $(CXXC) -c -o $@ $(PRINTFBENCH_CXXFLAGS) $(srcdir)/benchmarks/printfbench.cpp

View File

@@ -105,7 +105,8 @@ TEST_GUI_OBJECTS = \
$(OBJS)\test_gui_config.obj \ $(OBJS)\test_gui_config.obj \
$(OBJS)\test_gui_textctrltest.obj \ $(OBJS)\test_gui_textctrltest.obj \
$(OBJS)\test_gui_selstoretest.obj \ $(OBJS)\test_gui_selstoretest.obj \
$(OBJS)\test_gui_clientsize.obj $(OBJS)\test_gui_clientsize.obj \
$(OBJS)\test_gui_setsize.obj
PRINTFBENCH_CXXFLAGS = $(__RUNTIME_LIBS) -I$(BCCDIR)\include $(__DEBUGINFO) \ PRINTFBENCH_CXXFLAGS = $(__RUNTIME_LIBS) -I$(BCCDIR)\include $(__DEBUGINFO) \
$(__OPTIMIZEFLAG) $(__THREADSFLAG_1) -D__WXMSW__ $(__WXUNIV_DEFINE_p) \ $(__OPTIMIZEFLAG) $(__THREADSFLAG_1) -D__WXMSW__ $(__WXUNIV_DEFINE_p) \
$(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \ $(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \
@@ -545,6 +546,9 @@ $(OBJS)\test_gui_selstoretest.obj: .\misc\selstoretest.cpp
$(OBJS)\test_gui_clientsize.obj: .\window\clientsize.cpp $(OBJS)\test_gui_clientsize.obj: .\window\clientsize.cpp
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\window\clientsize.cpp $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\window\clientsize.cpp
$(OBJS)\test_gui_setsize.obj: .\window\setsize.cpp
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\window\setsize.cpp
$(OBJS)\printfbench_dummy.obj: .\dummy.cpp $(OBJS)\printfbench_dummy.obj: .\dummy.cpp
$(CXX) -q -c -P -o$@ $(PRINTFBENCH_CXXFLAGS) -H .\dummy.cpp $(CXX) -q -c -P -o$@ $(PRINTFBENCH_CXXFLAGS) -H .\dummy.cpp

View File

@@ -98,7 +98,8 @@ TEST_GUI_OBJECTS = \
$(OBJS)\test_gui_config.o \ $(OBJS)\test_gui_config.o \
$(OBJS)\test_gui_textctrltest.o \ $(OBJS)\test_gui_textctrltest.o \
$(OBJS)\test_gui_selstoretest.o \ $(OBJS)\test_gui_selstoretest.o \
$(OBJS)\test_gui_clientsize.o $(OBJS)\test_gui_clientsize.o \
$(OBJS)\test_gui_setsize.o
PRINTFBENCH_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(__THREADSFLAG) \ PRINTFBENCH_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(__THREADSFLAG) \
$(GCCFLAGS) -DHAVE_W32API_H -D__WXMSW__ $(__WXUNIV_DEFINE_p) \ $(GCCFLAGS) -DHAVE_W32API_H -D__WXMSW__ $(__WXUNIV_DEFINE_p) \
$(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \ $(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \
@@ -523,6 +524,9 @@ $(OBJS)\test_gui_selstoretest.o: ./misc/selstoretest.cpp
$(OBJS)\test_gui_clientsize.o: ./window/clientsize.cpp $(OBJS)\test_gui_clientsize.o: ./window/clientsize.cpp
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\test_gui_setsize.o: ./window/setsize.cpp
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\printfbench_dummy.o: ./dummy.cpp $(OBJS)\printfbench_dummy.o: ./dummy.cpp
$(CXX) -c -o $@ $(PRINTFBENCH_CXXFLAGS) $(CPPDEPS) $< $(CXX) -c -o $@ $(PRINTFBENCH_CXXFLAGS) $(CPPDEPS) $<

View File

@@ -101,7 +101,8 @@ TEST_GUI_OBJECTS = \
$(OBJS)\test_gui_config.obj \ $(OBJS)\test_gui_config.obj \
$(OBJS)\test_gui_textctrltest.obj \ $(OBJS)\test_gui_textctrltest.obj \
$(OBJS)\test_gui_selstoretest.obj \ $(OBJS)\test_gui_selstoretest.obj \
$(OBJS)\test_gui_clientsize.obj $(OBJS)\test_gui_clientsize.obj \
$(OBJS)\test_gui_setsize.obj
PRINTFBENCH_CXXFLAGS = /M$(__RUNTIME_LIBS_38)$(__DEBUGRUNTIME) /DWIN32 \ PRINTFBENCH_CXXFLAGS = /M$(__RUNTIME_LIBS_38)$(__DEBUGRUNTIME) /DWIN32 \
$(__DEBUGINFO) /Fd$(OBJS)\printfbench.pdb $(____DEBUGRUNTIME) \ $(__DEBUGINFO) /Fd$(OBJS)\printfbench.pdb $(____DEBUGRUNTIME) \
$(__OPTIMIZEFLAG) $(__NO_VC_CRTDBG_p) /D__WXMSW__ $(__WXUNIV_DEFINE_p) \ $(__OPTIMIZEFLAG) $(__NO_VC_CRTDBG_p) /D__WXMSW__ $(__WXUNIV_DEFINE_p) \
@@ -630,6 +631,9 @@ $(OBJS)\test_gui_selstoretest.obj: .\misc\selstoretest.cpp
$(OBJS)\test_gui_clientsize.obj: .\window\clientsize.cpp $(OBJS)\test_gui_clientsize.obj: .\window\clientsize.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\window\clientsize.cpp $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\window\clientsize.cpp
$(OBJS)\test_gui_setsize.obj: .\window\setsize.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\window\setsize.cpp
$(OBJS)\printfbench_dummy.obj: .\dummy.cpp $(OBJS)\printfbench_dummy.obj: .\dummy.cpp
$(CXX) /c /nologo /TP /Fo$@ $(PRINTFBENCH_CXXFLAGS) /Yctestprec.h .\dummy.cpp $(CXX) /c /nologo /TP /Fo$@ $(PRINTFBENCH_CXXFLAGS) /Yctestprec.h .\dummy.cpp

View File

@@ -310,7 +310,8 @@ TEST_GUI_OBJECTS = &
$(OBJS)\test_gui_config.obj & $(OBJS)\test_gui_config.obj &
$(OBJS)\test_gui_textctrltest.obj & $(OBJS)\test_gui_textctrltest.obj &
$(OBJS)\test_gui_selstoretest.obj & $(OBJS)\test_gui_selstoretest.obj &
$(OBJS)\test_gui_clientsize.obj $(OBJS)\test_gui_clientsize.obj &
$(OBJS)\test_gui_setsize.obj
PRINTFBENCH_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(__THREADSFLAG) & PRINTFBENCH_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(__THREADSFLAG) &
$(__RUNTIME_LIBS) -d__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) & $(__RUNTIME_LIBS) -d__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) &
$(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) & $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) &
@@ -576,6 +577,9 @@ $(OBJS)\test_gui_selstoretest.obj : .AUTODEPEND .\misc\selstoretest.cpp
$(OBJS)\test_gui_clientsize.obj : .AUTODEPEND .\window\clientsize.cpp $(OBJS)\test_gui_clientsize.obj : .AUTODEPEND .\window\clientsize.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
$(OBJS)\test_gui_setsize.obj : .AUTODEPEND .\window\setsize.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
$(OBJS)\printfbench_dummy.obj : .AUTODEPEND .\dummy.cpp $(OBJS)\printfbench_dummy.obj : .AUTODEPEND .\dummy.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(PRINTFBENCH_CXXFLAGS) $< $(CXX) -bt=nt -zq -fo=$^@ $(PRINTFBENCH_CXXFLAGS) $<

View File

@@ -98,6 +98,7 @@
controls/textctrltest.cpp controls/textctrltest.cpp
misc/selstoretest.cpp misc/selstoretest.cpp
window/clientsize.cpp window/clientsize.cpp
window/setsize.cpp
</sources> </sources>
<wx-lib>core</wx-lib> <wx-lib>core</wx-lib>
<wx-lib>base</wx-lib> <wx-lib>base</wx-lib>

View File

@@ -265,6 +265,10 @@ SOURCE=.\misc\selstoretest.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\window\setsize.cpp
# End Source File
# Begin Source File
SOURCE=.\geometry\size.cpp SOURCE=.\geometry\size.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File

View File

@@ -710,6 +710,8 @@
RelativePath=".\geometry\rect.cpp"/> RelativePath=".\geometry\rect.cpp"/>
<File <File
RelativePath=".\misc\selstoretest.cpp"/> RelativePath=".\misc\selstoretest.cpp"/>
<File
RelativePath=".\window\setsize.cpp"/>
<File <File
RelativePath=".\geometry\size.cpp"/> RelativePath=".\geometry\size.cpp"/>
<File <File

View File

@@ -890,6 +890,9 @@
<File <File
RelativePath=".\misc\selstoretest.cpp" RelativePath=".\misc\selstoretest.cpp"
/> />
<File
RelativePath=".\window\setsize.cpp"
/>
<File <File
RelativePath=".\geometry\size.cpp" RelativePath=".\geometry\size.cpp"
/> />

96
tests/window/setsize.cpp Normal file
View File

@@ -0,0 +1,96 @@
///////////////////////////////////////////////////////////////////////////////
// Name: tests/window/setsize.cpp
// Purpose: Tests for SetSize() and related wxWindow methods
// Author: Vadim Zeitlin
// Created: 2008-05-25
// RCS-ID: $Id$
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
///////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "testprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/app.h"
#include "wx/window.h"
#endif // WX_PRECOMP
inline std::ostream& operator<<(std::ostream& o, const wxSize& s)
{
return o << s.x << 'x' << s.y;
}
// ----------------------------------------------------------------------------
// test class
// ----------------------------------------------------------------------------
class SetSizeTestCase : public CppUnit::TestCase
{
public:
SetSizeTestCase() { }
virtual void setUp();
virtual void tearDown();
private:
CPPUNIT_TEST_SUITE( SetSizeTestCase );
CPPUNIT_TEST( SetSize );
CPPUNIT_TEST( SetSizeLessThanMinSize );
CPPUNIT_TEST_SUITE_END();
void SetSize();
void SetSizeLessThanMinSize();
wxWindow *m_win;
DECLARE_NO_COPY_CLASS(SetSizeTestCase)
};
// register in the unnamed registry so that these tests are run by default
CPPUNIT_TEST_SUITE_REGISTRATION( SetSizeTestCase );
// also include in it's own registry so that these tests can be run alone
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SetSizeTestCase, "SetSizeTestCase" );
// ----------------------------------------------------------------------------
// test initialization
// ----------------------------------------------------------------------------
void SetSizeTestCase::setUp()
{
m_win = new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY);
}
void SetSizeTestCase::tearDown()
{
delete m_win;
m_win = NULL;
}
// ----------------------------------------------------------------------------
// tests themselves
// ----------------------------------------------------------------------------
void SetSizeTestCase::SetSize()
{
const wxSize size(127, 35);
m_win->SetSize(size);
CPPUNIT_ASSERT_EQUAL( size, m_win->GetSize() );
}
void SetSizeTestCase::SetSizeLessThanMinSize()
{
m_win->SetMinSize(wxSize(100, 100));
const wxSize size(200, 50);
m_win->SetSize(size);
CPPUNIT_ASSERT_EQUAL( size, m_win->GetSize() );
}