no message
[wxWidgets.git] / src / os2 / statbmp.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: statbmp.cpp
3 // Purpose: wxStaticBitmap
4 // Author: David Webster
5 // Modified by:
6 // Created: ??/??/98
7 // RCS-ID: $Id$
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #include "wx/window.h"
16 #include "wx/os2/private.h"
17
18 #ifndef WX_PRECOMP
19 #include "wx/icon.h"
20 #include "wx/statbmp.h"
21 #endif
22
23 #include <stdio.h>
24
25 // ---------------------------------------------------------------------------
26 // macors
27 // ---------------------------------------------------------------------------
28
29 #if !USE_SHARED_LIBRARY
30 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
31 #endif
32
33 // ---------------------------------------------------------------------------
34 // wxStaticBitmap
35 // ---------------------------------------------------------------------------
36
37 bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
38 const wxBitmap& bitmap,
39 const wxPoint& pos,
40 const wxSize& size,
41 long style,
42 const wxString& name)
43 {
44 m_messageBitmap = bitmap;
45 SetName(name);
46 if (parent) parent->AddChild(this);
47
48 if ( id == -1 )
49 m_windowId = (int)NewControlId();
50 else
51 m_windowId = id;
52
53 m_windowStyle = style;
54
55 // TODO: create static bitmap control
56 return FALSE;
57 }
58
59 bool wxStaticBitmap::ImageIsOk() const
60 {
61 if ( m_isIcon && m_image.icon )
62 return m_image.icon->Ok();
63 else if ( m_image.bitmap )
64 return m_image.bitmap->Ok();
65 else
66 return FALSE;
67 }
68
69 void wxStaticBitmap::Free()
70 {
71 if ( m_isIcon )
72 delete m_image.icon;
73 else
74 delete m_image.bitmap;
75
76 m_image.icon = NULL;
77 }
78
79 wxSize wxStaticBitmap::DoGetBestSize()
80 {
81 // reuse the current size (as wxWindow does) instead of using some
82 // arbitrary default size (as wxControl, our immediate base class, does)
83 return wxWindow::DoGetBestSize();
84 }
85
86 void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
87 {
88 Free();
89
90 m_isIcon = bitmap.IsKindOf(CLASSINFO(wxIcon));
91 if ( m_isIcon )
92 m_image.icon = new wxIcon((const wxIcon&)bitmap);
93 else
94 m_image.bitmap = new wxBitmap(bitmap);
95
96 int x, y;
97 int w, h;
98 GetPosition(&x, &y);
99 GetSize(&w, &h);
100
101 // TODO: redraw bitmap
102 }
103
104