return;
}
+ const wxSize curSize = event.GetSize();
+
// Update the sash position if needed.
//
// Notice that we shouldn't do this if the sash position requested by user
// modified it before this happens.
if ( m_windowTwo && m_requestedSashPosition == INT_MAX )
{
- int w, h;
- GetClientSize(&w, &h);
-
- int size = m_splitMode == wxSPLIT_VERTICAL ? w : h;
+ 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.
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();
}
m_sashGravity = gravity;
}
-bool wxSplitterWindow::SashHitTest(int x, int y, int tolerance)
+bool wxSplitterWindow::SashHitTest(int x, int y)
{
if ( m_windowTwo == NULL || m_sashPosition == 0)
return false; // No sash
int z = m_splitMode == wxSPLIT_VERTICAL ? x : y;
- int hitMin = m_sashPosition - tolerance;
- int hitMax = m_sashPosition + GetSashSize() + tolerance;
+ int hitMax = m_sashPosition + GetSashSize() - 1;
- return z >= hitMin && z <= hitMax;
+ return z >= m_sashPosition && z <= hitMax;
+}
+
+void wxSplitterWindow::SetSashInvisible(bool invisible)
+{
+ if ( IsSashInvisible() != invisible )
+ ToggleWindowStyle(wxSP_NOSASH);
}
int wxSplitterWindow::GetSashSize() const
+{
+ return IsSashInvisible() ? 0 : GetDefaultSashSize();
+}
+
+int wxSplitterWindow::GetDefaultSashSize() const
{
return wxRendererNative::Get().GetSplitterParams(this).widthSash;
}
return;
// nor if we're configured to not show it
- if ( HasFlag(wxSP_NOSASH) )
+ if ( IsSashInvisible() )
return;
wxRendererNative::Get().DrawSplitterSash
// and like this we explicitly say that our cursor should not be used for
// children windows which overlap us
- if ( SashHitTest(event.GetX(), event.GetY(), 0) )
+ if ( SashHitTest(event.GetX(), event.GetY()) )
{
// default processing is ok
event.Skip();