]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/statbmp.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxStaticBitmap
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
15 #include "wx/window.h"
16 #include "wx/os2/private.h"
20 #include "wx/statbmp.h"
25 // ---------------------------------------------------------------------------
27 // ---------------------------------------------------------------------------
29 #if !USE_SHARED_LIBRARY
30 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap
, wxControl
)
33 // ---------------------------------------------------------------------------
35 // ---------------------------------------------------------------------------
37 bool wxStaticBitmap::Create(
40 , const wxGDIImage
& rBitmap
44 , const wxString
& rName
51 pParent
->AddChild(this);
53 m_backgroundColour
= pParent
->GetBackgroundColour() ;
54 m_foregroundColour
= pParent
->GetForegroundColour() ;
57 m_windowId
= (int)NewControlId();
61 m_windowStyle
= lStyle
;
66 int nHeight
= rSize
.y
;
68 m_windowStyle
= lStyle
;
70 m_bIsIcon
= rBitmap
.IsKindOf(CLASSINFO(wxIcon
));
72 // TODO: create static bitmap control
73 const wxChar
* zClassname
= wxT("WX_STATIC");
74 int nWinstyle
= m_bIsIcon
? SS_ICON
: SS_BITMAP
;
76 m_hWnd
= (WXHWND
)::WinCreateWindow( pParent
->GetHWND()
79 ,nWinstyle
| WS_VISIBLE
88 wxCHECK_MSG( m_hWnd
, FALSE
, wxT("Failed to create static bitmap") );
92 // Subclass again for purposes of dialog editing mode
94 SetFont(GetParent()->GetFont());
95 SetSize(nX
, nY
, nWidth
, nHeight
);
99 bool wxStaticBitmap::ImageIsOk() const
101 return(m_pImage
&& m_pImage
->Ok());
104 void wxStaticBitmap::Free()
110 wxSize
wxStaticBitmap::DoGetBestSize() const
112 // reuse the current size (as wxWindow does) instead of using some
113 // arbitrary default size (as wxControl, our immediate base class, does)
114 return wxWindow::DoGetBestSize();
117 void wxStaticBitmap::SetImage(
118 const wxGDIImage
& rBitmap
123 m_bIsIcon
= rBitmap
.IsKindOf(CLASSINFO(wxIcon
));
125 m_pImage
= new wxIcon((const wxIcon
&)rBitmap
);
127 m_pImage
= new wxBitmap((const wxBitmap
&)rBitmap
);
134 GetPosition(&nX
, &nY
);
137 ::WinSendMsg( GetHwnd()
139 ,MPFROMHWND(m_pImage
->GetHandle())
144 int nWidth
= rBitmap
.GetWidth();
145 int nHeight
= rBitmap
.GetHeight();
147 if (nWidth
&& nHeight
)
152 ::WinSetWindowPos( GetHwnd()
158 ,SWP_SIZE
| SWP_MOVE
| SWP_SHOW
167 vRect
.xRight
= nX
+ nW
;
168 vRect
.yBottom
= nY
+ nH
;
170 ::WinInvalidateRect(GetHwndOf(GetParent()), &vRect
, TRUE
);