]> git.saurik.com Git - wxWidgets.git/commitdiff
implemented Freeze/Thaw in wxGTK
authorVáclav Slavík <vslavik@fastmail.fm>
Tue, 4 Mar 2008 10:03:01 +0000 (10:03 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Tue, 4 Mar 2008 10:03:01 +0000 (10:03 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52305 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/gtk/window.h
src/gtk/textctrl.cpp
src/gtk/window.cpp

index ba3f7222d99cc24a95254394ad061859a425dea9..d2810e0c9bc79dbb1c541c25dbd28108ee46ee73 100644 (file)
@@ -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
index 4d122f975759977e2a560f04f97fa07791d7ff68..3dc367da3e27bb72d7043640c8f17056ce1ac9f1 100644 (file)
@@ -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();
 }
 
 // ----------------------------------------------------------------------------
index b548b0460c76a6cb9e873279203b639a0397ed75..33aa52e10a2fd579619cf573ad6b87d7814417e2 100644 (file)
@@ -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);
+}