+ // we use SS_CENTERIMAGE to prevent the control from resizing the bitmap to
+ // fit to its size -- this is unexpected and doesn't happen in other ports
+ msStyle |= SS_CENTERIMAGE;
+#else // Win16
+ msStyle |= BS_OWNERDRAW;
+#endif // Win32/16
+
+ return msStyle;
+}
+
+bool wxStaticBitmap::ImageIsOk() const
+{
+ return m_image && m_image->Ok();
+}
+
+void wxStaticBitmap::Free()
+{
+ delete m_image;
+
+ m_image = NULL;
+}
+
+wxSize wxStaticBitmap::DoGetBestSize() const
+{
+ // reuse the current size (as wxWindow does) instead of using some
+ // arbitrary default size (as wxControl, our immediate base class, does)
+ return wxWindow::DoGetBestSize();
+}
+
+void wxStaticBitmap::SetImage( const wxGDIImage* image )
+{
+ wxGDIImage* convertedImage = ConvertImage( *image );
+ SetImageNoCopy( convertedImage );
+}
+
+void wxStaticBitmap::SetImageNoCopy( wxGDIImage* image)
+{
+ Free();
+
+ m_isIcon = image->IsKindOf( CLASSINFO(wxIcon) );
+ // the image has already been copied
+ m_image = image;
+
+ int x, y;
+ int w, h;
+ GetPosition(&x, &y);
+ GetSize(&w, &h);
+
+#ifdef __WIN32__
+ HANDLE handle = (HANDLE)m_image->GetHandle();
+ LONG style = ::GetWindowLong( (HWND)GetHWND(), GWL_STYLE ) ;
+ ::SetWindowLong( (HWND)GetHWND(), GWL_STYLE, ( style & ~( SS_BITMAP|SS_ICON ) ) |
+ ( m_isIcon ? SS_ICON : SS_BITMAP ) );
+ ::SendMessage(GetHwnd(), STM_SETIMAGE,
+ m_isIcon ? IMAGE_ICON : IMAGE_BITMAP, (LPARAM)handle);
+#endif // Win32
+
+ if ( ImageIsOk() )
+ {
+ int width = image->GetWidth(),
+ height = image->GetHeight();
+ if ( width && height )
+ {
+ w = width;
+ h = height;
+
+ ::MoveWindow(GetHwnd(), x, y, width, height, FALSE);
+ }
+ }
+
+ RECT rect;
+ rect.left = x;
+ rect.top = y;
+ rect.right = x + w;
+ rect.bottom = y + h;
+ InvalidateRect(GetHwndOf(GetParent()), &rect, TRUE);
+}
+
+// under Win32 we use the standard static control style for this
+#ifdef __WIN16__
+bool wxStaticBitmap::MSWOnDraw(WXDRAWITEMSTRUCT *item)
+{