+
+ // 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;