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:
parent
1a86d2e52c
commit
5af86f4df5
@ -927,10 +927,10 @@ public:
|
||||
|
||||
/**
|
||||
Returns the minimum size of the window, an indication to the sizer layout
|
||||
mechanism
|
||||
that this is the minimum required size. It normally just returns the value set
|
||||
by SetMinSize(), but it can be overridden to do the
|
||||
calculation on demand.
|
||||
mechanism that this is the minimum required size.
|
||||
|
||||
This method normally just returns the value set by SetMinSize(), but it
|
||||
can be overridden to do the calculation on demand.
|
||||
|
||||
@see GetMinClientSize()
|
||||
*/
|
||||
@ -2122,18 +2122,30 @@ public:
|
||||
/**
|
||||
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
|
||||
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.
|
||||
|
||||
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()
|
||||
*/
|
||||
void SetMinClientSize(const wxSize& size);
|
||||
|
||||
/**
|
||||
Sets the minimum size of the window, to indicate to the sizer layout mechanism
|
||||
that this is the minimum required size. You may need to call this
|
||||
if you change the window size after construction and before adding
|
||||
to its parent sizer.
|
||||
Sets the minimum size of the window, to indicate to the sizer layout
|
||||
mechanism that this is the minimum required size.
|
||||
|
||||
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()
|
||||
*/
|
||||
|
@ -2419,8 +2419,6 @@ void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags
|
||||
if (height != -1)
|
||||
m_height = height;
|
||||
|
||||
ConstrainSize();
|
||||
|
||||
if (m_parent->m_wxwindow)
|
||||
{
|
||||
wxPizza* pizza = WX_PIZZA(m_parent->m_wxwindow);
|
||||
|
@ -118,7 +118,8 @@ TEST_GUI_OBJECTS = \
|
||||
test_gui_config.o \
|
||||
test_gui_textctrltest.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)
|
||||
PRINTFBENCH_CXXFLAGS = $(__printfbench_PCH_INC) -D__WX$(TOOLKIT)__ \
|
||||
$(__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)
|
||||
$(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)
|
||||
$(CXXC) -c -o $@ $(PRINTFBENCH_CXXFLAGS) $(srcdir)/benchmarks/printfbench.cpp
|
||||
|
||||
|
@ -105,7 +105,8 @@ TEST_GUI_OBJECTS = \
|
||||
$(OBJS)\test_gui_config.obj \
|
||||
$(OBJS)\test_gui_textctrltest.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) \
|
||||
$(__OPTIMIZEFLAG) $(__THREADSFLAG_1) -D__WXMSW__ $(__WXUNIV_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
|
||||
$(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
|
||||
$(CXX) -q -c -P -o$@ $(PRINTFBENCH_CXXFLAGS) -H .\dummy.cpp
|
||||
|
||||
|
@ -98,7 +98,8 @@ TEST_GUI_OBJECTS = \
|
||||
$(OBJS)\test_gui_config.o \
|
||||
$(OBJS)\test_gui_textctrltest.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) \
|
||||
$(GCCFLAGS) -DHAVE_W32API_H -D__WXMSW__ $(__WXUNIV_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
|
||||
$(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
|
||||
$(CXX) -c -o $@ $(PRINTFBENCH_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
|
@ -101,7 +101,8 @@ TEST_GUI_OBJECTS = \
|
||||
$(OBJS)\test_gui_config.obj \
|
||||
$(OBJS)\test_gui_textctrltest.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 \
|
||||
$(__DEBUGINFO) /Fd$(OBJS)\printfbench.pdb $(____DEBUGRUNTIME) \
|
||||
$(__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
|
||||
$(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
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(PRINTFBENCH_CXXFLAGS) /Yctestprec.h .\dummy.cpp
|
||||
|
||||
|
@ -310,7 +310,8 @@ TEST_GUI_OBJECTS = &
|
||||
$(OBJS)\test_gui_config.obj &
|
||||
$(OBJS)\test_gui_textctrltest.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) &
|
||||
$(__RUNTIME_LIBS) -d__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_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
|
||||
$(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
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(PRINTFBENCH_CXXFLAGS) $<
|
||||
|
||||
|
@ -98,6 +98,7 @@
|
||||
controls/textctrltest.cpp
|
||||
misc/selstoretest.cpp
|
||||
window/clientsize.cpp
|
||||
window/setsize.cpp
|
||||
</sources>
|
||||
<wx-lib>core</wx-lib>
|
||||
<wx-lib>base</wx-lib>
|
||||
|
@ -265,6 +265,10 @@ SOURCE=.\misc\selstoretest.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\window\setsize.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\geometry\size.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -710,6 +710,8 @@
|
||||
RelativePath=".\geometry\rect.cpp"/>
|
||||
<File
|
||||
RelativePath=".\misc\selstoretest.cpp"/>
|
||||
<File
|
||||
RelativePath=".\window\setsize.cpp"/>
|
||||
<File
|
||||
RelativePath=".\geometry\size.cpp"/>
|
||||
<File
|
||||
|
@ -890,6 +890,9 @@
|
||||
<File
|
||||
RelativePath=".\misc\selstoretest.cpp"
|
||||
/>
|
||||
<File
|
||||
RelativePath=".\window\setsize.cpp"
|
||||
/>
|
||||
<File
|
||||
RelativePath=".\geometry\size.cpp"
|
||||
/>
|
||||
|
96
tests/window/setsize.cpp
Normal file
96
tests/window/setsize.cpp
Normal 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() );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user