File: systhemectrl.h

package info (click to toggle)
wxpython4.0 4.2.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 221,752 kB
  • sloc: cpp: 962,555; python: 230,573; ansic: 170,731; makefile: 51,756; sh: 9,342; perl: 1,564; javascript: 584; php: 326; xml: 200
file content (87 lines) | stat: -rw-r--r-- 2,488 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/////////////////////////////////////////////////////////////////////////////
// Name:        wx/systhemectrl.h
// Purpose:     Class to make controls appear in the systems theme
// Author:      Tobias Taschner
// Created:     2014-08-14
// Copyright:   (c) 2014 wxWidgets development team
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////

#ifndef _WX_SYSTHEMECTRL_H
#define _WX_SYSTHEMECTRL_H

#include "wx/defs.h"

#if defined(__WXMSW__) && wxUSE_UXTHEME && !defined(__WXUNIVERSAL__)
    #define wxHAS_SYSTEM_THEMED_CONTROL
#endif

class WXDLLIMPEXP_FWD_CORE wxWindow;

class WXDLLIMPEXP_CORE wxSystemThemedControlBase
{
public:
    wxSystemThemedControlBase()
    {
#ifdef wxHAS_SYSTEM_THEMED_CONTROL
        m_systemThemeDisabled = false;
#endif // wxHAS_SYSTEM_THEMED_CONTROL
    }

    bool IsSystemThemeDisabled() const
    {
#ifdef wxHAS_SYSTEM_THEMED_CONTROL
        return m_systemThemeDisabled;
#else // !wxHAS_SYSTEM_THEMED_CONTROL
        return false;
#endif // wxHAS_SYSTEM_THEMED_CONTROL/!wxHAS_SYSTEM_THEMED_CONTROL
    }

    virtual ~wxSystemThemedControlBase() { }

protected:
    // This method is virtual and can be overridden, e.g. composite controls do
    // it to enable the system theme for all of their parts.
    virtual void DoEnableSystemTheme
#ifdef wxHAS_SYSTEM_THEMED_CONTROL
    // Only __WXMSW__ has a non-trivial implementation currently.
    (bool enable, wxWindow* window);
#else
    (bool WXUNUSED(enable), wxWindow* WXUNUSED(window)) { }
#endif // wxHAS_SYSTEM_THEMED_CONTROL

private:
#ifdef wxHAS_SYSTEM_THEMED_CONTROL
    bool m_systemThemeDisabled;
#endif // wxHAS_SYSTEM_THEMED_CONTROL

    wxDECLARE_NO_COPY_CLASS(wxSystemThemedControlBase);
};

// This class used CRTP, i.e. it should be instantiated for the real base class
// and inherited from.
template <class C>
class wxSystemThemedControl : public C,
                              public wxSystemThemedControlBase
{
public:
    wxSystemThemedControl() { }

    void EnableSystemTheme(bool enable = true)
    {
        DoEnableSystemTheme(enable, this);
    }

protected:
    void EnableSystemThemeByDefault()
    {
        // Check if the system theme hadn't been explicitly disabled before
        // enabling it by default.
        if ( !this->IsSystemThemeDisabled() )
            DoEnableSystemTheme(true, this);
    }

    wxDECLARE_NO_COPY_TEMPLATE_CLASS(wxSystemThemedControl, C);
};

#endif // _WX_SYSTHEMECTRL_H