]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/radiobox.cpp
don't send CHECKLISTBOX_TOGGLE event when Check() is called (closes bug 651140)
[wxWidgets.git] / src / gtk / radiobox.cpp
index cd422ade2ba8150e5c78a6a6c0e323dc31d1093e..5bc55111c2674038e1b9941dfc5c1c166602580b 100644 (file)
@@ -37,7 +37,8 @@ extern bool g_isIdle;
 // data
 //-----------------------------------------------------------------------------
 
-extern bool       g_blockEventsOnDrag;
+extern bool          g_blockEventsOnDrag;
+extern wxWindowGTK  *g_delayedFocus;
 
 //-----------------------------------------------------------------------------
 // "clicked"
@@ -179,7 +180,7 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
         return FALSE;
     }
 
-    m_widget = gtk_frame_new( title.mbc_str() );
+    m_widget = gtk_frame_new( wxGTK_CONV( title ) );
 
     // majorDim may be 0 if all trailing parameters were omitted, so don't
     // assert here but just use the correct value for it
@@ -201,7 +202,7 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
                 label += *pc;
         }
 
-        m_radio = GTK_RADIO_BUTTON( gtk_radio_button_new_with_label( radio_button_group, label.mbc_str() ) );
+        m_radio = GTK_RADIO_BUTTON( gtk_radio_button_new_with_label( radio_button_group, wxGTK_CONV( label ) ) );
 
         gtk_signal_connect( GTK_OBJECT(m_radio), "key_press_event",
            GTK_SIGNAL_FUNC(gtk_radiobox_keypress_callback), (gpointer)this );
@@ -417,7 +418,7 @@ bool wxRadioBox::Show( bool show )
     return TRUE;
 }
 
-int wxRadioBox::FindString( const wxString &s ) const
+int wxRadioBox::FindString( const wxString &find ) const
 {
     wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid radiobox") );
 
@@ -427,7 +428,12 @@ int wxRadioBox::FindString( const wxString &s ) const
     while (node)
     {
         GtkLabel *label = GTK_LABEL( BUTTON_CHILD(node->Data()) );
-        if (s == label->label)
+#ifdef __WXGTK20__
+        wxString str( wxGTK_CONV_BACK( gtk_label_get_text(label) ) );
+#else
+        wxString str( label->label );
+#endif
+        if (find == str)
             return count;
 
         count++;
@@ -455,7 +461,6 @@ void wxRadioBox::SetFocus()
         }
         node = node->Next();
     }
-
 }
 
 void wxRadioBox::SetSelection( int n )
@@ -505,7 +510,13 @@ wxString wxRadioBox::GetString( int n ) const
 
     GtkLabel *label = GTK_LABEL( BUTTON_CHILD(node->Data()) );
 
-    return wxString( label->label );
+#ifdef __WXGTK20__
+    wxString str( wxGTK_CONV_BACK( gtk_label_get_text(label) ) );
+#else
+    wxString str( label->label );
+#endif
+
+    return str;
 }
 
 void wxRadioBox::SetLabel( const wxString& label )
@@ -514,7 +525,7 @@ void wxRadioBox::SetLabel( const wxString& label )
 
     wxControl::SetLabel( label );
 
-    gtk_frame_set_label( GTK_FRAME(m_widget), wxControl::GetLabel().mbc_str() );
+    gtk_frame_set_label( GTK_FRAME(m_widget), wxGTK_CONV( wxControl::GetLabel() ) );
 }
 
 void wxRadioBox::SetString( int item, const wxString& label )
@@ -527,7 +538,7 @@ void wxRadioBox::SetString( int item, const wxString& label )
 
     GtkLabel *g_label = GTK_LABEL( BUTTON_CHILD(node->Data()) );
 
-    gtk_label_set( g_label, label.mbc_str() );
+    gtk_label_set( g_label, wxGTK_CONV( label ) );
 }
 
 bool wxRadioBox::Enable( bool enable )
@@ -592,7 +603,12 @@ wxString wxRadioBox::GetStringSelection() const
         {
             GtkLabel *label = GTK_LABEL( BUTTON_CHILD(node->Data()) );
 
-            return label->label;
+#ifdef __WXGTK20__
+            wxString str( wxGTK_CONV_BACK( gtk_label_get_text(label) ) );
+#else
+            wxString str( label->label );
+#endif
+            return str;
         }
         node = node->Next();
     }
@@ -711,6 +727,15 @@ void wxRadioBox::OnInternalIdle()
 
         (void)GetEventHandler()->ProcessEvent( event );
     }
+
+    if (g_delayedFocus == this)
+    {
+        if (GTK_WIDGET_REALIZED(m_widget))
+        {
+            g_delayedFocus = NULL;
+            SetFocus();
+        }
+    }
 }
 
 #endif // wxUSE_RADIOBOX