+ // keep the original string internally to be able to return it later (for
+ // consistency with the other ports)
+ m_label = label;
+
+ InvalidateBestSize();
+}
+
+wxString wxControl::GetLabel() const
+{
+ return m_label;
+}
+
+void wxControl::GTKSetLabelForLabel(GtkLabel *w, const wxString& label)
+{
+ // don't call the virtual function which might call this one back again
+ wxControl::SetLabel(label);
+
+ const wxString labelGTK = GTKRemoveMnemonics(label);
+
+ gtk_label_set(w, wxGTK_CONV(labelGTK));
+}
+
+void wxControl::GTKSetLabelForFrame(GtkFrame *w, const wxString& label)
+{
+ wxControl::SetLabel(label);
+
+ const wxString labelGTK = GTKRemoveMnemonics(label);
+
+ gtk_frame_set_label(w, labelGTK.empty() ? (const char *)NULL
+ : wxGTK_CONV(labelGTK));
+}
+
+/* static */
+wxString wxControl::GTKRemoveMnemonics(const wxString& label)
+{
+ const size_t len = label.length();
+ wxString labelGTK;
+ labelGTK.reserve(len);
+ for ( size_t i = 0; i < len; i++ )
+ {
+ wxChar ch = label[i];
+
+ if ( ch == wxT('&') )
+ {
+ if ( i == len - 1 )
+ {
+ // "&" at the end of string is an error
+ wxLogDebug(wxT("Invalid label \"%s\"."), label.c_str());
+ break;
+ }
+
+ ch = label[++i]; // skip '&' itself
+ if ( ch == wxT('&') )
+ {
+ // special case: "&&" is not a mnemonic at all but just an
+ // escaped "&"
+ labelGTK += wxT('&');
+ continue;
+ }
+ }
+
+ labelGTK += ch;
+ }
+
+ return labelGTK;
+}
+
+// ----------------------------------------------------------------------------
+// wxControl styles (a.k.a. attributes)
+// ----------------------------------------------------------------------------
+
+wxVisualAttributes wxControl::GetDefaultAttributes() const
+{
+ return GetDefaultAttributesFromGTKWidget(m_widget,
+ UseGTKStyleBase());
+}
+
+
+#define SHIFT (8*(sizeof(short int)-sizeof(char)))
+
+// static
+wxVisualAttributes
+wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* widget,
+ bool useBase,
+ int state)
+{
+ GtkStyle* style;
+ wxVisualAttributes attr;
+
+ style = gtk_rc_get_style(widget);
+ if (!style)
+ style = gtk_widget_get_default_style();
+
+ if (!style)
+ {
+ return wxWindow::GetClassDefaultAttributes(wxWINDOW_VARIANT_NORMAL);