X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/906c935a80b10d53cecf57f71ab5f3f4f1d529ec..d485bda109d5ef0fef36a3f737549e9b9f54baab:/src/msw/statbmp.cpp?ds=sidebyside diff --git a/src/msw/statbmp.cpp b/src/msw/statbmp.cpp index 31c46938b8..34aec58c09 100644 --- a/src/msw/statbmp.cpp +++ b/src/msw/statbmp.cpp @@ -42,9 +42,13 @@ #include // --------------------------------------------------------------------------- -// macors +// macros // --------------------------------------------------------------------------- +wxBEGIN_EVENT_TABLE(wxStaticBitmap, wxStaticBitmapBase) + EVT_SIZE(wxStaticBitmap::WXHandleSize) +wxEND_EVENT_TABLE() + // =========================================================================== // implementation // =========================================================================== @@ -61,7 +65,7 @@ static wxGDIImage* ConvertImage( const wxGDIImage& bitmap ) { - bool isIcon = bitmap.IsKindOf( CLASSINFO(wxIcon) ); + bool isIcon = bitmap.IsKindOf( wxCLASSINFO(wxIcon) ); if( !isIcon ) { @@ -99,10 +103,10 @@ bool wxStaticBitmap::Create(wxWindow *parent, // we may have either bitmap or icon: if a bitmap with mask is passed, we // will transform it to an icon ourselves because otherwise the mask will // be ignored by Windows - m_isIcon = bitmap.IsKindOf(CLASSINFO(wxIcon)); + m_isIcon = bitmap.IsKindOf(wxCLASSINFO(wxIcon)); wxGDIImage *image = ConvertImage( bitmap ); - m_isIcon = image->IsKindOf( CLASSINFO(wxIcon) ); + m_isIcon = image->IsKindOf( wxCLASSINFO(wxIcon) ); // create the native control if ( !MSWCreateControl(wxT("STATIC"), wxEmptyString, pos, size) ) @@ -189,17 +193,30 @@ void wxStaticBitmap::Free() wxDELETE(m_image); } -wxSize wxStaticBitmap::DoGetBestSize() const +wxSize wxStaticBitmap::DoGetBestClientSize() const { + wxSize size; if ( ImageIsOk() ) { - wxSize best(m_image->GetWidth(), m_image->GetHeight()); - CacheBestSize(best); - return best; + size = m_image->GetSize(); + } + else // No image yet + { + // this is completely arbitrary + size.x = + size.y = 16; } - // this is completely arbitrary - return wxSize(16, 16); + return size; +} + +void wxStaticBitmap::WXHandleSize(wxSizeEvent& event) +{ + // Invalidate everything when our size changes as the image position (it's + // drawn centred in the window client area) changes. + Refresh(); + + event.Skip(); } #ifndef __WXWINCE__ @@ -232,14 +249,14 @@ void wxStaticBitmap::SetImage( const wxGDIImage* image ) { wxGDIImage* convertedImage = ConvertImage( *image ); SetImageNoCopy( convertedImage ); - InvalidateBestSize(); } void wxStaticBitmap::SetImageNoCopy( wxGDIImage* image) { Free(); + InvalidateBestSize(); - m_isIcon = image->IsKindOf( CLASSINFO(wxIcon) ); + m_isIcon = image->IsKindOf( wxCLASSINFO(wxIcon) ); // the image has already been copied m_image = image;