]> git.saurik.com Git - wxWidgets.git/commitdiff
Correxted myfixed widget to prevent warnings from GTK
authorRobert Roebling <robert@roebling.de>
Tue, 18 May 1999 14:49:18 +0000 (14:49 +0000)
committerRobert Roebling <robert@roebling.de>
Tue, 18 May 1999 14:49:18 +0000 (14:49 +0000)
  Changed listbox dclick emission

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2495 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/listbox.cpp
src/gtk/win_gtk.c
src/gtk1/listbox.cpp
src/gtk1/win_gtk.c

index 10c10970455c8a75b431fe00dbfa47bc92812512..dc0d32c66b5ad1c927672087b89f7b204342397a 100644 (file)
@@ -64,12 +64,20 @@ extern bool g_isIdle;
 extern bool   g_blockEventsOnDrag;
 extern bool   g_blockEventsOnScroll;
 
+static bool   g_hasDoubleClicked = FALSE;
+
 //-----------------------------------------------------------------------------
-// "button_press_event"
+// "button_release_event"
 //-----------------------------------------------------------------------------
 
+/* we would normally emit a wxEVT_COMMAND_LISTBOX_DOUBLECLICKED event once
+   a GDK_2BUTTON_PRESS occurs, but this has the particular problem of the
+   listbox keeping the focus until it receives a GDK_BUTTON_RELEASE event.
+   this can lead to race conditions so that we emit the dclick event
+   after the GDK_BUTTON_RELEASE event after the GDK_2BUTTON_PRESS event */
+
 static gint
-gtk_listbox_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxListBox *listbox )
+gtk_listbox_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxListBox *listbox )
 {
     if (g_isIdle) wxapp_install_idle_handler();
 
@@ -78,22 +86,8 @@ gtk_listbox_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event,
 
     if (!listbox->m_hasVMT) return FALSE;
 
-    int sel = listbox->GetIndex( widget );
+    if (!g_hasDoubleClicked) return FALSE;
 
-    if ((listbox->m_hasCheckBoxes) && (gdk_event->x < 15) && (gdk_event->type != GDK_2BUTTON_PRESS))
-    {
-        wxCheckListBox *clb = (wxCheckListBox *)listbox;
-
-        clb->Check( sel, !clb->IsChecked(sel) );
-
-        wxCommandEvent event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, listbox->GetId() );
-        event.SetEventObject( listbox );
-        event.SetInt( sel );
-        listbox->GetEventHandler()->ProcessEvent( event );
-    }
-
-    if (gdk_event->type == GDK_2BUTTON_PRESS)
-    {
         wxCommandEvent event( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, listbox->GetId() );
         event.SetEventObject( listbox );
 
@@ -114,7 +108,39 @@ gtk_listbox_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event,
 
         listbox->GetEventHandler()->ProcessEvent( event );
 
+    return FALSE;
+}
+
+//-----------------------------------------------------------------------------
+// "button_press_event"
+//-----------------------------------------------------------------------------
+
+static gint
+gtk_listbox_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxListBox *listbox )
+{
+    if (g_isIdle) wxapp_install_idle_handler();
+
+    if (g_blockEventsOnDrag) return FALSE;
+    if (g_blockEventsOnScroll) return FALSE;
+
+    if (!listbox->m_hasVMT) return FALSE;
+
+    int sel = listbox->GetIndex( widget );
+
+    if ((listbox->m_hasCheckBoxes) && (gdk_event->x < 15) && (gdk_event->type != GDK_2BUTTON_PRESS))
+    {
+        wxCheckListBox *clb = (wxCheckListBox *)listbox;
+
+        clb->Check( sel, !clb->IsChecked(sel) );
+
+        wxCommandEvent event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, listbox->GetId() );
+        event.SetEventObject( listbox );
+        event.SetInt( sel );
+        listbox->GetEventHandler()->ProcessEvent( event );
     }
+    
+    /* emit wxEVT_COMMAND_LISTBOX_DOUBLECLICKED later */
+    g_hasDoubleClicked = (gdk_event->type == GDK_2BUTTON_PRESS);
 
     return FALSE;
 }
@@ -269,6 +295,11 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
                             (GtkSignalFunc)gtk_listbox_button_press_callback,
                             (gpointer) this );
 
+        gtk_signal_connect_after( GTK_OBJECT(list_item),
+                            "button_release_event",
+                            (GtkSignalFunc)gtk_listbox_button_release_callback,
+                            (gpointer) this );
+
         if (m_hasCheckBoxes)
         {
             gtk_signal_connect( GTK_OBJECT(list_item),
index d7f721c56b66d89ec0844f63fde2ce1d3ad57d9b..43f275e84010dffd5d1482cb562bc029db2a5364 100644 (file)
@@ -228,7 +228,7 @@ gtk_myfixed_put (GtkMyFixed   *myfixed,
   if (GTK_WIDGET_REALIZED (myfixed) && !GTK_WIDGET_REALIZED (widget))
     gtk_widget_realize (widget);
 
-  if (GTK_WIDGET_MAPPED (myfixed) && !GTK_WIDGET_MAPPED (widget))
+  if (GTK_WIDGET_MAPPED (myfixed) && !GTK_WIDGET_MAPPED (widget) && GTK_WIDGET_VISIBLE (widget))
     gtk_widget_map (widget);
 
   if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (myfixed))
index 10c10970455c8a75b431fe00dbfa47bc92812512..dc0d32c66b5ad1c927672087b89f7b204342397a 100644 (file)
@@ -64,12 +64,20 @@ extern bool g_isIdle;
 extern bool   g_blockEventsOnDrag;
 extern bool   g_blockEventsOnScroll;
 
+static bool   g_hasDoubleClicked = FALSE;
+
 //-----------------------------------------------------------------------------
-// "button_press_event"
+// "button_release_event"
 //-----------------------------------------------------------------------------
 
+/* we would normally emit a wxEVT_COMMAND_LISTBOX_DOUBLECLICKED event once
+   a GDK_2BUTTON_PRESS occurs, but this has the particular problem of the
+   listbox keeping the focus until it receives a GDK_BUTTON_RELEASE event.
+   this can lead to race conditions so that we emit the dclick event
+   after the GDK_BUTTON_RELEASE event after the GDK_2BUTTON_PRESS event */
+
 static gint
-gtk_listbox_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxListBox *listbox )
+gtk_listbox_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxListBox *listbox )
 {
     if (g_isIdle) wxapp_install_idle_handler();
 
@@ -78,22 +86,8 @@ gtk_listbox_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event,
 
     if (!listbox->m_hasVMT) return FALSE;
 
-    int sel = listbox->GetIndex( widget );
+    if (!g_hasDoubleClicked) return FALSE;
 
-    if ((listbox->m_hasCheckBoxes) && (gdk_event->x < 15) && (gdk_event->type != GDK_2BUTTON_PRESS))
-    {
-        wxCheckListBox *clb = (wxCheckListBox *)listbox;
-
-        clb->Check( sel, !clb->IsChecked(sel) );
-
-        wxCommandEvent event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, listbox->GetId() );
-        event.SetEventObject( listbox );
-        event.SetInt( sel );
-        listbox->GetEventHandler()->ProcessEvent( event );
-    }
-
-    if (gdk_event->type == GDK_2BUTTON_PRESS)
-    {
         wxCommandEvent event( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, listbox->GetId() );
         event.SetEventObject( listbox );
 
@@ -114,7 +108,39 @@ gtk_listbox_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event,
 
         listbox->GetEventHandler()->ProcessEvent( event );
 
+    return FALSE;
+}
+
+//-----------------------------------------------------------------------------
+// "button_press_event"
+//-----------------------------------------------------------------------------
+
+static gint
+gtk_listbox_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxListBox *listbox )
+{
+    if (g_isIdle) wxapp_install_idle_handler();
+
+    if (g_blockEventsOnDrag) return FALSE;
+    if (g_blockEventsOnScroll) return FALSE;
+
+    if (!listbox->m_hasVMT) return FALSE;
+
+    int sel = listbox->GetIndex( widget );
+
+    if ((listbox->m_hasCheckBoxes) && (gdk_event->x < 15) && (gdk_event->type != GDK_2BUTTON_PRESS))
+    {
+        wxCheckListBox *clb = (wxCheckListBox *)listbox;
+
+        clb->Check( sel, !clb->IsChecked(sel) );
+
+        wxCommandEvent event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, listbox->GetId() );
+        event.SetEventObject( listbox );
+        event.SetInt( sel );
+        listbox->GetEventHandler()->ProcessEvent( event );
     }
+    
+    /* emit wxEVT_COMMAND_LISTBOX_DOUBLECLICKED later */
+    g_hasDoubleClicked = (gdk_event->type == GDK_2BUTTON_PRESS);
 
     return FALSE;
 }
@@ -269,6 +295,11 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
                             (GtkSignalFunc)gtk_listbox_button_press_callback,
                             (gpointer) this );
 
+        gtk_signal_connect_after( GTK_OBJECT(list_item),
+                            "button_release_event",
+                            (GtkSignalFunc)gtk_listbox_button_release_callback,
+                            (gpointer) this );
+
         if (m_hasCheckBoxes)
         {
             gtk_signal_connect( GTK_OBJECT(list_item),
index d7f721c56b66d89ec0844f63fde2ce1d3ad57d9b..43f275e84010dffd5d1482cb562bc029db2a5364 100644 (file)
@@ -228,7 +228,7 @@ gtk_myfixed_put (GtkMyFixed   *myfixed,
   if (GTK_WIDGET_REALIZED (myfixed) && !GTK_WIDGET_REALIZED (widget))
     gtk_widget_realize (widget);
 
-  if (GTK_WIDGET_MAPPED (myfixed) && !GTK_WIDGET_MAPPED (widget))
+  if (GTK_WIDGET_MAPPED (myfixed) && !GTK_WIDGET_MAPPED (widget) && GTK_WIDGET_VISIBLE (widget))
     gtk_widget_map (widget);
 
   if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (myfixed))