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
This commit is contained in:
Vadim Zeitlin 2014-12-07 01:52:42 +00:00
parent 81f6d00518
commit 494b66b5fb
5 changed files with 16 additions and 1 deletions

View File

@ -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).

View File

@ -73,6 +73,8 @@ protected:
void MakeOwnerDrawn();
bool IsOwnerDrawn() const;
virtual bool MSWIsPushed() const;
private:
wxDECLARE_NO_COPY_CLASS(wxAnyButton);
};

View File

@ -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)

View File

@ -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);

View File

@ -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;