]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk1/window.cpp
Needed to add #include "wx/statusbr.h" to know that wxStatusBar is derived
[wxWidgets.git] / src / gtk1 / window.cpp
index 536777c8f04b29d99241dba2dde40f7bacfb46ed..7bd13fae8e06856ead82b0b9bf709f22f1c7361f 100644 (file)
@@ -7,11 +7,6 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-    #pragma implementation "window.h"
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
@@ -244,7 +239,9 @@ wxWindowGTK *g_delayedFocus = (wxWindowGTK*) NULL;
 
 // hack: we need something to pass to gtk_menu_popup, so we store the time of
 // the last click here
+#ifndef __WXGTK20__
 static guint32 gs_timeLastClick = 0;
+#endif
 
 extern bool g_mainThreadLocked;
 
@@ -1393,9 +1390,9 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
 
         if ( btnCancel )
         {
-            wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
-            event.SetEventObject(btnCancel);
-            ret = btnCancel->GetEventHandler()->ProcessEvent(event);
+            wxCommandEvent eventClick(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
+            eventClick.SetEventObject(btnCancel);
+            ret = btnCancel->GetEventHandler()->ProcessEvent(eventClick);
         }
     }
 
@@ -1804,9 +1801,9 @@ static gint gtk_window_button_press_callback( GtkWidget *widget,
     if ( !g_captureWindow )
         win = FindWindowForMouseEvent(win, event.m_x, event.m_y);
 
+#ifndef __WXGTK20__
     gs_timeLastClick = gdk_event->time;
 
-#ifndef __WXGTK20__
     if (event_type == wxEVT_LEFT_DCLICK)
     {
         // GTK 1.2 crashes when intercepting double
@@ -1818,7 +1815,7 @@ static gint gtk_window_button_press_callback( GtkWidget *widget,
             return FALSE;
         }
     }
-#endif
+#endif // !__WXGTK20__
 
     if (win->GetEventHandler()->ProcessEvent( event ))
     {
@@ -1963,11 +1960,11 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget,
             // the mouse changed window
             g_captureWindowHasMouse = hasMouse;
 
-            wxMouseEvent event(g_captureWindowHasMouse ? wxEVT_ENTER_WINDOW
-                                                       : wxEVT_LEAVE_WINDOW);
-            InitMouseEvent(win, event, gdk_event);
-            event.SetEventObject(win);
-            win->GetEventHandler()->ProcessEvent(event);
+            wxMouseEvent eventM(g_captureWindowHasMouse ? wxEVT_ENTER_WINDOW
+                                                        : wxEVT_LEAVE_WINDOW);
+            InitMouseEvent(win, eventM, gdk_event);
+            eventM.SetEventObject(win);
+            win->GetEventHandler()->ProcessEvent(eventM);
         }
     }
     else // no capture
@@ -2883,11 +2880,22 @@ wxWindowGTK::~wxWindowGTK()
     m_isBeingDeleted = true;
     m_hasVMT = false;
 
+    // destroy children before destroying this window itself
+    DestroyChildren();
+
+    // unhook focus handlers to prevent stray events being
+    // propagated to this (soon to be) dead object
+    if (m_focusWidget != NULL)
+    {
+        gtk_signal_disconnect_by_func( GTK_OBJECT(m_focusWidget),
+            (GtkSignalFunc) gtk_window_focus_in_callback, (gpointer) this );
+        gtk_signal_disconnect_by_func( GTK_OBJECT(m_focusWidget),
+            (GtkSignalFunc) gtk_window_focus_out_callback, (gpointer) this );
+    }
+
     if (m_widget)
         Show( false );
 
-    DestroyChildren();
-
 #ifdef HAVE_XIM
     if (m_ic)
         gdk_ic_destroy (m_ic);
@@ -2895,6 +2903,11 @@ wxWindowGTK::~wxWindowGTK()
         gdk_ic_attr_destroy (m_icattr);
 #endif
 
+#ifdef __WXGTK20__
+    // delete before the widgets to avoid a crash on solaris
+    delete m_imData;
+#endif
+
     if (m_wxwindow)
     {
         gtk_widget_destroy( m_wxwindow );
@@ -2906,10 +2919,6 @@ wxWindowGTK::~wxWindowGTK()
         gtk_widget_destroy( m_widget );
         m_widget = (GtkWidget*) NULL;
     }
-
-#ifdef __WXGTK20__
-    delete m_imData;
-#endif
 }
 
 bool wxWindowGTK::PreCreation( wxWindowGTK *parent, const wxPoint &pos,  const wxSize &size )
@@ -4151,8 +4160,7 @@ void wxWindowGTK::GtkSendPaintEvents()
 
     m_clipPaintRegion = false;
 
-#ifndef __WXUNIVERSAL__
-#ifndef __WXGTK20__
+#if !defined(__WXUNIVERSAL__) && !defined(__WXGTK20__)
     // The following code will result in all window-less widgets
     // being redrawn because the wxWidgets class is allowed to
     // paint over the window-less widgets.
@@ -4173,6 +4181,7 @@ void wxWindowGTK::GtkSendPaintEvents()
             gdk_event.type = GDK_EXPOSE;
             gdk_event.window = pizza->bin_window;
             gdk_event.count = 0;
+            gdk_event.send_event = TRUE;
 
             wxRegionIterator upd( m_updateRegion );
             while (upd)
@@ -4192,8 +4201,7 @@ void wxWindowGTK::GtkSendPaintEvents()
             }
         }
     }
-#endif
-#endif
+#endif // native GTK 1
 
     m_updateRegion.Clear();
 }
@@ -4280,12 +4288,10 @@ PangoContext *wxWindowGTK::GtkGetPangoDefaultContext()
     return gtk_widget_get_pango_context( m_widget );
 }
 
+// MR: Returns the same as GtkGetPangoDefaultContext until the symbol can be removed in 2.7.x
 PangoContext *wxWindowGTK::GtkGetPangoX11Context()
 {
-    if (!m_x11Context)
-        m_x11Context = pango_x_get_context( gdk_display );
-
-    return m_x11Context;
+    return gtk_widget_get_pango_context( m_widget );
 }
 #endif
 
@@ -4419,13 +4425,13 @@ bool wxWindowGTK::SetBackgroundStyle(wxBackgroundStyle style)
 
 #if wxUSE_MENUS_NATIVE
 
-extern "C"
+extern "C" WXDLLIMPEXP_CORE
 void gtk_pop_hide_callback( GtkWidget *WXUNUSED(widget), bool* is_waiting  )
 {
     *is_waiting = FALSE;
 }
 
-void SetInvokingWindow( wxMenu *menu, wxWindow* win )
+WXDLLIMPEXP_CORE void SetInvokingWindow( wxMenu *menu, wxWindow* win )
 {
     menu->SetInvokingWindow( win );
 
@@ -4442,12 +4448,13 @@ void SetInvokingWindow( wxMenu *menu, wxWindow* win )
     }
 }
 
-extern "C" void wxPopupMenuPositionCallback( GtkMenu *menu,
-                                             gint *x, gint *y,
+extern "C" WXDLLIMPEXP_CORE
+void wxPopupMenuPositionCallback( GtkMenu *menu,
+                                  gint *x, gint *y,
 #ifdef __WXGTK20__
-                                             gboolean * WXUNUSED(whatever),
+                                  gboolean * WXUNUSED(whatever),
 #endif
-                                             gpointer user_data )
+                                  gpointer user_data )
 {
     // ensure that the menu appears entirely on screen
     GtkRequisition req;