X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0e320a79f187558effb04d92020b470372bbe456..8a28f119c8864aa53bc1c33bf57aa9976f358f3b:/src/os2/statbmp.cpp diff --git a/src/os2/statbmp.cpp b/src/os2/statbmp.cpp index a67c558465..8a6baa82ee 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, @@ -30,30 +41,88 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id, long style, const wxString& name) { - m_messageBitmap = bitmap; + Init(); + SetName(name); if (parent) parent->AddChild(this); + m_backgroundColour = parent->GetBackgroundColour() ; + m_foregroundColour = parent->GetForegroundColour() ; + if ( id == -1 ) - m_windowId = (int)NewControlId(); + m_windowId = (int)NewControlId(); else - m_windowId = id; + m_windowId = id; + + m_windowStyle = style; + + 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)); + // TODO: create static bitmap control + wxCHECK_MSG( m_hWnd, FALSE, wxT("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 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 } +