fixed wxUniv's wxDialog::ShowModal() to use GetParentForModalDialog()
[wxWidgets.git] / src / univ / statbmp.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/univ/statbmp.cpp
3 // Purpose: wxStaticBitmap implementation
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 25.08.00
7 // RCS-ID: $Id$
8 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #include "wx/wxprec.h"
21
22 #ifdef __BORLANDC__
23 #pragma hdrstop
24 #endif
25
26 #if wxUSE_STATBMP
27
28 #include "wx/statbmp.h"
29
30 #ifndef WX_PRECOMP
31 #include "wx/dc.h"
32 #include "wx/icon.h"
33 #include "wx/validate.h"
34 #endif
35
36 #include "wx/univ/renderer.h"
37 #include "wx/univ/theme.h"
38
39 // ============================================================================
40 // implementation
41 // ============================================================================
42
43 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
44
45 // ----------------------------------------------------------------------------
46 // wxStaticBitmap
47 // ----------------------------------------------------------------------------
48
49 bool wxStaticBitmap::Create(wxWindow *parent,
50 wxWindowID id,
51 const wxBitmap &label,
52 const wxPoint &pos,
53 const wxSize &size,
54 long style,
55 const wxString &name)
56 {
57 if ( !wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name) )
58 return false;
59
60 // set bitmap first
61 SetBitmap(label);
62
63 // and adjust our size to fit it after this
64 SetInitialSize(size);
65
66 return true;
67 }
68
69 // ----------------------------------------------------------------------------
70 // bitmap/icon setting/getting and converting between
71 // ----------------------------------------------------------------------------
72
73 void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
74 {
75 m_bitmap = bitmap;
76 }
77
78 void wxStaticBitmap::SetIcon(const wxIcon& icon)
79 {
80 #ifdef __WXMSW__
81 m_bitmap.CopyFromIcon(icon);
82 #else
83 m_bitmap = (const wxBitmap&)icon;
84 #endif
85 }
86
87 wxIcon wxStaticBitmap::GetIcon() const
88 {
89 wxIcon icon;
90 #ifdef __WXMSW__
91 icon.CopyFromBitmap(m_bitmap);
92 #else
93 icon = (const wxIcon&)m_bitmap;
94 #endif
95 return icon;
96 }
97
98 // ----------------------------------------------------------------------------
99 // drawing
100 // ----------------------------------------------------------------------------
101
102 void wxStaticBitmap::DoDraw(wxControlRenderer *renderer)
103 {
104 wxControl::DoDraw(renderer);
105 renderer->DrawBitmap(GetBitmap());
106 }
107
108 #endif // wxUSE_STATBMP