Add a flag to wxUpdateUIEvent to tell if the item supports the check action
Not all items support check being set in an UpdateUIEvent handler, so it is nice to provide an API to find out if the item supports it. Fixes #13369
This commit is contained in:
@@ -2891,10 +2891,12 @@ public:
|
||||
m_setEnabled =
|
||||
m_setShown =
|
||||
m_setText =
|
||||
m_setChecked = false;
|
||||
m_setChecked =
|
||||
m_isCheckable = false;
|
||||
}
|
||||
wxUpdateUIEvent(const wxUpdateUIEvent& event)
|
||||
: wxCommandEvent(event),
|
||||
m_isCheckable(event.m_isCheckable),
|
||||
m_checked(event.m_checked),
|
||||
m_enabled(event.m_enabled),
|
||||
m_shown(event.m_shown),
|
||||
@@ -2919,6 +2921,10 @@ public:
|
||||
void Show(bool show) { m_shown = show; m_setShown = true; }
|
||||
void SetText(const wxString& text) { m_text = text; m_setText = true; }
|
||||
|
||||
// Set a flag saying if the object being updated supports the check action
|
||||
bool IsCheckable() const { return m_isCheckable; }
|
||||
void SetIsCheckable(bool aCheckable) { m_isCheckable = aCheckable; }
|
||||
|
||||
// Sets the interval between updates in milliseconds.
|
||||
// Set to -1 to disable updates, or to 0 to update as frequently as possible.
|
||||
static void SetUpdateInterval(long updateInterval) { sm_updateInterval = updateInterval; }
|
||||
@@ -2944,6 +2950,7 @@ public:
|
||||
virtual wxEvent *Clone() const wxOVERRIDE { return new wxUpdateUIEvent(*this); }
|
||||
|
||||
protected:
|
||||
bool m_isCheckable;
|
||||
bool m_checked;
|
||||
bool m_enabled;
|
||||
bool m_shown;
|
||||
|
@@ -2374,6 +2374,13 @@ public:
|
||||
*/
|
||||
bool GetEnabled() const;
|
||||
|
||||
/**
|
||||
Returns @true if the UI element can be checked.
|
||||
|
||||
@since 3.1.5
|
||||
*/
|
||||
bool IsCheckable() const;
|
||||
|
||||
/**
|
||||
Static function returning a value specifying how wxWidgets will send update
|
||||
events: to all windows, or only to those which specify that they will process
|
||||
|
@@ -2200,6 +2200,9 @@ void wxAuiToolBar::DoIdleUpdate()
|
||||
wxUpdateUIEvent evt(item.m_toolId);
|
||||
evt.SetEventObject(this);
|
||||
|
||||
if ( item.m_kind == wxITEM_CHECK || item.m_kind == wxITEM_RADIO )
|
||||
evt.SetIsCheckable(true);
|
||||
|
||||
if (handler->ProcessEvent(evt))
|
||||
{
|
||||
if (evt.GetSetEnabled())
|
||||
|
@@ -616,6 +616,7 @@ void wxMenuBase::UpdateUI(wxEvtHandler* source)
|
||||
wxWindowID itemid = item->GetId();
|
||||
wxUpdateUIEvent event(itemid);
|
||||
event.SetEventObject( this );
|
||||
event.SetIsCheckable(item->IsCheckable());
|
||||
|
||||
if ( source->ProcessEvent(event) )
|
||||
{
|
||||
|
@@ -738,6 +738,7 @@ void wxToolBarBase::UpdateWindowUI(long flags)
|
||||
|
||||
wxUpdateUIEvent event(toolid);
|
||||
event.SetEventObject(this);
|
||||
event.SetIsCheckable(tool->CanBeToggled());
|
||||
|
||||
if ( evtHandler->ProcessEvent(event) )
|
||||
{
|
||||
|
@@ -2817,6 +2817,7 @@ void wxWindowBase::UpdateWindowUI(long flags)
|
||||
{
|
||||
wxUpdateUIEvent event(GetId());
|
||||
event.SetEventObject(this);
|
||||
event.SetIsCheckable(true);
|
||||
|
||||
if ( GetEventHandler()->ProcessEvent(event) )
|
||||
{
|
||||
|
@@ -324,6 +324,11 @@ bool wxMenu::HandleCommandUpdateStatus( wxMenuItem* item, wxWindow* senderWindow
|
||||
wxUpdateUIEvent event(menuid);
|
||||
event.SetEventObject( this );
|
||||
|
||||
if ( item )
|
||||
event.SetIsCheckable(item->IsCheckable());
|
||||
else
|
||||
event.SetIsCheckable(true);
|
||||
|
||||
bool processed = DoProcessEvent(this, event, GetWindow());
|
||||
|
||||
if ( !processed && senderWindow != NULL)
|
||||
|
@@ -905,6 +905,7 @@ void wxRibbonButtonBar::UpdateWindowUI(long flags)
|
||||
|
||||
wxUpdateUIEvent event(id);
|
||||
event.SetEventObject(this);
|
||||
event.SetIsCheckable(true);
|
||||
|
||||
if ( ProcessWindowEvent(event) )
|
||||
{
|
||||
|
@@ -1178,6 +1178,7 @@ void wxRibbonToolBar::UpdateWindowUI(long flags)
|
||||
|
||||
wxUpdateUIEvent event(id);
|
||||
event.SetEventObject(this);
|
||||
event.SetIsCheckable(true);
|
||||
|
||||
if ( ProcessWindowEvent(event) )
|
||||
{
|
||||
|
Reference in New Issue
Block a user