]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk1/window.cpp
Rewrote wxRadioBox (recompile)
[wxWidgets.git] / src / gtk1 / window.cpp
index 1d121ea4c0752c8bc5b7355960c6bba9d3c5ac5f..eec08efb5b81f040a63ceff1767e522ee24e7f9e 100644 (file)
 extern wxList wxPendingDelete;
 extern wxList wxTopLevelWindows;
 extern bool   g_blockEventsOnDrag;
+       bool   g_capturing = FALSE;
 
 //-----------------------------------------------------------------------------
 // "expose_event" (of m_wxwindow, not of m_widget)
@@ -371,21 +372,24 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
   // Some control don't have their own X window and thus cannot get
   // any events. 
   
-  wxNode *node = win->GetChildren()->First();
-  while (node)
+  if (!g_capturing)
   {
-    wxWindow *child = (wxWindow*)node->Data();
-    if ((child->m_x <= event.m_x) &&
-        (child->m_y <= event.m_y) &&
-       (child->m_x+child->m_width  >= event.m_x) &&
-       (child->m_y+child->m_height >= event.m_y))
+    wxNode *node = win->GetChildren()->First();
+    while (node)
     {
-      win = child;
-      event.m_x -= child->m_x;
-      event.m_y -= child->m_y;
-      break;
+      wxWindow *child = (wxWindow*)node->Data();
+      if ((child->m_x <= event.m_x) &&
+          (child->m_y <= event.m_y) &&
+         (child->m_x+child->m_width  >= event.m_x) &&
+         (child->m_y+child->m_height >= event.m_y))
+      {
+        win = child;
+        event.m_x -= child->m_x;
+        event.m_y -= child->m_y;
+        break;
+      }
+      node = node->Next();
     }
-    node = node->Next();
   }
   
   event.SetEventObject( win );
@@ -403,6 +407,7 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
 static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
 { 
   if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
+  
   if (g_blockEventsOnDrag) return TRUE;
 
   if (!win->HasVMT()) return TRUE;
@@ -437,21 +442,24 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto
   // Some control don't have their own X window and thus cannot get
   // any events. 
   
-  wxNode *node = win->GetChildren()->First();
-  while (node)
+  if (!g_capturing)
   {
-    wxWindow *child = (wxWindow*)node->Data();
-    if ((child->m_x <= event.m_x) &&
-        (child->m_y <= event.m_y) &&
-       (child->m_x+child->m_width  >= event.m_x) &&
-       (child->m_y+child->m_height >= event.m_y))
+    wxNode *node = win->GetChildren()->First();
+    while (node)
     {
-      win = child;
-      event.m_x -= child->m_x;
-      event.m_y -= child->m_y;
-      break;
+      wxWindow *child = (wxWindow*)node->Data();
+      if ((child->m_x <= event.m_x) &&
+          (child->m_y <= event.m_y) &&
+         (child->m_x+child->m_width  >= event.m_x) &&
+         (child->m_y+child->m_height >= event.m_y))
+      {
+        win = child;
+        event.m_x -= child->m_x;
+        event.m_y -= child->m_y;
+        break;
+      }
+      node = node->Next();
     }
-    node = node->Next();
   }
   
   event.SetEventObject( win );
@@ -469,6 +477,7 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto
 static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxWindow *win )
 { 
   if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
+  
   if (g_blockEventsOnDrag) return TRUE;
 
   if (!win->HasVMT()) return TRUE;
@@ -495,21 +504,24 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion
   // Some control don't have their own X window and thus cannot get
   // any events. 
   
-  wxNode *node = win->GetChildren()->First();
-  while (node)
+  if (!g_capturing)
   {
-    wxWindow *child = (wxWindow*)node->Data();
-    if ((child->m_x <= event.m_x) &&
-        (child->m_y <= event.m_y) &&
-       (child->m_x+child->m_width  >= event.m_x) &&
-       (child->m_y+child->m_height >= event.m_y))
+    wxNode *node = win->GetChildren()->First();
+    while (node)
     {
-      win = child;
-      event.m_x -= child->m_x;
-      event.m_y -= child->m_y;
-      break;
+      wxWindow *child = (wxWindow*)node->Data();
+      if ((child->m_x <= event.m_x) &&
+          (child->m_y <= event.m_y) &&
+         (child->m_x+child->m_width  >= event.m_x) &&
+         (child->m_y+child->m_height >= event.m_y))
+      {
+        win = child;
+        event.m_x -= child->m_x;
+        event.m_y -= child->m_y;
+        break;
+      }
+      node = node->Next();
     }
-    node = node->Next();
   }
   
   event.SetEventObject( win );
@@ -599,7 +611,9 @@ static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED
 static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
 {
   if (widget->window != gdk_event->window) return TRUE;
+  
   if (g_blockEventsOnDrag) return TRUE;
+  
   if (!win->HasVMT()) return TRUE;
   
   if (widget->window)
@@ -621,9 +635,11 @@ static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_
 static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
 {
   if (widget->window != gdk_event->window) return TRUE;
-  if (!win->HasVMT()) return TRUE;
+  
   if (g_blockEventsOnDrag) return TRUE;
   
+  if (!win->HasVMT()) return TRUE;
+  
   if (widget->window)
     gdk_window_set_cursor( widget->window, wxSTANDARD_CURSOR->GetCursor() );
     
@@ -1885,22 +1901,12 @@ void wxWindow::SetDropTarget( wxDropTarget *dropTarget )
 {
   GtkWidget *dnd_widget = GetConnectWidget();
   
-  if (m_pDropTarget)
-  {
-    gtk_signal_disconnect_by_func( GTK_OBJECT(dnd_widget),
-      GTK_SIGNAL_FUNC(gtk_window_drop_callback), (gpointer)this );
+  DisconnectDnDWidget( dnd_widget );
   
-    m_pDropTarget->UnregisterWidget( dnd_widget );
-    delete m_pDropTarget;
-  }
+  if (m_pDropTarget) delete m_pDropTarget;
   m_pDropTarget = dropTarget;
-  if (m_pDropTarget)
-  {
-    m_pDropTarget->RegisterWidget( dnd_widget );
-    
-    gtk_signal_connect( GTK_OBJECT(dnd_widget), "drop_data_available_event",
-      GTK_SIGNAL_FUNC(gtk_window_drop_callback), (gpointer)this );
-  }
+  
+  ConnectDnDWidget( dnd_widget );
 }
 
 wxDropTarget *wxWindow::GetDropTarget() const
@@ -1908,6 +1914,26 @@ wxDropTarget *wxWindow::GetDropTarget() const
   return m_pDropTarget;
 }
 
+void wxWindow::ConnectDnDWidget( GtkWidget *widget )
+{
+  if (!m_pDropTarget) return;
+  
+  m_pDropTarget->RegisterWidget( widget );
+    
+  gtk_signal_connect( GTK_OBJECT(widget), "drop_data_available_event",
+    GTK_SIGNAL_FUNC(gtk_window_drop_callback), (gpointer)this );
+}
+
+void wxWindow::DisconnectDnDWidget( GtkWidget *widget )
+{
+  if (!m_pDropTarget) return;
+  
+  gtk_signal_disconnect_by_func( GTK_OBJECT(widget),
+    GTK_SIGNAL_FUNC(gtk_window_drop_callback), (gpointer)this );
+  
+  m_pDropTarget->UnregisterWidget( widget );
+}
+
 GtkWidget* wxWindow::GetConnectWidget(void)
 {
   GtkWidget *connect_widget = m_widget;
@@ -1971,6 +1997,7 @@ void wxWindow::CaptureMouse(void)
         GDK_BUTTON_RELEASE_MASK |
         GDK_POINTER_MOTION_MASK), 
         (GdkWindow *) NULL, (GdkCursor *) NULL, GDK_CURRENT_TIME );
+  g_capturing = TRUE;
 }
 
 void wxWindow::ReleaseMouse(void)
@@ -1978,6 +2005,7 @@ void wxWindow::ReleaseMouse(void)
   GtkWidget *connect_widget = GetConnectWidget();
   gtk_grab_remove( connect_widget );
   gdk_pointer_ungrab ( GDK_CURRENT_TIME );
+  g_capturing = FALSE;
 }
 
 void wxWindow::SetTitle( const wxString &WXUNUSED(title) )