Bug 1793629 - Implement attention indicator for the unified extensions button, r...
[gecko.git] / widget / windows / nsUXThemeData.h
blobd7c020083588190a77d7c7f8bf02b51d23d2efe3
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__
9 #include <windows.h>
10 #include <uxtheme.h>
12 #include "nscore.h"
13 #include "mozilla/LookAndFeel.h"
14 #include "mozilla/Maybe.h"
15 #include "WinUtils.h"
17 #include "nsWindowDefs.h"
19 enum nsUXThemeClass {
20 eUXButton = 0,
21 eUXEdit,
22 eUXRebar,
23 eUXMediaRebar,
24 eUXCommunicationsRebar,
25 eUXBrowserTabBarRebar,
26 eUXToolbar,
27 eUXMediaToolbar,
28 eUXCommunicationsToolbar,
29 eUXProgress,
30 eUXTab,
31 eUXTrackbar,
32 eUXSpin,
33 eUXStatus,
34 eUXCombobox,
35 eUXHeader,
36 eUXListview,
37 eUXMenu,
38 eUXWindowFrame,
39 eUXNumClasses
42 enum CmdButtonIdx {
43 CMDBUTTONIDX_MINIMIZE = 0,
44 CMDBUTTONIDX_RESTORE,
45 CMDBUTTONIDX_CLOSE,
46 CMDBUTTONIDX_BUTTONBOX
49 class nsUXThemeData {
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;
56 public:
57 ThemeHandle() = default;
58 ~ThemeHandle();
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;
66 operator HANDLE();
67 void OpenOnce(HWND aWindow, LPCWSTR aClassList);
68 void Close();
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();
85 public:
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__