1 /* vim: se cin sw=2 ts=2 et : */
2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef __UXThemeData_h__
8 #define __UXThemeData_h__
13 #include "mozilla/LookAndFeel.h"
14 #include "mozilla/Maybe.h"
17 #include "nsWindowDefs.h"
24 eUXCommunicationsRebar
,
25 eUXBrowserTabBarRebar
,
28 eUXCommunicationsToolbar
,
43 CMDBUTTONIDX_MINIMIZE
= 0,
46 CMDBUTTONIDX_BUTTONBOX
50 // This class makes sure we don't attempt to open a theme if the previous
51 // loading attempt has failed because OpenThemeData is a heavy task and
52 // it's less likely that the API returns a different result.
53 class ThemeHandle final
{
54 mozilla::Maybe
<HANDLE
> mHandle
;
57 ThemeHandle() = default;
60 // Disallow copy and move
61 ThemeHandle(const ThemeHandle
&) = delete;
62 ThemeHandle(ThemeHandle
&&) = delete;
63 ThemeHandle
& operator=(const ThemeHandle
&) = delete;
64 ThemeHandle
& operator=(ThemeHandle
&&) = delete;
67 void OpenOnce(HWND aWindow
, LPCWSTR aClassList
);
71 static ThemeHandle sThemes
[eUXNumClasses
];
73 // We initialize sCommandButtonBoxMetrics separately as a performance
74 // optimization to avoid fetching dummy values for sCommandButtonMetrics
75 // when we don't need those.
76 static SIZE sCommandButtonMetrics
[3];
77 static bool sCommandButtonMetricsInitialized
;
78 static SIZE sCommandButtonBoxMetrics
;
79 static bool sCommandButtonBoxMetricsInitialized
;
81 static const wchar_t* GetClassName(nsUXThemeClass
);
82 static void EnsureCommandButtonMetrics();
83 static void EnsureCommandButtonBoxMetrics();
86 static bool sTitlebarInfoPopulatedAero
;
87 static bool sTitlebarInfoPopulatedThemed
;
88 static bool sIsDefaultWindowsTheme
;
89 static bool sIsHighContrastOn
;
91 static void Invalidate();
92 static HANDLE
GetTheme(nsUXThemeClass cls
);
93 static HMODULE
GetThemeDLL();
95 // nsWindow calls this to update desktop settings info
96 static void UpdateTitlebarInfo(HWND aWnd
);
98 static SIZE
GetCommandButtonMetrics(CmdButtonIdx aMetric
) {
99 EnsureCommandButtonMetrics();
100 return sCommandButtonMetrics
[aMetric
];
102 static SIZE
GetCommandButtonBoxMetrics() {
103 EnsureCommandButtonBoxMetrics();
104 return sCommandButtonBoxMetrics
;
106 static void UpdateNativeThemeInfo();
107 static bool IsDefaultWindowTheme();
108 static bool IsHighContrastOn();
110 static bool AreFlatMenusEnabled();
111 static bool IsAppThemed();
113 #endif // __UXThemeData_h__