]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/textctrl.cpp
Implement GetValue() and SetValue() and send an event when clicked
[wxWidgets.git] / src / gtk / textctrl.cpp
index 0b1fc61efe8a28e61b6829aa6add7fc9dad1d8af..7ae4bda8cb795e5941c1ba4b7070bc484bf1bc66 100644 (file)
@@ -7,10 +7,13 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
 #pragma implementation "textctrl.h"
 #endif
 
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
 #include "wx/textctrl.h"
 #include "wx/utils.h"
 #include "wx/intl.h"
@@ -65,28 +68,16 @@ static void wxGtkTextInsert(GtkWidget *text,
                         ? attr.GetBackgroundColour().GetColor()
                         : NULL;
 
-    GtkTextIter start, end;
-    GtkTextMark *mark;
-    // iterators are invalidated by any mutation that affects 'indexable' buffer contents,
-    // so we save current position in a mark
-    // we need a mark of left gravity, so we cannot use
-    // mark = gtk_text_buffer_get_insert (text_buffer)
-
-    gtk_text_buffer_get_iter_at_mark( text_buffer, &start,
-                                     gtk_text_buffer_get_insert (text_buffer) );
-    mark = gtk_text_buffer_create_mark( text_buffer, NULL, &start, TRUE/*left gravity*/ );
-
-    gtk_text_buffer_insert_at_cursor( text_buffer, buffer, strlen(buffer) );
-
-    gtk_text_buffer_get_iter_at_mark( text_buffer, &end,
-                                     gtk_text_buffer_get_insert (text_buffer) );
-    gtk_text_buffer_get_iter_at_mark( text_buffer, &start, mark );
-
     GtkTextTag *tag;
     tag = gtk_text_buffer_create_tag( text_buffer, NULL, "font-desc", font_description,
                                      "foreground-gdk", colFg,
                                      "background-gdk", colBg, NULL );
-    gtk_text_buffer_apply_tag( text_buffer, tag, &start, &end );
+
+    GtkTextIter iter;
+    gtk_text_buffer_get_iter_at_mark( text_buffer, &iter,
+                                     gtk_text_buffer_get_insert (text_buffer) );
+
+    gtk_text_buffer_insert_with_tags( text_buffer, &iter, buffer, strlen(buffer), tag, NULL );
 }
 #else
 static void wxGtkTextInsert(GtkWidget *text,