As MSW native control centers the image, it must be entirely redrawn when the
area in which the image is centered changes, but it doesn't happen by default,
so do it ourselves explicitly.
Also explain that this centering behaviour is platform-specific and shouldn't
be relied upon.
Closes #4564.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73485
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
void DoPaintManually(wxPaintEvent& event);
#endif // !__WXWINCE__
+ void WXHandleSize(wxSizeEvent& event);
// we can have either an icon or a bitmap
bool m_isIcon;
private:
DECLARE_DYNAMIC_CLASS(wxStaticBitmap)
+ wxDECLARE_EVENT_TABLE();
wxDECLARE_NO_COPY_CLASS(wxStaticBitmap);
};
If you want to display larger images portably, you may use generic
implementation wxGenericStaticBitmap declared in \<wx/generic/statbmpg.h\>.
+ 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}
#include <stdio.h>
// ---------------------------------------------------------------------------
-// macors
+// macros
// ---------------------------------------------------------------------------
+wxBEGIN_EVENT_TABLE(wxStaticBitmap, wxStaticBitmapBase)
+ EVT_SIZE(wxStaticBitmap::WXHandleSize)
+wxEND_EVENT_TABLE()
+
// ===========================================================================
// implementation
// ===========================================================================
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))