]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/splitter.cpp
Interface fixes and tweaks for Phoenix
[wxWidgets.git] / src / generic / splitter.cpp
index 1b8025182f3fa9c051ee6a719b09a7f25b5a83d0..dee38940afa59a628e0a1f3a121fc6f23b55e712 100644 (file)
@@ -435,37 +435,44 @@ void wxSplitterWindow::OnSize(wxSizeEvent& event)
         return;
     }
 
-    if ( m_windowTwo )
-    {
-        int w, h;
-        GetClientSize(&w, &h);
+    const wxSize curSize = event.GetSize();
 
-        int size = m_splitMode == wxSPLIT_VERTICAL ? w : h;
+    // Update the sash position if needed.
+    //
+    // Notice that we shouldn't do this if the sash position requested by user
+    // couldn't be set yet as it would never be taken into account at all if we
+    // modified it before this happens.
+    if ( m_windowTwo && m_requestedSashPosition == INT_MAX )
+    {
+        int size = m_splitMode == wxSPLIT_VERTICAL ? curSize.x : curSize.y;
 
         int old_size = m_splitMode == wxSPLIT_VERTICAL ? m_lastSize.x : m_lastSize.y;
 
-        // Don't do anything if the size didn't really change. In particular,
-        // it is important that we don't reset our sash position because it's
-        // out of current range in this case as otherwise the really requested
-        // position would be lost and never set. Wait until we get a real size
-        // event with our non-initial size to do it.
+        // Don't do anything if the size didn't really change.
         if ( size != old_size )
         {
+            int newPosition = -1;
+
+            // Apply gravity if we use it.
             int delta = (int) ( (size - old_size)*m_sashGravity );
             if ( delta != 0 )
             {
-                int newPosition = m_sashPosition + delta;
+                newPosition = m_sashPosition + delta;
                 if( newPosition < m_minimumPaneSize )
                     newPosition = m_minimumPaneSize;
-                SetSashPositionAndNotify(newPosition);
             }
 
-            if ( m_sashPosition >= size - 5 )
-                SetSashPositionAndNotify(wxMax(10, size - 40));
-            m_lastSize = wxSize(w,h);
+            // Also check if the second window became too small.
+            newPosition = AdjustSashPosition(newPosition == -1
+                                                 ? m_sashPosition
+                                                 : newPosition);
+            if ( newPosition != m_sashPosition )
+                SetSashPositionAndNotify(newPosition);
         }
     }
 
+    m_lastSize = curSize;
+
     SizeWindows();
 }