X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/153b7996e59cbc85c6c4016a00dd3e99635a74aa..832e44d38a9c283ea1b03a76f80efb52519de21f:/src/generic/splitter.cpp diff --git a/src/generic/splitter.cpp b/src/generic/splitter.cpp index 3da3fa0472..9918c9f704 100644 --- a/src/generic/splitter.cpp +++ b/src/generic/splitter.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: splitter.cpp +// Name: src/generic/splitter.cpp // Purpose: wxSplitterWindow implementation // Author: Julian Smart // Modified by: @@ -243,7 +243,7 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event) m_windowOne = m_windowTwo; m_windowTwo = (wxWindow *) NULL; OnUnsplit(removedWindow); - DoSetSashPosition(0); + SetSashPositionAndNotify(0); } else if ( posSashNew == GetWindowSize() ) { @@ -251,16 +251,16 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event) wxWindow *removedWindow = m_windowTwo; m_windowTwo = (wxWindow *) NULL; OnUnsplit(removedWindow); - DoSetSashPosition(0); + SetSashPositionAndNotify(0); } else { - DoSetSashPosition(posSashNew); + SetSashPositionAndNotify(posSashNew); } } else { - DoSetSashPosition(posSashNew); + SetSashPositionAndNotify(posSashNew); } SizeWindows(); @@ -294,6 +294,11 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event) #endif // __WXMSW__ int diff = m_splitMode == wxSPLIT_VERTICAL ? x - m_oldX : y - m_oldY; + if ( !diff ) + { + // nothing to do, mouse didn't really move far enough + return; + } int posSashOld = isLive ? m_sashPosition : m_sashPositionCurrent; int posSashNew = OnSashPositionChanging(posSashOld + diff); @@ -343,7 +348,7 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event) } else { - DoSetSashPosition(posSashNew); + SetSashPositionAndNotify(posSashNew); m_needUpdating = TRUE; } } @@ -384,7 +389,7 @@ void wxSplitterWindow::OnSize(wxSizeEvent& event) iconized = FALSE; } #endif - + if ( iconized ) { event.Skip(); @@ -399,12 +404,12 @@ void wxSplitterWindow::OnSize(wxSizeEvent& event) if ( m_splitMode == wxSPLIT_VERTICAL ) { if ( m_sashPosition >= (cw - 5) ) - DoSetSashPosition(wxMax(10, cw - 40)); + SetSashPositionAndNotify(wxMax(10, cw - 40)); } else // m_splitMode == wxSPLIT_HORIZONTAL { if ( m_sashPosition >= (ch - 5) ) - DoSetSashPosition(wxMax(10, ch - 40)); + SetSashPositionAndNotify(wxMax(10, ch - 40)); } } @@ -712,14 +717,22 @@ int wxSplitterWindow::AdjustSashPosition(int sashPos) const return sashPos; } -void wxSplitterWindow::DoSetSashPosition(int sashPos) +bool wxSplitterWindow::DoSetSashPosition(int sashPos) { int newSashPosition = AdjustSashPosition(sashPos); - if ( newSashPosition != m_sashPosition ) - { - m_sashPosition = newSashPosition; + if ( newSashPosition == m_sashPosition ) + return FALSE; + + m_sashPosition = newSashPosition; + return TRUE; +} + +void wxSplitterWindow::SetSashPositionAndNotify(int sashPos) +{ + if ( DoSetSashPosition(sashPos) ) + { wxSplitterEvent event(wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED, this); event.m_data.pos = m_sashPosition; @@ -753,7 +766,7 @@ void wxSplitterWindow::SizeWindows() if ( GetWindow1() && !GetWindow2() ) { - GetWindow1()->SetSize(GetBorderSize(), GetBorderSize(), + GetWindow1()->SetSize(GetBorderSize(), GetBorderSize(), w - 2*GetBorderSize(), h - 2*GetBorderSize()); } else if ( GetWindow1() && GetWindow2() ) @@ -792,6 +805,9 @@ void wxSplitterWindow::SizeWindows() // Set pane for unsplit window void wxSplitterWindow::Initialize(wxWindow *window) { + wxASSERT_MSG( window->GetParent() == this, + _T("windows in the splitter should have it as parent!") ); + m_windowOne = window; m_windowTwo = (wxWindow *) NULL; DoSetSashPosition(0); @@ -807,6 +823,9 @@ bool wxSplitterWindow::DoSplit(wxSplitMode mode, if ( IsSplit() ) return FALSE; + wxASSERT_MSG( window1->GetParent() == this && window2->GetParent() == this, + _T("windows in the splitter should have it as parent!") ); + m_splitMode = mode; m_windowOne = window1; m_windowTwo = window2;