Ejemplo n.º 1
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() );
}
Ejemplo n.º 2
0
bool wxButton::DoSetLabelMarkup(const wxString& markup)
{
    wxCHECK_MSG( m_widget != NULL, false, "invalid button" );

    const wxString stripped = RemoveMarkup(markup);
    if ( stripped.empty() && !markup.empty() )
        return false;

    wxControl::SetLabel(stripped);

    GtkLabel * const label = GTKGetLabel();
    wxCHECK_MSG( label, false, "no label in this button?" );

    GTKSetLabelWithMarkupForLabel(label, markup);

    return true;
}