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