2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "nsLookAndFeel.h"
|
|
|
|
#include <windows.h>
|
|
|
|
#include <shellapi.h>
|
2011-03-31 05:26:49 -07:00
|
|
|
#include "nsStyleConsts.h"
|
2008-07-17 10:19:10 -07:00
|
|
|
#include "nsUXThemeData.h"
|
|
|
|
#include "nsUXThemeConstants.h"
|
2012-02-20 15:19:48 -08:00
|
|
|
#include "gfxFont.h"
|
2012-02-15 11:10:17 -08:00
|
|
|
#include "WinUtils.h"
|
2012-09-29 09:39:23 -07:00
|
|
|
#include "mozilla/Telemetry.h"
|
2012-02-15 11:10:17 -08:00
|
|
|
|
|
|
|
using namespace mozilla::widget;
|
2012-02-20 15:19:48 -08:00
|
|
|
using mozilla::LookAndFeel;
|
2012-02-08 08:00:47 -08:00
|
|
|
|
2008-07-17 10:19:10 -07:00
|
|
|
static nsresult GetColorFromTheme(nsUXThemeClass cls,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aPart,
|
|
|
|
int32_t aState,
|
|
|
|
int32_t aPropId,
|
2008-07-17 10:19:10 -07:00
|
|
|
nscolor &aColor)
|
|
|
|
{
|
|
|
|
COLORREF color;
|
2012-02-23 06:53:55 -08:00
|
|
|
HRESULT hr = GetThemeColor(nsUXThemeData::GetTheme(cls), aPart, aState, aPropId, &color);
|
2008-07-17 10:19:10 -07:00
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
aColor = COLOREF_2_NSRGB(color);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
static int32_t GetSystemParam(long flag, int32_t def)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
DWORD value;
|
|
|
|
return ::SystemParametersInfo(flag, 0, &value, 0) ? value : def;
|
|
|
|
}
|
|
|
|
|
2012-10-25 07:57:51 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace widget {
|
|
|
|
// This is in use here and in nsDOMTouchEvent.cpp
|
|
|
|
int32_t IsTouchDeviceSupportPresent()
|
2012-09-29 09:39:23 -07:00
|
|
|
{
|
|
|
|
int32_t touchCapabilities;
|
|
|
|
touchCapabilities = ::GetSystemMetrics(SM_DIGITIZER);
|
|
|
|
return ((touchCapabilities & NID_READY) &&
|
|
|
|
(touchCapabilities & (NID_EXTERNAL_TOUCH | NID_INTEGRATED_TOUCH)));
|
|
|
|
}
|
2012-10-25 07:57:51 -07:00
|
|
|
} }
|
2012-09-29 09:39:23 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel()
|
|
|
|
{
|
2012-09-29 09:39:23 -07:00
|
|
|
mozilla::Telemetry::Accumulate(mozilla::Telemetry::TOUCH_ENABLED_DEVICE,
|
2012-10-25 07:57:51 -07:00
|
|
|
IsTouchDeviceSupportPresent());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsLookAndFeel::~nsLookAndFeel()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
nsresult
|
|
|
|
nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsresult res = NS_OK;
|
|
|
|
|
|
|
|
int idx;
|
|
|
|
switch (aID) {
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_WindowBackground:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_WINDOW;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_WindowForeground:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_WINDOWTEXT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_WidgetBackground:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_BTNFACE;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_WidgetForeground:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_BTNTEXT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_WidgetSelectBackground:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_HIGHLIGHT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_WidgetSelectForeground:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_HIGHLIGHTTEXT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_Widget3DHighlight:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_BTNHIGHLIGHT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_Widget3DShadow:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_BTNSHADOW;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_TextBackground:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_WINDOW;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_TextForeground:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_WINDOWTEXT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_TextSelectBackground:
|
|
|
|
case eColorID_IMESelectedRawTextBackground:
|
|
|
|
case eColorID_IMESelectedConvertedTextBackground:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_HIGHLIGHT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_TextSelectForeground:
|
|
|
|
case eColorID_IMESelectedRawTextForeground:
|
|
|
|
case eColorID_IMESelectedConvertedTextForeground:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_HIGHLIGHTTEXT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_IMERawInputBackground:
|
|
|
|
case eColorID_IMEConvertedTextBackground:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = NS_TRANSPARENT;
|
|
|
|
return NS_OK;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_IMERawInputForeground:
|
|
|
|
case eColorID_IMEConvertedTextForeground:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = NS_SAME_AS_FOREGROUND_COLOR;
|
|
|
|
return NS_OK;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_IMERawInputUnderline:
|
|
|
|
case eColorID_IMEConvertedTextUnderline:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = NS_SAME_AS_FOREGROUND_COLOR;
|
|
|
|
return NS_OK;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_IMESelectedRawTextUnderline:
|
|
|
|
case eColorID_IMESelectedConvertedTextUnderline:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = NS_TRANSPARENT;
|
|
|
|
return NS_OK;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_SpellCheckerUnderline:
|
2009-04-03 00:26:28 -07:00
|
|
|
aColor = NS_RGB(0xff, 0, 0);
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// New CSS 2 Color definitions
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_activeborder:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_ACTIVEBORDER;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_activecaption:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_ACTIVECAPTION;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_appworkspace:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_APPWORKSPACE;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_background:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_BACKGROUND;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_buttonface:
|
|
|
|
case eColorID__moz_buttonhoverface:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_BTNFACE;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_buttonhighlight:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_BTNHIGHLIGHT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_buttonshadow:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_BTNSHADOW;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_buttontext:
|
|
|
|
case eColorID__moz_buttonhovertext:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_BTNTEXT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_captiontext:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_CAPTIONTEXT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_graytext:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_GRAYTEXT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_highlight:
|
|
|
|
case eColorID__moz_html_cellhighlight:
|
|
|
|
case eColorID__moz_menuhover:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_HIGHLIGHT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_menubarhovertext:
|
2012-02-15 11:10:17 -08:00
|
|
|
if (WinUtils::GetWindowsVersion() < WinUtils::VISTA_VERSION ||
|
2012-02-23 06:53:55 -08:00
|
|
|
!IsAppThemed())
|
2012-02-08 13:04:21 -08:00
|
|
|
{
|
2008-07-17 10:19:10 -07:00
|
|
|
idx = nsUXThemeData::sFlatMenus ?
|
2007-08-06 10:45:57 -07:00
|
|
|
COLOR_HIGHLIGHTTEXT :
|
|
|
|
COLOR_MENUTEXT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// Fall through
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_menuhovertext:
|
2012-02-15 11:10:17 -08:00
|
|
|
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION &&
|
2012-02-23 06:53:55 -08:00
|
|
|
IsAppThemed())
|
2012-02-08 13:04:21 -08:00
|
|
|
{
|
2008-07-17 10:19:10 -07:00
|
|
|
res = ::GetColorFromTheme(eUXMenu,
|
|
|
|
MENU_POPUPITEM, MPI_HOT, TMT_TEXTCOLOR, aColor);
|
2008-04-29 12:27:23 -07:00
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
return res;
|
2007-08-06 10:45:57 -07:00
|
|
|
// fall through to highlight case
|
|
|
|
}
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_highlighttext:
|
|
|
|
case eColorID__moz_html_cellhighlighttext:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_HIGHLIGHTTEXT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_inactiveborder:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_INACTIVEBORDER;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_inactivecaption:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_INACTIVECAPTION;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_inactivecaptiontext:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_INACTIVECAPTIONTEXT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_infobackground:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_INFOBK;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_infotext:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_INFOTEXT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_menu:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_MENU;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_menutext:
|
|
|
|
case eColorID__moz_menubartext:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_MENUTEXT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_scrollbar:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_SCROLLBAR;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_threeddarkshadow:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_3DDKSHADOW;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_threedface:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_3DFACE;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_threedhighlight:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_3DHIGHLIGHT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_threedlightshadow:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_3DLIGHT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_threedshadow:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_3DSHADOW;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_window:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_WINDOW;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_windowframe:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_WINDOWFRAME;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_windowtext:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_WINDOWTEXT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_eventreerow:
|
|
|
|
case eColorID__moz_oddtreerow:
|
|
|
|
case eColorID__moz_field:
|
|
|
|
case eColorID__moz_combobox:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_WINDOW;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_fieldtext:
|
|
|
|
case eColorID__moz_comboboxtext:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_WINDOWTEXT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_dialog:
|
|
|
|
case eColorID__moz_cellhighlight:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_3DFACE;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_win_mediatext:
|
2012-02-15 11:10:17 -08:00
|
|
|
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION &&
|
2012-02-23 06:53:55 -08:00
|
|
|
IsAppThemed()) {
|
2008-07-17 10:19:10 -07:00
|
|
|
res = ::GetColorFromTheme(eUXMediaToolbar,
|
|
|
|
TP_BUTTON, TS_NORMAL, TMT_TEXTCOLOR, aColor);
|
2008-04-29 12:27:23 -07:00
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
return res;
|
|
|
|
}
|
2009-01-05 10:17:44 -08:00
|
|
|
// if we've gotten here just return -moz-dialogtext instead
|
2008-04-29 12:27:23 -07:00
|
|
|
idx = COLOR_WINDOWTEXT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_win_communicationstext:
|
2012-02-15 11:10:17 -08:00
|
|
|
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION &&
|
2012-02-23 06:53:55 -08:00
|
|
|
IsAppThemed())
|
2012-02-08 13:04:21 -08:00
|
|
|
{
|
2008-07-17 10:19:10 -07:00
|
|
|
res = ::GetColorFromTheme(eUXCommunicationsToolbar,
|
|
|
|
TP_BUTTON, TS_NORMAL, TMT_TEXTCOLOR, aColor);
|
2008-04-29 12:27:23 -07:00
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
return res;
|
|
|
|
}
|
2009-01-05 10:17:44 -08:00
|
|
|
// if we've gotten here just return -moz-dialogtext instead
|
2008-04-29 12:27:23 -07:00
|
|
|
idx = COLOR_WINDOWTEXT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_dialogtext:
|
|
|
|
case eColorID__moz_cellhighlighttext:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_WINDOWTEXT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_dragtargetzone:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_HIGHLIGHTTEXT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_buttondefault:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_3DDKSHADOW;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_nativehyperlinktext:
|
2008-07-11 11:34:53 -07:00
|
|
|
idx = COLOR_HOTLIGHT;
|
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
default:
|
|
|
|
idx = COLOR_WINDOW;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
DWORD color = ::GetSysColor(idx);
|
|
|
|
aColor = COLOREF_2_NSRGB(color);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
nsresult
|
2012-08-22 08:56:38 -07:00
|
|
|
nsLookAndFeel::GetIntImpl(IntID aID, int32_t &aResult)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-09-08 19:27:13 -07:00
|
|
|
nsresult res = nsXPLookAndFeel::GetIntImpl(aID, aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
return res;
|
|
|
|
res = NS_OK;
|
|
|
|
|
|
|
|
switch (aID) {
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_CaretBlinkTime:
|
2012-08-22 08:56:38 -07:00
|
|
|
aResult = (int32_t)::GetCaretBlinkTime();
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_CaretWidth:
|
|
|
|
aResult = 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_ShowCaretDuringSelection:
|
|
|
|
aResult = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_SelectTextfieldsOnKeyFocus:
|
2007-03-22 10:30:00 -07:00
|
|
|
// Select textfield content when focused by kbd
|
|
|
|
// used by nsEventStateManager::sTextfieldSelectModel
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_SubmenuDelay:
|
2007-03-22 10:30:00 -07:00
|
|
|
// This will default to the Windows' default
|
|
|
|
// (400ms) on error.
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = GetSystemParam(SPI_GETMENUSHOWDELAY, 400);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-12-16 01:18:48 -08:00
|
|
|
case eIntID_TooltipDelay:
|
|
|
|
aResult = 500;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_MenusCanOverlapOSBar:
|
2007-03-22 10:30:00 -07:00
|
|
|
// we want XUL popups to be able to overlap the task bar.
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_DragThresholdX:
|
2007-03-22 10:30:00 -07: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-08 19:27:13 -07:00
|
|
|
aResult = ::GetSystemMetrics(SM_CXDRAG) - 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_DragThresholdY:
|
|
|
|
aResult = ::GetSystemMetrics(SM_CYDRAG) - 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_UseAccessibilityTheme:
|
2007-03-22 10:30:00 -07: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);
|
|
|
|
::SystemParametersInfo(SPI_GETHIGHCONTRAST, 0, &contrastThemeInfo, 0);
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = ((contrastThemeInfo.dwFlags & HCF_HIGHCONTRASTON) != 0);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_ScrollArrowStyle:
|
|
|
|
aResult = eScrollArrowStyle_Single;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_ScrollSliderStyle:
|
|
|
|
aResult = eScrollThumbStyle_Proportional;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_TreeOpenDelay:
|
|
|
|
aResult = 1000;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_TreeCloseDelay:
|
|
|
|
aResult = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_TreeLazyScrollDelay:
|
|
|
|
aResult = 150;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_TreeScrollDelay:
|
|
|
|
aResult = 100;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_TreeScrollLinesMax:
|
|
|
|
aResult = 3;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_WindowsClassic:
|
2012-02-23 06:53:55 -08:00
|
|
|
aResult = !IsAppThemed();
|
2009-08-10 19:59:06 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_TouchEnabled:
|
2012-10-25 07:57:51 -07:00
|
|
|
aResult = IsTouchDeviceSupportPresent();
|
2008-08-18 10:33:08 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_WindowsDefaultTheme:
|
|
|
|
aResult = nsUXThemeData::IsDefaultWindowTheme();
|
2010-10-09 13:53:44 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_WindowsThemeIdentifier:
|
|
|
|
aResult = nsUXThemeData::GetNativeThemeId();
|
2008-04-08 11:36:53 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_MacGraphiteTheme:
|
|
|
|
case eIntID_MacLionTheme:
|
|
|
|
case eIntID_MaemoClassic:
|
|
|
|
aResult = 0;
|
2008-09-17 09:23:58 -07:00
|
|
|
res = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_DWMCompositor:
|
|
|
|
aResult = nsUXThemeData::CheckForCompositor();
|
2008-08-12 17:44:14 -07:00
|
|
|
break;
|
2013-01-16 19:27:16 -08: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-08 19:27:13 -07:00
|
|
|
case eIntID_AlertNotificationOrigin:
|
|
|
|
aResult = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// Get task bar window handle
|
2008-08-29 14:26:56 -07:00
|
|
|
HWND shellWindow = FindWindowW(L"Shell_TrayWnd", NULL);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (shellWindow != NULL)
|
|
|
|
{
|
|
|
|
// Determine position
|
|
|
|
APPBARDATA appBarData;
|
|
|
|
appBarData.hWnd = shellWindow;
|
|
|
|
appBarData.cbSize = sizeof(appBarData);
|
2012-02-23 06:53:55 -08:00
|
|
|
if (SHAppBarMessage(ABM_GETTASKBARPOS, &appBarData))
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-09-08 19:27:12 -07:00
|
|
|
// Set alert origin as a bit field - see LookAndFeel.h
|
2007-03-22 10:30:00 -07:00
|
|
|
// 0 represents bottom right, sliding vertically.
|
|
|
|
switch(appBarData.uEdge)
|
|
|
|
{
|
|
|
|
case ABE_LEFT:
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = NS_ALERT_HORIZONTAL | NS_ALERT_LEFT;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case ABE_RIGHT:
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = NS_ALERT_HORIZONTAL;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case ABE_TOP:
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = NS_ALERT_TOP;
|
2007-03-22 10:30:00 -07:00
|
|
|
// fall through for the right-to-left handling.
|
|
|
|
case ABE_BOTTOM:
|
|
|
|
// If the task bar is right-to-left,
|
|
|
|
// move the origin to the left
|
|
|
|
if (::GetWindowLong(shellWindow, GWL_EXSTYLE) &
|
|
|
|
WS_EX_LAYOUTRTL)
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult |= NS_ALERT_LEFT;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_IMERawInputUnderlineStyle:
|
|
|
|
case eIntID_IMEConvertedTextUnderlineStyle:
|
|
|
|
aResult = NS_STYLE_TEXT_DECORATION_STYLE_DASHED;
|
2007-08-16 13:35:18 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_IMESelectedRawTextUnderlineStyle:
|
|
|
|
case eIntID_IMESelectedConvertedTextUnderline:
|
|
|
|
aResult = NS_STYLE_TEXT_DECORATION_STYLE_NONE;
|
2007-08-16 13:35:18 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_SpellCheckerUnderlineStyle:
|
|
|
|
aResult = NS_STYLE_TEXT_DECORATION_STYLE_WAVY;
|
2009-04-03 00:26:28 -07:00
|
|
|
break;
|
2011-11-17 15:41:35 -08:00
|
|
|
case eIntID_ScrollbarButtonAutoRepeatBehavior:
|
|
|
|
aResult = 0;
|
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
default:
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
res = NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
nsresult
|
|
|
|
nsLookAndFeel::GetFloatImpl(FloatID aID, float &aResult)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-09-08 19:27:13 -07:00
|
|
|
nsresult res = nsXPLookAndFeel::GetFloatImpl(aID, aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
return res;
|
|
|
|
res = NS_OK;
|
|
|
|
|
|
|
|
switch (aID) {
|
2011-09-08 19:27:13 -07:00
|
|
|
case eFloatID_IMEUnderlineRelativeSize:
|
|
|
|
aResult = 1.0f;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eFloatID_SpellCheckerUnderlineRelativeSize:
|
|
|
|
aResult = 1.0f;
|
2009-04-03 00:26:28 -07:00
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
default:
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = -1.0;
|
2007-03-22 10:30:00 -07:00
|
|
|
res = NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2012-02-20 15:19:48 -08: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;
|
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME?: mPixelScale is currently hardcoded to 1.
|
|
|
|
float mPixelScale = 1.0f;
|
|
|
|
|
|
|
|
// 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
|
|
|
|
// The mPixelScale will be a "1" for the screen and could be
|
|
|
|
// any value when going to a printer, for example mPixleScale is
|
|
|
|
// 6.25 when going to a 600dpi printer.
|
|
|
|
// round, but take into account whether it is negative
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
pixelHeight *= mPixelScale;
|
|
|
|
|
|
|
|
// 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 02:04:46 -07:00
|
|
|
(ptrLogFont->lfItalic) ? NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL;
|
2012-02-20 15:19:48 -08:00
|
|
|
|
|
|
|
// FIXME: Other weights?
|
|
|
|
aFontStyle.weight =
|
2012-03-15 02:04:46 -07:00
|
|
|
(ptrLogFont->lfWeight == FW_BOLD ?
|
|
|
|
NS_FONT_WEIGHT_BOLD : NS_FONT_WEIGHT_NORMAL);
|
2012-02-20 15:19:48 -08: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 04:35:08 -07:00
|
|
|
gfxFontStyle &aFontStyle,
|
|
|
|
float aDevPixPerCSSPixel)
|
2012-02-20 15:19:48 -08:00
|
|
|
{
|
|
|
|
HDC tdc = GetDC(NULL);
|
|
|
|
bool status = GetSysFontInfo(tdc, anID, aFontName, aFontStyle);
|
|
|
|
ReleaseDC(NULL, tdc);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/* virtual */
|
2011-09-08 19:27:13 -07:00
|
|
|
PRUnichar
|
|
|
|
nsLookAndFeel::GetPasswordCharacterImpl()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-07-08 17:26:30 -07:00
|
|
|
#define UNICODE_BLACK_CIRCLE_CHAR 0x25cf
|
2012-02-15 11:10:17 -08:00
|
|
|
return UNICODE_BLACK_CIRCLE_CHAR;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|