wxSplitterWindow now:
1. respects minimal size even when set programatically 2. respects minimal size of child windows if set git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14145 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -213,6 +213,9 @@ protected:
|
|||||||
// common part of all ctors
|
// common part of all ctors
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
|
// adjusts sash position with respect to min. pane and window sizes
|
||||||
|
void AdjustSashPosition(int &sashPos);
|
||||||
|
|
||||||
int m_splitMode;
|
int m_splitMode;
|
||||||
bool m_permitUnsplitAlways;
|
bool m_permitUnsplitAlways;
|
||||||
bool m_needUpdating; // when in live mode, set this to TRUE to resize children in idle
|
bool m_needUpdating; // when in live mode, set this to TRUE to resize children in idle
|
||||||
|
@@ -689,6 +689,37 @@ void wxSplitterWindow::DrawSashTracker(int x, int y)
|
|||||||
screenDC.SetBrush(wxNullBrush);
|
screenDC.SetBrush(wxNullBrush);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxSplitterWindow::AdjustSashPosition(int &sashPos)
|
||||||
|
{
|
||||||
|
int w, h;
|
||||||
|
GetClientSize(&w, &h);
|
||||||
|
int window_size = (m_splitMode == wxSPLIT_VERTICAL) ? w : h;
|
||||||
|
wxWindow *win;
|
||||||
|
|
||||||
|
if ( sashPos < m_minimumPaneSize )
|
||||||
|
sashPos = m_minimumPaneSize;
|
||||||
|
else if ( sashPos > window_size - m_minimumPaneSize )
|
||||||
|
sashPos = window_size - m_minimumPaneSize;
|
||||||
|
|
||||||
|
win = GetWindow1();
|
||||||
|
if ( win )
|
||||||
|
{
|
||||||
|
int minSize = (m_splitMode == wxSPLIT_VERTICAL) ?
|
||||||
|
win->GetMinWidth() : win->GetMinHeight();
|
||||||
|
if ( minSize != -1 && sashPos < minSize + GetBorderSize() )
|
||||||
|
sashPos = minSize + GetBorderSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
win = GetWindow2();
|
||||||
|
if ( win )
|
||||||
|
{
|
||||||
|
int minSize = (m_splitMode == wxSPLIT_VERTICAL) ?
|
||||||
|
win->GetMinWidth() : win->GetMinHeight();
|
||||||
|
if ( minSize != -1 && sashPos > window_size - minSize - GetBorderSize() )
|
||||||
|
sashPos = window_size - minSize - GetBorderSize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Position and size subwindows.
|
// Position and size subwindows.
|
||||||
// Note that the border size applies to each subwindow, not
|
// Note that the border size applies to each subwindow, not
|
||||||
// including the edges next to the sash.
|
// including the edges next to the sash.
|
||||||
@@ -764,6 +795,8 @@ bool wxSplitterWindow::SplitVertically(wxWindow *window1, wxWindow *window2, int
|
|||||||
else // default
|
else // default
|
||||||
m_sashPosition = w/2;
|
m_sashPosition = w/2;
|
||||||
|
|
||||||
|
AdjustSashPosition(m_sashPosition);
|
||||||
|
|
||||||
SizeWindows();
|
SizeWindows();
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -787,6 +820,8 @@ bool wxSplitterWindow::SplitHorizontally(wxWindow *window1, wxWindow *window2, i
|
|||||||
else // default
|
else // default
|
||||||
m_sashPosition = h/2;
|
m_sashPosition = h/2;
|
||||||
|
|
||||||
|
AdjustSashPosition(m_sashPosition);
|
||||||
|
|
||||||
SizeWindows();
|
SizeWindows();
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -855,6 +890,7 @@ bool wxSplitterWindow::ReplaceWindow(wxWindow *winOld, wxWindow *winNew)
|
|||||||
void wxSplitterWindow::SetSashPosition(int position, bool redraw)
|
void wxSplitterWindow::SetSashPosition(int position, bool redraw)
|
||||||
{
|
{
|
||||||
m_sashPosition = position;
|
m_sashPosition = position;
|
||||||
|
AdjustSashPosition(m_sashPosition);
|
||||||
|
|
||||||
if ( redraw )
|
if ( redraw )
|
||||||
{
|
{
|
||||||
@@ -945,10 +981,7 @@ void wxSplitterWindow::OnSashPosChanged(wxSplitterEvent& event)
|
|||||||
if ( !unsplit_scenario )
|
if ( !unsplit_scenario )
|
||||||
{
|
{
|
||||||
// If resultant pane would be too small, enlarge it
|
// If resultant pane would be too small, enlarge it
|
||||||
if ( newSashPosition < m_minimumPaneSize )
|
AdjustSashPosition(newSashPosition);
|
||||||
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,
|
// If the result is out of bounds it means minimum size is too big,
|
||||||
|
Reference in New Issue
Block a user