fixed wxBitmapButton to use focus and hover bitmaps correctly

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@52007 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2008-02-22 19:57:54 +00:00
parent e1f6fc8616
commit 7f427f9cc2
3 changed files with 22 additions and 0 deletions

View File

@@ -152,6 +152,7 @@ wxGTK:
with other applications.
- Fix wxNotebook::GetPage{Text,Image}() when they were called from the page
change event handler for the first added page (Mikkel S).
- Fixed wxBitmapButton to use focus and hover bitmaps correctly.
wxMac:

View File

@@ -68,6 +68,8 @@ protected:
void Init();
private:
void OnFocusChange(wxFocusEvent& event);
DECLARE_DYNAMIC_CLASS(wxBitmapButton)
};

View File

@@ -163,6 +163,13 @@ bool wxBitmapButton::Create( wxWindow *parent,
PostCreation(size);
Connect(wxEVT_SET_FOCUS,
wxFocusEventHandler(wxBitmapButton::OnFocusChange),
NULL, this);
Connect(wxEVT_KILL_FOCUS,
wxFocusEventHandler(wxBitmapButton::OnFocusChange),
NULL, this);
return true;
}
@@ -201,6 +208,12 @@ void wxBitmapButton::OnSetBitmap()
else if (m_isSelected)
the_one = m_bmpSelected;
else if (m_hasFocus)
{
// NB: this is misnomer, m_hasFocus doesn't mean "has focus", but
// "mouse is over the window"
the_one = m_bmpHover;
}
else if (FindFocus() == this)
the_one = m_bmpFocus;
else
the_one = m_bmpNormal;
@@ -264,4 +277,10 @@ void wxBitmapButton::EndSelect()
OnSetBitmap();
}
void wxBitmapButton::OnFocusChange(wxFocusEvent& event)
{
event.Skip();
OnSetBitmap();
}
#endif // wxUSE_BMPBUTTON