int GetSashPosition() const { return m_sashPosition; }
// If this is zero, we can remove panes by dragging the sash.
- void SetMinimumPaneSize(int min) { m_minimumPaneSize = min; }
+ void SetMinimumPaneSize(int min);
int GetMinimumPaneSize() const { return m_minimumPaneSize; }
// Called when the sash position is about to be changed, return
// get either width or height depending on the split mode
int GetWindowSize() const;
+
+ // set m_sashPosition w/ safeguards
+ void DoSetSashPosition(int sashPos);
wxSplitMode m_splitMode;
bool m_permitUnsplitAlways;
int m_borderSize;
int m_sashSize; // Sash width or height
int m_sashPosition; // Number of pixels from left or top
+ int m_requestedSashPosition;
int m_firstX;
int m_firstY;
int m_minimumPaneSize;
m_firstY = 0;
m_sashSize = 7;
m_borderSize = 2;
- m_sashPosition = 0;
+ m_sashPosition = m_requestedSashPosition = 0;
m_minimumPaneSize = 0;
m_sashCursorWE = new wxCursor(wxCURSOR_SIZEWE);
m_sashCursorNS = new wxCursor(wxCURSOR_SIZENS);
m_windowOne = m_windowTwo;
m_windowTwo = (wxWindow *) NULL;
SendUnsplitEvent(removedWindow);
- m_sashPosition = 0;
+ DoSetSashPosition(0);
}
else if ( new_sash_position == window_size )
{
wxWindow *removedWindow = m_windowTwo;
m_windowTwo = (wxWindow *) NULL;
SendUnsplitEvent(removedWindow);
- m_sashPosition = 0;
+ DoSetSashPosition(0);
}
else
{
- m_sashPosition = new_sash_position;
+ DoSetSashPosition(new_sash_position);
}
}
else
{
- m_sashPosition = new_sash_position;
+ DoSetSashPosition(new_sash_position);
}
SizeWindows();
}
else
{
- m_sashPosition = new_sash_position;
+ DoSetSashPosition(new_sash_position);
m_needUpdating = TRUE;
}
}
if ( m_splitMode == wxSPLIT_VERTICAL )
{
if ( m_sashPosition >= (cw - 5) )
- m_sashPosition = wxMax(10, cw - 40);
+ DoSetSashPosition(wxMax(10, cw - 40));
}
else // m_splitMode == wxSPLIT_HORIZONTAL
{
if ( m_sashPosition >= (ch - 5) )
- m_sashPosition = wxMax(10, ch - 40);
+ DoSetSashPosition(wxMax(10, ch - 40));
}
}
{
int window_size = GetWindowSize();
- // VZ: dirty fix, 20 is the initial window size under wxGTK, this is
- // going to be replaced with the correct Vaclav's code soon (FIXME)
- if ( window_size <= 20 )
- {
- // don't do anything before the window has a valid size, otherwise we
- // put the sash to 0 at the very beginning and it doesn't move from
- // there any more
- return sashPos;
- }
-
wxWindow *win;
win = GetWindow1();
return sashPos;
}
+void wxSplitterWindow::DoSetSashPosition(int sashPos)
+{
+ m_requestedSashPosition = sashPos;
+ m_sashPosition = (sashPos == 0) ? 0 : AdjustSashPosition(sashPos);
+}
+
// Position and size subwindows.
// Note that the border size applies to each subwindow, not
// including the edges next to the sash.
void wxSplitterWindow::SizeWindows()
{
+ if ( m_requestedSashPosition != m_sashPosition )
+ DoSetSashPosition(m_requestedSashPosition);
+
int w, h;
GetClientSize(&w, &h);
if ( GetWindow1() && !GetWindow2() )
{
- GetWindow1()->SetSize(GetBorderSize(), GetBorderSize(), w - 2*GetBorderSize(), h - 2*GetBorderSize());
-
+ GetWindow1()->SetSize(GetBorderSize(), GetBorderSize(),
+ w - 2*GetBorderSize(), h - 2*GetBorderSize());
}
else if ( GetWindow1() && GetWindow2() )
{
{
m_windowOne = window;
m_windowTwo = (wxWindow *) NULL;
- m_sashPosition = 0;
+ DoSetSashPosition(0);
}
// Associates the given window with window 2, drawing the appropriate sash
if ( sashPosition > 0 )
{
- m_sashPosition = sashPosition;
+ DoSetSashPosition(sashPosition);
}
else if ( sashPosition < 0 )
{
// It's negative so adding is subtracting
- m_sashPosition = window_size + sashPosition;
+ DoSetSashPosition(window_size + sashPosition);
}
else
{
// default
- m_sashPosition = window_size/2;
- }
-
- // don't do it initially, i.e. when creating the window because it doesn't
- // have a proper size yet and AdjustSashPosition() would happily set the
- // sash position to 0!
- if ( window_size > 0 )
- {
- m_sashPosition = AdjustSashPosition(m_sashPosition);
+ DoSetSashPosition(window_size/2);
}
SizeWindows();
}
SendUnsplitEvent(win);
- m_sashPosition = 0;
+ DoSetSashPosition(0);
SizeWindows();
return TRUE;
return TRUE;
}
+void wxSplitterWindow::SetMinimumPaneSize(int min)
+{
+ m_minimumPaneSize = min;
+ SetSashPosition(m_sashPosition); // re-check limits
+}
+
void wxSplitterWindow::SetSashPosition(int position, bool redraw)
{
- m_sashPosition = AdjustSashPosition(position);
+ DoSetSashPosition(position);
if ( redraw )
{