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