+ wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
+
+ wxString tmp = "";
+ if (!value.IsNull()) tmp = value;
+ if (m_windowStyle & wxTE_MULTILINE)
+ {
+ gint len = gtk_text_get_length( GTK_TEXT(m_text) );
+ gtk_editable_delete_text( GTK_EDITABLE(m_text), 0, len );
+ len = 0;
+ gtk_editable_insert_text( GTK_EDITABLE(m_text), tmp, tmp.Length(), &len );
+ }
+ else
+ {
+ gtk_entry_set_text( GTK_ENTRY(m_text), tmp );
+ }
+}
+
+void wxTextCtrl::WriteText( const wxString &text )
+{
+ wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
+
+ if (text.IsNull()) return;
+
+ if (m_windowStyle & wxTE_MULTILINE)
+ {
+ /* this moves the cursor pos to behind the inserted text */
+ gint len = GTK_EDITABLE(m_text)->current_pos;
+ gtk_editable_insert_text( GTK_EDITABLE(m_text), text, text.Length(), &len );
+
+ /* bring editable's cursor uptodate. bug in GTK. */
+ GTK_EDITABLE(m_text)->current_pos = gtk_text_get_point( GTK_TEXT(m_text) );
+ }
+ else
+ {
+ /* this moves the cursor pos to behind the inserted text */
+ gint len = GTK_EDITABLE(m_text)->current_pos;
+ gtk_editable_insert_text( GTK_EDITABLE(m_text), text, text.Length(), &len );
+
+ /* bring editable's cursor uptodate. bug in GTK. */
+ GTK_EDITABLE(m_text)->current_pos += text.Len();
+
+ /* bring entry's cursor uptodate. bug in GTK. */
+ gtk_entry_set_position( GTK_ENTRY(m_text), GTK_EDITABLE(m_text)->current_pos );
+ }
+}
+
+void wxTextCtrl::AppendText( const wxString &text )
+{
+ wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
+
+ if (m_windowStyle & wxTE_MULTILINE)
+ {
+ /* we'll insert at the last position */
+ gint len = gtk_text_get_length( GTK_TEXT(m_text) );
+ gtk_editable_insert_text( GTK_EDITABLE(m_text), text, text.Length(), &len );
+
+ /* bring editable's cursor uptodate. bug in GTK. */
+ GTK_EDITABLE(m_text)->current_pos = gtk_text_get_point( GTK_TEXT(m_text) );
+ }
+ else
+ {
+ gtk_entry_append_text( GTK_ENTRY(m_text), text );
+ }
+}
+
+bool wxTextCtrl::LoadFile( const wxString &file )
+{
+ wxCHECK_MSG( m_text != NULL, FALSE, "invalid text ctrl" );
+
+ if (!wxFileExists(file)) return FALSE;
+
+ Clear();
+
+ FILE *fp = (FILE*) NULL;
+ struct stat statb;
+
+ if ((stat ((char*) (const char*) file, &statb) == -1) || (statb.st_mode & S_IFMT) != S_IFREG ||
+ !(fp = fopen ((char*) (const char*) file, "r")))