Move SendTextUpdatedEvent() down to wxTextEntryBase from wxTextCtrlBase.

This will allow reusing it in wxComboBox implementation as well.

Also add SendTextUpdatedEventIfAllowed() which can be used to only send the
events if they were not blocked at wxTextEntry level.

No real changes otherwise.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63880 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2010-04-06 18:46:24 +00:00
parent ca1f7cb563
commit 501358073b
6 changed files with 50 additions and 37 deletions

View File

@@ -158,6 +158,16 @@ public:
wxPoint GetMargins() const
{ return DoGetMargins(); }
// events
// ------
// generate the wxEVT_COMMAND_TEXT_UPDATED event for GetEditableWindow(),
// like SetValue() does and return true if the event was processed
//
// NB: this is public for wxRichTextCtrl use only right now, do not call it
static bool SendTextUpdatedEvent(wxWindow *win);
protected:
// flags for DoSetValue(): common part of SetValue() and ChangeValue() and
// also used to implement WriteText() in wxMSW
@@ -207,8 +217,19 @@ protected:
friend class EventsSuppressor;
// return true if the events are currently not suppressed
bool EventsAllowed() const { return m_eventsBlock == 0; }
// generate the wxEVT_COMMAND_TEXT_UPDATED event for this window
bool SendTextUpdatedEvent()
{
return SendTextUpdatedEvent(GetEditableWindow());
}
// generate the wxEVT_COMMAND_TEXT_UPDATED event for this window if the
// events are not currently disabled
void SendTextUpdatedEventIfAllowed()
{
if ( EventsAllowed() )
SendTextUpdatedEvent();
}
private:
// suppress or resume the text changed events generation: don't use these
@@ -233,6 +254,10 @@ private:
// initially the generation of the events is enabled
virtual void EnableTextChangedEvents(bool WXUNUSED(enable)) { }
// return true if the events are currently not suppressed
bool EventsAllowed() const { return m_eventsBlock == 0; }
// if this counter is non-null, events are blocked
unsigned m_eventsBlock;