Ejemplo n.º 1
0
int wxSplitWindow::AdjustSashPosition(int sashPos) const {
    wxWindow *win;

    win = m_windowOne;
    if (win) {

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

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

        if (sashPos > 0 && sashPos < minSize) sashPos = minSize;
    }

    win = m_windowTwo;
    if (win) {

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

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

        int maxSize = GetWindowSize() - minSize - GetSashSize();
        if (sashPos < GetWindowSize() && sashPos > maxSize) sashPos = maxSize;
    }

    return sashPos;
}
Ejemplo n.º 2
0
bool wxSplitterWindow::SashHitTest(int x, int y)
{
    if ( m_windowTwo == NULL || m_sashPosition == 0)
        return false; // No sash

    int z = m_splitMode == wxSPLIT_VERTICAL ? x : y;
    int hitMax = m_sashPosition + GetSashSize() - 1;

    return z >= m_sashPosition && z <= hitMax;
}
Ejemplo n.º 3
0
bool wxSplitWindow::SashHitTest (int x, int y, int tolerance) {

    if (m_sashPosition == 0) return false; // No sash

    int z = m_splitMode == wxSPLIT_VERTICAL ? x : y;
    int hitMin = m_sashPosition - tolerance;
    int hitMax = m_sashPosition + GetSashSize() + tolerance;

    return z >=  hitMin && z <= hitMax;
}
Ejemplo n.º 4
0
 void OnExpandEvent(wxCommandEvent& event){
     if(resizing) return;
     int h =  GetSashSize() + expando->GetMinSize().GetHeight();
     //printf("Expando Event resize: %d\n", h);
     //printf("MaxHeight: %d\tMaxSize.Height: %d\n", expando->GetMaxHeight(), expando->GetMaxSize().GetHeight());
     //printf("MinHeight: %d\tMinSize.Height: %d\n\n", expando->GetMinHeight(), expando->GetMinSize().GetHeight());
     
     SetSashPosition(GetSize().GetHeight() - h);
     
     //SetSashPosition(GetSize().GetHeight() - GetSashSize() - expando->GetMinSize().GetHeight());
 }
Ejemplo n.º 5
0
wxSize wxSplitWindow::DoGetBestSize() const {
    // get best sizes of subwindows
    wxSize size1, size2;
    size1.x = 0; size1.y = 0; size2.x = 0; size2.y = 0;
    if (m_windowOne) size1 = m_windowOne->GetEffectiveMinSize();
    if (m_windowTwo) size2 = m_windowTwo->GetEffectiveMinSize();

    // sum them up
    wxSize sizeBest;
    if (m_splitMode == wxSPLIT_VERTICAL) {
        sizeBest.x = wxMax(size1.x, m_minimumPaneSize) + wxMax(size2.x, m_minimumPaneSize);
        sizeBest.y = wxMax(size1.y, size2.y);
        sizeBest.x += GetSashSize();
    }else{ // wxSPLIT_HORIZONTAL
        sizeBest.x = wxMax(size1.x, size2.x);
        sizeBest.y = wxMax(size1.y, m_minimumPaneSize) + wxMax(size2.y, m_minimumPaneSize);
        sizeBest.y += GetSashSize();
    }
    sizeBest.x += 2*GetBorderSize();
    sizeBest.y += 2*GetBorderSize();

    return sizeBest;
}
Ejemplo n.º 6
0
wxSize wxSplitterWindow::DoGetBestSize() const
{
    // get best sizes of subwindows
    wxSize size1, size2;
    if ( m_windowOne )
        size1 = m_windowOne->GetEffectiveMinSize();
    if ( m_windowTwo )
        size2 = m_windowTwo->GetEffectiveMinSize();

    // sum them
    //
    // pSash points to the size component to which sash size must be added
    int *pSash;
    wxSize sizeBest;
    if ( m_splitMode == wxSPLIT_VERTICAL )
    {
        sizeBest.y = wxMax(size1.y, size2.y);
        sizeBest.x = wxMax(size1.x, m_minimumPaneSize) +
                        wxMax(size2.x, m_minimumPaneSize);

        pSash = &sizeBest.x;
    }
    else // wxSPLIT_HORIZONTAL
    {
        sizeBest.x = wxMax(size1.x, size2.x);
        sizeBest.y = wxMax(size1.y, m_minimumPaneSize) +
                        wxMax(size2.y, m_minimumPaneSize);

        pSash = &sizeBest.y;
    }

    // account for the sash if the window is actually split
    if ( m_windowOne && m_windowTwo )
        *pSash += GetSashSize();

    // account for the border too
    int border = 2*GetBorderSize();
    sizeBest.x += border;
    sizeBest.y += border;

    return sizeBest;
}
Ejemplo n.º 7
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);
}
Ejemplo n.º 8
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);
}