]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/window.cpp
check for m_parentMenu being NULL in IsChecked/Checked/Enable() too (closes #10460)
[wxWidgets.git] / src / gtk / window.cpp
index 0a6eb5b75e00e54fd1bc0c6fb9750cc191ae77ad..6f2da8ab52bfe45e198d0946e20f3c597a552be4 100644 (file)
@@ -257,11 +257,11 @@ gdk_window_warp_pointer (GdkWindow      *window,
 // "size_request" of m_widget
 //-----------------------------------------------------------------------------
 
-// make it extern because wxStaticText needs to disconnect this one
 extern "C" {
-void wxgtk_window_size_request_callback(GtkWidget * WXUNUSED(widget),
-                                        GtkRequisition *requisition,
-                                        wxWindow * win)
+static void
+wxgtk_window_size_request_callback(GtkWidget * WXUNUSED(widget),
+                                   GtkRequisition *requisition,
+                                   wxWindow * win)
 {
     int w, h;
     win->GetSize( &w, &h );
@@ -2095,7 +2095,7 @@ bool wxWindowGTK::Create( wxWindow *parent,
 {
     // Get default border
     wxBorder border = GetBorder(style);
-    
+
     style &= ~wxBORDER_MASK;
     style |= border;
 
@@ -2113,7 +2113,7 @@ bool wxWindowGTK::Create( wxWindow *parent,
 #endif
 
 
-    m_wxwindow = wxPizza::New(m_windowStyle);
+    m_wxwindow = wxPizza::New(m_windowStyle,this);
 #ifndef __WXUNIVERSAL__
     if (HasFlag(wxPizza::BORDER_STYLES))
     {
@@ -2540,6 +2540,12 @@ void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags
             event.SetEventObject( this );
             HandleWindowEvent( event );
         }
+    } else 
+    if (sizeFlags & wxSIZE_FORCE_EVENT)
+    {
+        wxSizeEvent event( wxSize(m_width,m_height), GetId() );
+        event.SetEventObject( this );
+        HandleWindowEvent( event );
     }
 }
 
@@ -2681,7 +2687,7 @@ void wxWindowGTK::DoGetClientSize( int *width, int *height ) const
                             continue;
                 }
 
-                GtkScrolledWindowClass *scroll_class = 
+                GtkScrolledWindowClass *scroll_class =
                     GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT_GET_CLASS(m_widget) );
 
                 GtkRequisition req;
@@ -3531,63 +3537,39 @@ bool wxWindowGTK::ScrollPages(int pages)
 void wxWindowGTK::Refresh(bool WXUNUSED(eraseBackground),
                           const wxRect *rect)
 {
-    if (!m_widget)
-        return;
-    if (!m_widget->window)
+    GtkWidget* widget;
+    if (m_wxwindow)
+        widget = m_wxwindow;
+    else if (m_widget)
+        widget = m_widget;
+    else
         return;
 
-    if (m_wxwindow)
+    if (rect == NULL)
+        gtk_widget_queue_draw(widget);
+    else
     {
-        if (m_wxwindow->window == NULL) return;
-
-        GdkRectangle gdk_rect,
-                    *p;
-        if (rect)
-        {
-            gdk_rect.x = rect->x;
-            gdk_rect.y = rect->y;
-            gdk_rect.width = rect->width;
-            gdk_rect.height = rect->height;
-            if (GetLayoutDirection() == wxLayout_RightToLeft)
-                gdk_rect.x = GetClientSize().x - gdk_rect.x - gdk_rect.width;
-
-            p = &gdk_rect;
-        }
-        else // invalidate everything
-        {
-            p = NULL;
-        }
+        int x = rect->x;
+        if (GetLayoutDirection() == wxLayout_RightToLeft)
+            x = GetClientSize().x - x - rect->width;
 
-        gdk_window_invalidate_rect(m_wxwindow->window, p, true);
+        gtk_widget_queue_draw_area(widget, x, rect->y, rect->width, rect->height);
     }
 }
 
 void wxWindowGTK::Update()
 {
-    GtkUpdate();
-
-    // when we call Update() we really want to update the window immediately on
-    // screen, even if it means flushing the entire queue and hence slowing down
-    // everything -- but it should still be done, it's just that Update() should
-    // be called very rarely
-    gdk_flush();
-}
+    if (m_widget && m_widget->window)
+    {
+        GdkDisplay* display = gtk_widget_get_display(m_widget);
+        // Flush everything out to the server, and wait for it to finish.
+        // This ensures nothing will overwrite the drawing we are about to do.
+        gdk_display_sync(display);
 
-void wxWindowGTK::GtkUpdate()
-{
-    if (m_wxwindow && m_wxwindow->window)
-        gdk_window_process_updates(m_wxwindow->window, false);
-    if (m_widget && m_widget->window && (m_wxwindow != m_widget))
-        gdk_window_process_updates( m_widget->window, FALSE );
+        gdk_window_process_updates(m_widget->window, true);
 
-    // for consistency with other platforms (and also because it's convenient
-    // to be able to update an entire TLW by calling Update() only once), we
-    // should also update all our children here
-    for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
-          node;
-          node = node->GetNext() )
-    {
-        node->GetData()->GtkUpdate();
+        // Flush again, but no need to wait for it to finish
+        gdk_display_flush(display);
     }
 }
 
@@ -3596,7 +3578,6 @@ bool wxWindowGTK::DoIsExposed( int x, int y ) const
     return m_updateRegion.Contains(x, y) != wxOutRegion;
 }
 
-
 bool wxWindowGTK::DoIsExposed( int x, int y, int w, int h ) const
 {
     if (GetLayoutDirection() == wxLayout_RightToLeft)