honour the mnemonics; don't use gtk_label_set_markup() for foreground colour as this doesn't seem to be necessary
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37340 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -61,14 +61,9 @@ bool wxStaticText::Create(wxWindow *parent,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// notice that we call the base class version which will
|
const wxString labelGTK = GTKConvertMnemonics(label);
|
||||||
// not set the label's text to it because the label is no
|
m_label = label;
|
||||||
// yet created and because SetLabel() has a side
|
m_widget = gtk_label_new_with_mnemonic(wxGTK_CONV(labelGTK));
|
||||||
// effect of changing the control size which might not be desirable
|
|
||||||
// wxContro::SetLabel no longer strips menu codes, so do it here.
|
|
||||||
wxString label1(wxStripMenuCodes(label));
|
|
||||||
wxControl::SetLabel(label);
|
|
||||||
m_widget = gtk_label_new( wxGTK_CONV( label1 ) );
|
|
||||||
|
|
||||||
GtkJustification justify;
|
GtkJustification justify;
|
||||||
if ( style & wxALIGN_CENTER )
|
if ( style & wxALIGN_CENTER )
|
||||||
@@ -83,7 +78,7 @@ bool wxStaticText::Create(wxWindow *parent,
|
|||||||
static const float labelAlignments[] = { 0.0, 1.0, 0.5 };
|
static const float labelAlignments[] = { 0.0, 1.0, 0.5 };
|
||||||
gtk_misc_set_alignment(GTK_MISC(m_widget), labelAlignments[justify], 0.0);
|
gtk_misc_set_alignment(GTK_MISC(m_widget), labelAlignments[justify], 0.0);
|
||||||
|
|
||||||
gtk_label_set_line_wrap( GTK_LABEL(m_widget), TRUE );
|
gtk_label_set_line_wrap( GTK_LABEL(m_widget), TRUE );
|
||||||
|
|
||||||
m_parent->DoAddChild( this );
|
m_parent->DoAddChild( this );
|
||||||
|
|
||||||
@@ -114,32 +109,13 @@ wxString wxStaticText::GetLabel() const
|
|||||||
|
|
||||||
void wxStaticText::SetLabel( const wxString &label )
|
void wxStaticText::SetLabel( const wxString &label )
|
||||||
{
|
{
|
||||||
wxControl::SetLabel(label);
|
wxCHECK_RET( m_widget != NULL, wxT("invalid static text") );
|
||||||
wxString label1(wxStripMenuCodes(label));
|
|
||||||
|
|
||||||
// Build the colorized version of the label (markup only allowed
|
GTKSetLabelForLabel(GTK_LABEL(m_widget), label);
|
||||||
// under GTK2):
|
|
||||||
// FIXME: Does this handle background correct? I recall bug reports - MR
|
|
||||||
if (m_foregroundColour.Ok())
|
|
||||||
{
|
|
||||||
// If the color has been set, create a markup string to pass to
|
|
||||||
// the label setter
|
|
||||||
wxString colorlabel;
|
|
||||||
colorlabel.Printf(_T("<span foreground=\"#%02x%02x%02x\">%s</span>"),
|
|
||||||
m_foregroundColour.Red(), m_foregroundColour.Green(),
|
|
||||||
m_foregroundColour.Blue(),
|
|
||||||
wxEscapeStringForPangoMarkup(label1).c_str());
|
|
||||||
gtk_label_set_markup( GTK_LABEL(m_widget), wxGTK_CONV( colorlabel ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
gtk_label_set_text( GTK_LABEL(m_widget), wxGTK_CONV( label1 ) );
|
|
||||||
|
|
||||||
// adjust the label size to the new label unless disabled
|
// adjust the label size to the new label unless disabled
|
||||||
if (!HasFlag(wxST_NO_AUTORESIZE))
|
if ( !HasFlag(wxST_NO_AUTORESIZE) )
|
||||||
{
|
|
||||||
InvalidateBestSize();
|
|
||||||
SetSize( GetBestSize() );
|
SetSize( GetBestSize() );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxStaticText::SetFont( const wxFont &font )
|
bool wxStaticText::SetFont( const wxFont &font )
|
||||||
|
Reference in New Issue
Block a user