Fix checked disabled wxToolBar tools with custom images in wxMSW.
Windows doesn't use the correct image for checked disabled tools, at least up to and including Windows 7, so don't put such tools in the "checked" state at all: this doesn't matter as they are disabled anyhow, but shows the correct image for them. Closes #12989. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78248 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
bf08ea2666
commit
29cd13cc8f
@ -124,6 +124,7 @@ wxMSW:
|
|||||||
- Fix wxMenuEvent::GetMenu() for wxEVT_MENU_{OPEN,CLOSE} in MDI frames.
|
- Fix wxMenuEvent::GetMenu() for wxEVT_MENU_{OPEN,CLOSE} in MDI frames.
|
||||||
- Added support for reading multi string values to wxRegKey (Carl Godkin).
|
- Added support for reading multi string values to wxRegKey (Carl Godkin).
|
||||||
- Fix updating wxSpinCtrlDouble tooltip text (Laurent Poujoulat).
|
- Fix updating wxSpinCtrlDouble tooltip text (Laurent Poujoulat).
|
||||||
|
- Fix appearance of checked disabled wxToolBar tools with custom images.
|
||||||
|
|
||||||
wxOSX/Cocoa:
|
wxOSX/Cocoa:
|
||||||
|
|
||||||
|
@ -288,6 +288,23 @@ static RECT wxGetTBItemRect(HWND hwnd, int index, int id = wxID_NONE)
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool MSWShouldBeChecked(const wxToolBarToolBase *tool)
|
||||||
|
{
|
||||||
|
// Apparently, "checked" state image overrides the "disabled" image
|
||||||
|
// so we need to enforce our custom "disabled" image (if there is any)
|
||||||
|
// to be drawn for checked and disabled button tool.
|
||||||
|
// Note: We believe this erroneous overriding is fixed in MSW 8.
|
||||||
|
if ( wxGetWinVersion() <= wxWinVersion_7 &&
|
||||||
|
tool->GetKind() == wxITEM_CHECK &&
|
||||||
|
tool->GetDisabledBitmap().IsOk() &&
|
||||||
|
!tool->IsEnabled() )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return tool->IsToggled();
|
||||||
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// implementation
|
// implementation
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@ -976,7 +993,7 @@ bool wxToolBar::Realize()
|
|||||||
|
|
||||||
if ( tool->IsEnabled() )
|
if ( tool->IsEnabled() )
|
||||||
button.fsState |= TBSTATE_ENABLED;
|
button.fsState |= TBSTATE_ENABLED;
|
||||||
if ( tool->IsToggled() )
|
if ( MSWShouldBeChecked(tool) )
|
||||||
button.fsState |= TBSTATE_CHECKED;
|
button.fsState |= TBSTATE_CHECKED;
|
||||||
|
|
||||||
switch ( tool->GetKind() )
|
switch ( tool->GetKind() )
|
||||||
@ -1346,7 +1363,7 @@ bool wxToolBar::MSWCommand(WXUINT WXUNUSED(cmd), WXWORD id_)
|
|||||||
state |= TBSTATE_ENABLED;
|
state |= TBSTATE_ENABLED;
|
||||||
else
|
else
|
||||||
state &= ~TBSTATE_ENABLED;
|
state &= ~TBSTATE_ENABLED;
|
||||||
if (tool->IsToggled())
|
if ( MSWShouldBeChecked(tool) )
|
||||||
state |= TBSTATE_CHECKED;
|
state |= TBSTATE_CHECKED;
|
||||||
else
|
else
|
||||||
state &= ~TBSTATE_CHECKED;
|
state &= ~TBSTATE_CHECKED;
|
||||||
@ -1359,7 +1376,8 @@ bool wxToolBar::MSWCommand(WXUINT WXUNUSED(cmd), WXWORD id_)
|
|||||||
// revert back
|
// revert back
|
||||||
tool->Toggle(!toggled);
|
tool->Toggle(!toggled);
|
||||||
|
|
||||||
::SendMessage(GetHwnd(), TB_CHECKBUTTON, id, MAKELONG(!toggled, 0));
|
::SendMessage(GetHwnd(), TB_CHECKBUTTON, id,
|
||||||
|
MAKELONG(MSWShouldBeChecked(tool), 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -1574,12 +1592,19 @@ void wxToolBar::DoEnableTool(wxToolBarToolBase *tool, bool enable)
|
|||||||
{
|
{
|
||||||
::SendMessage(GetHwnd(), TB_ENABLEBUTTON,
|
::SendMessage(GetHwnd(), TB_ENABLEBUTTON,
|
||||||
(WPARAM)tool->GetId(), (LPARAM)MAKELONG(enable, 0));
|
(WPARAM)tool->GetId(), (LPARAM)MAKELONG(enable, 0));
|
||||||
|
|
||||||
|
// Adjust displayed checked state -- it could have changed if the tool is
|
||||||
|
// disabled and has a custom "disabled state" bitmap.
|
||||||
|
DoToggleTool(tool, tool->IsToggled());
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxToolBar::DoToggleTool(wxToolBarToolBase *tool, bool toggle)
|
void wxToolBar::DoToggleTool(wxToolBarToolBase *tool, bool toggle)
|
||||||
{
|
{
|
||||||
|
wxASSERT_MSG( tool->IsToggled() == toggle, wxT("Inconsistent tool state") );
|
||||||
|
|
||||||
::SendMessage(GetHwnd(), TB_CHECKBUTTON,
|
::SendMessage(GetHwnd(), TB_CHECKBUTTON,
|
||||||
(WPARAM)tool->GetId(), (LPARAM)MAKELONG(toggle, 0));
|
(WPARAM)tool->GetId(),
|
||||||
|
(LPARAM)MAKELONG(MSWShouldBeChecked(tool), 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxToolBar::DoSetToggle(wxToolBarToolBase *WXUNUSED(tool), bool WXUNUSED(toggle))
|
void wxToolBar::DoSetToggle(wxToolBarToolBase *WXUNUSED(tool), bool WXUNUSED(toggle))
|
||||||
|
Loading…
Reference in New Issue
Block a user