]>
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 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap
, wxControl
)
31 // ---------------------------------------------------------------------------
33 // ---------------------------------------------------------------------------
35 bool wxStaticBitmap::Create(
38 , const wxGDIImage
& rBitmap
42 , const wxString
& rName
49 pParent
->AddChild(this);
51 m_backgroundColour
= pParent
->GetBackgroundColour() ;
52 m_foregroundColour
= pParent
->GetForegroundColour() ;
55 m_windowId
= (int)NewControlId();
59 m_windowStyle
= lStyle
;
64 int nHeight
= rSize
.y
;
66 m_windowStyle
= lStyle
;
68 m_bIsIcon
= rBitmap
.IsKindOf(CLASSINFO(wxIcon
));
70 // TODO: create static bitmap control
71 const wxChar
* zClassname
= wxT("WX_STATIC");
72 int nWinstyle
= m_bIsIcon
? SS_ICON
: SS_BITMAP
;
74 m_hWnd
= (WXHWND
)::WinCreateWindow( pParent
->GetHWND()
77 ,nWinstyle
| WS_VISIBLE
86 wxCHECK_MSG( m_hWnd
, FALSE
, wxT("Failed to create static bitmap") );
90 // Subclass again for purposes of dialog editing mode
92 SetFont(GetParent()->GetFont());
93 SetSize(nX
, nY
, nWidth
, nHeight
);
97 bool wxStaticBitmap::ImageIsOk() const
99 return(m_pImage
&& m_pImage
->Ok());
102 void wxStaticBitmap::Free()
108 wxSize
wxStaticBitmap::DoGetBestSize() const
110 // reuse the current size (as wxWindow does) instead of using some
111 // arbitrary default size (as wxControl, our immediate base class, does)
112 return wxWindow::DoGetBestSize();
115 void wxStaticBitmap::SetImage(
116 const wxGDIImage
& rBitmap
121 m_bIsIcon
= rBitmap
.IsKindOf(CLASSINFO(wxIcon
));
123 m_pImage
= new wxIcon((const wxIcon
&)rBitmap
);
125 m_pImage
= new wxBitmap((const wxBitmap
&)rBitmap
);
132 GetPosition(&nX
, &nY
);
135 ::WinSendMsg( GetHwnd()
137 ,MPFROMHWND(m_pImage
->GetHandle())
142 int nWidth
= rBitmap
.GetWidth();
143 int nHeight
= rBitmap
.GetHeight();
145 if (nWidth
&& nHeight
)
150 ::WinSetWindowPos( GetHwnd()
156 ,SWP_SIZE
| SWP_MOVE
| SWP_SHOW
165 vRect
.xRight
= nX
+ nW
;
166 vRect
.yBottom
= nY
+ nH
;
168 ::WinInvalidateRect(GetHwndOf(GetParent()), &vRect
, TRUE
);