-  if ((key_event.KeyCode() == WXK_RETURN) && (m_windowStyle & wxPROCESS_ENTER))
-  {
-    wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
-    event.SetEventObject(this);
-    if (GetEventHandler()->ProcessEvent(event)) return;
-  }
-  else if (key_event.KeyCode() == WXK_TAB) 
-  {
-    wxNavigationKeyEvent event;
-    event.SetDirection( key_event.m_shiftDown );
-    event.SetWindowChange(FALSE);
-    event.SetEventObject(this);
+    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);
+    }
+}
+
+// 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 );