- gtk_widget_show( vscrollbar );
- }
- else
- {
- // a single-line text control: no need for scrollbars
- m_widget =
- m_text = gtk_entry_new();
- }
-
- wxSize newSize = size;
- if (newSize.x == -1) newSize.x = 80;
- if (newSize.y == -1) newSize.y = 26;
- SetSize( newSize.x, newSize.y );
-
- PostCreation();
-
- if (bMultiLine)
- {
- gtk_widget_realize(m_text);
- gtk_widget_show(m_text);
- }
-
- // we want to be notified about text changes
- gtk_signal_connect(GTK_OBJECT(m_text), "changed",
- GTK_SIGNAL_FUNC(gtk_text_changed_callback),
- (gpointer)this);
-
- if (!value.IsNull())
- {
- gint tmp = 0;
- gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.Length(), &tmp );
- }
-
- if (style & wxTE_READONLY)
- {
- }
- else
- {
- if (bMultiLine)
- gtk_text_set_editable( GTK_TEXT(m_text), 1 );
- }
-
- Show( TRUE );
-
- return TRUE;
-}
-
-wxString wxTextCtrl::GetValue(void) const
-{
- wxString tmp;
- if (m_windowStyle & wxTE_MULTILINE)
- {
- gint len = gtk_text_get_length( GTK_TEXT(m_text) );
- tmp = gtk_editable_get_chars( GTK_EDITABLE(m_text), 0, len );
- }
- else
- {
- tmp = gtk_entry_get_text( GTK_ENTRY(m_text) );
- }
- return tmp;
+#endif
+ }
+ else
+ {
+ // a single-line text control: no need for scrollbars
+ m_widget =
+ m_text = gtk_entry_new();
+ }
+
+ m_parent->DoAddChild( this );
+
+ m_focusWidget = m_text;
+
+ PostCreation();
+
+ SetFont( parent->GetFont() );
+
+ wxSize size_best( DoGetBestSize() );
+ wxSize new_size( size );
+ if (new_size.x == -1)
+ new_size.x = size_best.x;
+ if (new_size.y == -1)
+ new_size.y = size_best.y;
+ if ((new_size.x != size.x) || (new_size.y != size.y))
+ SetSize( new_size.x, new_size.y );
+
+ if (multi_line)
+ gtk_widget_show(m_text);
+
+#ifndef __WXGTK20__
+ if (multi_line)
+ {
+ gtk_signal_connect(GTK_OBJECT(GTK_TEXT(m_text)->vadj), "changed",
+ (GtkSignalFunc) gtk_scrollbar_changed_callback, (gpointer) this );
+
+ // only initialize gs_gtk_text_draw once, starting from the next the
+ // klass::draw will already be wxgtk_text_draw
+ if ( !gs_gtk_text_draw )
+ {
+ GtkDrawCallback&
+ draw = GTK_WIDGET_CLASS(GTK_OBJECT(m_text)->klass)->draw;
+
+ gs_gtk_text_draw = draw;
+
+ draw = wxgtk_text_draw;
+ }
+ }
+#endif // GTK+ 1.x
+
+ if (!value.IsEmpty())
+ {
+#ifdef __WXGTK20__
+ SetValue( value );
+#else
+
+#if !GTK_CHECK_VERSION(1, 2, 0)
+ // if we don't realize it, GTK 1.0.6 dies with a SIGSEGV in
+ // gtk_editable_insert_text()
+ gtk_widget_realize(m_text);
+#endif // GTK 1.0
+
+ gint tmp = 0;
+#if wxUSE_UNICODE
+ wxWX2MBbuf val = value.mbc_str();
+ gtk_editable_insert_text( GTK_EDITABLE(m_text), val, strlen(val), &tmp );
+#else
+ gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.Length(), &tmp );
+#endif
+
+ if (multi_line)
+ {
+ // Bring editable's cursor uptodate. Bug in GTK.
+ SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) ));
+ }
+
+#endif
+ }
+
+ if (style & wxTE_PASSWORD)
+ {
+ if (!multi_line)
+ gtk_entry_set_visibility( GTK_ENTRY(m_text), FALSE );
+ }
+
+ if (style & wxTE_READONLY)
+ {
+ if (!multi_line)
+ gtk_entry_set_editable( GTK_ENTRY(m_text), FALSE );
+#ifdef __WXGTK20__
+ else
+ gtk_text_view_set_editable( GTK_TEXT_VIEW( m_text), FALSE);
+ }
+#else
+ }
+ else
+ {
+ if (multi_line)
+ gtk_text_set_editable( GTK_TEXT(m_text), 1 );
+ }
+#endif
+
+ // We want to be notified about text changes.
+#ifdef __WXGTK20__
+ if (multi_line)
+ {
+ g_signal_connect( G_OBJECT(buffer), "changed",
+ GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
+ }
+ else
+#endif
+ {
+ gtk_signal_connect( GTK_OBJECT(m_text), "changed",
+ GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
+ }
+
+ // we don't set a valid background colour, because the window
+ // manager should use a default one
+ m_backgroundColour = wxColour();
+
+ wxColour colFg = parent->GetForegroundColour();
+ SetForegroundColour( colFg );
+
+ m_cursor = wxCursor( wxCURSOR_IBEAM );
+
+#ifndef __WXGTK20__
+ wxTextAttr attrDef( colFg, m_backgroundColour, parent->GetFont() );
+ SetDefaultStyle( attrDef );
+#endif
+
+ Show( TRUE );
+
+ return TRUE;