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