virtual void OnParentEnable( bool enable ) ;
// tell the control to ignore next text changed signal
- void IgnoreNextTextUpdate();
+ void IgnoreNextTextUpdate() { m_ignoreNextUpdate = true; }
// should we ignore the changed signal? always resets the flag
bool IgnoreTextUpdate();
+ // call this to indicate that the control is about to be changed
+ // programmatically and so m_modified flag shouldn't be set
+ void DontMarkDirtyOnNextChange() { m_dontMarkDirty = true; }
+
+ // should we mark the control as dirty? always resets the flag
+ bool MarkDirtyOnChange();
+
+
static wxVisualAttributes
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
bool m_modified:1;
bool m_ignoreNextUpdate:1;
+ bool m_dontMarkDirty:1;
// Our text buffer. Convenient, and holds the buffer while using
// a dummy one when m_frozenness > 0
if (g_isIdle)
wxapp_install_idle_handler();
- win->MarkDirty();
+ if ( win->MarkDirtyOnChange() )
+ win->MarkDirty();
wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, win->GetId() );
event.SetEventObject( win );
void wxTextCtrl::Init()
{
+ m_dontMarkDirty =
m_ignoreNextUpdate =
m_modified = false;
+
SetUpdateFont(false);
+
m_text = NULL;
m_frozenness = 0;
m_gdkHandCursor = NULL;
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
+ // the control won't be modified any more as we programmatically replace
+ // all the existing text, so reset the flag and don't set it again (and do
+ // it now, before the text event handler is ran so that IsModified() called
+ // from there returns the expected value)
+ m_modified = false;
+ DontMarkDirtyOnNextChange();
+
if (m_windowStyle & wxTE_MULTILINE)
{
const wxCharBuffer buffer(wxGTK_CONV(value));
// the lists. wxWidgets 2.2 will have a set of flags to
// customize this behaviour.
SetInsertionPoint(0);
-
- m_modified = false;
}
void wxTextCtrl::WriteText( const wxString &text )
return;
}
- // gtk_text_changed_callback() will set m_modified to true but m_modified
- // shouldn't be changed by the program writing to the text control itself,
- // so save the old value and restore when we're done
- bool oldModified = m_modified;
+ // we're changing the text programmatically
+ DontMarkDirtyOnNextChange();
if ( m_windowStyle & wxTE_MULTILINE )
{
// Bring entry's cursor uptodate.
gtk_editable_set_position( GTK_EDITABLE(m_text), len );
}
-
- m_modified = oldModified;
}
void wxTextCtrl::AppendText( const wxString &text )
// max text length support
// ----------------------------------------------------------------------------
-void wxTextCtrl::IgnoreNextTextUpdate()
-{
- m_ignoreNextUpdate = true;
-}
-
bool wxTextCtrl::IgnoreTextUpdate()
{
if ( m_ignoreNextUpdate )
return false;
}
+bool wxTextCtrl::MarkDirtyOnChange()
+{
+ if ( m_dontMarkDirty )
+ {
+ m_dontMarkDirty = false;
+
+ return false;
+ }
+
+ return true;
+}
+
void wxTextCtrl::SetMaxLength(unsigned long len)
{
if ( !HasFlag(wxTE_MULTILINE) )