+ 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