void wxTextCtrl::Init()
{
m_dontMarkDirty =
- m_ignoreNextUpdate =
m_modified = false;
+ m_countUpdatesToIgnore = 0;
+
SetUpdateFont(false);
m_text = NULL;
return enc;
}
-void wxTextCtrl::SetValue( const wxString &value )
+bool wxTextCtrl::IsEmpty() const
+{
+ if ( IsMultiLine() )
+ return gtk_text_buffer_get_char_count(m_buffer) != 0;
+
+ return wxTextCtrlBase::IsEmpty();
+}
+
+void wxTextCtrl::DoSetValue( const wxString &value, int flags )
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
return;
}
- if (gtk_text_buffer_get_char_count(m_buffer) != 0)
- IgnoreNextTextUpdate();
+
+ // if the control is not empty, two "changed" signals are emitted
+ if ( flags & SetValue_SendEvent )
+ {
+ if ( gtk_text_buffer_get_char_count(m_buffer) != 0 )
+ IgnoreNextTextUpdate();
+ }
+ else
+ {
+ if ( gtk_text_buffer_get_char_count(m_buffer) != 0 )
+ IgnoreNextTextUpdate(2);
+ else
+ IgnoreNextTextUpdate(1); // skip only one
+ }
gtk_text_buffer_set_text( m_buffer, buffer, strlen(buffer) );
}
{
// gtk_entry_set_text() emits two "changed" signals if the control is
// not empty because internally it calls gtk_editable_delete_text() and
- // gtk_editable_insert_text() but we want to have only one event
- if ( !GetValue().empty() )
- IgnoreNextTextUpdate();
+ // gtk_editable_insert_text()
+ if ( flags & SetValue_SendEvent )
+ {
+ if ( !GetValue().empty() )
+ IgnoreNextTextUpdate();
+ }
+ else
+ {
+ if ( !GetValue().empty() )
+ IgnoreNextTextUpdate(2);
+ else
+ IgnoreNextTextUpdate(1); // if we are empty, skip only one event
+ }
gtk_entry_set_text( GTK_ENTRY(m_text), wxGTK_CONV(value) );
}
bool wxTextCtrl::IgnoreTextUpdate()
{
- if ( m_ignoreNextUpdate )
+ if ( m_countUpdatesToIgnore > 0 )
{
- m_ignoreNextUpdate = false;
+ m_countUpdatesToIgnore--;
return true;
}