2008-07-17 17:19:10 +00:00
|
|
|
/* vim: se cin sw=2 ts=2 et : */
|
|
|
|
/* -*- 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 the Mozilla browser.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1999
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Rob Arnold <robarnold@mozilla.com> (Original Author)
|
2010-10-09 20:53:44 +00:00
|
|
|
* Jim Mathies <jmathies@mozilla.com>
|
2008-07-17 17:19:10 +00:00
|
|
|
*
|
|
|
|
* 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"),
|
|
|
|
* 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 ***** */
|
|
|
|
|
2011-10-11 05:50:08 +00:00
|
|
|
#include "mozilla/Util.h"
|
|
|
|
|
2009-09-26 22:42:14 +00:00
|
|
|
#include "nsUXThemeData.h"
|
2008-07-17 17:19:10 +00:00
|
|
|
#include "nsDebug.h"
|
2012-01-04 10:21:44 +00:00
|
|
|
#include "nsToolkit.h"
|
|
|
|
#include "WinUtils.h"
|
2008-07-17 17:19:10 +00:00
|
|
|
#include "nsUXThemeConstants.h"
|
|
|
|
|
2011-09-09 02:27:12 +00:00
|
|
|
using namespace mozilla;
|
2012-01-04 10:21:44 +00:00
|
|
|
using namespace mozilla::widget;
|
2011-09-09 02:27:12 +00:00
|
|
|
|
2008-09-27 22:40:34 +00:00
|
|
|
const PRUnichar
|
|
|
|
nsUXThemeData::kThemeLibraryName[] = L"uxtheme.dll";
|
|
|
|
const PRUnichar
|
|
|
|
nsUXThemeData::kDwmLibraryName[] = L"dwmapi.dll";
|
2008-07-17 17:19:10 +00:00
|
|
|
|
|
|
|
HANDLE
|
|
|
|
nsUXThemeData::sThemes[eUXNumClasses];
|
|
|
|
|
|
|
|
HMODULE
|
|
|
|
nsUXThemeData::sThemeDLL = NULL;
|
2008-08-13 00:44:14 +00:00
|
|
|
HMODULE
|
|
|
|
nsUXThemeData::sDwmDLL = NULL;
|
2008-07-17 17:19:10 +00:00
|
|
|
|
2012-02-23 14:53:55 +00:00
|
|
|
bool
|
|
|
|
nsUXThemeData::sFlatMenus = false;
|
2008-07-17 17:19:10 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool nsUXThemeData::sTitlebarInfoPopulatedAero = false;
|
|
|
|
bool nsUXThemeData::sTitlebarInfoPopulatedThemed = false;
|
2010-10-19 17:02:24 +00:00
|
|
|
SIZE nsUXThemeData::sCommandButtons[4];
|
2010-08-10 01:49:35 +00:00
|
|
|
|
2008-08-13 00:44:14 +00:00
|
|
|
nsUXThemeData::DwmExtendFrameIntoClientAreaProc nsUXThemeData::dwmExtendFrameIntoClientAreaPtr = NULL;
|
|
|
|
nsUXThemeData::DwmIsCompositionEnabledProc nsUXThemeData::dwmIsCompositionEnabledPtr = NULL;
|
2009-09-26 22:42:14 +00:00
|
|
|
nsUXThemeData::DwmSetIconicThumbnailProc nsUXThemeData::dwmSetIconicThumbnailPtr = NULL;
|
|
|
|
nsUXThemeData::DwmSetIconicLivePreviewBitmapProc nsUXThemeData::dwmSetIconicLivePreviewBitmapPtr = NULL;
|
2010-08-27 21:26:30 +00:00
|
|
|
nsUXThemeData::DwmGetWindowAttributeProc nsUXThemeData::dwmGetWindowAttributePtr = NULL;
|
2009-09-26 22:42:14 +00:00
|
|
|
nsUXThemeData::DwmSetWindowAttributeProc nsUXThemeData::dwmSetWindowAttributePtr = NULL;
|
|
|
|
nsUXThemeData::DwmInvalidateIconicBitmapsProc nsUXThemeData::dwmInvalidateIconicBitmapsPtr = NULL;
|
2010-06-25 02:01:07 +00:00
|
|
|
nsUXThemeData::DwmDefWindowProcProc nsUXThemeData::dwmDwmDefWindowProcPtr = NULL;
|
2008-07-17 17:19:10 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
nsUXThemeData::Teardown() {
|
|
|
|
Invalidate();
|
|
|
|
if(sThemeDLL)
|
|
|
|
FreeLibrary(sThemeDLL);
|
2008-08-13 00:44:14 +00:00
|
|
|
if(sDwmDLL)
|
|
|
|
FreeLibrary(sDwmDLL);
|
2008-07-17 17:19:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsUXThemeData::Initialize()
|
|
|
|
{
|
|
|
|
::ZeroMemory(sThemes, sizeof(sThemes));
|
|
|
|
NS_ASSERTION(!sThemeDLL, "nsUXThemeData being initialized twice!");
|
2010-08-14 07:05:03 +00:00
|
|
|
|
|
|
|
if (GetDwmDLL()) {
|
|
|
|
dwmExtendFrameIntoClientAreaPtr = (DwmExtendFrameIntoClientAreaProc)::GetProcAddress(sDwmDLL, "DwmExtendFrameIntoClientArea");
|
|
|
|
dwmIsCompositionEnabledPtr = (DwmIsCompositionEnabledProc)::GetProcAddress(sDwmDLL, "DwmIsCompositionEnabled");
|
|
|
|
dwmSetIconicThumbnailPtr = (DwmSetIconicThumbnailProc)::GetProcAddress(sDwmDLL, "DwmSetIconicThumbnail");
|
|
|
|
dwmSetIconicLivePreviewBitmapPtr = (DwmSetIconicLivePreviewBitmapProc)::GetProcAddress(sDwmDLL, "DwmSetIconicLivePreviewBitmap");
|
2010-08-27 21:26:30 +00:00
|
|
|
dwmGetWindowAttributePtr = (DwmGetWindowAttributeProc)::GetProcAddress(sDwmDLL, "DwmGetWindowAttribute");
|
2010-08-14 07:05:03 +00:00
|
|
|
dwmSetWindowAttributePtr = (DwmSetWindowAttributeProc)::GetProcAddress(sDwmDLL, "DwmSetWindowAttribute");
|
|
|
|
dwmInvalidateIconicBitmapsPtr = (DwmInvalidateIconicBitmapsProc)::GetProcAddress(sDwmDLL, "DwmInvalidateIconicBitmaps");
|
|
|
|
dwmDwmDefWindowProcPtr = (DwmDefWindowProcProc)::GetProcAddress(sDwmDLL, "DwmDefWindowProc");
|
2011-10-02 02:16:19 +00:00
|
|
|
CheckForCompositor(true);
|
2010-08-14 07:05:03 +00:00
|
|
|
}
|
2008-07-17 17:19:10 +00:00
|
|
|
|
2008-07-21 19:55:31 +00:00
|
|
|
Invalidate();
|
2008-07-17 17:19:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsUXThemeData::Invalidate() {
|
|
|
|
for(int i = 0; i < eUXNumClasses; i++) {
|
|
|
|
if(sThemes[i]) {
|
2012-02-23 14:53:55 +00:00
|
|
|
CloseThemeData(sThemes[i]);
|
2008-07-17 17:19:10 +00:00
|
|
|
sThemes[i] = NULL;
|
|
|
|
}
|
|
|
|
}
|
2012-02-23 14:53:55 +00:00
|
|
|
BOOL useFlat = FALSE;
|
2012-02-15 19:10:17 +00:00
|
|
|
sFlatMenus = ::SystemParametersInfo(SPI_GETFLATMENU, 0, &useFlat, 0) ?
|
|
|
|
useFlat : false;
|
2008-07-17 17:19:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HANDLE
|
|
|
|
nsUXThemeData::GetTheme(nsUXThemeClass cls) {
|
|
|
|
NS_ASSERTION(cls < eUXNumClasses, "Invalid theme class!");
|
|
|
|
if(!sThemes[cls])
|
|
|
|
{
|
2012-02-23 14:53:55 +00:00
|
|
|
sThemes[cls] = OpenThemeData(NULL, GetClassName(cls));
|
2008-07-17 17:19:10 +00:00
|
|
|
}
|
|
|
|
return sThemes[cls];
|
|
|
|
}
|
|
|
|
|
2010-08-14 07:05:03 +00:00
|
|
|
HMODULE
|
|
|
|
nsUXThemeData::GetThemeDLL() {
|
2012-02-15 19:10:17 +00:00
|
|
|
if (!sThemeDLL)
|
2010-08-14 07:05:03 +00:00
|
|
|
sThemeDLL = ::LoadLibraryW(kThemeLibraryName);
|
|
|
|
return sThemeDLL;
|
|
|
|
}
|
|
|
|
|
|
|
|
HMODULE
|
|
|
|
nsUXThemeData::GetDwmDLL() {
|
2012-02-15 19:10:17 +00:00
|
|
|
if (!sDwmDLL && WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION)
|
2010-08-14 07:05:03 +00:00
|
|
|
sDwmDLL = ::LoadLibraryW(kDwmLibraryName);
|
|
|
|
return sDwmDLL;
|
|
|
|
}
|
|
|
|
|
2008-07-17 17:19:10 +00:00
|
|
|
const wchar_t *nsUXThemeData::GetClassName(nsUXThemeClass cls) {
|
|
|
|
switch(cls) {
|
|
|
|
case eUXButton:
|
|
|
|
return L"Button";
|
|
|
|
case eUXEdit:
|
|
|
|
return L"Edit";
|
|
|
|
case eUXTooltip:
|
|
|
|
return L"Tooltip";
|
|
|
|
case eUXRebar:
|
|
|
|
return L"Rebar";
|
|
|
|
case eUXMediaRebar:
|
|
|
|
return L"Media::Rebar";
|
|
|
|
case eUXCommunicationsRebar:
|
|
|
|
return L"Communications::Rebar";
|
|
|
|
case eUXBrowserTabBarRebar:
|
|
|
|
return L"BrowserTabBar::Rebar";
|
|
|
|
case eUXToolbar:
|
|
|
|
return L"Toolbar";
|
|
|
|
case eUXMediaToolbar:
|
|
|
|
return L"Media::Toolbar";
|
|
|
|
case eUXCommunicationsToolbar:
|
|
|
|
return L"Communications::Toolbar";
|
|
|
|
case eUXProgress:
|
|
|
|
return L"Progress";
|
|
|
|
case eUXTab:
|
|
|
|
return L"Tab";
|
|
|
|
case eUXScrollbar:
|
|
|
|
return L"Scrollbar";
|
|
|
|
case eUXTrackbar:
|
|
|
|
return L"Trackbar";
|
|
|
|
case eUXSpin:
|
|
|
|
return L"Spin";
|
|
|
|
case eUXStatus:
|
|
|
|
return L"Status";
|
|
|
|
case eUXCombobox:
|
|
|
|
return L"Combobox";
|
|
|
|
case eUXHeader:
|
|
|
|
return L"Header";
|
|
|
|
case eUXListview:
|
|
|
|
return L"Listview";
|
|
|
|
case eUXMenu:
|
|
|
|
return L"Menu";
|
2010-08-10 01:49:35 +00:00
|
|
|
case eUXWindowFrame:
|
|
|
|
return L"Window";
|
2008-07-17 17:19:10 +00:00
|
|
|
default:
|
|
|
|
NS_NOTREACHED("unknown uxtheme class");
|
|
|
|
return L"";
|
|
|
|
}
|
|
|
|
}
|
2010-08-10 01:49:35 +00:00
|
|
|
|
|
|
|
// static
|
|
|
|
void
|
|
|
|
nsUXThemeData::InitTitlebarInfo()
|
|
|
|
{
|
|
|
|
// Pre-populate with generic metrics. These likley will not match
|
|
|
|
// the current theme, but they insure the buttons at least show up.
|
|
|
|
sCommandButtons[0].cx = GetSystemMetrics(SM_CXSIZE);
|
|
|
|
sCommandButtons[0].cy = GetSystemMetrics(SM_CYSIZE);
|
|
|
|
sCommandButtons[1].cx = sCommandButtons[2].cx = sCommandButtons[0].cx;
|
|
|
|
sCommandButtons[1].cy = sCommandButtons[2].cy = sCommandButtons[0].cy;
|
2010-10-19 17:02:24 +00:00
|
|
|
sCommandButtons[3].cx = sCommandButtons[0].cx * 3;
|
|
|
|
sCommandButtons[3].cy = sCommandButtons[0].cy;
|
2010-08-10 01:49:35 +00:00
|
|
|
|
2010-11-29 16:19:17 +00:00
|
|
|
// Use system metrics for pre-vista, otherwise trigger a
|
|
|
|
// refresh on the next layout.
|
|
|
|
sTitlebarInfoPopulatedAero = sTitlebarInfoPopulatedThemed =
|
2012-01-04 10:21:44 +00:00
|
|
|
(WinUtils::GetWindowsVersion() < WinUtils::VISTA_VERSION);
|
2010-08-10 01:49:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
void
|
2010-08-10 01:49:35 +00:00
|
|
|
nsUXThemeData::UpdateTitlebarInfo(HWND aWnd)
|
2010-08-10 01:49:35 +00:00
|
|
|
{
|
2010-11-12 02:39:02 +00:00
|
|
|
if (!aWnd)
|
2010-08-10 01:49:35 +00:00
|
|
|
return;
|
|
|
|
|
2010-11-12 02:39:02 +00:00
|
|
|
if (!sTitlebarInfoPopulatedAero && nsUXThemeData::CheckForCompositor()) {
|
2010-10-19 17:02:24 +00:00
|
|
|
RECT captionButtons;
|
2010-11-12 02:39:02 +00:00
|
|
|
if (SUCCEEDED(nsUXThemeData::dwmGetWindowAttributePtr(aWnd,
|
|
|
|
DWMWA_CAPTION_BUTTON_BOUNDS,
|
|
|
|
&captionButtons,
|
|
|
|
sizeof(captionButtons)))) {
|
|
|
|
sCommandButtons[CMDBUTTONIDX_BUTTONBOX].cx = captionButtons.right - captionButtons.left - 3;
|
|
|
|
sCommandButtons[CMDBUTTONIDX_BUTTONBOX].cy = (captionButtons.bottom - captionButtons.top) - 1;
|
2011-10-02 02:16:19 +00:00
|
|
|
sTitlebarInfoPopulatedAero = true;
|
2010-10-19 17:02:24 +00:00
|
|
|
}
|
2010-08-25 03:03:37 +00:00
|
|
|
}
|
|
|
|
|
2010-11-12 02:39:02 +00:00
|
|
|
if (sTitlebarInfoPopulatedThemed)
|
|
|
|
return;
|
|
|
|
|
2010-08-25 03:03:37 +00:00
|
|
|
// Query a temporary, visible window with command buttons to get
|
|
|
|
// the right metrics.
|
2010-11-08 09:06:13 +00:00
|
|
|
nsAutoString className;
|
|
|
|
className.AssignLiteral(kClassNameTemp);
|
2010-08-25 03:03:37 +00:00
|
|
|
WNDCLASSW wc;
|
|
|
|
wc.style = 0;
|
|
|
|
wc.lpfnWndProc = ::DefWindowProcW;
|
|
|
|
wc.cbClsExtra = 0;
|
|
|
|
wc.cbWndExtra = 0;
|
|
|
|
wc.hInstance = nsToolkit::mDllInstance;
|
|
|
|
wc.hIcon = NULL;
|
|
|
|
wc.hCursor = NULL;
|
|
|
|
wc.hbrBackground = NULL;
|
|
|
|
wc.lpszMenuName = NULL;
|
2010-11-08 09:06:13 +00:00
|
|
|
wc.lpszClassName = className.get();
|
2010-08-25 03:03:37 +00:00
|
|
|
::RegisterClassW(&wc);
|
|
|
|
|
2010-11-12 02:39:02 +00:00
|
|
|
// Create a transparent descendant of the window passed in. This
|
2010-08-25 03:03:37 +00:00
|
|
|
// keeps the window from showing up on the desktop or the taskbar.
|
|
|
|
// Note the parent (browser) window is usually still hidden, we
|
|
|
|
// don't want to display it, so we can't query it directly.
|
2010-11-12 02:39:02 +00:00
|
|
|
HWND hWnd = CreateWindowExW(WS_EX_LAYERED,
|
2010-11-08 09:06:13 +00:00
|
|
|
className.get(), L"",
|
2010-08-25 04:05:11 +00:00
|
|
|
WS_OVERLAPPEDWINDOW,
|
|
|
|
0, 0, 0, 0, aWnd, NULL,
|
|
|
|
nsToolkit::mDllInstance, NULL);
|
2010-08-25 03:03:37 +00:00
|
|
|
NS_ASSERTION(hWnd, "UpdateTitlebarInfo window creation failed.");
|
|
|
|
|
2010-11-12 02:39:02 +00:00
|
|
|
ShowWindow(hWnd, SW_SHOW);
|
2010-08-10 01:49:35 +00:00
|
|
|
TITLEBARINFOEX info = {0};
|
|
|
|
info.cbSize = sizeof(TITLEBARINFOEX);
|
2010-08-25 03:03:37 +00:00
|
|
|
SendMessage(hWnd, WM_GETTITLEBARINFOEX, 0, (LPARAM)&info);
|
|
|
|
DestroyWindow(hWnd);
|
2010-08-10 01:49:35 +00:00
|
|
|
|
2010-08-10 01:49:35 +00:00
|
|
|
// Only set if we have valid data for all three buttons we use.
|
|
|
|
if ((info.rgrect[2].right - info.rgrect[2].left) == 0 ||
|
|
|
|
(info.rgrect[3].right - info.rgrect[3].left) == 0 ||
|
2010-08-25 03:03:37 +00:00
|
|
|
(info.rgrect[5].right - info.rgrect[5].left) == 0) {
|
|
|
|
NS_WARNING("WM_GETTITLEBARINFOEX query failed to find usable metrics.");
|
2010-08-10 01:49:35 +00:00
|
|
|
return;
|
2010-08-25 03:03:37 +00:00
|
|
|
}
|
2010-08-10 01:49:35 +00:00
|
|
|
// minimize
|
|
|
|
sCommandButtons[0].cx = info.rgrect[2].right - info.rgrect[2].left;
|
|
|
|
sCommandButtons[0].cy = info.rgrect[2].bottom - info.rgrect[2].top;
|
|
|
|
// maximize/restore
|
|
|
|
sCommandButtons[1].cx = info.rgrect[3].right - info.rgrect[3].left;
|
|
|
|
sCommandButtons[1].cy = info.rgrect[3].bottom - info.rgrect[3].top;
|
|
|
|
// close
|
|
|
|
sCommandButtons[2].cx = info.rgrect[5].right - info.rgrect[5].left;
|
|
|
|
sCommandButtons[2].cy = info.rgrect[5].bottom - info.rgrect[5].top;
|
|
|
|
|
2011-10-02 02:16:19 +00:00
|
|
|
sTitlebarInfoPopulatedThemed = true;
|
2010-08-10 01:49:35 +00:00
|
|
|
}
|
2010-10-09 20:53:44 +00:00
|
|
|
|
|
|
|
// visual style (aero glass, aero basic)
|
|
|
|
// theme (aero, luna, zune)
|
|
|
|
// theme color (silver, olive, blue)
|
|
|
|
// system colors
|
|
|
|
|
|
|
|
struct THEMELIST {
|
|
|
|
LPCWSTR name;
|
|
|
|
int type;
|
|
|
|
};
|
|
|
|
|
|
|
|
const THEMELIST knownThemes[] = {
|
|
|
|
{ L"aero.msstyles", WINTHEME_AERO },
|
|
|
|
{ L"luna.msstyles", WINTHEME_LUNA },
|
|
|
|
{ L"zune.msstyles", WINTHEME_ZUNE },
|
|
|
|
{ L"royale.msstyles", WINTHEME_ROYALE }
|
|
|
|
};
|
|
|
|
|
|
|
|
const THEMELIST knownColors[] = {
|
|
|
|
{ L"normalcolor", WINTHEMECOLOR_NORMAL },
|
|
|
|
{ L"homestead", WINTHEMECOLOR_HOMESTEAD },
|
|
|
|
{ L"metallic", WINTHEMECOLOR_METALLIC }
|
|
|
|
};
|
|
|
|
|
2011-09-09 02:27:12 +00:00
|
|
|
LookAndFeel::WindowsTheme
|
|
|
|
nsUXThemeData::sThemeId = LookAndFeel::eWindowsTheme_Generic;
|
2010-10-09 20:53:44 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2011-10-02 02:16:19 +00:00
|
|
|
nsUXThemeData::sIsDefaultWindowsTheme = false;
|
2010-10-09 20:53:44 +00:00
|
|
|
|
|
|
|
// static
|
2011-09-09 02:27:12 +00:00
|
|
|
LookAndFeel::WindowsTheme
|
2010-10-09 20:53:44 +00:00
|
|
|
nsUXThemeData::GetNativeThemeId()
|
|
|
|
{
|
|
|
|
return sThemeId;
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2011-09-29 06:19:26 +00:00
|
|
|
bool nsUXThemeData::IsDefaultWindowTheme()
|
2010-10-09 20:53:44 +00:00
|
|
|
{
|
|
|
|
return sIsDefaultWindowsTheme;
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
void
|
|
|
|
nsUXThemeData::UpdateNativeThemeInfo()
|
|
|
|
{
|
2010-11-14 17:34:13 +00:00
|
|
|
// Trigger a refresh of themed button metrics if needed
|
2012-01-04 10:21:44 +00:00
|
|
|
sTitlebarInfoPopulatedThemed =
|
|
|
|
(WinUtils::GetWindowsVersion() < WinUtils::VISTA_VERSION);
|
2010-11-12 02:39:02 +00:00
|
|
|
|
2011-10-02 02:16:19 +00:00
|
|
|
sIsDefaultWindowsTheme = false;
|
2011-09-09 02:27:12 +00:00
|
|
|
sThemeId = LookAndFeel::eWindowsTheme_Generic;
|
2010-10-09 20:53:44 +00:00
|
|
|
|
2012-02-23 14:53:55 +00:00
|
|
|
if (!IsAppThemed()) {
|
2011-09-09 02:27:12 +00:00
|
|
|
sThemeId = LookAndFeel::eWindowsTheme_Classic;
|
2010-10-09 20:53:44 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
WCHAR themeFileName[MAX_PATH + 1];
|
|
|
|
WCHAR themeColor[MAX_PATH + 1];
|
2012-02-23 14:53:55 +00:00
|
|
|
if (FAILED(GetCurrentThemeName(themeFileName,
|
2010-10-09 20:53:44 +00:00
|
|
|
MAX_PATH,
|
|
|
|
themeColor,
|
|
|
|
MAX_PATH,
|
|
|
|
NULL, 0))) {
|
2011-09-09 02:27:12 +00:00
|
|
|
sThemeId = LookAndFeel::eWindowsTheme_Classic;
|
2010-10-09 20:53:44 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
LPCWSTR themeName = wcsrchr(themeFileName, L'\\');
|
|
|
|
themeName = themeName ? themeName + 1 : themeFileName;
|
|
|
|
|
|
|
|
WindowsTheme theme = WINTHEME_UNRECOGNIZED;
|
2011-10-11 05:50:08 +00:00
|
|
|
for (int i = 0; i < ArrayLength(knownThemes); ++i) {
|
2010-10-09 20:53:44 +00:00
|
|
|
if (!lstrcmpiW(themeName, knownThemes[i].name)) {
|
|
|
|
theme = (WindowsTheme)knownThemes[i].type;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (theme == WINTHEME_UNRECOGNIZED)
|
|
|
|
return;
|
|
|
|
|
2011-02-07 13:30:07 +00:00
|
|
|
if (theme == WINTHEME_AERO || theme == WINTHEME_LUNA)
|
2011-10-02 02:16:19 +00:00
|
|
|
sIsDefaultWindowsTheme = true;
|
2010-10-09 20:53:44 +00:00
|
|
|
|
|
|
|
if (theme != WINTHEME_LUNA) {
|
|
|
|
switch(theme) {
|
|
|
|
case WINTHEME_AERO:
|
2011-09-09 02:27:12 +00:00
|
|
|
sThemeId = LookAndFeel::eWindowsTheme_Aero;
|
2010-10-09 20:53:44 +00:00
|
|
|
return;
|
|
|
|
case WINTHEME_ZUNE:
|
2011-09-09 02:27:12 +00:00
|
|
|
sThemeId = LookAndFeel::eWindowsTheme_Zune;
|
2010-10-09 20:53:44 +00:00
|
|
|
return;
|
|
|
|
case WINTHEME_ROYALE:
|
2011-09-09 02:27:12 +00:00
|
|
|
sThemeId = LookAndFeel::eWindowsTheme_Royale;
|
2010-10-09 20:53:44 +00:00
|
|
|
return;
|
|
|
|
default:
|
|
|
|
NS_WARNING("unhandled theme type.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// calculate the luna color scheme
|
|
|
|
WindowsThemeColor color = WINTHEMECOLOR_UNRECOGNIZED;
|
2011-10-11 05:50:08 +00:00
|
|
|
for (int i = 0; i < ArrayLength(knownColors); ++i) {
|
2010-10-09 20:53:44 +00:00
|
|
|
if (!lstrcmpiW(themeColor, knownColors[i].name)) {
|
|
|
|
color = (WindowsThemeColor)knownColors[i].type;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(color) {
|
|
|
|
case WINTHEMECOLOR_NORMAL:
|
2011-09-09 02:27:12 +00:00
|
|
|
sThemeId = LookAndFeel::eWindowsTheme_LunaBlue;
|
2010-10-09 20:53:44 +00:00
|
|
|
return;
|
|
|
|
case WINTHEMECOLOR_HOMESTEAD:
|
2011-09-09 02:27:12 +00:00
|
|
|
sThemeId = LookAndFeel::eWindowsTheme_LunaOlive;
|
2010-10-09 20:53:44 +00:00
|
|
|
return;
|
|
|
|
case WINTHEMECOLOR_METALLIC:
|
2011-09-09 02:27:12 +00:00
|
|
|
sThemeId = LookAndFeel::eWindowsTheme_LunaSilver;
|
2010-10-09 20:53:44 +00:00
|
|
|
return;
|
|
|
|
default:
|
|
|
|
NS_WARNING("unhandled theme color.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|