]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/radiobox.cpp
check that the version of __sync_sub_and_fetch that returns a value is supported...
[wxWidgets.git] / src / gtk / radiobox.cpp
index 8d399e33e4a56490a58b2f8038013a03d115bc25..67d698b21421422d0d0b33eeaebdfd0fa8d77b1c 100644 (file)
@@ -27,8 +27,6 @@
 #include "wx/gtk/private.h"
 #include <gdk/gdkkeysyms.h>
 
 #include "wx/gtk/private.h"
 #include <gdk/gdkkeysyms.h>
 
-#include "wx/gtk/win_gtk.h"
-
 //-----------------------------------------------------------------------------
 // wxGTKRadioButtonInfo
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 // wxGTKRadioButtonInfo
 //-----------------------------------------------------------------------------
@@ -49,7 +47,7 @@ public:
 //-----------------------------------------------------------------------------
 
 #include "wx/listimpl.cpp"
 //-----------------------------------------------------------------------------
 
 #include "wx/listimpl.cpp"
-WX_DEFINE_LIST( wxRadioBoxButtonsInfoList );
+WX_DEFINE_LIST( wxRadioBoxButtonsInfoList )
 
 extern bool          g_blockEventsOnDrag;
 
 
 extern bool          g_blockEventsOnDrag;
 
@@ -60,8 +58,6 @@ extern bool          g_blockEventsOnDrag;
 extern "C" {
 static void gtk_radiobutton_clicked_callback( GtkToggleButton *button, wxRadioBox *rb )
 {
 extern "C" {
 static void gtk_radiobutton_clicked_callback( GtkToggleButton *button, wxRadioBox *rb )
 {
-    if (g_isIdle) wxapp_install_idle_handler();
-
     if (!rb->m_hasVMT) return;
     if (g_blockEventsOnDrag) return;
 
     if (!rb->m_hasVMT) return;
     if (g_blockEventsOnDrag) return;
 
@@ -71,7 +67,7 @@ static void gtk_radiobutton_clicked_callback( GtkToggleButton *button, wxRadioBo
     event.SetInt( rb->GetSelection() );
     event.SetString( rb->GetStringSelection() );
     event.SetEventObject( rb );
     event.SetInt( rb->GetSelection() );
     event.SetString( rb->GetStringSelection() );
     event.SetEventObject( rb );
-    rb->GetEventHandler()->ProcessEvent(event);
+    rb->HandleWindowEvent(event);
 }
 }
 
 }
 }
 
@@ -82,8 +78,6 @@ static void gtk_radiobutton_clicked_callback( GtkToggleButton *button, wxRadioBo
 extern "C" {
 static gint gtk_radiobox_keypress_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxRadioBox *rb )
 {
 extern "C" {
 static gint gtk_radiobox_keypress_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxRadioBox *rb )
 {
-    // don't need to install idle handler, its done from "event" signal
-
     if (!rb->m_hasVMT) return FALSE;
     if (g_blockEventsOnDrag) return FALSE;
 
     if (!rb->m_hasVMT) return FALSE;
     if (g_blockEventsOnDrag) return FALSE;
 
@@ -98,7 +92,7 @@ static gint gtk_radiobox_keypress_callback( GtkWidget *widget, GdkEventKey *gdk_
         // CTRL-TAB changes the (parent) window, i.e. switch notebook page
         new_event.SetWindowChange( (gdk_event->state & GDK_CONTROL_MASK) );
         new_event.SetCurrentFocus( rb );
         // CTRL-TAB changes the (parent) window, i.e. switch notebook page
         new_event.SetWindowChange( (gdk_event->state & GDK_CONTROL_MASK) );
         new_event.SetCurrentFocus( rb );
-        return rb->GetParent()->GetEventHandler()->ProcessEvent( new_event );
+        return rb->GetParent()->HandleWindowEvent(new_event);
     }
 
     if ((gdk_event->keyval != GDK_Up) &&
     }
 
     if ((gdk_event->keyval != GDK_Up) &&
@@ -119,8 +113,6 @@ static gint gtk_radiobox_keypress_callback( GtkWidget *widget, GdkEventKey *gdk_
         return FALSE;
     }
 
         return FALSE;
     }
 
-    g_signal_stop_emission_by_name (widget, "key_press_event");
-
     if ((gdk_event->keyval == GDK_Up) ||
         (gdk_event->keyval == GDK_Left))
     {
     if ((gdk_event->keyval == GDK_Up) ||
         (gdk_event->keyval == GDK_Left))
     {
@@ -146,7 +138,7 @@ static gint gtk_radiobox_keypress_callback( GtkWidget *widget, GdkEventKey *gdk_
 }
 
 extern "C" {
 }
 
 extern "C" {
-static gint gtk_radiobutton_focus_in( GtkWidget *widget,
+static gint gtk_radiobutton_focus_in( GtkWidget * WXUNUSED(widget),
                                       GdkEvent *WXUNUSED(event),
                                       wxRadioBox *win )
 {
                                       GdkEvent *WXUNUSED(event),
                                       wxRadioBox *win )
 {
@@ -164,7 +156,7 @@ static gint gtk_radiobutton_focus_in( GtkWidget *widget,
 
         // never stop the signal emission, it seems to break the kbd handling
         // inside the radiobox
 
         // never stop the signal emission, it seems to break the kbd handling
         // inside the radiobox
-        (void)win->GetEventHandler()->ProcessEvent( event );
+        (void)win->HandleWindowEvent( event );
     }
 
     return FALSE;
     }
 
     return FALSE;
@@ -172,7 +164,7 @@ static gint gtk_radiobutton_focus_in( GtkWidget *widget,
 }
 
 extern "C" {
 }
 
 extern "C" {
-static gint gtk_radiobutton_focus_out( GtkWidget *widget,
+static gint gtk_radiobutton_focus_out( GtkWidget * WXUNUSED(widget),
                                        GdkEvent *WXUNUSED(event),
                                        wxRadioBox *win )
 {
                                        GdkEvent *WXUNUSED(event),
                                        wxRadioBox *win )
 {
@@ -195,12 +187,11 @@ static void gtk_radiobutton_size_allocate( GtkWidget *widget,
                                            GtkAllocation * alloc,
                                            wxRadioBox *win )
 {
                                            GtkAllocation * alloc,
                                            wxRadioBox *win )
 {
-    unsigned int n = 0;
     for ( wxRadioBoxButtonsInfoList::compatibility_iterator node = win->m_buttonsInfo.GetFirst();
           node;
     for ( wxRadioBoxButtonsInfoList::compatibility_iterator node = win->m_buttonsInfo.GetFirst();
           node;
-          node = node->GetNext(), n++ )
+          node = node->GetNext())
     {
     {
-        if( widget == GTK_WIDGET(node->GetData()->button) )
+        if (widget == GTK_WIDGET(node->GetData()->button))
         {
             const wxPoint origin = win->GetPosition();
             wxRect rect = wxRect( alloc->x - origin.x, alloc->y - origin.y,
         {
             const wxPoint origin = win->GetPosition();
             wxRect rect = wxRect( alloc->x - origin.x, alloc->y - origin.y,
@@ -221,9 +212,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxRadioBox,wxControl)
 
 void wxRadioBox::Init()
 {
 
 void wxRadioBox::Init()
 {
-    m_needParent = true;
-    m_acceptsFocus = true;
-
     m_hasFocus =
     m_lostFocus = false;
 }
     m_hasFocus =
     m_lostFocus = false;
 }
@@ -256,6 +244,12 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
 
     m_widget = GTKCreateFrame(title);
     wxControl::SetLabel(title);
 
     m_widget = GTKCreateFrame(title);
     wxControl::SetLabel(title);
+    if ( HasFlag(wxNO_BORDER) )
+    {
+        // If we don't do this here, the wxNO_BORDER style is ignored in Show()
+        gtk_frame_set_shadow_type(GTK_FRAME(m_widget), GTK_SHADOW_NONE);
+    }
+
 
     // majorDim may be 0 if all trailing parameters were omitted, so don't
     // assert here but just use the correct value for it
 
     // majorDim may be 0 if all trailing parameters were omitted, so don't
     // assert here but just use the correct value for it
@@ -281,7 +275,8 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
             radio_button_group = gtk_radio_button_get_group( GTK_RADIO_BUTTON(rbtn) );
 
         label.Empty();
             radio_button_group = gtk_radio_button_get_group( GTK_RADIO_BUTTON(rbtn) );
 
         label.Empty();
-        for ( const wxChar *pc = choices[i]; *pc; pc++ )
+        for ( wxString::const_iterator pc = choices[i].begin();
+              pc != choices[i].end(); ++pc )
         {
             if ( *pc != wxT('&') )
                 label += *pc;
         {
             if ( *pc != wxT('&') )
                 label += *pc;
@@ -560,9 +555,8 @@ void wxRadioBox::GtkDisableEvents()
     wxRadioBoxButtonsInfoList::compatibility_iterator node = m_buttonsInfo.GetFirst();
     while (node)
     {
     wxRadioBoxButtonsInfoList::compatibility_iterator node = m_buttonsInfo.GetFirst();
     while (node)
     {
-        g_signal_handlers_disconnect_by_func (node->GetData()->button,
-                                              (gpointer) gtk_radiobutton_clicked_callback,
-                                              this);
+        g_signal_handlers_block_by_func(node->GetData()->button,
+            (gpointer)gtk_radiobutton_clicked_callback, this);
 
         node = node->GetNext();
     }
 
         node = node->GetNext();
     }
@@ -573,8 +567,8 @@ void wxRadioBox::GtkEnableEvents()
     wxRadioBoxButtonsInfoList::compatibility_iterator node = m_buttonsInfo.GetFirst();
     while (node)
     {
     wxRadioBoxButtonsInfoList::compatibility_iterator node = m_buttonsInfo.GetFirst();
     while (node)
     {
-        g_signal_connect (node->GetData()->button, "clicked",
-                          G_CALLBACK (gtk_radiobutton_clicked_callback), this);
+        g_signal_handlers_unblock_by_func(node->GetData()->button,
+            (gpointer)gtk_radiobutton_clicked_callback, this);
 
         node = node->GetNext();
     }
 
         node = node->GetNext();
     }
@@ -607,7 +601,7 @@ void wxRadioBox::GTKWidgetDoSetMnemonic(GtkWidget* w)
 }
 
 #if wxUSE_TOOLTIPS
 }
 
 #if wxUSE_TOOLTIPS
-void wxRadioBox::ApplyToolTip(GtkTooltips * WXUNUSED(tips), const wxChar *tip)
+void wxRadioBox::ApplyToolTip(GtkTooltips * WXUNUSED(tips), const gchar *tip)
 {
     // set this tooltip for all radiobuttons which don't have their own tips
     unsigned n = 0;
 {
     // set this tooltip for all radiobuttons which don't have their own tips
     unsigned n = 0;
@@ -617,8 +611,7 @@ void wxRadioBox::ApplyToolTip(GtkTooltips * WXUNUSED(tips), const wxChar *tip)
     {
         if ( !GetItemToolTip(n) )
         {
     {
         if ( !GetItemToolTip(n) )
         {
-            wxToolTip::Apply(GTK_WIDGET(node->GetData()->button),
-                             wxConvCurrent->cWX2MB(tip));
+            wxToolTip::Apply(GTK_WIDGET(node->GetData()->button), tip);
         }
     }
 }
         }
     }
 }
@@ -665,7 +658,7 @@ void wxRadioBox::OnInternalIdle()
         wxFocusEvent event( wxEVT_KILL_FOCUS, GetId() );
         event.SetEventObject( this );
 
         wxFocusEvent event( wxEVT_KILL_FOCUS, GetId() );
         event.SetEventObject( this );
 
-        (void)GetEventHandler()->ProcessEvent( event );
+        (void)HandleWindowEvent( event );
     }
 }
 
     }
 }
 
@@ -690,7 +683,7 @@ int wxRadioBox::GetItemFromPoint(const wxPoint& point) const
     for ( wxRadioBoxButtonsInfoList::compatibility_iterator
             node = m_buttonsInfo.GetFirst(); node; node = node->GetNext(), n++ )
     {
     for ( wxRadioBoxButtonsInfoList::compatibility_iterator
             node = m_buttonsInfo.GetFirst(); node; node = node->GetNext(), n++ )
     {
-        if ( m_buttonsInfo[n]->rect.Inside(pt) )
+        if ( m_buttonsInfo[n]->rect.Contains(pt) )
             return n;
     }
 
             return n;
     }