зеркало из https://github.com/mozilla/gecko-dev.git
178 строки
6.2 KiB
C++
178 строки
6.2 KiB
C++
/* 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 ***** */
|
|
#ifndef __UXThemeData_h__
|
|
#define __UXThemeData_h__
|
|
#include <windows.h>
|
|
#include <uxtheme.h>
|
|
|
|
#include "nscore.h"
|
|
#include "mozilla/LookAndFeel.h"
|
|
|
|
#include <dwmapi.h>
|
|
|
|
#include "nsWindowDefs.h"
|
|
|
|
// These window messages are not defined in dwmapi.h
|
|
#ifndef WM_DWMCOMPOSITIONCHANGED
|
|
#define WM_DWMCOMPOSITIONCHANGED 0x031E
|
|
#endif
|
|
|
|
// Windows 7 additions
|
|
#ifndef WM_DWMSENDICONICTHUMBNAIL
|
|
#define WM_DWMSENDICONICTHUMBNAIL 0x0323
|
|
#define WM_DWMSENDICONICLIVEPREVIEWBITMAP 0x0326
|
|
#endif
|
|
|
|
#define DWMWA_FORCE_ICONIC_REPRESENTATION 7
|
|
#define DWMWA_HAS_ICONIC_BITMAP 10
|
|
|
|
enum nsUXThemeClass {
|
|
eUXButton = 0,
|
|
eUXEdit,
|
|
eUXTooltip,
|
|
eUXRebar,
|
|
eUXMediaRebar,
|
|
eUXCommunicationsRebar,
|
|
eUXBrowserTabBarRebar,
|
|
eUXToolbar,
|
|
eUXMediaToolbar,
|
|
eUXCommunicationsToolbar,
|
|
eUXProgress,
|
|
eUXTab,
|
|
eUXScrollbar,
|
|
eUXTrackbar,
|
|
eUXSpin,
|
|
eUXStatus,
|
|
eUXCombobox,
|
|
eUXHeader,
|
|
eUXListview,
|
|
eUXMenu,
|
|
eUXWindowFrame,
|
|
eUXNumClasses
|
|
};
|
|
|
|
// 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
|
|
};
|
|
|
|
#define CMDBUTTONIDX_MINIMIZE 0
|
|
#define CMDBUTTONIDX_RESTORE 1
|
|
#define CMDBUTTONIDX_CLOSE 2
|
|
#define CMDBUTTONIDX_BUTTONBOX 3
|
|
|
|
class nsUXThemeData {
|
|
static HMODULE sThemeDLL;
|
|
static HMODULE sDwmDLL;
|
|
static HANDLE sThemes[eUXNumClasses];
|
|
|
|
static const wchar_t *GetClassName(nsUXThemeClass);
|
|
|
|
public:
|
|
static const PRUnichar kThemeLibraryName[];
|
|
static const PRUnichar kDwmLibraryName[];
|
|
static bool sFlatMenus;
|
|
static bool sTitlebarInfoPopulatedAero;
|
|
static bool sTitlebarInfoPopulatedThemed;
|
|
static SIZE sCommandButtons[4];
|
|
static mozilla::LookAndFeel::WindowsTheme sThemeId;
|
|
static bool sIsDefaultWindowsTheme;
|
|
|
|
static void Initialize();
|
|
static void Teardown();
|
|
static void Invalidate();
|
|
static HANDLE GetTheme(nsUXThemeClass cls);
|
|
static HMODULE GetThemeDLL();
|
|
static HMODULE GetDwmDLL();
|
|
|
|
// nsWindow calls this to update desktop settings info
|
|
static void InitTitlebarInfo();
|
|
static void UpdateTitlebarInfo(HWND aWnd);
|
|
|
|
static void UpdateNativeThemeInfo();
|
|
static mozilla::LookAndFeel::WindowsTheme GetNativeThemeId();
|
|
static bool IsDefaultWindowTheme();
|
|
|
|
// dwmapi.dll function typedefs and declarations
|
|
typedef HRESULT (WINAPI*DwmExtendFrameIntoClientAreaProc)(HWND hWnd, const MARGINS *pMarInset);
|
|
typedef HRESULT (WINAPI*DwmIsCompositionEnabledProc)(BOOL *pfEnabled);
|
|
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*DwmGetWindowAttributeProc)(HWND hWnd, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute);
|
|
typedef HRESULT (WINAPI*DwmSetWindowAttributeProc)(HWND hWnd, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute);
|
|
typedef HRESULT (WINAPI*DwmInvalidateIconicBitmapsProc)(HWND hWnd);
|
|
typedef HRESULT (WINAPI*DwmDefWindowProcProc)(HWND hWnd, UINT msg, LPARAM lParam, WPARAM wParam, LRESULT *aRetValue);
|
|
|
|
static DwmExtendFrameIntoClientAreaProc dwmExtendFrameIntoClientAreaPtr;
|
|
static DwmIsCompositionEnabledProc dwmIsCompositionEnabledPtr;
|
|
static DwmSetIconicThumbnailProc dwmSetIconicThumbnailPtr;
|
|
static DwmSetIconicLivePreviewBitmapProc dwmSetIconicLivePreviewBitmapPtr;
|
|
static DwmGetWindowAttributeProc dwmGetWindowAttributePtr;
|
|
static DwmSetWindowAttributeProc dwmSetWindowAttributePtr;
|
|
static DwmInvalidateIconicBitmapsProc dwmInvalidateIconicBitmapsPtr;
|
|
static DwmDefWindowProcProc dwmDwmDefWindowProcPtr;
|
|
|
|
// 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.
|
|
static bool CheckForCompositor(bool aUpdateCache = false) {
|
|
static BOOL sCachedValue = FALSE;
|
|
if(aUpdateCache && dwmIsCompositionEnabledPtr) {
|
|
dwmIsCompositionEnabledPtr(&sCachedValue);
|
|
}
|
|
return (sCachedValue != FALSE);
|
|
}
|
|
};
|
|
#endif // __UXThemeData_h__
|