diff --git a/include/wx/msw/statbmp.h b/include/wx/msw/statbmp.h index 9466edf512..6d5802c008 100644 --- a/include/wx/msw/statbmp.h +++ b/include/wx/msw/statbmp.h @@ -76,6 +76,7 @@ protected: void DoPaintManually(wxPaintEvent& event); #endif // !__WXWINCE__ + void WXHandleSize(wxSizeEvent& event); // we can have either an icon or a bitmap bool m_isIcon; @@ -86,6 +87,7 @@ protected: private: DECLARE_DYNAMIC_CLASS(wxStaticBitmap) + wxDECLARE_EVENT_TABLE(); wxDECLARE_NO_COPY_CLASS(wxStaticBitmap); }; diff --git a/interface/wx/statbmp.h b/interface/wx/statbmp.h index 048bf90be9..ffbbb1a93c 100644 --- a/interface/wx/statbmp.h +++ b/interface/wx/statbmp.h @@ -17,6 +17,12 @@ If you want to display larger images portably, you may use generic implementation wxGenericStaticBitmap declared in \. + Notice that for the best results, the size of the control should be the + same as the size of the image displayed in it, as happens by default if + if it's not resized explicitly. Otherwise, behaviour depends on the + platform: under MSW, the bitmap is drawn centred inside the control, while + elsewhere it is drawn at the origin of the control. + @library{wxcore} @category{ctrl} @appearance{staticbitmap} diff --git a/src/msw/statbmp.cpp b/src/msw/statbmp.cpp index 469d3e68c4..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 // =========================================================================== @@ -206,6 +210,15 @@ wxSize wxStaticBitmap::DoGetBestClientSize() const 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__ void wxStaticBitmap::DoPaintManually(wxPaintEvent& WXUNUSED(event))