+bool wxSplitterWindow::DoSendEvent(wxSplitterEvent& event)
+{
+ return !GetEventHandler()->ProcessEvent(event) || event.IsAllowed();
+}
+
+// ---------------------------------------------------------------------------
+// wxSplitterWindow virtual functions: they now just generate the events
+// ---------------------------------------------------------------------------
+
+bool wxSplitterWindow::OnSashPositionChange(int WXUNUSED(newSashPosition))
+{
+ // always allow by default
+ return TRUE;
+}
+
+int wxSplitterWindow::OnSashPositionChanging(int newSashPosition)
+{
+ // If within UNSPLIT_THRESHOLD from edge, set to edge to cause closure.
+ const int UNSPLIT_THRESHOLD = 4;
+
+ // first of all, check if OnSashPositionChange() doesn't forbid this change
+ if ( !OnSashPositionChange(newSashPosition) )
+ {
+ // it does
+ return -1;
+ }
+
+ // Obtain relevant window dimension for bottom / right threshold check
+ int window_size = GetWindowSize();
+
+ 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
+ newSashPosition = AdjustSashPosition(newSashPosition);
+ }
+
+ // 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;
+
+ // now let the event handler have it
+ //
+ // FIXME: shouldn't we do it before the adjustments above so as to ensure
+ // that the sash position is always reasonable?
+ wxSplitterEvent event(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING, this);
+ event.m_data.pos = newSashPosition;
+
+ if ( !DoSendEvent(event) )
+ {
+ // the event handler vetoed the change
+ newSashPosition = -1;
+ }
+ else
+ {
+ // it could have been changed by it
+ newSashPosition = event.GetSashPosition();
+ }
+
+ return 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::OnDoubleClickSash(int x, int y)
+{
+ wxCHECK_RET(m_windowTwo, wxT("splitter: no window to remove"));
+
+ // new code should handle events instead of using the virtual functions
+ wxSplitterEvent event(wxEVT_COMMAND_SPLITTER_DOUBLECLICKED, this);
+ event.m_data.pt.x = x;
+ event.m_data.pt.y = y;
+ if ( DoSendEvent(event) )
+ {
+ if ( GetMinimumPaneSize() == 0 || m_permitUnsplitAlways )
+ {
+ wxWindow* win = m_windowTwo;
+ if ( Unsplit(win) )
+ {
+ wxSplitterEvent unsplitEvent(wxEVT_COMMAND_SPLITTER_UNSPLIT, this);
+ unsplitEvent.m_data.win = win;
+ (void)DoSendEvent(unsplitEvent);
+ }
+ }
+ }
+ //else: blocked by user
+}
+
+void wxSplitterWindow::OnUnsplit(wxWindow *winRemoved)
+{
+ // call this before calling the event handler which may delete the window
+ winRemoved->Show(FALSE);
+}
+
+#if defined( __WXMSW__ ) || defined( __WXMAC__)
+
+// this is currently called (and needed) under MSW only...
+void wxSplitterWindow::OnSetCursor(wxSetCursorEvent& event)
+{
+ // 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 // wxUSE_SPLITTER
+#endif // wxMSW
+