Beispiel #1
0
void wxStatusBarBase::PopStatusText(int number)
{
    wxCHECK_RET( (unsigned)number < m_panes.size(),
                    "invalid status bar field index" );

    if ( m_panes[number].PopText() )
        DoUpdateStatusText(number);
}
Beispiel #2
0
void wxStatusBarBase::PushStatusText(const wxString& text, int number)
{
    wxCHECK_RET( (unsigned)number < m_panes.size(),
                    "invalid status bar field index" );

    if ( m_panes[number].PushText(text) )
        DoUpdateStatusText(number);
}
Beispiel #3
0
void wxStatusBar::MSWUpdateFieldsWidths()
{
    if ( m_panes.IsEmpty() )
        return;

    const int count = m_panes.GetCount();

    const int extraWidth = MSWGetBorderWidth() + MSWGetMetrics().textMargin;

    // compute the effectively available amount of space:
    int widthAvailable = GetClientSize().x;     // start with the entire width
    widthAvailable -= extraWidth*(count - 1);   // extra space between fields
    widthAvailable -= MSWGetMetrics().textMargin;   // and for the last field

    // Deal with the grip: we shouldn't overflow onto the space occupied by it
    // so the effectively available space is smaller.
    const int gripWidth = HasFlag(wxSTB_SIZEGRIP) ? MSWGetMetrics().gripWidth
                                                  : 0;
    widthAvailable -= gripWidth;

    // distribute the available space (client width) among the various fields:

    wxArrayInt widthsAbs = CalculateAbsWidths(widthAvailable);


    // update the field widths in the native control:

    int *pWidths = new int[count];

    int nCurPos = 0;
    int i;
    for ( i = 0; i < count; i++ )
    {
        nCurPos += widthsAbs[i] + extraWidth;
        pWidths[i] = nCurPos;
    }

    // The total width of the panes passed to Windows must be equal to the
    // total width available, including the grip. Otherwise we get an extra
    // separator line just before it.
    pWidths[count - 1] += gripWidth;

    if ( !StatusBar_SetParts(GetHwnd(), count, pWidths) )
    {
        wxLogLastError("StatusBar_SetParts");
    }

    // Now that all parts have been created, set their text.
    for ( i = 0; i < count; i++ )
    {
        DoUpdateStatusText(i);
    }

    delete [] pWidths;
}
Beispiel #4
0
WXLRESULT
wxStatusBar::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
{
#ifndef __WXWINCE__
    if ( nMsg == WM_WINDOWPOSCHANGING )
    {
        WINDOWPOS *lpPos = (WINDOWPOS *)lParam;
        int x, y, w, h;
        GetPosition(&x, &y);
        GetSize(&w, &h);

        // we need real window coords and not wx client coords
        AdjustForParentClientOrigin(x, y);

        lpPos->x  = x;
        lpPos->y  = y;
        lpPos->cx = w;
        lpPos->cy = h;

        return 0;
    }

    if ( nMsg == WM_NCLBUTTONDOWN )
    {
        // if hit-test is on gripper then send message to TLW to begin
        // resizing. It is possible to send this message to any window.
        if ( wParam == HTBOTTOMRIGHT )
        {
            wxWindow *win;

            for ( win = GetParent(); win; win = win->GetParent() )
            {
                if ( win->IsTopLevel() )
                {
                    SendMessage(GetHwndOf(win), WM_NCLBUTTONDOWN,
                                wParam, lParam);

                    return 0;
                }
            }
        }
    }
#endif

    if ( nMsg == WM_SIZE )
    {
        MSWUpdateFieldsWidths();

        if ( HasFlag(wxSTB_ELLIPSIZE_START) ||
                HasFlag(wxSTB_ELLIPSIZE_MIDDLE) ||
                    HasFlag(wxSTB_ELLIPSIZE_END) )
        {
            for (int i=0; i<GetFieldsCount(); i++)
            {
                // re-set the field text, in case we need to ellipsize
                // (or de-ellipsize) some parts of it
                DoUpdateStatusText(i);
            }
        }
    }

    return wxStatusBarBase::MSWWindowProc(nMsg, wParam, lParam);
}