2001-11-06 02:41:04 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; 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/. */
|
1998-07-29 18:55:25 +00:00
|
|
|
|
|
|
|
#include "nsLookAndFeel.h"
|
1999-01-21 23:59:14 +00:00
|
|
|
#include <windows.h>
|
2006-07-19 19:47:19 +00:00
|
|
|
#include <shellapi.h>
|
2011-03-31 12:26:49 +00:00
|
|
|
#include "nsStyleConsts.h"
|
2008-07-17 17:19:10 +00:00
|
|
|
#include "nsUXThemeData.h"
|
|
|
|
#include "nsUXThemeConstants.h"
|
2012-02-20 23:19:48 +00:00
|
|
|
#include "gfxFont.h"
|
2013-04-01 09:10:28 +00:00
|
|
|
#include "gfxWindowsPlatform.h"
|
2012-02-15 19:10:17 +00:00
|
|
|
#include "WinUtils.h"
|
2012-09-29 16:39:23 +00:00
|
|
|
#include "mozilla/Telemetry.h"
|
2012-02-15 19:10:17 +00:00
|
|
|
|
|
|
|
using namespace mozilla::widget;
|
2012-02-20 23:19:48 +00:00
|
|
|
using mozilla::LookAndFeel;
|
2012-02-08 16:00:47 +00:00
|
|
|
|
2008-07-17 17:19:10 +00:00
|
|
|
static nsresult GetColorFromTheme(nsUXThemeClass cls,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aPart,
|
|
|
|
int32_t aState,
|
|
|
|
int32_t aPropId,
|
2008-07-17 17:19:10 +00:00
|
|
|
nscolor &aColor)
|
|
|
|
{
|
|
|
|
COLORREF color;
|
2012-02-23 14:53:55 +00:00
|
|
|
HRESULT hr = GetThemeColor(nsUXThemeData::GetTheme(cls), aPart, aState, aPropId, &color);
|
2008-07-17 17:19:10 +00:00
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
aColor = COLOREF_2_NSRGB(color);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
static int32_t GetSystemParam(long flag, int32_t def)
|
2007-01-04 18:43:26 +00:00
|
|
|
{
|
2006-10-10 13:18:25 +00:00
|
|
|
DWORD value;
|
2007-01-04 18:43:26 +00:00
|
|
|
return ::SystemParametersInfo(flag, 0, &value, 0) ? value : def;
|
2006-10-10 13:18:25 +00:00
|
|
|
}
|
|
|
|
|
2012-10-25 14:57:51 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace widget {
|
|
|
|
// This is in use here and in nsDOMTouchEvent.cpp
|
|
|
|
int32_t IsTouchDeviceSupportPresent()
|
2012-09-29 16:39:23 +00:00
|
|
|
{
|
|
|
|
int32_t touchCapabilities;
|
|
|
|
touchCapabilities = ::GetSystemMetrics(SM_DIGITIZER);
|
|
|
|
return ((touchCapabilities & NID_READY) &&
|
|
|
|
(touchCapabilities & (NID_EXTERNAL_TOUCH | NID_INTEGRATED_TOUCH)));
|
|
|
|
}
|
2012-10-25 14:57:51 +00:00
|
|
|
} }
|
2012-09-29 16:39:23 +00:00
|
|
|
|
2001-11-06 02:41:04 +00:00
|
|
|
nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel()
|
1998-09-14 20:40:49 +00:00
|
|
|
{
|
2012-09-29 16:39:23 +00:00
|
|
|
mozilla::Telemetry::Accumulate(mozilla::Telemetry::TOUCH_ENABLED_DEVICE,
|
2012-10-25 14:57:51 +00:00
|
|
|
IsTouchDeviceSupportPresent());
|
1998-07-29 18:55:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsLookAndFeel::~nsLookAndFeel()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
nsresult
|
|
|
|
nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor)
|
1998-07-29 18:55:25 +00:00
|
|
|
{
|
1998-12-21 16:53:49 +00:00
|
|
|
nsresult res = NS_OK;
|
2000-03-30 22:42:40 +00:00
|
|
|
|
1998-12-21 16:53:49 +00:00
|
|
|
int idx;
|
|
|
|
switch (aID) {
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_WindowBackground:
|
1998-07-29 18:55:25 +00:00
|
|
|
idx = COLOR_WINDOW;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_WindowForeground:
|
1998-07-29 18:55:25 +00:00
|
|
|
idx = COLOR_WINDOWTEXT;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_WidgetBackground:
|
1998-07-29 18:55:25 +00:00
|
|
|
idx = COLOR_BTNFACE;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_WidgetForeground:
|
1998-07-29 18:55:25 +00:00
|
|
|
idx = COLOR_BTNTEXT;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_WidgetSelectBackground:
|
1998-07-29 18:55:25 +00:00
|
|
|
idx = COLOR_HIGHLIGHT;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_WidgetSelectForeground:
|
1998-07-29 18:55:25 +00:00
|
|
|
idx = COLOR_HIGHLIGHTTEXT;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_Widget3DHighlight:
|
1998-07-29 18:55:25 +00:00
|
|
|
idx = COLOR_BTNHIGHLIGHT;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_Widget3DShadow:
|
1998-07-29 18:55:25 +00:00
|
|
|
idx = COLOR_BTNSHADOW;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_TextBackground:
|
1998-07-29 18:55:25 +00:00
|
|
|
idx = COLOR_WINDOW;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_TextForeground:
|
1998-07-29 18:55:25 +00:00
|
|
|
idx = COLOR_WINDOWTEXT;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_TextSelectBackground:
|
|
|
|
case eColorID_IMESelectedRawTextBackground:
|
|
|
|
case eColorID_IMESelectedConvertedTextBackground:
|
1998-07-29 18:55:25 +00:00
|
|
|
idx = COLOR_HIGHLIGHT;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_TextSelectForeground:
|
|
|
|
case eColorID_IMESelectedRawTextForeground:
|
|
|
|
case eColorID_IMESelectedConvertedTextForeground:
|
1998-07-29 18:55:25 +00:00
|
|
|
idx = COLOR_HIGHLIGHTTEXT;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_IMERawInputBackground:
|
|
|
|
case eColorID_IMEConvertedTextBackground:
|
2005-09-17 11:34:27 +00:00
|
|
|
aColor = NS_TRANSPARENT;
|
|
|
|
return NS_OK;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_IMERawInputForeground:
|
|
|
|
case eColorID_IMEConvertedTextForeground:
|
2005-09-17 11:34:27 +00:00
|
|
|
aColor = NS_SAME_AS_FOREGROUND_COLOR;
|
|
|
|
return NS_OK;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_IMERawInputUnderline:
|
|
|
|
case eColorID_IMEConvertedTextUnderline:
|
2005-09-17 11:34:27 +00:00
|
|
|
aColor = NS_SAME_AS_FOREGROUND_COLOR;
|
|
|
|
return NS_OK;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_IMESelectedRawTextUnderline:
|
|
|
|
case eColorID_IMESelectedConvertedTextUnderline:
|
2005-09-17 11:34:27 +00:00
|
|
|
aColor = NS_TRANSPARENT;
|
|
|
|
return NS_OK;
|
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);
|
|
|
|
return NS_OK;
|
1999-09-10 18:30:55 +00:00
|
|
|
|
|
|
|
// New CSS 2 Color definitions
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_activeborder:
|
1999-09-10 18:30:55 +00:00
|
|
|
idx = COLOR_ACTIVEBORDER;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_activecaption:
|
1999-09-10 18:30:55 +00:00
|
|
|
idx = COLOR_ACTIVECAPTION;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_appworkspace:
|
1999-10-24 03:03:38 +00:00
|
|
|
idx = COLOR_APPWORKSPACE;
|
1999-09-10 18:30:55 +00:00
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_background:
|
2001-04-17 00:46:07 +00:00
|
|
|
idx = COLOR_BACKGROUND;
|
1999-09-10 18:30:55 +00:00
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_buttonface:
|
|
|
|
case eColorID__moz_buttonhoverface:
|
1999-09-10 18:30:55 +00:00
|
|
|
idx = COLOR_BTNFACE;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_buttonhighlight:
|
1999-09-10 18:30:55 +00:00
|
|
|
idx = COLOR_BTNHIGHLIGHT;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_buttonshadow:
|
1999-09-10 18:30:55 +00:00
|
|
|
idx = COLOR_BTNSHADOW;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_buttontext:
|
|
|
|
case eColorID__moz_buttonhovertext:
|
1999-09-10 18:30:55 +00:00
|
|
|
idx = COLOR_BTNTEXT;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_captiontext:
|
1999-09-10 18:30:55 +00:00
|
|
|
idx = COLOR_CAPTIONTEXT;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_graytext:
|
1999-09-10 18:30:55 +00:00
|
|
|
idx = COLOR_GRAYTEXT;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_highlight:
|
|
|
|
case eColorID__moz_html_cellhighlight:
|
|
|
|
case eColorID__moz_menuhover:
|
1999-09-10 18:30:55 +00:00
|
|
|
idx = COLOR_HIGHLIGHT;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID__moz_menubarhovertext:
|
2012-02-15 19:10:17 +00:00
|
|
|
if (WinUtils::GetWindowsVersion() < WinUtils::VISTA_VERSION ||
|
2012-02-23 14:53:55 +00:00
|
|
|
!IsAppThemed())
|
2012-02-08 21:04:21 +00:00
|
|
|
{
|
2008-07-17 17:19:10 +00:00
|
|
|
idx = nsUXThemeData::sFlatMenus ?
|
2007-08-06 17:45:57 +00:00
|
|
|
COLOR_HIGHLIGHTTEXT :
|
|
|
|
COLOR_MENUTEXT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// Fall through
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID__moz_menuhovertext:
|
2012-02-15 19:10:17 +00:00
|
|
|
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION &&
|
2012-02-23 14:53:55 +00:00
|
|
|
IsAppThemed())
|
2012-02-08 21:04:21 +00:00
|
|
|
{
|
2008-07-17 17:19:10 +00:00
|
|
|
res = ::GetColorFromTheme(eUXMenu,
|
|
|
|
MENU_POPUPITEM, MPI_HOT, TMT_TEXTCOLOR, aColor);
|
2008-04-29 19:27:23 +00:00
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
return res;
|
2007-08-06 17:45:57 +00:00
|
|
|
// fall through to highlight case
|
|
|
|
}
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_highlighttext:
|
|
|
|
case eColorID__moz_html_cellhighlighttext:
|
1999-09-10 18:30:55 +00:00
|
|
|
idx = COLOR_HIGHLIGHTTEXT;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_inactiveborder:
|
1999-09-10 18:30:55 +00:00
|
|
|
idx = COLOR_INACTIVEBORDER;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_inactivecaption:
|
1999-09-10 18:30:55 +00:00
|
|
|
idx = COLOR_INACTIVECAPTION;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_inactivecaptiontext:
|
1999-09-10 18:30:55 +00:00
|
|
|
idx = COLOR_INACTIVECAPTIONTEXT;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_infobackground:
|
1999-09-10 18:30:55 +00:00
|
|
|
idx = COLOR_INFOBK;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_infotext:
|
1999-09-10 18:30:55 +00:00
|
|
|
idx = COLOR_INFOTEXT;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_menu:
|
1999-09-10 18:30:55 +00:00
|
|
|
idx = COLOR_MENU;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_menutext:
|
|
|
|
case eColorID__moz_menubartext:
|
1999-09-10 18:30:55 +00:00
|
|
|
idx = COLOR_MENUTEXT;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_scrollbar:
|
1999-09-10 18:30:55 +00:00
|
|
|
idx = COLOR_SCROLLBAR;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_threeddarkshadow:
|
1999-09-10 18:30:55 +00:00
|
|
|
idx = COLOR_3DDKSHADOW;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_threedface:
|
1999-09-10 18:30:55 +00:00
|
|
|
idx = COLOR_3DFACE;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_threedhighlight:
|
1999-09-10 18:30:55 +00:00
|
|
|
idx = COLOR_3DHIGHLIGHT;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_threedlightshadow:
|
1999-09-10 18:30:55 +00:00
|
|
|
idx = COLOR_3DLIGHT;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_threedshadow:
|
1999-09-10 18:30:55 +00:00
|
|
|
idx = COLOR_3DSHADOW;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_window:
|
1999-09-10 18:30:55 +00:00
|
|
|
idx = COLOR_WINDOW;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_windowframe:
|
1999-09-10 18:30:55 +00:00
|
|
|
idx = COLOR_WINDOWFRAME;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID_windowtext:
|
1999-09-10 18:30:55 +00:00
|
|
|
idx = COLOR_WINDOWTEXT;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID__moz_eventreerow:
|
|
|
|
case eColorID__moz_oddtreerow:
|
|
|
|
case eColorID__moz_field:
|
|
|
|
case eColorID__moz_combobox:
|
2001-04-17 00:46:07 +00:00
|
|
|
idx = COLOR_WINDOW;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID__moz_fieldtext:
|
|
|
|
case eColorID__moz_comboboxtext:
|
2001-04-17 00:46:07 +00:00
|
|
|
idx = COLOR_WINDOWTEXT;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID__moz_dialog:
|
|
|
|
case eColorID__moz_cellhighlight:
|
2001-04-17 00:46:07 +00:00
|
|
|
idx = COLOR_3DFACE;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID__moz_win_mediatext:
|
2012-02-15 19:10:17 +00:00
|
|
|
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION &&
|
2012-02-23 14:53:55 +00:00
|
|
|
IsAppThemed()) {
|
2008-07-17 17:19:10 +00:00
|
|
|
res = ::GetColorFromTheme(eUXMediaToolbar,
|
|
|
|
TP_BUTTON, TS_NORMAL, TMT_TEXTCOLOR, aColor);
|
2008-04-29 19:27:23 +00:00
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
return res;
|
|
|
|
}
|
2009-01-05 18:17:44 +00:00
|
|
|
// if we've gotten here just return -moz-dialogtext instead
|
2008-04-29 19:27:23 +00:00
|
|
|
idx = COLOR_WINDOWTEXT;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID__moz_win_communicationstext:
|
2012-02-15 19:10:17 +00:00
|
|
|
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION &&
|
2012-02-23 14:53:55 +00:00
|
|
|
IsAppThemed())
|
2012-02-08 21:04:21 +00:00
|
|
|
{
|
2008-07-17 17:19:10 +00:00
|
|
|
res = ::GetColorFromTheme(eUXCommunicationsToolbar,
|
|
|
|
TP_BUTTON, TS_NORMAL, TMT_TEXTCOLOR, aColor);
|
2008-04-29 19:27:23 +00:00
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
return res;
|
|
|
|
}
|
2009-01-05 18:17:44 +00:00
|
|
|
// if we've gotten here just return -moz-dialogtext instead
|
2008-04-29 19:27:23 +00:00
|
|
|
idx = COLOR_WINDOWTEXT;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID__moz_dialogtext:
|
|
|
|
case eColorID__moz_cellhighlighttext:
|
2001-04-17 00:46:07 +00:00
|
|
|
idx = COLOR_WINDOWTEXT;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID__moz_dragtargetzone:
|
2003-06-18 21:16:29 +00:00
|
|
|
idx = COLOR_HIGHLIGHTTEXT;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID__moz_buttondefault:
|
2003-06-18 21:16:29 +00:00
|
|
|
idx = COLOR_3DDKSHADOW;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eColorID__moz_nativehyperlinktext:
|
2008-07-11 18:34:53 +00:00
|
|
|
idx = COLOR_HOTLIGHT;
|
|
|
|
break;
|
1998-07-29 18:55:25 +00:00
|
|
|
default:
|
2003-06-18 21:16:29 +00:00
|
|
|
idx = COLOR_WINDOW;
|
|
|
|
break;
|
1998-07-29 18:55:25 +00:00
|
|
|
}
|
|
|
|
|
2001-05-25 14:48:31 +00:00
|
|
|
DWORD color = ::GetSysColor(idx);
|
|
|
|
aColor = COLOREF_2_NSRGB(color);
|
1998-07-29 18:55:25 +00:00
|
|
|
|
1998-12-21 16:53:49 +00:00
|
|
|
return res;
|
1998-09-01 20:54:39 +00:00
|
|
|
}
|
2001-04-17 00:46:07 +00:00
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
nsresult
|
2012-08-22 15:56:38 +00:00
|
|
|
nsLookAndFeel::GetIntImpl(IntID aID, int32_t &aResult)
|
1998-07-29 18:55:25 +00:00
|
|
|
{
|
2011-09-09 02:27:13 +00:00
|
|
|
nsresult res = nsXPLookAndFeel::GetIntImpl(aID, aResult);
|
2001-11-06 02:41:04 +00:00
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
return res;
|
|
|
|
res = NS_OK;
|
2000-03-30 22:42:40 +00:00
|
|
|
|
1998-12-21 16:53:49 +00:00
|
|
|
switch (aID) {
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_CaretBlinkTime:
|
2012-08-22 15:56:38 +00:00
|
|
|
aResult = (int32_t)::GetCaretBlinkTime();
|
1999-07-14 22:16:59 +00:00
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_CaretWidth:
|
|
|
|
aResult = 1;
|
2000-07-28 22:12:45 +00:00
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_ShowCaretDuringSelection:
|
|
|
|
aResult = 0;
|
2000-12-28 03:27:23 +00:00
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_SelectTextfieldsOnKeyFocus:
|
2002-10-05 15:39:33 +00:00
|
|
|
// Select textfield content when focused by kbd
|
|
|
|
// used by nsEventStateManager::sTextfieldSelectModel
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult = 1;
|
2002-10-05 15:39:33 +00:00
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_SubmenuDelay:
|
2007-01-04 18:43:26 +00:00
|
|
|
// This will default to the Windows' default
|
2006-10-10 13:18:25 +00:00
|
|
|
// (400ms) on error.
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult = GetSystemParam(SPI_GETMENUSHOWDELAY, 400);
|
2000-01-21 21:56:09 +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:
|
2000-03-22 02:55:12 +00:00
|
|
|
// we want XUL popups to be able to overlap the task bar.
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult = 1;
|
2000-03-22 02:55:12 +00:00
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_DragThresholdX:
|
2003-05-02 18:20:38 +00:00
|
|
|
// The system metric is the number of pixels at which a drag should
|
|
|
|
// start. Our look and feel metric is the number of pixels you can
|
|
|
|
// move before starting a drag, so subtract 1.
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult = ::GetSystemMetrics(SM_CXDRAG) - 1;
|
2003-05-02 18:20:38 +00:00
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_DragThresholdY:
|
|
|
|
aResult = ::GetSystemMetrics(SM_CYDRAG) - 1;
|
2003-05-02 18:20:38 +00:00
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_UseAccessibilityTheme:
|
2004-06-08 19:34:55 +00:00
|
|
|
// High contrast is a misnomer under Win32 -- any theme can be used with it,
|
|
|
|
// e.g. normal contrast with large fonts, low contrast, etc.
|
|
|
|
// The high contrast flag really means -- use this theme and don't override it.
|
|
|
|
HIGHCONTRAST contrastThemeInfo;
|
|
|
|
contrastThemeInfo.cbSize = sizeof(contrastThemeInfo);
|
2007-01-04 18:43:26 +00:00
|
|
|
::SystemParametersInfo(SPI_GETHIGHCONTRAST, 0, &contrastThemeInfo, 0);
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult = ((contrastThemeInfo.dwFlags & HCF_HIGHCONTRASTON) != 0);
|
2004-06-08 19:34:55 +00:00
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_ScrollArrowStyle:
|
|
|
|
aResult = eScrollArrowStyle_Single;
|
2000-11-30 01:51:14 +00:00
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_ScrollSliderStyle:
|
|
|
|
aResult = eScrollThumbStyle_Proportional;
|
2000-11-30 01:51:14 +00:00
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_TreeOpenDelay:
|
|
|
|
aResult = 1000;
|
2003-03-16 23:26:31 +00:00
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_TreeCloseDelay:
|
|
|
|
aResult = 0;
|
2003-03-16 23:26:31 +00:00
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_TreeLazyScrollDelay:
|
|
|
|
aResult = 150;
|
2003-03-16 23:26:31 +00:00
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_TreeScrollDelay:
|
|
|
|
aResult = 100;
|
2003-03-16 23:26:31 +00:00
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_TreeScrollLinesMax:
|
|
|
|
aResult = 3;
|
2003-03-16 23:26:31 +00:00
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_WindowsClassic:
|
2012-02-23 14:53:55 +00:00
|
|
|
aResult = !IsAppThemed();
|
2009-08-11 02:59:06 +00:00
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_TouchEnabled:
|
2012-10-25 14:57:51 +00:00
|
|
|
aResult = IsTouchDeviceSupportPresent();
|
2008-08-18 17:33:08 +00:00
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_WindowsDefaultTheme:
|
|
|
|
aResult = nsUXThemeData::IsDefaultWindowTheme();
|
2010-10-09 20:53:44 +00:00
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_WindowsThemeIdentifier:
|
|
|
|
aResult = nsUXThemeData::GetNativeThemeId();
|
2008-04-08 18:36:53 +00:00
|
|
|
break;
|
2013-07-01 16:02:29 +00:00
|
|
|
|
|
|
|
case eIntID_OperatingSystemVersionIdentifier:
|
|
|
|
{
|
|
|
|
switch(WinUtils::GetWindowsVersion()) {
|
|
|
|
case WinUtils::WINXP_VERSION:
|
|
|
|
case WinUtils::WIN2K3_VERSION:
|
|
|
|
aResult = LookAndFeel::eOperatingSystemVersion_WindowsXP;
|
|
|
|
break;
|
|
|
|
case WinUtils::VISTA_VERSION:
|
|
|
|
aResult = LookAndFeel::eOperatingSystemVersion_WindowsVista;
|
|
|
|
break;
|
|
|
|
case WinUtils::WIN7_VERSION:
|
|
|
|
aResult = LookAndFeel::eOperatingSystemVersion_Windows7;
|
|
|
|
break;
|
|
|
|
case WinUtils::WIN8_VERSION:
|
|
|
|
aResult = LookAndFeel::eOperatingSystemVersion_Windows8;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
aResult = LookAndFeel::eOperatingSystemVersion_Unknown;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_MacGraphiteTheme:
|
|
|
|
case eIntID_MacLionTheme:
|
|
|
|
case eIntID_MaemoClassic:
|
|
|
|
aResult = 0;
|
2008-09-17 16:23:58 +00:00
|
|
|
res = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_DWMCompositor:
|
|
|
|
aResult = nsUXThemeData::CheckForCompositor();
|
2008-08-13 00:44:14 +00:00
|
|
|
break;
|
2013-01-17 03:27:16 +00:00
|
|
|
case eIntID_WindowsGlass:
|
|
|
|
// Aero Glass is only available prior to Windows 8 when DWM is used.
|
|
|
|
aResult = (nsUXThemeData::CheckForCompositor() &&
|
|
|
|
WinUtils::GetWindowsVersion() < WinUtils::WIN8_VERSION);
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_AlertNotificationOrigin:
|
|
|
|
aResult = 0;
|
2006-07-19 19:47:19 +00:00
|
|
|
{
|
|
|
|
// Get task bar window handle
|
2008-08-29 21:26:56 +00:00
|
|
|
HWND shellWindow = FindWindowW(L"Shell_TrayWnd", NULL);
|
2006-07-19 19:47:19 +00:00
|
|
|
|
|
|
|
if (shellWindow != NULL)
|
|
|
|
{
|
|
|
|
// Determine position
|
|
|
|
APPBARDATA appBarData;
|
|
|
|
appBarData.hWnd = shellWindow;
|
|
|
|
appBarData.cbSize = sizeof(appBarData);
|
2012-02-23 14:53:55 +00:00
|
|
|
if (SHAppBarMessage(ABM_GETTASKBARPOS, &appBarData))
|
2006-07-19 19:47:19 +00:00
|
|
|
{
|
2011-09-09 02:27:12 +00:00
|
|
|
// Set alert origin as a bit field - see LookAndFeel.h
|
2006-07-19 19:47:19 +00:00
|
|
|
// 0 represents bottom right, sliding vertically.
|
|
|
|
switch(appBarData.uEdge)
|
|
|
|
{
|
|
|
|
case ABE_LEFT:
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult = NS_ALERT_HORIZONTAL | NS_ALERT_LEFT;
|
2006-07-19 19:47:19 +00:00
|
|
|
break;
|
|
|
|
case ABE_RIGHT:
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult = NS_ALERT_HORIZONTAL;
|
2006-07-19 19:47:19 +00:00
|
|
|
break;
|
|
|
|
case ABE_TOP:
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult = NS_ALERT_TOP;
|
2006-12-06 20:52:09 +00:00
|
|
|
// fall through for the right-to-left handling.
|
2006-07-19 19:47:19 +00:00
|
|
|
case ABE_BOTTOM:
|
2006-12-06 20:52:09 +00:00
|
|
|
// If the task bar is right-to-left,
|
|
|
|
// move the origin to the left
|
|
|
|
if (::GetWindowLong(shellWindow, GWL_EXSTYLE) &
|
|
|
|
WS_EX_LAYOUTRTL)
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult |= NS_ALERT_LEFT;
|
2006-07-19 19:47:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_IMERawInputUnderlineStyle:
|
|
|
|
case eIntID_IMEConvertedTextUnderlineStyle:
|
|
|
|
aResult = NS_STYLE_TEXT_DECORATION_STYLE_DASHED;
|
2007-08-16 20:35:18 +00:00
|
|
|
break;
|
2011-09-09 02:27:13 +00:00
|
|
|
case eIntID_IMESelectedRawTextUnderlineStyle:
|
|
|
|
case eIntID_IMESelectedConvertedTextUnderline:
|
|
|
|
aResult = NS_STYLE_TEXT_DECORATION_STYLE_NONE;
|
2007-08-16 20:35:18 +00:00
|
|
|
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 = 0;
|
|
|
|
break;
|
2013-04-09 19:44:01 +00:00
|
|
|
case eIntID_SwipeAnimationEnabled:
|
|
|
|
aResult = 0;
|
|
|
|
break;
|
1998-07-29 18:55:25 +00:00
|
|
|
default:
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult = 0;
|
1998-09-01 20:54:39 +00:00
|
|
|
res = NS_ERROR_FAILURE;
|
1998-07-29 18:55:25 +00:00
|
|
|
}
|
1998-12-21 16:53:49 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
nsresult
|
|
|
|
nsLookAndFeel::GetFloatImpl(FloatID aID, float &aResult)
|
1998-12-21 16:53:49 +00:00
|
|
|
{
|
2011-09-09 02:27:13 +00:00
|
|
|
nsresult res = nsXPLookAndFeel::GetFloatImpl(aID, aResult);
|
2001-11-06 02:41:04 +00:00
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
return res;
|
|
|
|
res = NS_OK;
|
2000-03-30 22:42:40 +00:00
|
|
|
|
1998-12-21 16:53:49 +00:00
|
|
|
switch (aID) {
|
2011-09-09 02:27:13 +00:00
|
|
|
case eFloatID_IMEUnderlineRelativeSize:
|
|
|
|
aResult = 1.0f;
|
2005-09-17 11:34:27 +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;
|
1998-12-21 16:53:49 +00:00
|
|
|
default:
|
2011-09-09 02:27:13 +00:00
|
|
|
aResult = -1.0;
|
1998-12-21 16:53:49 +00:00
|
|
|
res = NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
return res;
|
1998-07-29 18:55:25 +00:00
|
|
|
}
|
|
|
|
|
2012-02-20 23:19:48 +00:00
|
|
|
static bool
|
|
|
|
GetSysFontInfo(HDC aHDC, LookAndFeel::FontID anID,
|
|
|
|
nsString &aFontName,
|
|
|
|
gfxFontStyle &aFontStyle)
|
|
|
|
{
|
|
|
|
LOGFONTW* ptrLogFont = NULL;
|
|
|
|
LOGFONTW logFont;
|
|
|
|
NONCLIENTMETRICSW ncm;
|
|
|
|
HGDIOBJ hGDI;
|
|
|
|
PRUnichar name[LF_FACESIZE];
|
|
|
|
|
|
|
|
// Depending on which stock font we want, there are three different
|
|
|
|
// places we might have to look it up.
|
|
|
|
switch (anID) {
|
|
|
|
case LookAndFeel::eFont_Icon:
|
|
|
|
if (!::SystemParametersInfoW(SPI_GETICONTITLELOGFONT,
|
|
|
|
sizeof(logFont), (PVOID)&logFont, 0))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
ptrLogFont = &logFont;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LookAndFeel::eFont_Menu:
|
|
|
|
case LookAndFeel::eFont_MessageBox:
|
|
|
|
case LookAndFeel::eFont_SmallCaption:
|
|
|
|
case LookAndFeel::eFont_StatusBar:
|
|
|
|
case LookAndFeel::eFont_Tooltips:
|
|
|
|
ncm.cbSize = sizeof(NONCLIENTMETRICSW);
|
|
|
|
if (!::SystemParametersInfoW(SPI_GETNONCLIENTMETRICS,
|
|
|
|
sizeof(ncm), (PVOID)&ncm, 0))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
switch (anID) {
|
|
|
|
case LookAndFeel::eFont_Menu:
|
|
|
|
ptrLogFont = &ncm.lfMenuFont;
|
|
|
|
break;
|
|
|
|
case LookAndFeel::eFont_MessageBox:
|
|
|
|
ptrLogFont = &ncm.lfMessageFont;
|
|
|
|
break;
|
|
|
|
case LookAndFeel::eFont_SmallCaption:
|
|
|
|
ptrLogFont = &ncm.lfSmCaptionFont;
|
|
|
|
break;
|
|
|
|
case LookAndFeel::eFont_StatusBar:
|
|
|
|
case LookAndFeel::eFont_Tooltips:
|
|
|
|
ptrLogFont = &ncm.lfStatusFont;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LookAndFeel::eFont_Widget:
|
|
|
|
case LookAndFeel::eFont_Window: // css3
|
|
|
|
case LookAndFeel::eFont_Document:
|
|
|
|
case LookAndFeel::eFont_Workspace:
|
|
|
|
case LookAndFeel::eFont_Desktop:
|
|
|
|
case LookAndFeel::eFont_Info:
|
|
|
|
case LookAndFeel::eFont_Dialog:
|
|
|
|
case LookAndFeel::eFont_Button:
|
|
|
|
case LookAndFeel::eFont_PullDownMenu:
|
|
|
|
case LookAndFeel::eFont_List:
|
|
|
|
case LookAndFeel::eFont_Field:
|
|
|
|
case LookAndFeel::eFont_Caption:
|
|
|
|
hGDI = ::GetStockObject(DEFAULT_GUI_FONT);
|
|
|
|
if (!hGDI)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (::GetObjectW(hGDI, sizeof(logFont), &logFont) <= 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
ptrLogFont = &logFont;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-04-01 09:10:28 +00:00
|
|
|
// Get scaling factor from physical to logical pixels
|
|
|
|
float pixelScale = 1.0f / gfxWindowsPlatform::GetPlatform()->GetDPIScale();
|
2012-02-20 23:19:48 +00:00
|
|
|
|
|
|
|
// The lfHeight is in pixels, and it needs to be adjusted for the
|
|
|
|
// device it will be displayed on.
|
|
|
|
// Screens and Printers will differ in DPI
|
|
|
|
//
|
|
|
|
// So this accounts for the difference in the DeviceContexts
|
2013-03-19 17:24:27 +00:00
|
|
|
// The pixelScale will typically be 1.0 for the screen
|
|
|
|
// (though larger for hi-dpi screens where the Windows resolution
|
|
|
|
// scale factor is 125% or 150% or even more), and could be
|
|
|
|
// any value when going to a printer, for example pixelScale is
|
2012-02-20 23:19:48 +00:00
|
|
|
// 6.25 when going to a 600dpi printer.
|
|
|
|
float pixelHeight = -ptrLogFont->lfHeight;
|
|
|
|
if (pixelHeight < 0) {
|
|
|
|
HFONT hFont = ::CreateFontIndirectW(ptrLogFont);
|
|
|
|
if (!hFont)
|
|
|
|
return false;
|
|
|
|
HGDIOBJ hObject = ::SelectObject(aHDC, hFont);
|
|
|
|
TEXTMETRIC tm;
|
|
|
|
::GetTextMetrics(aHDC, &tm);
|
|
|
|
::SelectObject(aHDC, hObject);
|
|
|
|
::DeleteObject(hFont);
|
|
|
|
pixelHeight = tm.tmAscent;
|
|
|
|
}
|
2013-03-19 17:24:27 +00:00
|
|
|
pixelHeight *= pixelScale;
|
2012-02-20 23:19:48 +00:00
|
|
|
|
|
|
|
// we have problem on Simplified Chinese system because the system
|
|
|
|
// report the default font size is 8 points. but if we use 8, the text
|
|
|
|
// display very ugly. force it to be at 9 points (12 pixels) on that
|
|
|
|
// system (cp936), but leave other sizes alone.
|
|
|
|
if (pixelHeight < 12 && ::GetACP() == 936)
|
|
|
|
pixelHeight = 12;
|
|
|
|
|
|
|
|
aFontStyle.size = pixelHeight;
|
|
|
|
|
|
|
|
// FIXME: What about oblique?
|
|
|
|
aFontStyle.style =
|
2012-03-15 09:04:46 +00:00
|
|
|
(ptrLogFont->lfItalic) ? NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL;
|
2012-02-20 23:19:48 +00:00
|
|
|
|
|
|
|
// FIXME: Other weights?
|
|
|
|
aFontStyle.weight =
|
2012-03-15 09:04:46 +00:00
|
|
|
(ptrLogFont->lfWeight == FW_BOLD ?
|
|
|
|
NS_FONT_WEIGHT_BOLD : NS_FONT_WEIGHT_NORMAL);
|
2012-02-20 23:19:48 +00:00
|
|
|
|
|
|
|
// FIXME: Set aFontStyle->stretch correctly!
|
|
|
|
aFontStyle.stretch = NS_FONT_STRETCH_NORMAL;
|
|
|
|
|
|
|
|
aFontStyle.systemFont = true;
|
|
|
|
|
|
|
|
name[0] = 0;
|
|
|
|
memcpy(name, ptrLogFont->lfFaceName, LF_FACESIZE*sizeof(PRUnichar));
|
|
|
|
aFontName = name;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsLookAndFeel::GetFontImpl(FontID anID, nsString &aFontName,
|
2012-09-29 11:35:08 +00:00
|
|
|
gfxFontStyle &aFontStyle,
|
|
|
|
float aDevPixPerCSSPixel)
|
2012-02-20 23:19:48 +00:00
|
|
|
{
|
|
|
|
HDC tdc = GetDC(NULL);
|
|
|
|
bool status = GetSysFontInfo(tdc, anID, aFontName, aFontStyle);
|
|
|
|
ReleaseDC(NULL, tdc);
|
2013-03-19 17:24:27 +00:00
|
|
|
// now convert the logical font size from GetSysFontInfo into device pixels for layout
|
|
|
|
aFontStyle.size *= aDevPixPerCSSPixel;
|
2012-02-20 23:19:48 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2006-10-26 22:32:30 +00:00
|
|
|
/* virtual */
|
2011-09-09 02:27:13 +00:00
|
|
|
PRUnichar
|
|
|
|
nsLookAndFeel::GetPasswordCharacterImpl()
|
2006-10-26 22:32:30 +00:00
|
|
|
{
|
2009-07-09 00:26:30 +00:00
|
|
|
#define UNICODE_BLACK_CIRCLE_CHAR 0x25cf
|
2012-02-15 19:10:17 +00:00
|
|
|
return UNICODE_BLACK_CIRCLE_CHAR;
|
2006-10-26 22:32:30 +00:00
|
|
|
}
|