Beispiel #1
0
/*****************************************************
**
**   SplitterWidget   ---   OnSize
**
******************************************************/
void SplitterWidget::OnSize( wxSizeEvent &event )
{
	if ( GetWindow1() ) GetWindow1()->Refresh();
	if ( GetWindow2()) GetWindow2()->Refresh();
	//SetSize( event.GetSize() );
	event.Skip();
}
Beispiel #2
0
/*****************************************************
**
**   SplitterWidget   ---   OnPositionChanged
**
******************************************************/
void SplitterWidget::OnPositionChanged(wxSplitterEvent& event)
{
	wxSize size1 = wxSplitterWindow::GetSize();
	size1.x = event.GetSashPosition();
	GetWindow1()->SetSize( size1 );
	GetWindow1()->Refresh();
	wxSize size2 = wxSplitterWindow::GetSize();
	size2.x -= event.GetSashPosition();
	GetWindow2()->SetSize( size2 );
	GetWindow2()->Refresh();
	//event.Skip();
}
Beispiel #3
0
int wxSplitterWindow::AdjustSashPosition(int sashPos) const
{
    int window_size = GetWindowSize();

    wxWindow *win;

    win = GetWindow1();
    if ( win )
    {
        // the window shouldn't be smaller than its own minimal size nor
        // smaller than the minimual pane size specified for this splitter
        int minSize = m_splitMode == wxSPLIT_VERTICAL ? win->GetMinWidth()
                                                      : win->GetMinHeight();

        if ( minSize == -1 || m_minimumPaneSize > minSize )
            minSize = m_minimumPaneSize;

        minSize += GetBorderSize();

        if ( sashPos < minSize )
            sashPos = minSize;
    }

    win = GetWindow2();
    if ( win )
    {
        int minSize = m_splitMode == wxSPLIT_VERTICAL ? win->GetMinWidth()
                                                      : win->GetMinHeight();

        if ( minSize == -1 || m_minimumPaneSize > minSize )
            minSize = m_minimumPaneSize;

        int maxSize = window_size - minSize - GetBorderSize() - GetSashSize();
        if ( sashPos > maxSize )
            sashPos = maxSize;
    }

    return sashPos;
}
Beispiel #4
0
/*****************************************************
**
**   SplitterWidget   ---   OnSplitterSashPosChanged
**
******************************************************/
void SplitterWidget::OnSplitterSashPosChanged(wxSplitterEvent& )
{
	printf( "SplitterWidget::OnSplitterSashPosChanged\n" );
	if ( GetWindow1() ) GetWindow1()->Refresh();
	if ( GetWindow2() ) GetWindow2()->Refresh();
}
Beispiel #5
0
// Position and size subwindows.
// Note that the border size applies to each subwindow, not
// including the edges next to the sash.
void wxSplitterWindow::SizeWindows()
{
    // check if we have delayed setting the real sash position
    if ( m_requestedSashPosition != INT_MAX )
    {
        int newSashPosition = ConvertSashPosition(m_requestedSashPosition);
        if ( newSashPosition != m_sashPosition )
        {
            DoSetSashPosition(newSashPosition);
        }

        if ( newSashPosition <= m_sashPosition
            && newSashPosition >= m_sashPosition - GetBorderSize() )
        {
            // don't update it any more
            m_requestedSashPosition = INT_MAX;
        }
    }

    int w, h;
    GetClientSize(&w, &h);

    if ( GetWindow1() && !GetWindow2() )
    {
        GetWindow1()->SetSize(GetBorderSize(), GetBorderSize(),
                              w - 2*GetBorderSize(), h - 2*GetBorderSize());
    }
    else if ( GetWindow1() && GetWindow2() )
    {
        const int border = GetBorderSize(),
                  sash = GetSashSize();

        int size1 = GetSashPosition() - border,
            size2 = GetSashPosition() + sash;

        int x2, y2, w1, h1, w2, h2;
        if ( GetSplitMode() == wxSPLIT_VERTICAL )
        {
            w1 = size1;
            w2 = w - 2*border - sash - w1;
            if (w2 < 0)
                w2 = 0;
            h2 = h - 2*border;
            if (h2 < 0)
                h2 = 0;
            h1 = h2;
            x2 = size2;
            y2 = border;
        }
        else // horz splitter
        {
            w2 = w - 2*border;
            if (w2 < 0)
                w2 = 0;
            w1 = w2;
            h1 = size1;
            h2 = h - 2*border - sash - h1;
            if (h2 < 0)
                h2 = 0;
            x2 = border;
            y2 = size2;
        }

        GetWindow2()->SetSize(x2, y2, w2, h2);
        GetWindow1()->SetSize(border, border, w1, h1);
    }

    wxClientDC dc(this);
    DrawSash(dc);
}