Fix wxStaticBitmap best size calculation in wxMSW.
Take the control borders into account by overriding DoGetBestClientSize() instead of DoGetBestSize(). Also invalidate the default best size computed before we have any valid image when setting the initial image in Create(). Closes #4099. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71380 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -58,7 +58,7 @@ public:
|
|||||||
virtual bool CanApplyThemeBorder() const { return false; }
|
virtual bool CanApplyThemeBorder() const { return false; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual wxSize DoGetBestSize() const;
|
virtual wxSize DoGetBestClientSize() const;
|
||||||
|
|
||||||
// ctor/dtor helpers
|
// ctor/dtor helpers
|
||||||
void Init() { m_isIcon = true; m_image = NULL; m_currentHandle = 0; }
|
void Init() { m_isIcon = true; m_image = NULL; m_currentHandle = 0; }
|
||||||
|
@@ -189,17 +189,21 @@ void wxStaticBitmap::Free()
|
|||||||
wxDELETE(m_image);
|
wxDELETE(m_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSize wxStaticBitmap::DoGetBestSize() const
|
wxSize wxStaticBitmap::DoGetBestClientSize() const
|
||||||
{
|
{
|
||||||
|
wxSize size;
|
||||||
if ( ImageIsOk() )
|
if ( ImageIsOk() )
|
||||||
{
|
{
|
||||||
wxSize best(m_image->GetWidth(), m_image->GetHeight());
|
size = m_image->GetSize();
|
||||||
CacheBestSize(best);
|
}
|
||||||
return best;
|
else // No image yet
|
||||||
|
{
|
||||||
|
// this is completely arbitrary
|
||||||
|
size.x =
|
||||||
|
size.y = 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is completely arbitrary
|
return size;
|
||||||
return wxSize(16, 16);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __WXWINCE__
|
#ifndef __WXWINCE__
|
||||||
@@ -232,12 +236,12 @@ void wxStaticBitmap::SetImage( const wxGDIImage* image )
|
|||||||
{
|
{
|
||||||
wxGDIImage* convertedImage = ConvertImage( *image );
|
wxGDIImage* convertedImage = ConvertImage( *image );
|
||||||
SetImageNoCopy( convertedImage );
|
SetImageNoCopy( convertedImage );
|
||||||
InvalidateBestSize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxStaticBitmap::SetImageNoCopy( wxGDIImage* image)
|
void wxStaticBitmap::SetImageNoCopy( wxGDIImage* image)
|
||||||
{
|
{
|
||||||
Free();
|
Free();
|
||||||
|
InvalidateBestSize();
|
||||||
|
|
||||||
m_isIcon = image->IsKindOf( CLASSINFO(wxIcon) );
|
m_isIcon = image->IsKindOf( CLASSINFO(wxIcon) );
|
||||||
// the image has already been copied
|
// the image has already been copied
|
||||||
|
Reference in New Issue
Block a user