]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/textctrl.cpp
Trying to commit wxDirDialog patch.
[wxWidgets.git] / src / gtk / textctrl.cpp
index 5a550f140b07037f3592462f98279adb540f9b89..3b3cd28c2dc9ae147d10aa93557db71b6569fa21 100644 (file)
 #include "wx/wxprec.h"
 
 #include "wx/textctrl.h"
+
+#ifndef WX_PRECOMP
+    #include "wx/intl.h"
+    #include "wx/log.h"
+#endif
+
 #include "wx/utils.h"
-#include "wx/intl.h"
-#include "wx/log.h"
 #include "wx/math.h"
 #include "wx/settings.h"
 #include "wx/panel.h"
@@ -600,8 +604,7 @@ bool wxTextCtrl::Create( wxWindow *parent,
 
         gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( m_text ), wrap );
 
-        if (!HasFlag(wxNO_BORDER))
-            gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW(m_widget), GTK_SHADOW_IN );
+        GtkScrolledWindowSetBorder(m_widget, style);
 
         gtk_widget_add_events( GTK_WIDGET(m_text), GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK );
 
@@ -779,9 +782,14 @@ void wxTextCtrl::SetValue( const wxString &value )
 
         gtk_text_buffer_set_text( m_buffer, buffer, strlen(buffer) );
     }
-    else
+    else // single line
     {
-        gtk_entry_set_text( GTK_ENTRY(m_text), wxGTK_CONV( value ) );
+        // gtk_entry_set_text() emits two "changed" signals because internally
+        // it calls gtk_editable_delete_text() and gtk_editable_insert_text()
+        // but we want to have only one event
+        IgnoreNextTextUpdate();
+
+        gtk_entry_set_text( GTK_ENTRY(m_text), wxGTK_CONV(value) );
     }
 
     // GRG, Jun/2000: Changed this after a lot of discussion in
@@ -813,7 +821,14 @@ void wxTextCtrl::WriteText( const wxString &text )
 
     if ( m_windowStyle & wxTE_MULTILINE )
     {
-        // TODO: Call whatever is needed to delete the selection.
+        // First remove the selection if there is one
+        // TODO:  Is there an easier GTK specific way to do this?
+        long from, to;
+        GetSelection(&from, &to);
+        if (from != to)
+            Remove(from, to);
+
+        // Insert the text
         wxGtkTextInsert( m_text, m_buffer, m_defaultStyle, buffer );
 
         GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment( GTK_SCROLLED_WINDOW(m_widget) );