2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim:expandtab:shiftwidth=4:tabstop=4:
|
|
|
|
*/
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-02-20 15:19:48 -08:00
|
|
|
// for strtod()
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsLookAndFeel.h"
|
2012-02-20 15:19:48 -08:00
|
|
|
|
2009-01-02 23:37:52 -08:00
|
|
|
#include <gtk/gtk.h>
|
2012-02-20 15:19:48 -08:00
|
|
|
#include <gdk/gdk.h>
|
|
|
|
|
|
|
|
#ifdef MOZ_PANGO
|
|
|
|
#include <pango/pango.h>
|
|
|
|
#include <pango/pango-fontmap.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <fontconfig/fontconfig.h>
|
|
|
|
#include "gfxPlatformGtk.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "gtkdrawing.h"
|
2011-03-31 05:26:49 -07:00
|
|
|
#include "nsStyleConsts.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-02-09 11:02:11 -08:00
|
|
|
#ifdef MOZ_PLATFORM_MAEMO
|
2009-11-25 14:27:05 -08:00
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIPropertyBag2.h"
|
|
|
|
#include "nsLiteralString.h"
|
2009-10-04 18:31:26 -07:00
|
|
|
#endif
|
|
|
|
|
2012-02-20 15:19:48 -08:00
|
|
|
using mozilla::LookAndFeel;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#define GDK_COLOR_TO_NS_RGB(c) \
|
|
|
|
((nscolor) NS_RGB(c.red>>8, c.green>>8, c.blue>>8))
|
|
|
|
|
|
|
|
nscolor nsLookAndFeel::sInfoText = 0;
|
|
|
|
nscolor nsLookAndFeel::sInfoBackground = 0;
|
2009-06-14 14:58:14 -07:00
|
|
|
nscolor nsLookAndFeel::sMenuBarText = 0;
|
|
|
|
nscolor nsLookAndFeel::sMenuBarHoverText = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
nscolor nsLookAndFeel::sMenuText = 0;
|
|
|
|
nscolor nsLookAndFeel::sMenuHover = 0;
|
|
|
|
nscolor nsLookAndFeel::sMenuHoverText = 0;
|
|
|
|
nscolor nsLookAndFeel::sMenuBackground = 0;
|
|
|
|
nscolor nsLookAndFeel::sButtonBackground = 0;
|
|
|
|
nscolor nsLookAndFeel::sButtonText = 0;
|
|
|
|
nscolor nsLookAndFeel::sButtonOuterLightBorder = 0;
|
|
|
|
nscolor nsLookAndFeel::sButtonInnerDarkBorder = 0;
|
2008-04-12 05:13:32 -07:00
|
|
|
nscolor nsLookAndFeel::sOddCellBackground = 0;
|
2008-07-11 11:34:53 -07:00
|
|
|
nscolor nsLookAndFeel::sNativeHyperLinkText = 0;
|
2009-01-16 00:18:49 -08:00
|
|
|
nscolor nsLookAndFeel::sComboBoxText = 0;
|
|
|
|
nscolor nsLookAndFeel::sComboBoxBackground = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
PRUnichar nsLookAndFeel::sInvisibleCharacter = PRUnichar('*');
|
2008-06-23 01:50:52 -07:00
|
|
|
float nsLookAndFeel::sCaretRatio = 0;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool nsLookAndFeel::sMenuSupportsDrag = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-02-20 15:19:48 -08:00
|
|
|
nsLookAndFeel::nsLookAndFeel()
|
|
|
|
: nsXPLookAndFeel(),
|
2012-07-30 07:20:58 -07:00
|
|
|
mStyle(nullptr),
|
2012-02-20 15:19:48 -08:00
|
|
|
mDefaultFontCached(false), mButtonFontCached(false),
|
|
|
|
mFieldFontCached(false), mMenuFontCached(false)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
InitWidget();
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool sInitialized = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (!sInitialized) {
|
2011-10-03 00:56:21 -07:00
|
|
|
sInitialized = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
InitLookAndFeel();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsLookAndFeel::~nsLookAndFeel()
|
|
|
|
{
|
2009-04-16 13:55:12 -07:00
|
|
|
g_object_unref(mStyle);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
nsresult
|
|
|
|
nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsresult res = NS_OK;
|
|
|
|
|
|
|
|
switch (aID) {
|
|
|
|
// 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.
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_WindowBackground:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->base[GTK_STATE_NORMAL]);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_WindowForeground:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->text[GTK_STATE_NORMAL]);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_WidgetBackground:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_NORMAL]);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_WidgetForeground:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->fg[GTK_STATE_NORMAL]);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_WidgetSelectBackground:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_SELECTED]);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_WidgetSelectForeground:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->fg[GTK_STATE_SELECTED]);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_Widget3DHighlight:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = NS_RGB(0xa0,0xa0,0xa0);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_Widget3DShadow:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = NS_RGB(0x40,0x40,0x40);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_TextBackground:
|
2007-03-22 10:30:00 -07:00
|
|
|
// not used?
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->base[GTK_STATE_NORMAL]);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_TextForeground:
|
2007-03-22 10:30:00 -07:00
|
|
|
// not used?
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->text[GTK_STATE_NORMAL]);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_TextSelectBackground:
|
|
|
|
case eColorID_IMESelectedRawTextBackground:
|
|
|
|
case eColorID_IMESelectedConvertedTextBackground:
|
2007-03-22 10:30:00 -07:00
|
|
|
// still used
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->base[GTK_STATE_SELECTED]);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_TextSelectForeground:
|
|
|
|
case eColorID_IMESelectedRawTextForeground:
|
|
|
|
case eColorID_IMESelectedConvertedTextForeground:
|
2007-03-22 10:30:00 -07:00
|
|
|
// still used
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->text[GTK_STATE_SELECTED]);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_IMERawInputBackground:
|
|
|
|
case eColorID_IMEConvertedTextBackground:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = NS_TRANSPARENT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_IMERawInputForeground:
|
|
|
|
case eColorID_IMEConvertedTextForeground:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = NS_SAME_AS_FOREGROUND_COLOR;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_IMERawInputUnderline:
|
|
|
|
case eColorID_IMEConvertedTextUnderline:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = NS_SAME_AS_FOREGROUND_COLOR;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_IMESelectedRawTextUnderline:
|
|
|
|
case eColorID_IMESelectedConvertedTextUnderline:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = NS_TRANSPARENT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_SpellCheckerUnderline:
|
2009-04-03 00:26:28 -07:00
|
|
|
aColor = NS_RGB(0xff, 0, 0);
|
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// css2 http://www.w3.org/TR/REC-CSS2/ui.html#system-colors
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_activeborder:
|
2007-03-22 10:30:00 -07:00
|
|
|
// active window border
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_NORMAL]);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_activecaption:
|
2007-03-22 10:30:00 -07:00
|
|
|
// active window caption background
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_NORMAL]);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_appworkspace:
|
2007-03-22 10:30:00 -07:00
|
|
|
// MDI background color
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_NORMAL]);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_background:
|
2007-03-22 10:30:00 -07:00
|
|
|
// desktop background
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_NORMAL]);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_captiontext:
|
2007-03-22 10:30:00 -07: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-08 19:27:13 -07:00
|
|
|
case eColorID_graytext:
|
2007-03-22 10:30:00 -07:00
|
|
|
// disabled text in windows, menus, etc.
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->fg[GTK_STATE_INSENSITIVE]);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_highlight:
|
2007-03-22 10:30:00 -07:00
|
|
|
// background of selected item
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->base[GTK_STATE_SELECTED]);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_highlighttext:
|
2007-03-22 10:30:00 -07:00
|
|
|
// text of selected item
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->text[GTK_STATE_SELECTED]);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_inactiveborder:
|
2007-03-22 10:30:00 -07:00
|
|
|
// inactive window border
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_NORMAL]);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_inactivecaption:
|
2007-03-22 10:30:00 -07:00
|
|
|
// inactive window caption
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_INSENSITIVE]);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_inactivecaptiontext:
|
2007-03-22 10:30:00 -07:00
|
|
|
// text in inactive window caption
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->fg[GTK_STATE_INSENSITIVE]);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_infobackground:
|
2007-03-22 10:30:00 -07:00
|
|
|
// tooltip background color
|
|
|
|
aColor = sInfoBackground;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_infotext:
|
2007-03-22 10:30:00 -07:00
|
|
|
// tooltip text color
|
|
|
|
aColor = sInfoText;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_menu:
|
2007-03-22 10:30:00 -07:00
|
|
|
// menu background
|
|
|
|
aColor = sMenuBackground;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_menutext:
|
2007-03-22 10:30:00 -07:00
|
|
|
// menu text
|
|
|
|
aColor = sMenuText;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_scrollbar:
|
2007-03-22 10:30:00 -07:00
|
|
|
// scrollbar gray area
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_ACTIVE]);
|
|
|
|
break;
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_threedface:
|
|
|
|
case eColorID_buttonface:
|
2007-03-22 10:30:00 -07:00
|
|
|
// 3-D face color
|
|
|
|
aColor = sButtonBackground;
|
|
|
|
break;
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_buttontext:
|
2007-03-22 10:30:00 -07:00
|
|
|
// text on push buttons
|
|
|
|
aColor = sButtonText;
|
|
|
|
break;
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_buttonhighlight:
|
2007-03-22 10:30:00 -07:00
|
|
|
// 3-D highlighted edge color
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_threedhighlight:
|
2007-03-22 10:30:00 -07:00
|
|
|
// 3-D highlighted outer edge color
|
|
|
|
aColor = sButtonOuterLightBorder;
|
|
|
|
break;
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_threedlightshadow:
|
2007-03-22 10:30:00 -07:00
|
|
|
// 3-D highlighted inner edge color
|
|
|
|
aColor = sButtonBackground; // always same as background in GTK code
|
|
|
|
break;
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_buttonshadow:
|
2007-03-22 10:30:00 -07:00
|
|
|
// 3-D shadow edge color
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_threedshadow:
|
2007-03-22 10:30:00 -07:00
|
|
|
// 3-D shadow inner edge color
|
|
|
|
aColor = sButtonInnerDarkBorder;
|
|
|
|
break;
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_threeddarkshadow:
|
2007-03-22 10:30:00 -07:00
|
|
|
// 3-D shadow outer edge color
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->black);
|
|
|
|
break;
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_window:
|
|
|
|
case eColorID_windowframe:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_NORMAL]);
|
|
|
|
break;
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_windowtext:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->fg[GTK_STATE_NORMAL]);
|
|
|
|
break;
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_eventreerow:
|
|
|
|
case eColorID__moz_field:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->base[GTK_STATE_NORMAL]);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_fieldtext:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->text[GTK_STATE_NORMAL]);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_dialog:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_NORMAL]);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_dialogtext:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->fg[GTK_STATE_NORMAL]);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_dragtargetzone:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_SELECTED]);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_buttondefault:
|
2007-03-22 10:30:00 -07:00
|
|
|
// default button border color
|
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->black);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_buttonhoverface:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_PRELIGHT]);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_buttonhovertext:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->fg[GTK_STATE_PRELIGHT]);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_cellhighlight:
|
|
|
|
case eColorID__moz_html_cellhighlight:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->base[GTK_STATE_ACTIVE]);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_cellhighlighttext:
|
|
|
|
case eColorID__moz_html_cellhighlighttext:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = GDK_COLOR_TO_NS_RGB(mStyle->text[GTK_STATE_ACTIVE]);
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_menuhover:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = sMenuHover;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_menuhovertext:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = sMenuHoverText;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_oddtreerow:
|
2008-04-12 05:13:32 -07:00
|
|
|
aColor = sOddCellBackground;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_nativehyperlinktext:
|
2008-07-11 11:34:53 -07:00
|
|
|
aColor = sNativeHyperLinkText;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_comboboxtext:
|
2009-01-16 00:18:49 -08:00
|
|
|
aColor = sComboBoxText;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_combobox:
|
2009-01-16 00:18:49 -08:00
|
|
|
aColor = sComboBoxBackground;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_menubartext:
|
2009-06-14 14:58:14 -07:00
|
|
|
aColor = sMenuBarText;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_menubarhovertext:
|
2009-06-14 14:58:14 -07:00
|
|
|
aColor = sMenuBarHoverText;
|
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
default:
|
|
|
|
/* default color is BLACK */
|
|
|
|
aColor = 0;
|
|
|
|
res = NS_ERROR_FAILURE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2008-04-12 05:13:32 -07: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;
|
|
|
|
}
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
static PRInt32 CheckWidgetStyle(GtkWidget* aWidget, const char* aStyle, PRInt32 aResult) {
|
2011-10-03 00:56:21 -07:00
|
|
|
gboolean value = FALSE;
|
2007-03-22 10:30:00 -07:00
|
|
|
gtk_widget_style_get(aWidget, aStyle, &value, NULL);
|
2011-09-08 19:27:13 -07:00
|
|
|
return value ? aResult : 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static PRInt32 ConvertGTKStepperStyleToMozillaScrollArrowStyle(GtkWidget* aWidget)
|
|
|
|
{
|
|
|
|
if (!aWidget)
|
2011-09-08 19:27:13 -07:00
|
|
|
return mozilla::LookAndFeel::eScrollArrowStyle_Single;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return
|
|
|
|
CheckWidgetStyle(aWidget, "has-backward-stepper",
|
2011-09-08 19:27:13 -07:00
|
|
|
mozilla::LookAndFeel::eScrollArrow_StartBackward) |
|
2007-03-22 10:30:00 -07:00
|
|
|
CheckWidgetStyle(aWidget, "has-forward-stepper",
|
2011-09-08 19:27:13 -07:00
|
|
|
mozilla::LookAndFeel::eScrollArrow_EndForward) |
|
2007-03-22 10:30:00 -07:00
|
|
|
CheckWidgetStyle(aWidget, "has-secondary-backward-stepper",
|
2011-09-08 19:27:13 -07:00
|
|
|
mozilla::LookAndFeel::eScrollArrow_EndBackward) |
|
2007-03-22 10:30:00 -07:00
|
|
|
CheckWidgetStyle(aWidget, "has-secondary-forward-stepper",
|
2011-09-08 19:27:13 -07:00
|
|
|
mozilla::LookAndFeel::eScrollArrow_StartForward);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
nsresult
|
|
|
|
nsLookAndFeel::GetIntImpl(IntID aID, PRInt32 &aResult)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsresult res = NS_OK;
|
|
|
|
|
|
|
|
// Set these before they can get overrided in the nsXPLookAndFeel.
|
|
|
|
switch (aID) {
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_ScrollButtonLeftMouseButtonAction:
|
|
|
|
aResult = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_ScrollButtonMiddleMouseButtonAction:
|
|
|
|
aResult = 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_ScrollButtonRightMouseButtonAction:
|
|
|
|
aResult = 2;
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
2008-01-01 02:21:28 -08:00
|
|
|
default:
|
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
res = nsXPLookAndFeel::GetIntImpl(aID, aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
return res;
|
|
|
|
res = NS_OK;
|
|
|
|
|
|
|
|
switch (aID) {
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_CaretBlinkTime:
|
2007-03-22 10:30:00 -07: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,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (blink)
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = (PRInt32) blink_time;
|
2007-03-22 10:30:00 -07:00
|
|
|
else
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
}
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_CaretWidth:
|
|
|
|
aResult = 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_ShowCaretDuringSelection:
|
|
|
|
aResult = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_SelectTextfieldsOnKeyFocus:
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
GtkWidget *entry;
|
|
|
|
GtkSettings *settings;
|
|
|
|
gboolean select_on_focus;
|
|
|
|
|
|
|
|
entry = gtk_entry_new();
|
2011-05-16 02:07:37 -07:00
|
|
|
g_object_ref_sink(entry);
|
2007-03-22 10:30:00 -07:00
|
|
|
settings = gtk_widget_get_settings(entry);
|
|
|
|
g_object_get(settings,
|
|
|
|
"gtk-entry-select-on-focus",
|
|
|
|
&select_on_focus,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if(select_on_focus)
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
else
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
gtk_widget_destroy(entry);
|
2009-02-02 09:49:58 -08:00
|
|
|
g_object_unref(entry);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_SubmenuDelay:
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
GtkSettings *settings;
|
|
|
|
gint delay;
|
|
|
|
|
|
|
|
settings = gtk_settings_get_default ();
|
|
|
|
g_object_get (settings, "gtk-menu-popup-delay", &delay, NULL);
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = (PRInt32) delay;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
}
|
2011-12-16 01:18:48 -08:00
|
|
|
case eIntID_TooltipDelay:
|
|
|
|
{
|
|
|
|
aResult = 500;
|
|
|
|
break;
|
|
|
|
}
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_MenusCanOverlapOSBar:
|
2007-03-22 10:30:00 -07:00
|
|
|
// we want XUL popups to be able to overlap the task bar.
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_SkipNavigatingDisabledMenuItem:
|
|
|
|
aResult = 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_DragThresholdX:
|
|
|
|
case eIntID_DragThresholdY:
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
GtkWidget* box = gtk_hbox_new(FALSE, 5);
|
|
|
|
gint threshold = 0;
|
|
|
|
g_object_get(gtk_widget_get_settings(box),
|
|
|
|
"gtk-dnd-drag-threshold", &threshold,
|
|
|
|
NULL);
|
2011-05-16 02:07:37 -07:00
|
|
|
g_object_ref_sink(box);
|
2009-02-04 05:21:02 -08:00
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = threshold;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_ScrollArrowStyle:
|
2011-02-16 15:01:51 -08:00
|
|
|
moz_gtk_init();
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult =
|
2007-03-22 10:30:00 -07:00
|
|
|
ConvertGTKStepperStyleToMozillaScrollArrowStyle(moz_gtk_get_scrollbar_widget());
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_ScrollSliderStyle:
|
|
|
|
aResult = eScrollThumbStyle_Proportional;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_TreeOpenDelay:
|
|
|
|
aResult = 1000;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_TreeCloseDelay:
|
|
|
|
aResult = 1000;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_TreeLazyScrollDelay:
|
|
|
|
aResult = 150;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_TreeScrollDelay:
|
|
|
|
aResult = 100;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_TreeScrollLinesMax:
|
|
|
|
aResult = 3;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_DWMCompositor:
|
|
|
|
case eIntID_WindowsClassic:
|
|
|
|
case eIntID_WindowsDefaultTheme:
|
|
|
|
case eIntID_WindowsThemeIdentifier:
|
|
|
|
aResult = 0;
|
2009-10-04 18:31:25 -07:00
|
|
|
res = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_TouchEnabled:
|
2010-02-09 11:02:11 -08:00
|
|
|
#ifdef MOZ_PLATFORM_MAEMO
|
2009-10-04 18:31:25 -07:00
|
|
|
// All Hildon devices are touch-enabled
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = 1;
|
2009-10-04 18:31:25 -07:00
|
|
|
#else
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = 0;
|
2008-04-08 11:36:53 -07:00
|
|
|
res = NS_ERROR_NOT_IMPLEMENTED;
|
2009-10-04 18:31:26 -07:00
|
|
|
#endif
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_MaemoClassic:
|
2010-02-09 11:02:11 -08:00
|
|
|
#ifdef MOZ_PLATFORM_MAEMO
|
2009-11-25 14:27:05 -08:00
|
|
|
{
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = 0;
|
2009-11-25 14:27:05 -08:00
|
|
|
nsCOMPtr<nsIPropertyBag2> infoService(do_GetService("@mozilla.org/system-info;1"));
|
|
|
|
if (infoService) {
|
|
|
|
nsCString deviceType;
|
|
|
|
nsresult rv = infoService->GetPropertyAsACString(NS_LITERAL_STRING("device"),
|
|
|
|
deviceType);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
if (deviceType.EqualsLiteral("Nokia N8xx"))
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = 1;
|
2009-11-25 14:27:05 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-10-04 18:31:26 -07:00
|
|
|
#else
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = 0;
|
2009-10-04 18:31:26 -07:00
|
|
|
res = NS_ERROR_NOT_IMPLEMENTED;
|
2009-10-04 18:31:25 -07:00
|
|
|
#endif
|
2008-04-08 11:36:53 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_MacGraphiteTheme:
|
|
|
|
case eIntID_MacLionTheme:
|
|
|
|
aResult = 0;
|
2008-09-17 09:23:58 -07:00
|
|
|
res = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_IMERawInputUnderlineStyle:
|
|
|
|
case eIntID_IMEConvertedTextUnderlineStyle:
|
|
|
|
aResult = NS_STYLE_TEXT_DECORATION_STYLE_SOLID;
|
2007-08-16 13:35:18 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_IMESelectedRawTextUnderlineStyle:
|
|
|
|
case eIntID_IMESelectedConvertedTextUnderline:
|
|
|
|
aResult = NS_STYLE_TEXT_DECORATION_STYLE_NONE;
|
2007-08-16 13:35:18 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_SpellCheckerUnderlineStyle:
|
|
|
|
aResult = NS_STYLE_TEXT_DECORATION_STYLE_WAVY;
|
2009-04-03 00:26:28 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_ImagesInMenus:
|
|
|
|
aResult = moz_gtk_images_in_menus();
|
2008-02-20 02:12:33 -08:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_ImagesInButtons:
|
|
|
|
aResult = moz_gtk_images_in_buttons();
|
2009-10-06 07:20:59 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_MenuBarDrag:
|
|
|
|
aResult = sMenuSupportsDrag;
|
2010-07-17 01:11:54 -07:00
|
|
|
break;
|
2011-11-17 15:41:35 -08:00
|
|
|
case eIntID_ScrollbarButtonAutoRepeatBehavior:
|
|
|
|
aResult = 1;
|
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
default:
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
res = NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
nsresult
|
|
|
|
nsLookAndFeel::GetFloatImpl(FloatID aID, float &aResult)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsresult res = NS_OK;
|
2011-09-08 19:27:13 -07:00
|
|
|
res = nsXPLookAndFeel::GetFloatImpl(aID, aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
return res;
|
|
|
|
res = NS_OK;
|
|
|
|
|
|
|
|
switch (aID) {
|
2011-09-08 19:27:13 -07:00
|
|
|
case eFloatID_IMEUnderlineRelativeSize:
|
|
|
|
aResult = 1.0f;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eFloatID_SpellCheckerUnderlineRelativeSize:
|
|
|
|
aResult = 1.0f;
|
2009-04-03 00:26:28 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eFloatID_CaretAspectRatio:
|
|
|
|
aResult = sCaretRatio;
|
2008-06-23 01:50:52 -07:00
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
default:
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = -1.0;
|
2007-03-22 10:30:00 -07:00
|
|
|
res = NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2012-02-20 15:19:48 -08:00
|
|
|
#ifdef MOZ_PANGO
|
|
|
|
static void
|
|
|
|
GetSystemFontInfo(GtkWidget *aWidget,
|
|
|
|
nsString *aFontName,
|
|
|
|
gfxFontStyle *aFontStyle)
|
|
|
|
{
|
|
|
|
GtkSettings *settings = gtk_widget_get_settings(aWidget);
|
|
|
|
|
2012-03-15 02:04:46 -07:00
|
|
|
aFontStyle->style = NS_FONT_STYLE_NORMAL;
|
2012-02-20 15:19:48 -08:00
|
|
|
|
|
|
|
gchar *fontname;
|
|
|
|
g_object_get(settings, "gtk-font-name", &fontname, NULL);
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
// |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 {
|
|
|
|
NS_ABORT_IF_FALSE(aID == LookAndFeel::eFont_Menu, "unexpected font ID");
|
|
|
|
GtkWidget *accel_label = gtk_accel_label_new("M");
|
|
|
|
GtkWidget *menuitem = gtk_menu_item_new();
|
|
|
|
GtkWidget *menu = gtk_menu_new();
|
|
|
|
g_object_ref_sink(GTK_OBJECT(menu));
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#else // not MOZ_PANGO
|
|
|
|
|
|
|
|
static void
|
|
|
|
GetSystemFontInfo(LookAndFeel::FontID /*unused */,
|
|
|
|
nsString *aFontName,
|
|
|
|
gfxFontStyle *aFontStyle)
|
|
|
|
{
|
|
|
|
/* FIXME: DFB FT2 Hardcoding the system font info for now. */
|
2012-03-15 02:04:46 -07:00
|
|
|
aFontStyle->style = NS_FONT_STYLE_NORMAL;
|
|
|
|
aFontStyle->weight = NS_FONT_WEIGHT_NORMAL;
|
2012-02-20 15:19:48 -08:00
|
|
|
aFontStyle->size = 40/3;
|
|
|
|
aFontStyle->stretch = NS_FONT_STRETCH_NORMAL;
|
|
|
|
aFontStyle->systemFont = true;
|
|
|
|
aFontName->AssignLiteral("\"Sans\"");
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // not MOZ_PANGO
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsLookAndFeel::GetFontImpl(FontID aID, nsString& aFontName,
|
|
|
|
gfxFontStyle& aFontStyle)
|
|
|
|
{
|
|
|
|
nsString *cachedFontName = NULL;
|
|
|
|
gfxFontStyle *cachedFontStyle = NULL;
|
|
|
|
bool *isCached = NULL;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
void
|
|
|
|
nsLookAndFeel::InitLookAndFeel()
|
|
|
|
{
|
|
|
|
GtkStyle *style;
|
|
|
|
|
|
|
|
// tooltip foreground and background
|
|
|
|
style = gtk_rc_get_style_by_paths(gtk_settings_get_default(),
|
|
|
|
"gtk-tooltips", "GtkWindow",
|
|
|
|
GTK_TYPE_WINDOW);
|
|
|
|
if (style) {
|
|
|
|
sInfoBackground = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_NORMAL]);
|
|
|
|
sInfoText = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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-14 14:58:14 -07:00
|
|
|
|
2011-05-16 02:07:37 -07:00
|
|
|
g_object_ref_sink(menu);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
gtk_container_add(GTK_CONTAINER(menuitem), accel_label);
|
2009-06-14 14:58:14 -07:00
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-02-02 09:49:58 -08:00
|
|
|
gtk_widget_set_style(accel_label, NULL);
|
|
|
|
gtk_widget_set_style(menu, NULL);
|
2007-03-22 10:30:00 -07:00
|
|
|
gtk_widget_realize(menu);
|
|
|
|
gtk_widget_realize(accel_label);
|
|
|
|
|
|
|
|
style = gtk_widget_get_style(accel_label);
|
|
|
|
if (style) {
|
|
|
|
sMenuText = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]);
|
|
|
|
}
|
|
|
|
|
|
|
|
style = gtk_widget_get_style(menu);
|
|
|
|
if (style) {
|
|
|
|
sMenuBackground = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_NORMAL]);
|
|
|
|
}
|
|
|
|
|
|
|
|
style = gtk_widget_get_style(menuitem);
|
|
|
|
if (style) {
|
|
|
|
sMenuHover = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_PRELIGHT]);
|
|
|
|
sMenuHoverText = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_PRELIGHT]);
|
|
|
|
}
|
|
|
|
|
2009-02-02 09:49:58 -08:00
|
|
|
g_object_unref(menu);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
|
|
|
|
// button styles
|
|
|
|
GtkWidget *parent = gtk_fixed_new();
|
|
|
|
GtkWidget *button = gtk_button_new();
|
|
|
|
GtkWidget *label = gtk_label_new("M");
|
2009-01-16 00:18:49 -08:00
|
|
|
GtkWidget *combobox = gtk_combo_box_new();
|
|
|
|
GtkWidget *comboboxLabel = gtk_label_new("M");
|
2007-03-22 10:30:00 -07:00
|
|
|
GtkWidget *window = gtk_window_new(GTK_WINDOW_POPUP);
|
2008-04-12 05:13:32 -07:00
|
|
|
GtkWidget *treeView = gtk_tree_view_new();
|
2008-07-11 11:34:53 -07:00
|
|
|
GtkWidget *linkButton = gtk_link_button_new("http://example.com/");
|
2009-06-14 14:58:14 -07:00
|
|
|
GtkWidget *menuBar = gtk_menu_bar_new();
|
2010-04-01 19:09:05 -07:00
|
|
|
GtkWidget *entry = gtk_entry_new();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
gtk_container_add(GTK_CONTAINER(button), label);
|
2009-01-16 00:18:49 -08:00
|
|
|
gtk_container_add(GTK_CONTAINER(combobox), comboboxLabel);
|
2007-03-22 10:30:00 -07:00
|
|
|
gtk_container_add(GTK_CONTAINER(parent), button);
|
2008-04-12 05:13:32 -07:00
|
|
|
gtk_container_add(GTK_CONTAINER(parent), treeView);
|
2008-07-11 11:34:53 -07:00
|
|
|
gtk_container_add(GTK_CONTAINER(parent), linkButton);
|
2009-01-16 00:18:49 -08:00
|
|
|
gtk_container_add(GTK_CONTAINER(parent), combobox);
|
2009-06-14 14:58:14 -07:00
|
|
|
gtk_container_add(GTK_CONTAINER(parent), menuBar);
|
2007-03-22 10:30:00 -07:00
|
|
|
gtk_container_add(GTK_CONTAINER(window), parent);
|
2010-04-01 19:09:05 -07:00
|
|
|
gtk_container_add(GTK_CONTAINER(parent), entry);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-02-02 09:49:58 -08:00
|
|
|
gtk_widget_set_style(button, NULL);
|
|
|
|
gtk_widget_set_style(label, NULL);
|
|
|
|
gtk_widget_set_style(treeView, NULL);
|
|
|
|
gtk_widget_set_style(linkButton, NULL);
|
|
|
|
gtk_widget_set_style(combobox, NULL);
|
|
|
|
gtk_widget_set_style(comboboxLabel, NULL);
|
2009-06-14 14:58:14 -07:00
|
|
|
gtk_widget_set_style(menuBar, NULL);
|
2010-04-01 19:09:05 -07:00
|
|
|
gtk_widget_set_style(entry, NULL);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
gtk_widget_realize(button);
|
|
|
|
gtk_widget_realize(label);
|
2008-04-12 05:13:32 -07:00
|
|
|
gtk_widget_realize(treeView);
|
2008-07-11 11:34:53 -07:00
|
|
|
gtk_widget_realize(linkButton);
|
2009-01-16 00:18:49 -08:00
|
|
|
gtk_widget_realize(combobox);
|
|
|
|
gtk_widget_realize(comboboxLabel);
|
2009-06-14 14:58:14 -07:00
|
|
|
gtk_widget_realize(menuBar);
|
2010-04-01 19:09:05 -07:00
|
|
|
gtk_widget_realize(entry);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
style = gtk_widget_get_style(label);
|
|
|
|
if (style) {
|
|
|
|
sButtonText = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]);
|
|
|
|
}
|
|
|
|
|
2009-01-16 00:18:49 -08: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-14 14:58:14 -07: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]);
|
|
|
|
}
|
|
|
|
|
2010-07-17 01:11:54 -07:00
|
|
|
// Some themes have a unified menu bar, and support window dragging on it
|
|
|
|
gboolean supports_menubar_drag = FALSE;
|
2010-08-06 04:09:08 -07:00
|
|
|
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,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
}
|
2010-07-17 01:11:54 -07:00
|
|
|
sMenuSupportsDrag = supports_menubar_drag;
|
|
|
|
|
2008-04-12 05:13:32 -07: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
|
|
|
|
GdkColor colorValue;
|
|
|
|
GdkColor *colorValuePtr = NULL;
|
|
|
|
gtk_widget_style_get(treeView,
|
|
|
|
"odd-row-color", &colorValuePtr,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (colorValuePtr) {
|
|
|
|
colorValue = *colorValuePtr;
|
|
|
|
} else {
|
|
|
|
gtk_widget_style_get(treeView,
|
|
|
|
"even-row-color", &colorValuePtr,
|
|
|
|
NULL);
|
|
|
|
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);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
style = gtk_widget_get_style(button);
|
|
|
|
if (style) {
|
|
|
|
sButtonBackground = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_NORMAL]);
|
|
|
|
sButtonOuterLightBorder =
|
|
|
|
GDK_COLOR_TO_NS_RGB(style->light[GTK_STATE_NORMAL]);
|
|
|
|
sButtonInnerDarkBorder =
|
|
|
|
GDK_COLOR_TO_NS_RGB(style->dark[GTK_STATE_NORMAL]);
|
|
|
|
}
|
|
|
|
|
2008-07-11 11:34:53 -07:00
|
|
|
colorValuePtr = NULL;
|
|
|
|
gtk_widget_style_get(linkButton, "link-color", &colorValuePtr, NULL);
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// invisible character styles
|
|
|
|
guint value;
|
|
|
|
g_object_get (entry, "invisible-char", &value, NULL);
|
|
|
|
sInvisibleCharacter = PRUnichar(value);
|
2008-06-23 01:50:52 -07:00
|
|
|
|
|
|
|
// caret styles
|
|
|
|
gtk_widget_style_get(entry,
|
|
|
|
"cursor-aspect-ratio", &sCaretRatio,
|
|
|
|
NULL);
|
|
|
|
|
2010-04-01 19:09:05 -07:00
|
|
|
gtk_widget_destroy(window);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-02-20 15:19:48 -08:00
|
|
|
void
|
|
|
|
nsLookAndFeel::InitWidget()
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// virtual
|
|
|
|
PRUnichar
|
2011-09-08 19:27:13 -07:00
|
|
|
nsLookAndFeel::GetPasswordCharacterImpl()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return sInvisibleCharacter;
|
|
|
|
}
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
void
|
|
|
|
nsLookAndFeel::RefreshImpl()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-09-08 19:27:13 -07:00
|
|
|
nsXPLookAndFeel::RefreshImpl();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-02-20 15:19:48 -08:00
|
|
|
mDefaultFontCached = false;
|
|
|
|
mButtonFontCached = false;
|
|
|
|
mFieldFontCached = false;
|
|
|
|
mMenuFontCached = false;
|
|
|
|
|
2009-04-16 13:55:12 -07:00
|
|
|
g_object_unref(mStyle);
|
2012-07-30 07:20:58 -07:00
|
|
|
mStyle = nullptr;
|
2012-02-20 15:19:48 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
InitWidget();
|
|
|
|
InitLookAndFeel();
|
|
|
|
}
|
2011-09-23 10:15:29 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2011-09-27 13:18:51 -07:00
|
|
|
nsLookAndFeel::GetEchoPasswordImpl() {
|
2011-09-23 10:15:29 -07:00
|
|
|
#ifdef MOZ_PLATFORM_MAEMO
|
2011-10-03 00:56:21 -07:00
|
|
|
return true;
|
2011-09-23 10:15:29 -07:00
|
|
|
#else
|
2011-10-03 00:56:21 -07:00
|
|
|
return false;
|
2011-09-23 10:15:29 -07:00
|
|
|
#endif
|
|
|
|
}
|