/////////////////////////////////////////////////////////////////////////////
-// Name: splitter.cpp
+// Name: src/generic/splitter.cpp
// Purpose: wxSplitterWindow implementation
// Author: Julian Smart
// Modified by:
m_windowOne = m_windowTwo;
m_windowTwo = (wxWindow *) NULL;
OnUnsplit(removedWindow);
- DoSetSashPosition(0);
+ SetSashPositionAndNotify(0);
}
else if ( posSashNew == GetWindowSize() )
{
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();
}
else
{
- DoSetSashPosition(posSashNew);
+ SetSashPositionAndNotify(posSashNew);
m_needUpdating = TRUE;
}
}
iconized = FALSE;
}
#endif
-
+
if ( iconized )
{
event.Skip();
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));
}
}
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;
if ( GetWindow1() && !GetWindow2() )
{
- GetWindow1()->SetSize(GetBorderSize(), GetBorderSize(),
+ GetWindow1()->SetSize(GetBorderSize(), GetBorderSize(),
w - 2*GetBorderSize(), h - 2*GetBorderSize());
}
else if ( GetWindow1() && GetWindow2() )
// 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);
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;