]> git.saurik.com Git - wxWidgets.git/commitdiff
Change wxBoxSizer::AddSpacer() to only add space in sizer direction.
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 15 Sep 2009 17:05:32 +0000 (17:05 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 15 Sep 2009 17:05:32 +0000 (17:05 +0000)
It used to add a spacer with the given size in both directions but this was
counter-intuitive and wasn't expected even by the original author of this code
so change it to behave more reasonably.

Closes #11197.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61939 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
include/wx/sizer.h
interface/wx/sizer.h
src/common/sizer.cpp

index 9862a02889775a3bbb2dc894766fee0bbb0be202..9657620a73d316e1a0e059c5b24a2f6b70b8c355 100644 (file)
@@ -149,6 +149,11 @@ Changes in behaviour not resulting in compilation errors, please read this!
   new constructors taking wxSize for the gap argument is preferred. The same
   applies to wxFlexGridSizer as well.
 
+- wxBoxSizer::AddSpacer(x) now adds space in the direction of the sizer only
+  and not in both this and the orthogonal directions. This behaviour is what
+  most of the people expect but if you really relied on this overload adding
+  space in both directions you should change your code to use AddSpacer(x, x).
+
 
 Changes in behaviour which may result in compilation errors
 -----------------------------------------------------------
index 289b765d80f2beeb7ac9eff95f4b9af1a9a4571e..f4b0b4ba8af24f819d494ae90b2def559771d69b 100644 (file)
@@ -510,7 +510,7 @@ public:
     wxSizerItem* Add( int width, int height, const wxSizerFlags& flags);
     wxSizerItem* Add( wxSizerItem *item);
 
-    wxSizerItem* AddSpacer(int size);
+    virtual wxSizerItem *AddSpacer(int size);
     wxSizerItem* AddStretchSpacer(int prop = 1);
 
     wxSizerItem* Insert(size_t index,
@@ -913,6 +913,8 @@ public:
                       wxT("invalid value for wxBoxSizer orientation") );
     }
 
+    virtual wxSizerItem *AddSpacer(int size);
+
     int GetOrientation() const { return m_orient; }
 
     bool IsVertical() const { return m_orient == wxVERTICAL; }
index 1423c6d485ea86a05188ab40da833b76771b25b7..cfd1dd841ce855cb2582bf5c8e4ebf7723233c88 100644 (file)
@@ -291,13 +291,15 @@ public:
                      wxObject* userData = NULL);
 
     /**
-        Adds non-stretchable space to the sizer.
+        This base function adds non-stretchable space to both the horizontal
+        and vertical orientation of the sizer.
         More readable way of calling:
         @code
         wxSizer::Add(size, size, 0).
         @endcode
+        @see wxBoxSizer::AddSpacer()
     */
-    wxSizerItem* AddSpacer(int size);
+    virtual wxSizerItem *AddSpacer(int size);
 
     /**
         Adds stretchable space to the sizer.
@@ -1747,6 +1749,22 @@ public:
     */
     wxBoxSizer(int orient);
 
+    /**
+        Adds non-stretchable space to the main orientation of the sizer only.
+        More readable way of calling:
+        @code
+        if ( wxBoxSizer::IsVertical() )
+        {
+            wxBoxSizer::Add(0, size, 0).
+        }
+        else
+        {
+            wxBoxSizer::Add(size, 0, 0).
+        }
+        @endcode
+    */
+    virtual wxSizerItem *AddSpacer(int size);
+
     /**
         Implements the calculation of a box sizer's minimal.
 
index 01180b5374bb716b31f4e1e46835688ef8402ce2..1325015a264bce0f1e81952203aded91c80ad805 100644 (file)
@@ -1982,6 +1982,11 @@ void wxFlexGridSizer::RemoveGrowableRow( size_t idx )
 // wxBoxSizer
 //---------------------------------------------------------------------------
 
+wxSizerItem *wxBoxSizer::AddSpacer(int size)
+{
+    return IsVertical() ? Add(0, size) : Add(size, 0);
+}
+
 void wxBoxSizer::RecalcSizes()
 {
     if ( m_children.empty() )