2012-02-20 23:19:48 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2008-04-19 15:31:50 +00:00
|
|
|
|
2012-02-20 23:19:48 +00:00
|
|
|
// Qt headers must be included before anything that might pull in our
|
|
|
|
// malloc wrappers.
|
2008-04-19 16:04:22 +00:00
|
|
|
#include <QApplication>
|
2012-02-20 23:19:48 +00:00
|
|
|
#include <QFont>
|
|
|
|
#include <QPalette>
|
2008-04-19 16:04:22 +00:00
|
|
|
#include <QStyle>
|
2010-03-04 21:51:42 +00:00
|
|
|
|
2008-04-19 16:07:10 +00:00
|
|
|
#undef NS_LOOKANDFEEL_DEBUG
|
|
|
|
#ifdef NS_LOOKANDFEEL_DEBUG
|
|
|
|
#include <QDebug>
|
|
|
|
#endif
|
|
|
|
|
2012-02-20 23:19:48 +00:00
|
|
|
#include "nsLookAndFeel.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
|
|
|
|
#include <qglobal.h>
|
|
|
|
|
|
|
|
#define QCOLOR_TO_NS_RGB(c) \
|
|
|
|
((nscolor)NS_RGB(c.red(),c.green(),c.blue()))
|
2008-04-19 15:31:50 +00:00
|
|
|
|
2012-02-20 23:19:48 +00:00
|
|
|
nsLookAndFeel::nsLookAndFeel()
|
|
|
|
: nsXPLookAndFeel(),
|
|
|
|
mDefaultFontCached(false), mButtonFontCached(false),
|
|
|
|
mFieldFontCached(false), mMenuFontCached(false)
|
2008-04-19 15:31:50 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsLookAndFeel::~nsLookAndFeel()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
nsresult
|
|
|
|
nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor)
|
2008-04-19 15:31:50 +00:00
|
|
|
{
|
2008-04-19 16:04:37 +00:00
|
|
|
nsresult res = NS_OK;
|
|
|
|
|
|
|
|
if (!qApp)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
QPalette palette = qApp->palette();
|
|
|
|
|
|
|
|
switch (aID) {
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_WindowBackground:
|
2008-04-19 16:07:10 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window));
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_WindowForeground:
|
2008-04-19 16:07:10 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window));
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_WidgetBackground:
|
2008-04-19 16:07:10 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window));
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_WidgetForeground:
|
2008-04-19 16:07:10 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::WindowText));
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_WidgetSelectBackground:
|
2008-04-19 16:07:10 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window));
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_WidgetSelectForeground:
|
2008-04-19 16:07:10 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::WindowText));
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_Widget3DHighlight:
|
2008-04-19 16:04:37 +00:00
|
|
|
aColor = NS_RGB(0xa0,0xa0,0xa0);
|
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_Widget3DShadow:
|
2008-04-19 16:04:37 +00:00
|
|
|
aColor = NS_RGB(0x40,0x40,0x40);
|
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_TextBackground:
|
2008-04-19 16:07:10 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window));
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_TextForeground:
|
2008-04-19 16:09:56 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::WindowText));
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_TextSelectBackground:
|
|
|
|
case eColorID_IMESelectedRawTextBackground:
|
|
|
|
case eColorID_IMESelectedConvertedTextBackground:
|
2008-04-19 16:07:10 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Highlight));
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_TextSelectForeground:
|
|
|
|
case eColorID_IMESelectedRawTextForeground:
|
|
|
|
case eColorID_IMESelectedConvertedTextForeground:
|
2008-04-19 16:07:10 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::HighlightedText));
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_IMERawInputBackground:
|
|
|
|
case eColorID_IMEConvertedTextBackground:
|
2008-04-19 16:04:37 +00:00
|
|
|
aColor = NS_TRANSPARENT;
|
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_IMERawInputForeground:
|
|
|
|
case eColorID_IMEConvertedTextForeground:
|
2008-04-19 16:04:37 +00:00
|
|
|
aColor = NS_SAME_AS_FOREGROUND_COLOR;
|
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_IMERawInputUnderline:
|
|
|
|
case eColorID_IMEConvertedTextUnderline:
|
2008-04-19 16:04:37 +00:00
|
|
|
aColor = NS_SAME_AS_FOREGROUND_COLOR;
|
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_IMESelectedRawTextUnderline:
|
|
|
|
case eColorID_IMESelectedConvertedTextUnderline:
|
2008-04-19 16:04:37 +00:00
|
|
|
aColor = NS_TRANSPARENT;
|
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_SpellCheckerUnderline:
|
2009-04-03 07:26:28 +00:00
|
|
|
aColor = NS_RGB(0xff, 0, 0);
|
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_activeborder:
|
2008-04-19 16:07:10 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window));
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_activecaption:
|
2008-04-19 16:07:10 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window));
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_appworkspace:
|
2008-04-19 16:07:10 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window));
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_background:
|
2008-04-19 16:07:10 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window));
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_captiontext:
|
2008-04-19 16:07:10 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Text));
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_graytext:
|
2008-04-19 16:04:37 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Disabled, QPalette::Text));
|
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_highlight:
|
2008-04-19 16:07:10 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Highlight));
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_highlighttext:
|
2008-04-19 16:07:10 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::HighlightedText));
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_inactiveborder:
|
2008-04-19 16:07:10 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Disabled, QPalette::Window));
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_inactivecaption:
|
2008-04-19 16:07:10 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Disabled, QPalette::Window));
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_inactivecaptiontext:
|
2008-04-19 16:04:37 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Disabled, QPalette::Text));
|
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_infobackground:
|
2008-04-19 16:07:34 +00:00
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0))
|
2008-04-19 16:07:15 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::ToolTipBase));
|
2008-04-19 16:07:20 +00:00
|
|
|
#else
|
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Base));
|
|
|
|
#endif
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_infotext:
|
2008-04-19 16:07:34 +00:00
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0))
|
2008-04-19 16:07:15 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::ToolTipText));
|
2008-04-19 16:07:20 +00:00
|
|
|
#else
|
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Text));
|
|
|
|
#endif
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_menu:
|
2008-04-19 16:07:10 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window));
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_menutext:
|
|
|
|
case eColorID__moz_menubartext:
|
2008-04-19 16:07:10 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Text));
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_scrollbar:
|
2008-04-19 16:07:15 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Mid));
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_threedface:
|
|
|
|
case eColorID_buttonface:
|
2008-04-19 16:07:10 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Button));
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_buttonhighlight:
|
|
|
|
case eColorID_threedhighlight:
|
2008-04-19 16:07:15 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Dark));
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_buttontext:
|
2008-04-19 16:07:10 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::ButtonText));
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_buttonshadow:
|
|
|
|
case eColorID_threedshadow:
|
2008-04-19 16:07:15 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Dark));
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_threeddarkshadow:
|
2008-04-19 16:07:15 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Shadow));
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_threedlightshadow:
|
2008-04-19 16:07:10 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Light));
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_window:
|
|
|
|
case eColorID_windowframe:
|
2008-04-19 16:07:10 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window));
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_windowtext:
|
2008-04-19 16:07:10 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Text));
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2012-02-20 23:19:48 +00:00
|
|
|
// from the CSS3 working draft (not yet finalized)
|
|
|
|
// http://www.w3.org/tr/2000/wd-css3-userint-20000216.html#color
|
2008-04-19 16:04:37 +00:00
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID__moz_buttondefault:
|
2008-04-19 16:09:56 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Button));
|
|
|
|
break;
|
2008-04-19 16:04:37 +00:00
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID__moz_field:
|
|
|
|
case eColorID__moz_combobox:
|
2008-04-19 16:09:56 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Base));
|
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID__moz_fieldtext:
|
|
|
|
case eColorID__moz_comboboxtext:
|
2008-04-19 16:09:56 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Text));
|
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID__moz_dialog:
|
2008-04-19 16:09:56 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window));
|
|
|
|
break;
|
2008-04-19 16:04:37 +00:00
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID__moz_dialogtext:
|
2008-04-19 16:09:56 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::WindowText));
|
|
|
|
break;
|
2008-04-19 16:04:37 +00:00
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID__moz_dragtargetzone:
|
2008-04-19 16:09:56 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window));
|
|
|
|
break;
|
2008-04-19 16:04:37 +00:00
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID__moz_buttonhovertext:
|
2008-04-19 16:09:56 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::ButtonText));
|
|
|
|
break;
|
2008-04-19 16:07:10 +00:00
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID__moz_menuhovertext:
|
|
|
|
case eColorID__moz_menubarhovertext:
|
2008-04-19 16:09:56 +00:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Text));
|
|
|
|
break;
|
2008-04-19 16:07:20 +00:00
|
|
|
|
2008-04-19 16:09:56 +00:00
|
|
|
default:
|
|
|
|
aColor = 0;
|
|
|
|
res = NS_ERROR_FAILURE;
|
|
|
|
break;
|
2008-04-19 16:04:37 +00:00
|
|
|
}
|
|
|
|
return res;
|
2008-04-19 15:31:50 +00:00
|
|
|
}
|
|
|
|
|
2008-04-19 16:07:10 +00:00
|
|
|
#ifdef NS_LOOKANDFEEL_DEBUG
|
2008-04-19 15:31:50 +00:00
|
|
|
static const char *metricToString[] = {
|
2012-02-20 23:19:48 +00:00
|
|
|
"eIntID_CaretBlinkTime",
|
|
|
|
"eIntID_CaretWidth",
|
|
|
|
"eIntID_ShowCaretDuringSelection",
|
|
|
|
"eIntID_SelectTextfieldsOnKeyFocus",
|
|
|
|
"eIntID_SubmenuDelay",
|
|
|
|
"eIntID_MenusCanOverlapOSBar",
|
|
|
|
"eIntID_SkipNavigatingDisabledMenuItem",
|
|
|
|
"eIntID_DragThresholdX",
|
|
|
|
"eIntID_DragThresholdY",
|
|
|
|
"eIntID_UseAccessibilityTheme",
|
|
|
|
"eIntID_ScrollArrowStyle",
|
|
|
|
"eIntID_ScrollSliderStyle",
|
|
|
|
"eIntID_ScrollButtonLeftMouseButtonAction",
|
|
|
|
"eIntID_ScrollButtonMiddleMouseButtonAction",
|
|
|
|
"eIntID_ScrollButtonRightMouseButtonAction",
|
|
|
|
"eIntID_TreeOpenDelay",
|
|
|
|
"eIntID_TreeCloseDelay",
|
|
|
|
"eIntID_TreeLazyScrollDelay",
|
|
|
|
"eIntID_TreeScrollDelay",
|
|
|
|
"eIntID_TreeScrollLinesMax",
|
|
|
|
"eIntID_TabFocusModel",
|
|
|
|
"eIntID_WindowsDefaultTheme",
|
|
|
|
"eIntID_AlertNotificationOrigin",
|
|
|
|
"eIntID_ScrollToClick",
|
|
|
|
"eIntID_IMERawInputUnderlineStyle",
|
|
|
|
"eIntID_IMESelectedRawTextUnderlineStyle",
|
|
|
|
"eIntID_IMEConvertedTextUnderlineStyle",
|
|
|
|
"eIntID_IMESelectedConvertedTextUnderline",
|
|
|
|
"eIntID_ImagesInMenus"
|
|
|
|
};
|
2008-04-19 16:07:10 +00:00
|
|
|
#endif
|
2008-04-19 15:31:50 +00:00
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
nsresult
|
|
|
|
nsLookAndFeel::GetIntImpl(IntID aID, PRInt32 &aResult)
|
2008-04-19 15:31:50 +00:00
|
|
|
{
|
2008-04-19 16:07:10 +00:00
|
|
|
#ifdef NS_LOOKANDFEEL_DEBUG
|
2011-09-09 02:27:13 +00:00
|
|
|
qDebug("nsLookAndFeel::GetIntImpl aID = %s", metricToString[aID]);
|
2008-04-19 16:07:10 +00:00
|
|
|
#endif
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
nsresult res = nsXPLookAndFeel::GetIntImpl(aID, aResult);
|
2008-04-19 16:04:37 +00:00
|
|
|
if (NS_SUCCEEDED(res))
|
2012-02-20 23:19:48 +00:00
|
|
|
return res;
|
2008-04-19 16:07:10 +00:00
|
|
|
|
2008-04-19 16:04:37 +00:00
|
|
|
res = NS_OK;
|
|
|
|
|
|
|
|
switch (aID) {
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_CaretBlinkTime:
|
|
|
|
aResult = 500;
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_CaretWidth:
|
|
|
|
aResult = 1;
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_ShowCaretDuringSelection:
|
|
|
|
aResult = 0;
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_SelectTextfieldsOnKeyFocus:
|
2008-04-19 16:04:37 +00:00
|
|
|
// Select textfield content when focused by kbd
|
|
|
|
// used by nsEventStateManager::sTextfieldSelectModel
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult = 1;
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_SubmenuDelay:
|
|
|
|
aResult = 200;
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-12-16 09:18:48 +00:00
|
|
|
case eIntID_TooltipDelay:
|
|
|
|
aResult = 500;
|
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_MenusCanOverlapOSBar:
|
2008-04-19 16:04:37 +00:00
|
|
|
// we want XUL popups to be able to overlap the task bar.
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult = 1;
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_ScrollArrowStyle:
|
|
|
|
aResult = eScrollArrowStyle_Single;
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_ScrollSliderStyle:
|
|
|
|
aResult = eScrollThumbStyle_Proportional;
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_TouchEnabled:
|
2010-02-04 14:42:47 +00:00
|
|
|
#ifdef MOZ_PLATFORM_MAEMO
|
2010-02-04 14:49:55 +00:00
|
|
|
// All known Maemo devices are touch enabled.
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult = 1;
|
2010-02-04 14:42:47 +00:00
|
|
|
#else
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult = 0;
|
2010-02-04 14:42:47 +00:00
|
|
|
res = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_WindowsDefaultTheme:
|
|
|
|
case eIntID_MaemoClassic:
|
|
|
|
aResult = 0;
|
2008-04-19 16:07:10 +00:00
|
|
|
res = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_SpellCheckerUnderlineStyle:
|
|
|
|
aResult = NS_STYLE_TEXT_DECORATION_STYLE_WAVY;
|
2009-04-03 07:26:28 +00:00
|
|
|
break;
|
|
|
|
|
2011-11-17 23:41:35 +00:00
|
|
|
case eIntID_ScrollbarButtonAutoRepeatBehavior:
|
|
|
|
aResult = 1;
|
|
|
|
break;
|
|
|
|
|
2008-04-19 16:04:37 +00:00
|
|
|
default:
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult = 0;
|
2008-04-19 16:04:37 +00:00
|
|
|
res = NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
return res;
|
2008-04-19 15:31:50 +00:00
|
|
|
}
|
|
|
|
|
2008-04-19 16:07:10 +00:00
|
|
|
#ifdef NS_LOOKANDFEEL_DEBUG
|
|
|
|
static const char *floatMetricToString[] = {
|
2012-02-20 23:19:48 +00:00
|
|
|
"eFloatID_IMEUnderlineRelativeSize"
|
2008-04-19 16:07:10 +00:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
nsresult
|
|
|
|
nsLookAndFeel::GetFloatImpl(FloatID aID, float &aResult)
|
2008-04-19 15:31:50 +00:00
|
|
|
{
|
2008-04-19 16:07:10 +00:00
|
|
|
#ifdef NS_LOOKANDFEEL_DEBUG
|
2011-09-09 02:27:13 +00:00
|
|
|
qDebug("nsLookAndFeel::GetFloatImpl aID = %s", floatMetricToString[aID]);
|
2008-04-19 16:07:10 +00:00
|
|
|
#endif
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
nsresult res = nsXPLookAndFeel::GetFloatImpl(aID, aResult);
|
2008-04-19 16:04:37 +00:00
|
|
|
if (NS_SUCCEEDED(res))
|
2012-02-20 23:19:48 +00:00
|
|
|
return res;
|
2008-04-19 16:04:37 +00:00
|
|
|
res = NS_OK;
|
|
|
|
|
|
|
|
switch (aID) {
|
2011-09-09 02:27:13 +00:00
|
|
|
case eFloatID_IMEUnderlineRelativeSize:
|
|
|
|
aResult = 1.0f;
|
2008-04-19 16:04:37 +00:00
|
|
|
break;
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eFloatID_SpellCheckerUnderlineRelativeSize:
|
|
|
|
aResult = 1.0f;
|
2009-04-03 07:26:28 +00:00
|
|
|
break;
|
|
|
|
|
2008-04-19 16:04:37 +00:00
|
|
|
default:
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult = -1.0;
|
2008-04-19 16:04:37 +00:00
|
|
|
res = NS_ERROR_FAILURE;
|
2008-04-19 16:07:10 +00:00
|
|
|
break;
|
2008-04-19 16:04:37 +00:00
|
|
|
}
|
|
|
|
return res;
|
2008-04-19 15:31:50 +00:00
|
|
|
}
|
2012-02-20 23:19:48 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
GetSystemFontInfo(const char *aClassName, nsString *aFontName,
|
|
|
|
gfxFontStyle *aFontStyle)
|
|
|
|
{
|
|
|
|
QFont qFont = QApplication::font(aClassName);
|
|
|
|
|
|
|
|
NS_NAMED_LITERAL_STRING(quote, "\"");
|
|
|
|
nsString family((PRUnichar*)qFont.family().data());
|
|
|
|
*aFontName = quote + family + quote;
|
|
|
|
|
|
|
|
aFontStyle->systemFont = true;
|
2012-03-15 09:04:46 +00:00
|
|
|
aFontStyle->style = NS_FONT_STYLE_NORMAL;
|
2012-02-20 23:19:48 +00:00
|
|
|
aFontStyle->weight = qFont.weight();
|
|
|
|
// FIXME: Set aFontStyle->stretch correctly!
|
|
|
|
aFontStyle->stretch = NS_FONT_STRETCH_NORMAL;
|
|
|
|
// use pixel size directly if it is set, otherwise compute from point size
|
|
|
|
if (qFont.pixelSize() != -1) {
|
|
|
|
aFontStyle->size = qFont.pixelSize();
|
|
|
|
} else {
|
|
|
|
aFontStyle->size = qFont.pointSizeF() * 96.0f / 72.0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsLookAndFeel::GetFontImpl(FontID aID, nsString& aFontName,
|
|
|
|
gfxFontStyle& aFontStyle)
|
|
|
|
{
|
|
|
|
const char *className = NULL;
|
|
|
|
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;
|
|
|
|
className = "QAction";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eFont_Field: // css3
|
|
|
|
case eFont_List: // css3
|
|
|
|
cachedFontName = &mFieldFontName;
|
|
|
|
cachedFontStyle = &mFieldFontStyle;
|
|
|
|
isCached = &mFieldFontCached;
|
|
|
|
className = "QlineEdit";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eFont_Button: // css3
|
|
|
|
cachedFontName = &mButtonFontName;
|
|
|
|
cachedFontStyle = &mButtonFontStyle;
|
|
|
|
isCached = &mButtonFontCached;
|
|
|
|
className = "QPushButton";
|
|
|
|
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;
|
|
|
|
className = "Qlabel";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!*isCached) {
|
|
|
|
GetSystemFontInfo(className, cachedFontName, cachedFontStyle);
|
|
|
|
*isCached = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
aFontName = *cachedFontName;
|
|
|
|
aFontStyle = *cachedFontStyle;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsLookAndFeel::RefreshImpl()
|
|
|
|
{
|
|
|
|
nsXPLookAndFeel::RefreshImpl();
|
|
|
|
mDefaultFontCached = false;
|
|
|
|
mButtonFontCached = false;
|
|
|
|
mFieldFontCached = false;
|
|
|
|
mMenuFontCached = false;
|
|
|
|
}
|