Bug 1712669 - Make Windows tooltip margin depend on cursor size. r=yjuglaret,win...
[gecko.git] / widget / windows / nsLookAndFeel.h
blob0ef38bfda5289838e58a511540f9738d1a5bf81c
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
9 #include <windows.h>
11 #include "nsXPLookAndFeel.h"
12 #include "gfxFont.h"
15 * Gesture System Metrics
17 #ifndef SM_DIGITIZER
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
26 #endif
29 * Tablet mode detection
31 #ifndef SM_SYSTEMDOCKED
32 # define SM_CONVERTIBLESLATEMODE 0x00002003
33 # define SM_SYSTEMDOCKED 0x00002004
34 #endif
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 {
48 class KeyWatcher;
51 class nsLookAndFeel final : public nsXPLookAndFeel {
52 public:
53 nsLookAndFeel();
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 private:
66 struct TitlebarColors {
67 // NOTE: These are the DWM accent colors, which might not match the
68 // UISettings/UWP accent color in some cases, see bug 1796730.
69 mozilla::Maybe<nscolor> mAccent;
70 mozilla::Maybe<nscolor> mAccentText;
71 mozilla::Maybe<nscolor> mAccentInactive;
72 mozilla::Maybe<nscolor> mAccentInactiveText;
74 bool mUseAccent = false;
76 struct Set {
77 nscolor mBg = 0;
78 nscolor mFg = 0;
79 nscolor mBorder = 0;
82 Set mActiveLight;
83 Set mActiveDark;
85 Set mInactiveLight;
86 Set mInactiveDark;
88 const Set& Get(mozilla::ColorScheme aScheme, bool aActive) const {
89 if (aScheme == mozilla::ColorScheme::Dark) {
90 return aActive ? mActiveDark : mInactiveDark;
92 return aActive ? mActiveLight : mInactiveLight;
96 TitlebarColors ComputeTitlebarColors();
98 nscolor GetColorForSysColorIndex(int index);
100 LookAndFeelFont GetLookAndFeelFontInternal(const LOGFONTW& aLogFont,
101 bool aUseShellDlg);
103 uint32_t SystemColorFilter();
105 LookAndFeelFont GetLookAndFeelFont(LookAndFeel::FontID anID);
107 // Cached colors and flags indicating success in their retrieval.
108 mozilla::Maybe<nscolor> mColorMenuHoverText;
110 mozilla::Maybe<nscolor> mDarkHighlight;
111 mozilla::Maybe<nscolor> mDarkHighlightText;
113 TitlebarColors mTitlebarColors;
115 nscolor mColorAccent = 0;
116 nscolor mColorAccentText = 0;
118 nscolor mSysColorTable[SYS_COLOR_COUNT];
120 mozilla::UniquePtr<mozilla::widget::WinRegistry::KeyWatcher>
121 mColorFilterWatcher;
122 uint32_t mCurrentColorFilter = 0;
124 bool mInitialized = false;
125 void EnsureInit();
128 #endif