Make the initial sash position work in splitter sample.
The initial splitter size must be set correctly when using gravity with wxSplitterWindow as otherwise the sash would jump on first resize -- which was exactly what happened in the splitter sample. Add a SetSize() call to the sample with the comment explaining why is it needed and also actually make it stick as the cached last size was not updated before the splitter was split before. Closes #9821. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69599 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -257,6 +257,12 @@ MyFrame::MyFrame()
|
||||
menuBar->Check(SPLIT_LIVE, true);
|
||||
m_splitter = new MySplitterWindow(this);
|
||||
|
||||
// If you use non-zero gravity you must initialize the splitter with its
|
||||
// correct initial size, otherwise it will change the sash position by a
|
||||
// huge amount when it's resized from its initial default size to its real
|
||||
// size when the frame lays it out. This wouldn't be necessary if default
|
||||
// zero gravity were used (although it would do no harm neither).
|
||||
m_splitter->SetSize(GetClientSize());
|
||||
m_splitter->SetSashGravity(1.0);
|
||||
|
||||
#if 1
|
||||
|
@@ -435,6 +435,8 @@ void wxSplitterWindow::OnSize(wxSizeEvent& event)
|
||||
return;
|
||||
}
|
||||
|
||||
const wxSize curSize = event.GetSize();
|
||||
|
||||
// Update the sash position if needed.
|
||||
//
|
||||
// Notice that we shouldn't do this if the sash position requested by user
|
||||
@@ -442,10 +444,7 @@ void wxSplitterWindow::OnSize(wxSizeEvent& event)
|
||||
// modified it before this happens.
|
||||
if ( m_windowTwo && m_requestedSashPosition == INT_MAX )
|
||||
{
|
||||
int w, h;
|
||||
GetClientSize(&w, &h);
|
||||
|
||||
int size = m_splitMode == wxSPLIT_VERTICAL ? w : h;
|
||||
int size = m_splitMode == wxSPLIT_VERTICAL ? curSize.x : curSize.y;
|
||||
|
||||
int old_size = m_splitMode == wxSPLIT_VERTICAL ? m_lastSize.x : m_lastSize.y;
|
||||
|
||||
@@ -468,6 +467,8 @@ void wxSplitterWindow::OnSize(wxSizeEvent& event)
|
||||
}
|
||||
}
|
||||
|
||||
m_lastSize = curSize;
|
||||
|
||||
SizeWindows();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user