2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2000-03-30 22:32:18 +00:00
|
|
|
|
|
|
|
#ifndef __nsXPLookAndFeel
|
|
|
|
#define __nsXPLookAndFeel
|
|
|
|
|
2011-09-09 02:27:12 +00:00
|
|
|
#include "mozilla/LookAndFeel.h"
|
2020-11-11 23:26:51 +00:00
|
|
|
#include "mozilla/widget/LookAndFeelTypes.h"
|
2015-04-22 14:58:15 +00:00
|
|
|
#include "nsTArray.h"
|
2000-03-30 22:32:18 +00:00
|
|
|
|
2011-09-09 02:27:11 +00:00
|
|
|
class nsLookAndFeel;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
class nsXPLookAndFeel : public mozilla::LookAndFeel {
|
2000-03-30 22:32:18 +00:00
|
|
|
public:
|
2021-03-24 22:57:36 +00:00
|
|
|
using FullLookAndFeel = mozilla::widget::FullLookAndFeel;
|
|
|
|
using LookAndFeelFont = mozilla::widget::LookAndFeelFont;
|
|
|
|
using LookAndFeelTheme = mozilla::widget::LookAndFeelTheme;
|
|
|
|
|
2000-03-30 22:32:18 +00:00
|
|
|
virtual ~nsXPLookAndFeel();
|
|
|
|
|
2017-04-04 14:22:00 +00:00
|
|
|
static nsXPLookAndFeel* GetInstance();
|
2011-09-09 02:27:11 +00:00
|
|
|
static void Shutdown();
|
|
|
|
|
2000-03-30 22:32:18 +00:00
|
|
|
void Init();
|
|
|
|
|
2020-11-20 23:52:47 +00:00
|
|
|
// These functions will return a value specified by an override pref, if it
|
|
|
|
// exists, and otherwise will call into the NativeGetXxx function to get the
|
|
|
|
// platform-specific value.
|
2000-03-30 22:32:18 +00:00
|
|
|
//
|
2020-11-20 23:52:47 +00:00
|
|
|
// NS_ERROR_NOT_AVAILABLE is returned if there is neither an override pref or
|
|
|
|
// a platform-specific value.
|
2021-04-02 16:34:35 +00:00
|
|
|
nsresult GetColorValue(ColorID, ColorScheme, UseStandins, nscolor& aResult);
|
2020-11-20 23:52:47 +00:00
|
|
|
nsresult GetIntValue(IntID aID, int32_t& aResult);
|
|
|
|
nsresult GetFloatValue(FloatID aID, float& aResult);
|
|
|
|
// Same, but returns false if there is no platform-specific value.
|
|
|
|
// (There are no override prefs for font values.)
|
2021-03-24 22:57:36 +00:00
|
|
|
bool GetFontValue(FontID aID, nsString& aName, gfxFontStyle& aStyle);
|
2020-11-20 23:52:47 +00:00
|
|
|
|
|
|
|
virtual nsresult NativeGetInt(IntID aID, int32_t& aResult) = 0;
|
|
|
|
virtual nsresult NativeGetFloat(FloatID aID, float& aResult) = 0;
|
|
|
|
virtual nsresult NativeGetColor(ColorID aID, nscolor& aResult) = 0;
|
|
|
|
virtual bool NativeGetFont(FontID aID, nsString& aName,
|
|
|
|
gfxFontStyle& aStyle) = 0;
|
2012-02-20 23:19:48 +00:00
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
virtual void RefreshImpl();
|
|
|
|
|
2014-01-04 15:02:17 +00:00
|
|
|
virtual char16_t GetPasswordCharacterImpl() { return char16_t('*'); }
|
2011-09-09 02:27:13 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual bool GetEchoPasswordImpl() { return false; }
|
2000-03-30 22:32:18 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual uint32_t GetPasswordMaskDelayImpl() { return 600; }
|
2012-07-13 02:26:20 +00:00
|
|
|
|
2021-03-24 22:57:36 +00:00
|
|
|
static bool LookAndFeelFontToStyle(const LookAndFeelFont&, nsString& aName,
|
|
|
|
gfxFontStyle&);
|
|
|
|
static LookAndFeelFont StyleToLookAndFeelFont(const nsAString& aName,
|
|
|
|
const gfxFontStyle&);
|
2020-11-11 23:26:51 +00:00
|
|
|
|
2020-12-16 04:17:36 +00:00
|
|
|
virtual void SetDataImpl(FullLookAndFeel&& aTables) {}
|
2015-04-22 14:58:15 +00:00
|
|
|
|
2017-08-03 20:16:31 +00:00
|
|
|
virtual void NativeInit() = 0;
|
|
|
|
|
2020-12-22 19:26:41 +00:00
|
|
|
virtual void WithThemeConfiguredForContent(
|
2021-03-30 08:17:38 +00:00
|
|
|
const std::function<void(const LookAndFeelTheme&, bool aChanged)>& aFn) {
|
|
|
|
aFn(LookAndFeelTheme{}, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Whether the color should be from the parent theme, if the theme differs
|
|
|
|
// between parent and content processes.
|
|
|
|
virtual bool FromParentTheme(IntID) {
|
|
|
|
MOZ_ASSERT_UNREACHABLE(
|
|
|
|
"Should override if WithThemeConfiguredForContent can change the "
|
|
|
|
"theme");
|
|
|
|
return false;
|
2020-12-16 04:41:05 +00:00
|
|
|
}
|
2021-03-30 08:17:38 +00:00
|
|
|
virtual bool FromParentTheme(ColorID) {
|
|
|
|
MOZ_ASSERT_UNREACHABLE(
|
|
|
|
"Should override if WithThemeConfiguredForContent can change the "
|
|
|
|
"theme");
|
|
|
|
return false;
|
|
|
|
}
|
2020-12-16 04:41:05 +00:00
|
|
|
|
2000-03-30 22:32:18 +00:00
|
|
|
protected:
|
2020-01-14 05:50:53 +00:00
|
|
|
nsXPLookAndFeel() = default;
|
2011-09-09 02:27:13 +00:00
|
|
|
|
2021-02-13 03:59:22 +00:00
|
|
|
static nscolor GetStandinForNativeColor(ColorID);
|
2019-12-20 19:05:12 +00:00
|
|
|
void RecordTelemetry();
|
2020-10-15 04:50:48 +00:00
|
|
|
virtual void RecordLookAndFeelSpecificTelemetry() {}
|
2000-03-30 22:32:18 +00:00
|
|
|
|
2013-12-10 23:10:01 +00:00
|
|
|
static void OnPrefChanged(const char* aPref, void* aClosure);
|
2011-09-09 02:27:11 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool sInitialized;
|
2000-03-30 22:32:18 +00:00
|
|
|
|
2017-04-04 14:22:00 +00:00
|
|
|
static nsXPLookAndFeel* sInstance;
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool sShutdown;
|
2011-09-09 02:27:11 +00:00
|
|
|
};
|
2000-03-30 22:32:18 +00:00
|
|
|
|
|
|
|
#endif
|