#if defined( __WXMSW__ ) || defined( __WXMAC__)
EVT_SET_CURSOR(wxSplitterWindow::OnSetCursor)
#endif // wxMSW
-
- WX_EVENT_TABLE_CONTROL_CONTAINER(wxSplitterWindow)
END_EVENT_TABLE()
-WX_DELEGATE_TO_CONTROL_CONTAINER(wxSplitterWindow, wxWindow)
-
static bool IsLive(wxSplitterWindow* wnd)
{
// with wxSP_LIVE_UPDATE style the splitter windows are always resized
// allow TABbing from one window to the other
style |= wxTAB_TRAVERSAL;
- // we draw our border ourselves to blend the sash with it
- style &= ~wxBORDER_MASK;
- style |= wxBORDER_NONE;
-
-
if ( !wxWindow::Create(parent, id, pos, size, style, name) )
return false;
- if (size.x >= 0)
- m_lastSize.x = size.x;
- if (size.y >= 0)
- m_lastSize.y = size.y;
+ m_lastSize = GetClientSize();
m_permitUnsplitAlways = (style & wxSP_PERMIT_UNSPLIT) != 0;
void wxSplitterWindow::Init()
{
- WX_INIT_CONTROL_CONTAINER();
-
m_splitMode = wxSPLIT_VERTICAL;
m_permitUnsplitAlways = true;
m_windowOne = NULL;
m_sashStart = 0;
m_sashPosition = m_requestedSashPosition = 0;
m_sashGravity = 0.0;
- m_sashSize = -1; // -1 means use the native sash size
m_lastSize = wxSize(0,0);
m_checkRequestedSashPosition = false;
m_minimumPaneSize = 0;
void wxSplitterWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
{
wxPaintDC dc(this);
+#ifdef __WXOSX__
+ // as subpanels might have a transparent background we must erase the background
+ // at least on OSX, otherwise traces of the sash will remain
+ // test with: splitter sample->replace right window
+ dc.Clear();
+#endif
DrawSash(dc);
}
int size = m_splitMode == wxSPLIT_VERTICAL ? w : h;
int old_size = m_splitMode == wxSPLIT_VERTICAL ? m_lastSize.x : m_lastSize.y;
- if ( old_size != 0 )
+
+ // Don't do anything if the size didn't really change. In particular,
+ // it is important that we don't reset our sash position because it's
+ // out of current range in this case as otherwise the really requested
+ // position would be lost and never set. Wait until we get a real size
+ // event with our non-initial size to do it.
+ if ( size == old_size )
+ return;
+
+ int delta = (int) ( (size - old_size)*m_sashGravity );
+ if ( delta != 0 )
{
- int delta = (int) ( (size - old_size)*m_sashGravity );
- if ( delta != 0 )
- {
- int newPosition = m_sashPosition + delta;
- if( newPosition < m_minimumPaneSize )
- newPosition = m_minimumPaneSize;
- SetSashPositionAndNotify(newPosition);
- }
+ int newPosition = m_sashPosition + delta;
+ if( newPosition < m_minimumPaneSize )
+ newPosition = m_minimumPaneSize;
+ SetSashPositionAndNotify(newPosition);
}
if ( m_sashPosition >= size - 5 )
int wxSplitterWindow::GetSashSize() const
{
- return m_sashSize > -1 ? m_sashSize : wxRendererNative::Get().GetSplitterParams(this).widthSash;
+ return wxRendererNative::Get().GetSplitterParams(this).widthSash;
}
int wxSplitterWindow::GetBorderSize() const
return false;
wxCHECK_MSG( window1 && window2, false,
- wxT("can not split with NULL window(s)") );
+ wxT("cannot split with NULL window(s)") );
wxCHECK_MSG( window1->GetParent() == this && window2->GetParent() == this, false,
wxT("windows in the splitter should have it as parent!") );