+// ---------------------------------------------------------------------------
+// splitter event handlers
+// ---------------------------------------------------------------------------
+
+void wxSplitterWindow::OnSashPosChanged(wxSplitterEvent& event)
+{
+ // If within UNSPLIT_THRESHOLD from edge, set to edge to cause closure.
+ const int UNSPLIT_THRESHOLD = 4;
+
+ int newSashPosition = event.GetSashPosition();
+
+ // Obtain relevant window dimension for bottom / right threshold check
+ int w, h;
+ GetClientSize(&w, &h);
+ int window_size = (m_splitMode == wxSPLIT_VERTICAL) ? w : h ;
+
+ bool unsplit_scenario = FALSE;
+ if ( m_permitUnsplitAlways
+ || m_minimumPaneSize == 0 )
+ {
+ // Do edge detection if unsplit premitted
+ if ( newSashPosition <= UNSPLIT_THRESHOLD )
+ {
+ // threshold top / left check
+ newSashPosition = 0;
+ unsplit_scenario = TRUE;
+ }
+ if ( newSashPosition >= window_size - UNSPLIT_THRESHOLD )
+ {
+ // threshold bottom/right check
+ newSashPosition = window_size;
+ unsplit_scenario = TRUE;
+ }
+ }
+
+ if ( !unsplit_scenario )
+ {
+ // If resultant pane would be too small, enlarge it
+ if ( newSashPosition < m_minimumPaneSize )
+ newSashPosition = m_minimumPaneSize;
+ if ( newSashPosition > window_size - m_minimumPaneSize )
+ newSashPosition = window_size - m_minimumPaneSize;
+ }
+
+ // If the result is out of bounds it means minimum size is too big,
+ // so split window in half as best compromise.
+ if ( newSashPosition < 0 || newSashPosition > window_size )
+ newSashPosition = window_size / 2;
+
+ // for compatibility, call the virtual function
+ if ( !OnSashPositionChange(newSashPosition) )
+ {
+ newSashPosition = -1;
+ }
+
+ event.SetSashPosition(newSashPosition);
+}
+
+// Called when the sash is double-clicked. The default behaviour is to remove
+// the sash if the minimum pane size is zero.
+void wxSplitterWindow::OnDoubleClick(wxSplitterEvent& event)
+{
+ // for compatibility, call the virtual function
+ OnDoubleClickSash(event.GetX(), event.GetY());
+
+ if ( GetMinimumPaneSize() == 0 || m_permitUnsplitAlways )
+ {
+ Unsplit();
+ }
+}
+
+void wxSplitterWindow::OnUnsplitEvent(wxSplitterEvent& event)
+{
+ wxWindow *win = event.GetWindowBeingRemoved();
+
+ // do it before calling OnUnsplit() which may delete the window
+ win->Show(FALSE);
+
+ // for compatibility, call the virtual function
+ OnUnsplit(win);
+}
+
+#if defined(__WXMSW__)
+ #define WXUNUSED_UNLESS_MSW(identifier) identifier
+#else
+ #define WXUNUSED_UNLESS_MSW(identifier) WXUNUSED(identifier)
+#endif
+
+void wxSplitterWindow::OnSetCursor(wxSetCursorEvent& WXUNUSED_UNLESS_MSW(event))
+{
+ // this is currently called (and needed) under MSW only...
+#ifdef __WXMSW__
+
+ // if we don't do it, the resizing cursor might be set for child window:
+ // 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()) )
+ {
+ // default processing is ok
+ event.Skip();
+ }
+ //else: do nothing, in particular, don't call Skip()
+#endif // wxMSW
+}