コード例 #1
0
// Associates the given window with window 2, drawing the appropriate sash
// and changing the split mode.
// Does nothing and returns false if the window is already split.
bool wxSplitterWindow::DoSplit(wxSplitMode mode,
                               wxWindow *window1, wxWindow *window2,
                               int sashPosition)
{
    if ( IsSplit() )
        return false;

    wxCHECK_MSG( window1 && window2, false,
                 _T("can not split with NULL window(s)") );

    wxCHECK_MSG( window1->GetParent() == this && window2->GetParent() == this, false,
                  _T("windows in the splitter should have it as parent!") );

    if (! window1->IsShown())
        window1->Show();
    if (! window2->IsShown())
        window2->Show();

    m_splitMode = mode;
    m_windowOne = window1;
    m_windowTwo = window2;

    // remember the sash position we want to set for later if we can't set it
    // right now (e.g. because the window is too small)
    m_requestedSashPosition = sashPosition;
    m_checkRequestedSashPosition = false;

    DoSetSashPosition(ConvertSashPosition(sashPosition));

    SizeWindows();

    return true;
}
コード例 #2
0
void wxSplitWindow::SetSashPosition (int position, bool redraw) {
    // remember the sash position we want to set for later if we can't set it
    // right now (e.g. because the window is too small)
    m_requestedSashPosition = position;
    m_checkRequestedSashPosition = false;

    DoSetSashPosition (ConvertSashPosition (position));
    if (redraw) SizeWindows();
}
コード例 #3
0
ファイル: splitter.cpp プロジェクト: CodeSmithyIDE/wxWidgets
// 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);
}
コード例 #4
0
// Position and size subwindows.
// Note that the border size applies to each subwindow, not
// including the edges next to the sash.
void wxSplitWindow::SizeWindows()
{
    // check if we have delayed setting the real sash position
    if (m_checkRequestedSashPosition && 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);

    const int border = GetBorderSize();
    const int sash = GetSashSize();

    if (m_windowOne && m_windowTwo) {

        int size = GetWindowSize();
        int size1;
        int size2;
        if (m_sashPosition == 0) {
            size1 = 0;
            size2 = size - 2*border;
        }else if (m_sashPosition > 0 && m_sashPosition < size) {
            size1 = m_sashPosition - border;
            size2 = size - m_sashPosition - sash - border;
        }else{
            size1 = size;
            size2 = 0 - 2*border;
        }

        int x2, y2, w1, h1, w2, h2;
        if (m_splitMode == wxSPLIT_VERTICAL) {
            w1 = size1;
            w2 = size2;
            h1 = h - 2*border;
            h2 = h1;
            x2 = size - (size2 - border);
            y2 = border;
        }
        else // horz splitwindow
        {
            w1 = w - 2*border;
            w2 = w1;
            h1 = size1;
            h2 = size2;
            x2 = border;
            y2 = size - (size2 - border);
        }

        m_windowOne->SetSize (border, border, w1, h1);
        m_windowTwo->SetSize (x2, y2, w2, h2);
    }

    wxClientDC dc(this);
    DrawSash(dc);

    SetNeedUpdating (false);
}