2008-04-19 08:31:50 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Lars Knoll <knoll@kde.org>
|
|
|
|
* Zack Rusin <zack@kde.org>
|
|
|
|
* John C. Griggs <johng@corel.com>
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
2008-04-19 09:04:22 -07:00
|
|
|
#include <QPalette>
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QStyle>
|
2010-03-04 13:51:42 -08:00
|
|
|
|
|
|
|
#include "nsLookAndFeel.h"
|
|
|
|
|
2008-04-19 09:07:20 -07:00
|
|
|
#include <qglobal.h>
|
2008-04-19 08:31:50 -07:00
|
|
|
|
2008-04-19 09:07:10 -07:00
|
|
|
#undef NS_LOOKANDFEEL_DEBUG
|
|
|
|
#ifdef NS_LOOKANDFEEL_DEBUG
|
|
|
|
#include <QDebug>
|
|
|
|
#endif
|
|
|
|
|
2008-04-19 08:31:50 -07:00
|
|
|
#define QCOLOR_TO_NS_RGB(c) \
|
|
|
|
((nscolor)NS_RGB(c.red(),c.green(),c.blue()))
|
|
|
|
|
|
|
|
nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsLookAndFeel::~nsLookAndFeel()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult nsLookAndFeel::NativeGetColor(const nsColorID aID,nscolor &aColor)
|
|
|
|
{
|
2008-04-19 09:04:37 -07:00
|
|
|
nsresult res = NS_OK;
|
|
|
|
|
|
|
|
if (!qApp)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
QPalette palette = qApp->palette();
|
|
|
|
|
|
|
|
switch (aID) {
|
|
|
|
case eColor_WindowBackground:
|
2008-04-19 09:07:10 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window));
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_WindowForeground:
|
2008-04-19 09:07:10 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window));
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_WidgetBackground:
|
2008-04-19 09:07:10 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window));
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_WidgetForeground:
|
2008-04-19 09:07:10 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::WindowText));
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_WidgetSelectBackground:
|
2008-04-19 09:07:10 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window));
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_WidgetSelectForeground:
|
2008-04-19 09:07:10 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::WindowText));
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_Widget3DHighlight:
|
|
|
|
aColor = NS_RGB(0xa0,0xa0,0xa0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_Widget3DShadow:
|
|
|
|
aColor = NS_RGB(0x40,0x40,0x40);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_TextBackground:
|
2008-04-19 09:07:10 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window));
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_TextForeground:
|
2008-04-19 09:09:56 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::WindowText));
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_TextSelectBackground:
|
|
|
|
case eColor_IMESelectedRawTextBackground:
|
|
|
|
case eColor_IMESelectedConvertedTextBackground:
|
2008-04-19 09:07:10 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Highlight));
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_TextSelectForeground:
|
|
|
|
case eColor_IMESelectedRawTextForeground:
|
|
|
|
case eColor_IMESelectedConvertedTextForeground:
|
2008-04-19 09:07:10 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::HighlightedText));
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_IMERawInputBackground:
|
|
|
|
case eColor_IMEConvertedTextBackground:
|
|
|
|
aColor = NS_TRANSPARENT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_IMERawInputForeground:
|
|
|
|
case eColor_IMEConvertedTextForeground:
|
|
|
|
aColor = NS_SAME_AS_FOREGROUND_COLOR;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_IMERawInputUnderline:
|
|
|
|
case eColor_IMEConvertedTextUnderline:
|
|
|
|
aColor = NS_SAME_AS_FOREGROUND_COLOR;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_IMESelectedRawTextUnderline:
|
|
|
|
case eColor_IMESelectedConvertedTextUnderline:
|
|
|
|
aColor = NS_TRANSPARENT;
|
|
|
|
break;
|
|
|
|
|
2009-04-03 00:26:28 -07:00
|
|
|
case eColor_SpellCheckerUnderline:
|
|
|
|
aColor = NS_RGB(0xff, 0, 0);
|
|
|
|
break;
|
|
|
|
|
2008-04-19 09:04:37 -07:00
|
|
|
case eColor_activeborder:
|
2008-04-19 09:07:10 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window));
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_activecaption:
|
2008-04-19 09:07:10 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window));
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_appworkspace:
|
2008-04-19 09:07:10 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window));
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_background:
|
2008-04-19 09:07:10 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window));
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_captiontext:
|
2008-04-19 09:07:10 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Text));
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_graytext:
|
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Disabled, QPalette::Text));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_highlight:
|
2008-04-19 09:07:10 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Highlight));
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_highlighttext:
|
2008-04-19 09:07:10 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::HighlightedText));
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_inactiveborder:
|
2008-04-19 09:07:10 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Disabled, QPalette::Window));
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_inactivecaption:
|
2008-04-19 09:07:10 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Disabled, QPalette::Window));
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_inactivecaptiontext:
|
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Disabled, QPalette::Text));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_infobackground:
|
2008-04-19 09:07:34 -07:00
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0))
|
2008-04-19 09:07:15 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::ToolTipBase));
|
2008-04-19 09:07:20 -07:00
|
|
|
#else
|
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Base));
|
|
|
|
#endif
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_infotext:
|
2008-04-19 09:07:34 -07:00
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0))
|
2008-04-19 09:07:15 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::ToolTipText));
|
2008-04-19 09:07:20 -07:00
|
|
|
#else
|
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Text));
|
|
|
|
#endif
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_menu:
|
2008-04-19 09:07:10 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window));
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_menutext:
|
2009-06-14 14:58:14 -07:00
|
|
|
case eColor__moz_menubartext:
|
2008-04-19 09:07:10 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Text));
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_scrollbar:
|
2008-04-19 09:07:15 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Mid));
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_threedface:
|
|
|
|
case eColor_buttonface:
|
2008-04-19 09:07:10 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Button));
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_buttonhighlight:
|
|
|
|
case eColor_threedhighlight:
|
2008-04-19 09:07:15 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Dark));
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_buttontext:
|
2008-04-19 09:07:10 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::ButtonText));
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_buttonshadow:
|
|
|
|
case eColor_threedshadow:
|
2008-04-19 09:07:15 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Dark));
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_threeddarkshadow:
|
2008-04-19 09:07:15 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Shadow));
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_threedlightshadow:
|
2008-04-19 09:07:10 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Light));
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_window:
|
|
|
|
case eColor_windowframe:
|
2008-04-19 09:07:10 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window));
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor_windowtext:
|
2008-04-19 09:07:10 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Text));
|
2008-04-19 09:04:37 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
// from the CSS3 working draft (not yet finalized)
|
|
|
|
// http://www.w3.org/tr/2000/wd-css3-userint-20000216.html#color
|
|
|
|
|
2008-04-19 09:09:56 -07:00
|
|
|
case eColor__moz_buttondefault:
|
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Button));
|
|
|
|
break;
|
2008-04-19 09:04:37 -07:00
|
|
|
|
2008-04-19 09:09:56 -07:00
|
|
|
case eColor__moz_field:
|
2009-01-16 00:18:49 -08:00
|
|
|
case eColor__moz_combobox:
|
2008-04-19 09:09:56 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Base));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor__moz_fieldtext:
|
2009-01-16 00:18:49 -08:00
|
|
|
case eColor__moz_comboboxtext:
|
2008-04-19 09:09:56 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Text));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eColor__moz_dialog:
|
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window));
|
|
|
|
break;
|
2008-04-19 09:04:37 -07:00
|
|
|
|
2008-04-19 09:09:56 -07:00
|
|
|
case eColor__moz_dialogtext:
|
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::WindowText));
|
|
|
|
break;
|
2008-04-19 09:04:37 -07:00
|
|
|
|
2008-04-19 09:09:56 -07:00
|
|
|
case eColor__moz_dragtargetzone:
|
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window));
|
|
|
|
break;
|
2008-04-19 09:04:37 -07:00
|
|
|
|
2008-04-19 09:09:56 -07:00
|
|
|
case eColor__moz_buttonhovertext:
|
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::ButtonText));
|
|
|
|
break;
|
2008-04-19 09:07:10 -07:00
|
|
|
|
2008-04-19 09:07:20 -07:00
|
|
|
case eColor__moz_menuhovertext:
|
|
|
|
case eColor__moz_menubarhovertext:
|
2008-04-19 09:09:56 -07:00
|
|
|
aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Text));
|
|
|
|
break;
|
2008-04-19 09:07:20 -07:00
|
|
|
|
2008-04-19 09:09:56 -07:00
|
|
|
default:
|
|
|
|
aColor = 0;
|
|
|
|
res = NS_ERROR_FAILURE;
|
|
|
|
break;
|
2008-04-19 09:04:37 -07:00
|
|
|
}
|
|
|
|
return res;
|
2008-04-19 08:31:50 -07:00
|
|
|
}
|
|
|
|
|
2008-04-19 09:07:10 -07:00
|
|
|
#ifdef NS_LOOKANDFEEL_DEBUG
|
2008-04-19 08:31:50 -07:00
|
|
|
static const char *metricToString[] = {
|
|
|
|
"eMetric_CaretBlinkTime",
|
|
|
|
"eMetric_CaretWidth",
|
|
|
|
"eMetric_ShowCaretDuringSelection",
|
|
|
|
"eMetric_SelectTextfieldsOnKeyFocus",
|
|
|
|
"eMetric_SubmenuDelay",
|
|
|
|
"eMetric_MenusCanOverlapOSBar",
|
2008-04-19 09:07:10 -07:00
|
|
|
"eMetric_SkipNavigatingDisabledMenuItem",
|
2008-04-19 08:31:50 -07:00
|
|
|
"eMetric_DragThresholdX",
|
|
|
|
"eMetric_DragThresholdY",
|
|
|
|
"eMetric_UseAccessibilityTheme",
|
|
|
|
"eMetric_ScrollArrowStyle",
|
|
|
|
"eMetric_ScrollSliderStyle",
|
2008-04-19 09:07:10 -07:00
|
|
|
"eMetric_ScrollButtonLeftMouseButtonAction",
|
|
|
|
"eMetric_ScrollButtonMiddleMouseButtonAction",
|
|
|
|
"eMetric_ScrollButtonRightMouseButtonAction",
|
2008-04-19 08:31:50 -07:00
|
|
|
"eMetric_TreeOpenDelay",
|
|
|
|
"eMetric_TreeCloseDelay",
|
|
|
|
"eMetric_TreeLazyScrollDelay",
|
|
|
|
"eMetric_TreeScrollDelay",
|
2008-04-19 09:07:10 -07:00
|
|
|
"eMetric_TreeScrollLinesMax",
|
|
|
|
"eMetric_TabFocusModel",
|
|
|
|
"eMetric_WindowsDefaultTheme",
|
|
|
|
"eMetric_AlertNotificationOrigin",
|
|
|
|
"eMetric_ScrollToClick",
|
|
|
|
"eMetric_IMERawInputUnderlineStyle",
|
|
|
|
"eMetric_IMESelectedRawTextUnderlineStyle",
|
|
|
|
"eMetric_IMEConvertedTextUnderlineStyle",
|
|
|
|
"eMetric_IMESelectedConvertedTextUnderline",
|
|
|
|
"eMetric_ImagesInMenus"
|
2008-04-19 08:31:50 -07:00
|
|
|
};
|
2008-04-19 09:07:10 -07:00
|
|
|
#endif
|
2008-04-19 08:31:50 -07:00
|
|
|
|
|
|
|
NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID,PRInt32 &aMetric)
|
|
|
|
{
|
2008-04-19 09:07:10 -07:00
|
|
|
#ifdef NS_LOOKANDFEEL_DEBUG
|
|
|
|
qDebug("nsLookAndFeel::GetMetric aID = %s", metricToString[aID]);
|
|
|
|
#endif
|
|
|
|
|
2008-04-19 09:04:37 -07:00
|
|
|
nsresult res = nsXPLookAndFeel::GetMetric(aID, aMetric);
|
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
return res;
|
2008-04-19 09:07:10 -07:00
|
|
|
|
2008-04-19 09:04:37 -07:00
|
|
|
res = NS_OK;
|
|
|
|
|
|
|
|
switch (aID) {
|
|
|
|
case eMetric_CaretBlinkTime:
|
|
|
|
aMetric = 500;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eMetric_CaretWidth:
|
|
|
|
aMetric = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eMetric_ShowCaretDuringSelection:
|
|
|
|
aMetric = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eMetric_SelectTextfieldsOnKeyFocus:
|
|
|
|
// Select textfield content when focused by kbd
|
|
|
|
// used by nsEventStateManager::sTextfieldSelectModel
|
|
|
|
aMetric = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eMetric_SubmenuDelay:
|
|
|
|
aMetric = 200;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eMetric_MenusCanOverlapOSBar:
|
|
|
|
// we want XUL popups to be able to overlap the task bar.
|
|
|
|
aMetric = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eMetric_ScrollArrowStyle:
|
|
|
|
aMetric = eMetric_ScrollArrowStyleSingle;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eMetric_ScrollSliderStyle:
|
|
|
|
aMetric = eMetric_ScrollThumbStyleProportional;
|
|
|
|
break;
|
|
|
|
|
2009-08-10 19:59:06 -07:00
|
|
|
case eMetric_TouchEnabled:
|
2010-02-04 06:42:47 -08:00
|
|
|
#ifdef MOZ_PLATFORM_MAEMO
|
2010-02-04 06:49:55 -08:00
|
|
|
// All known Maemo devices are touch enabled.
|
2010-02-04 06:42:47 -08:00
|
|
|
aMetric = 1;
|
|
|
|
#else
|
|
|
|
aMetric = 0;
|
|
|
|
res = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eMetric_WindowsDefaultTheme:
|
2009-10-04 18:31:26 -07:00
|
|
|
case eMetric_MaemoClassic:
|
2008-04-19 09:07:10 -07:00
|
|
|
aMetric = 0;
|
|
|
|
res = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
break;
|
|
|
|
|
2009-04-03 00:26:28 -07:00
|
|
|
case eMetric_SpellCheckerUnderlineStyle:
|
|
|
|
aMetric = NS_UNDERLINE_STYLE_WAVY;
|
|
|
|
break;
|
|
|
|
|
2008-04-19 09:04:37 -07:00
|
|
|
default:
|
|
|
|
aMetric = 0;
|
|
|
|
res = NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
return res;
|
2008-04-19 08:31:50 -07:00
|
|
|
}
|
|
|
|
|
2008-04-19 09:07:10 -07:00
|
|
|
#ifdef NS_LOOKANDFEEL_DEBUG
|
|
|
|
static const char *floatMetricToString[] = {
|
|
|
|
"eMetricFloat_IMEUnderlineRelativeSize"
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2008-04-19 08:31:50 -07:00
|
|
|
NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricFloatID aID,
|
|
|
|
float &aMetric)
|
|
|
|
{
|
2008-04-19 09:07:10 -07:00
|
|
|
#ifdef NS_LOOKANDFEEL_DEBUG
|
|
|
|
qDebug("nsLookAndFeel::GetMetric aID = %s", floatMetricToString[aID]);
|
|
|
|
#endif
|
|
|
|
|
2008-04-19 09:04:37 -07:00
|
|
|
nsresult res = nsXPLookAndFeel::GetMetric(aID, aMetric);
|
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
return res;
|
|
|
|
res = NS_OK;
|
|
|
|
|
|
|
|
switch (aID) {
|
|
|
|
case eMetricFloat_IMEUnderlineRelativeSize:
|
|
|
|
aMetric = 1.0f;
|
|
|
|
break;
|
|
|
|
|
2009-04-03 00:26:28 -07:00
|
|
|
case eMetricFloat_SpellCheckerUnderlineRelativeSize:
|
|
|
|
aMetric = 1.0f;
|
|
|
|
break;
|
|
|
|
|
2008-04-19 09:04:37 -07:00
|
|
|
default:
|
|
|
|
aMetric = -1.0;
|
|
|
|
res = NS_ERROR_FAILURE;
|
2008-04-19 09:07:10 -07:00
|
|
|
break;
|
2008-04-19 09:04:37 -07:00
|
|
|
}
|
|
|
|
return res;
|
2008-04-19 08:31:50 -07:00
|
|
|
}
|