+    wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
+
+    Remove( from, to );
+
+    if (!value.empty())
+    {
+        gint pos = (gint)from;
+#if wxUSE_UNICODE
+        wxWX2MBbuf buf = value.mbc_str();
+        gtk_editable_insert_text( GTK_EDITABLE(m_text), buf, strlen(buf), &pos );
+#else
+        gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.length(), &pos );
+#endif // wxUSE_UNICODE
+    }
+}
+
+void wxTextCtrl::Cut()
+{
+    wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
+    gtk_editable_cut_clipboard(GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG);
+}
+
+void wxTextCtrl::Copy()
+{
+    wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
+    gtk_editable_copy_clipboard(GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG);
+}
+
+void wxTextCtrl::Paste()
+{
+    wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
+    gtk_editable_paste_clipboard(GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG);
+}
+
+// Undo/redo
+void wxTextCtrl::Undo()
+{
+    // TODO
+    wxFAIL_MSG( wxT("wxTextCtrl::Undo not implemented") );
+}
+
+void wxTextCtrl::Redo()
+{
+    // TODO
+    wxFAIL_MSG( wxT("wxTextCtrl::Redo not implemented") );
+}
+
+bool wxTextCtrl::CanUndo() const
+{
+    // TODO
+    //wxFAIL_MSG( wxT("wxTextCtrl::CanUndo not implemented") );
+    return false;
+}
+
+bool wxTextCtrl::CanRedo() const
+{
+    // TODO
+    //wxFAIL_MSG( wxT("wxTextCtrl::CanRedo not implemented") );
+    return false;
+}
+
+// If the return values from and to are the same, there is no
+// selection.
+void wxTextCtrl::GetSelection(long* fromOut, long* toOut) const
+{
+    wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
+
+    gint from = -1;
+    gint to = -1;
+    bool haveSelection = false;
+
+     if ( (GTK_EDITABLE(m_text)->has_selection) )
+     {
+         haveSelection = true;
+         from = (long) GTK_EDITABLE(m_text)->selection_start_pos;
+         to = (long) GTK_EDITABLE(m_text)->selection_end_pos;
+     }
+
+     if (! haveSelection )
+          from = to = GetInsertionPoint();
+
+     if ( from > to )
+     {
+         // exchange them to be compatible with wxMSW
+         gint tmp = from;
+         from = to;
+         to = tmp;
+     }
+
+    if ( fromOut )
+        *fromOut = from;
+    if ( toOut )
+        *toOut = to;
+}
+
+
+bool wxTextCtrl::IsEditable() const
+{
+    wxCHECK_MSG( m_text != NULL, false, wxT("invalid text ctrl") );
+    return GTK_EDITABLE(m_text)->editable;
+}
+
+bool wxTextCtrl::IsModified() const
+{
+    return m_modified;
+}
+
+void wxTextCtrl::Clear()
+{
+    SetValue( wxEmptyString );
+}
+
+void wxTextCtrl::OnChar( wxKeyEvent &key_event )
+{
+    wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
+
+    if ((key_event.GetKeyCode() == WXK_RETURN) && (m_windowStyle & wxTE_PROCESS_ENTER))
+    {
+        wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
+        event.SetEventObject(this);
+        event.SetString(GetValue());
+        if (GetEventHandler()->ProcessEvent(event)) return;
+    }
+
+    if ((key_event.GetKeyCode() == WXK_RETURN) && !(m_windowStyle & wxTE_MULTILINE))
+    {
+        // This will invoke the dialog default action, such
+        // as the clicking the default button.
+
+        wxWindow *top_frame = m_parent;
+        while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
+            top_frame = top_frame->GetParent();
+
+        if (top_frame && GTK_IS_WINDOW(top_frame->m_widget))
+        {
+            GtkWindow *window = GTK_WINDOW(top_frame->m_widget);
+
+            if (window->default_widget)
+            {
+                gtk_widget_activate (window->default_widget);
+                return;
+            }
+        }
+    }
+
+    key_event.Skip();
+}
+
+GtkWidget* wxTextCtrl::GetConnectWidget()
+{
+    return GTK_WIDGET(m_text);
+}
+
+bool wxTextCtrl::IsOwnGtkWindow( GdkWindow *window )
+{
+    if (m_windowStyle & wxTE_MULTILINE)
+    {
+        return (window == GTK_TEXT(m_text)->text_area);
+    }
+    else
+    {
+        return (window == GTK_ENTRY(m_text)->text_area);
+    }
+}