X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f2f18548a7e303fb5edd497884e689b39009985a..07aaf32633ecf18ec3edfbb41793a112914792d0:/src/msw/anybutton.cpp diff --git a/src/msw/anybutton.cpp b/src/msw/anybutton.cpp index b8fc1ad197..cf561b548e 100644 --- a/src/msw/anybutton.cpp +++ b/src/msw/anybutton.cpp @@ -217,7 +217,7 @@ public: // the image list wxXPButtonImageData(wxAnyButton *btn, const wxBitmap& bitmap) : m_iml(bitmap.GetWidth(), bitmap.GetHeight(), true /* use mask */, - wxAnyButton::State_Max), + wxAnyButton::State_Max + 1 /* see "pulse" comment below */), m_hwndBtn(GetHwndOf(btn)) { // initialize all bitmaps except for the disabled one to normal state @@ -231,6 +231,20 @@ public: #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); // no margins by default @@ -254,6 +268,11 @@ public: { 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(); }