diff --git a/include/wx/aui/auibar.h b/include/wx/aui/auibar.h index 6b612b545a..2e2f3e3a52 100644 --- a/include/wx/aui/auibar.h +++ b/include/wx/aui/auibar.h @@ -211,6 +211,11 @@ public: void SetAlignment(int l) { m_alignment = l; } int GetAlignment() const { return m_alignment; } + bool CanBeToggled() const + { + return m_kind == wxITEM_CHECK || m_kind == wxITEM_RADIO; + } + private: wxWindow* m_window; // item's associated window diff --git a/include/wx/event.h b/include/wx/event.h index 6f0128c76d..5042ada638 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -2891,12 +2891,11 @@ public: m_setEnabled = m_setShown = m_setText = - m_setChecked = - m_isCheckable = false; + m_setChecked = false; + m_isCheckable = true; } 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), @@ -2904,6 +2903,7 @@ public: m_setShown(event.m_setShown), m_setText(event.m_setText), m_setChecked(event.m_setChecked), + m_isCheckable(event.m_isCheckable), m_text(event.m_text) { } @@ -2921,9 +2921,9 @@ 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 + // A flag saying if the item can be checked. True by default. bool IsCheckable() const { return m_isCheckable; } - void SetIsCheckable(bool aCheckable) { m_isCheckable = aCheckable; } + void DisallowCheck() { m_isCheckable = false; } // Sets the interval between updates in milliseconds. // Set to -1 to disable updates, or to 0 to update as frequently as possible. @@ -2950,7 +2950,6 @@ public: virtual wxEvent *Clone() const wxOVERRIDE { return new wxUpdateUIEvent(*this); } protected: - bool m_isCheckable; bool m_checked; bool m_enabled; bool m_shown; @@ -2958,6 +2957,7 @@ protected: bool m_setShown; bool m_setText; bool m_setChecked; + bool m_isCheckable; wxString m_text; #if wxUSE_LONGLONG static wxLongLong sm_lastUpdate; diff --git a/interface/wx/aui/auibar.h b/interface/wx/aui/auibar.h index 2c118bd19b..5d2e640272 100644 --- a/interface/wx/aui/auibar.h +++ b/interface/wx/aui/auibar.h @@ -407,6 +407,13 @@ public: */ int GetAlignment() const; + + /** + Returns whether the toolbar item can be toggled. + + @since 3.1.5 + */ + bool CanBeToggled() const; }; /** diff --git a/src/aui/auibar.cpp b/src/aui/auibar.cpp index 83f022371e..6956e652cd 100644 --- a/src/aui/auibar.cpp +++ b/src/aui/auibar.cpp @@ -2200,8 +2200,8 @@ 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 ( !item.CanBeToggled() ) + evt.DisallowCheck(); if (handler->ProcessEvent(evt)) { diff --git a/src/common/menucmn.cpp b/src/common/menucmn.cpp index da51fc32b1..f70e85e002 100644 --- a/src/common/menucmn.cpp +++ b/src/common/menucmn.cpp @@ -616,7 +616,9 @@ void wxMenuBase::UpdateUI(wxEvtHandler* source) wxWindowID itemid = item->GetId(); wxUpdateUIEvent event(itemid); event.SetEventObject( this ); - event.SetIsCheckable(item->IsCheckable()); + + if ( !item->IsCheckable() ) + event.DisallowCheck(); if ( source->ProcessEvent(event) ) { diff --git a/src/common/tbarbase.cpp b/src/common/tbarbase.cpp index 285a5ddb8f..c44dfdf175 100644 --- a/src/common/tbarbase.cpp +++ b/src/common/tbarbase.cpp @@ -738,7 +738,9 @@ void wxToolBarBase::UpdateWindowUI(long flags) wxUpdateUIEvent event(toolid); event.SetEventObject(this); - event.SetIsCheckable(tool->CanBeToggled()); + + if ( !tool->CanBeToggled() ) + event.DisallowCheck(); if ( evtHandler->ProcessEvent(event) ) { diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index 2aca66e556..9b2e522920 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -2817,7 +2817,6 @@ void wxWindowBase::UpdateWindowUI(long flags) { wxUpdateUIEvent event(GetId()); event.SetEventObject(this); - event.SetIsCheckable(true); if ( GetEventHandler()->ProcessEvent(event) ) { diff --git a/src/osx/menu_osx.cpp b/src/osx/menu_osx.cpp index 3c8552ffa4..df85dc2c89 100644 --- a/src/osx/menu_osx.cpp +++ b/src/osx/menu_osx.cpp @@ -324,10 +324,8 @@ bool wxMenu::HandleCommandUpdateStatus( wxMenuItem* item, wxWindow* senderWindow wxUpdateUIEvent event(menuid); event.SetEventObject( this ); - if ( item ) - event.SetIsCheckable(item->IsCheckable()); - else - event.SetIsCheckable(true); + if ( !item || !item->IsCheckable() ) + event.DisallowCheck(); bool processed = DoProcessEvent(this, event, GetWindow()); diff --git a/src/ribbon/buttonbar.cpp b/src/ribbon/buttonbar.cpp index 52751002fa..7e631d88a0 100644 --- a/src/ribbon/buttonbar.cpp +++ b/src/ribbon/buttonbar.cpp @@ -905,7 +905,6 @@ void wxRibbonButtonBar::UpdateWindowUI(long flags) wxUpdateUIEvent event(id); event.SetEventObject(this); - event.SetIsCheckable(true); if ( ProcessWindowEvent(event) ) { diff --git a/src/ribbon/toolbar.cpp b/src/ribbon/toolbar.cpp index dffc8147c4..ec6c2e0054 100644 --- a/src/ribbon/toolbar.cpp +++ b/src/ribbon/toolbar.cpp @@ -1178,7 +1178,6 @@ void wxRibbonToolBar::UpdateWindowUI(long flags) wxUpdateUIEvent event(id); event.SetEventObject(this); - event.SetIsCheckable(true); if ( ProcessWindowEvent(event) ) {