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