コード例 #1
0
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(GetLabel());
    }
    else // not supported natively
    {
        DoSetLabel(GetEllipsizedLabel());
    }

    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();
}
コード例 #2
0
void wxStaticText::SetLabel(const wxString& label)
{
    m_labelOrig = label;       // save original label

    // Motif does not support ellipsized labels natively
    DoSetLabel(GetEllipsizedLabel());
}
コード例 #3
0
ファイル: stattext.cpp プロジェクト: beanhome/dev
void wxStaticText::SetLabel(const wxString& str)
{
    // save original label
    m_labelOrig = str;

    // draw as real label the abbreviated version of it
    DoSetLabel(GetEllipsizedLabel());
}
コード例 #4
0
ファイル: stattextg.cpp プロジェクト: Anonymous2/project64
void wxGenericStaticText::SetLabel(const wxString& label)
{
    wxControl::SetLabel(label);
    DoSetLabel(GetEllipsizedLabel());
    if ( !HasFlag(wxST_NO_AUTORESIZE) && !IsEllipsized() )
        InvalidateBestSize();

#if wxUSE_MARKUP
    if ( m_markupText )
    {
        delete m_markupText;
        m_markupText = NULL;
    }
#endif // wxUSE_MARKUP

    Refresh();
}
コード例 #5
0
ファイル: stattext.cpp プロジェクト: Annovae/Dolphin-Core
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

    // save the label in m_labelOrig with both the markup (if any) and
    // the mnemonics characters (if any)
    m_labelOrig = label;

#ifdef SS_ENDELLIPSIS
    if ( styleReal & SS_ENDELLIPSIS )
        DoSetLabel(GetLabel());
    else
#endif // SS_ENDELLIPSIS
        DoSetLabel(GetEllipsizedLabel());

    // 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);
    }
}
コード例 #6
0
void wxGenericStaticText::SetLabel(const wxString& label)
{
    wxControl::SetLabel(label);
    DoSetLabel(GetEllipsizedLabel());

    AutoResizeIfNecessary();

#if wxUSE_MARKUP
    if ( m_markupText )
    {
        delete m_markupText;
        m_markupText = NULL;
    }
#endif // wxUSE_MARKUP

    Refresh();
}
コード例 #7
0
ファイル: stattextcmn.cpp プロジェクト: chromylei/third_party
void wxStaticTextBase::UpdateLabel()
{
    if (!IsEllipsized())
        return;

    wxString newlabel = GetEllipsizedLabel();

    // 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);
}
コード例 #8
0
ファイル: stattext.cpp プロジェクト: AaronDP/wxWidgets
void wxStaticText::SetLabel(const wxString& label)
{
#ifdef SS_ENDELLIPSIS
    long styleReal = ::GetWindowLong(GetHwnd(), GWL_STYLE);
    if ( HasFlag(wxST_ELLIPSIZE_END) )
    {
        // 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

    // save the label in m_labelOrig with both the markup (if any) and
    // the mnemonics characters (if any)
    m_labelOrig = label;

#ifdef SS_ENDELLIPSIS
    if ( styleReal & SS_ENDELLIPSIS )
        DoSetLabel(GetLabel());
    else
#endif // SS_ENDELLIPSIS
        DoSetLabel(GetEllipsizedLabel());

    InvalidateBestSize();

    if ( !IsEllipsized() )  // if ellipsize is ON, then we don't want to get resized!
    {
        AutoResizeIfNecessary();
    }
}
コード例 #9
0
ファイル: stattext.cpp プロジェクト: Richard-Ni/wxWidgets
void wxStaticText::GTKDoSetLabel(GTKLabelSetter setter, const wxString& label)
{
    wxCHECK_RET( m_widget != NULL, wxT("invalid static text") );

    InvalidateBestSize();

    if (gtk_check_version(2,6,0) && IsEllipsized())
    {
        // GTK+ < 2.6 does not support ellipsization so we need to do it
        // manually and as our ellipsization code doesn't deal with markup, we
        // have no choice but to ignore it in this case and always use plain
        // text.
        GTKSetLabelForLabel(GTK_LABEL(m_widget), GetEllipsizedLabel());
    }
    else // Ellipsization not needed or supported by GTK+.
    {
        (this->*setter)(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() );
}