X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/409c9842c71df526bcfbf1cf5ce80067b09d4d97..b3402d0df8c9f763da1e32fc28c824014e5516c6:/src/os2/statbmp.cpp diff --git a/src/os2/statbmp.cpp b/src/os2/statbmp.cpp index 412e6511a3..5d674c3826 100644 --- a/src/os2/statbmp.cpp +++ b/src/os2/statbmp.cpp @@ -3,7 +3,7 @@ // Purpose: wxStaticBitmap // Author: David Webster // Modified by: -// Created: ??/??/98 +// Created: 11/27/99 // RCS-ID: $Id$ // Copyright: (c) David Webster // Licence: wxWindows licence @@ -26,79 +26,145 @@ // macors // --------------------------------------------------------------------------- -#if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl) -#endif // --------------------------------------------------------------------------- // wxStaticBitmap // --------------------------------------------------------------------------- -bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id, - const wxBitmap& bitmap, - const wxPoint& pos, - const wxSize& size, - long style, - const wxString& name) +bool wxStaticBitmap::Create( + wxWindow* pParent +, wxWindowID nId +, const wxGDIImage& rBitmap +, const wxPoint& rPos +, const wxSize& rSize +, long lStyle +, const wxString& rName +) { - m_messageBitmap = bitmap; - SetName(name); - if (parent) parent->AddChild(this); + Init(); + + SetName(rName); + if (pParent) + pParent->AddChild(this); + + m_backgroundColour = pParent->GetBackgroundColour() ; + m_foregroundColour = pParent->GetForegroundColour() ; - if ( id == -1 ) + if (nId == -1) m_windowId = (int)NewControlId(); else - m_windowId = id; + m_windowId = nId; + + m_windowStyle = lStyle; + + int nX= rPos.x; + int nY = rPos.y; + int nWidth = rSize.x; + int nHeight = rSize.y; + + m_windowStyle = lStyle; - m_windowStyle = style; + m_bIsIcon = rBitmap.IsKindOf(CLASSINFO(wxIcon)); // TODO: create static bitmap control - return FALSE; + const wxChar* zClassname = wxT("WX_STATIC"); + int nWinstyle = m_bIsIcon ? SS_ICON : SS_BITMAP; + + m_hWnd = (WXHWND)::WinCreateWindow( pParent->GetHWND() + ,zClassname + ,wxT("") + ,nWinstyle | WS_VISIBLE + ,0,0,0,0 + ,pParent->GetHWND() + ,HWND_TOP + ,m_windowId + ,NULL + ,NULL + ); + + wxCHECK_MSG( m_hWnd, FALSE, wxT("Failed to create static bitmap") ); + + SetImage(rBitmap); + + // Subclass again for purposes of dialog editing mode + SubclassWin(m_hWnd); + SetFont(GetParent()->GetFont()); + SetSize(nX, nY, nWidth, nHeight); + return(FALSE); } 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; + return(m_pImage && m_pImage->Ok()); } void wxStaticBitmap::Free() { - if ( m_isIcon ) - delete m_image.icon; - else - delete m_image.bitmap; - - m_image.icon = NULL; + delete m_pImage; + m_pImage = NULL; } -wxSize wxStaticBitmap::DoGetBestSize() +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::SetBitmap(const wxBitmap& bitmap) +void wxStaticBitmap::SetImage( + const wxGDIImage& rBitmap +) { Free(); - m_isIcon = bitmap.IsKindOf(CLASSINFO(wxIcon)); - if ( m_isIcon ) - m_image.icon = new wxIcon((const wxIcon&)bitmap); + m_bIsIcon = rBitmap.IsKindOf(CLASSINFO(wxIcon)); + if (m_bIsIcon) + m_pImage = new wxIcon((const wxIcon&)rBitmap); else - m_image.bitmap = new wxBitmap(bitmap); - - int x, y; - int w, h; - GetPosition(&x, &y); - GetSize(&w, &h); - - // TODO: redraw bitmap + m_pImage = new wxBitmap((const wxBitmap &)rBitmap); + + int nX; + int nY; + int nW; + int nH; + + GetPosition(&nX, &nY); + GetSize(&nW, &nH); + + ::WinSendMsg( GetHwnd() + ,SM_SETHANDLE + ,MPFROMHWND(m_pImage->GetHandle()) + ,NULL + ); + if (ImageIsOk()) + { + int nWidth = rBitmap.GetWidth(); + int nHeight = rBitmap.GetHeight(); + + if (nWidth && nHeight) + { + nW = nWidth; + nW = nHeight; + + ::WinSetWindowPos( GetHwnd() + ,HWND_TOP + ,nX + ,nY + ,nWidth + ,nHeight + ,SWP_SIZE | SWP_MOVE | SWP_SHOW + ); + } + } + + RECTL vRect; + + vRect.xLeft = nW; + vRect.yTop = nY; + vRect.xRight = nX + nW; + vRect.yBottom = nY + nH; + + ::WinInvalidateRect(GetHwndOf(GetParent()), &vRect, TRUE); } -