Fix disabling control tools in wxMSW wxToolBar

Tools containing controls should be enabled/disabled in a different way from
the button tools in wxToolBar::DoEnableTool(). The control and its label (if
any) need to be explicitly enabled/disabled for wxToolBarBase::EnableTool() to
work properly.

Closes #17346.

(cherry picked from commit 68eae6ba5b)
This commit is contained in:
Artur Wieczorek
2016-01-25 22:27:05 +01:00
committed by Dimitri Schoolwerth
parent 15507c0ab4
commit f82f74d09b

View File

@@ -1687,6 +1687,8 @@ void wxToolBar::SetWindowStyleFlag(long style)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void wxToolBar::DoEnableTool(wxToolBarToolBase *tool, bool enable) void wxToolBar::DoEnableTool(wxToolBarToolBase *tool, bool enable)
{
if ( tool->IsButton() )
{ {
::SendMessage(GetHwnd(), TB_ENABLEBUTTON, ::SendMessage(GetHwnd(), TB_ENABLEBUTTON,
(WPARAM)tool->GetId(), (LPARAM)MAKELONG(enable, 0)); (WPARAM)tool->GetId(), (LPARAM)MAKELONG(enable, 0));
@@ -1695,6 +1697,16 @@ void wxToolBar::DoEnableTool(wxToolBarToolBase *tool, bool enable)
// disabled and has a custom "disabled state" bitmap. // disabled and has a custom "disabled state" bitmap.
DoToggleTool(tool, tool->IsToggled()); DoToggleTool(tool, tool->IsToggled());
} }
else if ( tool->IsControl() )
{
wxToolBarTool* tbTool = static_cast<wxToolBarTool*>(tool);
tbTool->GetControl()->Enable(enable);
wxStaticText* text = tbTool->GetStaticText();
if ( text )
text->Enable(enable);
}
}
void wxToolBar::DoToggleTool(wxToolBarToolBase *tool, void wxToolBar::DoToggleTool(wxToolBarToolBase *tool,
bool WXUNUSED_UNLESS_DEBUG(toggle)) bool WXUNUSED_UNLESS_DEBUG(toggle))