/////////////////////////////////////////////////////////////////////////////
-// Name: textctrl.cpp
+// Name: src/gtk1/textctrl.cpp
// Purpose:
// Author: Robert Roebling
// Id: $Id$
#include "wx/wxprec.h"
#include "wx/textctrl.h"
-#include "wx/utils.h"
-#include "wx/intl.h"
-#include "wx/log.h"
-#include "wx/math.h"
-#include "wx/settings.h"
-#include "wx/panel.h"
+
+#ifndef WX_PRECOMP
+ #include "wx/intl.h"
+ #include "wx/log.h"
+ #include "wx/utils.h"
+ #include "wx/panel.h"
+ #include "wx/settings.h"
+ #include "wx/math.h"
+#endif
+
#include "wx/strconv.h"
#include "wx/fontutil.h" // for wxNativeFontInfo (GetNativeFontInfo())
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
-#include "wx/math.h"
#include "wx/gtk1/private.h"
#include <gdk/gdkkeysyms.h>
// wxTextCtrl
//-----------------------------------------------------------------------------
-IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl,wxControl)
+IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxTextCtrlBase)
-BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
+BEGIN_EVENT_TABLE(wxTextCtrl, wxTextCtrlBase)
EVT_CHAR(wxTextCtrl::OnChar)
EVT_MENU(wxID_CUT, wxTextCtrl::OnCut)
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 );
+ gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.length(), &tmp );
#endif
if (multi_line)
return tmp;
}
-void wxTextCtrl::SetValue( const wxString &value )
+void wxTextCtrl::DoSetValue( const wxString &value, int flags )
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
+ if ( !(flags & SetValue_SendEvent) )
+ {
+ // do not generate events
+ IgnoreNextTextUpdate();
+ }
+
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), value.mbc_str(), value.Length(), &len );
+ gtk_editable_insert_text( GTK_EDITABLE(m_text), value.mbc_str(), value.length(), &len );
}
else
{
// resetting the style and appending some more text wouldn't work: if
// we don't specify the style explicitly, the old style would be used
gtk_editable_delete_selection( GTK_EDITABLE(m_text) );
- wxGtkTextInsert(m_text, m_defaultStyle, text.c_str(), text.Len());
+ wxGtkTextInsert(m_text, m_defaultStyle, text.c_str(), text.length());
// we called wxGtkTextInsert with correct font, no need to do anything
// in UpdateFontIfNeeded() any longer
// This moves the cursor pos to behind the inserted text.
gint len = GET_EDITABLE_POS(m_text);
- gtk_editable_insert_text( GTK_EDITABLE(m_text), text.c_str(), text.Len(), &len );
+ gtk_editable_insert_text( GTK_EDITABLE(m_text), text.c_str(), text.length(), &len );
// Bring entry's cursor uptodate.
gtk_entry_set_position( GTK_ENTRY(m_text), len );
wxString text = GetValue();
// cast to prevent warning. But pos really should've been unsigned.
- if( (unsigned long)pos > text.Len() )
+ if( (unsigned long)pos > text.length() )
return false;
*x=0; // First Col
int wxTextCtrl::GetLineLength(long lineNo) const
{
wxString str = GetLineText (lineNo);
- return (int) str.Length();
+ return (int) str.length();
}
int wxTextCtrl::GetNumberOfLines() const
}
}
-bool wxTextCtrl::Enable( bool enable )
+void wxTextCtrl::DoEnable( bool enable )
{
- if (!wxWindowBase::Enable(enable))
- {
- // nothing to do
- return false;
- }
-
if (m_windowStyle & wxTE_MULTILINE)
{
gtk_text_set_editable( GTK_TEXT(m_text), enable );
- OnParentEnable(enable);
}
else
{
gtk_widget_set_sensitive( m_text, enable );
}
-
- return true;
}
// wxGTK-specific: called recursively by Enable,
// to give widgets an oppprtunity to correct their colours after they
// have been changed by Enable
-void wxTextCtrl::OnParentEnable( bool enable )
+void wxTextCtrl::OnEnabled( bool enable )
{
+ if ( IsSingleLine() )
+ return;
+
// If we have a custom background colour, we use this colour in both
// disabled and enabled mode, or we end up with a different colour under the
// text.
if (from == -1 && to == -1)
{
from = 0;
- to = GetValue().Length();
+ to = GetValue().length();
}
if ( (m_windowStyle & wxTE_MULTILINE) &&
wxWX2MBbuf buf = value.mbc_str();
gtk_editable_insert_text( GTK_EDITABLE(m_text), buf, strlen(buf), &pos );
#else
- gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.Length(), &pos );
+ gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.length(), &pos );
#endif // wxUSE_UNICODE
}
}
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
- if ((key_event.GetKeyCode() == WXK_RETURN) && (m_windowStyle & wxPROCESS_ENTER))
+ if ((key_event.GetKeyCode() == WXK_RETURN) && (m_windowStyle & wxTE_PROCESS_ENTER))
{
wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
event.SetEventObject(this);