X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0e320a79f187558effb04d92020b470372bbe456..8e193f384f7b98daef459653ddb8485173fba8ba:/src/os2/statbmp.cpp diff --git a/src/os2/statbmp.cpp b/src/os2/statbmp.cpp index a67c558465..412e6511a3 100644 --- a/src/os2/statbmp.cpp +++ b/src/os2/statbmp.cpp @@ -1,27 +1,38 @@ ///////////////////////////////////////////////////////////////////////////// // Name: statbmp.cpp // Purpose: wxStaticBitmap -// Author: AUTHOR +// Author: David Webster // Modified by: // Created: ??/??/98 // RCS-ID: $Id$ -// Copyright: (c) AUTHOR -// Licence: wxWindows licence +// Copyright: (c) David Webster +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation "statbmp.h" +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#include "wx/window.h" +#include "wx/os2/private.h" + +#ifndef WX_PRECOMP + #include "wx/icon.h" + #include "wx/statbmp.h" #endif -#include "wx/statbmp.h" +#include + +// --------------------------------------------------------------------------- +// macors +// --------------------------------------------------------------------------- #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl) #endif -/* - * wxStaticBitmap - */ +// --------------------------------------------------------------------------- +// wxStaticBitmap +// --------------------------------------------------------------------------- bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, @@ -35,9 +46,9 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id, if (parent) parent->AddChild(this); if ( id == -1 ) - m_windowId = (int)NewControlId(); + m_windowId = (int)NewControlId(); else - m_windowId = id; + m_windowId = id; m_windowStyle = style; @@ -45,15 +56,49 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id, return FALSE; } -void wxStaticBitmap::SetSize(int x, int y, int width, int height, int sizeFlags) +bool wxStaticBitmap::ImageIsOk() const { - // TODO + 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; +} + +wxSize wxStaticBitmap::DoGetBestSize() +{ + // 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::SetBitmap(const wxBitmap& bitmap) { - m_messageBitmap = bitmap; + Free(); + + m_isIcon = bitmap.IsKindOf(CLASSINFO(wxIcon)); + if ( m_isIcon ) + m_image.icon = new wxIcon((const wxIcon&)bitmap); + else + m_image.bitmap = new wxBitmap(bitmap); + + int x, y; + int w, h; + GetPosition(&x, &y); + GetSize(&w, &h); // TODO: redraw bitmap } +