]> git.saurik.com Git - wxWidgets.git/blame - src/os2/statbmp.cpp
Removed debug comments
[wxWidgets.git] / src / os2 / statbmp.cpp
CommitLineData
0e320a79
DW
1/////////////////////////////////////////////////////////////////////////////
2// Name: statbmp.cpp
3// Purpose: wxStaticBitmap
409c9842 4// Author: David Webster
0e320a79 5// Modified by:
3b9e3455 6// Created: 11/27/99
0e320a79 7// RCS-ID: $Id$
409c9842
DW
8// Copyright: (c) David Webster
9// Licence: wxWindows licence
0e320a79
DW
10/////////////////////////////////////////////////////////////////////////////
11
aa213887
SN
12#ifdef __GNUG__
13#pragma implementation "statbmp.h"
14#endif
15
409c9842
DW
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
19#include "wx/window.h"
20#include "wx/os2/private.h"
21
22#ifndef WX_PRECOMP
23 #include "wx/icon.h"
24 #include "wx/statbmp.h"
0e320a79
DW
25#endif
26
409c9842
DW
27#include <stdio.h>
28
29// ---------------------------------------------------------------------------
30// macors
31// ---------------------------------------------------------------------------
0e320a79 32
0e320a79 33IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
0e320a79 34
409c9842
DW
35// ---------------------------------------------------------------------------
36// wxStaticBitmap
37// ---------------------------------------------------------------------------
0e320a79 38
3b9e3455
DW
39bool wxStaticBitmap::Create(
40 wxWindow* pParent
41, wxWindowID nId
42, const wxGDIImage& rBitmap
43, const wxPoint& rPos
44, const wxSize& rSize
45, long lStyle
46, const wxString& rName
47)
0e320a79 48{
04701dd9
DW
49 Init();
50
3b9e3455 51 SetName(rName);
43543d98
DW
52 if (pParent)
53 pParent->AddChild(this);
0e320a79 54
43543d98
DW
55 m_backgroundColour = pParent->GetBackgroundColour() ;
56 m_foregroundColour = pParent->GetForegroundColour() ;
04701dd9 57
43543d98 58 if (nId == -1)
409c9842 59 m_windowId = (int)NewControlId();
0e320a79 60 else
3b9e3455 61 m_windowId = nId;
0e320a79 62
3b9e3455 63 m_windowStyle = lStyle;
0e320a79 64
43543d98
DW
65 int nX= rPos.x;
66 int nY = rPos.y;
67 int nWidth = rSize.x;
68 int nHeight = rSize.y;
04701dd9 69
3b9e3455 70 m_windowStyle = lStyle;
04701dd9 71
3b9e3455 72 m_bIsIcon = rBitmap.IsKindOf(CLASSINFO(wxIcon));
04701dd9 73
0e320a79 74 // TODO: create static bitmap control
3b9e3455 75 const wxChar* zClassname = wxT("WX_STATIC");
43543d98 76 int nWinstyle = m_bIsIcon ? SS_ICON : SS_BITMAP;
3b9e3455 77
43543d98 78 m_hWnd = (WXHWND)::WinCreateWindow( pParent->GetHWND()
3b9e3455
DW
79 ,zClassname
80 ,wxT("")
81 ,nWinstyle | WS_VISIBLE
82 ,0,0,0,0
83 ,pParent->GetHWND()
84 ,HWND_TOP
85 ,m_windowId
86 ,NULL
87 ,NULL
88 );
89
04701dd9
DW
90 wxCHECK_MSG( m_hWnd, FALSE, wxT("Failed to create static bitmap") );
91
3b9e3455 92 SetImage(rBitmap);
04701dd9
DW
93
94 // Subclass again for purposes of dialog editing mode
95 SubclassWin(m_hWnd);
04701dd9 96 SetFont(GetParent()->GetFont());
3b9e3455
DW
97 SetSize(nX, nY, nWidth, nHeight);
98 return(FALSE);
0e320a79
DW
99}
100
409c9842 101bool wxStaticBitmap::ImageIsOk() const
0e320a79 102{
43543d98 103 return(m_pImage && m_pImage->Ok());
409c9842
DW
104}
105
106void wxStaticBitmap::Free()
107{
3b9e3455
DW
108 delete m_pImage;
109 m_pImage = NULL;
409c9842
DW
110}
111
e78c4d50 112wxSize wxStaticBitmap::DoGetBestSize() const
409c9842
DW
113{
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();
0e320a79
DW
117}
118
3b9e3455
DW
119void wxStaticBitmap::SetImage(
120 const wxGDIImage& rBitmap
121)
0e320a79 122{
409c9842
DW
123 Free();
124
3b9e3455
DW
125 m_bIsIcon = rBitmap.IsKindOf(CLASSINFO(wxIcon));
126 if (m_bIsIcon)
127 m_pImage = new wxIcon((const wxIcon&)rBitmap);
409c9842 128 else
3b9e3455
DW
129 m_pImage = new wxBitmap((const wxBitmap &)rBitmap);
130
131 int nX;
132 int nY;
133 int nW;
134 int nH;
135
136 GetPosition(&nX, &nY);
43543d98 137 GetSize(&nW, &nH);
3b9e3455
DW
138
139 ::WinSendMsg( GetHwnd()
140 ,SM_SETHANDLE
141 ,MPFROMHWND(m_pImage->GetHandle())
142 ,NULL
143 );
144 if (ImageIsOk())
145 {
146 int nWidth = rBitmap.GetWidth();
147 int nHeight = rBitmap.GetHeight();
148
149 if (nWidth && nHeight)
150 {
151 nW = nWidth;
152 nW = nHeight;
153
154 ::WinSetWindowPos( GetHwnd()
155 ,HWND_TOP
156 ,nX
157 ,nY
158 ,nWidth
159 ,nHeight
160 ,SWP_SIZE | SWP_MOVE | SWP_SHOW
161 );
162 }
163 }
164
165 RECTL vRect;
166
167 vRect.xLeft = nW;
168 vRect.yTop = nY;
169 vRect.xRight = nX + nW;
170 vRect.yBottom = nY + nH;
171
172 ::WinInvalidateRect(GetHwndOf(GetParent()), &vRect, TRUE);
0e320a79
DW
173}
174
32334453
DW
175MRESULT wxStaticBitmap::OS2WindowProc(
176 WXUINT uMsg
177, WXWPARAM wParam
178, WXLPARAM lParam
179)
180{
181 return wxWindow::OS2WindowProc(uMsg, wParam, lParam);
182} // end of wxStaticBitmap::OS2WindowProc