]>
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 // TODO: create static bitmap control
75 const wxChar
* zClassname
= wxT("WX_STATIC");
76 int nWinstyle
= m_bIsIcon
? SS_ICON
: SS_BITMAP
;
78 m_hWnd
= (WXHWND
)::WinCreateWindow( pParent
->GetHWND()
81 ,nWinstyle
| WS_VISIBLE
90 wxCHECK_MSG( m_hWnd
, FALSE
, wxT("Failed to create static bitmap") );
94 // Subclass again for purposes of dialog editing mode
96 SetFont(GetParent()->GetFont());
97 SetSize(nX
, nY
, nWidth
, nHeight
);
101 bool wxStaticBitmap::ImageIsOk() const
103 return(m_pImage
&& m_pImage
->Ok());
106 void wxStaticBitmap::Free()
112 wxSize
wxStaticBitmap::DoGetBestSize() const
114 // reuse the current size (as wxWindow does) instead of using some
115 // arbitrary default size (as wxControl, our immediate base class, does)
116 return wxWindow::DoGetBestSize();
119 void wxStaticBitmap::SetImage(
120 const wxGDIImage
& rBitmap
125 m_bIsIcon
= rBitmap
.IsKindOf(CLASSINFO(wxIcon
));
127 m_pImage
= new wxIcon((const wxIcon
&)rBitmap
);
129 m_pImage
= new wxBitmap((const wxBitmap
&)rBitmap
);
136 GetPosition(&nX
, &nY
);
139 ::WinSendMsg( GetHwnd()
141 ,MPFROMHWND(m_pImage
->GetHandle())
146 int nWidth
= rBitmap
.GetWidth();
147 int nHeight
= rBitmap
.GetHeight();
149 if (nWidth
&& nHeight
)
154 ::WinSetWindowPos( GetHwnd()
160 ,SWP_SIZE
| SWP_MOVE
| SWP_SHOW
169 vRect
.xRight
= nX
+ nW
;
170 vRect
.yBottom
= nY
+ nH
;
172 ::WinInvalidateRect(GetHwndOf(GetParent()), &vRect
, TRUE
);
175 MRESULT
wxStaticBitmap::OS2WindowProc(
181 return wxWindow::OS2WindowProc(uMsg
, wParam
, lParam
);
182 } // end of wxStaticBitmap::OS2WindowProc