/**
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()
*/
/**
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()
*/
if (height != -1)
m_height = height;
- ConstrainSize();
-
if (m_parent->m_wxwindow)
{
wxPizza* pizza = WX_PIZZA(m_parent->m_wxwindow);
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) \
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
$(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) \
$(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
$(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) \
$(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) $<
$(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) \
$(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
$(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) &
$(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) $<
controls/textctrltest.cpp
misc/selstoretest.cpp
window/clientsize.cpp
+ window/setsize.cpp
</sources>
<wx-lib>core</wx-lib>
<wx-lib>base</wx-lib>
# End Source File\r
# Begin Source File\r
\r
+SOURCE=.\window\setsize.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=.\geometry\size.cpp\r
# End Source File\r
# Begin Source File\r
RelativePath=".\geometry\rect.cpp"/>\r
<File\r
RelativePath=".\misc\selstoretest.cpp"/>\r
+ <File\r
+ RelativePath=".\window\setsize.cpp"/>\r
<File\r
RelativePath=".\geometry\size.cpp"/>\r
<File\r
<File\r
RelativePath=".\misc\selstoretest.cpp"\r
/>\r
+ <File\r
+ RelativePath=".\window\setsize.cpp"\r
+ />\r
<File\r
RelativePath=".\geometry\size.cpp"\r
/>\r
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// 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() );
+}
+