- m_messageBitmap = bitmap;
- SetName(name);
- if (parent) parent->AddChild(this);
-
- m_backgroundColour = parent->GetBackgroundColour() ;
- m_foregroundColour = parent->GetForegroundColour() ;
-
- if ( id == -1 )
- m_windowId = (int)NewControlId();
- else
- m_windowId = id;
-
- int x = pos.x;
- int y = pos.y;
- int width = size.x;
- int height = size.y;
-
- if ( width < 0 && bitmap.Ok() )
- width = bitmap.GetWidth();
- if ( height < 0 && bitmap.Ok() )
- height = bitmap.GetHeight();
-
- m_windowStyle = style;
-
- // Use an ownerdraw button to produce a static bitmap, since there's
- // no ownerdraw static.
- // TODO: perhaps this should be a static item, with style SS_BITMAP.
- m_hWnd = (WXHWND)CreateWindow
- (
- "BUTTON",
- "",
- BS_OWNERDRAW | WS_TABSTOP | WS_CHILD | WS_VISIBLE,
- 0, 0, 0, 0,
- (HWND)parent->GetHWND(),
- (HMENU)m_windowId,
- wxGetInstance(),
- NULL
- );
-
- // Subclass again for purposes of dialog editing mode
- SubclassWin(m_hWnd);
-
- SetFont(GetParent()->GetFont());
-
- SetSize(x, y, width, height);
- return TRUE;
+ Init();
+
+ SetName(name);
+ if (parent)
+ parent->AddChild(this);
+
+ m_backgroundColour = parent->GetBackgroundColour() ;
+ m_foregroundColour = parent->GetForegroundColour() ;
+
+ if ( id == -1 )
+ m_windowId = (int)NewControlId();
+ else
+ m_windowId = id;
+
+ int x = pos.x;
+ int y = pos.y;
+ int width = size.x;
+ int height = size.y;
+
+ m_windowStyle = style;
+
+ m_isIcon = bitmap.IsKindOf(CLASSINFO(wxIcon));
+
+#ifdef __WIN32__
+ // create a static control with either SS_BITMAP or SS_ICON style depending
+ // on what we have here
+ const char *classname = "STATIC";
+ int winstyle = m_isIcon ? SS_ICON : SS_BITMAP;
+#else // Win16
+ const char *classname = "BUTTON";
+ int winstyle = BS_OWNERDRAWN;
+#endif // Win32
+
+ m_hWnd = (WXHWND)::CreateWindow
+ (
+ classname,
+ "",
+ winstyle | WS_CHILD | WS_VISIBLE,
+ 0, 0, 0, 0,
+ (HWND)parent->GetHWND(),
+ (HMENU)m_windowId,
+ wxGetInstance(),
+ NULL
+ );
+
+ wxCHECK_MSG( m_hWnd, FALSE, "Failed to create static bitmap" );
+
+ SetBitmap(bitmap);
+
+ // Subclass again for purposes of dialog editing mode
+ SubclassWin(m_hWnd);
+
+ SetFont(GetParent()->GetFont());
+
+ SetSize(x, y, width, height);
+
+ return TRUE;
+}
+
+bool wxStaticBitmap::ImageIsOk() const
+{
+ if ( m_isIcon && m_image.icon )
+ return m_image.icon->Ok();
+ else if ( m_image.bitmap )
+ return m_image.bitmap->Ok();
+ else
+ return FALSE;
+}
+
+void wxStaticBitmap::Free()
+{
+ if ( m_isIcon )
+ delete m_image.icon;
+ else
+ delete m_image.bitmap;
+
+ m_image.icon = NULL;