+
+void wxTextCtrl::OnInternalIdle()
+{
+ wxCursor cursor = m_cursor;
+ if (g_globalCursor.Ok()) cursor = g_globalCursor;
+
+ if (cursor.Ok())
+ {
+ GdkWindow *window = (GdkWindow*) NULL;
+ if (HasFlag(wxTE_MULTILINE))
+ window = GTK_TEXT(m_text)->text_area;
+ else
+ window = GTK_ENTRY(m_text)->text_area;
+
+ if (window)
+ gdk_window_set_cursor( window, cursor.GetCursor() );
+
+ if (!g_globalCursor.Ok())
+ cursor = *wxSTANDARD_CURSOR;
+
+ window = m_widget->window;
+ if ((window) && !(GTK_WIDGET_NO_WINDOW(m_widget)))
+ gdk_window_set_cursor( window, cursor.GetCursor() );
+ }
+
+ if (g_delayedFocus == this)
+ {
+ if (GTK_WIDGET_REALIZED(m_widget))
+ {
+ gtk_widget_grab_focus( m_widget );
+ g_delayedFocus = NULL;
+ }
+ }
+
+ if (wxUpdateUIEvent::CanUpdate(this))
+ UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
+}
+
+wxSize wxTextCtrl::DoGetBestSize() const
+{
+ // FIXME should be different for multi-line controls...
+ wxSize ret( wxControl::DoGetBestSize() );
+ wxSize best(80, ret.y);
+ CacheBestSize(best);
+ return best;
+}
+
+// ----------------------------------------------------------------------------
+// freeze/thaw
+// ----------------------------------------------------------------------------
+
+void wxTextCtrl::DoFreeze()
+{
+ if ( HasFlag(wxTE_MULTILINE) )
+ {
+ gtk_text_freeze(GTK_TEXT(m_text));
+ }
+}
+
+void wxTextCtrl::DoThaw()
+{
+ if ( HasFlag(wxTE_MULTILINE) )
+ {
+ GTK_TEXT(m_text)->vadj->value = 0.0;
+
+ gtk_text_thaw(GTK_TEXT(m_text));
+ }
+}
+
+// ----------------------------------------------------------------------------
+// scrolling
+// ----------------------------------------------------------------------------
+
+GtkAdjustment *wxTextCtrl::GetVAdj() const
+{
+ if ( !IsMultiLine() )
+ return NULL;
+
+ return GTK_TEXT(m_text)->vadj;
+}
+
+bool wxTextCtrl::DoScroll(GtkAdjustment *adj, int diff)
+{
+ float value = adj->value + diff;
+
+ if ( value < 0 )
+ value = 0;
+
+ float upper = adj->upper - adj->page_size;
+ if ( value > upper )
+ value = upper;
+
+ // did we noticeably change the scroll position?
+ if ( fabs(adj->value - value) < 0.2 )
+ {
+ // well, this is what Robert does in wxScrollBar, so it must be good...
+ return false;
+ }
+
+ adj->value = value;
+ gtk_signal_emit_by_name(GTK_OBJECT(adj), "value_changed");
+
+ return true;
+}
+
+bool wxTextCtrl::ScrollLines(int lines)
+{
+ GtkAdjustment *adj = GetVAdj();
+ if ( !adj )
+ return false;
+
+ // this is hardcoded to 10 in GTK+ 1.2 (great idea)
+ int diff = 10*lines;
+
+ return DoScroll(adj, diff);
+}
+
+bool wxTextCtrl::ScrollPages(int pages)
+{
+ GtkAdjustment *adj = GetVAdj();
+ if ( !adj )
+ return false;
+
+ return DoScroll(adj, (int)ceil(pages*adj->page_increment));
+}
+
+
+// static
+wxVisualAttributes
+wxTextCtrl::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+ return GetDefaultAttributesFromGTKWidget(gtk_entry_new, true);
+}