]> git.saurik.com Git - wxWidgets.git/commitdiff
don't take the min size into account when setting the window size explicitly in wxGTK...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 25 May 2008 03:08:31 +0000 (03:08 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 25 May 2008 03:08:31 +0000 (03:08 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53741 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

12 files changed:
interface/window.h
src/gtk/window.cpp
tests/Makefile.in
tests/makefile.bcc
tests/makefile.gcc
tests/makefile.vc
tests/makefile.wat
tests/test.bkl
tests/test_test_gui.dsp
tests/test_vc7_test_gui.vcproj
tests/test_vc8_test_gui.vcproj
tests/window/setsize.cpp [new file with mode: 0644]

index 79235c42cad76769405c69be9eef67df418c06a4..1c5857c2ffed2e9d035a5215affa144476d2d15c 100644 (file)
@@ -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()
     */
index f7c7bf4e249a7b60448a8eeba610c18cedc0e401..5634ab6e2bc3753995b903188b986dd8e5807a58 100644 (file)
@@ -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);
index 48b14a96e74caba1299b7309c7c2d8478ff89d97..cdc0b755f14b1cfe85b1152b698d38dbda975c17 100644 (file)
@@ -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
 
index 2edcdf71d90f971658e4a822e0209d0b12993705..232de8819409e2626e5f4d41782e150ca03098e0 100644 (file)
@@ -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
 
index 7bf11401904c2f49779cbcd80d7122a97e438db7..0d9e1d3186779aa94e3e26f769bcd8ff3c383e8a 100644 (file)
@@ -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) $<
 
index 4a238a32959941f9fb6d8732c9ee2968be40a39c..08d5e1ede0aaddf9ecf980ec16bef38629bd6780 100644 (file)
@@ -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
 
index 4da93dc9fc9eb802358cce3ff045405447e4f541..ec777b57b1f17886bb9a671ad9e9461df8fa81ed 100644 (file)
@@ -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) $<
 
index b8b0475dc92372b5ec386027685a010df3ed1046..292779bcaca54c905c67ddac86acce5a44641bb0 100644 (file)
@@ -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>
index ee5b74aea4b3c545163af10fa7bbb39db6a1eb98..55dd1d27d1909eaa238cfc9a9103af855a3ab99a 100644 (file)
@@ -265,6 +265,10 @@ SOURCE=.\misc\selstoretest.cpp
 # 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
index 2a750e387942ffee9a1105b75abb850dc593c133..99c8d2cd077b4fb31fb45d2bb383ea890053b9fd 100644 (file)
                                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
index 4506ca485e77c86cf79db384f5f1be4958c328b4..15347d1ebc61edc6b89faad4bccf8f2af7b87573 100644 (file)
                        <File\r
                                RelativePath=".\misc\selstoretest.cpp"\r
                        />\r
+                       <File\r
+                               RelativePath=".\window\setsize.cpp"\r
+                       />\r
                        <File\r
                                RelativePath=".\geometry\size.cpp"\r
                        />\r
diff --git a/tests/window/setsize.cpp b/tests/window/setsize.cpp
new file mode 100644 (file)
index 0000000..122cb07
--- /dev/null
@@ -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() );
+}
+