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 -*-
|
|
|
|
*
|
2012-05-21 11:12:37 +00: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/. */
|
2010-03-17 22:56:00 +00:00
|
|
|
#ifndef __UXThemeData_h__
|
|
|
|
#define __UXThemeData_h__
|
2008-08-14 15:48:06 +00:00
|
|
|
#include <windows.h>
|
2010-03-04 22:52:58 +00:00
|
|
|
#include <uxtheme.h>
|
|
|
|
|
2008-07-17 17:19:10 +00:00
|
|
|
#include "nscore.h"
|
2011-09-09 02:27:12 +00:00
|
|
|
#include "mozilla/LookAndFeel.h"
|
2008-07-17 17:19:10 +00:00
|
|
|
|
2009-09-26 22:42:14 +00:00
|
|
|
#include <dwmapi.h>
|
|
|
|
|
2010-08-10 01:49:35 +00:00
|
|
|
#include "nsWindowDefs.h"
|
|
|
|
|
2009-09-26 22:42:14 +00:00
|
|
|
// These window messages are not defined in dwmapi.h
|
2008-08-13 00:44:14 +00:00
|
|
|
#ifndef WM_DWMCOMPOSITIONCHANGED
|
|
|
|
#define WM_DWMCOMPOSITIONCHANGED 0x031E
|
|
|
|
#endif
|
|
|
|
|
2009-09-26 22:42:14 +00:00
|
|
|
// Windows 7 additions
|
|
|
|
#ifndef WM_DWMSENDICONICTHUMBNAIL
|
|
|
|
#define WM_DWMSENDICONICTHUMBNAIL 0x0323
|
|
|
|
#define WM_DWMSENDICONICLIVEPREVIEWBITMAP 0x0326
|
|
|
|
#endif
|
|
|
|
|
2009-10-06 02:26:54 +00:00
|
|
|
#define DWMWA_FORCE_ICONIC_REPRESENTATION 7
|
|
|
|
#define DWMWA_HAS_ICONIC_BITMAP 10
|
|
|
|
|
2008-07-17 17:19:10 +00:00
|
|
|
enum nsUXThemeClass {
|
|
|
|
eUXButton = 0,
|
|
|
|
eUXEdit,
|
|
|
|
eUXTooltip,
|
|
|
|
eUXRebar,
|
|
|
|
eUXMediaRebar,
|
|
|
|
eUXCommunicationsRebar,
|
|
|
|
eUXBrowserTabBarRebar,
|
|
|
|
eUXToolbar,
|
|
|
|
eUXMediaToolbar,
|
|
|
|
eUXCommunicationsToolbar,
|
|
|
|
eUXProgress,
|
|
|
|
eUXTab,
|
|
|
|
eUXScrollbar,
|
|
|
|
eUXTrackbar,
|
|
|
|
eUXSpin,
|
|
|
|
eUXStatus,
|
|
|
|
eUXCombobox,
|
|
|
|
eUXHeader,
|
|
|
|
eUXListview,
|
|
|
|
eUXMenu,
|
2010-08-10 01:49:35 +00:00
|
|
|
eUXWindowFrame,
|
2008-07-17 17:19:10 +00:00
|
|
|
eUXNumClasses
|
|
|
|
};
|
|
|
|
|
2010-10-09 20:53:44 +00:00
|
|
|
// Native windows style constants
|
|
|
|
enum WindowsTheme {
|
|
|
|
WINTHEME_UNRECOGNIZED = 0,
|
|
|
|
WINTHEME_CLASSIC = 1, // no theme
|
|
|
|
WINTHEME_AERO = 2,
|
|
|
|
WINTHEME_LUNA = 3,
|
|
|
|
WINTHEME_ROYALE = 4,
|
|
|
|
WINTHEME_ZUNE = 5
|
|
|
|
};
|
|
|
|
enum WindowsThemeColor {
|
|
|
|
WINTHEMECOLOR_UNRECOGNIZED = 0,
|
|
|
|
WINTHEMECOLOR_NORMAL = 1,
|
|
|
|
WINTHEMECOLOR_HOMESTEAD = 2,
|
|
|
|
WINTHEMECOLOR_METALLIC = 3
|
|
|
|
};
|
|
|
|
|
2010-10-19 17:02:24 +00:00
|
|
|
#define CMDBUTTONIDX_MINIMIZE 0
|
|
|
|
#define CMDBUTTONIDX_RESTORE 1
|
|
|
|
#define CMDBUTTONIDX_CLOSE 2
|
|
|
|
#define CMDBUTTONIDX_BUTTONBOX 3
|
2008-07-17 17:19:10 +00:00
|
|
|
|
|
|
|
class nsUXThemeData {
|
|
|
|
static HMODULE sThemeDLL;
|
2009-09-26 22:42:14 +00:00
|
|
|
static HMODULE sDwmDLL;
|
2008-07-17 17:19:10 +00:00
|
|
|
static HANDLE sThemes[eUXNumClasses];
|
|
|
|
|
|
|
|
static const wchar_t *GetClassName(nsUXThemeClass);
|
|
|
|
|
|
|
|
public:
|
2008-09-27 22:40:34 +00:00
|
|
|
static const PRUnichar kThemeLibraryName[];
|
2009-09-26 22:42:14 +00:00
|
|
|
static const PRUnichar kDwmLibraryName[];
|
2012-02-23 14:53:55 +00:00
|
|
|
static bool sFlatMenus;
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool sTitlebarInfoPopulatedAero;
|
|
|
|
static bool sTitlebarInfoPopulatedThemed;
|
2010-10-19 17:02:24 +00:00
|
|
|
static SIZE sCommandButtons[4];
|
2011-09-09 02:27:12 +00:00
|
|
|
static mozilla::LookAndFeel::WindowsTheme sThemeId;
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool sIsDefaultWindowsTheme;
|
2010-08-10 01:49:35 +00:00
|
|
|
|
2008-07-17 17:19:10 +00:00
|
|
|
static void Initialize();
|
|
|
|
static void Teardown();
|
|
|
|
static void Invalidate();
|
|
|
|
static HANDLE GetTheme(nsUXThemeClass cls);
|
2010-08-14 07:05:03 +00:00
|
|
|
static HMODULE GetThemeDLL();
|
|
|
|
static HMODULE GetDwmDLL();
|
2008-07-17 17:19:10 +00:00
|
|
|
|
2010-08-10 01:49:35 +00:00
|
|
|
// nsWindow calls this to update desktop settings info
|
|
|
|
static void InitTitlebarInfo();
|
2010-08-10 01:49:35 +00:00
|
|
|
static void UpdateTitlebarInfo(HWND aWnd);
|
2010-08-10 01:49:35 +00:00
|
|
|
|
2010-10-09 20:53:44 +00:00
|
|
|
static void UpdateNativeThemeInfo();
|
2011-09-09 02:27:12 +00:00
|
|
|
static mozilla::LookAndFeel::WindowsTheme GetNativeThemeId();
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool IsDefaultWindowTheme();
|
2010-10-09 20:53:44 +00:00
|
|
|
|
2008-08-13 00:44:14 +00:00
|
|
|
// dwmapi.dll function typedefs and declarations
|
|
|
|
typedef HRESULT (WINAPI*DwmExtendFrameIntoClientAreaProc)(HWND hWnd, const MARGINS *pMarInset);
|
|
|
|
typedef HRESULT (WINAPI*DwmIsCompositionEnabledProc)(BOOL *pfEnabled);
|
2009-09-26 22:42:14 +00:00
|
|
|
typedef HRESULT (WINAPI*DwmSetIconicThumbnailProc)(HWND hWnd, HBITMAP hBitmap, DWORD dwSITFlags);
|
|
|
|
typedef HRESULT (WINAPI*DwmSetIconicLivePreviewBitmapProc)(HWND hWnd, HBITMAP hBitmap, POINT *pptClient, DWORD dwSITFlags);
|
2010-08-27 21:26:30 +00:00
|
|
|
typedef HRESULT (WINAPI*DwmGetWindowAttributeProc)(HWND hWnd, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute);
|
2009-09-26 22:42:14 +00:00
|
|
|
typedef HRESULT (WINAPI*DwmSetWindowAttributeProc)(HWND hWnd, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute);
|
|
|
|
typedef HRESULT (WINAPI*DwmInvalidateIconicBitmapsProc)(HWND hWnd);
|
2010-06-25 02:01:07 +00:00
|
|
|
typedef HRESULT (WINAPI*DwmDefWindowProcProc)(HWND hWnd, UINT msg, LPARAM lParam, WPARAM wParam, LRESULT *aRetValue);
|
2008-08-13 00:44:14 +00:00
|
|
|
|
|
|
|
static DwmExtendFrameIntoClientAreaProc dwmExtendFrameIntoClientAreaPtr;
|
|
|
|
static DwmIsCompositionEnabledProc dwmIsCompositionEnabledPtr;
|
2009-09-26 22:42:14 +00:00
|
|
|
static DwmSetIconicThumbnailProc dwmSetIconicThumbnailPtr;
|
|
|
|
static DwmSetIconicLivePreviewBitmapProc dwmSetIconicLivePreviewBitmapPtr;
|
2010-08-27 21:26:30 +00:00
|
|
|
static DwmGetWindowAttributeProc dwmGetWindowAttributePtr;
|
2009-09-26 22:42:14 +00:00
|
|
|
static DwmSetWindowAttributeProc dwmSetWindowAttributePtr;
|
|
|
|
static DwmInvalidateIconicBitmapsProc dwmInvalidateIconicBitmapsPtr;
|
2010-06-25 02:01:07 +00:00
|
|
|
static DwmDefWindowProcProc dwmDwmDefWindowProcPtr;
|
2008-08-13 00:44:14 +00:00
|
|
|
|
2010-11-18 02:31:22 +00:00
|
|
|
// This method returns the cached compositor state. Most
|
|
|
|
// callers should call without the argument. The cache
|
|
|
|
// should be modified only when the application receives
|
|
|
|
// WM_DWMCOMPOSITIONCHANGED. This rule prevents inconsistent
|
|
|
|
// results for two or more calls which check the state during
|
|
|
|
// composition transition.
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool CheckForCompositor(bool aUpdateCache = false) {
|
2010-11-18 02:31:22 +00:00
|
|
|
static BOOL sCachedValue = FALSE;
|
|
|
|
if(aUpdateCache && dwmIsCompositionEnabledPtr) {
|
|
|
|
dwmIsCompositionEnabledPtr(&sCachedValue);
|
|
|
|
}
|
|
|
|
return (sCachedValue != FALSE);
|
2008-08-13 00:44:14 +00:00
|
|
|
}
|
2008-07-17 17:19:10 +00:00
|
|
|
};
|
2010-03-17 22:56:00 +00:00
|
|
|
#endif // __UXThemeData_h__
|