2002-04-27 20:26:10 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim:expandtab:shiftwidth=4:tabstop=4:
|
|
|
|
*/
|
2012-05-21 15:12:37 +04: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/. */
|
2001-12-10 20:37:36 +03:00
|
|
|
|
2012-02-21 03:19:48 +04:00
|
|
|
// for strtod()
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2001-12-10 20:37:36 +03:00
|
|
|
#include "nsLookAndFeel.h"
|
2012-02-21 03:19:48 +04:00
|
|
|
|
2009-01-03 10:37:52 +03:00
|
|
|
#include <gtk/gtk.h>
|
2012-02-21 03:19:48 +04:00
|
|
|
#include <gdk/gdk.h>
|
|
|
|
|
|
|
|
#include <pango/pango.h>
|
|
|
|
#include <pango/pango-fontmap.h>
|
|
|
|
|
|
|
|
#include <fontconfig/fontconfig.h>
|
|
|
|
#include "gfxPlatformGtk.h"
|
2015-04-23 19:35:00 +03:00
|
|
|
#include "nsScreenGtk.h"
|
2001-12-10 20:37:36 +03:00
|
|
|
|
2006-05-02 03:23:33 +04:00
|
|
|
#include "gtkdrawing.h"
|
2011-03-31 16:26:49 +04:00
|
|
|
#include "nsStyleConsts.h"
|
2013-10-08 03:15:59 +04:00
|
|
|
#include "gfxFontConstants.h"
|
2015-04-29 23:29:34 +03:00
|
|
|
#include "WidgetUtils.h"
|
2015-01-21 07:53:00 +03:00
|
|
|
|
|
|
|
#include <dlfcn.h>
|
|
|
|
|
2013-10-08 03:15:59 +04:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2006-05-02 03:23:33 +04:00
|
|
|
|
2016-03-18 12:49:46 +03:00
|
|
|
#if MOZ_WIDGET_GTK != 2
|
|
|
|
#include <cairo-gobject.h>
|
2016-06-07 07:11:51 +03:00
|
|
|
#include "WidgetStyleCache.h"
|
2016-08-05 16:21:00 +03:00
|
|
|
#include "prenv.h"
|
2016-03-18 12:49:46 +03:00
|
|
|
#endif
|
|
|
|
|
2012-02-21 03:19:48 +04:00
|
|
|
using mozilla::LookAndFeel;
|
|
|
|
|
2001-12-10 20:37:36 +03:00
|
|
|
#define GDK_COLOR_TO_NS_RGB(c) \
|
|
|
|
((nscolor) NS_RGB(c.red>>8, c.green>>8, c.blue>>8))
|
2013-05-30 03:26:40 +04:00
|
|
|
#define GDK_RGBA_TO_NS_RGBA(c) \
|
|
|
|
((nscolor) NS_RGBA((int)((c).red*255), (int)((c).green*255), \
|
|
|
|
(int)((c).blue*255), (int)((c).alpha*255)))
|
2001-12-10 20:37:36 +03:00
|
|
|
|
2012-02-21 03:19:48 +04:00
|
|
|
nsLookAndFeel::nsLookAndFeel()
|
|
|
|
: nsXPLookAndFeel(),
|
2013-05-30 03:26:40 +04:00
|
|
|
#if (MOZ_WIDGET_GTK == 2)
|
2012-07-30 18:20:58 +04:00
|
|
|
mStyle(nullptr),
|
2013-05-30 03:26:40 +04:00
|
|
|
#endif
|
2012-02-21 03:19:48 +04:00
|
|
|
mDefaultFontCached(false), mButtonFontCached(false),
|
|
|
|
mFieldFontCached(false), mMenuFontCached(false)
|
2001-12-10 20:37:36 +03:00
|
|
|
{
|
2013-05-30 03:26:40 +04:00
|
|
|
Init();
|
2001-12-10 20:37:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsLookAndFeel::~nsLookAndFeel()
|
|
|
|
{
|
2013-05-30 03:26:40 +04:00
|
|
|
#if (MOZ_WIDGET_GTK == 2)
|
2009-04-17 00:55:12 +04:00
|
|
|
g_object_unref(mStyle);
|
2013-05-30 03:26:40 +04:00
|
|
|
#endif
|
2001-12-10 20:37:36 +03:00
|
|
|
}
|
|
|
|
|
2016-03-18 12:49:46 +03:00
|
|
|
#if MOZ_WIDGET_GTK != 2
|
2017-01-03 03:08:07 +03:00
|
|
|
// Modifies color |*aDest| as if a pattern of color |aSource| was painted with
|
|
|
|
// CAIRO_OPERATOR_OVER to a surface with color |*aDest|.
|
|
|
|
static void
|
|
|
|
ApplyColorOver(const GdkRGBA& aSource, GdkRGBA* aDest) {
|
|
|
|
gdouble sourceCoef = aSource.alpha;
|
|
|
|
gdouble destCoef = aDest->alpha * (1.0 - sourceCoef);
|
|
|
|
gdouble resultAlpha = sourceCoef + destCoef;
|
|
|
|
if (resultAlpha != 0.0) { // don't divide by zero
|
|
|
|
destCoef /= resultAlpha;
|
|
|
|
sourceCoef /= resultAlpha;
|
|
|
|
aDest->red = sourceCoef * aSource.red + destCoef * aDest->red;
|
|
|
|
aDest->green = sourceCoef * aSource.green + destCoef * aDest->green;
|
|
|
|
aDest->blue = sourceCoef * aSource.blue + destCoef * aDest->blue;
|
2017-01-03 22:43:20 +03:00
|
|
|
aDest->alpha = resultAlpha;
|
2017-01-03 03:08:07 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-18 12:49:46 +03:00
|
|
|
static void
|
|
|
|
GetLightAndDarkness(const GdkRGBA& aColor,
|
|
|
|
double* aLightness, double* aDarkness)
|
|
|
|
{
|
|
|
|
double sum = aColor.red + aColor.green + aColor.blue;
|
|
|
|
*aLightness = sum * aColor.alpha;
|
|
|
|
*aDarkness = (3.0 - sum) * aColor.alpha;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
GetGradientColors(const GValue* aValue,
|
|
|
|
GdkRGBA* aLightColor, GdkRGBA* aDarkColor)
|
|
|
|
{
|
|
|
|
if (!G_TYPE_CHECK_VALUE_TYPE(aValue, CAIRO_GOBJECT_TYPE_PATTERN))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
auto pattern = static_cast<cairo_pattern_t*>(g_value_get_boxed(aValue));
|
2016-03-29 07:50:47 +03:00
|
|
|
if (!pattern)
|
|
|
|
return false;
|
2016-03-18 12:49:46 +03:00
|
|
|
|
|
|
|
// Just picking the lightest and darkest colors as simple samples rather
|
|
|
|
// than trying to blend, which could get messy if there are many stops.
|
|
|
|
if (CAIRO_STATUS_SUCCESS !=
|
|
|
|
cairo_pattern_get_color_stop_rgba(pattern, 0, nullptr, &aDarkColor->red,
|
|
|
|
&aDarkColor->green, &aDarkColor->blue,
|
|
|
|
&aDarkColor->alpha))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
double maxLightness, maxDarkness;
|
|
|
|
GetLightAndDarkness(*aDarkColor, &maxLightness, &maxDarkness);
|
|
|
|
*aLightColor = *aDarkColor;
|
|
|
|
|
|
|
|
GdkRGBA stop;
|
|
|
|
for (int index = 1;
|
|
|
|
CAIRO_STATUS_SUCCESS ==
|
|
|
|
cairo_pattern_get_color_stop_rgba(pattern, index, nullptr,
|
|
|
|
&stop.red, &stop.green,
|
|
|
|
&stop.blue, &stop.alpha);
|
|
|
|
++index) {
|
|
|
|
double lightness, darkness;
|
|
|
|
GetLightAndDarkness(stop, &lightness, &darkness);
|
|
|
|
if (lightness > maxLightness) {
|
|
|
|
maxLightness = lightness;
|
|
|
|
*aLightColor = stop;
|
|
|
|
}
|
|
|
|
if (darkness > maxDarkness) {
|
|
|
|
maxDarkness = darkness;
|
|
|
|
*aDarkColor = stop;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
GetUnicoBorderGradientColors(GtkStyleContext* aContext,
|
|
|
|
GdkRGBA* aLightColor, GdkRGBA* aDarkColor)
|
|
|
|
{
|
|
|
|
// Ubuntu 12.04 has GTK engine Unico-1.0.2, which overrides render_frame,
|
|
|
|
// providing its own border code. Ubuntu 14.04 has
|
|
|
|
// Unico-1.0.3+14.04.20140109, which does not override render_frame, and
|
|
|
|
// so does not need special attention. The earlier Unico can be detected
|
|
|
|
// by the -unico-border-gradient style property it registers.
|
|
|
|
// gtk_style_properties_lookup_property() is checked first to avoid the
|
|
|
|
// warning from gtk_style_context_get_property() when the property does
|
|
|
|
// not exist. (gtk_render_frame() of GTK+ 3.16 no longer uses the
|
|
|
|
// engine.)
|
|
|
|
const char* propertyName = "-unico-border-gradient";
|
|
|
|
if (!gtk_style_properties_lookup_property(propertyName, nullptr, nullptr))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// -unico-border-gradient is used only when the CSS node's engine is Unico.
|
|
|
|
GtkThemingEngine* engine;
|
|
|
|
GtkStateFlags state = gtk_style_context_get_state(aContext);
|
|
|
|
gtk_style_context_get(aContext, state, "engine", &engine, nullptr);
|
|
|
|
if (strcmp(g_type_name(G_TYPE_FROM_INSTANCE(engine)), "UnicoEngine") != 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// draw_border() of Unico engine uses -unico-border-gradient
|
|
|
|
// in preference to border-color.
|
|
|
|
GValue value = G_VALUE_INIT;
|
|
|
|
gtk_style_context_get_property(aContext, propertyName, state, &value);
|
|
|
|
|
|
|
|
bool result = GetGradientColors(&value, aLightColor, aDarkColor);
|
|
|
|
|
|
|
|
g_value_unset(&value);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-11-21 08:07:48 +03:00
|
|
|
// Sets |aLightColor| and |aDarkColor| to colors from |aContext|. Returns
|
|
|
|
// true if |aContext| uses these colors to render a visible border.
|
|
|
|
// If returning false, then the colors returned are a fallback from the
|
|
|
|
// border-color value even though |aContext| does not use these colors to
|
|
|
|
// render a border.
|
|
|
|
static bool
|
2016-03-18 12:49:46 +03:00
|
|
|
GetBorderColors(GtkStyleContext* aContext,
|
|
|
|
GdkRGBA* aLightColor, GdkRGBA* aDarkColor)
|
|
|
|
{
|
2016-11-21 08:07:48 +03:00
|
|
|
// Determine whether the border on this style context is visible.
|
2016-03-18 12:49:46 +03:00
|
|
|
GtkStateFlags state = gtk_style_context_get_state(aContext);
|
2016-11-21 08:07:48 +03:00
|
|
|
GtkBorderStyle borderStyle;
|
|
|
|
gtk_style_context_get(aContext, state, GTK_STYLE_PROPERTY_BORDER_STYLE,
|
|
|
|
&borderStyle, nullptr);
|
|
|
|
bool visible = borderStyle != GTK_BORDER_STYLE_NONE &&
|
|
|
|
borderStyle != GTK_BORDER_STYLE_HIDDEN;
|
|
|
|
if (visible) {
|
|
|
|
// GTK has an initial value of zero for border-widths, and so themes
|
|
|
|
// need to explicitly set border-widths to make borders visible.
|
|
|
|
GtkBorder border;
|
|
|
|
gtk_style_context_get_border(aContext, GTK_STATE_FLAG_NORMAL, &border);
|
|
|
|
visible = border.top != 0 || border.right != 0 ||
|
|
|
|
border.bottom != 0 || border.left != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (visible &&
|
|
|
|
GetUnicoBorderGradientColors(aContext, aLightColor, aDarkColor))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// The initial value for the border-color is the foreground color, and so
|
|
|
|
// this will usually return a color distinct from the background even if
|
|
|
|
// there is no visible border detected.
|
2016-03-18 12:49:46 +03:00
|
|
|
gtk_style_context_get_border_color(aContext, state, aDarkColor);
|
|
|
|
// TODO GTK3 - update aLightColor
|
|
|
|
// for GTK_BORDER_STYLE_INSET/OUTSET/GROVE/RIDGE border styles.
|
|
|
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=978172#c25
|
|
|
|
*aLightColor = *aDarkColor;
|
2016-11-21 08:07:48 +03:00
|
|
|
return visible;
|
2016-03-18 12:49:46 +03:00
|
|
|
}
|
|
|
|
|
2016-11-21 08:07:48 +03:00
|
|
|
static bool
|
2016-03-18 12:49:46 +03:00
|
|
|
GetBorderColors(GtkStyleContext* aContext,
|
|
|
|
nscolor* aLightColor, nscolor* aDarkColor)
|
|
|
|
{
|
|
|
|
GdkRGBA lightColor, darkColor;
|
2016-11-21 08:07:48 +03:00
|
|
|
bool ret = GetBorderColors(aContext, &lightColor, &darkColor);
|
2016-03-18 12:49:46 +03:00
|
|
|
*aLightColor = GDK_RGBA_TO_NS_RGBA(lightColor);
|
|
|
|
*aDarkColor = GDK_RGBA_TO_NS_RGBA(darkColor);
|
2016-11-21 08:07:48 +03:00
|
|
|
return ret;
|
2016-03-18 12:49:46 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-09-09 06:27:13 +04:00
|
|
|
nsresult
|
|
|
|
nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor)
|
2001-12-10 20:37:36 +03:00
|
|
|
{
|
2013-05-30 03:26:40 +04:00
|
|
|
#if (MOZ_WIDGET_GTK == 3)
|
|
|
|
GdkRGBA gdk_color;
|
|
|
|
#endif
|
2002-04-27 20:26:10 +04:00
|
|
|
nsresult res = NS_OK;
|
|
|
|
|
|
|
|
switch (aID) {
|
2004-01-31 01:57:07 +03:00
|
|
|
// These colors don't seem to be used for anything anymore in Mozilla
|
|
|
|
// (except here at least TextSelectBackground and TextSelectForeground)
|
|
|
|
// The CSS2 colors below are used.
|
2013-05-30 03:26:40 +04:00
|
|
|
#if (MOZ_WIDGET_GTK == 2)
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_WindowBackground:
|
2005-02-16 16:07:13 +03:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->base[GTK_STATE_NORMAL]);
|
2002-04-27 20:26:10 +04:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_WindowForeground:
|
2005-03-09 00:54:34 +03:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->text[GTK_STATE_NORMAL]);
|
2002-04-27 20:26:10 +04:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_WidgetBackground:
|
2002-04-27 20:26:10 +04:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_NORMAL]);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_WidgetForeground:
|
2002-04-27 20:26:10 +04:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->fg[GTK_STATE_NORMAL]);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_WidgetSelectBackground:
|
2002-04-27 20:26:10 +04:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_SELECTED]);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_WidgetSelectForeground:
|
2002-04-27 20:26:10 +04:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->fg[GTK_STATE_SELECTED]);
|
|
|
|
break;
|
2013-05-30 03:26:40 +04:00
|
|
|
#else
|
|
|
|
case eColorID_WindowBackground:
|
|
|
|
case eColorID_WidgetBackground:
|
|
|
|
case eColorID_TextBackground:
|
|
|
|
case eColorID_activecaption: // active window caption background
|
|
|
|
case eColorID_appworkspace: // MDI background color
|
|
|
|
case eColorID_background: // desktop background
|
|
|
|
case eColorID_window:
|
|
|
|
case eColorID_windowframe:
|
|
|
|
case eColorID__moz_dialog:
|
2015-05-05 16:08:00 +03:00
|
|
|
case eColorID__moz_combobox:
|
2013-05-30 03:26:40 +04:00
|
|
|
aColor = sMozWindowBackground;
|
|
|
|
break;
|
|
|
|
case eColorID_WindowForeground:
|
|
|
|
case eColorID_WidgetForeground:
|
|
|
|
case eColorID_TextForeground:
|
|
|
|
case eColorID_captiontext: // text in active window caption, size box, and scrollbar arrow box (!)
|
|
|
|
case eColorID_windowtext:
|
|
|
|
case eColorID__moz_dialogtext:
|
|
|
|
aColor = sMozWindowText;
|
|
|
|
break;
|
|
|
|
case eColorID_WidgetSelectBackground:
|
|
|
|
case eColorID_TextSelectBackground:
|
|
|
|
case eColorID_IMESelectedRawTextBackground:
|
|
|
|
case eColorID_IMESelectedConvertedTextBackground:
|
|
|
|
case eColorID__moz_dragtargetzone:
|
2014-12-08 09:35:00 +03:00
|
|
|
case eColorID__moz_cellhighlight:
|
|
|
|
case eColorID__moz_html_cellhighlight:
|
|
|
|
case eColorID_highlight: // preference selected item,
|
|
|
|
aColor = sTextSelectedBackground;
|
2013-05-30 03:26:40 +04:00
|
|
|
break;
|
|
|
|
case eColorID_WidgetSelectForeground:
|
|
|
|
case eColorID_TextSelectForeground:
|
|
|
|
case eColorID_IMESelectedRawTextForeground:
|
|
|
|
case eColorID_IMESelectedConvertedTextForeground:
|
2014-12-08 09:35:00 +03:00
|
|
|
case eColorID_highlighttext:
|
|
|
|
case eColorID__moz_cellhighlighttext:
|
|
|
|
case eColorID__moz_html_cellhighlighttext:
|
|
|
|
aColor = sTextSelectedText;
|
2013-05-30 03:26:40 +04:00
|
|
|
break;
|
|
|
|
#endif
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_Widget3DHighlight:
|
2002-04-27 20:26:10 +04:00
|
|
|
aColor = NS_RGB(0xa0,0xa0,0xa0);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_Widget3DShadow:
|
2002-04-27 20:26:10 +04:00
|
|
|
aColor = NS_RGB(0x40,0x40,0x40);
|
|
|
|
break;
|
2013-05-30 03:26:40 +04:00
|
|
|
#if (MOZ_WIDGET_GTK == 2)
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_TextBackground:
|
2004-01-31 01:57:07 +03:00
|
|
|
// not used?
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->base[GTK_STATE_NORMAL]);
|
2002-04-27 20:26:10 +04:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_TextForeground:
|
2004-01-31 01:57:07 +03:00
|
|
|
// not used?
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->text[GTK_STATE_NORMAL]);
|
2002-04-27 20:26:10 +04:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_TextSelectBackground:
|
|
|
|
case eColorID_IMESelectedRawTextBackground:
|
|
|
|
case eColorID_IMESelectedConvertedTextBackground:
|
2004-01-31 01:57:07 +03:00
|
|
|
// still used
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->base[GTK_STATE_SELECTED]);
|
2002-04-27 20:26:10 +04:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_TextSelectForeground:
|
|
|
|
case eColorID_IMESelectedRawTextForeground:
|
|
|
|
case eColorID_IMESelectedConvertedTextForeground:
|
2004-01-31 01:57:07 +03:00
|
|
|
// still used
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->text[GTK_STATE_SELECTED]);
|
2002-04-27 20:26:10 +04:00
|
|
|
break;
|
2013-05-30 03:26:40 +04:00
|
|
|
#endif
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_IMERawInputBackground:
|
|
|
|
case eColorID_IMEConvertedTextBackground:
|
2005-09-17 15:34:27 +04:00
|
|
|
aColor = NS_TRANSPARENT;
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_IMERawInputForeground:
|
|
|
|
case eColorID_IMEConvertedTextForeground:
|
2005-09-17 15:34:27 +04:00
|
|
|
aColor = NS_SAME_AS_FOREGROUND_COLOR;
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_IMERawInputUnderline:
|
|
|
|
case eColorID_IMEConvertedTextUnderline:
|
2005-09-17 15:34:27 +04:00
|
|
|
aColor = NS_SAME_AS_FOREGROUND_COLOR;
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_IMESelectedRawTextUnderline:
|
|
|
|
case eColorID_IMESelectedConvertedTextUnderline:
|
2005-09-17 15:34:27 +04:00
|
|
|
aColor = NS_TRANSPARENT;
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_SpellCheckerUnderline:
|
2009-04-03 11:26:28 +04:00
|
|
|
aColor = NS_RGB(0xff, 0, 0);
|
|
|
|
break;
|
2002-04-27 20:26:10 +04:00
|
|
|
|
2013-05-30 03:26:40 +04:00
|
|
|
#if (MOZ_WIDGET_GTK == 2)
|
2002-04-27 20:26:10 +04:00
|
|
|
// css2 http://www.w3.org/TR/REC-CSS2/ui.html#system-colors
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_activeborder:
|
2002-04-27 20:26:10 +04:00
|
|
|
// active window border
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_NORMAL]);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_activecaption:
|
2002-04-27 20:26:10 +04:00
|
|
|
// active window caption background
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_NORMAL]);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_appworkspace:
|
2002-04-27 20:26:10 +04:00
|
|
|
// MDI background color
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_NORMAL]);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_background:
|
2002-04-27 20:26:10 +04:00
|
|
|
// desktop background
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_NORMAL]);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_captiontext:
|
2002-04-27 20:26:10 +04:00
|
|
|
// text in active window caption, size box, and scrollbar arrow box (!)
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->fg[GTK_STATE_NORMAL]);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_graytext:
|
2004-03-04 07:55:31 +03:00
|
|
|
// disabled text in windows, menus, etc.
|
2002-04-27 20:26:10 +04:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->fg[GTK_STATE_INSENSITIVE]);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_highlight:
|
2002-04-27 20:26:10 +04:00
|
|
|
// background of selected item
|
2004-10-26 05:45:28 +04:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->base[GTK_STATE_SELECTED]);
|
2002-04-27 20:26:10 +04:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_highlighttext:
|
2002-04-27 20:26:10 +04:00
|
|
|
// text of selected item
|
2004-10-26 05:45:28 +04:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->text[GTK_STATE_SELECTED]);
|
2002-04-27 20:26:10 +04:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_inactiveborder:
|
2002-04-27 20:26:10 +04:00
|
|
|
// inactive window border
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_NORMAL]);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_inactivecaption:
|
2002-04-27 20:26:10 +04:00
|
|
|
// inactive window caption
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_INSENSITIVE]);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_inactivecaptiontext:
|
2002-04-27 20:26:10 +04:00
|
|
|
// text in inactive window caption
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->fg[GTK_STATE_INSENSITIVE]);
|
|
|
|
break;
|
2013-05-30 03:26:40 +04:00
|
|
|
#else
|
|
|
|
// css2 http://www.w3.org/TR/REC-CSS2/ui.html#system-colors
|
2016-11-23 04:00:00 +03:00
|
|
|
case eColorID_activeborder: {
|
2013-05-30 03:26:40 +04:00
|
|
|
// active window border
|
2016-11-23 04:00:00 +03:00
|
|
|
GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_WINDOW);
|
|
|
|
gtk_style_context_get_border_color(style,
|
2013-05-30 03:26:40 +04:00
|
|
|
GTK_STATE_FLAG_NORMAL, &gdk_color);
|
|
|
|
aColor = GDK_RGBA_TO_NS_RGBA(gdk_color);
|
2016-11-23 04:00:00 +03:00
|
|
|
ReleaseStyleContext(style);
|
2013-05-30 03:26:40 +04:00
|
|
|
break;
|
2016-11-23 04:00:00 +03:00
|
|
|
}
|
|
|
|
case eColorID_inactiveborder: {
|
2013-05-30 03:26:40 +04:00
|
|
|
// inactive window border
|
2016-11-23 04:00:00 +03:00
|
|
|
GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_WINDOW);
|
|
|
|
gtk_style_context_get_border_color(style,
|
|
|
|
GTK_STATE_FLAG_INSENSITIVE,
|
2013-05-30 03:26:40 +04:00
|
|
|
&gdk_color);
|
|
|
|
aColor = GDK_RGBA_TO_NS_RGBA(gdk_color);
|
2016-11-23 04:00:00 +03:00
|
|
|
ReleaseStyleContext(style);
|
2013-05-30 03:26:40 +04:00
|
|
|
break;
|
2016-11-23 04:00:00 +03:00
|
|
|
}
|
2013-05-30 03:26:40 +04:00
|
|
|
case eColorID_graytext: // disabled text in windows, menus, etc.
|
|
|
|
case eColorID_inactivecaptiontext: // text in inactive window caption
|
2015-05-29 12:40:00 +03:00
|
|
|
aColor = sMenuTextInactive;
|
2013-05-30 03:26:40 +04:00
|
|
|
break;
|
2016-11-23 04:00:00 +03:00
|
|
|
case eColorID_inactivecaption: {
|
2013-05-30 03:26:40 +04:00
|
|
|
// inactive window caption
|
2016-11-23 04:00:00 +03:00
|
|
|
GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_WINDOW);
|
|
|
|
gtk_style_context_get_background_color(style,
|
2013-05-30 03:26:40 +04:00
|
|
|
GTK_STATE_FLAG_INSENSITIVE,
|
|
|
|
&gdk_color);
|
|
|
|
aColor = GDK_RGBA_TO_NS_RGBA(gdk_color);
|
2016-11-23 04:00:00 +03:00
|
|
|
ReleaseStyleContext(style);
|
2013-05-30 03:26:40 +04:00
|
|
|
break;
|
2016-11-23 04:00:00 +03:00
|
|
|
}
|
2013-05-30 03:26:40 +04:00
|
|
|
#endif
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_infobackground:
|
2002-04-27 20:26:10 +04:00
|
|
|
// tooltip background color
|
|
|
|
aColor = sInfoBackground;
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_infotext:
|
2002-04-27 20:26:10 +04:00
|
|
|
// tooltip text color
|
|
|
|
aColor = sInfoText;
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_menu:
|
2002-04-27 20:26:10 +04:00
|
|
|
// menu background
|
|
|
|
aColor = sMenuBackground;
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_menutext:
|
2002-04-27 20:26:10 +04:00
|
|
|
// menu text
|
|
|
|
aColor = sMenuText;
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_scrollbar:
|
2002-04-27 20:26:10 +04:00
|
|
|
// scrollbar gray area
|
2013-05-30 03:26:40 +04:00
|
|
|
#if (MOZ_WIDGET_GTK == 2)
|
2002-04-27 20:26:10 +04:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_ACTIVE]);
|
2013-05-30 03:26:40 +04:00
|
|
|
#else
|
|
|
|
aColor = sMozScrollbar;
|
|
|
|
#endif
|
2002-04-27 20:26:10 +04:00
|
|
|
break;
|
|
|
|
|
2014-11-27 06:08:00 +03:00
|
|
|
case eColorID_threedlightshadow:
|
|
|
|
// 3-D highlighted inner edge color
|
|
|
|
// always same as background in GTK code
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_threedface:
|
|
|
|
case eColorID_buttonface:
|
2002-04-27 20:26:10 +04:00
|
|
|
// 3-D face color
|
2014-11-27 06:08:00 +03:00
|
|
|
#if (MOZ_WIDGET_GTK == 3)
|
|
|
|
aColor = sMozWindowBackground;
|
|
|
|
#else
|
|
|
|
aColor = sButtonBackground;
|
|
|
|
#endif
|
2002-04-27 20:26:10 +04:00
|
|
|
break;
|
|
|
|
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_buttontext:
|
2002-04-27 20:26:10 +04:00
|
|
|
// text on push buttons
|
|
|
|
aColor = sButtonText;
|
|
|
|
break;
|
|
|
|
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_buttonhighlight:
|
2002-04-27 20:26:10 +04:00
|
|
|
// 3-D highlighted edge color
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_threedhighlight:
|
2002-04-27 20:26:10 +04:00
|
|
|
// 3-D highlighted outer edge color
|
2014-06-24 09:28:00 +04:00
|
|
|
aColor = sFrameOuterLightBorder;
|
2002-04-27 20:26:10 +04:00
|
|
|
break;
|
|
|
|
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_buttonshadow:
|
2002-04-27 20:26:10 +04:00
|
|
|
// 3-D shadow edge color
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_threedshadow:
|
2002-04-27 20:26:10 +04:00
|
|
|
// 3-D shadow inner edge color
|
2014-06-24 09:28:00 +04:00
|
|
|
aColor = sFrameInnerDarkBorder;
|
2002-04-27 20:26:10 +04:00
|
|
|
break;
|
|
|
|
|
2013-05-30 03:26:40 +04:00
|
|
|
#if (MOZ_WIDGET_GTK == 2)
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_threeddarkshadow:
|
2002-04-27 20:26:10 +04:00
|
|
|
// 3-D shadow outer edge color
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->black);
|
|
|
|
break;
|
|
|
|
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_window:
|
|
|
|
case eColorID_windowframe:
|
2002-04-27 20:26:10 +04:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_NORMAL]);
|
|
|
|
break;
|
|
|
|
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_windowtext:
|
2002-04-27 20:26:10 +04:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->fg[GTK_STATE_NORMAL]);
|
|
|
|
break;
|
|
|
|
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_eventreerow:
|
|
|
|
case eColorID__moz_field:
|
2002-04-27 20:26:10 +04:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->base[GTK_STATE_NORMAL]);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_fieldtext:
|
2004-01-31 01:57:07 +03:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->text[GTK_STATE_NORMAL]);
|
2002-04-27 20:26:10 +04:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_dialog:
|
2002-04-27 20:26:10 +04:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_NORMAL]);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_dialogtext:
|
2002-04-27 20:26:10 +04:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->fg[GTK_STATE_NORMAL]);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_dragtargetzone:
|
2002-04-27 20:26:10 +04:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_SELECTED]);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_buttondefault:
|
2003-06-19 01:16:29 +04:00
|
|
|
// default button border color
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->black);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_buttonhoverface:
|
2004-10-26 05:45:28 +04:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_PRELIGHT]);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_buttonhovertext:
|
2004-06-01 05:58:10 +04:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->fg[GTK_STATE_PRELIGHT]);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_cellhighlight:
|
|
|
|
case eColorID__moz_html_cellhighlight:
|
2004-10-26 05:45:28 +04:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->base[GTK_STATE_ACTIVE]);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_cellhighlighttext:
|
|
|
|
case eColorID__moz_html_cellhighlighttext:
|
2004-10-26 05:45:28 +04:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->text[GTK_STATE_ACTIVE]);
|
|
|
|
break;
|
2013-05-30 03:26:40 +04:00
|
|
|
#else
|
|
|
|
case eColorID_threeddarkshadow:
|
|
|
|
// Hardcode to black
|
2016-01-22 18:58:49 +03:00
|
|
|
aColor = NS_RGB(0x00,0x00,0x00);
|
2013-05-30 03:26:40 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColorID__moz_eventreerow:
|
|
|
|
case eColorID__moz_field:
|
|
|
|
aColor = sMozFieldBackground;
|
|
|
|
break;
|
|
|
|
case eColorID__moz_fieldtext:
|
|
|
|
aColor = sMozFieldText;
|
|
|
|
break;
|
2016-11-23 04:00:00 +03:00
|
|
|
case eColorID__moz_buttondefault: {
|
|
|
|
// default button border color
|
|
|
|
GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_BUTTON);
|
|
|
|
gtk_style_context_get_border_color(style,
|
2013-05-30 03:26:40 +04:00
|
|
|
GTK_STATE_FLAG_NORMAL, &gdk_color);
|
|
|
|
aColor = GDK_RGBA_TO_NS_RGBA(gdk_color);
|
2016-11-23 04:00:00 +03:00
|
|
|
ReleaseStyleContext(style);
|
2013-05-30 03:26:40 +04:00
|
|
|
break;
|
2016-11-23 04:00:00 +03:00
|
|
|
}
|
|
|
|
case eColorID__moz_buttonhoverface: {
|
|
|
|
GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_BUTTON);
|
|
|
|
gtk_style_context_get_background_color(style,
|
2013-05-30 03:26:40 +04:00
|
|
|
GTK_STATE_FLAG_PRELIGHT,
|
|
|
|
&gdk_color);
|
|
|
|
aColor = GDK_RGBA_TO_NS_RGBA(gdk_color);
|
2016-11-23 04:00:00 +03:00
|
|
|
ReleaseStyleContext(style);
|
2013-05-30 03:26:40 +04:00
|
|
|
break;
|
2016-11-23 04:00:00 +03:00
|
|
|
}
|
2013-05-30 03:26:40 +04:00
|
|
|
case eColorID__moz_buttonhovertext:
|
2014-04-02 19:47:55 +04:00
|
|
|
aColor = sButtonHoverText;
|
2013-05-30 03:26:40 +04:00
|
|
|
break;
|
|
|
|
#endif
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_menuhover:
|
2004-10-26 05:45:28 +04:00
|
|
|
aColor = sMenuHover;
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_menuhovertext:
|
2004-10-26 05:45:28 +04:00
|
|
|
aColor = sMenuHoverText;
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_oddtreerow:
|
2008-04-12 16:13:32 +04:00
|
|
|
aColor = sOddCellBackground;
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_nativehyperlinktext:
|
2008-07-11 22:34:53 +04:00
|
|
|
aColor = sNativeHyperLinkText;
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_comboboxtext:
|
2009-01-16 11:18:49 +03:00
|
|
|
aColor = sComboBoxText;
|
|
|
|
break;
|
2015-05-05 16:08:00 +03:00
|
|
|
#if (MOZ_WIDGET_GTK == 2)
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_combobox:
|
2009-01-16 11:18:49 +03:00
|
|
|
aColor = sComboBoxBackground;
|
|
|
|
break;
|
2015-05-05 16:08:00 +03:00
|
|
|
#endif
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_menubartext:
|
2009-06-15 01:58:14 +04:00
|
|
|
aColor = sMenuBarText;
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_menubarhovertext:
|
2009-06-15 01:58:14 +04:00
|
|
|
aColor = sMenuBarHoverText;
|
|
|
|
break;
|
2015-08-19 22:42:17 +03:00
|
|
|
case eColorID__moz_gtk_info_bar_text:
|
|
|
|
#if (MOZ_WIDGET_GTK == 3)
|
|
|
|
aColor = sInfoBarText;
|
|
|
|
#else
|
|
|
|
aColor = sInfoText;
|
|
|
|
#endif
|
|
|
|
break;
|
2002-04-27 20:26:10 +04:00
|
|
|
default:
|
|
|
|
/* default color is BLACK */
|
|
|
|
aColor = 0;
|
|
|
|
res = NS_ERROR_FAILURE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
2001-12-10 20:37:36 +03:00
|
|
|
}
|
|
|
|
|
2013-05-30 03:26:40 +04:00
|
|
|
#if (MOZ_WIDGET_GTK == 2)
|
2008-04-12 16:13:32 +04:00
|
|
|
static void darken_gdk_color(GdkColor *src, GdkColor *dest)
|
|
|
|
{
|
|
|
|
gdouble red;
|
|
|
|
gdouble green;
|
|
|
|
gdouble blue;
|
|
|
|
|
|
|
|
red = (gdouble) src->red / 65535.0;
|
|
|
|
green = (gdouble) src->green / 65535.0;
|
|
|
|
blue = (gdouble) src->blue / 65535.0;
|
|
|
|
|
|
|
|
red *= 0.93;
|
|
|
|
green *= 0.93;
|
|
|
|
blue *= 0.93;
|
|
|
|
|
|
|
|
dest->red = red * 65535.0;
|
|
|
|
dest->green = green * 65535.0;
|
|
|
|
dest->blue = blue * 65535.0;
|
|
|
|
}
|
2013-05-30 03:26:40 +04:00
|
|
|
#endif
|
2008-04-12 16:13:32 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static int32_t CheckWidgetStyle(GtkWidget* aWidget, const char* aStyle, int32_t aResult) {
|
2011-10-03 11:56:21 +04:00
|
|
|
gboolean value = FALSE;
|
2013-10-08 22:47:37 +04:00
|
|
|
gtk_widget_style_get(aWidget, aStyle, &value, nullptr);
|
2011-09-09 06:27:13 +04:00
|
|
|
return value ? aResult : 0;
|
2006-05-02 03:23:33 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static int32_t ConvertGTKStepperStyleToMozillaScrollArrowStyle(GtkWidget* aWidget)
|
2006-05-02 03:23:33 +04:00
|
|
|
{
|
|
|
|
if (!aWidget)
|
2011-09-09 06:27:13 +04:00
|
|
|
return mozilla::LookAndFeel::eScrollArrowStyle_Single;
|
2006-05-02 03:23:33 +04:00
|
|
|
|
|
|
|
return
|
|
|
|
CheckWidgetStyle(aWidget, "has-backward-stepper",
|
2011-09-09 06:27:13 +04:00
|
|
|
mozilla::LookAndFeel::eScrollArrow_StartBackward) |
|
2006-05-02 03:23:33 +04:00
|
|
|
CheckWidgetStyle(aWidget, "has-forward-stepper",
|
2011-09-09 06:27:13 +04:00
|
|
|
mozilla::LookAndFeel::eScrollArrow_EndForward) |
|
2006-05-02 03:23:33 +04:00
|
|
|
CheckWidgetStyle(aWidget, "has-secondary-backward-stepper",
|
2011-09-09 06:27:13 +04:00
|
|
|
mozilla::LookAndFeel::eScrollArrow_EndBackward) |
|
2006-05-02 03:23:33 +04:00
|
|
|
CheckWidgetStyle(aWidget, "has-secondary-forward-stepper",
|
2011-09-09 06:27:13 +04:00
|
|
|
mozilla::LookAndFeel::eScrollArrow_StartForward);
|
2006-05-02 03:23:33 +04:00
|
|
|
}
|
|
|
|
|
2011-09-09 06:27:13 +04:00
|
|
|
nsresult
|
2012-08-22 19:56:38 +04:00
|
|
|
nsLookAndFeel::GetIntImpl(IntID aID, int32_t &aResult)
|
2001-12-10 20:37:36 +03:00
|
|
|
{
|
2002-04-27 20:26:10 +04:00
|
|
|
nsresult res = NS_OK;
|
|
|
|
|
2006-07-20 02:13:18 +04:00
|
|
|
// Set these before they can get overrided in the nsXPLookAndFeel.
|
|
|
|
switch (aID) {
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_ScrollButtonLeftMouseButtonAction:
|
|
|
|
aResult = 0;
|
2006-07-20 02:13:18 +04:00
|
|
|
return NS_OK;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_ScrollButtonMiddleMouseButtonAction:
|
|
|
|
aResult = 1;
|
2006-07-20 02:13:18 +04:00
|
|
|
return NS_OK;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_ScrollButtonRightMouseButtonAction:
|
|
|
|
aResult = 2;
|
2006-07-20 02:13:18 +04:00
|
|
|
return NS_OK;
|
2008-01-01 13:21:28 +03:00
|
|
|
default:
|
|
|
|
break;
|
2006-07-20 02:13:18 +04:00
|
|
|
}
|
|
|
|
|
2011-09-09 06:27:13 +04:00
|
|
|
res = nsXPLookAndFeel::GetIntImpl(aID, aResult);
|
2002-04-27 20:26:10 +04:00
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
return res;
|
|
|
|
res = NS_OK;
|
|
|
|
|
|
|
|
switch (aID) {
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_CaretBlinkTime:
|
2006-04-20 00:03:30 +04:00
|
|
|
{
|
|
|
|
GtkSettings *settings;
|
|
|
|
gint blink_time;
|
|
|
|
gboolean blink;
|
|
|
|
|
|
|
|
settings = gtk_settings_get_default ();
|
|
|
|
g_object_get (settings,
|
|
|
|
"gtk-cursor-blink-time", &blink_time,
|
|
|
|
"gtk-cursor-blink", &blink,
|
2013-10-08 22:47:37 +04:00
|
|
|
nullptr);
|
2006-04-20 00:03:30 +04:00
|
|
|
|
|
|
|
if (blink)
|
2012-08-22 19:56:38 +04:00
|
|
|
aResult = (int32_t) blink_time;
|
2006-04-20 00:03:30 +04:00
|
|
|
else
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = 0;
|
2006-04-20 00:03:30 +04:00
|
|
|
break;
|
|
|
|
}
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_CaretWidth:
|
|
|
|
aResult = 1;
|
2002-04-27 20:26:10 +04:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_ShowCaretDuringSelection:
|
|
|
|
aResult = 0;
|
2002-04-27 20:26:10 +04:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_SelectTextfieldsOnKeyFocus:
|
2005-02-18 09:13:33 +03:00
|
|
|
{
|
|
|
|
GtkWidget *entry;
|
|
|
|
GtkSettings *settings;
|
|
|
|
gboolean select_on_focus;
|
|
|
|
|
|
|
|
entry = gtk_entry_new();
|
2011-05-16 13:07:37 +04:00
|
|
|
g_object_ref_sink(entry);
|
2005-02-18 09:13:33 +03:00
|
|
|
settings = gtk_widget_get_settings(entry);
|
|
|
|
g_object_get(settings,
|
|
|
|
"gtk-entry-select-on-focus",
|
|
|
|
&select_on_focus,
|
2013-10-08 22:47:37 +04:00
|
|
|
nullptr);
|
2005-02-18 09:13:33 +03:00
|
|
|
|
|
|
|
if(select_on_focus)
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = 1;
|
2005-02-18 09:13:33 +03:00
|
|
|
else
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = 0;
|
2005-02-18 09:13:33 +03:00
|
|
|
|
|
|
|
gtk_widget_destroy(entry);
|
2009-02-02 20:49:58 +03:00
|
|
|
g_object_unref(entry);
|
2005-02-18 09:13:33 +03:00
|
|
|
}
|
2003-05-02 22:20:38 +04:00
|
|
|
break;
|
2014-08-10 13:05:51 +04:00
|
|
|
case eIntID_ScrollToClick:
|
|
|
|
{
|
|
|
|
GtkSettings *settings;
|
|
|
|
gboolean warps_slider = FALSE;
|
|
|
|
|
|
|
|
settings = gtk_settings_get_default ();
|
|
|
|
if (g_object_class_find_property (G_OBJECT_GET_CLASS(settings),
|
|
|
|
"gtk-primary-button-warps-slider")) {
|
|
|
|
g_object_get (settings,
|
|
|
|
"gtk-primary-button-warps-slider",
|
|
|
|
&warps_slider,
|
|
|
|
nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (warps_slider)
|
|
|
|
aResult = 1;
|
|
|
|
else
|
|
|
|
aResult = 0;
|
|
|
|
}
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_SubmenuDelay:
|
2006-04-20 00:03:30 +04:00
|
|
|
{
|
|
|
|
GtkSettings *settings;
|
|
|
|
gint delay;
|
|
|
|
|
|
|
|
settings = gtk_settings_get_default ();
|
2013-10-08 22:47:37 +04:00
|
|
|
g_object_get (settings, "gtk-menu-popup-delay", &delay, nullptr);
|
2012-08-22 19:56:38 +04:00
|
|
|
aResult = (int32_t) delay;
|
2006-04-20 00:03:30 +04:00
|
|
|
break;
|
|
|
|
}
|
2011-12-16 13:18:48 +04:00
|
|
|
case eIntID_TooltipDelay:
|
|
|
|
{
|
|
|
|
aResult = 500;
|
|
|
|
break;
|
|
|
|
}
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_MenusCanOverlapOSBar:
|
2002-04-27 20:26:10 +04:00
|
|
|
// we want XUL popups to be able to overlap the task bar.
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = 1;
|
2002-04-27 20:26:10 +04:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_SkipNavigatingDisabledMenuItem:
|
|
|
|
aResult = 1;
|
2006-03-17 06:55:10 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_DragThresholdX:
|
|
|
|
case eIntID_DragThresholdY:
|
2003-05-02 22:20:38 +04:00
|
|
|
{
|
|
|
|
GtkWidget* box = gtk_hbox_new(FALSE, 5);
|
|
|
|
gint threshold = 0;
|
|
|
|
g_object_get(gtk_widget_get_settings(box),
|
|
|
|
"gtk-dnd-drag-threshold", &threshold,
|
2013-10-08 22:47:37 +04:00
|
|
|
nullptr);
|
2011-05-16 13:07:37 +04:00
|
|
|
g_object_ref_sink(box);
|
2009-02-04 16:21:02 +03:00
|
|
|
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = threshold;
|
2003-05-02 22:20:38 +04:00
|
|
|
}
|
|
|
|
break;
|
2017-03-21 07:14:55 +03:00
|
|
|
case eIntID_ScrollArrowStyle: {
|
|
|
|
GtkWidget* scrollbar = GetWidget(MOZ_GTK_SCROLLBAR_HORIZONTAL);
|
|
|
|
aResult = ConvertGTKStepperStyleToMozillaScrollArrowStyle(scrollbar);
|
2002-04-27 20:26:10 +04:00
|
|
|
break;
|
2017-03-21 07:14:55 +03:00
|
|
|
}
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_ScrollSliderStyle:
|
|
|
|
aResult = eScrollThumbStyle_Proportional;
|
2002-04-27 20:26:10 +04:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_TreeOpenDelay:
|
|
|
|
aResult = 1000;
|
2003-03-17 02:26:31 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_TreeCloseDelay:
|
|
|
|
aResult = 1000;
|
2003-03-17 02:26:31 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_TreeLazyScrollDelay:
|
|
|
|
aResult = 150;
|
2003-03-17 02:26:31 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_TreeScrollDelay:
|
|
|
|
aResult = 100;
|
2003-03-17 02:26:31 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_TreeScrollLinesMax:
|
|
|
|
aResult = 3;
|
2003-03-17 02:26:31 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_DWMCompositor:
|
|
|
|
case eIntID_WindowsClassic:
|
|
|
|
case eIntID_WindowsDefaultTheme:
|
|
|
|
case eIntID_WindowsThemeIdentifier:
|
2013-07-01 20:02:29 +04:00
|
|
|
case eIntID_OperatingSystemVersionIdentifier:
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = 0;
|
2009-10-05 05:31:25 +04:00
|
|
|
res = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_TouchEnabled:
|
2015-04-29 23:29:34 +03:00
|
|
|
#if MOZ_WIDGET_GTK == 3
|
|
|
|
aResult = mozilla::widget::WidgetUtils::IsTouchDeviceSupportPresent();
|
|
|
|
break;
|
|
|
|
#else
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = 0;
|
2009-10-05 05:31:26 +04:00
|
|
|
res = NS_ERROR_NOT_IMPLEMENTED;
|
2015-04-29 23:29:34 +03:00
|
|
|
#endif
|
2008-04-08 22:36:53 +04:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_MacGraphiteTheme:
|
|
|
|
aResult = 0;
|
2008-09-17 20:23:58 +04:00
|
|
|
res = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
break;
|
2013-03-18 17:24:54 +04:00
|
|
|
case eIntID_AlertNotificationOrigin:
|
|
|
|
aResult = NS_ALERT_TOP;
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_IMERawInputUnderlineStyle:
|
|
|
|
case eIntID_IMEConvertedTextUnderlineStyle:
|
|
|
|
aResult = NS_STYLE_TEXT_DECORATION_STYLE_SOLID;
|
2007-08-17 00:35:18 +04:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_IMESelectedRawTextUnderlineStyle:
|
|
|
|
case eIntID_IMESelectedConvertedTextUnderline:
|
|
|
|
aResult = NS_STYLE_TEXT_DECORATION_STYLE_NONE;
|
2007-08-17 00:35:18 +04:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_SpellCheckerUnderlineStyle:
|
|
|
|
aResult = NS_STYLE_TEXT_DECORATION_STYLE_WAVY;
|
2009-04-03 11:26:28 +04:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_MenuBarDrag:
|
|
|
|
aResult = sMenuSupportsDrag;
|
2010-07-17 12:11:54 +04:00
|
|
|
break;
|
2011-11-18 03:41:35 +04:00
|
|
|
case eIntID_ScrollbarButtonAutoRepeatBehavior:
|
|
|
|
aResult = 1;
|
|
|
|
break;
|
2013-04-09 23:44:01 +04:00
|
|
|
case eIntID_SwipeAnimationEnabled:
|
|
|
|
aResult = 0;
|
|
|
|
break;
|
2013-11-11 07:07:59 +04:00
|
|
|
case eIntID_ColorPickerAvailable:
|
|
|
|
aResult = 1;
|
|
|
|
break;
|
2015-08-04 23:41:00 +03:00
|
|
|
case eIntID_ContextMenuOffsetVertical:
|
|
|
|
case eIntID_ContextMenuOffsetHorizontal:
|
|
|
|
aResult = 2;
|
|
|
|
break;
|
2002-04-27 20:26:10 +04:00
|
|
|
default:
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = 0;
|
2002-04-27 20:26:10 +04:00
|
|
|
res = NS_ERROR_FAILURE;
|
|
|
|
}
|
2001-12-10 20:37:36 +03:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2011-09-09 06:27:13 +04:00
|
|
|
nsresult
|
|
|
|
nsLookAndFeel::GetFloatImpl(FloatID aID, float &aResult)
|
2001-12-10 20:37:36 +03:00
|
|
|
{
|
2002-04-27 20:26:10 +04:00
|
|
|
nsresult res = NS_OK;
|
2011-09-09 06:27:13 +04:00
|
|
|
res = nsXPLookAndFeel::GetFloatImpl(aID, aResult);
|
2002-04-27 20:26:10 +04:00
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
return res;
|
|
|
|
res = NS_OK;
|
|
|
|
|
|
|
|
switch (aID) {
|
2011-09-09 06:27:13 +04:00
|
|
|
case eFloatID_IMEUnderlineRelativeSize:
|
|
|
|
aResult = 1.0f;
|
2005-09-17 15:34:27 +04:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eFloatID_SpellCheckerUnderlineRelativeSize:
|
|
|
|
aResult = 1.0f;
|
2009-04-03 11:26:28 +04:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eFloatID_CaretAspectRatio:
|
|
|
|
aResult = sCaretRatio;
|
2008-06-23 12:50:52 +04:00
|
|
|
break;
|
2002-04-27 20:26:10 +04:00
|
|
|
default:
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = -1.0;
|
2002-04-27 20:26:10 +04:00
|
|
|
res = NS_ERROR_FAILURE;
|
|
|
|
}
|
2001-12-10 20:37:36 +03:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2012-02-21 03:19:48 +04:00
|
|
|
static void
|
|
|
|
GetSystemFontInfo(GtkWidget *aWidget,
|
|
|
|
nsString *aFontName,
|
|
|
|
gfxFontStyle *aFontStyle)
|
|
|
|
{
|
|
|
|
GtkSettings *settings = gtk_widget_get_settings(aWidget);
|
|
|
|
|
2012-03-15 13:04:46 +04:00
|
|
|
aFontStyle->style = NS_FONT_STYLE_NORMAL;
|
2012-02-21 03:19:48 +04:00
|
|
|
|
|
|
|
gchar *fontname;
|
2013-10-08 22:47:37 +04:00
|
|
|
g_object_get(settings, "gtk-font-name", &fontname, nullptr);
|
2012-02-21 03:19:48 +04:00
|
|
|
|
|
|
|
PangoFontDescription *desc;
|
|
|
|
desc = pango_font_description_from_string(fontname);
|
|
|
|
|
|
|
|
aFontStyle->systemFont = true;
|
|
|
|
|
|
|
|
g_free(fontname);
|
|
|
|
|
|
|
|
NS_NAMED_LITERAL_STRING(quote, "\"");
|
|
|
|
NS_ConvertUTF8toUTF16 family(pango_font_description_get_family(desc));
|
|
|
|
*aFontName = quote + family + quote;
|
|
|
|
|
|
|
|
aFontStyle->weight = pango_font_description_get_weight(desc);
|
|
|
|
|
|
|
|
// FIXME: Set aFontStyle->stretch correctly!
|
|
|
|
aFontStyle->stretch = NS_FONT_STRETCH_NORMAL;
|
|
|
|
|
|
|
|
float size = float(pango_font_description_get_size(desc)) / PANGO_SCALE;
|
|
|
|
|
|
|
|
// |size| is now either pixels or pango-points (not Mozilla-points!)
|
|
|
|
|
|
|
|
if (!pango_font_description_get_size_is_absolute(desc)) {
|
|
|
|
// |size| is in pango-points, so convert to pixels.
|
|
|
|
size *= float(gfxPlatformGtk::GetDPI()) / POINTS_PER_INCH_FLOAT;
|
|
|
|
}
|
|
|
|
|
2015-01-21 07:53:00 +03:00
|
|
|
// Scale fonts up on HiDPI displays.
|
|
|
|
// This would be done automatically with cairo, but we manually manage
|
|
|
|
// the display scale for platform consistency.
|
2015-04-23 19:35:00 +03:00
|
|
|
size *= nsScreenGtk::GetGtkMonitorScaleFactor();
|
2015-01-21 07:53:00 +03:00
|
|
|
|
2012-02-21 03:19:48 +04:00
|
|
|
// |size| is now pixels
|
|
|
|
|
|
|
|
aFontStyle->size = size;
|
|
|
|
|
|
|
|
pango_font_description_free(desc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
GetSystemFontInfo(LookAndFeel::FontID aID,
|
|
|
|
nsString *aFontName,
|
|
|
|
gfxFontStyle *aFontStyle)
|
|
|
|
{
|
|
|
|
if (aID == LookAndFeel::eFont_Widget) {
|
|
|
|
GtkWidget *label = gtk_label_new("M");
|
|
|
|
GtkWidget *parent = gtk_fixed_new();
|
|
|
|
GtkWidget *window = gtk_window_new(GTK_WINDOW_POPUP);
|
|
|
|
|
|
|
|
gtk_container_add(GTK_CONTAINER(parent), label);
|
|
|
|
gtk_container_add(GTK_CONTAINER(window), parent);
|
|
|
|
|
|
|
|
gtk_widget_ensure_style(label);
|
|
|
|
GetSystemFontInfo(label, aFontName, aFontStyle);
|
|
|
|
gtk_widget_destroy(window); // no unref, windows are different
|
|
|
|
|
|
|
|
} else if (aID == LookAndFeel::eFont_Button) {
|
|
|
|
GtkWidget *label = gtk_label_new("M");
|
|
|
|
GtkWidget *parent = gtk_fixed_new();
|
|
|
|
GtkWidget *button = gtk_button_new();
|
|
|
|
GtkWidget *window = gtk_window_new(GTK_WINDOW_POPUP);
|
|
|
|
|
|
|
|
gtk_container_add(GTK_CONTAINER(button), label);
|
|
|
|
gtk_container_add(GTK_CONTAINER(parent), button);
|
|
|
|
gtk_container_add(GTK_CONTAINER(window), parent);
|
|
|
|
|
|
|
|
gtk_widget_ensure_style(label);
|
|
|
|
GetSystemFontInfo(label, aFontName, aFontStyle);
|
|
|
|
gtk_widget_destroy(window); // no unref, windows are different
|
|
|
|
|
|
|
|
} else if (aID == LookAndFeel::eFont_Field) {
|
|
|
|
GtkWidget *entry = gtk_entry_new();
|
|
|
|
GtkWidget *parent = gtk_fixed_new();
|
|
|
|
GtkWidget *window = gtk_window_new(GTK_WINDOW_POPUP);
|
|
|
|
|
|
|
|
gtk_container_add(GTK_CONTAINER(parent), entry);
|
|
|
|
gtk_container_add(GTK_CONTAINER(window), parent);
|
|
|
|
|
|
|
|
gtk_widget_ensure_style(entry);
|
|
|
|
GetSystemFontInfo(entry, aFontName, aFontStyle);
|
|
|
|
gtk_widget_destroy(window); // no unref, windows are different
|
|
|
|
|
|
|
|
} else {
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(aID == LookAndFeel::eFont_Menu, "unexpected font ID");
|
2012-02-21 03:19:48 +04:00
|
|
|
GtkWidget *accel_label = gtk_accel_label_new("M");
|
|
|
|
GtkWidget *menuitem = gtk_menu_item_new();
|
|
|
|
GtkWidget *menu = gtk_menu_new();
|
2013-05-30 03:26:40 +04:00
|
|
|
g_object_ref_sink(menu);
|
2012-02-21 03:19:48 +04:00
|
|
|
|
|
|
|
gtk_container_add(GTK_CONTAINER(menuitem), accel_label);
|
|
|
|
gtk_menu_shell_append((GtkMenuShell *)GTK_MENU(menu), menuitem);
|
|
|
|
|
|
|
|
gtk_widget_ensure_style(accel_label);
|
|
|
|
GetSystemFontInfo(accel_label, aFontName, aFontStyle);
|
|
|
|
g_object_unref(menu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsLookAndFeel::GetFontImpl(FontID aID, nsString& aFontName,
|
2012-09-29 15:35:08 +04:00
|
|
|
gfxFontStyle& aFontStyle,
|
|
|
|
float aDevPixPerCSSPixel)
|
2012-02-21 03:19:48 +04:00
|
|
|
{
|
2013-10-08 22:47:37 +04:00
|
|
|
nsString *cachedFontName = nullptr;
|
|
|
|
gfxFontStyle *cachedFontStyle = nullptr;
|
|
|
|
bool *isCached = nullptr;
|
2012-02-21 03:19:48 +04:00
|
|
|
|
|
|
|
switch (aID) {
|
|
|
|
case eFont_Menu: // css2
|
|
|
|
case eFont_PullDownMenu: // css3
|
|
|
|
cachedFontName = &mMenuFontName;
|
|
|
|
cachedFontStyle = &mMenuFontStyle;
|
|
|
|
isCached = &mMenuFontCached;
|
|
|
|
aID = eFont_Menu;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eFont_Field: // css3
|
|
|
|
case eFont_List: // css3
|
|
|
|
cachedFontName = &mFieldFontName;
|
|
|
|
cachedFontStyle = &mFieldFontStyle;
|
|
|
|
isCached = &mFieldFontCached;
|
|
|
|
aID = eFont_Field;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eFont_Button: // css3
|
|
|
|
cachedFontName = &mButtonFontName;
|
|
|
|
cachedFontStyle = &mButtonFontStyle;
|
|
|
|
isCached = &mButtonFontCached;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eFont_Caption: // css2
|
|
|
|
case eFont_Icon: // css2
|
|
|
|
case eFont_MessageBox: // css2
|
|
|
|
case eFont_SmallCaption: // css2
|
|
|
|
case eFont_StatusBar: // css2
|
|
|
|
case eFont_Window: // css3
|
|
|
|
case eFont_Document: // css3
|
|
|
|
case eFont_Workspace: // css3
|
|
|
|
case eFont_Desktop: // css3
|
|
|
|
case eFont_Info: // css3
|
|
|
|
case eFont_Dialog: // css3
|
|
|
|
case eFont_Tooltips: // moz
|
|
|
|
case eFont_Widget: // moz
|
|
|
|
cachedFontName = &mDefaultFontName;
|
|
|
|
cachedFontStyle = &mDefaultFontStyle;
|
|
|
|
isCached = &mDefaultFontCached;
|
|
|
|
aID = eFont_Widget;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!*isCached) {
|
|
|
|
GetSystemFontInfo(aID, cachedFontName, cachedFontStyle);
|
|
|
|
*isCached = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
aFontName = *cachedFontName;
|
|
|
|
aFontStyle = *cachedFontStyle;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2001-12-10 20:37:36 +03:00
|
|
|
void
|
2013-05-30 03:26:40 +04:00
|
|
|
nsLookAndFeel::Init()
|
2001-12-10 20:37:36 +03:00
|
|
|
{
|
2013-05-30 03:26:40 +04:00
|
|
|
GdkColor colorValue;
|
|
|
|
GdkColor *colorValuePtr;
|
2002-04-27 20:26:10 +04:00
|
|
|
|
2013-05-30 03:26:40 +04:00
|
|
|
#if (MOZ_WIDGET_GTK == 2)
|
|
|
|
NS_ASSERTION(!mStyle, "already initialized");
|
|
|
|
// GtkInvisibles come with a refcount that is not floating
|
|
|
|
// (since their initialization code calls g_object_ref_sink) and
|
|
|
|
// their destroy code releases that reference (which means they
|
|
|
|
// have to be explicitly destroyed, since calling unref enough
|
|
|
|
// to cause destruction would lead to *another* unref).
|
|
|
|
// However, this combination means that it's actually still ok
|
|
|
|
// to use the normal pattern, which is to g_object_ref_sink
|
|
|
|
// after construction, and then destroy *and* unref when we're
|
|
|
|
// done. (Though we could skip the g_object_ref_sink and the
|
|
|
|
// corresponding g_object_unref, but that's particular to
|
|
|
|
// GtkInvisibles and GtkWindows.)
|
|
|
|
GtkWidget *widget = gtk_invisible_new();
|
|
|
|
g_object_ref_sink(widget); // effectively g_object_ref (see above)
|
|
|
|
|
|
|
|
gtk_widget_ensure_style(widget);
|
|
|
|
mStyle = gtk_style_copy(gtk_widget_get_style(widget));
|
|
|
|
|
|
|
|
gtk_widget_destroy(widget);
|
|
|
|
g_object_unref(widget);
|
|
|
|
|
2002-04-27 20:26:10 +04:00
|
|
|
// tooltip foreground and background
|
2013-05-30 03:26:40 +04:00
|
|
|
GtkStyle *style = gtk_rc_get_style_by_paths(gtk_settings_get_default(),
|
|
|
|
"gtk-tooltips", "GtkWindow",
|
|
|
|
GTK_TYPE_WINDOW);
|
2007-01-11 12:26:47 +03:00
|
|
|
if (style) {
|
|
|
|
sInfoBackground = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_NORMAL]);
|
|
|
|
sInfoText = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]);
|
|
|
|
}
|
2001-12-10 20:37:36 +03:00
|
|
|
|
2002-04-27 20:26:10 +04:00
|
|
|
// menu foreground & menu background
|
|
|
|
GtkWidget *accel_label = gtk_accel_label_new("M");
|
|
|
|
GtkWidget *menuitem = gtk_menu_item_new();
|
|
|
|
GtkWidget *menu = gtk_menu_new();
|
2009-06-15 01:58:14 +04:00
|
|
|
|
2011-05-16 13:07:37 +04:00
|
|
|
g_object_ref_sink(menu);
|
2001-12-10 20:37:36 +03:00
|
|
|
|
2002-04-27 20:26:10 +04:00
|
|
|
gtk_container_add(GTK_CONTAINER(menuitem), accel_label);
|
2009-06-15 01:58:14 +04:00
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
2001-12-10 20:37:36 +03:00
|
|
|
|
2013-10-08 22:47:37 +04:00
|
|
|
gtk_widget_set_style(accel_label, nullptr);
|
|
|
|
gtk_widget_set_style(menu, nullptr);
|
2002-04-27 20:26:10 +04:00
|
|
|
gtk_widget_realize(menu);
|
|
|
|
gtk_widget_realize(accel_label);
|
2001-12-10 20:37:36 +03:00
|
|
|
|
2002-04-27 20:26:10 +04:00
|
|
|
style = gtk_widget_get_style(accel_label);
|
2007-01-11 12:26:47 +03:00
|
|
|
if (style) {
|
|
|
|
sMenuText = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]);
|
|
|
|
}
|
2001-12-10 20:37:36 +03:00
|
|
|
|
2002-04-27 20:26:10 +04:00
|
|
|
style = gtk_widget_get_style(menu);
|
2007-01-11 12:26:47 +03:00
|
|
|
if (style) {
|
|
|
|
sMenuBackground = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_NORMAL]);
|
|
|
|
}
|
2004-10-26 05:45:28 +04:00
|
|
|
|
|
|
|
style = gtk_widget_get_style(menuitem);
|
2007-01-11 12:26:47 +03:00
|
|
|
if (style) {
|
|
|
|
sMenuHover = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_PRELIGHT]);
|
|
|
|
sMenuHoverText = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_PRELIGHT]);
|
|
|
|
}
|
2001-12-10 20:37:36 +03:00
|
|
|
|
2009-02-02 20:49:58 +03:00
|
|
|
g_object_unref(menu);
|
2013-05-30 03:26:40 +04:00
|
|
|
#else
|
|
|
|
GdkRGBA color;
|
2013-06-04 16:23:29 +04:00
|
|
|
GtkStyleContext *style;
|
2013-05-30 03:26:40 +04:00
|
|
|
|
2014-02-24 19:09:55 +04:00
|
|
|
// Gtk manages a screen's CSS in the settings object so we
|
2014-12-08 09:35:00 +03:00
|
|
|
// ask Gtk to create it explicitly. Otherwise we may end up
|
2014-02-24 19:09:55 +04:00
|
|
|
// with wrong color theme, see Bug 972382
|
2016-04-29 11:14:29 +03:00
|
|
|
GtkSettings *settings = gtk_settings_get_for_screen(gdk_screen_get_default());
|
|
|
|
|
2016-07-28 09:35:17 +03:00
|
|
|
// Disable dark theme because it interacts poorly with widget styling in
|
|
|
|
// web content (see bug 1216658).
|
|
|
|
// To avoid triggering reload of theme settings unnecessarily, only set the
|
|
|
|
// setting when necessary.
|
|
|
|
const gchar* dark_setting = "gtk-application-prefer-dark-theme";
|
|
|
|
gboolean dark;
|
|
|
|
g_object_get(settings, dark_setting, &dark, nullptr);
|
|
|
|
|
2016-08-05 16:21:00 +03:00
|
|
|
if (dark && !PR_GetEnv("MOZ_ALLOW_GTK_DARK_THEME")) {
|
2016-07-28 09:35:17 +03:00
|
|
|
g_object_set(settings, dark_setting, FALSE, nullptr);
|
2016-04-29 11:14:29 +03:00
|
|
|
}
|
2014-02-24 19:09:55 +04:00
|
|
|
|
2013-05-30 03:26:40 +04:00
|
|
|
// Scrollbar colors
|
2016-11-23 04:00:00 +03:00
|
|
|
style = ClaimStyleContext(MOZ_GTK_SCROLLBAR_TROUGH_VERTICAL);
|
2013-05-30 03:26:40 +04:00
|
|
|
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
|
|
|
|
sMozScrollbar = GDK_RGBA_TO_NS_RGBA(color);
|
2016-11-23 04:00:00 +03:00
|
|
|
ReleaseStyleContext(style);
|
2013-05-30 03:26:40 +04:00
|
|
|
|
|
|
|
// Window colors
|
2016-11-23 04:00:00 +03:00
|
|
|
style = ClaimStyleContext(MOZ_GTK_WINDOW);
|
2013-05-30 03:26:40 +04:00
|
|
|
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
|
|
|
|
sMozWindowBackground = GDK_RGBA_TO_NS_RGBA(color);
|
|
|
|
gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
|
|
|
|
sMozWindowText = GDK_RGBA_TO_NS_RGBA(color);
|
2016-11-23 04:00:00 +03:00
|
|
|
ReleaseStyleContext(style);
|
2013-05-30 03:26:40 +04:00
|
|
|
|
|
|
|
// tooltip foreground and background
|
2016-06-07 07:11:51 +03:00
|
|
|
style = ClaimStyleContext(MOZ_GTK_TOOLTIP);
|
2013-05-30 03:26:40 +04:00
|
|
|
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
|
|
|
|
sInfoBackground = GDK_RGBA_TO_NS_RGBA(color);
|
2016-11-24 05:14:58 +03:00
|
|
|
ReleaseStyleContext(style);
|
|
|
|
|
|
|
|
style = ClaimStyleContext(MOZ_GTK_TOOLTIP_BOX_LABEL);
|
|
|
|
gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
|
2013-05-30 03:26:40 +04:00
|
|
|
sInfoText = GDK_RGBA_TO_NS_RGBA(color);
|
2016-06-07 07:11:51 +03:00
|
|
|
ReleaseStyleContext(style);
|
2013-05-30 03:26:40 +04:00
|
|
|
|
2016-12-01 13:09:00 +03:00
|
|
|
style = ClaimStyleContext(MOZ_GTK_MENUITEM);
|
|
|
|
{
|
|
|
|
GtkStyleContext* accelStyle =
|
|
|
|
CreateStyleForWidget(gtk_accel_label_new("M"), style);
|
|
|
|
gtk_style_context_get_color(accelStyle, GTK_STATE_FLAG_NORMAL, &color);
|
|
|
|
sMenuText = GDK_RGBA_TO_NS_RGBA(color);
|
|
|
|
gtk_style_context_get_color(accelStyle, GTK_STATE_FLAG_INSENSITIVE, &color);
|
|
|
|
sMenuTextInactive = GDK_RGBA_TO_NS_RGBA(color);
|
|
|
|
g_object_unref(accelStyle);
|
|
|
|
}
|
|
|
|
ReleaseStyleContext(style);
|
2013-05-30 03:26:40 +04:00
|
|
|
|
2016-11-23 06:29:00 +03:00
|
|
|
style = ClaimStyleContext(MOZ_GTK_MENUPOPUP);
|
2013-05-30 03:26:40 +04:00
|
|
|
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
|
|
|
|
sMenuBackground = GDK_RGBA_TO_NS_RGBA(color);
|
2016-11-23 06:29:00 +03:00
|
|
|
ReleaseStyleContext(style);
|
2013-05-30 03:26:40 +04:00
|
|
|
|
2016-11-23 06:29:00 +03:00
|
|
|
style = ClaimStyleContext(MOZ_GTK_MENUITEM);
|
2013-05-30 03:26:40 +04:00
|
|
|
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_PRELIGHT, &color);
|
|
|
|
sMenuHover = GDK_RGBA_TO_NS_RGBA(color);
|
|
|
|
gtk_style_context_get_color(style, GTK_STATE_FLAG_PRELIGHT, &color);
|
|
|
|
sMenuHoverText = GDK_RGBA_TO_NS_RGBA(color);
|
2016-11-23 06:29:00 +03:00
|
|
|
ReleaseStyleContext(style);
|
2013-05-30 03:26:40 +04:00
|
|
|
#endif
|
2001-12-10 20:37:36 +03:00
|
|
|
|
2002-04-27 20:26:10 +04:00
|
|
|
// button styles
|
|
|
|
GtkWidget *parent = gtk_fixed_new();
|
|
|
|
GtkWidget *button = gtk_button_new();
|
|
|
|
GtkWidget *label = gtk_label_new("M");
|
2014-04-02 19:47:55 +04:00
|
|
|
#if (MOZ_WIDGET_GTK == 2)
|
2009-01-16 11:18:49 +03:00
|
|
|
GtkWidget *combobox = gtk_combo_box_new();
|
|
|
|
GtkWidget *comboboxLabel = gtk_label_new("M");
|
2014-04-02 19:47:55 +04:00
|
|
|
gtk_container_add(GTK_CONTAINER(combobox), comboboxLabel);
|
|
|
|
#endif
|
2002-04-27 20:26:10 +04:00
|
|
|
GtkWidget *window = gtk_window_new(GTK_WINDOW_POPUP);
|
2008-04-12 16:13:32 +04:00
|
|
|
GtkWidget *treeView = gtk_tree_view_new();
|
2008-07-11 22:34:53 +04:00
|
|
|
GtkWidget *linkButton = gtk_link_button_new("http://example.com/");
|
2009-06-15 01:58:14 +04:00
|
|
|
GtkWidget *menuBar = gtk_menu_bar_new();
|
2016-05-09 05:17:00 +03:00
|
|
|
GtkWidget *menuBarItem = gtk_menu_item_new();
|
2010-04-02 06:09:05 +04:00
|
|
|
GtkWidget *entry = gtk_entry_new();
|
2015-10-30 11:08:00 +03:00
|
|
|
GtkWidget *textView = gtk_text_view_new();
|
2001-12-10 20:37:36 +03:00
|
|
|
|
2002-04-27 20:26:10 +04:00
|
|
|
gtk_container_add(GTK_CONTAINER(button), label);
|
|
|
|
gtk_container_add(GTK_CONTAINER(parent), button);
|
2008-04-12 16:13:32 +04:00
|
|
|
gtk_container_add(GTK_CONTAINER(parent), treeView);
|
2008-07-11 22:34:53 +04:00
|
|
|
gtk_container_add(GTK_CONTAINER(parent), linkButton);
|
2016-12-01 13:09:00 +03:00
|
|
|
#if (MOZ_WIDGET_GTK == 2)
|
2009-01-16 11:18:49 +03:00
|
|
|
gtk_container_add(GTK_CONTAINER(parent), combobox);
|
2016-12-01 13:09:00 +03:00
|
|
|
#endif
|
2009-06-15 01:58:14 +04:00
|
|
|
gtk_container_add(GTK_CONTAINER(parent), menuBar);
|
2016-05-09 05:17:00 +03:00
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(menuBar), menuBarItem);
|
2002-04-27 20:26:10 +04:00
|
|
|
gtk_container_add(GTK_CONTAINER(window), parent);
|
2010-04-02 06:09:05 +04:00
|
|
|
gtk_container_add(GTK_CONTAINER(parent), entry);
|
2015-10-30 11:08:00 +03:00
|
|
|
gtk_container_add(GTK_CONTAINER(parent), textView);
|
2013-05-30 03:26:40 +04:00
|
|
|
|
|
|
|
#if (MOZ_WIDGET_GTK == 2)
|
2013-10-08 22:47:37 +04:00
|
|
|
gtk_widget_set_style(button, nullptr);
|
|
|
|
gtk_widget_set_style(label, nullptr);
|
|
|
|
gtk_widget_set_style(treeView, nullptr);
|
|
|
|
gtk_widget_set_style(linkButton, nullptr);
|
|
|
|
gtk_widget_set_style(combobox, nullptr);
|
|
|
|
gtk_widget_set_style(comboboxLabel, nullptr);
|
|
|
|
gtk_widget_set_style(menuBar, nullptr);
|
|
|
|
gtk_widget_set_style(entry, nullptr);
|
2001-12-10 20:37:36 +03:00
|
|
|
|
2002-04-27 20:26:10 +04:00
|
|
|
gtk_widget_realize(button);
|
|
|
|
gtk_widget_realize(label);
|
2008-04-12 16:13:32 +04:00
|
|
|
gtk_widget_realize(treeView);
|
2008-07-11 22:34:53 +04:00
|
|
|
gtk_widget_realize(linkButton);
|
2009-01-16 11:18:49 +03:00
|
|
|
gtk_widget_realize(combobox);
|
|
|
|
gtk_widget_realize(comboboxLabel);
|
2009-06-15 01:58:14 +04:00
|
|
|
gtk_widget_realize(menuBar);
|
2010-04-02 06:09:05 +04:00
|
|
|
gtk_widget_realize(entry);
|
2001-12-10 20:37:36 +03:00
|
|
|
|
2002-04-27 20:26:10 +04:00
|
|
|
style = gtk_widget_get_style(label);
|
2007-01-11 12:26:47 +03:00
|
|
|
if (style) {
|
|
|
|
sButtonText = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]);
|
|
|
|
}
|
2001-12-10 20:37:36 +03:00
|
|
|
|
2009-01-16 11:18:49 +03:00
|
|
|
style = gtk_widget_get_style(comboboxLabel);
|
|
|
|
if (style) {
|
|
|
|
sComboBoxText = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]);
|
|
|
|
}
|
|
|
|
style = gtk_widget_get_style(combobox);
|
|
|
|
if (style) {
|
|
|
|
sComboBoxBackground = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_NORMAL]);
|
|
|
|
}
|
|
|
|
|
2009-06-15 01:58:14 +04:00
|
|
|
style = gtk_widget_get_style(menuBar);
|
|
|
|
if (style) {
|
|
|
|
sMenuBarText = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]);
|
|
|
|
sMenuBarHoverText = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_SELECTED]);
|
|
|
|
}
|
|
|
|
|
2008-04-12 16:13:32 +04:00
|
|
|
// GTK's guide to fancy odd row background colors:
|
|
|
|
// 1) Check if a theme explicitly defines an odd row color
|
|
|
|
// 2) If not, check if it defines an even row color, and darken it
|
|
|
|
// slightly by a hardcoded value (gtkstyle.c)
|
|
|
|
// 3) If neither are defined, take the base background color and
|
|
|
|
// darken that by a hardcoded value
|
2013-10-08 22:47:37 +04:00
|
|
|
colorValuePtr = nullptr;
|
2008-04-12 16:13:32 +04:00
|
|
|
gtk_widget_style_get(treeView,
|
|
|
|
"odd-row-color", &colorValuePtr,
|
2013-10-08 22:47:37 +04:00
|
|
|
nullptr);
|
2008-04-12 16:13:32 +04:00
|
|
|
|
|
|
|
if (colorValuePtr) {
|
|
|
|
colorValue = *colorValuePtr;
|
|
|
|
} else {
|
|
|
|
gtk_widget_style_get(treeView,
|
|
|
|
"even-row-color", &colorValuePtr,
|
2013-10-08 22:47:37 +04:00
|
|
|
nullptr);
|
2008-04-12 16:13:32 +04:00
|
|
|
if (colorValuePtr)
|
|
|
|
darken_gdk_color(colorValuePtr, &colorValue);
|
|
|
|
else
|
|
|
|
darken_gdk_color(&treeView->style->base[GTK_STATE_NORMAL], &colorValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
sOddCellBackground = GDK_COLOR_TO_NS_RGB(colorValue);
|
|
|
|
if (colorValuePtr)
|
|
|
|
gdk_color_free(colorValuePtr);
|
|
|
|
|
2002-04-27 20:26:10 +04:00
|
|
|
style = gtk_widget_get_style(button);
|
2007-01-11 12:26:47 +03:00
|
|
|
if (style) {
|
2014-11-27 06:08:00 +03:00
|
|
|
sButtonBackground = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_NORMAL]);
|
2014-06-24 09:28:00 +04:00
|
|
|
sFrameOuterLightBorder =
|
2007-01-11 12:26:47 +03:00
|
|
|
GDK_COLOR_TO_NS_RGB(style->light[GTK_STATE_NORMAL]);
|
2014-06-24 09:28:00 +04:00
|
|
|
sFrameInnerDarkBorder =
|
2007-01-11 12:26:47 +03:00
|
|
|
GDK_COLOR_TO_NS_RGB(style->dark[GTK_STATE_NORMAL]);
|
|
|
|
}
|
2013-05-30 03:26:40 +04:00
|
|
|
#else
|
2015-10-30 11:08:00 +03:00
|
|
|
// Text colors
|
2017-01-03 03:08:07 +03:00
|
|
|
GdkRGBA bgColor;
|
|
|
|
// If the text window background is translucent, then the background of
|
|
|
|
// the textview root node is visible.
|
|
|
|
style = ClaimStyleContext(MOZ_GTK_TEXT_VIEW);
|
|
|
|
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL,
|
|
|
|
&bgColor);
|
|
|
|
ReleaseStyleContext(style);
|
|
|
|
|
2016-12-30 03:37:51 +03:00
|
|
|
style = ClaimStyleContext(MOZ_GTK_TEXT_VIEW_TEXT);
|
2017-01-03 03:08:07 +03:00
|
|
|
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL,
|
|
|
|
&color);
|
|
|
|
ApplyColorOver(color, &bgColor);
|
|
|
|
sMozFieldBackground = GDK_RGBA_TO_NS_RGBA(bgColor);
|
2015-10-30 11:08:00 +03:00
|
|
|
gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
|
|
|
|
sMozFieldText = GDK_RGBA_TO_NS_RGBA(color);
|
|
|
|
|
|
|
|
// Selected text and background
|
|
|
|
gtk_style_context_get_background_color(style,
|
|
|
|
static_cast<GtkStateFlags>(GTK_STATE_FLAG_FOCUSED|GTK_STATE_FLAG_SELECTED),
|
|
|
|
&color);
|
|
|
|
sTextSelectedBackground = GDK_RGBA_TO_NS_RGBA(color);
|
|
|
|
gtk_style_context_get_color(style,
|
|
|
|
static_cast<GtkStateFlags>(GTK_STATE_FLAG_FOCUSED|GTK_STATE_FLAG_SELECTED),
|
|
|
|
&color);
|
|
|
|
sTextSelectedText = GDK_RGBA_TO_NS_RGBA(color);
|
2016-11-23 06:29:00 +03:00
|
|
|
ReleaseStyleContext(style);
|
2015-10-30 11:08:00 +03:00
|
|
|
|
2016-12-01 13:09:00 +03:00
|
|
|
// Button text color
|
|
|
|
style = ClaimStyleContext(MOZ_GTK_BUTTON);
|
|
|
|
{
|
|
|
|
GtkStyleContext* labelStyle =
|
|
|
|
CreateStyleForWidget(gtk_label_new("M"), style);
|
|
|
|
gtk_style_context_get_color(labelStyle, GTK_STATE_FLAG_NORMAL, &color);
|
|
|
|
sButtonText = GDK_RGBA_TO_NS_RGBA(color);
|
|
|
|
gtk_style_context_get_color(labelStyle, GTK_STATE_FLAG_PRELIGHT, &color);
|
|
|
|
sButtonHoverText = GDK_RGBA_TO_NS_RGBA(color);
|
|
|
|
g_object_unref(labelStyle);
|
|
|
|
}
|
|
|
|
ReleaseStyleContext(style);
|
2013-05-30 03:26:40 +04:00
|
|
|
|
2015-05-05 16:08:00 +03:00
|
|
|
// Combobox text color
|
2016-12-01 13:09:00 +03:00
|
|
|
style = ClaimStyleContext(MOZ_GTK_COMBOBOX_ENTRY_TEXTAREA);
|
2013-05-30 03:26:40 +04:00
|
|
|
gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
|
|
|
|
sComboBoxText = GDK_RGBA_TO_NS_RGBA(color);
|
2016-12-01 13:09:00 +03:00
|
|
|
ReleaseStyleContext(style);
|
2013-05-30 03:26:40 +04:00
|
|
|
|
|
|
|
// Menubar text and hover text colors
|
2016-11-23 06:29:00 +03:00
|
|
|
style = ClaimStyleContext(MOZ_GTK_MENUBARITEM);
|
2013-05-30 03:26:40 +04:00
|
|
|
gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
|
|
|
|
sMenuBarText = GDK_RGBA_TO_NS_RGBA(color);
|
|
|
|
gtk_style_context_get_color(style, GTK_STATE_FLAG_PRELIGHT, &color);
|
|
|
|
sMenuBarHoverText = GDK_RGBA_TO_NS_RGBA(color);
|
2016-11-23 06:29:00 +03:00
|
|
|
ReleaseStyleContext(style);
|
2013-05-30 03:26:40 +04:00
|
|
|
|
|
|
|
// GTK's guide to fancy odd row background colors:
|
|
|
|
// 1) Check if a theme explicitly defines an odd row color
|
|
|
|
// 2) If not, check if it defines an even row color, and darken it
|
|
|
|
// slightly by a hardcoded value (gtkstyle.c)
|
|
|
|
// 3) If neither are defined, take the base background color and
|
|
|
|
// darken that by a hardcoded value
|
2016-11-23 06:29:00 +03:00
|
|
|
style = ClaimStyleContext(MOZ_GTK_TREEVIEW);
|
2013-05-30 03:26:40 +04:00
|
|
|
|
|
|
|
// Get odd row background color
|
|
|
|
gtk_style_context_save(style);
|
|
|
|
gtk_style_context_add_region(style, GTK_STYLE_REGION_ROW, GTK_REGION_ODD);
|
|
|
|
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
|
|
|
|
sOddCellBackground = GDK_RGBA_TO_NS_RGBA(color);
|
|
|
|
gtk_style_context_restore(style);
|
2016-11-23 06:29:00 +03:00
|
|
|
ReleaseStyleContext(style);
|
2013-05-30 03:26:40 +04:00
|
|
|
|
2016-11-21 08:07:48 +03:00
|
|
|
// GtkFrame has a "border" subnode on which Adwaita draws the border.
|
|
|
|
// Some themes do not draw on this node but draw a border on the widget
|
|
|
|
// root node, so check the root node if no border is found on the border
|
|
|
|
// node.
|
2016-07-25 17:32:12 +03:00
|
|
|
style = ClaimStyleContext(MOZ_GTK_FRAME_BORDER);
|
2016-11-21 08:07:48 +03:00
|
|
|
bool themeUsesColors =
|
|
|
|
GetBorderColors(style, &sFrameOuterLightBorder, &sFrameInnerDarkBorder);
|
2016-07-25 17:32:12 +03:00
|
|
|
ReleaseStyleContext(style);
|
2016-11-21 08:07:48 +03:00
|
|
|
if (!themeUsesColors) {
|
|
|
|
style = ClaimStyleContext(MOZ_GTK_FRAME);
|
|
|
|
GetBorderColors(style, &sFrameOuterLightBorder, &sFrameInnerDarkBorder);
|
|
|
|
ReleaseStyleContext(style);
|
|
|
|
}
|
2016-07-25 17:32:12 +03:00
|
|
|
|
2015-08-19 22:42:17 +03:00
|
|
|
// GtkInfoBar
|
2016-07-19 07:03:00 +03:00
|
|
|
// TODO - Use WidgetCache for it?
|
2015-09-29 20:32:00 +03:00
|
|
|
GtkWidget* infoBar = gtk_info_bar_new();
|
|
|
|
GtkWidget* infoBarContent = gtk_info_bar_get_content_area(GTK_INFO_BAR(infoBar));
|
|
|
|
GtkWidget* infoBarLabel = gtk_label_new(nullptr);
|
|
|
|
gtk_container_add(GTK_CONTAINER(parent), infoBar);
|
|
|
|
gtk_container_add(GTK_CONTAINER(infoBarContent), infoBarLabel);
|
|
|
|
style = gtk_widget_get_style_context(infoBarLabel);
|
2015-08-19 22:42:17 +03:00
|
|
|
gtk_style_context_add_class(style, GTK_STYLE_CLASS_INFO);
|
|
|
|
gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
|
|
|
|
sInfoBarText = GDK_RGBA_TO_NS_RGBA(color);
|
2013-05-30 03:26:40 +04:00
|
|
|
#endif
|
|
|
|
// Some themes have a unified menu bar, and support window dragging on it
|
|
|
|
gboolean supports_menubar_drag = FALSE;
|
|
|
|
GParamSpec *param_spec =
|
|
|
|
gtk_widget_class_find_style_property(GTK_WIDGET_GET_CLASS(menuBar),
|
|
|
|
"window-dragging");
|
|
|
|
if (param_spec) {
|
|
|
|
if (g_type_is_a(G_PARAM_SPEC_VALUE_TYPE(param_spec), G_TYPE_BOOLEAN)) {
|
|
|
|
gtk_widget_style_get(menuBar,
|
|
|
|
"window-dragging", &supports_menubar_drag,
|
2013-10-08 22:47:37 +04:00
|
|
|
nullptr);
|
2013-05-30 03:26:40 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
sMenuSupportsDrag = supports_menubar_drag;
|
2001-12-10 20:37:36 +03:00
|
|
|
|
2013-10-08 22:47:37 +04:00
|
|
|
colorValuePtr = nullptr;
|
|
|
|
gtk_widget_style_get(linkButton, "link-color", &colorValuePtr, nullptr);
|
2008-07-11 22:34:53 +04:00
|
|
|
if (colorValuePtr) {
|
|
|
|
colorValue = *colorValuePtr; // we can't pass deref pointers to GDK_COLOR_TO_NS_RGB
|
|
|
|
sNativeHyperLinkText = GDK_COLOR_TO_NS_RGB(colorValue);
|
|
|
|
gdk_color_free(colorValuePtr);
|
|
|
|
} else {
|
|
|
|
sNativeHyperLinkText = NS_RGB(0x00,0x00,0xEE);
|
|
|
|
}
|
|
|
|
|
2006-10-24 00:48:05 +04:00
|
|
|
// invisible character styles
|
|
|
|
guint value;
|
2013-10-08 22:47:37 +04:00
|
|
|
g_object_get (entry, "invisible-char", &value, nullptr);
|
2014-01-04 19:02:17 +04:00
|
|
|
sInvisibleCharacter = char16_t(value);
|
2008-06-23 12:50:52 +04:00
|
|
|
|
|
|
|
// caret styles
|
|
|
|
gtk_widget_style_get(entry,
|
|
|
|
"cursor-aspect-ratio", &sCaretRatio,
|
2013-10-08 22:47:37 +04:00
|
|
|
nullptr);
|
2008-06-23 12:50:52 +04:00
|
|
|
|
2010-04-02 06:09:05 +04:00
|
|
|
gtk_widget_destroy(window);
|
2006-10-24 00:48:05 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// virtual
|
2014-01-04 19:02:17 +04:00
|
|
|
char16_t
|
2011-09-09 06:27:13 +04:00
|
|
|
nsLookAndFeel::GetPasswordCharacterImpl()
|
2006-10-24 00:48:05 +04:00
|
|
|
{
|
|
|
|
return sInvisibleCharacter;
|
2001-12-10 20:37:36 +03:00
|
|
|
}
|
2004-09-17 10:27:01 +04:00
|
|
|
|
2011-09-09 06:27:13 +04:00
|
|
|
void
|
|
|
|
nsLookAndFeel::RefreshImpl()
|
2004-09-17 10:27:01 +04:00
|
|
|
{
|
2011-09-09 06:27:13 +04:00
|
|
|
nsXPLookAndFeel::RefreshImpl();
|
2004-09-17 10:27:01 +04:00
|
|
|
|
2012-02-21 03:19:48 +04:00
|
|
|
mDefaultFontCached = false;
|
|
|
|
mButtonFontCached = false;
|
|
|
|
mFieldFontCached = false;
|
|
|
|
mMenuFontCached = false;
|
|
|
|
|
2013-05-30 03:26:40 +04:00
|
|
|
#if (MOZ_WIDGET_GTK == 2)
|
2009-04-17 00:55:12 +04:00
|
|
|
g_object_unref(mStyle);
|
2012-07-30 18:20:58 +04:00
|
|
|
mStyle = nullptr;
|
2013-05-30 03:26:40 +04:00
|
|
|
#endif
|
2012-02-21 03:19:48 +04:00
|
|
|
|
2013-05-30 03:26:40 +04:00
|
|
|
Init();
|
2004-09-17 10:27:01 +04:00
|
|
|
}
|
2011-09-23 21:15:29 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2011-09-28 00:18:51 +04:00
|
|
|
nsLookAndFeel::GetEchoPasswordImpl() {
|
2011-10-03 11:56:21 +04:00
|
|
|
return false;
|
2011-09-23 21:15:29 +04:00
|
|
|
}
|