]>
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 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "statbmp.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
19 #include "wx/window.h"
20 #include "wx/os2/private.h"
24 #include "wx/statbmp.h"
29 // ---------------------------------------------------------------------------
31 // ---------------------------------------------------------------------------
33 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap
, wxControl
)
35 // ---------------------------------------------------------------------------
37 // ---------------------------------------------------------------------------
39 bool wxStaticBitmap::Create(
42 , const wxGDIImage
& rBitmap
46 , const wxString
& rName
53 pParent
->AddChild(this);
55 m_backgroundColour
= pParent
->GetBackgroundColour() ;
56 m_foregroundColour
= pParent
->GetForegroundColour() ;
59 m_windowId
= (int)NewControlId();
63 m_windowStyle
= lStyle
;
68 int nHeight
= rSize
.y
;
70 m_windowStyle
= lStyle
;
72 m_bIsIcon
= rBitmap
.IsKindOf(CLASSINFO(wxIcon
));
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(*wxSMALL_FONT
);
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
);
173 MRESULT
wxStaticBitmap::OS2WindowProc(
179 return wxWindow::OS2WindowProc(uMsg
, wParam
, lParam
);
180 } // end of wxStaticBitmap::OS2WindowProc