IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl,wxControl)
void gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win )
-{
+{
win->m_modified = TRUE;
};
m_modified = FALSE;
};
-wxTextCtrl::wxTextCtrl( wxWindow *parent, const wxWindowID id, const wxString &value,
- const wxPoint &pos, const wxSize &size,
+wxTextCtrl::wxTextCtrl( wxWindow *parent, const wxWindowID id, const wxString &value,
+ const wxPoint &pos, const wxSize &size,
const int style, const wxString &name ) : streambuf()
{
m_modified = FALSE;
};
bool wxTextCtrl::Create( wxWindow *parent, const wxWindowID id, const wxString &value,
- const wxPoint &pos, const wxSize &size,
+ const wxPoint &pos, const wxSize &size,
const int style, const wxString &name )
{
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();
-
+
+ // we want to be notified about text changes
+ gtk_signal_connect(GTK_OBJECT(m_widget), "changed",
+ GTK_SIGNAL_FUNC(gtk_text_changed_callback),
+ (gpointer)this);
+
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 );
- else
- gtk_editable_insert_text( GTK_EDITABLE(m_widget), value, value.Length(), &tmp );
+ gtk_editable_insert_text( GTK_EDITABLE(m_widget), value, value.Length(), &tmp );
};
-
+
if (style & wxREADONLY)
{
}
{
if (style & wxTE_MULTILINE) gtk_text_set_editable( GTK_TEXT(m_widget), 1 );
};
-
+
Show( TRUE );
-
+
return TRUE;
};
if (m_windowStyle & wxTE_MULTILINE)
{
gint len = gtk_text_get_length( GTK_TEXT(m_widget) );
- tmp = gtk_editable_get_chars( GTK_EDITABLE(m_widget), 0, len-1 );
+ tmp = gtk_editable_get_chars( GTK_EDITABLE(m_widget), 0, len );
}
else
{
if (m_windowStyle & wxTE_MULTILINE)
{
gint len = gtk_text_get_length( GTK_TEXT(m_widget) );
- gtk_editable_delete_text( GTK_EDITABLE(m_widget), 0, len-1 );
+ gtk_editable_delete_text( GTK_EDITABLE(m_widget), 0, len );
len = 0;
gtk_editable_insert_text( GTK_EDITABLE(m_widget), tmp, tmp.Length(), &len );
}
void wxTextCtrl::WriteText( const wxString &text )
{
if (text.IsNull()) return;
-
+
if (m_windowStyle & wxTE_MULTILINE)
{
gint len = gtk_text_get_length( GTK_TEXT(m_widget) );
void wxTextCtrl::DiscardEdits(void)
{
+ m_modified = FALSE;
};
/*
wxError("Streambuf allocation failed","Internal error");
return EOF;
}
-
+
// Verify that there are no characters in get area
if ( gptr() && gptr() < egptr() )
{
IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl,wxControl)
void gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win )
-{
+{
win->m_modified = TRUE;
};
m_modified = FALSE;
};
-wxTextCtrl::wxTextCtrl( wxWindow *parent, const wxWindowID id, const wxString &value,
- const wxPoint &pos, const wxSize &size,
+wxTextCtrl::wxTextCtrl( wxWindow *parent, const wxWindowID id, const wxString &value,
+ const wxPoint &pos, const wxSize &size,
const int style, const wxString &name ) : streambuf()
{
m_modified = FALSE;
};
bool wxTextCtrl::Create( wxWindow *parent, const wxWindowID id, const wxString &value,
- const wxPoint &pos, const wxSize &size,
+ const wxPoint &pos, const wxSize &size,
const int style, const wxString &name )
{
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();
-
+
+ // we want to be notified about text changes
+ gtk_signal_connect(GTK_OBJECT(m_widget), "changed",
+ GTK_SIGNAL_FUNC(gtk_text_changed_callback),
+ (gpointer)this);
+
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 );
- else
- gtk_editable_insert_text( GTK_EDITABLE(m_widget), value, value.Length(), &tmp );
+ gtk_editable_insert_text( GTK_EDITABLE(m_widget), value, value.Length(), &tmp );
};
-
+
if (style & wxREADONLY)
{
}
{
if (style & wxTE_MULTILINE) gtk_text_set_editable( GTK_TEXT(m_widget), 1 );
};
-
+
Show( TRUE );
-
+
return TRUE;
};
if (m_windowStyle & wxTE_MULTILINE)
{
gint len = gtk_text_get_length( GTK_TEXT(m_widget) );
- tmp = gtk_editable_get_chars( GTK_EDITABLE(m_widget), 0, len-1 );
+ tmp = gtk_editable_get_chars( GTK_EDITABLE(m_widget), 0, len );
}
else
{
if (m_windowStyle & wxTE_MULTILINE)
{
gint len = gtk_text_get_length( GTK_TEXT(m_widget) );
- gtk_editable_delete_text( GTK_EDITABLE(m_widget), 0, len-1 );
+ gtk_editable_delete_text( GTK_EDITABLE(m_widget), 0, len );
len = 0;
gtk_editable_insert_text( GTK_EDITABLE(m_widget), tmp, tmp.Length(), &len );
}
void wxTextCtrl::WriteText( const wxString &text )
{
if (text.IsNull()) return;
-
+
if (m_windowStyle & wxTE_MULTILINE)
{
gint len = gtk_text_get_length( GTK_TEXT(m_widget) );
void wxTextCtrl::DiscardEdits(void)
{
+ m_modified = FALSE;
};
/*
wxError("Streambuf allocation failed","Internal error");
return EOF;
}
-
+
// Verify that there are no characters in get area
if ( gptr() && gptr() < egptr() )
{