wxGTK:
+- added support for label mnemonics to GTK+2 build (Michael Moss)
- added native wxMessageDialog implementation for GTK+2 build
- fixed wxMenu::Remove (John Skiff and Benjamin Williams)
- made wxTextCtrl::EmulateKeyPress() work for Delete and Backspace
protected:
virtual wxSize DoGetBestSize() const;
+#ifdef __WXGTK20__
+ wxString PrepareLabelMnemonics( const wxString &label ) const;
+#endif
wxString m_label;
char m_chAccel; // enabled to avoid breaking binary compatibility later on
protected:
virtual wxSize DoGetBestSize() const;
+#ifdef __WXGTK20__
+ wxString PrepareLabelMnemonics( const wxString &label ) const;
+#endif
wxString m_label;
char m_chAccel; // enabled to avoid breaking binary compatibility later on
wxControl::SetLabel( label );
+#ifdef __WXGTK20__
+ wxString label2 = PrepareLabelMnemonics( label );
+ gtk_label_set_text_with_mnemonic( GTK_LABEL( BUTTON_CHILD(m_widget) ), wxGTK_CONV( label2 ) );
+#else
gtk_label_set( GTK_LABEL( BUTTON_CHILD(m_widget) ), wxGTK_CONV( GetLabel() ) );
+#endif
}
bool wxButton::Enable( bool enable )
return FALSE;
}
- wxControl::SetLabel( label );
-
if ( style & wxALIGN_RIGHT )
{
// VZ: as I don't know a way to create a right aligned checkbox with
// left of it
m_widgetCheckbox = gtk_check_button_new();
- m_widgetLabel = gtk_label_new( wxGTK_CONV( m_label ) );
+ m_widgetLabel = gtk_label_new("");
gtk_misc_set_alignment(GTK_MISC(m_widgetLabel), 0.0, 0.5);
m_widget = gtk_hbox_new(FALSE, 0);
}
else
{
- m_widgetCheckbox = gtk_check_button_new_with_label( wxGTK_CONV( m_label ) );
+ m_widgetCheckbox = gtk_check_button_new_with_label("");
m_widgetLabel = BUTTON_CHILD( m_widgetCheckbox );
m_widget = m_widgetCheckbox;
}
+ SetLabel( label );
gtk_signal_connect( GTK_OBJECT(m_widgetCheckbox),
"clicked",
wxControl::SetLabel( label );
+#ifdef __WXGTK20__
+ wxString label2 = PrepareLabelMnemonics( label );
+ gtk_label_set_text_with_mnemonic( GTK_LABEL(m_widgetLabel), wxGTK_CONV( label2 ) );
+#else
gtk_label_set( GTK_LABEL(m_widgetLabel), wxGTK_CONV( GetLabel() ) );
+#endif
}
bool wxCheckBox::Enable( bool enable )
return wxSize(req.width, req.height);
}
+wxString wxControl::PrepareLabelMnemonics( const wxString &label ) const
+{
+ //Format mnemonics properly for GTK2. This can be called from GTK1.x, but
+ //it's not very useful because mnemonics don't exist prior to GTK2.
+ wxString label2;
+ for (size_t i = 0; i < label.Len(); i++)
+ {
+ if (label.GetChar(i) == wxT('&'))
+ {
+ //Mnemonic escape sequence "&&" is a literal "&" in the output.
+ if (label.GetChar(i + 1) == wxT('&'))
+ {
+ label2 << wxT('&');
+ i++;
+ }
+ //Handle special case of "&_" (i.e. "_" is the mnemonic).
+ //FIXME - Is it possible to use "_" as a GTK mnemonic? Just use a
+ //dash for now.
+ else if (label.GetChar(i + 1) == wxT('_'))
+ {
+ label2 << wxT("_-");
+ i++;
+ }
+ //Replace WX mnemonic indicator "&" with GTK indicator "_".
+ else
+ {
+ label2 << wxT('_');
+ }
+ }
+ else if (label.GetChar(i) == wxT('_'))
+ {
+ //Escape any underlines in the string so GTK doesn't use them.
+ label2 << wxT("__");
+ }
+ else
+ {
+ label2 << label.GetChar(i);
+ }
+ }
+ return label2;
+}
+
#endif // wxUSE_CONTROLS
wxControl::SetLabel( label );
GtkLabel *g_label = GTK_LABEL( BUTTON_CHILD(m_widget) );
+#ifdef __WXGTK20__
+ wxString label2 = PrepareLabelMnemonics( label );
+ gtk_label_set_text_with_mnemonic( g_label, wxGTK_CONV( label2 ) );
+#else
gtk_label_set( g_label, wxGTK_CONV( GetLabel() ) );
+#endif
}
void wxRadioButton::SetValue( bool val )
wxControl::SetLabel( label );
+#ifdef __WXGTK20__
+ wxString label2 = PrepareLabelMnemonics( label );
+ gtk_label_set_text_with_mnemonic( GTK_LABEL( BUTTON_CHILD(m_widget) ), wxGTK_CONV( label2 ) );
+#else
gtk_label_set( GTK_LABEL( BUTTON_CHILD(m_widget) ), wxGTK_CONV( GetLabel() ) );
+#endif
}
bool wxButton::Enable( bool enable )
return FALSE;
}
- wxControl::SetLabel( label );
-
if ( style & wxALIGN_RIGHT )
{
// VZ: as I don't know a way to create a right aligned checkbox with
// left of it
m_widgetCheckbox = gtk_check_button_new();
- m_widgetLabel = gtk_label_new( wxGTK_CONV( m_label ) );
+ m_widgetLabel = gtk_label_new("");
gtk_misc_set_alignment(GTK_MISC(m_widgetLabel), 0.0, 0.5);
m_widget = gtk_hbox_new(FALSE, 0);
}
else
{
- m_widgetCheckbox = gtk_check_button_new_with_label( wxGTK_CONV( m_label ) );
+ m_widgetCheckbox = gtk_check_button_new_with_label("");
m_widgetLabel = BUTTON_CHILD( m_widgetCheckbox );
m_widget = m_widgetCheckbox;
}
+ SetLabel( label );
gtk_signal_connect( GTK_OBJECT(m_widgetCheckbox),
"clicked",
wxControl::SetLabel( label );
+#ifdef __WXGTK20__
+ wxString label2 = PrepareLabelMnemonics( label );
+ gtk_label_set_text_with_mnemonic( GTK_LABEL(m_widgetLabel), wxGTK_CONV( label2 ) );
+#else
gtk_label_set( GTK_LABEL(m_widgetLabel), wxGTK_CONV( GetLabel() ) );
+#endif
}
bool wxCheckBox::Enable( bool enable )
return wxSize(req.width, req.height);
}
+wxString wxControl::PrepareLabelMnemonics( const wxString &label ) const
+{
+ //Format mnemonics properly for GTK2. This can be called from GTK1.x, but
+ //it's not very useful because mnemonics don't exist prior to GTK2.
+ wxString label2;
+ for (size_t i = 0; i < label.Len(); i++)
+ {
+ if (label.GetChar(i) == wxT('&'))
+ {
+ //Mnemonic escape sequence "&&" is a literal "&" in the output.
+ if (label.GetChar(i + 1) == wxT('&'))
+ {
+ label2 << wxT('&');
+ i++;
+ }
+ //Handle special case of "&_" (i.e. "_" is the mnemonic).
+ //FIXME - Is it possible to use "_" as a GTK mnemonic? Just use a
+ //dash for now.
+ else if (label.GetChar(i + 1) == wxT('_'))
+ {
+ label2 << wxT("_-");
+ i++;
+ }
+ //Replace WX mnemonic indicator "&" with GTK indicator "_".
+ else
+ {
+ label2 << wxT('_');
+ }
+ }
+ else if (label.GetChar(i) == wxT('_'))
+ {
+ //Escape any underlines in the string so GTK doesn't use them.
+ label2 << wxT("__");
+ }
+ else
+ {
+ label2 << label.GetChar(i);
+ }
+ }
+ return label2;
+}
+
#endif // wxUSE_CONTROLS
wxControl::SetLabel( label );
GtkLabel *g_label = GTK_LABEL( BUTTON_CHILD(m_widget) );
+#ifdef __WXGTK20__
+ wxString label2 = PrepareLabelMnemonics( label );
+ gtk_label_set_text_with_mnemonic( g_label, wxGTK_CONV( label2 ) );
+#else
gtk_label_set( g_label, wxGTK_CONV( GetLabel() ) );
+#endif
}
void wxRadioButton::SetValue( bool val )