- m_needParent = TRUE;
-
- PreCreation( parent, id, pos, size, style, name );
-
- if (style & wxTE_MULTILINE)
- m_widget = gtk_text_new( NULL, NULL );
- else
- m_widget = 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 (!value.IsNull())
- {
- gint tmp = 0;
-
- // Don't know why this is so
- if (style & wxTE_MULTILINE)
- gtk_editable_insert_text( GTK_EDITABLE(m_widget), value, value.Length()+1, &tmp );
+ if (allocate()) setp(base(),ebuf());
+
+ m_modified = FALSE;
+ Create( parent, id, value, pos, size, style, validator, name );
+}
+#else
+wxTextCtrl::wxTextCtrl( wxWindow *parent, wxWindowID id, const wxString &value,
+ const wxPoint &pos, const wxSize &size,
+ int style, const wxValidator& validator, const wxString &name )
+{
+ m_modified = FALSE;
+ Create( parent, id, value, pos, size, style, validator, name );
+}
+#endif
+
+bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value,
+ const wxPoint &pos, const wxSize &size,
+ int style, const wxValidator& validator, const wxString &name )
+{
+ m_needParent = TRUE;
+ m_acceptsFocus = TRUE;
+
+ PreCreation( parent, id, pos, size, style, name );
+
+ SetValidator( validator );
+
+ m_vScrollbarVisible = TRUE;
+
+ bool multi_line = (style & wxTE_MULTILINE) != 0;
+ if ( multi_line )
+ {
+ // a multi-line edit control: create a vertical scrollbar by default and
+ // horizontal if requested
+ bool bHasHScrollbar = (style & wxHSCROLL) != 0;
+
+ // create our control...
+ m_text = gtk_text_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL );
+
+ // ... and put into the upper left hand corner of the table
+ m_widget = gtk_table_new(bHasHScrollbar ? 2 : 1, 2, FALSE);
+ GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
+
+ gtk_table_attach( GTK_TABLE(m_widget), m_text, 0, 1, 0, 1,
+ (GtkAttachOptions)(GTK_FILL | GTK_EXPAND | GTK_SHRINK),
+ (GtkAttachOptions)(GTK_FILL | GTK_EXPAND | GTK_SHRINK),
+ 0, 0);
+
+ // put the horizontal scrollbar in the lower left hand corner
+ if (bHasHScrollbar)
+ {
+ GtkWidget *hscrollbar = gtk_hscrollbar_new(GTK_TEXT(m_text)->hadj);
+ GTK_WIDGET_UNSET_FLAGS( hscrollbar, GTK_CAN_FOCUS );
+
+ gtk_table_attach(GTK_TABLE(m_widget), hscrollbar, 0, 1, 1, 2,
+ (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
+ GTK_FILL,
+ 0, 0);
+ gtk_widget_show(hscrollbar);
+ }
+
+ // finally, put the vertical scrollbar in the upper right corner
+ m_vScrollbar = gtk_vscrollbar_new( GTK_TEXT(m_text)->vadj );
+ GTK_WIDGET_UNSET_FLAGS( m_vScrollbar, GTK_CAN_FOCUS );
+
+ gtk_table_attach(GTK_TABLE(m_widget), m_vScrollbar, 1, 2, 0, 1,
+ GTK_FILL,
+ (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK),
+ 0, 0);
+ gtk_widget_show( m_vScrollbar );
+
+ gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
+ GTK_SIGNAL_FUNC(gtk_text_size_callback), (gpointer)this );
+ }