2006-12-07 01:31:17 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2006-12-07 01:31:17 +03:00
|
|
|
|
|
|
|
#include "nsLookAndFeel.h"
|
2012-05-17 11:53:20 +04:00
|
|
|
#include "nsCocoaFeatures.h"
|
2006-12-07 01:31:17 +03:00
|
|
|
#include "nsIServiceManager.h"
|
2008-09-17 15:45:30 +04:00
|
|
|
#include "nsNativeThemeColors.h"
|
2011-03-31 16:26:49 +04:00
|
|
|
#include "nsStyleConsts.h"
|
2013-05-24 01:14:00 +04:00
|
|
|
#include "nsCocoaFeatures.h"
|
2012-02-21 03:19:48 +04:00
|
|
|
#include "gfxFont.h"
|
2013-10-08 03:15:59 +04:00
|
|
|
#include "gfxFontConstants.h"
|
|
|
|
#include "mozilla/gfx/2D.h"
|
2007-01-17 01:43:05 +03:00
|
|
|
|
2008-09-17 20:23:58 +04:00
|
|
|
#import <Cocoa/Cocoa.h>
|
2006-12-07 01:31:17 +03:00
|
|
|
|
2013-01-15 16:22:03 +04:00
|
|
|
// This must be included last:
|
|
|
|
#include "nsObjCExceptions.h"
|
|
|
|
|
2013-05-02 18:58:00 +04:00
|
|
|
enum {
|
|
|
|
mozNSScrollerStyleLegacy = 0,
|
|
|
|
mozNSScrollerStyleOverlay = 1
|
|
|
|
};
|
|
|
|
typedef NSInteger mozNSScrollerStyle;
|
|
|
|
|
|
|
|
@interface NSScroller(AvailableSinceLion)
|
|
|
|
+ (mozNSScrollerStyle)preferredScrollerStyle;
|
|
|
|
@end
|
|
|
|
|
2006-12-07 01:31:17 +03:00
|
|
|
nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsLookAndFeel::~nsLookAndFeel()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-11-28 01:30:12 +03: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));
|
|
|
|
}
|
|
|
|
|
2011-09-09 06:27:13 +04:00
|
|
|
nsresult
|
|
|
|
nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor)
|
2006-12-07 01:31:17 +03:00
|
|
|
{
|
2012-10-03 01:11:43 +04:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
|
|
|
|
2006-12-07 01:31:17 +03:00
|
|
|
nsresult res = NS_OK;
|
|
|
|
|
|
|
|
switch (aID) {
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_WindowBackground:
|
2009-06-23 23:09:19 +04:00
|
|
|
aColor = NS_RGB(0xff,0xff,0xff);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_WindowForeground:
|
2006-12-07 01:31:17 +03:00
|
|
|
aColor = NS_RGB(0x00,0x00,0x00);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_WidgetBackground:
|
2006-12-07 01:31:17 +03:00
|
|
|
aColor = NS_RGB(0xdd,0xdd,0xdd);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_WidgetForeground:
|
2006-12-07 01:31:17 +03:00
|
|
|
aColor = NS_RGB(0x00,0x00,0x00);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_WidgetSelectBackground:
|
2006-12-07 01:31:17 +03:00
|
|
|
aColor = NS_RGB(0x80,0x80,0x80);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_WidgetSelectForeground:
|
2006-12-07 01:31:17 +03:00
|
|
|
aColor = NS_RGB(0x00,0x00,0x80);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_Widget3DHighlight:
|
2006-12-07 01:31:17 +03:00
|
|
|
aColor = NS_RGB(0xa0,0xa0,0xa0);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_Widget3DShadow:
|
2006-12-07 01:31:17 +03:00
|
|
|
aColor = NS_RGB(0x40,0x40,0x40);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_TextBackground:
|
2006-12-07 01:31:17 +03:00
|
|
|
aColor = NS_RGB(0xff,0xff,0xff);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_TextForeground:
|
2006-12-07 01:31:17 +03:00
|
|
|
aColor = NS_RGB(0x00,0x00,0x00);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_TextSelectBackground:
|
2009-09-22 12:03:17 +04:00
|
|
|
aColor = GetColorFromNSColor([NSColor selectedTextBackgroundColor]);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_highlight: // CSS2 color
|
2009-09-22 12:03:17 +04:00
|
|
|
aColor = GetColorFromNSColor([NSColor alternateSelectedControlColor]);
|
2007-05-08 00:27:53 +04:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_menuhover:
|
2009-09-22 12:03:17 +04:00
|
|
|
aColor = GetColorFromNSColor([NSColor alternateSelectedControlColor]);
|
2007-02-21 00:52:04 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_TextSelectForeground:
|
|
|
|
GetColor(eColorID_TextSelectBackground, aColor);
|
2007-02-21 00:52:04 +03:00
|
|
|
if (aColor == 0x000000)
|
|
|
|
aColor = NS_RGB(0xff,0xff,0xff);
|
|
|
|
else
|
|
|
|
aColor = NS_DONT_CHANGE_COLOR;
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_highlighttext: // CSS2 color
|
|
|
|
case eColorID__moz_menuhovertext:
|
2009-09-22 12:03:17 +04:00
|
|
|
aColor = GetColorFromNSColor([NSColor alternateSelectedControlTextColor]);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_IMESelectedRawTextBackground:
|
|
|
|
case eColorID_IMESelectedConvertedTextBackground:
|
|
|
|
case eColorID_IMERawInputBackground:
|
|
|
|
case eColorID_IMEConvertedTextBackground:
|
2006-12-07 01:31:17 +03:00
|
|
|
aColor = NS_TRANSPARENT;
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_IMESelectedRawTextForeground:
|
|
|
|
case eColorID_IMESelectedConvertedTextForeground:
|
|
|
|
case eColorID_IMERawInputForeground:
|
|
|
|
case eColorID_IMEConvertedTextForeground:
|
2006-12-07 01:31:17 +03:00
|
|
|
aColor = NS_SAME_AS_FOREGROUND_COLOR;
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_IMERawInputUnderline:
|
|
|
|
case eColorID_IMEConvertedTextUnderline:
|
2006-12-07 01:31:17 +03:00
|
|
|
aColor = NS_40PERCENT_FOREGROUND_COLOR;
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_IMESelectedRawTextUnderline:
|
|
|
|
case eColorID_IMESelectedConvertedTextUnderline:
|
2006-12-07 01:31:17 +03:00
|
|
|
aColor = NS_SAME_AS_FOREGROUND_COLOR;
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_SpellCheckerUnderline:
|
2009-04-03 11:26:28 +04:00
|
|
|
aColor = NS_RGB(0xff, 0, 0);
|
|
|
|
break;
|
|
|
|
|
2006-12-07 01:31:17 +03: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 ;)
|
|
|
|
//
|
|
|
|
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_buttontext:
|
|
|
|
case eColorID__moz_buttonhovertext:
|
2009-09-22 12:03:17 +04:00
|
|
|
aColor = GetColorFromNSColor([NSColor controlTextColor]);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_captiontext:
|
|
|
|
case eColorID_menutext:
|
|
|
|
case eColorID_infotext:
|
|
|
|
case eColorID__moz_menubartext:
|
2009-09-24 10:19:40 +04:00
|
|
|
aColor = GetColorFromNSColor([NSColor textColor]);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_windowtext:
|
2009-09-22 12:03:17 +04:00
|
|
|
aColor = GetColorFromNSColor([NSColor windowFrameTextColor]);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_activecaption:
|
2009-09-23 06:21:38 +04:00
|
|
|
aColor = GetColorFromNSColor([NSColor gridColor]);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_activeborder:
|
2009-09-22 12:03:17 +04:00
|
|
|
aColor = NS_RGB(0x00,0x00,0x00);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_appworkspace:
|
2009-09-22 12:03:17 +04:00
|
|
|
aColor = NS_RGB(0xFF,0xFF,0xFF);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_background:
|
2006-12-07 01:31:17 +03:00
|
|
|
aColor = NS_RGB(0x63,0x63,0xCE);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_buttonface:
|
|
|
|
case eColorID__moz_buttonhoverface:
|
2009-09-22 12:03:17 +04:00
|
|
|
aColor = NS_RGB(0xF0,0xF0,0xF0);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_buttonhighlight:
|
2009-09-22 12:03:17 +04:00
|
|
|
aColor = NS_RGB(0xFF,0xFF,0xFF);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_buttonshadow:
|
2009-09-22 12:03:17 +04:00
|
|
|
aColor = NS_RGB(0xDC,0xDC,0xDC);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_graytext:
|
2008-11-28 01:30:12 +03:00
|
|
|
aColor = GetColorFromNSColor([NSColor disabledControlTextColor]);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_inactiveborder:
|
2009-09-22 12:03:17 +04:00
|
|
|
aColor = GetColorFromNSColor([NSColor controlBackgroundColor]);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_inactivecaption:
|
2009-09-22 12:03:17 +04:00
|
|
|
aColor = GetColorFromNSColor([NSColor controlBackgroundColor]);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_inactivecaptiontext:
|
2009-09-22 12:03:17 +04:00
|
|
|
aColor = NS_RGB(0x45,0x45,0x45);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_scrollbar:
|
2009-09-22 12:03:17 +04:00
|
|
|
aColor = GetColorFromNSColor([NSColor scrollBarColor]);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_threeddarkshadow:
|
2009-09-22 12:03:17 +04:00
|
|
|
aColor = NS_RGB(0xDC,0xDC,0xDC);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_threedshadow:
|
2009-09-22 12:03:17 +04:00
|
|
|
aColor = NS_RGB(0xE0,0xE0,0xE0);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_threedface:
|
2009-09-22 12:03:17 +04:00
|
|
|
aColor = NS_RGB(0xF0,0xF0,0xF0);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_threedhighlight:
|
2009-09-22 12:03:17 +04:00
|
|
|
aColor = GetColorFromNSColor([NSColor highlightColor]);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_threedlightshadow:
|
2009-09-22 12:03:17 +04:00
|
|
|
aColor = NS_RGB(0xDA,0xDA,0xDA);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_menu:
|
2009-09-22 12:03:17 +04:00
|
|
|
aColor = GetColorFromNSColor([NSColor alternateSelectedControlTextColor]);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_infobackground:
|
2007-01-27 18:23:33 +03:00
|
|
|
aColor = NS_RGB(0xFF,0xFF,0xC7);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_windowframe:
|
2009-09-23 06:21:38 +04:00
|
|
|
aColor = GetColorFromNSColor([NSColor gridColor]);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID_window:
|
|
|
|
case eColorID__moz_field:
|
|
|
|
case eColorID__moz_combobox:
|
2006-12-07 01:31:17 +03:00
|
|
|
aColor = NS_RGB(0xff,0xff,0xff);
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_fieldtext:
|
|
|
|
case eColorID__moz_comboboxtext:
|
2009-09-22 12:03:17 +04:00
|
|
|
aColor = GetColorFromNSColor([NSColor controlTextColor]);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_dialog:
|
2009-09-23 06:21:38 +04:00
|
|
|
aColor = GetColorFromNSColor([NSColor controlHighlightColor]);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_dialogtext:
|
|
|
|
case eColorID__moz_cellhighlighttext:
|
|
|
|
case eColorID__moz_html_cellhighlighttext:
|
2009-09-22 12:03:17 +04:00
|
|
|
aColor = GetColorFromNSColor([NSColor controlTextColor]);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_dragtargetzone:
|
2009-09-22 12:03:17 +04:00
|
|
|
aColor = GetColorFromNSColor([NSColor selectedControlColor]);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_mac_chrome_active:
|
|
|
|
case eColorID__moz_mac_chrome_inactive: {
|
|
|
|
int grey = NativeGreyColorAsInt(toolbarFillGrey, (aID == eColorID__moz_mac_chrome_active));
|
2008-09-17 15:45:30 +04:00
|
|
|
aColor = NS_RGB(grey, grey, grey);
|
|
|
|
}
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_mac_focusring:
|
2010-12-21 21:51:00 +03:00
|
|
|
aColor = GetColorFromNSColor([NSColor keyboardFocusIndicatorColor]);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_mac_menushadow:
|
2009-09-22 12:03:17 +04:00
|
|
|
aColor = NS_RGB(0xA3,0xA3,0xA3);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_mac_menutextdisable:
|
2012-11-09 14:22:36 +04:00
|
|
|
aColor = NS_RGB(0x88,0x88,0x88);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_mac_menutextselect:
|
2009-09-22 12:03:17 +04:00
|
|
|
aColor = GetColorFromNSColor([NSColor selectedMenuItemTextColor]);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_mac_disabledtoolbartext:
|
2013-09-18 13:06:07 +04:00
|
|
|
aColor = GetColorFromNSColor([NSColor disabledControlTextColor]);
|
2008-12-09 19:48:51 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_mac_menuselect:
|
2009-09-22 12:03:17 +04:00
|
|
|
aColor = GetColorFromNSColor([NSColor alternateSelectedControlColor]);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_buttondefault:
|
2009-09-22 12:03:17 +04:00
|
|
|
aColor = NS_RGB(0xDC,0xDC,0xDC);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_cellhighlight:
|
|
|
|
case eColorID__moz_html_cellhighlight:
|
|
|
|
case eColorID__moz_mac_secondaryhighlight:
|
2006-12-07 01:31:17 +03:00
|
|
|
// For inactive list selection
|
2009-09-22 12:03:17 +04:00
|
|
|
aColor = GetColorFromNSColor([NSColor secondarySelectedControlColor]);
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_eventreerow:
|
2009-09-22 12:03:17 +04:00
|
|
|
// Background color of even list rows.
|
|
|
|
aColor = GetColorFromNSColor([[NSColor controlAlternatingRowBackgroundColors] objectAtIndex:0]);
|
2008-04-24 12:08:33 +04:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_oddtreerow:
|
2008-04-24 12:08:33 +04:00
|
|
|
// Background color of odd list rows.
|
2009-09-22 12:03:17 +04:00
|
|
|
aColor = GetColorFromNSColor([[NSColor controlAlternatingRowBackgroundColors] objectAtIndex:1]);
|
2008-03-29 14:43:31 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eColorID__moz_nativehyperlinktext:
|
2008-07-11 22:34:53 +04:00
|
|
|
// There appears to be no available system defined color. HARDCODING to the appropriate color.
|
|
|
|
aColor = NS_RGB(0x14,0x4F,0xAE);
|
|
|
|
break;
|
2006-12-07 01:31:17 +03: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;
|
2012-10-03 01:11:43 +04:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
2006-12-07 01:31:17 +03:00
|
|
|
}
|
|
|
|
|
2011-09-09 06:27:13 +04:00
|
|
|
nsresult
|
2012-08-22 19:56:38 +04:00
|
|
|
nsLookAndFeel::GetIntImpl(IntID aID, int32_t &aResult)
|
2006-12-07 01:31:17 +03:00
|
|
|
{
|
2008-02-19 23:58:01 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
|
|
|
|
2011-09-09 06:27:13 +04:00
|
|
|
nsresult res = nsXPLookAndFeel::GetIntImpl(aID, aResult);
|
2006-12-07 01:31:17 +03:00
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
return res;
|
|
|
|
res = NS_OK;
|
|
|
|
|
|
|
|
switch (aID) {
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_CaretBlinkTime:
|
|
|
|
aResult = 567;
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_CaretWidth:
|
|
|
|
aResult = 1;
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_ShowCaretDuringSelection:
|
|
|
|
aResult = 0;
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_SelectTextfieldsOnKeyFocus:
|
2006-12-07 01:31:17 +03:00
|
|
|
// Select textfield content when focused by kbd
|
|
|
|
// used by nsEventStateManager::sTextfieldSelectModel
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = 1;
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_SubmenuDelay:
|
|
|
|
aResult = 200;
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-12-16 13:18:48 +04:00
|
|
|
case eIntID_TooltipDelay:
|
|
|
|
aResult = 500;
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_MenusCanOverlapOSBar:
|
2006-12-07 01:31:17 +03:00
|
|
|
// xul popups are not allowed to overlap the menubar.
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = 0;
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_SkipNavigatingDisabledMenuItem:
|
|
|
|
aResult = 1;
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_DragThresholdX:
|
|
|
|
case eIntID_DragThresholdY:
|
|
|
|
aResult = 4;
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_ScrollArrowStyle:
|
2012-05-17 11:53:20 +04:00
|
|
|
if (nsCocoaFeatures::OnLionOrLater()) {
|
2011-05-16 21:56:03 +04:00
|
|
|
// OS X Lion's scrollbars have no arrows
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = eScrollArrow_None;
|
2009-09-22 12:03:17 +04:00
|
|
|
} else {
|
2011-05-16 21:56:03 +04:00
|
|
|
NSString *buttonPlacement = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleScrollBarVariant"];
|
|
|
|
if ([buttonPlacement isEqualToString:@"Single"]) {
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = eScrollArrowStyle_Single;
|
2011-05-16 21:56:03 +04:00
|
|
|
} else if ([buttonPlacement isEqualToString:@"DoubleMin"]) {
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = eScrollArrowStyle_BothAtTop;
|
2011-05-16 21:56:03 +04:00
|
|
|
} else if ([buttonPlacement isEqualToString:@"DoubleBoth"]) {
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = eScrollArrowStyle_BothAtEachEnd;
|
2011-05-16 21:56:03 +04:00
|
|
|
} else {
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = eScrollArrowStyle_BothAtBottom; // The default is BothAtBottom.
|
2011-05-16 21:56:03 +04:00
|
|
|
}
|
2006-12-07 01:31:17 +03:00
|
|
|
}
|
2011-05-16 21:56:03 +04:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_ScrollSliderStyle:
|
|
|
|
aResult = eScrollThumbStyle_Proportional;
|
2011-05-16 21:56:03 +04:00
|
|
|
break;
|
2013-05-02 18:58:00 +04:00
|
|
|
case eIntID_UseOverlayScrollbars:
|
2013-06-07 23:44:24 +04:00
|
|
|
aResult = SystemWantsOverlayScrollbars() ? 1 : 0;
|
2013-05-24 01:14:00 +04:00
|
|
|
break;
|
|
|
|
case eIntID_AllowOverlayScrollbarsOverlap:
|
|
|
|
aResult = AllowOverlayScrollbarsOverlap() ? 1 : 0;
|
2013-05-02 18:58:00 +04:00
|
|
|
break;
|
2013-07-02 14:02:21 +04:00
|
|
|
case eIntID_ScrollbarDisplayOnMouseMove:
|
|
|
|
aResult = 0;
|
|
|
|
break;
|
|
|
|
case eIntID_ScrollbarFadeBeginDelay:
|
|
|
|
aResult = 450;
|
|
|
|
break;
|
|
|
|
case eIntID_ScrollbarFadeDuration:
|
|
|
|
aResult = 200;
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_TreeOpenDelay:
|
|
|
|
aResult = 1000;
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_TreeCloseDelay:
|
|
|
|
aResult = 1000;
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_TreeLazyScrollDelay:
|
|
|
|
aResult = 150;
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_TreeScrollDelay:
|
|
|
|
aResult = 100;
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_TreeScrollLinesMax:
|
|
|
|
aResult = 3;
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_DWMCompositor:
|
|
|
|
case eIntID_WindowsClassic:
|
|
|
|
case eIntID_WindowsDefaultTheme:
|
|
|
|
case eIntID_TouchEnabled:
|
|
|
|
case eIntID_WindowsThemeIdentifier:
|
2013-07-01 20:02:29 +04:00
|
|
|
case eIntID_OperatingSystemVersionIdentifier:
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = 0;
|
2008-04-08 22:36:53 +04:00
|
|
|
res = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_MacGraphiteTheme:
|
|
|
|
aResult = [NSColor currentControlTint] == NSGraphiteControlTint;
|
2008-09-17 20:23:58 +04:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_MacLionTheme:
|
2012-05-17 11:53:20 +04:00
|
|
|
aResult = nsCocoaFeatures::OnLionOrLater();
|
2011-08-18 12:40:27 +04:00
|
|
|
break;
|
2013-03-18 17:24:54 +04:00
|
|
|
case eIntID_AlertNotificationOrigin:
|
|
|
|
aResult = NS_ALERT_TOP;
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_TabFocusModel:
|
2006-12-07 01:31:17 +03:00
|
|
|
{
|
|
|
|
// we should probably cache this
|
|
|
|
CFPropertyListRef fullKeyboardAccessProperty;
|
|
|
|
fullKeyboardAccessProperty = ::CFPreferencesCopyValue(CFSTR("AppleKeyboardUIMode"),
|
|
|
|
kCFPreferencesAnyApplication,
|
|
|
|
kCFPreferencesCurrentUser,
|
|
|
|
kCFPreferencesAnyHost);
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = 1; // default to just textboxes
|
2006-12-07 01:31:17 +03:00
|
|
|
if (fullKeyboardAccessProperty) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t fullKeyboardAccessPrefVal;
|
2006-12-07 01:31:17 +03:00
|
|
|
if (::CFNumberGetValue((CFNumberRef) fullKeyboardAccessProperty, kCFNumberIntType, &fullKeyboardAccessPrefVal)) {
|
|
|
|
// the second bit means "Full keyboard access" is on
|
|
|
|
if (fullKeyboardAccessPrefVal & (1 << 1))
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = 7; // everything that can be focused
|
2006-12-07 01:31:17 +03:00
|
|
|
}
|
|
|
|
::CFRelease(fullKeyboardAccessProperty);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_ScrollToClick:
|
2007-04-12 04:36:40 +04:00
|
|
|
{
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = [[NSUserDefaults standardUserDefaults] boolForKey:@"AppleScrollerPagingBehavior"];
|
2007-04-12 04:36:40 +04:00
|
|
|
}
|
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_ChosenMenuItemsShouldBlink:
|
|
|
|
aResult = 1;
|
2010-04-19 18:12:58 +04:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_IMERawInputUnderlineStyle:
|
|
|
|
case eIntID_IMEConvertedTextUnderlineStyle:
|
|
|
|
case eIntID_IMESelectedRawTextUnderlineStyle:
|
|
|
|
case eIntID_IMESelectedConvertedTextUnderline:
|
|
|
|
aResult = NS_STYLE_TEXT_DECORATION_STYLE_SOLID;
|
2007-08-17 00:35:18 +04:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eIntID_SpellCheckerUnderlineStyle:
|
|
|
|
aResult = NS_STYLE_TEXT_DECORATION_STYLE_DOTTED;
|
2009-04-03 11:26:28 +04:00
|
|
|
break;
|
2011-11-18 03:41:35 +04:00
|
|
|
case eIntID_ScrollbarButtonAutoRepeatBehavior:
|
|
|
|
aResult = 0;
|
|
|
|
break;
|
2013-04-09 23:44:01 +04:00
|
|
|
case eIntID_SwipeAnimationEnabled:
|
|
|
|
aResult = 0;
|
|
|
|
if ([NSEvent respondsToSelector:@selector(
|
|
|
|
isSwipeTrackingFromScrollEventsEnabled)]) {
|
|
|
|
aResult = [NSEvent isSwipeTrackingFromScrollEventsEnabled] ? 1 : 0;
|
|
|
|
}
|
|
|
|
break;
|
2006-12-07 01:31:17 +03:00
|
|
|
default:
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = 0;
|
2006-12-07 01:31:17 +03:00
|
|
|
res = NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
return res;
|
2008-02-19 23:58:01 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
2006-12-07 01:31:17 +03:00
|
|
|
}
|
|
|
|
|
2011-09-09 06:27:13 +04:00
|
|
|
nsresult
|
|
|
|
nsLookAndFeel::GetFloatImpl(FloatID aID, float &aResult)
|
2006-12-07 01:31:17 +03:00
|
|
|
{
|
2011-09-09 06:27:13 +04:00
|
|
|
nsresult res = nsXPLookAndFeel::GetFloatImpl(aID, aResult);
|
2006-12-07 01:31:17 +03:00
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
return res;
|
|
|
|
res = NS_OK;
|
|
|
|
|
|
|
|
switch (aID) {
|
2011-09-09 06:27:13 +04:00
|
|
|
case eFloatID_IMEUnderlineRelativeSize:
|
|
|
|
aResult = 2.0f;
|
2006-12-07 01:31:17 +03:00
|
|
|
break;
|
2011-09-09 06:27:13 +04:00
|
|
|
case eFloatID_SpellCheckerUnderlineRelativeSize:
|
|
|
|
aResult = 2.0f;
|
2009-04-03 11:26:28 +04:00
|
|
|
break;
|
2006-12-07 01:31:17 +03:00
|
|
|
default:
|
2011-09-09 06:27:13 +04:00
|
|
|
aResult = -1.0;
|
2006-12-07 01:31:17 +03:00
|
|
|
res = NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
2012-02-21 03:19:48 +04:00
|
|
|
|
2013-05-02 18:58:00 +04:00
|
|
|
bool nsLookAndFeel::UseOverlayScrollbars()
|
2013-06-07 23:44:24 +04:00
|
|
|
{
|
|
|
|
return GetInt(eIntID_UseOverlayScrollbars) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool nsLookAndFeel::SystemWantsOverlayScrollbars()
|
2013-05-02 18:58:00 +04:00
|
|
|
{
|
2013-05-24 01:14:00 +04:00
|
|
|
return ([NSScroller respondsToSelector:@selector(preferredScrollerStyle)] &&
|
|
|
|
[NSScroller preferredScrollerStyle] == mozNSScrollerStyleOverlay);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool nsLookAndFeel::AllowOverlayScrollbarsOverlap()
|
|
|
|
{
|
|
|
|
return (UseOverlayScrollbars() && nsCocoaFeatures::OnMountainLionOrLater());
|
2013-05-02 18:58:00 +04:00
|
|
|
}
|
|
|
|
|
2012-02-21 03:19:48 +04:00
|
|
|
// copied from gfxQuartzFontCache.mm, maybe should go in a Cocoa utils
|
|
|
|
// file somewhere
|
|
|
|
static void GetStringForNSString(const NSString *aSrc, nsAString& aDest)
|
|
|
|
{
|
|
|
|
aDest.SetLength([aSrc length]);
|
2013-10-10 20:59:40 +04:00
|
|
|
[aSrc getCharacters:reinterpret_cast<unichar*>(aDest.BeginWriting())];
|
2012-02-21 03:19:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsLookAndFeel::GetFontImpl(FontID aID, nsString &aFontName,
|
2012-09-29 15:35:08 +04:00
|
|
|
gfxFontStyle &aFontStyle,
|
|
|
|
float aDevPixPerCSSPixel)
|
2012-02-21 03:19:48 +04:00
|
|
|
{
|
2012-10-03 01:11:43 +04:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
|
|
|
|
|
2012-02-21 03:19:48 +04:00
|
|
|
// hack for now
|
|
|
|
if (aID == eFont_Window || aID == eFont_Document) {
|
2012-03-15 13:04:46 +04:00
|
|
|
aFontStyle.style = NS_FONT_STYLE_NORMAL;
|
|
|
|
aFontStyle.weight = NS_FONT_WEIGHT_NORMAL;
|
2012-02-21 03:19:48 +04:00
|
|
|
aFontStyle.stretch = NS_FONT_STRETCH_NORMAL;
|
2012-09-29 15:35:08 +04:00
|
|
|
aFontStyle.size = 14 * aDevPixPerCSSPixel;
|
2012-02-21 03:19:48 +04:00
|
|
|
aFontStyle.systemFont = true;
|
|
|
|
|
|
|
|
aFontName.AssignLiteral("sans-serif");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* possibilities, see NSFont Class Reference:
|
|
|
|
[NSFont boldSystemFontOfSize: 0.0]
|
|
|
|
[NSFont controlContentFontOfSize: 0.0]
|
|
|
|
[NSFont labelFontOfSize: 0.0]
|
|
|
|
[NSFont menuBarFontOfSize: 0.0]
|
|
|
|
[NSFont menuFontOfSize: 0.0]
|
|
|
|
[NSFont messageFontOfSize: 0.0]
|
|
|
|
[NSFont paletteFontOfSize: 0.0]
|
|
|
|
[NSFont systemFontOfSize: 0.0]
|
|
|
|
[NSFont titleBarFontOfSize: 0.0]
|
|
|
|
[NSFont toolTipsFontOfSize: 0.0]
|
|
|
|
[NSFont userFixedPitchFontOfSize: 0.0]
|
|
|
|
[NSFont userFontOfSize: 0.0]
|
|
|
|
[NSFont systemFontOfSize: [NSFont smallSystemFontSize]]
|
|
|
|
[NSFont boldSystemFontOfSize: [NSFont smallSystemFontSize]]
|
|
|
|
*/
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
NSFont *font = nullptr;
|
2012-02-21 03:19:48 +04:00
|
|
|
switch (aID) {
|
|
|
|
// css2
|
|
|
|
case eFont_Caption:
|
|
|
|
font = [NSFont systemFontOfSize:0.0];
|
|
|
|
break;
|
|
|
|
case eFont_Icon: // used in urlbar; tried labelFont, but too small
|
|
|
|
font = [NSFont controlContentFontOfSize:0.0];
|
|
|
|
break;
|
|
|
|
case eFont_Menu:
|
|
|
|
font = [NSFont systemFontOfSize:0.0];
|
|
|
|
break;
|
|
|
|
case eFont_MessageBox:
|
|
|
|
font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
|
|
|
|
break;
|
|
|
|
case eFont_SmallCaption:
|
|
|
|
font = [NSFont boldSystemFontOfSize:[NSFont smallSystemFontSize]];
|
|
|
|
break;
|
|
|
|
case eFont_StatusBar:
|
|
|
|
font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
|
|
|
|
break;
|
|
|
|
// css3
|
|
|
|
//case eFont_Window: = 'sans-serif'
|
|
|
|
//case eFont_Document: = 'sans-serif'
|
|
|
|
case eFont_Workspace:
|
|
|
|
font = [NSFont controlContentFontOfSize:0.0];
|
|
|
|
break;
|
|
|
|
case eFont_Desktop:
|
|
|
|
font = [NSFont controlContentFontOfSize:0.0];
|
|
|
|
break;
|
|
|
|
case eFont_Info:
|
|
|
|
font = [NSFont controlContentFontOfSize:0.0];
|
|
|
|
break;
|
|
|
|
case eFont_Dialog:
|
|
|
|
font = [NSFont systemFontOfSize:0.0];
|
|
|
|
break;
|
|
|
|
case eFont_Button:
|
|
|
|
font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
|
|
|
|
break;
|
|
|
|
case eFont_PullDownMenu:
|
|
|
|
font = [NSFont menuBarFontOfSize:0.0];
|
|
|
|
break;
|
|
|
|
case eFont_List:
|
|
|
|
font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
|
|
|
|
break;
|
|
|
|
case eFont_Field:
|
|
|
|
font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
|
|
|
|
break;
|
|
|
|
// moz
|
|
|
|
case eFont_Tooltips:
|
|
|
|
font = [NSFont toolTipsFontOfSize:0.0];
|
|
|
|
break;
|
|
|
|
case eFont_Widget:
|
|
|
|
font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
|
|
|
|
break;
|
2012-02-22 05:44:40 +04:00
|
|
|
default:
|
|
|
|
break;
|
2012-02-21 03:19:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!font) {
|
|
|
|
NS_WARNING("failed to find a system font!");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
NSFontSymbolicTraits traits = [[font fontDescriptor] symbolicTraits];
|
|
|
|
aFontStyle.style =
|
2012-03-15 13:04:46 +04:00
|
|
|
(traits & NSFontItalicTrait) ? NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL;
|
2012-02-21 03:19:48 +04:00
|
|
|
aFontStyle.weight =
|
2012-03-15 13:04:46 +04:00
|
|
|
(traits & NSFontBoldTrait) ? NS_FONT_WEIGHT_BOLD : NS_FONT_WEIGHT_NORMAL;
|
2012-02-21 03:19:48 +04:00
|
|
|
aFontStyle.stretch =
|
|
|
|
(traits & NSFontExpandedTrait) ?
|
|
|
|
NS_FONT_STRETCH_EXPANDED : (traits & NSFontCondensedTrait) ?
|
|
|
|
NS_FONT_STRETCH_CONDENSED : NS_FONT_STRETCH_NORMAL;
|
2012-09-29 15:35:08 +04:00
|
|
|
// convert size from css pixels to device pixels
|
|
|
|
aFontStyle.size = [font pointSize] * aDevPixPerCSSPixel;
|
2012-02-21 03:19:48 +04:00
|
|
|
aFontStyle.systemFont = true;
|
|
|
|
|
|
|
|
GetStringForNSString([font familyName], aFontName);
|
|
|
|
return true;
|
2012-10-03 01:11:43 +04:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(false);
|
2012-02-21 03:19:48 +04:00
|
|
|
}
|