Fix pulsing of bitmaps in focused buttons under Windows 7.

It turns out that the actual bitmap shown in this case varies between the
bitmaps at PBS_DEFAULTED and PBS_STYLUSHOT, so that it's invisible half of the
time if we don't specify the value for the latter. Do it now to fix unwanted
pulsing of the bitmap in the focused button.

Closes #15034.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73486 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2013-02-09 00:35:58 +00:00
parent 05942059ef
commit e56fee472c
2 changed files with 21 additions and 1 deletions

View File

@@ -635,6 +635,7 @@ wxGTK:
wxMSW: wxMSW:
- Fix pulsing of bitmaps in focused buttons under Windows 7 (Catalin Raceanu).
- Fix setting colours for the text part of wxComboBox (Igor Korot). - Fix setting colours for the text part of wxComboBox (Igor Korot).
- Add support for CURRENCY and SCODE types to OLE Automation helpers (PB). - Add support for CURRENCY and SCODE types to OLE Automation helpers (PB).
- Allow setting LCID used by wxAutomationObject (PB). - Allow setting LCID used by wxAutomationObject (PB).

View File

@@ -217,7 +217,7 @@ public:
// the image list // the image list
wxXPButtonImageData(wxAnyButton *btn, const wxBitmap& bitmap) wxXPButtonImageData(wxAnyButton *btn, const wxBitmap& bitmap)
: m_iml(bitmap.GetWidth(), bitmap.GetHeight(), true /* use mask */, : m_iml(bitmap.GetWidth(), bitmap.GetHeight(), true /* use mask */,
wxAnyButton::State_Max), wxAnyButton::State_Max + 1 /* see "pulse" comment below */),
m_hwndBtn(GetHwndOf(btn)) m_hwndBtn(GetHwndOf(btn))
{ {
// initialize all bitmaps except for the disabled one to normal state // initialize all bitmaps except for the disabled one to normal state
@@ -231,6 +231,20 @@ public:
#endif #endif
} }
// In addition to the states supported by wxWidgets such as normal,
// hot, pressed, disabled and focused, we need to add bitmap for
// another state when running under Windows 7 -- the so called "stylus
// hot" state corresponding to PBS_STYLUSHOT constant. While it's
// documented in MSDN as being only used with tablets, it is a lie as
// a focused button actually alternates between the image list elements
// with PBS_DEFAULTED and PBS_STYLUSHOT indices and, in particular,
// just disappears during half of the time if the latter is not set so
// we absolutely must set it.
//
// This also explains why we need to allocate an extra slot in the
// image list ctor above, the slot State_Max is used for this one.
m_iml.Add(bitmap);
m_data.himl = GetHimagelistOf(&m_iml); m_data.himl = GetHimagelistOf(&m_iml);
// no margins by default // no margins by default
@@ -254,6 +268,11 @@ public:
{ {
m_iml.Replace(which, bitmap); m_iml.Replace(which, bitmap);
// As we want the focused button to always show its bitmap, we need to
// update the "stylus hot" one to match it to avoid any pulsing.
if ( which == wxAnyButton::State_Focused )
m_iml.Replace(wxAnyButton::State_Max, bitmap);
UpdateImageInfo(); UpdateImageInfo();
} }