1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim:expandtab:shiftwidth=4:tabstop=4: 3 */ 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 8 #ifndef __nsLookAndFeel 9 #define __nsLookAndFeel 10 11 #include "X11UndefineNone.h" 12 #include "nsXPLookAndFeel.h" 13 #include "nsCOMPtr.h" 14 #include "gfxFont.h" 15 16 struct _GtkStyle; 17 18 class nsLookAndFeel final : public nsXPLookAndFeel { 19 public: 20 nsLookAndFeel(); 21 virtual ~nsLookAndFeel(); 22 23 void NativeInit() final; 24 void RefreshImpl() override; 25 nsresult NativeGetColor(ColorID aID, nscolor& aResult) override; 26 nsresult GetIntImpl(IntID aID, int32_t& aResult) override; 27 nsresult GetFloatImpl(FloatID aID, float& aResult) override; 28 bool GetFontImpl(FontID aID, nsString& aFontName, 29 gfxFontStyle& aFontStyle) override; 30 31 char16_t GetPasswordCharacterImpl() override; 32 bool GetEchoPasswordImpl() override; 33 34 nsTArray<LookAndFeelInt> GetIntCacheImpl() override; 35 void SetIntCacheImpl( 36 const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache) override; 37 IsCSDAvailable()38 bool IsCSDAvailable() const { return mCSDAvailable; } 39 40 static const nscolor kBlack = NS_RGB(0, 0, 0); 41 static const nscolor kWhite = NS_RGB(255, 255, 255); 42 43 protected: 44 // Cached fonts 45 bool mDefaultFontCached = false; 46 bool mButtonFontCached = false; 47 bool mFieldFontCached = false; 48 bool mMenuFontCached = false; 49 nsString mDefaultFontName; 50 nsString mButtonFontName; 51 nsString mFieldFontName; 52 nsString mMenuFontName; 53 gfxFontStyle mDefaultFontStyle; 54 gfxFontStyle mButtonFontStyle; 55 gfxFontStyle mFieldFontStyle; 56 gfxFontStyle mMenuFontStyle; 57 58 // Cached colors 59 nscolor mInfoBackground = kWhite; 60 nscolor mInfoText = kBlack; 61 nscolor mMenuBackground = kWhite; 62 nscolor mMenuBarText = kBlack; 63 nscolor mMenuBarHoverText = kBlack; 64 nscolor mMenuText = kBlack; 65 nscolor mMenuTextInactive = kWhite; 66 nscolor mMenuHover = kWhite; 67 nscolor mMenuHoverText = kBlack; 68 nscolor mButtonDefault = kWhite; 69 nscolor mButtonText = kBlack; 70 nscolor mButtonHoverText = kBlack; 71 nscolor mButtonHoverFace = kWhite; 72 nscolor mButtonActiveText = kBlack; 73 nscolor mFrameOuterLightBorder = kBlack; 74 nscolor mFrameInnerDarkBorder = kBlack; 75 nscolor mOddCellBackground = kWhite; 76 nscolor mNativeHyperLinkText = kBlack; 77 nscolor mComboBoxText = kBlack; 78 nscolor mComboBoxBackground = kWhite; 79 nscolor mFieldText = kBlack; 80 nscolor mFieldBackground = kWhite; 81 nscolor mMozWindowText = kBlack; 82 nscolor mMozWindowBackground = kWhite; 83 nscolor mMozWindowActiveBorder = kBlack; 84 nscolor mMozWindowInactiveBorder = kBlack; 85 nscolor mMozWindowInactiveCaption = kWhite; 86 nscolor mMozCellHighlightBackground = kWhite; 87 nscolor mMozCellHighlightText = kBlack; 88 nscolor mTextSelectedText = kBlack; 89 nscolor mTextSelectedBackground = kWhite; 90 nscolor mMozScrollbar = kWhite; 91 nscolor mInfoBarText = kBlack; 92 char16_t mInvisibleCharacter = 0; 93 float mCaretRatio = 0.0f; 94 int32_t mCaretBlinkTime = 0; 95 bool mMenuSupportsDrag = false; 96 bool mCSDAvailable = false; 97 bool mCSDHideTitlebarByDefault = false; 98 bool mCSDMaximizeButton = false; 99 bool mCSDMinimizeButton = false; 100 bool mCSDCloseButton = false; 101 bool mCSDReversedPlacement = false; 102 bool mSystemUsesDarkTheme = false; 103 bool mPrefersReducedMotion = false; 104 bool mHighContrast = false; 105 bool mInitialized = false; 106 int32_t mCSDMaximizeButtonPosition = 0; 107 int32_t mCSDMinimizeButtonPosition = 0; 108 int32_t mCSDCloseButtonPosition = 0; 109 110 void EnsureInit(); 111 void ConfigureContentGtkTheme(); 112 113 private: 114 nsresult InitCellHighlightColors(); 115 }; 116 117 #endif 118