From 494b66b5fb5e183455371070af2b11da1ca10ba2 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 7 Dec 2014 01:52:42 +0000 Subject: [PATCH] Fix appearance of wxMSW wxToggleButtons with bitmaps in pressed state. Correct the "pushed" state determination in our own drawn code, it didn't work for wxToggleButton which doesn't return BST_PUSHED from BM_GETSTATE. But it does have BM_GETCHECK returning its state directly, so add a new virtual MSWIsPushed() method and implement it differently for it. Closes #13755. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78251 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + include/wx/msw/anybutton.h | 2 ++ include/wx/msw/tglbtn.h | 2 ++ src/msw/anybutton.cpp | 7 ++++++- src/msw/tglbtn.cpp | 5 +++++ 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index a8397090f8..dead06c6e6 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -105,6 +105,7 @@ wxMSW: - Improve wxMimeTypesManager open command detection (Eric Jensen). - Make wxFILTER_INCLUDE_LIST in wxTextValidator actually usable. +- Fix appearance of toggled wxToggleButtons with bitmap (tm). - Fix setting menu item bitmaps after appending them (Artur Wieczorek). - Fix setting label of submenu items (Artur Wieczorek). - Fix handling of selected images in wxBitmapButton (Artur Wieczorek). diff --git a/include/wx/msw/anybutton.h b/include/wx/msw/anybutton.h index e8226d51c3..75a24464b9 100644 --- a/include/wx/msw/anybutton.h +++ b/include/wx/msw/anybutton.h @@ -73,6 +73,8 @@ protected: void MakeOwnerDrawn(); bool IsOwnerDrawn() const; + virtual bool MSWIsPushed() const; + private: wxDECLARE_NO_COPY_CLASS(wxAnyButton); }; diff --git a/include/wx/msw/tglbtn.h b/include/wx/msw/tglbtn.h index 091978b865..67f58696d4 100644 --- a/include/wx/msw/tglbtn.h +++ b/include/wx/msw/tglbtn.h @@ -56,6 +56,8 @@ protected: virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const; + virtual bool MSWIsPushed() const; + void Init(); // current state of the button (when owner-drawn) diff --git a/src/msw/anybutton.cpp b/src/msw/anybutton.cpp index dd0431bdd1..2a3bdd067b 100644 --- a/src/msw/anybutton.cpp +++ b/src/msw/anybutton.cpp @@ -1204,6 +1204,11 @@ bool wxAnyButton::SetForegroundColour(const wxColour &colour) return true; } +bool wxAnyButton::MSWIsPushed() const +{ + return (SendMessage(GetHwnd(), BM_GETSTATE, 0, 0) & BST_PUSHED) != 0; +} + bool wxAnyButton::MSWOnDraw(WXDRAWITEMSTRUCT *wxdis) { LPDRAWITEMSTRUCT lpDIS = (LPDRAWITEMSTRUCT)wxdis; @@ -1225,7 +1230,7 @@ bool wxAnyButton::MSWOnDraw(WXDRAWITEMSTRUCT *wxdis) break; } - bool pushed = (SendMessage(GetHwnd(), BM_GETSTATE, 0, 0) & BST_PUSHED) != 0; + bool pushed = MSWIsPushed(); RECT rectBtn; CopyRect(&rectBtn, &lpDIS->rcItem); diff --git a/src/msw/tglbtn.cpp b/src/msw/tglbtn.cpp index 5cce60bc94..ed34387b03 100644 --- a/src/msw/tglbtn.cpp +++ b/src/msw/tglbtn.cpp @@ -135,6 +135,11 @@ WXDWORD wxToggleButton::MSWGetStyle(long style, WXDWORD *exstyle) const return msStyle; } +bool wxToggleButton::MSWIsPushed() const +{ + return GetValue(); +} + void wxToggleButton::SetValue(bool val) { m_state = val;