From 5f346ddc0a4233f78c22a4f7a0501d9779732789 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Tue, 4 Mar 2008 10:03:01 +0000 Subject: [PATCH] implemented Freeze/Thaw in wxGTK git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52305 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/window.h | 6 ++++++ src/gtk/textctrl.cpp | 39 ++++++++++++--------------------------- src/gtk/window.cpp | 30 ++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 27 deletions(-) diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h index ba3f7222d9..d2810e0c9b 100644 --- a/include/wx/gtk/window.h +++ b/include/wx/gtk/window.h @@ -326,6 +326,12 @@ protected: virtual void DoCaptureMouse(); virtual void DoReleaseMouse(); + virtual void DoFreeze(); + virtual void DoThaw(); + + static void GTKFreezeWidget(GtkWidget *w); + static void GTKThawWidget(GtkWidget *w); + #if wxUSE_TOOLTIPS virtual void DoSetToolTip( wxToolTip *tip ); #endif // wxUSE_TOOLTIPS diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index 4d122f9757..3dc367da3e 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -557,21 +557,6 @@ gtk_paste_clipboard_callback( GtkWidget *widget, wxTextCtrl *win ) } } -//----------------------------------------------------------------------------- -// "expose_event" from scrolled window and textview -//----------------------------------------------------------------------------- - -extern "C" { -static gboolean -gtk_text_exposed_callback( GtkWidget * WXUNUSED(widget), - GdkEventExpose * WXUNUSED(event), - wxTextCtrl * WXUNUSED(win) ) -{ - return TRUE; -} -} - - //----------------------------------------------------------------------------- // wxTextCtrl //----------------------------------------------------------------------------- @@ -1722,14 +1707,13 @@ void wxTextCtrl::DoFreeze() { wxCHECK_RET(m_text != NULL, wxT("invalid text ctrl")); + wxWindow::DoFreeze(); + if ( HasFlag(wxTE_MULTILINE) ) { - // freeze textview updates and remove buffer - g_signal_connect (m_text, "expose_event", - G_CALLBACK (gtk_text_exposed_callback), this); - g_signal_connect (m_widget, "expose_event", - G_CALLBACK (gtk_text_exposed_callback), this); - gtk_widget_set_sensitive(m_widget, false); + GTKFreezeWidget(m_text); + + // removing buffer dramatically speeds up insertion: g_object_ref(m_buffer); GtkTextBuffer* buf_new = gtk_text_buffer_new(NULL); GtkTextMark* mark = GTK_TEXT_VIEW(m_text)->first_para_mark; @@ -1749,21 +1733,22 @@ void wxTextCtrl::DoThaw() { if ( HasFlag(wxTE_MULTILINE) ) { - // Reattach buffer and thaw textview updates + // reattach buffer: gtk_text_view_set_buffer(GTK_TEXT_VIEW(m_text), m_buffer); g_object_unref(m_buffer); - gtk_widget_set_sensitive(m_widget, true); - g_signal_handlers_disconnect_by_func (m_widget, - (gpointer) gtk_text_exposed_callback, this); - g_signal_handlers_disconnect_by_func (m_text, - (gpointer) gtk_text_exposed_callback, this); + if (m_showPositionOnThaw != NULL) { gtk_text_view_scroll_mark_onscreen( GTK_TEXT_VIEW(m_text), m_showPositionOnThaw); m_showPositionOnThaw = NULL; } + + // and thaw the window + GTKThawWidget(m_text); } + + wxWindow::DoThaw(); } // ---------------------------------------------------------------------------- diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index b548b0460c..33aa52e10a 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -4205,3 +4205,33 @@ GdkWindow* wxWindowGTK::GTKGetDrawingWindow() const window = m_wxwindow->window; return window; } + +// ---------------------------------------------------------------------------- +// freeze/thaw +// ---------------------------------------------------------------------------- + +void wxWindowGTK::GTKFreezeWidget(GtkWidget *w) +{ + if ( w && !GTK_WIDGET_NO_WINDOW(w) ) + gdk_window_freeze_updates(w->window); +} + +void wxWindowGTK::GTKThawWidget(GtkWidget *w) +{ + if ( w && !GTK_WIDGET_NO_WINDOW(w) ) + gdk_window_thaw_updates(w->window); +} + +void wxWindowGTK::DoFreeze() +{ + GTKFreezeWidget(m_widget); + if ( m_wxwindow && m_widget != m_wxwindow ) + GTKFreezeWidget(m_wxwindow); +} + +void wxWindowGTK::DoThaw() +{ + GTKThawWidget(m_widget); + if ( m_wxwindow && m_widget != m_wxwindow ) + GTKThawWidget(m_wxwindow); +} -- 2.45.2