Add wxPanel::SetBackgroundBitmap().
[wxWidgets.git] / src / msw / panel.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/panel.cpp
3 // Purpose: Implementation of wxMSW-specific wxPanel class.
4 // Author: Vadim Zeitlin
5 // Created: 2011-03-18
6 // RCS-ID: $Id: wxhead.cpp,v 1.11 2010-04-22 12:44:51 zeitlin Exp $
7 // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 // ============================================================================
12 // declarations
13 // ============================================================================
14
15 // ----------------------------------------------------------------------------
16 // headers
17 // ----------------------------------------------------------------------------
18
19 // for compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
21
22 #ifdef __BORLANDC__
23 #pragma hdrstop
24 #endif
25
26 #ifndef WX_PRECOMP
27 #include "wx/brush.h"
28 #include "wx/panel.h"
29 #endif // WX_PRECOMP
30
31 // ============================================================================
32 // implementation
33 // ============================================================================
34
35 bool wxPanel::HasTransparentBackground()
36 {
37 for ( wxWindow *win = GetParent(); win; win = win->GetParent() )
38 {
39 if ( win->MSWHasInheritableBackground() )
40 return true;
41
42 if ( win->IsTopLevel() )
43 break;
44 }
45
46 return false;
47 }
48
49 void wxPanel::DoSetBackgroundBitmap(const wxBitmap& bmp)
50 {
51 delete m_backgroundBrush;
52 m_backgroundBrush = bmp.IsOk() ? new wxBrush(bmp) : NULL;
53 }
54
55 WXHBRUSH wxPanel::MSWGetCustomBgBrush()
56 {
57 if ( m_backgroundBrush )
58 return (WXHBRUSH)m_backgroundBrush->GetResourceHandle();
59
60 return wxPanelBase::MSWGetCustomBgBrush();
61 }