Make IsCheckable true by default and switch to explicitly disallowing it
Also add a new accessor to wxAuiToolBarItem to make it easier to determine when a tool can be checked.
This commit is contained in:
@@ -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
|
||||
|
@@ -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;
|
||||
|
@@ -407,6 +407,13 @@ public:
|
||||
|
||||
*/
|
||||
int GetAlignment() const;
|
||||
|
||||
/**
|
||||
Returns whether the toolbar item can be toggled.
|
||||
|
||||
@since 3.1.5
|
||||
*/
|
||||
bool CanBeToggled() const;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -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))
|
||||
{
|
||||
|
@@ -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) )
|
||||
{
|
||||
|
@@ -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) )
|
||||
{
|
||||
|
@@ -2817,7 +2817,6 @@ void wxWindowBase::UpdateWindowUI(long flags)
|
||||
{
|
||||
wxUpdateUIEvent event(GetId());
|
||||
event.SetEventObject(this);
|
||||
event.SetIsCheckable(true);
|
||||
|
||||
if ( GetEventHandler()->ProcessEvent(event) )
|
||||
{
|
||||
|
@@ -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());
|
||||
|
||||
|
@@ -905,7 +905,6 @@ void wxRibbonButtonBar::UpdateWindowUI(long flags)
|
||||
|
||||
wxUpdateUIEvent event(id);
|
||||
event.SetEventObject(this);
|
||||
event.SetIsCheckable(true);
|
||||
|
||||
if ( ProcessWindowEvent(event) )
|
||||
{
|
||||
|
@@ -1178,7 +1178,6 @@ void wxRibbonToolBar::UpdateWindowUI(long flags)
|
||||
|
||||
wxUpdateUIEvent event(id);
|
||||
event.SetEventObject(this);
|
||||
event.SetIsCheckable(true);
|
||||
|
||||
if ( ProcessWindowEvent(event) )
|
||||
{
|
||||
|
Reference in New Issue
Block a user