]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/custombgwin.h
Always provide wxMenuItem bitmap-related methods in wxMSW.
[wxWidgets.git] / include / wx / msw / custombgwin.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/custombgwin.h
3 // Purpose: wxMSW implementation of wxCustomBackgroundWindow
4 // Author: Vadim Zeitlin
5 // Created: 2011-10-10
6 // RCS-ID: $Id: wxhead.h,v 1.12 2010-04-22 12:44:51 zeitlin Exp $
7 // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_MSW_CUSTOMBGWIN_H_
12 #define _WX_MSW_CUSTOMBGWIN_H_
13
14 #include "wx/bitmap.h"
15 #include "wx/brush.h"
16
17 // ----------------------------------------------------------------------------
18 // wxCustomBackgroundWindow
19 // ----------------------------------------------------------------------------
20
21 template <class W>
22 class wxCustomBackgroundWindow : public W,
23 public wxCustomBackgroundWindowBase
24 {
25 public:
26 typedef W BaseWindowClass;
27
28 wxCustomBackgroundWindow() { m_backgroundBrush = NULL; }
29
30 virtual ~wxCustomBackgroundWindow() { delete m_backgroundBrush; }
31
32 protected:
33 virtual void DoSetBackgroundBitmap(const wxBitmap& bmp)
34 {
35 delete m_backgroundBrush;
36 m_backgroundBrush = bmp.IsOk() ? new wxBrush(bmp) : NULL;
37
38 // Our transparent children should use our background if we have it,
39 // otherwise try to restore m_inheritBgCol to some reasonable value: true
40 // if we also have non-default background colour or false otherwise.
41 BaseWindowClass::m_inheritBgCol = bmp.IsOk()
42 || BaseWindowClass::UseBgCol();
43 }
44
45 virtual WXHBRUSH MSWGetCustomBgBrush()
46 {
47 if ( m_backgroundBrush )
48 return (WXHBRUSH)m_backgroundBrush->GetResourceHandle();
49
50 return BaseWindowClass::MSWGetCustomBgBrush();
51 }
52
53 wxBrush *m_backgroundBrush;
54
55 wxDECLARE_NO_COPY_TEMPLATE_CLASS(wxCustomBackgroundWindow, W);
56 };
57
58 #endif // _WX_MSW_CUSTOMBGWIN_H_