return a valid bitmap from GetBitmap() even if we created an icon internally

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36480 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2005-12-19 13:46:23 +00:00
parent 62bdd4db0e
commit 333c869716
2 changed files with 32 additions and 16 deletions

View File

@@ -196,6 +196,34 @@ bool wxStaticBitmap::ImageIsOk() const
return m_image && m_image->Ok();
}
wxIcon wxStaticBitmap::GetIcon() const
{
wxCHECK_MSG( m_image, wxIcon(), _T("no image in wxStaticBitmap") );
// we can't ask for an icon if all we have is a bitmap
wxCHECK_MSG( m_isIcon, wxIcon(), _T("no icon in this wxStaticBitmap") );
return *(wxIcon *)m_image;
}
wxBitmap wxStaticBitmap::GetBitmap() const
{
if ( m_isIcon )
{
// don't fail because we might have replaced the bitmap with icon
// ourselves internally in ConvertImage() to keep the transparency but
// the user code doesn't know about it so it still can use GetBitmap()
// to retrieve the bitmap
return wxBitmap(GetIcon());
}
else // we have a bitmap
{
wxCHECK_MSG( m_image, wxBitmap(), _T("no image in wxStaticBitmap") );
return *(wxBitmap *)m_image;
}
}
void wxStaticBitmap::Free()
{
delete m_image;