+ return m_splitMode == wxSPLIT_VERTICAL ? size.x : size.y;
+}
+
+int wxSplitterWindow::AdjustSashPosition(int sashPos) const
+{
+ int window_size = GetWindowSize();
+
+ wxWindow *win;
+
+ win = GetWindow1();
+ if ( win )
+ {
+ // the window shouldn't be smaller than its own minimal size nor
+ // smaller than the minimual pane size specified for this splitter
+ int minSize = m_splitMode == wxSPLIT_VERTICAL ? win->GetMinWidth()
+ : win->GetMinHeight();
+
+ if ( minSize == -1 || m_minimumPaneSize > minSize )
+ minSize = m_minimumPaneSize;
+
+ minSize += GetBorderSize();
+
+ if ( sashPos < minSize )
+ sashPos = minSize;
+ }
+
+ win = GetWindow2();
+ if ( win )
+ {
+ int minSize = m_splitMode == wxSPLIT_VERTICAL ? win->GetMinWidth()
+ : win->GetMinHeight();
+
+ if ( minSize == -1 || m_minimumPaneSize > minSize )
+ minSize = m_minimumPaneSize;
+
+ int maxSize = window_size - minSize - GetBorderSize() - GetSashSize();
+ if ( sashPos > maxSize )
+ sashPos = maxSize;
+ }
+
+ return sashPos;
+}
+
+bool wxSplitterWindow::DoSetSashPosition(int sashPos)
+{
+ int newSashPosition = AdjustSashPosition(sashPos);
+
+ if ( newSashPosition == m_sashPosition )
+ return false;
+
+ m_sashPosition = newSashPosition;
+
+ return true;
+}
+
+void wxSplitterWindow::SetSashPositionAndNotify(int sashPos)
+{
+ // we must reset the request here, otherwise the sash would be stuck at
+ // old position if the user attempted to move the sash after invalid
+ // (e.g. smaller than minsize) sash position was requested using
+ // SetSashPosition():
+ m_requestedSashPosition = INT_MAX;
+
+ if ( DoSetSashPosition(sashPos) )
+ {
+ wxSplitterEvent event(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED, this);
+ event.m_data.pos = m_sashPosition;
+
+ (void)DoSendEvent(event);
+ }