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)
|
|
|
|
*
|
|
|
|
* 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 ***** */
|
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"
|
|
|
|
|
2009-09-26 22:42:14 +00:00
|
|
|
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
|
|
|
|
#include <dwmapi.h>
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
|
|
|
|
#define DWMWA_FORCE_ICONIC_REPRESENTATION 7
|
|
|
|
#define DWMWA_HAS_ICONIC_BITMAP 10
|
|
|
|
#endif
|
|
|
|
|
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-08-10 01:49:35 +00:00
|
|
|
#define CMDBUTTONIDX_MINIMIZE 0
|
|
|
|
#define CMDBUTTONIDX_RESTORE 1
|
|
|
|
#define CMDBUTTONIDX_CLOSE 2
|
2008-07-17 17:19:10 +00:00
|
|
|
|
|
|
|
class nsUXThemeData {
|
|
|
|
static HMODULE sThemeDLL;
|
2009-09-26 22:42:14 +00:00
|
|
|
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
|
|
|
|
static HMODULE sDwmDLL;
|
|
|
|
#endif
|
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
|
|
|
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
|
|
|
|
static const PRUnichar kDwmLibraryName[];
|
|
|
|
#endif
|
2008-07-17 17:19:10 +00:00
|
|
|
static BOOL sFlatMenus;
|
|
|
|
static PRPackedBool sIsXPOrLater;
|
|
|
|
static PRPackedBool sIsVistaOrLater;
|
2008-08-13 00:44:14 +00:00
|
|
|
static PRPackedBool sHaveCompositor;
|
2010-08-10 01:49:35 +00:00
|
|
|
static PRBool sTitlebarInfoPopulated;
|
|
|
|
static SIZE sCommandButtons[3];
|
|
|
|
|
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();
|
2010-08-21 19:43:53 +00:00
|
|
|
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
|
2010-08-14 07:05:03 +00:00
|
|
|
static HMODULE GetDwmDLL();
|
2010-08-21 19:43:53 +00:00
|
|
|
#endif
|
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
|
|
|
|
2008-07-17 17:19:10 +00:00
|
|
|
static inline BOOL IsAppThemed() {
|
|
|
|
return isAppThemed && isAppThemed();
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline HRESULT GetThemeColor(nsUXThemeClass cls, int iPartId, int iStateId,
|
|
|
|
int iPropId, OUT COLORREF* pFont) {
|
|
|
|
if(!getThemeColor)
|
|
|
|
return E_FAIL;
|
|
|
|
return getThemeColor(GetTheme(cls), iPartId, iStateId, iPropId, pFont);
|
|
|
|
}
|
|
|
|
|
2008-08-13 00:44:14 +00:00
|
|
|
// UXTheme.dll Function typedefs and declarations
|
2008-07-17 17:19:10 +00:00
|
|
|
typedef HANDLE (WINAPI*OpenThemeDataPtr)(HWND hwnd, LPCWSTR pszClassList);
|
|
|
|
typedef HRESULT (WINAPI*CloseThemeDataPtr)(HANDLE hTheme);
|
|
|
|
typedef HRESULT (WINAPI*DrawThemeBackgroundPtr)(HANDLE hTheme, HDC hdc, int iPartId,
|
|
|
|
int iStateId, const RECT *pRect,
|
|
|
|
const RECT* pClipRect);
|
|
|
|
typedef HRESULT (WINAPI*DrawThemeEdgePtr)(HANDLE hTheme, HDC hdc, int iPartId,
|
|
|
|
int iStateId, const RECT *pDestRect,
|
|
|
|
uint uEdge, uint uFlags,
|
|
|
|
const RECT* pContentRect);
|
|
|
|
typedef HRESULT (WINAPI*GetThemeContentRectPtr)(HANDLE hTheme, HDC hdc, int iPartId,
|
|
|
|
int iStateId, const RECT* pRect,
|
|
|
|
RECT* pContentRect);
|
2009-03-25 00:51:57 +00:00
|
|
|
typedef HRESULT (WINAPI*GetThemeBackgroundRegionPtr)(HANDLE hTheme, HDC hdc, int iPartId,
|
|
|
|
int iStateId, const RECT* pRect,
|
|
|
|
HRGN *pRegion);
|
2008-07-17 17:19:10 +00:00
|
|
|
typedef HRESULT (WINAPI*GetThemePartSizePtr)(HANDLE hTheme, HDC hdc, int iPartId,
|
|
|
|
int iStateId, RECT* prc, int ts,
|
|
|
|
SIZE* psz);
|
|
|
|
typedef HRESULT (WINAPI*GetThemeSysFontPtr)(HANDLE hTheme, int iFontId, OUT LOGFONT* pFont);
|
|
|
|
typedef HRESULT (WINAPI*GetThemeColorPtr)(HANDLE hTheme, int iPartId,
|
|
|
|
int iStateId, int iPropId, OUT COLORREF* pFont);
|
|
|
|
typedef HRESULT (WINAPI*GetThemeMarginsPtr)(HANDLE hTheme, HDC hdc, int iPartId,
|
|
|
|
int iStateid, int iPropId,
|
|
|
|
LPRECT prc, MARGINS *pMargins);
|
|
|
|
typedef BOOL (WINAPI*IsAppThemedPtr)(VOID);
|
|
|
|
typedef HRESULT (WINAPI*GetCurrentThemeNamePtr)(LPWSTR pszThemeFileName, int dwMaxNameChars,
|
|
|
|
LPWSTR pszColorBuff, int cchMaxColorChars,
|
|
|
|
LPWSTR pszSizeBuff, int cchMaxSizeChars);
|
2008-08-15 09:50:24 +00:00
|
|
|
typedef COLORREF (WINAPI*GetThemeSysColorPtr)(HANDLE hTheme, int iColorID);
|
2010-06-10 22:53:57 +00:00
|
|
|
typedef BOOL (WINAPI*IsThemeBackgroundPartiallyTransparentPtr)(HANDLE hTheme, int iPartId, int iStateId);
|
2008-07-17 17:19:10 +00:00
|
|
|
|
|
|
|
static OpenThemeDataPtr openTheme;
|
|
|
|
static CloseThemeDataPtr closeTheme;
|
|
|
|
static DrawThemeBackgroundPtr drawThemeBG;
|
|
|
|
static DrawThemeEdgePtr drawThemeEdge;
|
|
|
|
static GetThemeContentRectPtr getThemeContentRect;
|
2009-03-25 00:51:57 +00:00
|
|
|
static GetThemeBackgroundRegionPtr getThemeBackgroundRegion;
|
2008-07-17 17:19:10 +00:00
|
|
|
static GetThemePartSizePtr getThemePartSize;
|
|
|
|
static GetThemeSysFontPtr getThemeSysFont;
|
|
|
|
static GetThemeColorPtr getThemeColor;
|
|
|
|
static GetThemeMarginsPtr getThemeMargins;
|
|
|
|
static IsAppThemedPtr isAppThemed;
|
|
|
|
static GetCurrentThemeNamePtr getCurrentThemeName;
|
2008-08-13 00:44:14 +00:00
|
|
|
static GetThemeSysColorPtr getThemeSysColor;
|
2010-06-10 22:53:57 +00:00
|
|
|
static IsThemeBackgroundPartiallyTransparentPtr isThemeBackgroundPartiallyTransparent;
|
2008-08-13 00:44:14 +00:00
|
|
|
|
2009-09-26 22:42:14 +00:00
|
|
|
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
|
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);
|
|
|
|
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;
|
|
|
|
static DwmSetWindowAttributeProc dwmSetWindowAttributePtr;
|
|
|
|
static DwmInvalidateIconicBitmapsProc dwmInvalidateIconicBitmapsPtr;
|
2010-06-25 02:01:07 +00:00
|
|
|
static DwmDefWindowProcProc dwmDwmDefWindowProcPtr;
|
2010-06-28 09:41:01 +00:00
|
|
|
#endif // MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
|
2008-08-13 00:44:14 +00:00
|
|
|
|
|
|
|
static PRBool CheckForCompositor() {
|
|
|
|
BOOL compositionIsEnabled = FALSE;
|
2010-06-28 09:41:01 +00:00
|
|
|
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
|
2008-08-13 00:44:14 +00:00
|
|
|
if(dwmIsCompositionEnabledPtr)
|
|
|
|
dwmIsCompositionEnabledPtr(&compositionIsEnabled);
|
2010-06-28 09:41:01 +00:00
|
|
|
#endif // MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
|
2008-08-13 00:44:14 +00:00
|
|
|
return sHaveCompositor = (compositionIsEnabled != 0);
|
|
|
|
}
|
2008-07-17 17:19:10 +00:00
|
|
|
};
|
2010-03-17 22:56:00 +00:00
|
|
|
#endif // __UXThemeData_h__
|