]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/textctrl.cpp
fixing file paths after renaming
[wxWidgets.git] / src / gtk / textctrl.cpp
index 4d122f975759977e2a560f04f97fa07791d7ff68..7e5b5f5472b761bfa86711b3d290f2e9f38b6317 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
 //-----------------------------------------------------------------------------
@@ -970,6 +955,22 @@ void wxTextCtrl::DoSetValue( const wxString &value, int flags )
         return;
     }
 
+    if (value.IsEmpty())
+    {
+        if ( !(flags & SetValue_SendEvent) )
+            EnableTextChangedEvents(false);
+        
+        gtk_text_buffer_set_text( m_buffer, "", 0 );
+            
+        if ( !(flags & SetValue_SendEvent) )
+            EnableTextChangedEvents(true);
+            
+        return;
+    }
+
+#ifdef wxUSE_UNICODE
+    const wxCharBuffer buffer(value.utf8_str());
+#else
     wxFontEncoding enc = m_defaultStyle.HasFont()
                             ? m_defaultStyle.GetFont().GetEncoding()
                             : wxFONTENCODING_SYSTEM;
@@ -984,6 +985,7 @@ void wxTextCtrl::DoSetValue( const wxString &value, int flags )
         wxLogWarning(_("Failed to set text in the text control."));
         return;
     }
+#endif
 
     if ( !(flags & SetValue_SendEvent) )
     {
@@ -1022,6 +1024,9 @@ void wxTextCtrl::WriteText( const wxString &text )
         return;
     }
 
+#ifdef wxUSE_UNICODE
+    const wxCharBuffer buffer(text.utf8_str());
+#else
     // check if we have a specific style for the current position
     wxFontEncoding enc = wxFONTENCODING_SYSTEM;
     wxTextAttr style;
@@ -1042,6 +1047,7 @@ void wxTextCtrl::WriteText( const wxString &text )
         wxLogWarning(_("Failed to insert text in the control."));
         return;
     }
+#endif
 
     // First remove the selection if there is one
     // TODO:  Is there an easier GTK specific way to do this?
@@ -1722,14 +1728,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 +1754,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();
 }
 
 // ----------------------------------------------------------------------------