Bug 426660 - "Allow Firefox themes to change based on the OS theme" [p=ehsan.akhgari@gmail.com (Ehsan Akhgari [ehsan]) r=vlad sr=dbaron a=blocking1.9+]

This commit is contained in:
reed%reedloden.com 2008-04-08 18:36:54 +00:00
Родитель 985e96ccc7
Коммит 6dd0b75d45
8 изменённых файлов: 78 добавлений и 0 удалений

Просмотреть файл

@ -23,6 +23,7 @@
* Contributor(s):
* L. David Baron <dbaron@dbaron.org>
* Daniel Glazman <glazman@netscape.com>
* Ehsan Akhgari <ehsan.akhgari@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
@ -782,6 +783,11 @@ InitSystemMetrics()
sSystemMetrics->AppendElement(do_GetAtom("images-in-menus"));
}
rv = lookAndFeel->GetMetric(nsILookAndFeel::eMetric_WindowsDefaultTheme, metricResult);
if (NS_SUCCEEDED(rv) && metricResult) {
sSystemMetrics->AppendElement(do_GetAtom("windows-default-theme"));
}
return PR_TRUE;
}

Просмотреть файл

@ -213,6 +213,15 @@ public:
eMetric_TreeScrollLinesMax, // the maximum number of lines to be scrolled at ones
eMetric_TabFocusModel, // What type of tab-order to use
/*
* A Boolean value to determine whether the Windows default theme is
* being used.
*
* The value of this metric is not used on other platforms. These platforms
* should return NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
*/
eMetric_WindowsDefaultTheme,
/*
* eMetric_AlertNotificationOrigin indicates from which corner of the
* screen alerts slide in, and from which direction (horizontal/vertical).

Просмотреть файл

@ -420,6 +420,10 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric)
case eMetric_TreeScrollLinesMax:
aMetric = 3;
break;
case eMetric_WindowsDefaultTheme:
aMetric = 0;
res = NS_ERROR_NOT_IMPLEMENTED;
break;
case eMetric_IMERawInputUnderlineStyle:
case eMetric_IMEConvertedTextUnderlineStyle:
aMetric = NS_UNDERLINE_STYLE_SOLID;

Просмотреть файл

@ -588,6 +588,10 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric)
case eMetric_TreeScrollLinesMax:
aMetric = 3;
break;
case eMetric_WindowsDefaultTheme:
aMetric = 0;
res = NS_ERROR_NOT_IMPLEMENTED;
break;
case eMetric_TabFocusModel:
{
// we should probably cache this

Просмотреть файл

@ -528,6 +528,10 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric)
case eMetric_TreeScrollLinesMax:
aMetric = 3;
break;
case eMetric_WindowsDefaultTheme:
aMetric = 0;
res = NS_ERROR_NOT_IMPLEMENTED;
break;
case eMetric_IMERawInputUnderlineStyle:
case eMetric_IMEConvertedTextUnderlineStyle:
aMetric = NS_UNDERLINE_STYLE_SOLID;

Просмотреть файл

@ -364,6 +364,10 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric)
case eMetric_TreeScrollLinesMax:
aMetric = 3;
break;
case eMetric_WindowsDefaultTheme:
aMetric = 0;
res = NS_ERROR_NOT_IMPLEMENTED;
break;
case eMetric_IMERawInputUnderlineStyle:
case eMetric_IMEConvertedTextUnderlineStyle:
aMetric = NS_UNDERLINE_STYLE_SOLID;

Просмотреть файл

@ -364,6 +364,10 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric)
case eMetric_TreeScrollLinesMax:
aMetric = 3;
break;
case eMetric_WindowsDefaultTheme:
aMetric = 0;
res = NS_ERROR_NOT_IMPLEMENTED;
break;
case eMetric_IMERawInputUnderlineStyle:
case eMetric_IMEConvertedTextUnderlineStyle:
aMetric = NS_UNDERLINE_STYLE_SOLID;

Просмотреть файл

@ -23,6 +23,7 @@
* Michael Lowe <michael.lowe@bigfoot.com>
* Jens Bannmann <jens.b@web.de>
* Ryan Jones <sciguyryan@gmail.com>
* Ehsan Akhgari <ehsan.akhgari@gmail.com>
*
* 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
@ -50,11 +51,16 @@ typedef HRESULT (WINAPI*CloseThemeDataPtr)(HANDLE hTheme);
typedef HRESULT (WINAPI*GetThemeColorPtr)(HANDLE hTheme, int iPartId,
int iStateId, int iPropId, OUT COLORREF* pFont);
typedef BOOL (WINAPI*IsAppThemedPtr)(VOID);
typedef HRESULT (WINAPI*GetCurrentThemeNamePtr)(LPWSTR pszThemeFileName, int dwMaxNameChars,
LPWSTR pszColorBuff, int cchMaxColorChars,
LPWSTR pszSizeBuff, int cchMaxSizeChars);
static OpenThemeDataPtr openTheme = NULL;
static CloseThemeDataPtr closeTheme = NULL;
static GetThemeColorPtr getThemeColor = NULL;
static IsAppThemedPtr isAppThemed = NULL;
static GetCurrentThemeNamePtr getCurrentThemeName = NULL;
static const char kThemeLibraryName[] = "uxtheme.dll";
static HINSTANCE gThemeDLLInst = NULL;
@ -118,6 +124,7 @@ nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel()
closeTheme = (CloseThemeDataPtr)GetProcAddress(gThemeDLLInst, "CloseThemeData");
getThemeColor = (GetThemeColorPtr)GetProcAddress(gThemeDLLInst, "GetThemeColor");
isAppThemed = (IsAppThemedPtr)GetProcAddress(gThemeDLLInst, "IsAppThemed");
getCurrentThemeName = (GetCurrentThemeNamePtr)GetProcAddress(gThemeDLLInst, "GetCurrentThemeName");
gMenuTheme = openTheme(NULL, L"Menu");
}
#endif
@ -498,6 +505,42 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric)
case eMetric_TreeScrollLinesMax:
aMetric = 3;
break;
case eMetric_WindowsDefaultTheme:
aMetric = 0;
#ifndef WINCE
if (getCurrentThemeName) {
WCHAR themeFileName[MAX_PATH + 1] = {L'\0'};
HRESULT hresult = getCurrentThemeName(themeFileName, MAX_PATH,
NULL, 0, NULL, 0);
if (hresult == S_OK) {
const WCHAR * defaultThemeName = NULL;
switch (GetWindowsVersion()) {
case WINXP_VERSION:
case WIN2K3_VERSION:
defaultThemeName = L"luna.msstyles";
break;
case VISTA_VERSION:
defaultThemeName = L"aero.msstyles";
break;
default:
res = NS_ERROR_NOT_IMPLEMENTED;
break;
}
const int pathLen = lstrlenW(themeFileName),
defaultLen = lstrlenW(defaultThemeName);
if (pathLen > defaultLen &&
!wcsicmp(themeFileName + pathLen - defaultLen, defaultThemeName)) {
aMetric = 1;
}
}
} else
#endif
{
res = NS_ERROR_NOT_IMPLEMENTED;
}
break;
#ifndef WINCE
case eMetric_AlertNotificationOrigin:
aMetric = 0;