From 6cab4fcac7fe26d9ae5a1d29066e0893d689bb38 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Sun, 1 Feb 2009 07:52:39 +0000 Subject: [PATCH] simplify Refresh() and Update() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58585 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/window.h | 3 --- src/gtk/window.cpp | 62 ++++++++++++++----------------------------------- 2 files changed, 17 insertions(+), 48 deletions(-) diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h index 075a40c..9a47bea 100644 --- a/include/wx/gtk/window.h +++ b/include/wx/gtk/window.h @@ -129,9 +129,6 @@ public: // regularly virtual void OnInternalIdle(); - // Internal represention of Update() - void GtkUpdate(); - // For compatibility across platforms (not in event table) void OnIdle(wxIdleEvent& WXUNUSED(event)) {} diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index e0d7ae0..6f2da8a 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -3537,66 +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() { - if (m_widget) + 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); - GtkUpdate(); - // Flush again, but no need to wait for it to finish - gdk_display_flush(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); } } @@ -3605,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) -- 2.7.4