X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e808cf8a0a77ced81143e9b27283a3b2a907a747..f1e3914fde06186edb75b2948418aeea9914a075:/src/gtk/textctrl.cpp diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index 79cdce6465..cf14bf7797 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -544,9 +544,10 @@ END_EVENT_TABLE() void wxTextCtrl::Init() { m_dontMarkDirty = - m_ignoreNextUpdate = m_modified = false; + m_countUpdatesToIgnore = 0; + SetUpdateFont(false); m_text = NULL; @@ -820,7 +821,15 @@ wxFontEncoding wxTextCtrl::GetTextEncoding() const 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") ); @@ -842,8 +851,20 @@ void wxTextCtrl::SetValue( const wxString &value ) 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) ); } @@ -851,9 +872,19 @@ void wxTextCtrl::SetValue( const wxString &value ) { // 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) ); } @@ -1178,9 +1209,9 @@ void wxTextCtrl::DiscardEdits() bool wxTextCtrl::IgnoreTextUpdate() { - if ( m_ignoreNextUpdate ) + if ( m_countUpdatesToIgnore > 0 ) { - m_ignoreNextUpdate = false; + m_countUpdatesToIgnore--; return true; }