From 627870be90c5452623eefdcc067a35871b2e40f1 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Wed, 6 Sep 2017 14:09:29 +0200 Subject: [PATCH] Restore wxButton's feature to use focus bitmap for hover state (wxMSW) Prior to 2.9.2, if the focus bitmap was specified but current one wasn't, the focus bitmap was used for hovering as well. This feature was entirely discarded in b4354db179f5b9f3107cc532bb5232deccab90d0 (see wxBitmapButton::DoSetBitmap) but it is still described in the documentation of wxButton's states and images. It seems it was removed unintentionally, so let's restore it. --- interface/wx/button.h | 2 +- src/msw/anybutton.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/interface/wx/button.h b/interface/wx/button.h index bbd040cc8a..15e77f48bb 100644 --- a/interface/wx/button.h +++ b/interface/wx/button.h @@ -42,7 +42,7 @@ @li @b current: bitmap shown when the mouse is over the button (but it is not pressed although it may have focus). Notice that if current bitmap is not specified but the current platform UI uses hover images for the - buttons (such as Windows XP or GTK+), then the focus bitmap is used for + buttons (such as Windows or GTK+), then the focus bitmap is used for hover state as well. This makes it possible to set focus bitmap only to get reasonably good behaviour on all platforms. diff --git a/src/msw/anybutton.cpp b/src/msw/anybutton.cpp index a1c99e9d47..9966d89ba4 100644 --- a/src/msw/anybutton.cpp +++ b/src/msw/anybutton.cpp @@ -747,6 +747,19 @@ void wxAnyButton::DoSetBitmap(const wxBitmap& bitmap, State which) else { m_imageData->SetBitmap(bitmap, which); + + // if the focus bitmap is specified but current one isn't, use + // the focus bitmap for hovering as well if this is consistent + // with the current Windows version look and feel. + // + // rationale: this is compatible with the old wxGTK behaviour + // and also makes it much easier to do "the right thing" for + // all platforms (some of them, such as Windows, have "hot" + // buttons while others don't) + if ( which == State_Focused && !m_imageData->GetBitmap(State_Current).IsOk() ) + { + m_imageData->SetBitmap(bitmap, State_Current); + } } // it should be enough to only invalidate the best size when the normal