]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk1/textctrl.cpp
DMC conflicts with old SC.
[wxWidgets.git] / src / gtk1 / textctrl.cpp
index 09059a3f0058f95fcd94b9697e0e79b286c0f4b1..023debbdb1a2dd6b49ef220dfd543667212b0bee 100644 (file)
@@ -518,7 +518,8 @@ wxString wxTextCtrl::GetValue() const
 #else
         wxCharBuffer buffer( wxConvLocal.cWC2WX( wxConvUTF8.cMB2WC( text ) ) );
 #endif
-        tmp = buffer;
+        if ( buffer )
+            tmp = buffer;
 
         g_free( text );
 #else
@@ -550,6 +551,9 @@ void wxTextCtrl::SetValue( const wxString &value )
         wxCharBuffer buffer( wxConvUTF8.cWC2MB( wxConvLocal.cWX2WC( value ) ) );
 #endif
         GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) );
+        if (gtk_text_buffer_get_char_count(text_buffer) != 0)
+            IgnoreNextTextUpdate();
+
         gtk_text_buffer_set_text( text_buffer, buffer, strlen(buffer) );
 
 #else
@@ -821,14 +825,19 @@ void wxTextCtrl::SetInsertionPoint( long pos )
 {
     wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
 
-    if (m_windowStyle & wxTE_MULTILINE)
+    if ( IsMultiLine() )
     {
 #ifdef __WXGTK20__
         GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) );
         GtkTextIter iter;
         gtk_text_buffer_get_iter_at_offset( text_buffer, &iter, pos );
         gtk_text_buffer_place_cursor( text_buffer, &iter );
-#else
+        gtk_text_view_scroll_mark_onscreen
+        (
+            GTK_TEXT_VIEW(m_text),
+            gtk_text_buffer_get_insert( text_buffer )
+        );
+#else // GTK+ 1.x
         gtk_signal_disconnect_by_func( GTK_OBJECT(m_text),
           GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
 
@@ -845,7 +854,7 @@ void wxTextCtrl::SetInsertionPoint( long pos )
 
         // bring editable's cursor uptodate. Bug in GTK.
         SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) ));
-#endif
+#endif // GTK+ 2/1
     }
     else
     {
@@ -1430,12 +1439,14 @@ void wxTextCtrl::ChangeFontGlobally()
     // possible!
     //
     // TODO: it can be implemented much more efficiently for GTK2
-    wxASSERT_MSG( (m_windowStyle & wxTE_MULTILINE)
 #ifndef __WXGTK20__
-                    && m_updateFont
-#endif // GTK+ 1.x
-                    ,
+    wxASSERT_MSG( (m_windowStyle & wxTE_MULTILINE) && m_updateFont,
+
                   _T("shouldn't be called for single line controls") );
+#else
+    wxASSERT_MSG( (m_windowStyle & wxTE_MULTILINE),
+                  _T("shouldn't be called for single line controls") );
+#endif
 
     wxString value = GetValue();
     if ( !value.IsEmpty() )
@@ -1475,8 +1486,10 @@ bool wxTextCtrl::SetBackgroundColour( const wxColour &colour )
     if ( !wxControl::SetBackgroundColour( colour ) )
         return FALSE;
 
+#ifndef __WXGTK20__
     if (!m_widget->window)
         return FALSE;
+#endif
 
     if (!m_backgroundColour.Ok())
         return FALSE;