+extern wxCursor g_globalCursor;
+extern wxWindowGTK *g_delayedFocus;
+
+// ----------------------------------------------------------------------------
+// helpers
+// ----------------------------------------------------------------------------
+
+extern "C" {
+static void wxGtkTextInsert(GtkWidget *text,
+ const wxTextAttr& attr,
+ const char *txt,
+ size_t len)
+{
+ wxFont tmpFont;
+ GdkFont *font;
+ if (attr.HasFont())
+ {
+ tmpFont = attr.GetFont();
+
+ // FIXME: if this crashes because tmpFont goes out of scope and the GdkFont is
+ // deleted, then we need to call gdk_font_ref on font.
+ // This is because attr.GetFont() now returns a temporary font since wxTextAttr
+ // no longer stores a wxFont object, for efficiency.
+
+ font = tmpFont.GetInternalFont();
+ }
+ else
+ font = NULL;
+
+ GdkColor *colFg = attr.HasTextColour() ? attr.GetTextColour().GetColor()
+ : NULL;
+
+ GdkColor *colBg = attr.HasBackgroundColour()
+ ? attr.GetBackgroundColour().GetColor()
+ : NULL;
+
+ gtk_text_insert( GTK_TEXT(text), font, colFg, colBg, txt, len );
+}
+}
+
+// ----------------------------------------------------------------------------
+// "insert_text" for GtkEntry
+// ----------------------------------------------------------------------------
+
+extern "C" {
+static void
+gtk_insert_text_callback(GtkEditable *editable,
+ const gchar *WXUNUSED(new_text),
+ gint WXUNUSED(new_text_length),
+ gint *WXUNUSED(position),
+ wxTextCtrl *win)
+{
+ if (g_isIdle)
+ wxapp_install_idle_handler();
+
+ // we should only be called if we have a max len limit at all
+ GtkEntry *entry = GTK_ENTRY (editable);
+
+ wxCHECK_RET( entry->text_max_length, wxT("shouldn't be called") );
+
+ // check that we don't overflow the max length limit
+ //
+ // FIXME: this doesn't work when we paste a string which is going to be
+ // truncated
+ if ( entry->text_length == entry->text_max_length )
+ {
+ // we don't need to run the base class version at all
+ gtk_signal_emit_stop_by_name(GTK_OBJECT(editable), "insert_text");
+
+ // remember that the next changed signal is to be ignored to avoid
+ // generating a dummy wxEVT_COMMAND_TEXT_UPDATED event
+ win->IgnoreNextTextUpdate();
+
+ // and generate the correct one ourselves
+ wxCommandEvent event(wxEVT_COMMAND_TEXT_MAXLEN, win->GetId());
+ event.SetEventObject(win);
+ event.SetString(win->GetValue());
+ win->HandleWindowEvent( event );
+ }
+}
+}