+    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 (HandleWindowEvent(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);
+    }
+}
+
+// the font will change for subsequent text insertiongs
+bool wxTextCtrl::SetFont( const wxFont &font )
+{
+    wxCHECK_MSG( m_text != NULL, false, wxT("invalid text ctrl") );
+
+    if ( !wxTextCtrlBase::SetFont(font) )
+    {
+        // font didn't change, nothing to do
+        return false;
+    }
+
+    if ( m_windowStyle & wxTE_MULTILINE )
+    {
+        SetUpdateFont(true);
+
+        m_defaultStyle.SetFont(font);
+
+        ChangeFontGlobally();
+    }
+
+    return true;
+}
+
+void wxTextCtrl::ChangeFontGlobally()
+{
+    // this method is very inefficient and hence should be called as rarely as
+    // possible!
+    wxASSERT_MSG( (m_windowStyle & wxTE_MULTILINE) && m_updateFont,
+
+                  _T("shouldn't be called for single line controls") );
+
+    wxString value = GetValue();
+    if ( !value.empty() )
+    {
+        SetUpdateFont(false);
+
+        Clear();
+        AppendText(value);
+    }
+}
+
+void wxTextCtrl::UpdateFontIfNeeded()
+{
+    if ( m_updateFont )
+        ChangeFontGlobally();
+}
+
+bool wxTextCtrl::SetForegroundColour(const wxColour& colour)
+{
+    if ( !wxControl::SetForegroundColour(colour) )
+        return false;
+
+    // update default fg colour too
+    m_defaultStyle.SetTextColour(colour);
+
+    return true;
+}
+
+bool wxTextCtrl::SetBackgroundColour( const wxColour &colour )
+{
+    wxCHECK_MSG( m_text != NULL, false, wxT("invalid text ctrl") );
+
+    if ( !wxControl::SetBackgroundColour( colour ) )
+        return false;
+
+    if (!m_widget->window)
+        return false;
+
+    if (!m_backgroundColour.Ok())
+        return false;
+
+    if (m_windowStyle & wxTE_MULTILINE)
+    {
+        GdkWindow *window = GTK_TEXT(m_text)->text_area;
+        if (!window)
+            return false;
+        m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
+        gdk_window_set_background( window, m_backgroundColour.GetColor() );
+        gdk_window_clear( window );
+    }
+
+    // change active background color too
+    m_defaultStyle.SetBackgroundColour( colour );
+
+    return true;
+}
+
+bool wxTextCtrl::SetStyle( long start, long end, const wxTextAttr& style )
+{
+    if ( m_windowStyle & wxTE_MULTILINE )
+    {
+        if ( style.IsDefault() )
+        {
+            // nothing to do
+            return true;
+        }
+
+        // VERY dirty way to do that - removes the required text and re-adds it
+        // with styling (FIXME)
+
+        gint l = gtk_text_get_length( GTK_TEXT(m_text) );
+
+        wxCHECK_MSG( start >= 0 && end <= l, false,
+                     _T("invalid range in wxTextCtrl::SetStyle") );
+
+        gint old_pos = gtk_editable_get_position( GTK_EDITABLE(m_text) );
+        char *text = gtk_editable_get_chars( GTK_EDITABLE(m_text), start, end );
+        wxString tmp(text,*wxConvCurrent);
+        g_free( text );
+
+        gtk_editable_delete_text( GTK_EDITABLE(m_text), start, end );
+        gtk_editable_set_position( GTK_EDITABLE(m_text), start );
+
+    #if wxUSE_UNICODE
+        wxWX2MBbuf buf = tmp.mbc_str();
+        const char *txt = buf;
+        size_t txtlen = strlen(buf);
+    #else
+        const char *txt = tmp;
+        size_t txtlen = tmp.length();
+    #endif
+
+        // use the attributes from style which are set in it and fall back
+        // first to the default style and then to the text control default
+        // colours for the others
+        wxGtkTextInsert(m_text,
+                        wxTextAttr::Combine(style, m_defaultStyle, this),
+                        txt,
+                        txtlen);
+
+        /* does not seem to help under GTK+ 1.2 !!!
+        gtk_editable_set_position( GTK_EDITABLE(m_text), old_pos ); */
+        SetInsertionPoint( old_pos );
+
+        return true;
+    }
+
+    // else single line
+    // cannot do this for GTK+'s Entry widget
+    return false;