2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Michael Lowe <michael.lowe@bigfoot.com>
|
|
|
|
* Jens Bannmann <jens.b@web.de>
|
|
|
|
* Ryan Jones <sciguyryan@gmail.com>
|
2008-04-08 11:36:53 -07:00
|
|
|
* Ehsan Akhgari <ehsan.akhgari@gmail.com>
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#include "nsLookAndFeel.h"
|
|
|
|
#include "nsXPLookAndFeel.h"
|
|
|
|
#include <windows.h>
|
|
|
|
#include <shellapi.h>
|
|
|
|
#include "nsWindow.h"
|
|
|
|
|
2009-01-05 10:17:44 -08:00
|
|
|
#ifndef WINCE
|
2008-07-17 10:19:10 -07:00
|
|
|
#include "nsUXThemeData.h"
|
|
|
|
#include "nsUXThemeConstants.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
typedef UINT (CALLBACK *SHAppBarMessagePtr)(DWORD, PAPPBARDATA);
|
|
|
|
SHAppBarMessagePtr gSHAppBarMessage = NULL;
|
|
|
|
static HINSTANCE gShell32DLLInst = NULL;
|
|
|
|
|
2008-07-17 10:19:10 -07:00
|
|
|
static nsresult GetColorFromTheme(nsUXThemeClass cls,
|
|
|
|
PRInt32 aPart,
|
|
|
|
PRInt32 aState,
|
|
|
|
PRInt32 aPropId,
|
|
|
|
nscolor &aColor)
|
|
|
|
{
|
|
|
|
COLORREF color;
|
|
|
|
HRESULT hr = nsUXThemeData::GetThemeColor(cls, aPart, aState, aPropId, &color);
|
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
aColor = COLOREF_2_NSRGB(color);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2009-01-05 10:17:44 -08:00
|
|
|
#endif
|
2008-07-17 10:19:10 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
static PRInt32 GetSystemParam(long flag, PRInt32 def)
|
|
|
|
{
|
|
|
|
DWORD value;
|
|
|
|
return ::SystemParametersInfo(flag, 0, &value, 0) ? value : def;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel()
|
|
|
|
{
|
|
|
|
#ifndef WINCE
|
2008-08-29 14:26:56 -07:00
|
|
|
gShell32DLLInst = LoadLibraryW(L"Shell32.dll");
|
2007-03-22 10:30:00 -07:00
|
|
|
if (gShell32DLLInst)
|
|
|
|
{
|
|
|
|
gSHAppBarMessage = (SHAppBarMessagePtr) GetProcAddress(gShell32DLLInst,
|
|
|
|
"SHAppBarMessage");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
nsLookAndFeel::~nsLookAndFeel()
|
|
|
|
{
|
|
|
|
#ifndef WINCE
|
|
|
|
if (gShell32DLLInst)
|
|
|
|
{
|
|
|
|
FreeLibrary(gShell32DLLInst);
|
|
|
|
gShell32DLLInst = NULL;
|
|
|
|
gSHAppBarMessage = NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult nsLookAndFeel::NativeGetColor(const nsColorID aID, nscolor &aColor)
|
|
|
|
{
|
|
|
|
nsresult res = NS_OK;
|
|
|
|
|
|
|
|
int idx;
|
|
|
|
switch (aID) {
|
|
|
|
case eColor_WindowBackground:
|
|
|
|
idx = COLOR_WINDOW;
|
|
|
|
break;
|
|
|
|
case eColor_WindowForeground:
|
|
|
|
idx = COLOR_WINDOWTEXT;
|
|
|
|
break;
|
|
|
|
case eColor_WidgetBackground:
|
|
|
|
idx = COLOR_BTNFACE;
|
|
|
|
break;
|
|
|
|
case eColor_WidgetForeground:
|
|
|
|
idx = COLOR_BTNTEXT;
|
|
|
|
break;
|
|
|
|
case eColor_WidgetSelectBackground:
|
|
|
|
idx = COLOR_HIGHLIGHT;
|
|
|
|
break;
|
|
|
|
case eColor_WidgetSelectForeground:
|
|
|
|
idx = COLOR_HIGHLIGHTTEXT;
|
|
|
|
break;
|
|
|
|
case eColor_Widget3DHighlight:
|
|
|
|
idx = COLOR_BTNHIGHLIGHT;
|
|
|
|
break;
|
|
|
|
case eColor_Widget3DShadow:
|
|
|
|
idx = COLOR_BTNSHADOW;
|
|
|
|
break;
|
|
|
|
case eColor_TextBackground:
|
|
|
|
idx = COLOR_WINDOW;
|
|
|
|
break;
|
|
|
|
case eColor_TextForeground:
|
|
|
|
idx = COLOR_WINDOWTEXT;
|
|
|
|
break;
|
|
|
|
case eColor_TextSelectBackground:
|
|
|
|
case eColor_IMESelectedRawTextBackground:
|
|
|
|
case eColor_IMESelectedConvertedTextBackground:
|
|
|
|
idx = COLOR_HIGHLIGHT;
|
|
|
|
break;
|
|
|
|
case eColor_TextSelectForeground:
|
|
|
|
case eColor_IMESelectedRawTextForeground:
|
|
|
|
case eColor_IMESelectedConvertedTextForeground:
|
|
|
|
idx = COLOR_HIGHLIGHTTEXT;
|
|
|
|
break;
|
|
|
|
case eColor_IMERawInputBackground:
|
|
|
|
case eColor_IMEConvertedTextBackground:
|
|
|
|
aColor = NS_TRANSPARENT;
|
|
|
|
return NS_OK;
|
|
|
|
case eColor_IMERawInputForeground:
|
|
|
|
case eColor_IMEConvertedTextForeground:
|
|
|
|
aColor = NS_SAME_AS_FOREGROUND_COLOR;
|
|
|
|
return NS_OK;
|
|
|
|
case eColor_IMERawInputUnderline:
|
|
|
|
case eColor_IMEConvertedTextUnderline:
|
|
|
|
aColor = NS_SAME_AS_FOREGROUND_COLOR;
|
|
|
|
return NS_OK;
|
|
|
|
case eColor_IMESelectedRawTextUnderline:
|
|
|
|
case eColor_IMESelectedConvertedTextUnderline:
|
|
|
|
aColor = NS_TRANSPARENT;
|
|
|
|
return NS_OK;
|
2009-04-03 00:26:28 -07:00
|
|
|
case eColor_SpellCheckerUnderline:
|
|
|
|
aColor = NS_RGB(0xff, 0, 0);
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// New CSS 2 Color definitions
|
|
|
|
case eColor_activeborder:
|
|
|
|
idx = COLOR_ACTIVEBORDER;
|
|
|
|
break;
|
|
|
|
case eColor_activecaption:
|
|
|
|
idx = COLOR_ACTIVECAPTION;
|
|
|
|
break;
|
|
|
|
case eColor_appworkspace:
|
|
|
|
idx = COLOR_APPWORKSPACE;
|
|
|
|
break;
|
|
|
|
case eColor_background:
|
|
|
|
idx = COLOR_BACKGROUND;
|
|
|
|
break;
|
|
|
|
case eColor_buttonface:
|
|
|
|
case eColor__moz_buttonhoverface:
|
|
|
|
idx = COLOR_BTNFACE;
|
|
|
|
break;
|
|
|
|
case eColor_buttonhighlight:
|
|
|
|
idx = COLOR_BTNHIGHLIGHT;
|
|
|
|
break;
|
|
|
|
case eColor_buttonshadow:
|
|
|
|
idx = COLOR_BTNSHADOW;
|
|
|
|
break;
|
|
|
|
case eColor_buttontext:
|
|
|
|
case eColor__moz_buttonhovertext:
|
|
|
|
idx = COLOR_BTNTEXT;
|
|
|
|
break;
|
|
|
|
case eColor_captiontext:
|
|
|
|
idx = COLOR_CAPTIONTEXT;
|
|
|
|
break;
|
|
|
|
case eColor_graytext:
|
|
|
|
idx = COLOR_GRAYTEXT;
|
|
|
|
break;
|
|
|
|
case eColor_highlight:
|
2008-01-24 01:31:44 -08:00
|
|
|
case eColor__moz_html_cellhighlight:
|
2007-03-22 10:30:00 -07:00
|
|
|
case eColor__moz_menuhover:
|
|
|
|
idx = COLOR_HIGHLIGHT;
|
|
|
|
break;
|
2008-07-17 10:19:10 -07:00
|
|
|
case eColor__moz_menubarhovertext:
|
2007-08-06 10:45:57 -07:00
|
|
|
#ifndef WINCE
|
2008-07-17 10:19:10 -07:00
|
|
|
if (!nsUXThemeData::sIsVistaOrLater || !nsUXThemeData::isAppThemed())
|
2007-08-06 10:45:57 -07: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;
|
|
|
|
}
|
2009-01-05 10:17:44 -08:00
|
|
|
#endif
|
2007-08-06 10:45:57 -07:00
|
|
|
// Fall through
|
2007-03-22 10:30:00 -07:00
|
|
|
case eColor__moz_menuhovertext:
|
2007-08-06 10:45:57 -07:00
|
|
|
#ifndef WINCE
|
2008-07-17 10:19:10 -07:00
|
|
|
if (nsUXThemeData::IsAppThemed() && nsUXThemeData::sIsVistaOrLater)
|
2007-08-06 10:45:57 -07: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
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
case eColor_highlighttext:
|
2008-01-24 01:31:44 -08:00
|
|
|
case eColor__moz_html_cellhighlighttext:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_HIGHLIGHTTEXT;
|
|
|
|
break;
|
|
|
|
case eColor_inactiveborder:
|
|
|
|
idx = COLOR_INACTIVEBORDER;
|
|
|
|
break;
|
|
|
|
case eColor_inactivecaption:
|
|
|
|
idx = COLOR_INACTIVECAPTION;
|
|
|
|
break;
|
|
|
|
case eColor_inactivecaptiontext:
|
|
|
|
idx = COLOR_INACTIVECAPTIONTEXT;
|
|
|
|
break;
|
|
|
|
case eColor_infobackground:
|
|
|
|
idx = COLOR_INFOBK;
|
|
|
|
break;
|
|
|
|
case eColor_infotext:
|
|
|
|
idx = COLOR_INFOTEXT;
|
|
|
|
break;
|
|
|
|
case eColor_menu:
|
|
|
|
idx = COLOR_MENU;
|
|
|
|
break;
|
|
|
|
case eColor_menutext:
|
2009-06-14 14:58:14 -07:00
|
|
|
case eColor__moz_menubartext:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_MENUTEXT;
|
|
|
|
break;
|
|
|
|
case eColor_scrollbar:
|
|
|
|
idx = COLOR_SCROLLBAR;
|
|
|
|
break;
|
|
|
|
case eColor_threeddarkshadow:
|
|
|
|
idx = COLOR_3DDKSHADOW;
|
|
|
|
break;
|
|
|
|
case eColor_threedface:
|
|
|
|
idx = COLOR_3DFACE;
|
|
|
|
break;
|
|
|
|
case eColor_threedhighlight:
|
|
|
|
idx = COLOR_3DHIGHLIGHT;
|
|
|
|
break;
|
|
|
|
case eColor_threedlightshadow:
|
|
|
|
idx = COLOR_3DLIGHT;
|
|
|
|
break;
|
|
|
|
case eColor_threedshadow:
|
|
|
|
idx = COLOR_3DSHADOW;
|
|
|
|
break;
|
|
|
|
case eColor_window:
|
|
|
|
idx = COLOR_WINDOW;
|
|
|
|
break;
|
|
|
|
case eColor_windowframe:
|
|
|
|
idx = COLOR_WINDOWFRAME;
|
|
|
|
break;
|
|
|
|
case eColor_windowtext:
|
|
|
|
idx = COLOR_WINDOWTEXT;
|
|
|
|
break;
|
2008-04-24 01:08:33 -07:00
|
|
|
case eColor__moz_eventreerow:
|
|
|
|
case eColor__moz_oddtreerow:
|
2007-03-22 10:30:00 -07:00
|
|
|
case eColor__moz_field:
|
2009-01-16 00:18:49 -08:00
|
|
|
case eColor__moz_combobox:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_WINDOW;
|
|
|
|
break;
|
|
|
|
case eColor__moz_fieldtext:
|
2009-01-16 00:18:49 -08:00
|
|
|
case eColor__moz_comboboxtext:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = COLOR_WINDOWTEXT;
|
|
|
|
break;
|
|
|
|
case eColor__moz_dialog:
|
|
|
|
case eColor__moz_cellhighlight:
|
|
|
|
idx = COLOR_3DFACE;
|
|
|
|
break;
|
2008-04-29 12:27:23 -07:00
|
|
|
case eColor__moz_win_mediatext:
|
|
|
|
#ifndef WINCE
|
2008-07-17 10:19:10 -07:00
|
|
|
if (nsUXThemeData::IsAppThemed() && nsUXThemeData::sIsVistaOrLater) {
|
|
|
|
res = ::GetColorFromTheme(eUXMediaToolbar,
|
|
|
|
TP_BUTTON, TS_NORMAL, TMT_TEXTCOLOR, aColor);
|
2008-04-29 12:27:23 -07:00
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
#endif
|
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;
|
|
|
|
case eColor__moz_win_communicationstext:
|
|
|
|
#ifndef WINCE
|
2008-07-17 10:19:10 -07:00
|
|
|
if (nsUXThemeData::IsAppThemed() && nsUXThemeData::sIsVistaOrLater)
|
2008-04-29 12:27:23 -07: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;
|
|
|
|
}
|
|
|
|
#endif
|
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;
|
2007-03-22 10:30:00 -07:00
|
|
|
case eColor__moz_dialogtext:
|
|
|
|
case eColor__moz_cellhighlighttext:
|
|
|
|
idx = COLOR_WINDOWTEXT;
|
|
|
|
break;
|
|
|
|
case eColor__moz_dragtargetzone:
|
|
|
|
idx = COLOR_HIGHLIGHTTEXT;
|
|
|
|
break;
|
|
|
|
case eColor__moz_buttondefault:
|
|
|
|
idx = COLOR_3DDKSHADOW;
|
|
|
|
break;
|
2008-07-11 11:34:53 -07:00
|
|
|
case eColor__moz_nativehyperlinktext:
|
2008-09-27 15:40:34 -07:00
|
|
|
#ifndef WINCE
|
2008-07-11 11:34:53 -07:00
|
|
|
idx = COLOR_HOTLIGHT;
|
2008-09-27 15:40:34 -07:00
|
|
|
#else
|
2009-07-08 17:26:29 -07:00
|
|
|
aColor = NS_RGB(0, 0, 0xee);
|
|
|
|
return NS_OK;
|
2008-09-27 15:40:34 -07:00
|
|
|
#endif
|
2008-07-11 11:34:53 -07:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric)
|
|
|
|
{
|
|
|
|
nsresult res = nsXPLookAndFeel::GetMetric(aID, aMetric);
|
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
return res;
|
|
|
|
res = NS_OK;
|
|
|
|
|
|
|
|
switch (aID) {
|
|
|
|
case eMetric_WindowTitleHeight:
|
|
|
|
aMetric = ::GetSystemMetrics(SM_CYCAPTION);
|
|
|
|
break;
|
|
|
|
#ifndef WINCE
|
|
|
|
case eMetric_WindowBorderWidth:
|
|
|
|
aMetric = ::GetSystemMetrics(SM_CXFRAME);
|
|
|
|
break;
|
|
|
|
case eMetric_WindowBorderHeight:
|
|
|
|
aMetric = ::GetSystemMetrics(SM_CYFRAME);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
case eMetric_Widget3DBorder:
|
|
|
|
aMetric = ::GetSystemMetrics(SM_CXEDGE);
|
|
|
|
break;
|
|
|
|
case eMetric_TextFieldBorder:
|
|
|
|
aMetric = 3;
|
|
|
|
break;
|
|
|
|
case eMetric_TextFieldHeight:
|
|
|
|
aMetric = 24;
|
|
|
|
break;
|
|
|
|
case eMetric_ButtonHorizontalInsidePaddingNavQuirks:
|
|
|
|
aMetric = 10;
|
|
|
|
break;
|
|
|
|
case eMetric_ButtonHorizontalInsidePaddingOffsetNavQuirks:
|
|
|
|
aMetric = 8;
|
|
|
|
break;
|
|
|
|
case eMetric_CheckboxSize:
|
|
|
|
aMetric = 12;
|
|
|
|
break;
|
|
|
|
case eMetric_RadioboxSize:
|
|
|
|
aMetric = 12;
|
|
|
|
break;
|
|
|
|
case eMetric_TextHorizontalInsideMinimumPadding:
|
|
|
|
aMetric = 3;
|
|
|
|
break;
|
|
|
|
case eMetric_TextVerticalInsidePadding:
|
|
|
|
aMetric = 0;
|
|
|
|
break;
|
|
|
|
case eMetric_TextShouldUseVerticalInsidePadding:
|
|
|
|
aMetric = 0;
|
|
|
|
break;
|
|
|
|
case eMetric_TextShouldUseHorizontalInsideMinimumPadding:
|
|
|
|
aMetric = 1;
|
|
|
|
break;
|
|
|
|
case eMetric_ListShouldUseHorizontalInsideMinimumPadding:
|
|
|
|
aMetric = 0;
|
|
|
|
break;
|
|
|
|
case eMetric_ListHorizontalInsideMinimumPadding:
|
|
|
|
aMetric = 3;
|
|
|
|
break;
|
|
|
|
case eMetric_ListShouldUseVerticalInsidePadding:
|
|
|
|
aMetric = 0;
|
|
|
|
break;
|
|
|
|
case eMetric_ListVerticalInsidePadding:
|
|
|
|
aMetric = 0;
|
|
|
|
break;
|
|
|
|
case eMetric_CaretBlinkTime:
|
|
|
|
aMetric = (PRInt32)::GetCaretBlinkTime();
|
|
|
|
break;
|
|
|
|
case eMetric_CaretWidth:
|
|
|
|
aMetric = 1;
|
|
|
|
break;
|
|
|
|
case eMetric_ShowCaretDuringSelection:
|
|
|
|
aMetric = 0;
|
|
|
|
break;
|
|
|
|
case eMetric_SelectTextfieldsOnKeyFocus:
|
|
|
|
// Select textfield content when focused by kbd
|
|
|
|
// used by nsEventStateManager::sTextfieldSelectModel
|
|
|
|
aMetric = 1;
|
|
|
|
break;
|
|
|
|
case eMetric_SubmenuDelay:
|
|
|
|
// This will default to the Windows' default
|
|
|
|
// (400ms) on error.
|
2009-01-05 10:17:44 -08:00
|
|
|
#ifndef WINCE
|
2007-03-22 10:30:00 -07:00
|
|
|
aMetric = GetSystemParam(SPI_GETMENUSHOWDELAY, 400);
|
2009-01-05 10:17:44 -08:00
|
|
|
#else
|
|
|
|
aMetric = 400;
|
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eMetric_MenusCanOverlapOSBar:
|
|
|
|
// we want XUL popups to be able to overlap the task bar.
|
|
|
|
aMetric = 1;
|
|
|
|
break;
|
|
|
|
#ifndef WINCE
|
|
|
|
case eMetric_DragThresholdX:
|
|
|
|
// 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.
|
|
|
|
|
|
|
|
aMetric = ::GetSystemMetrics(SM_CXDRAG) - 1;
|
|
|
|
break;
|
|
|
|
case eMetric_DragThresholdY:
|
|
|
|
aMetric = ::GetSystemMetrics(SM_CYDRAG) - 1;
|
|
|
|
break;
|
|
|
|
case eMetric_UseAccessibilityTheme:
|
|
|
|
// 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);
|
|
|
|
|
|
|
|
aMetric = ((contrastThemeInfo.dwFlags & HCF_HIGHCONTRASTON) != 0);
|
|
|
|
break;
|
|
|
|
case eMetric_IsScreenReaderActive:
|
|
|
|
// This will default to the Windows' default
|
|
|
|
// (off by default) on error.
|
|
|
|
aMetric = GetSystemParam(SPI_GETSCREENREADER, 0);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
case eMetric_ScrollArrowStyle:
|
|
|
|
aMetric = eMetric_ScrollArrowStyleSingle;
|
|
|
|
break;
|
|
|
|
case eMetric_ScrollSliderStyle:
|
|
|
|
aMetric = eMetric_ScrollThumbStyleProportional;
|
|
|
|
break;
|
|
|
|
case eMetric_TreeOpenDelay:
|
|
|
|
aMetric = 1000;
|
|
|
|
break;
|
|
|
|
case eMetric_TreeCloseDelay:
|
|
|
|
aMetric = 0;
|
|
|
|
break;
|
|
|
|
case eMetric_TreeLazyScrollDelay:
|
|
|
|
aMetric = 150;
|
|
|
|
break;
|
|
|
|
case eMetric_TreeScrollDelay:
|
|
|
|
aMetric = 100;
|
|
|
|
break;
|
|
|
|
case eMetric_TreeScrollLinesMax:
|
|
|
|
aMetric = 3;
|
|
|
|
break;
|
2008-08-18 10:33:08 -07:00
|
|
|
case eMetric_WindowsClassic:
|
2009-01-05 10:17:44 -08:00
|
|
|
#ifndef WINCE
|
2008-08-18 10:33:08 -07:00
|
|
|
aMetric = !nsUXThemeData::IsAppThemed();
|
2009-01-05 10:17:44 -08:00
|
|
|
#else
|
|
|
|
aMetric = 0;
|
|
|
|
#endif
|
2008-08-18 10:33:08 -07:00
|
|
|
break;
|
2008-04-08 11:36:53 -07:00
|
|
|
case eMetric_WindowsDefaultTheme:
|
|
|
|
aMetric = 0;
|
|
|
|
#ifndef WINCE
|
2008-07-17 10:19:10 -07:00
|
|
|
if (nsUXThemeData::getCurrentThemeName) {
|
2008-04-08 11:36:53 -07:00
|
|
|
WCHAR themeFileName[MAX_PATH + 1] = {L'\0'};
|
2008-07-17 10:19:10 -07:00
|
|
|
HRESULT hresult =
|
|
|
|
nsUXThemeData::getCurrentThemeName(themeFileName, MAX_PATH,
|
|
|
|
NULL, 0, NULL, 0);
|
2008-04-08 11:36:53 -07:00
|
|
|
|
2008-04-22 09:54:51 -07:00
|
|
|
// WIN2K and earlier will not have getCurrentThemeName defined, so
|
|
|
|
// they will never make it this far. Unless we want to save 6.0
|
|
|
|
// users a handful of clock cycles by skipping checks for the
|
|
|
|
// 5.x themes (or vice-versa), we can use a single loop for all
|
|
|
|
// the different Windows versions.
|
2009-06-29 12:36:16 -07:00
|
|
|
if (hresult == S_OK && nsWindow::GetWindowsVersion() <= WIN7_VERSION) {
|
2008-04-22 09:54:51 -07:00
|
|
|
LPCWSTR defThemes[] = {
|
|
|
|
L"luna.msstyles",
|
|
|
|
L"royale.msstyles",
|
|
|
|
L"zune.msstyles",
|
|
|
|
L"aero.msstyles"
|
|
|
|
};
|
2008-04-08 11:36:53 -07:00
|
|
|
|
2008-04-22 09:54:51 -07:00
|
|
|
LPWSTR curTheme = wcsrchr(themeFileName, L'\\');
|
|
|
|
curTheme = curTheme ? curTheme + 1 : themeFileName;
|
|
|
|
|
|
|
|
for (int i = 0; i < NS_ARRAY_LENGTH(defThemes); ++i) {
|
|
|
|
if (!lstrcmpiW(curTheme, defThemes[i])) {
|
|
|
|
aMetric = 1;
|
|
|
|
}
|
2008-04-08 11:36:53 -07:00
|
|
|
}
|
2008-04-22 09:54:51 -07:00
|
|
|
} else {
|
|
|
|
res = NS_ERROR_NOT_IMPLEMENTED;
|
2008-04-08 11:36:53 -07:00
|
|
|
}
|
2009-01-05 10:17:44 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif /* WINCE */
|
2008-04-08 11:36:53 -07:00
|
|
|
{
|
|
|
|
res = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
break;
|
2008-09-17 09:23:58 -07:00
|
|
|
case eMetric_MacGraphiteTheme:
|
|
|
|
aMetric = 0;
|
|
|
|
res = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
break;
|
2008-08-12 17:44:14 -07:00
|
|
|
case eMetric_DWMCompositor:
|
2009-01-05 10:17:44 -08:00
|
|
|
#ifndef WINCE
|
2008-08-12 17:44:14 -07:00
|
|
|
aMetric = nsUXThemeData::sHaveCompositor;
|
2009-01-05 10:17:44 -08:00
|
|
|
#else
|
|
|
|
aMetric = 0;
|
|
|
|
#endif
|
2008-08-12 17:44:14 -07:00
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
case eMetric_AlertNotificationOrigin:
|
|
|
|
aMetric = 0;
|
2009-01-05 10:17:44 -08:00
|
|
|
#ifndef WINCE
|
2007-03-22 10:30:00 -07:00
|
|
|
if (gSHAppBarMessage)
|
|
|
|
{
|
|
|
|
// 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);
|
|
|
|
if (gSHAppBarMessage(ABM_GETTASKBARPOS, &appBarData))
|
|
|
|
{
|
|
|
|
// Set alert origin as a bit field - see nsILookAndFeel.h
|
|
|
|
// 0 represents bottom right, sliding vertically.
|
|
|
|
switch(appBarData.uEdge)
|
|
|
|
{
|
|
|
|
case ABE_LEFT:
|
|
|
|
aMetric = NS_ALERT_HORIZONTAL | NS_ALERT_LEFT;
|
|
|
|
break;
|
|
|
|
case ABE_RIGHT:
|
|
|
|
aMetric = NS_ALERT_HORIZONTAL;
|
|
|
|
break;
|
|
|
|
case ABE_TOP:
|
|
|
|
aMetric = NS_ALERT_TOP;
|
|
|
|
// 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)
|
|
|
|
aMetric |= NS_ALERT_LEFT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-01-05 10:17:44 -08:00
|
|
|
#endif // WINCE
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2007-08-16 13:35:18 -07:00
|
|
|
case eMetric_IMERawInputUnderlineStyle:
|
|
|
|
case eMetric_IMEConvertedTextUnderlineStyle:
|
|
|
|
aMetric = NS_UNDERLINE_STYLE_DASHED;
|
|
|
|
break;
|
|
|
|
case eMetric_IMESelectedRawTextUnderlineStyle:
|
|
|
|
case eMetric_IMESelectedConvertedTextUnderline:
|
|
|
|
aMetric = NS_UNDERLINE_STYLE_NONE;
|
|
|
|
break;
|
2009-04-03 00:26:28 -07:00
|
|
|
case eMetric_SpellCheckerUnderlineStyle:
|
|
|
|
aMetric = NS_UNDERLINE_STYLE_WAVY;
|
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
default:
|
|
|
|
aMetric = 0;
|
|
|
|
res = NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricFloatID aID, float & aMetric)
|
|
|
|
{
|
|
|
|
nsresult res = nsXPLookAndFeel::GetMetric(aID, aMetric);
|
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
return res;
|
|
|
|
res = NS_OK;
|
|
|
|
|
|
|
|
switch (aID) {
|
|
|
|
case eMetricFloat_TextFieldVerticalInsidePadding:
|
|
|
|
aMetric = 0.25f;
|
|
|
|
break;
|
|
|
|
case eMetricFloat_TextFieldHorizontalInsidePadding:
|
|
|
|
aMetric = 1.025f;
|
|
|
|
break;
|
|
|
|
case eMetricFloat_TextAreaVerticalInsidePadding:
|
|
|
|
aMetric = 0.40f;
|
|
|
|
break;
|
|
|
|
case eMetricFloat_TextAreaHorizontalInsidePadding:
|
|
|
|
aMetric = 0.40f;
|
|
|
|
break;
|
|
|
|
case eMetricFloat_ListVerticalInsidePadding:
|
|
|
|
aMetric = 0.10f;
|
|
|
|
break;
|
|
|
|
case eMetricFloat_ListHorizontalInsidePadding:
|
|
|
|
aMetric = 0.40f;
|
|
|
|
break;
|
|
|
|
case eMetricFloat_ButtonVerticalInsidePadding:
|
|
|
|
aMetric = 0.25f;
|
|
|
|
break;
|
|
|
|
case eMetricFloat_ButtonHorizontalInsidePadding:
|
|
|
|
aMetric = 0.25f;
|
|
|
|
break;
|
|
|
|
case eMetricFloat_IMEUnderlineRelativeSize:
|
|
|
|
aMetric = 1.0f;
|
|
|
|
break;
|
2009-04-03 00:26:28 -07:00
|
|
|
case eMetricFloat_SpellCheckerUnderlineRelativeSize:
|
|
|
|
aMetric = 1.0f;
|
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
default:
|
|
|
|
aMetric = -1.0;
|
|
|
|
res = NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */
|
|
|
|
PRUnichar nsLookAndFeel::GetPasswordCharacter()
|
|
|
|
{
|
2009-07-08 17:26:30 -07:00
|
|
|
#define UNICODE_BLACK_CIRCLE_CHAR 0x25cf
|
|
|
|
#ifdef WINCE
|
|
|
|
return UNICODE_BLACK_CIRCLE_CHAR;
|
|
|
|
#else
|
2007-03-22 10:30:00 -07:00
|
|
|
static PRUnichar passwordCharacter = 0;
|
|
|
|
if (!passwordCharacter) {
|
|
|
|
passwordCharacter = '*';
|
2008-07-17 10:19:10 -07:00
|
|
|
if (nsUXThemeData::sIsXPOrLater)
|
2009-07-08 17:26:30 -07:00
|
|
|
passwordCharacter = UNICODE_BLACK_CIRCLE_CHAR;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
return passwordCharacter;
|
2009-07-08 17:26:30 -07:00
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsLookAndFeel::GetNavSize(const nsMetricNavWidgetID aWidgetID,
|
|
|
|
const nsMetricNavFontID aFontID,
|
|
|
|
const PRInt32 aFontSize,
|
|
|
|
nsSize &aSize)
|
|
|
|
{
|
|
|
|
nsresult rv = nsXPLookAndFeel::GetNavSize(aWidgetID, aFontID, aFontSize,
|
|
|
|
aSize);
|
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
aSize.width = 0;
|
|
|
|
aSize.height = 0;
|
|
|
|
|
|
|
|
if (aFontSize < 1 || aFontSize > 7) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32 kTextFieldWidths[2][7] = {
|
|
|
|
{106,147,169,211,253,338,506}, // Courier
|
|
|
|
{152,214,237,281,366,495,732} // sans-serif
|
|
|
|
};
|
|
|
|
|
|
|
|
PRInt32 kTextFieldHeights[2][7] = {
|
|
|
|
{18,21,24,27,33,45,63}, // Courier
|
|
|
|
{18,21,24,27,34,48,67} // sans-serif
|
|
|
|
};
|
|
|
|
|
|
|
|
PRInt32 kTextAreaWidths[2][7] = {
|
|
|
|
{121,163,184,226,268,352,520}, // Courier
|
|
|
|
{163,226,247,289,373,499,730} // sans-serif
|
|
|
|
};
|
|
|
|
|
|
|
|
PRInt32 kTextAreaHeights[2][7] = {
|
|
|
|
{40,44,48,52,60,76,100}, // Courier
|
|
|
|
{40,44,48,52,62,80,106} // sans-serif
|
|
|
|
};
|
|
|
|
|
|
|
|
switch (aWidgetID) {
|
|
|
|
case eMetricSize_TextField:
|
|
|
|
aSize.width = kTextFieldWidths[aFontID][aFontSize-1];
|
|
|
|
aSize.height = kTextFieldHeights[aFontID][aFontSize-1];
|
|
|
|
break;
|
|
|
|
case eMetricSize_TextArea:
|
|
|
|
aSize.width = kTextAreaWidths[aFontID][aFontSize-1];
|
|
|
|
aSize.height = kTextAreaHeights[aFontID][aFontSize-1];
|
|
|
|
break;
|
|
|
|
} //switch
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|