small code simplification in DoSetValue() after the last change
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41748 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -840,8 +840,6 @@ void wxTextCtrl::DoSetValue( const wxString &value, int flags )
|
|||||||
m_modified = false;
|
m_modified = false;
|
||||||
DontMarkDirtyOnNextChange();
|
DontMarkDirtyOnNextChange();
|
||||||
|
|
||||||
if ( IsMultiLine() )
|
|
||||||
{
|
|
||||||
const wxCharBuffer buffer(wxGTK_CONV_ENC(value, GetTextEncoding()));
|
const wxCharBuffer buffer(wxGTK_CONV_ENC(value, GetTextEncoding()));
|
||||||
if ( !buffer )
|
if ( !buffer )
|
||||||
{
|
{
|
||||||
@@ -851,42 +849,22 @@ void wxTextCtrl::DoSetValue( const wxString &value, int flags )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if the control is not empty, two "changed" signals are emitted,
|
||||||
|
// otherwise only one and we need to ignore either both or one of them
|
||||||
|
int ignore = flags & SetValue_SendEvent ? 0 : 1;
|
||||||
|
if ( !IsEmpty() )
|
||||||
|
ignore++;
|
||||||
|
|
||||||
// if the control is not empty, two "changed" signals are emitted
|
if ( ignore )
|
||||||
if ( flags & SetValue_SendEvent )
|
IgnoreNextTextUpdate(ignore);
|
||||||
{
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if ( IsMultiLine() )
|
||||||
|
{
|
||||||
gtk_text_buffer_set_text( m_buffer, buffer, strlen(buffer) );
|
gtk_text_buffer_set_text( m_buffer, buffer, strlen(buffer) );
|
||||||
}
|
}
|
||||||
else // single line
|
else // single line
|
||||||
{
|
{
|
||||||
// gtk_entry_set_text() emits two "changed" signals if the control is
|
gtk_entry_set_text( GTK_ENTRY(m_text), buffer );
|
||||||
// not empty because internally it calls gtk_editable_delete_text() and
|
|
||||||
// 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) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GRG, Jun/2000: Changed this after a lot of discussion in
|
// GRG, Jun/2000: Changed this after a lot of discussion in
|
||||||
|
Reference in New Issue
Block a user