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
11 #include "nsXPLookAndFeel.h"
15 * Gesture System Metrics
18 # define SM_DIGITIZER 94
19 # define TABLET_CONFIG_NONE 0x00000000
20 # define NID_INTEGRATED_TOUCH 0x00000001
21 # define NID_EXTERNAL_TOUCH 0x00000002
22 # define NID_INTEGRATED_PEN 0x00000004
23 # define NID_EXTERNAL_PEN 0x00000008
24 # define NID_MULTI_INPUT 0x00000040
25 # define NID_READY 0x00000080
29 * Tablet mode detection
31 #ifndef SM_SYSTEMDOCKED
32 # define SM_CONVERTIBLESLATEMODE 0x00002003
33 # define SM_SYSTEMDOCKED 0x00002004
37 * Color constant inclusive bounds for GetSysColor
39 #define SYS_COLOR_MIN 0
40 #define SYS_COLOR_MAX 30
41 #define SYS_COLOR_COUNT (SYS_COLOR_MAX - SYS_COLOR_MIN + 1)
43 // Undocumented SPI, see bug 1712669 comment 4.
44 #define MOZ_SPI_CURSORSIZE 0x2028
45 #define MOZ_SPI_SETCURSORSIZE 0x2029
47 namespace mozilla::widget::WinRegistry
{
51 class nsLookAndFeel final
: public nsXPLookAndFeel
{
54 virtual ~nsLookAndFeel();
56 void NativeInit() final
;
57 void RefreshImpl() override
;
58 nsresult
NativeGetInt(IntID
, int32_t& aResult
) override
;
59 nsresult
NativeGetFloat(FloatID
, float& aResult
) override
;
60 nsresult
NativeGetColor(ColorID
, ColorScheme
, nscolor
& aResult
) override
;
61 bool NativeGetFont(FontID aID
, nsString
& aFontName
,
62 gfxFontStyle
& aFontStyle
) override
;
63 char16_t
GetPasswordCharacterImpl() override
;
65 nsresult
GetKeyboardLayoutImpl(nsACString
& aLayout
) override
;
68 struct TitlebarColors
{
69 // NOTE: These are the DWM accent colors, which might not match the
70 // UISettings/UWP accent color in some cases, see bug 1796730.
71 mozilla::Maybe
<nscolor
> mAccent
;
72 mozilla::Maybe
<nscolor
> mAccentText
;
73 mozilla::Maybe
<nscolor
> mAccentInactive
;
74 mozilla::Maybe
<nscolor
> mAccentInactiveText
;
76 bool mUseAccent
= false;
90 const Set
& Get(mozilla::ColorScheme aScheme
, bool aActive
) const {
91 if (aScheme
== mozilla::ColorScheme::Dark
) {
92 return aActive
? mActiveDark
: mInactiveDark
;
94 return aActive
? mActiveLight
: mInactiveLight
;
98 TitlebarColors
ComputeTitlebarColors();
100 nscolor
GetColorForSysColorIndex(int index
);
102 LookAndFeelFont
GetLookAndFeelFontInternal(const LOGFONTW
& aLogFont
,
105 uint32_t SystemColorFilter();
107 LookAndFeelFont
GetLookAndFeelFont(LookAndFeel::FontID anID
);
109 // Cached colors and flags indicating success in their retrieval.
110 mozilla::Maybe
<nscolor
> mColorMenuHoverText
;
112 mozilla::Maybe
<nscolor
> mDarkHighlight
;
113 mozilla::Maybe
<nscolor
> mDarkHighlightText
;
115 TitlebarColors mTitlebarColors
;
117 nscolor mColorAccent
= 0;
118 nscolor mColorAccentText
= 0;
120 nscolor mSysColorTable
[SYS_COLOR_COUNT
];
122 mozilla::UniquePtr
<mozilla::widget::WinRegistry::KeyWatcher
>
124 uint32_t mCurrentColorFilter
= 0;
126 bool mInitialized
= false;