1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef __nsLookAndFeel
7 #define __nsLookAndFeel
12 #include "nsXPLookAndFeel.h"
14 #include "mozilla/RangedArray.h"
15 #include "nsIWindowsRegKey.h"
18 * Gesture System Metrics
21 # define SM_DIGITIZER 94
22 # define TABLET_CONFIG_NONE 0x00000000
23 # define NID_INTEGRATED_TOUCH 0x00000001
24 # define NID_EXTERNAL_TOUCH 0x00000002
25 # define NID_INTEGRATED_PEN 0x00000004
26 # define NID_EXTERNAL_PEN 0x00000008
27 # define NID_MULTI_INPUT 0x00000040
28 # define NID_READY 0x00000080
32 * Tablet mode detection
34 #ifndef SM_SYSTEMDOCKED
35 # define SM_CONVERTIBLESLATEMODE 0x00002003
36 # define SM_SYSTEMDOCKED 0x00002004
40 * Color constant inclusive bounds for GetSysColor
42 #define SYS_COLOR_MIN 0
43 #define SYS_COLOR_MAX 30
44 #define SYS_COLOR_COUNT (SYS_COLOR_MAX - SYS_COLOR_MIN + 1)
46 class nsLookAndFeel final
: public nsXPLookAndFeel
{
49 virtual ~nsLookAndFeel();
51 void NativeInit() final
;
52 void RefreshImpl() override
;
53 nsresult
NativeGetInt(IntID
, int32_t& aResult
) override
;
54 nsresult
NativeGetFloat(FloatID
, float& aResult
) override
;
55 nsresult
NativeGetColor(ColorID
, ColorScheme
, nscolor
& aResult
) override
;
56 bool NativeGetFont(FontID aID
, nsString
& aFontName
,
57 gfxFontStyle
& aFontStyle
) override
;
58 char16_t
GetPasswordCharacterImpl() override
;
61 struct TitlebarColors
{
62 // NOTE: These are the DWM accent colors, which might not match the
63 // UISettings/UWP accent color in some cases, see bug 1796730.
64 mozilla::Maybe
<nscolor
> mAccent
;
65 mozilla::Maybe
<nscolor
> mAccentText
;
66 mozilla::Maybe
<nscolor
> mAccentInactive
;
67 mozilla::Maybe
<nscolor
> mAccentInactiveText
;
69 bool mUseAccent
= false;
83 const Set
& Get(mozilla::ColorScheme aScheme
, bool aActive
) const {
84 if (aScheme
== mozilla::ColorScheme::Dark
) {
85 return aActive
? mActiveDark
: mInactiveDark
;
87 return aActive
? mActiveLight
: mInactiveLight
;
91 TitlebarColors
ComputeTitlebarColors();
93 nscolor
GetColorForSysColorIndex(int index
);
95 LookAndFeelFont
GetLookAndFeelFontInternal(const LOGFONTW
& aLogFont
,
98 LookAndFeelFont
GetLookAndFeelFont(LookAndFeel::FontID anID
);
100 // Cached colors and flags indicating success in their retrieval.
101 mozilla::Maybe
<nscolor
> mColorMenuHoverText
;
102 mozilla::Maybe
<nscolor
> mColorMediaText
;
103 mozilla::Maybe
<nscolor
> mColorCommunicationsText
;
105 mozilla::Maybe
<nscolor
> mDarkHighlight
;
106 mozilla::Maybe
<nscolor
> mDarkHighlightText
;
108 TitlebarColors mTitlebarColors
;
110 nscolor mColorAccent
= 0;
111 nscolor mColorAccentText
= 0;
113 nscolor mSysColorTable
[SYS_COLOR_COUNT
];
115 bool mInitialized
= false;