void wxStaticText::SetLabel(const wxString& label)
{
    m_labelOrig = label;

    // middle/end ellipsization is handled by the OS:
    if ( HasFlag(wxST_ELLIPSIZE_END) || HasFlag(wxST_ELLIPSIZE_MIDDLE)
#if wxOSX_USE_COCOA // Cocoa has all three modes
         || HasFlag(wxST_ELLIPSIZE_START)
#endif
    )
    {
        // leave ellipsization to the OS
        DoSetLabel(GetLabelWithoutMarkup());
    }
    else // not supported natively
    {
        DoSetLabel(GetEllipsizedLabelWithoutMarkup());
    }

    if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) &&
         !IsEllipsized() )  // don't resize if we adjust to current size
    {
        InvalidateBestSize();
        SetSize( GetBestSize() );
    }

    Refresh();

    // we shouldn't need forced updates
    // Update();
}
void wxStaticText::SetLabel(const wxString& label)
{
    m_labelOrig = label;       // save original label

    // Motif does not support neither ellipsize nor markup in static text:
    DoSetLabel(GetEllipsizedLabelWithoutMarkup());
}
Exemple #3
0
void wxStaticText::SetLabel( const wxString& str )
{
    wxCHECK_RET( m_widget != NULL, wxT("invalid static text") );

    // save the label inside m_labelOrig in case user calls GetLabel() later
    m_labelOrig = str;

    InvalidateBestSize();

    wxString label(str);
    if (gtk_check_version(2,6,0) &&
        IsEllipsized())
    {
        // GTK+ < 2.6 does not support ellipsization:
        // since we need to use our generic code for ellipsization (which does not
        // behaves well in conjunction with markup; i.e. it may break the markup
        // validity erasing portions of the string), we also need to strip out
        // the markup (if present) from the label.

        label = GetEllipsizedLabelWithoutMarkup();
    }

    if ( HasFlag(wxST_MARKUP) )
        GTKSetLabelWithMarkupForLabel(GTK_LABEL(m_widget), label);
    else
        GTKSetLabelForLabel(GTK_LABEL(m_widget), label);

    // adjust the label size to the new label unless disabled
    if ( !HasFlag(wxST_NO_AUTORESIZE) &&
         !IsEllipsized() )  // if ellipsization is ON, then we don't want to get resized!
        SetSize( GetBestSize() );
}
void wxStaticText::SetLabel(
  const wxString&                   rsLabel
)
{
    m_labelOrig = rsLabel;       // save original label

    // OS/2 does not support neither ellipsize nor markup in static text:
    DoSetLabel(rsLabel);
    DoSetLabel(GetEllipsizedLabelWithoutMarkup());

    //
    // Adjust the size of the window to fit to the label unless autoresizing is
    // disabled
    //
    if (!(GetWindowStyle() & wxST_NO_AUTORESIZE) &&
        !IsEllipsized())
    {
        wxCoord                     vX;
        wxCoord                     vY;
        wxCoord                     vWidth;
        wxCoord                     vHeight;

        GetPosition(&vX, &vY);
        GetSize(&vWidth, &vHeight);
        if (!(vX == -1 && vY == -1 && vWidth == -1 && vHeight == -1))
            DoSetSize(vX, vY, vWidth, vHeight, wxSIZE_AUTO_WIDTH | wxSIZE_AUTO_HEIGHT);
        else
            DoSetSize(-1, -1, -1, -1, wxSIZE_AUTO_WIDTH | wxSIZE_AUTO_HEIGHT);
    }
} // end of wxStaticText::SetLabel
Exemple #5
0
void wxGenericStaticText::SetLabel(const wxString& label)
{
    wxControl::SetLabel(label);
    DoSetLabel(GetEllipsizedLabelWithoutMarkup());
    if ( !HasFlag(wxST_NO_AUTORESIZE) && !IsEllipsized() )
        InvalidateBestSize();
    Refresh();
}
Exemple #6
0
void wxStaticTextBase::UpdateLabel()
{
    if (!IsEllipsized())
        return;

    wxString newlabel = GetEllipsizedLabelWithoutMarkup();

    // we need to touch the "real" label (i.e. the text set inside the control,
    // using port-specific functions) instead of the string returned by GetLabel().
    //
    // In fact, we must be careful not to touch the original label passed to
    // SetLabel() otherwise GetLabel() will behave in a strange way to the user
    // (e.g. returning a "Ver...ing" instead of "Very long string") !
    if (newlabel == DoGetLabel())
        return;
    DoSetLabel(newlabel);
}
Exemple #7
0
void wxStaticText::SetLabel(const wxString& label)
{
#ifdef SS_ENDELLIPSIS
    long styleReal = ::GetWindowLong(GetHwnd(), GWL_STYLE);
    if ( HasFlag(wxST_ELLIPSIZE_END) &&
          wxGetOsVersion() == wxOS_WINDOWS_NT )
    {
        // adding SS_ENDELLIPSIS or SS_ENDELLIPSIS "disables" the correct
        // newline handling in static texts: the newlines in the labels are
        // shown as square. Thus we don't use it even on newer OS when
        // the static label contains a newline.
        if ( label.Contains(wxT('\n')) )
            styleReal &= ~SS_ENDELLIPSIS;
        else
            styleReal |= SS_ENDELLIPSIS;

        ::SetWindowLong(GetHwnd(), GWL_STYLE, styleReal);
    }
    else // style not supported natively
    {
        styleReal &= ~SS_ENDELLIPSIS;
        ::SetWindowLong(GetHwnd(), GWL_STYLE, styleReal);
    }
#endif // SS_ENDELLIPSIS

    // this call will save the label in m_labelOrig and set it into this window
    // (through wxWindow::SetLabel)
    m_labelOrig = label;

#ifdef SS_ENDELLIPSIS
    if ( styleReal & SS_ENDELLIPSIS )
        DoSetLabel(RemoveMarkup(label));
    else
#endif // SS_ENDELLIPSIS
        DoSetLabel(GetEllipsizedLabelWithoutMarkup());

    // adjust the size of the window to fit to the label unless autoresizing is
    // disabled
    if ( !HasFlag(wxST_NO_AUTORESIZE) &&
         !IsEllipsized() )  // if ellipsize is ON, then we don't want to get resized!
    {
        InvalidateBestSize();
        DoSetSize(wxDefaultCoord, wxDefaultCoord, wxDefaultCoord, wxDefaultCoord,
                  wxSIZE_AUTO_WIDTH | wxSIZE_AUTO_HEIGHT);
    }
}