2007-03-22 10:30:00 -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):
|
|
|
|
* Josh Aas <josh@mozilla.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 ***** */
|
|
|
|
|
|
|
|
#include "nsLookAndFeel.h"
|
2008-02-19 12:58:01 -08:00
|
|
|
#include "nsObjCExceptions.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIServiceManager.h"
|
2008-09-17 04:45:30 -07:00
|
|
|
#include "nsNativeThemeColors.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-09-17 09:23:58 -07:00
|
|
|
#import <Cocoa/Cocoa.h>
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsLookAndFeel::~nsLookAndFeel()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-11-27 14:30:12 -08:00
|
|
|
static nscolor GetColorFromNSColor(NSColor* aColor)
|
|
|
|
{
|
|
|
|
NSColor* deviceColor = [aColor colorUsingColorSpaceName:NSDeviceRGBColorSpace];
|
|
|
|
return NS_RGB((unsigned int)([deviceColor redComponent] * 255.0),
|
|
|
|
(unsigned int)([deviceColor greenComponent] * 255.0),
|
|
|
|
(unsigned int)([deviceColor blueComponent] * 255.0));
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult nsLookAndFeel::NativeGetColor(const nsColorID aID, nscolor &aColor)
|
|
|
|
{
|
|
|
|
nsresult res = NS_OK;
|
|
|
|
|
|
|
|
switch (aID) {
|
|
|
|
case eColor_WindowBackground:
|
2009-06-23 12:09:19 -07:00
|
|
|
aColor = NS_RGB(0xff,0xff,0xff);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor_WindowForeground:
|
|
|
|
aColor = NS_RGB(0x00,0x00,0x00);
|
|
|
|
break;
|
|
|
|
case eColor_WidgetBackground:
|
|
|
|
aColor = NS_RGB(0xdd,0xdd,0xdd);
|
|
|
|
break;
|
|
|
|
case eColor_WidgetForeground:
|
|
|
|
aColor = NS_RGB(0x00,0x00,0x00);
|
|
|
|
break;
|
|
|
|
case eColor_WidgetSelectBackground:
|
|
|
|
aColor = NS_RGB(0x80,0x80,0x80);
|
|
|
|
break;
|
|
|
|
case eColor_WidgetSelectForeground:
|
|
|
|
aColor = NS_RGB(0x00,0x00,0x80);
|
|
|
|
break;
|
|
|
|
case eColor_Widget3DHighlight:
|
|
|
|
aColor = NS_RGB(0xa0,0xa0,0xa0);
|
|
|
|
break;
|
|
|
|
case eColor_Widget3DShadow:
|
|
|
|
aColor = NS_RGB(0x40,0x40,0x40);
|
|
|
|
break;
|
|
|
|
case eColor_TextBackground:
|
|
|
|
aColor = NS_RGB(0xff,0xff,0xff);
|
|
|
|
break;
|
2009-06-23 12:09:19 -07:00
|
|
|
case eColor_TextForeground:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = NS_RGB(0x00,0x00,0x00);
|
|
|
|
break;
|
|
|
|
case eColor_TextSelectBackground:
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = GetColorFromNSColor([NSColor selectedTextBackgroundColor]);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor_highlight: // CSS2 color
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = GetColorFromNSColor([NSColor alternateSelectedControlColor]);
|
2007-05-07 13:27:53 -07:00
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
case eColor__moz_menuhover:
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = GetColorFromNSColor([NSColor alternateSelectedControlColor]);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor_TextSelectForeground:
|
|
|
|
GetColor(eColor_TextSelectBackground, aColor);
|
|
|
|
if (aColor == 0x000000)
|
|
|
|
aColor = NS_RGB(0xff,0xff,0xff);
|
|
|
|
else
|
|
|
|
aColor = NS_DONT_CHANGE_COLOR;
|
|
|
|
break;
|
|
|
|
case eColor_highlighttext: // CSS2 color
|
|
|
|
case eColor__moz_menuhovertext:
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = GetColorFromNSColor([NSColor alternateSelectedControlTextColor]);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor_IMESelectedRawTextBackground:
|
|
|
|
case eColor_IMESelectedConvertedTextBackground:
|
|
|
|
case eColor_IMERawInputBackground:
|
|
|
|
case eColor_IMEConvertedTextBackground:
|
|
|
|
aColor = NS_TRANSPARENT;
|
|
|
|
break;
|
|
|
|
case eColor_IMESelectedRawTextForeground:
|
|
|
|
case eColor_IMESelectedConvertedTextForeground:
|
|
|
|
case eColor_IMERawInputForeground:
|
|
|
|
case eColor_IMEConvertedTextForeground:
|
|
|
|
aColor = NS_SAME_AS_FOREGROUND_COLOR;
|
|
|
|
break;
|
|
|
|
case eColor_IMERawInputUnderline:
|
|
|
|
case eColor_IMEConvertedTextUnderline:
|
|
|
|
aColor = NS_40PERCENT_FOREGROUND_COLOR;
|
|
|
|
break;
|
|
|
|
case eColor_IMESelectedRawTextUnderline:
|
|
|
|
case eColor_IMESelectedConvertedTextUnderline:
|
|
|
|
aColor = NS_SAME_AS_FOREGROUND_COLOR;
|
|
|
|
break;
|
2009-04-03 00:26:28 -07:00
|
|
|
case eColor_SpellCheckerUnderline:
|
|
|
|
aColor = NS_RGB(0xff, 0, 0);
|
|
|
|
break;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//
|
|
|
|
// css2 system colors http://www.w3.org/TR/REC-CSS2/ui.html#system-colors
|
|
|
|
//
|
|
|
|
// It's really hard to effectively map these to the Appearance Manager properly,
|
|
|
|
// since they are modeled word for word after the win32 system colors and don't have any
|
|
|
|
// real counterparts in the Mac world. I'm sure we'll be tweaking these for
|
|
|
|
// years to come.
|
|
|
|
//
|
|
|
|
// Thanks to mpt26@student.canterbury.ac.nz for the hardcoded values that form the defaults
|
|
|
|
// if querying the Appearance Manager fails ;)
|
|
|
|
//
|
|
|
|
|
|
|
|
case eColor_buttontext:
|
|
|
|
case eColor__moz_buttonhovertext:
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = GetColorFromNSColor([NSColor controlTextColor]);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor_captiontext:
|
2009-09-22 19:21:38 -07:00
|
|
|
case eColor_menutext:
|
|
|
|
case eColor_infotext:
|
2009-06-14 14:58:14 -07:00
|
|
|
case eColor__moz_menubartext:
|
2009-09-23 23:19:40 -07:00
|
|
|
aColor = GetColorFromNSColor([NSColor textColor]);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor_windowtext:
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = GetColorFromNSColor([NSColor windowFrameTextColor]);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor_activecaption:
|
2009-09-22 19:21:38 -07:00
|
|
|
aColor = GetColorFromNSColor([NSColor gridColor]);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor_activeborder:
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = NS_RGB(0x00,0x00,0x00);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor_appworkspace:
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = NS_RGB(0xFF,0xFF,0xFF);
|
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
case eColor_background:
|
|
|
|
aColor = NS_RGB(0x63,0x63,0xCE);
|
|
|
|
break;
|
|
|
|
case eColor_buttonface:
|
|
|
|
case eColor__moz_buttonhoverface:
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = NS_RGB(0xF0,0xF0,0xF0);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor_buttonhighlight:
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = NS_RGB(0xFF,0xFF,0xFF);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor_buttonshadow:
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = NS_RGB(0xDC,0xDC,0xDC);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor_graytext:
|
2008-11-27 14:30:12 -08:00
|
|
|
aColor = GetColorFromNSColor([NSColor disabledControlTextColor]);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor_inactiveborder:
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = GetColorFromNSColor([NSColor controlBackgroundColor]);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor_inactivecaption:
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = GetColorFromNSColor([NSColor controlBackgroundColor]);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor_inactivecaptiontext:
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = NS_RGB(0x45,0x45,0x45);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor_scrollbar:
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = GetColorFromNSColor([NSColor scrollBarColor]);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor_threeddarkshadow:
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = NS_RGB(0xDC,0xDC,0xDC);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor_threedshadow:
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = NS_RGB(0xE0,0xE0,0xE0);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor_threedface:
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = NS_RGB(0xF0,0xF0,0xF0);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor_threedhighlight:
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = GetColorFromNSColor([NSColor highlightColor]);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor_threedlightshadow:
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = NS_RGB(0xDA,0xDA,0xDA);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor_menu:
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = GetColorFromNSColor([NSColor alternateSelectedControlTextColor]);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor_infobackground:
|
|
|
|
aColor = NS_RGB(0xFF,0xFF,0xC7);
|
|
|
|
break;
|
|
|
|
case eColor_windowframe:
|
2009-09-22 19:21:38 -07:00
|
|
|
aColor = GetColorFromNSColor([NSColor gridColor]);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor_window:
|
|
|
|
case eColor__moz_field:
|
2009-01-16 00:18:49 -08:00
|
|
|
case eColor__moz_combobox:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = NS_RGB(0xff,0xff,0xff);
|
|
|
|
break;
|
|
|
|
case eColor__moz_fieldtext:
|
2009-09-23 23:19:40 -07:00
|
|
|
case eColor__moz_comboboxtext:
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = GetColorFromNSColor([NSColor controlTextColor]);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor__moz_dialog:
|
2009-09-22 19:21:38 -07:00
|
|
|
aColor = GetColorFromNSColor([NSColor controlHighlightColor]);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor__moz_dialogtext:
|
|
|
|
case eColor__moz_cellhighlighttext:
|
2008-01-24 01:31:44 -08:00
|
|
|
case eColor__moz_html_cellhighlighttext:
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = GetColorFromNSColor([NSColor controlTextColor]);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor__moz_dragtargetzone:
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = GetColorFromNSColor([NSColor selectedControlColor]);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2008-09-17 04:45:30 -07:00
|
|
|
case eColor__moz_mac_chrome_active:
|
|
|
|
case eColor__moz_mac_chrome_inactive: {
|
|
|
|
int grey = NativeGreyColorAsInt(headerEndGrey, (aID == eColor__moz_mac_chrome_active));
|
|
|
|
aColor = NS_RGB(grey, grey, grey);
|
|
|
|
}
|
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
case eColor__moz_mac_focusring:
|
2009-09-22 00:48:55 -07:00
|
|
|
aColor = nsToolkit::OnSnowLeopardOrLater() ?
|
|
|
|
([NSColor currentControlTint] == NSGraphiteControlTint ?
|
|
|
|
NS_RGB(0x6C,0x7E,0x8D) : NS_RGB(0x3F,0x98,0xDD)) :
|
|
|
|
([NSColor currentControlTint] == NSGraphiteControlTint ?
|
|
|
|
NS_RGB(0x5F,0x70,0x82) : NS_RGB(0x53,0x90,0xD2));
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor__moz_mac_menushadow:
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = NS_RGB(0xA3,0xA3,0xA3);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor__moz_mac_menutextdisable:
|
2009-12-30 07:23:56 -08:00
|
|
|
aColor = nsToolkit::OnSnowLeopardOrLater() ?
|
|
|
|
NS_RGB(0x88,0x88,0x88) : NS_RGB(0x98,0x98,0x98);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor__moz_mac_menutextselect:
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = GetColorFromNSColor([NSColor selectedMenuItemTextColor]);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2008-12-09 08:48:51 -08:00
|
|
|
case eColor__moz_mac_disabledtoolbartext:
|
|
|
|
aColor = NS_RGB(0x3F,0x3F,0x3F);
|
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
case eColor__moz_mac_menuselect:
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = GetColorFromNSColor([NSColor alternateSelectedControlColor]);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor__moz_buttondefault:
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = NS_RGB(0xDC,0xDC,0xDC);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eColor__moz_mac_alternateprimaryhighlight:
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = GetColorFromNSColor([NSColor alternateSelectedControlColor]);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2008-01-17 02:22:34 -08:00
|
|
|
case eColor__moz_cellhighlight:
|
2008-01-24 01:47:03 -08:00
|
|
|
case eColor__moz_html_cellhighlight:
|
2007-03-22 10:30:00 -07:00
|
|
|
case eColor__moz_mac_secondaryhighlight:
|
|
|
|
// For inactive list selection
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = GetColorFromNSColor([NSColor secondarySelectedControlColor]);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2008-04-24 01:08:33 -07:00
|
|
|
case eColor__moz_eventreerow:
|
2009-09-22 01:03:17 -07:00
|
|
|
// Background color of even list rows.
|
|
|
|
aColor = GetColorFromNSColor([[NSColor controlAlternatingRowBackgroundColors] objectAtIndex:0]);
|
2008-04-24 01:08:33 -07:00
|
|
|
break;
|
|
|
|
case eColor__moz_oddtreerow:
|
|
|
|
// Background color of odd list rows.
|
2009-09-22 01:03:17 -07:00
|
|
|
aColor = GetColorFromNSColor([[NSColor controlAlternatingRowBackgroundColors] objectAtIndex:1]);
|
2008-03-29 04:43:31 -07:00
|
|
|
break;
|
2008-07-11 11:34:53 -07:00
|
|
|
case eColor__moz_nativehyperlinktext:
|
|
|
|
// There appears to be no available system defined color. HARDCODING to the appropriate color.
|
|
|
|
aColor = NS_RGB(0x14,0x4F,0xAE);
|
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
default:
|
|
|
|
NS_WARNING("Someone asked nsILookAndFeel for a color I don't know about");
|
|
|
|
aColor = NS_RGB(0xff,0xff,0xff);
|
|
|
|
res = NS_ERROR_FAILURE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric)
|
|
|
|
{
|
2008-02-19 12:58:01 -08:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult res = nsXPLookAndFeel::GetMetric(aID, aMetric);
|
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
return res;
|
|
|
|
res = NS_OK;
|
|
|
|
|
|
|
|
switch (aID) {
|
|
|
|
case eMetric_WindowTitleHeight:
|
|
|
|
aMetric = 0;
|
|
|
|
break;
|
|
|
|
case eMetric_WindowBorderWidth:
|
|
|
|
aMetric = 4;
|
|
|
|
break;
|
|
|
|
case eMetric_WindowBorderHeight:
|
|
|
|
aMetric = 4;
|
|
|
|
break;
|
|
|
|
case eMetric_Widget3DBorder:
|
|
|
|
aMetric = 4;
|
|
|
|
break;
|
|
|
|
case eMetric_TextFieldHeight:
|
|
|
|
aMetric = 16;
|
|
|
|
break;
|
|
|
|
case eMetric_TextFieldBorder:
|
|
|
|
aMetric = 2;
|
|
|
|
break;
|
|
|
|
case eMetric_ButtonHorizontalInsidePaddingNavQuirks:
|
|
|
|
aMetric = 20;
|
|
|
|
break;
|
|
|
|
case eMetric_ButtonHorizontalInsidePaddingOffsetNavQuirks:
|
|
|
|
aMetric = 0;
|
|
|
|
break;
|
|
|
|
case eMetric_CheckboxSize:
|
|
|
|
aMetric = 14;
|
|
|
|
break;
|
|
|
|
case eMetric_RadioboxSize:
|
|
|
|
aMetric = 14;
|
|
|
|
break;
|
|
|
|
case eMetric_TextHorizontalInsideMinimumPadding:
|
|
|
|
aMetric = 4;
|
|
|
|
break;
|
|
|
|
case eMetric_TextVerticalInsidePadding:
|
|
|
|
aMetric = 4;
|
|
|
|
break;
|
|
|
|
case eMetric_TextShouldUseVerticalInsidePadding:
|
|
|
|
aMetric = 1;
|
|
|
|
break;
|
|
|
|
case eMetric_TextShouldUseHorizontalInsideMinimumPadding:
|
|
|
|
aMetric = 1;
|
|
|
|
break;
|
|
|
|
case eMetric_ListShouldUseHorizontalInsideMinimumPadding:
|
|
|
|
aMetric = 0;
|
|
|
|
break;
|
|
|
|
case eMetric_ListHorizontalInsideMinimumPadding:
|
|
|
|
aMetric = 4;
|
|
|
|
break;
|
|
|
|
case eMetric_ListShouldUseVerticalInsidePadding:
|
|
|
|
aMetric = 1;
|
|
|
|
break;
|
|
|
|
case eMetric_ListVerticalInsidePadding:
|
|
|
|
aMetric = 3;
|
|
|
|
break;
|
|
|
|
case eMetric_CaretBlinkTime:
|
2009-09-22 13:51:02 -07:00
|
|
|
aMetric = 567;
|
2007-03-22 10:30:00 -07:00
|
|
|
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:
|
|
|
|
// xul popups are not allowed to overlap the menubar.
|
|
|
|
aMetric = 0;
|
|
|
|
break;
|
|
|
|
case eMetric_SkipNavigatingDisabledMenuItem:
|
|
|
|
aMetric = 1;
|
|
|
|
break;
|
|
|
|
case eMetric_DragThresholdX:
|
|
|
|
case eMetric_DragThresholdY:
|
|
|
|
aMetric = 4;
|
|
|
|
break;
|
|
|
|
case eMetric_ScrollArrowStyle:
|
2009-09-22 01:03:17 -07:00
|
|
|
{
|
|
|
|
NSString *buttonPlacement = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleScrollBarVariant"];
|
|
|
|
if ([buttonPlacement isEqualToString:@"Single"]) {
|
|
|
|
aMetric = eMetric_ScrollArrowStyleSingle;
|
|
|
|
} else if ([buttonPlacement isEqualToString:@"DoubleMin"]) {
|
|
|
|
aMetric = eMetric_ScrollArrowStyleBothAtTop;
|
|
|
|
} else if ([buttonPlacement isEqualToString:@"DoubleBoth"]) {
|
|
|
|
aMetric = eMetric_ScrollArrowStyleBothAtEachEnd;
|
|
|
|
} else {
|
|
|
|
aMetric = eMetric_ScrollArrowStyleBothAtBottom; // The default is BothAtBottom.
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2009-09-22 01:03:17 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eMetric_ScrollSliderStyle:
|
2009-09-22 01:03:17 -07:00
|
|
|
aMetric = eMetric_ScrollThumbStyleProportional;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eMetric_TreeOpenDelay:
|
|
|
|
aMetric = 1000;
|
|
|
|
break;
|
|
|
|
case eMetric_TreeCloseDelay:
|
|
|
|
aMetric = 1000;
|
|
|
|
break;
|
|
|
|
case eMetric_TreeLazyScrollDelay:
|
|
|
|
aMetric = 150;
|
|
|
|
break;
|
|
|
|
case eMetric_TreeScrollDelay:
|
|
|
|
aMetric = 100;
|
|
|
|
break;
|
|
|
|
case eMetric_TreeScrollLinesMax:
|
|
|
|
aMetric = 3;
|
|
|
|
break;
|
2008-08-12 17:44:14 -07:00
|
|
|
case eMetric_DWMCompositor:
|
2008-08-18 10:33:08 -07:00
|
|
|
case eMetric_WindowsClassic:
|
2008-04-08 11:36:53 -07:00
|
|
|
case eMetric_WindowsDefaultTheme:
|
2009-08-10 19:59:06 -07:00
|
|
|
case eMetric_TouchEnabled:
|
2009-10-04 18:31:26 -07:00
|
|
|
case eMetric_MaemoClassic:
|
2008-04-08 11:36:53 -07:00
|
|
|
aMetric = 0;
|
|
|
|
res = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
break;
|
2008-09-17 09:23:58 -07:00
|
|
|
case eMetric_MacGraphiteTheme:
|
|
|
|
aMetric = [NSColor currentControlTint] == NSGraphiteControlTint;
|
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
case eMetric_TabFocusModel:
|
|
|
|
{
|
|
|
|
// we should probably cache this
|
|
|
|
CFPropertyListRef fullKeyboardAccessProperty;
|
|
|
|
fullKeyboardAccessProperty = ::CFPreferencesCopyValue(CFSTR("AppleKeyboardUIMode"),
|
|
|
|
kCFPreferencesAnyApplication,
|
|
|
|
kCFPreferencesCurrentUser,
|
|
|
|
kCFPreferencesAnyHost);
|
|
|
|
aMetric = 1; // default to just textboxes
|
|
|
|
if (fullKeyboardAccessProperty) {
|
|
|
|
PRInt32 fullKeyboardAccessPrefVal;
|
|
|
|
if (::CFNumberGetValue((CFNumberRef) fullKeyboardAccessProperty, kCFNumberIntType, &fullKeyboardAccessPrefVal)) {
|
|
|
|
// the second bit means "Full keyboard access" is on
|
|
|
|
if (fullKeyboardAccessPrefVal & (1 << 1))
|
|
|
|
aMetric = 7; // everything that can be focused
|
|
|
|
}
|
|
|
|
::CFRelease(fullKeyboardAccessProperty);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2007-04-11 17:36:40 -07:00
|
|
|
case eMetric_ScrollToClick:
|
|
|
|
{
|
2009-09-22 01:03:17 -07:00
|
|
|
aMetric = [[NSUserDefaults standardUserDefaults] boolForKey:@"AppleScrollerPagingBehavior"];
|
2007-04-11 17:36:40 -07:00
|
|
|
}
|
|
|
|
break;
|
2007-08-16 13:35:18 -07:00
|
|
|
case eMetric_IMERawInputUnderlineStyle:
|
|
|
|
case eMetric_IMEConvertedTextUnderlineStyle:
|
|
|
|
case eMetric_IMESelectedRawTextUnderlineStyle:
|
|
|
|
case eMetric_IMESelectedConvertedTextUnderline:
|
|
|
|
aMetric = NS_UNDERLINE_STYLE_SOLID;
|
|
|
|
break;
|
2009-04-03 00:26:28 -07:00
|
|
|
case eMetric_SpellCheckerUnderlineStyle:
|
|
|
|
aMetric = NS_UNDERLINE_STYLE_DOTTED;
|
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
default:
|
|
|
|
aMetric = 0;
|
|
|
|
res = NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
return res;
|
2008-02-19 12:58:01 -08:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricFloatID aID, float & aMetric)
|
|
|
|
{
|
|
|
|
nsresult res = nsXPLookAndFeel::GetMetric(aID, aMetric);
|
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
return res;
|
|
|
|
res = NS_OK;
|
|
|
|
|
|
|
|
switch (aID) {
|
|
|
|
case eMetricFloat_TextFieldVerticalInsidePadding:
|
|
|
|
aMetric = 0.25f;
|
|
|
|
break;
|
|
|
|
case eMetricFloat_TextFieldHorizontalInsidePadding:
|
|
|
|
aMetric = 0.95f;
|
|
|
|
break;
|
|
|
|
case eMetricFloat_TextAreaVerticalInsidePadding:
|
|
|
|
aMetric = 0.40f;
|
|
|
|
break;
|
|
|
|
case eMetricFloat_TextAreaHorizontalInsidePadding:
|
|
|
|
aMetric = 0.40f;
|
|
|
|
break;
|
|
|
|
case eMetricFloat_ListVerticalInsidePadding:
|
|
|
|
aMetric = 0.08f;
|
|
|
|
break;
|
|
|
|
case eMetricFloat_ListHorizontalInsidePadding:
|
|
|
|
aMetric = 0.40f;
|
|
|
|
break;
|
|
|
|
case eMetricFloat_ButtonVerticalInsidePadding:
|
|
|
|
aMetric = 0.5f;
|
|
|
|
break;
|
|
|
|
case eMetricFloat_ButtonHorizontalInsidePadding:
|
|
|
|
aMetric = 0.5f;
|
|
|
|
break;
|
|
|
|
case eMetricFloat_IMEUnderlineRelativeSize:
|
|
|
|
aMetric = 2.0f;
|
|
|
|
break;
|
2009-04-03 00:26:28 -07:00
|
|
|
case eMetricFloat_SpellCheckerUnderlineRelativeSize:
|
|
|
|
aMetric = 2.0f;
|
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
default:
|
|
|
|
aMetric = -1.0;
|
|
|
|
res = NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|