Add common implementations of wxStaticBitmap icon methods

Instead of defining them, slightly differently, in all the non-MSW
ports, define them once in wxStaticBitmapBase.

No real changes, this is just a simplification.
This commit is contained in:
Vadim Zeitlin
2021-10-21 18:15:12 +01:00
parent 5773a8736c
commit b403624f22
11 changed files with 38 additions and 99 deletions

View File

@@ -96,4 +96,38 @@ wxSize wxStaticBitmapBase::DoGetBestSize() const
return bmp.IsOk() ? bmp.GetScaledSize() : wxSize(16, 16);
}
// Only wxMSW handles icons and bitmaps differently, in all the other ports
// they are exactly the same thing.
#ifdef wxICON_IS_BITMAP
void wxStaticBitmapBase::SetIcon(const wxIcon& icon)
{
SetBitmap(icon);
}
wxIcon wxStaticBitmapBase::GetIcon() const
{
wxIcon icon;
icon.CopyFromBitmap(GetBitmap());
return icon;
}
#else // !wxICON_IS_BITMAP
// Just provide the stabs for them, they're never used anyhow as they're
// overridden in wxMSW implementation of this class.
void wxStaticBitmapBase::SetIcon(const wxIcon& WXUNUSED(icon))
{
wxFAIL_MSG(wxS("unreachable"));
}
wxIcon wxStaticBitmapBase::GetIcon() const
{
wxFAIL_MSG(wxS("unreachable"));
return wxIcon();
}
#endif // wxICON_IS_BITMAP/!wxICON_IS_BITMAP
#endif // wxUSE_STATBMP