Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / widget / windows / nsUXThemeData.h
blob24fe07d128057c1886ad3fa649535278c1ea20c8
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 eUXToolbar,
23 eUXProgress,
24 eUXTab,
25 eUXTrackbar,
26 eUXCombobox,
27 eUXHeader,
28 eUXListview,
29 eUXMenu,
30 eUXNumClasses
33 class nsUXThemeData {
34 // This class makes sure we don't attempt to open a theme if the previous
35 // loading attempt has failed because OpenThemeData is a heavy task and
36 // it's less likely that the API returns a different result.
37 class ThemeHandle final {
38 mozilla::Maybe<HANDLE> mHandle;
40 public:
41 ThemeHandle() = default;
42 ~ThemeHandle();
44 // Disallow copy and move
45 ThemeHandle(const ThemeHandle&) = delete;
46 ThemeHandle(ThemeHandle&&) = delete;
47 ThemeHandle& operator=(const ThemeHandle&) = delete;
48 ThemeHandle& operator=(ThemeHandle&&) = delete;
50 operator HANDLE();
51 void OpenOnce(HWND aWindow, LPCWSTR aClassList);
52 void Close();
55 static ThemeHandle sThemes[eUXNumClasses];
56 static const wchar_t* GetClassName(nsUXThemeClass);
58 public:
59 static bool sIsHighContrastOn;
61 static void Invalidate();
62 static HANDLE GetTheme(nsUXThemeClass cls);
63 static HMODULE GetThemeDLL();
65 static void UpdateNativeThemeInfo();
66 static bool IsHighContrastOn() { return sIsHighContrastOn; }
68 #endif // __UXThemeData_h__