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:
@@ -50,24 +50,12 @@ public:
|
|||||||
virtual void SetIcon(const wxIcon& icon) { SetImage(&icon); }
|
virtual void SetIcon(const wxIcon& icon) { SetImage(&icon); }
|
||||||
virtual void SetBitmap(const wxBitmap& bitmap) { SetImage(&bitmap); }
|
virtual void SetBitmap(const wxBitmap& bitmap) { SetImage(&bitmap); }
|
||||||
|
|
||||||
// assert failure is provoked by an attempt to get an icon from bitmap or
|
// can always be used, whether we have a bitmap or an icon in reality
|
||||||
// vice versa
|
wxBitmap GetBitmap() const;
|
||||||
wxIcon GetIcon() const
|
|
||||||
{
|
|
||||||
wxASSERT_MSG( m_isIcon, _T("no icon in this wxStaticBitmap") );
|
|
||||||
|
|
||||||
return *(wxIcon *)m_image;
|
// can only be used if an icon had been originally used
|
||||||
}
|
wxIcon GetIcon() const;
|
||||||
|
|
||||||
wxBitmap GetBitmap() const
|
|
||||||
{
|
|
||||||
wxASSERT_MSG( !m_isIcon, _T("no bitmap in this wxStaticBitmap") );
|
|
||||||
|
|
||||||
return *(wxBitmap *)m_image;
|
|
||||||
}
|
|
||||||
|
|
||||||
// implementation only from now on
|
|
||||||
// -------------------------------
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual wxBorder GetDefaultBorder() const;
|
virtual wxBorder GetDefaultBorder() const;
|
||||||
|
@@ -196,6 +196,34 @@ bool wxStaticBitmap::ImageIsOk() const
|
|||||||
return m_image && m_image->Ok();
|
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()
|
void wxStaticBitmap::Free()
|
||||||
{
|
{
|
||||||
delete m_image;
|
delete m_image;
|
||||||
|
Reference in New Issue
Block a user