2006-02-09 04:24:30 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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/. */
|
2005-08-20 11:11:56 +04:00
|
|
|
|
|
|
|
#include "nsNativeThemeWin.h"
|
2014-10-20 13:55:49 +04:00
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
#include "mozilla/EventStates.h"
|
2016-12-01 06:48:32 +03:00
|
|
|
#include "mozilla/Logging.h"
|
2013-11-22 07:35:42 +04:00
|
|
|
#include "mozilla/WindowsVersion.h"
|
2014-10-20 13:55:49 +04:00
|
|
|
#include "nsDeviceContext.h"
|
2005-08-20 11:11:56 +04:00
|
|
|
#include "nsRect.h"
|
|
|
|
#include "nsSize.h"
|
|
|
|
#include "nsTransform2D.h"
|
|
|
|
#include "nsThemeConstants.h"
|
|
|
|
#include "nsIPresShell.h"
|
2005-08-20 11:14:04 +04:00
|
|
|
#include "nsPresContext.h"
|
2005-08-20 11:11:56 +04:00
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsIFrame.h"
|
2014-02-28 03:04:46 +04:00
|
|
|
#include "nsNameSpaceManager.h"
|
2005-08-20 11:12:55 +04:00
|
|
|
#include "nsIDOMHTMLInputElement.h"
|
2013-11-11 19:19:54 +04:00
|
|
|
#include "nsLookAndFeel.h"
|
2011-07-11 18:05:07 +04:00
|
|
|
#include "nsMenuFrame.h"
|
2011-10-14 22:11:22 +04:00
|
|
|
#include "nsGkAtoms.h"
|
2005-08-20 11:11:57 +04:00
|
|
|
#include <malloc.h>
|
2007-08-18 00:47:33 +04:00
|
|
|
#include "nsWindow.h"
|
2008-03-06 03:23:38 +03:00
|
|
|
#include "nsIComboboxControlFrame.h"
|
2011-05-04 18:57:04 +04:00
|
|
|
#include "prinrval.h"
|
2013-12-03 22:21:09 +04:00
|
|
|
#include "WinUtils.h"
|
2005-08-20 11:11:56 +04:00
|
|
|
|
2007-08-06 21:45:57 +04:00
|
|
|
#include "gfxPlatform.h"
|
2005-10-06 08:02:10 +04:00
|
|
|
#include "gfxContext.h"
|
2010-08-20 06:19:00 +04:00
|
|
|
#include "gfxWindowsPlatform.h"
|
2006-04-05 01:54:22 +04:00
|
|
|
#include "gfxWindowsSurface.h"
|
2012-03-08 05:15:57 +04:00
|
|
|
#include "gfxWindowsNativeDrawing.h"
|
2007-03-03 03:18:34 +03:00
|
|
|
|
2008-07-17 21:19:10 +04:00
|
|
|
#include "nsUXThemeData.h"
|
|
|
|
#include "nsUXThemeConstants.h"
|
2013-01-15 16:22:03 +04:00
|
|
|
#include <algorithm>
|
2005-10-07 04:31:36 +04:00
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
using namespace mozilla;
|
2013-12-03 22:21:09 +04:00
|
|
|
using namespace mozilla::widget;
|
2012-01-04 14:21:44 +04:00
|
|
|
|
2016-12-01 06:48:32 +03:00
|
|
|
extern mozilla::LazyLogModule gWindowsLog;
|
2011-08-16 23:30:44 +04:00
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED(nsNativeThemeWin, nsNativeTheme, nsITheme)
|
2005-08-20 11:11:56 +04:00
|
|
|
|
2013-02-25 04:27:10 +04:00
|
|
|
nsNativeThemeWin::nsNativeThemeWin() :
|
|
|
|
mProgressDeterminateTimeStamp(TimeStamp::Now()),
|
2017-06-21 23:43:27 +03:00
|
|
|
mProgressIndeterminateTimeStamp(TimeStamp::Now()),
|
2017-06-22 23:19:13 +03:00
|
|
|
mBorderCacheValid(),
|
2017-09-06 00:40:00 +03:00
|
|
|
mMinimumWidgetSizeCacheValid(),
|
|
|
|
mGutterSizeCacheValid(false)
|
2008-02-29 08:10:12 +03:00
|
|
|
{
|
2013-02-25 04:16:02 +04:00
|
|
|
// If there is a relevant change in forms.css for windows platform,
|
|
|
|
// static widget style variables (e.g. sButtonBorderSize) should be
|
|
|
|
// reinitialized here.
|
2008-02-29 08:10:12 +03:00
|
|
|
}
|
|
|
|
|
2013-02-25 04:16:02 +04:00
|
|
|
nsNativeThemeWin::~nsNativeThemeWin()
|
|
|
|
{
|
|
|
|
nsUXThemeData::Invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
static int32_t
|
|
|
|
GetTopLevelWindowActiveState(nsIFrame *aFrame)
|
2010-08-10 05:49:35 +04:00
|
|
|
{
|
2015-03-10 13:54:59 +03:00
|
|
|
// Used by window frame and button box rendering. We can end up in here in
|
|
|
|
// the content process when rendering one of these moz styles freely in a
|
|
|
|
// page. Bail in this case, there is no applicable window focus state.
|
2015-07-04 04:29:00 +03:00
|
|
|
if (!XRE_IsParentProcess()) {
|
2015-03-10 13:54:59 +03:00
|
|
|
return mozilla::widget::themeconst::FS_INACTIVE;
|
|
|
|
}
|
2017-06-08 00:33:11 +03:00
|
|
|
// All headless windows are considered active so they are painted.
|
|
|
|
if (gfxPlatform::IsHeadless()) {
|
|
|
|
return mozilla::widget::themeconst::FS_ACTIVE;
|
|
|
|
}
|
2010-08-10 05:49:35 +04:00
|
|
|
// Get the widget. nsIFrame's GetNearestWidget walks up the view chain
|
|
|
|
// until it finds a real window.
|
|
|
|
nsIWidget* widget = aFrame->GetNearestWidget();
|
2013-08-09 14:12:38 +04:00
|
|
|
nsWindowBase * window = static_cast<nsWindowBase*>(widget);
|
2011-12-02 20:23:55 +04:00
|
|
|
if (!window)
|
|
|
|
return mozilla::widget::themeconst::FS_INACTIVE;
|
2010-08-10 05:49:35 +04:00
|
|
|
if (widget && !window->IsTopLevelWidget() &&
|
2013-08-09 14:12:38 +04:00
|
|
|
!(window = window->GetParentWindowBase(false)))
|
2011-12-02 20:23:55 +04:00
|
|
|
return mozilla::widget::themeconst::FS_INACTIVE;
|
2010-08-10 05:49:35 +04:00
|
|
|
|
|
|
|
if (window->GetWindowHandle() == ::GetActiveWindow())
|
|
|
|
return mozilla::widget::themeconst::FS_ACTIVE;
|
|
|
|
return mozilla::widget::themeconst::FS_INACTIVE;
|
|
|
|
}
|
|
|
|
|
2013-02-25 04:16:02 +04:00
|
|
|
static int32_t
|
2014-04-03 08:18:36 +04:00
|
|
|
GetWindowFrameButtonState(nsIFrame* aFrame, EventStates eventState)
|
2010-08-10 05:49:35 +04:00
|
|
|
{
|
|
|
|
if (GetTopLevelWindowActiveState(aFrame) ==
|
2010-08-10 05:49:35 +04:00
|
|
|
mozilla::widget::themeconst::FS_INACTIVE) {
|
2010-10-20 15:26:32 +04:00
|
|
|
if (eventState.HasState(NS_EVENT_STATE_HOVER))
|
2010-08-10 05:49:35 +04:00
|
|
|
return mozilla::widget::themeconst::BS_HOT;
|
2010-08-10 05:49:35 +04:00
|
|
|
return mozilla::widget::themeconst::BS_INACTIVE;
|
2010-08-10 05:49:35 +04:00
|
|
|
}
|
2010-08-10 05:49:35 +04:00
|
|
|
|
2010-11-13 11:14:30 +03:00
|
|
|
if (eventState.HasState(NS_EVENT_STATE_HOVER)) {
|
|
|
|
if (eventState.HasState(NS_EVENT_STATE_ACTIVE))
|
|
|
|
return mozilla::widget::themeconst::BS_PUSHED;
|
2010-08-10 05:49:35 +04:00
|
|
|
return mozilla::widget::themeconst::BS_HOT;
|
2010-11-13 11:14:30 +03:00
|
|
|
}
|
|
|
|
return mozilla::widget::themeconst::BS_NORMAL;
|
2010-08-10 05:49:35 +04:00
|
|
|
}
|
|
|
|
|
2013-02-25 04:16:02 +04:00
|
|
|
static int32_t
|
2014-04-03 08:18:36 +04:00
|
|
|
GetClassicWindowFrameButtonState(EventStates eventState)
|
2010-08-10 05:49:35 +04:00
|
|
|
{
|
2010-11-16 12:15:24 +03:00
|
|
|
if (eventState.HasState(NS_EVENT_STATE_ACTIVE) &&
|
|
|
|
eventState.HasState(NS_EVENT_STATE_HOVER))
|
|
|
|
return DFCS_BUTTONPUSH|DFCS_PUSHED;
|
2010-11-13 11:14:30 +03:00
|
|
|
return DFCS_BUTTONPUSH;
|
2010-08-10 05:49:35 +04:00
|
|
|
}
|
|
|
|
|
2013-02-25 04:16:02 +04:00
|
|
|
static bool
|
|
|
|
IsTopLevelMenu(nsIFrame *aFrame)
|
2007-08-06 21:45:57 +04:00
|
|
|
{
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isTopLevel(false);
|
2011-07-11 18:05:07 +04:00
|
|
|
nsMenuFrame *menuFrame = do_QueryFrame(aFrame);
|
2007-08-06 21:45:57 +04:00
|
|
|
if (menuFrame) {
|
|
|
|
isTopLevel = menuFrame->IsOnMenuBar();
|
|
|
|
}
|
|
|
|
return isTopLevel;
|
|
|
|
}
|
|
|
|
|
2013-02-25 04:16:02 +04:00
|
|
|
static MARGINS
|
|
|
|
GetCheckboxMargins(HANDLE theme, HDC hdc)
|
2009-08-25 02:13:01 +04:00
|
|
|
{
|
|
|
|
MARGINS checkboxContent = {0};
|
2013-02-25 04:16:02 +04:00
|
|
|
GetThemeMargins(theme, hdc, MENU_POPUPCHECK, MCB_NORMAL,
|
2013-10-08 22:48:20 +04:00
|
|
|
TMT_CONTENTMARGINS, nullptr, &checkboxContent);
|
2009-08-25 02:13:01 +04:00
|
|
|
return checkboxContent;
|
|
|
|
}
|
2013-02-25 04:16:02 +04:00
|
|
|
|
|
|
|
static SIZE
|
|
|
|
GetCheckboxBGSize(HANDLE theme, HDC hdc)
|
2007-08-06 21:45:57 +04:00
|
|
|
{
|
|
|
|
SIZE checkboxSize;
|
2013-02-25 04:16:02 +04:00
|
|
|
GetThemePartSize(theme, hdc, MENU_POPUPCHECK, MC_CHECKMARKNORMAL,
|
2013-10-08 22:48:20 +04:00
|
|
|
nullptr, TS_TRUE, &checkboxSize);
|
2007-08-06 21:45:57 +04:00
|
|
|
|
2009-08-25 02:13:01 +04:00
|
|
|
MARGINS checkboxMargins = GetCheckboxMargins(theme, hdc);
|
2007-08-06 21:45:57 +04:00
|
|
|
|
2009-08-25 02:13:01 +04:00
|
|
|
int leftMargin = checkboxMargins.cxLeftWidth;
|
|
|
|
int rightMargin = checkboxMargins.cxRightWidth;
|
|
|
|
int topMargin = checkboxMargins.cyTopHeight;
|
|
|
|
int bottomMargin = checkboxMargins.cyBottomHeight;
|
2007-08-06 21:45:57 +04:00
|
|
|
|
|
|
|
int width = leftMargin + checkboxSize.cx + rightMargin;
|
|
|
|
int height = topMargin + checkboxSize.cy + bottomMargin;
|
|
|
|
SIZE ret;
|
|
|
|
ret.cx = width;
|
|
|
|
ret.cy = height;
|
|
|
|
return ret;
|
|
|
|
}
|
2013-02-25 04:16:02 +04:00
|
|
|
|
|
|
|
static SIZE
|
|
|
|
GetCheckboxBGBounds(HANDLE theme, HDC hdc)
|
2007-08-06 21:45:57 +04:00
|
|
|
{
|
2009-08-25 02:13:01 +04:00
|
|
|
MARGINS checkboxBGSizing = {0};
|
|
|
|
MARGINS checkboxBGContent = {0};
|
2013-02-25 04:16:02 +04:00
|
|
|
GetThemeMargins(theme, hdc, MENU_POPUPCHECKBACKGROUND, MCB_NORMAL,
|
2013-10-08 22:48:20 +04:00
|
|
|
TMT_SIZINGMARGINS, nullptr, &checkboxBGSizing);
|
2013-02-25 04:16:02 +04:00
|
|
|
GetThemeMargins(theme, hdc, MENU_POPUPCHECKBACKGROUND, MCB_NORMAL,
|
2013-10-08 22:48:20 +04:00
|
|
|
TMT_CONTENTMARGINS, nullptr, &checkboxBGContent);
|
2007-08-06 21:45:57 +04:00
|
|
|
|
|
|
|
#define posdx(d) ((d) > 0 ? d : 0)
|
|
|
|
|
2013-02-25 04:16:02 +04:00
|
|
|
int dx = posdx(checkboxBGContent.cxRightWidth -
|
|
|
|
checkboxBGSizing.cxRightWidth) +
|
|
|
|
posdx(checkboxBGContent.cxLeftWidth -
|
|
|
|
checkboxBGSizing.cxLeftWidth);
|
|
|
|
int dy = posdx(checkboxBGContent.cyTopHeight -
|
|
|
|
checkboxBGSizing.cyTopHeight) +
|
|
|
|
posdx(checkboxBGContent.cyBottomHeight -
|
|
|
|
checkboxBGSizing.cyBottomHeight);
|
2007-08-06 21:45:57 +04:00
|
|
|
|
|
|
|
#undef posdx
|
|
|
|
|
2009-08-25 02:13:01 +04:00
|
|
|
SIZE ret(GetCheckboxBGSize(theme, hdc));
|
2007-08-06 21:45:57 +04:00
|
|
|
ret.cx += dx;
|
|
|
|
ret.cy += dy;
|
|
|
|
return ret;
|
|
|
|
}
|
2013-02-25 04:16:02 +04:00
|
|
|
|
|
|
|
static SIZE
|
|
|
|
GetGutterSize(HANDLE theme, HDC hdc)
|
2007-08-06 21:45:57 +04:00
|
|
|
{
|
|
|
|
SIZE gutterSize;
|
2013-10-08 22:48:20 +04:00
|
|
|
GetThemePartSize(theme, hdc, MENU_POPUPGUTTER, 0, nullptr, TS_TRUE, &gutterSize);
|
2007-08-06 21:45:57 +04:00
|
|
|
|
2009-08-25 02:13:01 +04:00
|
|
|
SIZE checkboxBGSize(GetCheckboxBGBounds(theme, hdc));
|
2007-08-06 21:45:57 +04:00
|
|
|
|
|
|
|
SIZE itemSize;
|
2013-10-08 22:48:20 +04:00
|
|
|
GetThemePartSize(theme, hdc, MENU_POPUPITEM, MPI_NORMAL, nullptr, TS_TRUE, &itemSize);
|
2007-08-06 21:45:57 +04:00
|
|
|
|
2013-04-01 13:09:51 +04:00
|
|
|
// Figure out how big the menuitem's icon will be (if present) at current DPI
|
2017-04-09 04:00:08 +03:00
|
|
|
// Needs the system scale for consistency with Windows Theme API.
|
|
|
|
double scaleFactor = WinUtils::SystemScaleFactor();
|
2013-04-01 13:09:51 +04:00
|
|
|
int iconDevicePixels = NSToIntRound(16 * scaleFactor);
|
|
|
|
SIZE iconSize = {
|
|
|
|
iconDevicePixels, iconDevicePixels
|
|
|
|
};
|
|
|
|
// Not really sure what margins should be used here, but this seems to work in practice...
|
|
|
|
MARGINS margins = {0};
|
|
|
|
GetThemeMargins(theme, hdc, MENU_POPUPCHECKBACKGROUND, MCB_NORMAL,
|
2013-10-08 22:48:20 +04:00
|
|
|
TMT_CONTENTMARGINS, nullptr, &margins);
|
2013-04-01 13:09:51 +04:00
|
|
|
iconSize.cx += margins.cxLeftWidth + margins.cxRightWidth;
|
|
|
|
iconSize.cy += margins.cyTopHeight + margins.cyBottomHeight;
|
|
|
|
|
|
|
|
int width = std::max(itemSize.cx, std::max(iconSize.cx, checkboxBGSize.cx) + gutterSize.cx);
|
|
|
|
int height = std::max(itemSize.cy, std::max(iconSize.cy, checkboxBGSize.cy));
|
|
|
|
|
2007-08-06 21:45:57 +04:00
|
|
|
SIZE ret;
|
|
|
|
ret.cx = width;
|
|
|
|
ret.cy = height;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-09-06 00:40:00 +03:00
|
|
|
SIZE
|
|
|
|
nsNativeThemeWin::GetCachedGutterSize(HANDLE theme)
|
|
|
|
{
|
|
|
|
if (mGutterSizeCacheValid) {
|
|
|
|
return mGutterSizeCache;
|
|
|
|
}
|
|
|
|
|
|
|
|
mGutterSizeCache = GetGutterSize(theme, nullptr);
|
|
|
|
mGutterSizeCacheValid = true;
|
|
|
|
|
|
|
|
return mGutterSizeCache;
|
|
|
|
}
|
|
|
|
|
2013-02-25 04:16:02 +04:00
|
|
|
/* DrawThemeBGRTLAware - render a theme part based on rtl state.
|
|
|
|
* Some widgets are not direction-neutral and need to be drawn reversed for
|
|
|
|
* RTL. Windows provides a way to do this with SetLayout, but this reverses
|
|
|
|
* the entire drawing area of a given device context, which means that its
|
|
|
|
* use will also affect the positioning of the widget. There are two ways
|
|
|
|
* to work around this:
|
|
|
|
*
|
|
|
|
* Option 1: Alter the position of the rect that we send so that we cancel
|
|
|
|
* out the positioning effects of SetLayout
|
|
|
|
* Option 2: Create a memory DC with the widgetRect's dimensions, draw onto
|
|
|
|
* that, and then transfer the results back to our DC
|
|
|
|
*
|
|
|
|
* This function tries to implement option 1, under the assumption that the
|
|
|
|
* correct way to reverse the effects of SetLayout is to translate the rect
|
|
|
|
* such that the offset from the DC bitmap's left edge to the old rect's
|
|
|
|
* left edge is equal to the offset from the DC bitmap's right edge to the
|
|
|
|
* new rect's right edge. In other words,
|
|
|
|
* (oldRect.left + vpOrg.x) == ((dcBMP.width - vpOrg.x) - newRect.right)
|
|
|
|
*/
|
|
|
|
static HRESULT
|
|
|
|
DrawThemeBGRTLAware(HANDLE aTheme, HDC aHdc, int aPart, int aState,
|
|
|
|
const RECT *aWidgetRect, const RECT *aClipRect,
|
|
|
|
bool aIsRtl)
|
2008-07-19 00:50:21 +04:00
|
|
|
{
|
2013-02-25 04:16:02 +04:00
|
|
|
NS_ASSERTION(aTheme, "Bad theme handle.");
|
|
|
|
NS_ASSERTION(aHdc, "Bad hdc.");
|
|
|
|
NS_ASSERTION(aWidgetRect, "Bad rect.");
|
|
|
|
NS_ASSERTION(aClipRect, "Bad clip rect.");
|
|
|
|
|
|
|
|
if (!aIsRtl) {
|
|
|
|
return DrawThemeBackground(aTheme, aHdc, aPart, aState,
|
|
|
|
aWidgetRect, aClipRect);
|
2008-07-19 00:50:21 +04:00
|
|
|
}
|
|
|
|
|
2013-02-25 04:16:02 +04:00
|
|
|
HGDIOBJ hObj = GetCurrentObject(aHdc, OBJ_BITMAP);
|
|
|
|
BITMAP bitmap;
|
|
|
|
POINT vpOrg;
|
|
|
|
|
|
|
|
if (hObj && GetObject(hObj, sizeof(bitmap), &bitmap) &&
|
|
|
|
GetViewportOrgEx(aHdc, &vpOrg)) {
|
|
|
|
RECT newWRect(*aWidgetRect);
|
|
|
|
newWRect.left = bitmap.bmWidth - (aWidgetRect->right + 2*vpOrg.x);
|
|
|
|
newWRect.right = bitmap.bmWidth - (aWidgetRect->left + 2*vpOrg.x);
|
|
|
|
|
|
|
|
RECT newCRect;
|
2013-10-08 22:48:20 +04:00
|
|
|
RECT *newCRectPtr = nullptr;
|
2013-02-25 04:16:02 +04:00
|
|
|
|
|
|
|
if (aClipRect) {
|
|
|
|
newCRect.top = aClipRect->top;
|
|
|
|
newCRect.bottom = aClipRect->bottom;
|
|
|
|
newCRect.left = bitmap.bmWidth - (aClipRect->right + 2*vpOrg.x);
|
|
|
|
newCRect.right = bitmap.bmWidth - (aClipRect->left + 2*vpOrg.x);
|
|
|
|
newCRectPtr = &newCRect;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetLayout(aHdc, LAYOUT_RTL);
|
|
|
|
HRESULT hr = DrawThemeBackground(aTheme, aHdc, aPart, aState, &newWRect,
|
|
|
|
newCRectPtr);
|
|
|
|
SetLayout(aHdc, 0);
|
|
|
|
if (SUCCEEDED(hr)) {
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return DrawThemeBackground(aTheme, aHdc, aPart, aState,
|
|
|
|
aWidgetRect, aClipRect);
|
2008-07-19 00:50:21 +04:00
|
|
|
}
|
|
|
|
|
2010-11-29 19:19:17 +03:00
|
|
|
/*
|
2013-02-25 04:16:02 +04:00
|
|
|
* Caption button padding data - 'hot' button padding.
|
|
|
|
* These areas are considered hot, in that they activate
|
|
|
|
* a button when hovered or clicked. The button graphic
|
|
|
|
* is drawn inside the padding border. Unrecognized themes
|
|
|
|
* are treated as their recognized counterparts for now.
|
|
|
|
* left top right bottom
|
|
|
|
* classic min 1 2 0 1
|
|
|
|
* classic max 0 2 1 1
|
|
|
|
* classic close 1 2 2 1
|
|
|
|
*
|
|
|
|
* aero basic min 1 2 0 2
|
|
|
|
* aero basic max 0 2 1 2
|
|
|
|
* aero basic close 1 2 1 2
|
|
|
|
*
|
|
|
|
* 'cold' button padding - generic button padding, should
|
|
|
|
* be handled in css.
|
|
|
|
* left top right bottom
|
|
|
|
* classic min 0 0 0 0
|
|
|
|
* classic max 0 0 0 0
|
|
|
|
* classic close 0 0 0 0
|
|
|
|
*
|
|
|
|
* aero basic min 0 0 1 0
|
|
|
|
* aero basic max 1 0 0 0
|
|
|
|
* aero basic close 0 0 0 0
|
|
|
|
*/
|
2010-11-29 19:19:17 +03:00
|
|
|
|
|
|
|
enum CaptionDesktopTheme {
|
|
|
|
CAPTION_CLASSIC = 0,
|
|
|
|
CAPTION_BASIC,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum CaptionButton {
|
|
|
|
CAPTIONBUTTON_MINIMIZE = 0,
|
|
|
|
CAPTIONBUTTON_RESTORE,
|
|
|
|
CAPTIONBUTTON_CLOSE,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CaptionButtonPadding {
|
|
|
|
RECT hotPadding[3];
|
|
|
|
};
|
|
|
|
|
|
|
|
// RECT: left, top, right, bottom
|
|
|
|
static CaptionButtonPadding buttonData[3] = {
|
|
|
|
{
|
|
|
|
{ { 1, 2, 0, 1 }, { 0, 2, 1, 1 }, { 1, 2, 2, 1 } }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{ { 1, 2, 0, 2 }, { 0, 2, 1, 2 }, { 1, 2, 2, 2 } }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{ { 0, 2, 0, 2 }, { 0, 2, 1, 2 }, { 1, 2, 2, 2 } }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Adds "hot" caption button padding to minimum widget size.
|
2013-02-25 04:16:02 +04:00
|
|
|
static void
|
2015-03-30 18:36:14 +03:00
|
|
|
AddPaddingRect(LayoutDeviceIntSize* aSize, CaptionButton button) {
|
2010-11-29 19:19:17 +03:00
|
|
|
if (!aSize)
|
|
|
|
return;
|
|
|
|
RECT offset;
|
2012-02-23 18:53:55 +04:00
|
|
|
if (!IsAppThemed())
|
2010-11-29 19:19:17 +03:00
|
|
|
offset = buttonData[CAPTION_CLASSIC].hotPadding[button];
|
|
|
|
else
|
|
|
|
offset = buttonData[CAPTION_BASIC].hotPadding[button];
|
|
|
|
aSize->width += offset.left + offset.right;
|
|
|
|
aSize->height += offset.top + offset.bottom;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we've added padding to the minimum widget size, offset
|
|
|
|
// the area we draw into to compensate.
|
2013-02-25 04:16:02 +04:00
|
|
|
static void
|
|
|
|
OffsetBackgroundRect(RECT& rect, CaptionButton button) {
|
2010-11-29 19:19:17 +03:00
|
|
|
RECT offset;
|
2012-02-23 18:53:55 +04:00
|
|
|
if (!IsAppThemed())
|
2010-11-29 19:19:17 +03:00
|
|
|
offset = buttonData[CAPTION_CLASSIC].hotPadding[button];
|
|
|
|
else
|
|
|
|
offset = buttonData[CAPTION_BASIC].hotPadding[button];
|
|
|
|
rect.left += offset.left;
|
|
|
|
rect.top += offset.top;
|
|
|
|
rect.right -= offset.right;
|
|
|
|
rect.bottom -= offset.bottom;
|
|
|
|
}
|
|
|
|
|
2013-02-25 04:27:10 +04:00
|
|
|
/*
|
|
|
|
* Notes on progress track and meter part constants:
|
|
|
|
* xp and up:
|
|
|
|
* PP_BAR(_VERT) - base progress track
|
|
|
|
* PP_TRANSPARENTBAR(_VERT) - transparent progress track. this only works if
|
|
|
|
* the underlying surface supports alpha. otherwise
|
|
|
|
* theme lib's DrawThemeBackground falls back on
|
|
|
|
* opaque PP_BAR. we currently don't use this.
|
|
|
|
* PP_CHUNK(_VERT) - xp progress meter. this does not draw an xp style
|
|
|
|
* progress w/chunks, it draws fill using the chunk
|
|
|
|
* graphic.
|
|
|
|
* vista and up:
|
|
|
|
* PP_FILL(_VERT) - progress meter. these have four states/colors.
|
|
|
|
* PP_PULSEOVERLAY(_VERT) - white reflection - an overlay, not sure what this
|
|
|
|
* is used for.
|
|
|
|
* PP_MOVEOVERLAY(_VERT) - green pulse - the pulse effect overlay on
|
|
|
|
* determined progress bars. we also use this for
|
|
|
|
* indeterminate chunk.
|
|
|
|
*
|
|
|
|
* Notes on state constants:
|
|
|
|
* PBBS_NORMAL - green progress
|
|
|
|
* PBBVS_PARTIAL/PBFVS_ERROR - red error progress
|
|
|
|
* PBFS_PAUSED - yellow paused progress
|
|
|
|
*
|
|
|
|
* There is no common controls style indeterminate part on vista and up.
|
|
|
|
*/
|
|
|
|
|
2013-02-25 04:16:02 +04:00
|
|
|
/*
|
|
|
|
* Progress bar related constants. These values are found by experimenting and
|
|
|
|
* comparing against native widgets used by the system. They are very unlikely
|
|
|
|
* exact but try to not be too wrong.
|
|
|
|
*/
|
2013-02-25 04:27:10 +04:00
|
|
|
// The amount of time we animate progress meters parts across the frame.
|
|
|
|
static const double kProgressDeterminateTimeSpan = 3.0;
|
|
|
|
static const double kProgressIndeterminateTimeSpan = 5.0;
|
2013-02-25 04:16:02 +04:00
|
|
|
// The width of the overlay used to animate the horizontal progress bar (Vista and later).
|
2016-12-23 05:13:31 +03:00
|
|
|
static const int32_t kProgressHorizontalOverlaySize = 120;
|
2013-02-25 04:16:02 +04:00
|
|
|
// The height of the overlay used to animate the vertical progress bar (Vista and later).
|
|
|
|
static const int32_t kProgressVerticalOverlaySize = 45;
|
|
|
|
// The height of the overlay used for the vertical indeterminate progress bar (Vista and later).
|
|
|
|
static const int32_t kProgressVerticalIndeterminateOverlaySize = 60;
|
|
|
|
// The width of the overlay used to animate the indeterminate progress bar (Windows Classic).
|
|
|
|
static const int32_t kProgressClassicOverlaySize = 40;
|
2013-02-25 04:27:10 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* GetProgressOverlayStyle - returns the proper overlay part for themed
|
|
|
|
* progress bars based on os and orientation.
|
|
|
|
*/
|
|
|
|
static int32_t
|
|
|
|
GetProgressOverlayStyle(bool aIsVertical)
|
2016-12-23 05:13:31 +03:00
|
|
|
{
|
|
|
|
return aIsVertical ? PP_MOVEOVERLAYVERT : PP_MOVEOVERLAY;
|
2013-02-25 04:27:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* GetProgressOverlaySize - returns the minimum width or height for themed
|
|
|
|
* progress bar overlays. This includes the width of indeterminate chunks
|
|
|
|
* and vista pulse overlays.
|
|
|
|
*/
|
|
|
|
static int32_t
|
|
|
|
GetProgressOverlaySize(bool aIsVertical, bool aIsIndeterminate)
|
|
|
|
{
|
2016-12-23 05:13:31 +03:00
|
|
|
if (aIsVertical) {
|
|
|
|
return aIsIndeterminate ? kProgressVerticalIndeterminateOverlaySize
|
|
|
|
: kProgressVerticalOverlaySize;
|
2013-02-25 04:27:10 +04:00
|
|
|
}
|
2016-12-23 05:13:31 +03:00
|
|
|
return kProgressHorizontalOverlaySize;
|
2013-02-25 04:27:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* IsProgressMeterFilled - Determines if a progress meter is at 100% fill based
|
|
|
|
* on a comparison of the current value and maximum.
|
|
|
|
*/
|
|
|
|
static bool
|
|
|
|
IsProgressMeterFilled(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(aFrame, false);
|
|
|
|
nsIFrame* parentFrame = aFrame->GetParent();
|
|
|
|
NS_ENSURE_TRUE(parentFrame, false);
|
|
|
|
return nsNativeTheme::GetProgressValue(parentFrame) ==
|
|
|
|
nsNativeTheme::GetProgressMaxValue(parentFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* CalculateProgressOverlayRect - returns the padded overlay animation rect
|
|
|
|
* used in rendering progress bars. Resulting rects are used in rendering
|
|
|
|
* vista+ pulse overlays and indeterminate progress meters. Graphics should
|
|
|
|
* be rendered at the origin.
|
|
|
|
*/
|
|
|
|
RECT
|
|
|
|
nsNativeThemeWin::CalculateProgressOverlayRect(nsIFrame* aFrame,
|
|
|
|
RECT* aWidgetRect,
|
|
|
|
bool aIsVertical,
|
|
|
|
bool aIsIndeterminate,
|
|
|
|
bool aIsClassic)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aFrame, "bad frame pointer");
|
|
|
|
NS_ASSERTION(aWidgetRect, "bad rect pointer");
|
|
|
|
|
|
|
|
int32_t frameSize = aIsVertical ? aWidgetRect->bottom - aWidgetRect->top
|
|
|
|
: aWidgetRect->right - aWidgetRect->left;
|
|
|
|
|
|
|
|
// Recycle a set of progress pulse timers - these timers control the position
|
|
|
|
// of all progress overlays and indeterminate chunks that get rendered.
|
|
|
|
double span = aIsIndeterminate ? kProgressIndeterminateTimeSpan
|
|
|
|
: kProgressDeterminateTimeSpan;
|
|
|
|
TimeDuration period;
|
|
|
|
if (!aIsIndeterminate) {
|
|
|
|
if (TimeStamp::Now() > (mProgressDeterminateTimeStamp +
|
|
|
|
TimeDuration::FromSeconds(span))) {
|
|
|
|
mProgressDeterminateTimeStamp = TimeStamp::Now();
|
|
|
|
}
|
|
|
|
period = TimeStamp::Now() - mProgressDeterminateTimeStamp;
|
|
|
|
} else {
|
|
|
|
if (TimeStamp::Now() > (mProgressIndeterminateTimeStamp +
|
|
|
|
TimeDuration::FromSeconds(span))) {
|
|
|
|
mProgressIndeterminateTimeStamp = TimeStamp::Now();
|
|
|
|
}
|
|
|
|
period = TimeStamp::Now() - mProgressIndeterminateTimeStamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
double percent = period / TimeDuration::FromSeconds(span);
|
|
|
|
|
|
|
|
if (!aIsVertical && IsFrameRTL(aFrame))
|
|
|
|
percent = 1 - percent;
|
|
|
|
|
|
|
|
RECT overlayRect = *aWidgetRect;
|
|
|
|
int32_t overlaySize;
|
|
|
|
if (!aIsClassic) {
|
|
|
|
overlaySize = GetProgressOverlaySize(aIsVertical, aIsIndeterminate);
|
|
|
|
} else {
|
|
|
|
overlaySize = kProgressClassicOverlaySize;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Calculate a bounds that is larger than the meters frame such that the
|
|
|
|
// overlay starts and ends completely off the edge of the frame:
|
|
|
|
// [overlay][frame][overlay]
|
|
|
|
// This also yields a nice delay on rotation. Use overlaySize as the minimum
|
|
|
|
// size for [overlay] based on the graphics dims. If [frame] is larger, use
|
|
|
|
// the frame size instead.
|
|
|
|
int trackWidth = frameSize > overlaySize ? frameSize : overlaySize;
|
|
|
|
if (!aIsVertical) {
|
|
|
|
int xPos = aWidgetRect->left - trackWidth;
|
|
|
|
xPos += (int)ceil(((double)(trackWidth*2) * percent));
|
|
|
|
overlayRect.left = xPos;
|
|
|
|
overlayRect.right = xPos + overlaySize;
|
|
|
|
} else {
|
|
|
|
int yPos = aWidgetRect->bottom + trackWidth;
|
|
|
|
yPos -= (int)ceil(((double)(trackWidth*2) * percent));
|
|
|
|
overlayRect.bottom = yPos;
|
|
|
|
overlayRect.top = yPos - overlaySize;
|
|
|
|
}
|
|
|
|
return overlayRect;
|
|
|
|
}
|
2013-02-25 04:16:02 +04:00
|
|
|
|
2013-03-02 18:37:20 +04:00
|
|
|
/*
|
|
|
|
* DrawProgressMeter - render an appropriate progress meter based on progress
|
2013-02-25 04:27:22 +04:00
|
|
|
* meter style, orientation, and os. Note, this does not render the underlying
|
|
|
|
* progress track.
|
|
|
|
*
|
|
|
|
* @param aFrame the widget frame
|
|
|
|
* @param aWidgetType type of widget
|
|
|
|
* @param aTheme progress theme handle
|
|
|
|
* @param aHdc hdc returned by gfxWindowsNativeDrawing
|
|
|
|
* @param aPart the PP_X progress part
|
|
|
|
* @param aState the theme state
|
|
|
|
* @param aWidgetRect bounding rect for the widget
|
|
|
|
* @param aClipRect dirty rect that needs drawing.
|
|
|
|
* @param aAppUnits app units per device pixel
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
nsNativeThemeWin::DrawThemedProgressMeter(nsIFrame* aFrame, int aWidgetType,
|
|
|
|
HANDLE aTheme, HDC aHdc,
|
|
|
|
int aPart, int aState,
|
2016-12-23 05:13:31 +03:00
|
|
|
RECT* aWidgetRect, RECT* aClipRect)
|
2013-02-25 04:27:22 +04:00
|
|
|
{
|
|
|
|
if (!aFrame || !aTheme || !aHdc)
|
|
|
|
return;
|
|
|
|
|
|
|
|
NS_ASSERTION(aWidgetRect, "bad rect pointer");
|
|
|
|
NS_ASSERTION(aClipRect, "bad clip rect pointer");
|
|
|
|
|
|
|
|
RECT adjWidgetRect, adjClipRect;
|
|
|
|
adjWidgetRect = *aWidgetRect;
|
|
|
|
adjClipRect = *aClipRect;
|
|
|
|
|
|
|
|
nsIFrame* parentFrame = aFrame->GetParent();
|
|
|
|
if (!parentFrame) {
|
|
|
|
// We have no parent to work with, just bail.
|
|
|
|
NS_WARNING("No parent frame for progress rendering. Can't paint.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates eventStates = GetContentState(parentFrame, aWidgetType);
|
2013-02-25 04:27:22 +04:00
|
|
|
bool vertical = IsVerticalProgress(parentFrame) ||
|
2016-05-18 20:29:56 +03:00
|
|
|
aWidgetType == NS_THEME_PROGRESSCHUNK_VERTICAL;
|
2013-02-25 04:27:22 +04:00
|
|
|
bool indeterminate = IsIndeterminateProgress(parentFrame, eventStates);
|
|
|
|
bool animate = indeterminate;
|
|
|
|
|
2016-12-23 05:13:31 +03:00
|
|
|
// Vista and up progress meter is fill style, rendered here. We render
|
|
|
|
// the pulse overlay in the follow up section below.
|
|
|
|
DrawThemeBackground(aTheme, aHdc, aPart, aState,
|
|
|
|
&adjWidgetRect, &adjClipRect);
|
|
|
|
if (!IsProgressMeterFilled(aFrame)) {
|
|
|
|
animate = true;
|
|
|
|
}
|
2013-02-25 04:27:22 +04:00
|
|
|
|
|
|
|
if (animate) {
|
|
|
|
// Indeterminate rendering
|
|
|
|
int32_t overlayPart = GetProgressOverlayStyle(vertical);
|
|
|
|
RECT overlayRect =
|
|
|
|
CalculateProgressOverlayRect(aFrame, &adjWidgetRect, vertical,
|
|
|
|
indeterminate, false);
|
2016-12-23 05:13:31 +03:00
|
|
|
DrawThemeBackground(aTheme, aHdc, overlayPart, aState, &overlayRect,
|
|
|
|
&adjClipRect);
|
2013-02-25 04:27:22 +04:00
|
|
|
|
|
|
|
if (!QueueAnimatedContentForRefresh(aFrame->GetContent(), 60)) {
|
|
|
|
NS_WARNING("unable to animate progress widget!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-17 23:55:28 +03:00
|
|
|
nsresult nsNativeThemeWin::GetCachedWidgetBorder(nsIFrame * aFrame, HTHEME aTheme,
|
|
|
|
nsUXThemeClass aThemeClass, uint8_t aWidgetType,
|
|
|
|
int32_t aPart, int32_t aState,
|
2017-06-21 23:43:27 +03:00
|
|
|
nsIntMargin * aResult)
|
|
|
|
{
|
|
|
|
int32_t cacheIndex = aThemeClass * THEME_PART_DISTINCT_VALUE_COUNT + aPart;
|
|
|
|
int32_t cacheBitIndex = cacheIndex / 8;
|
|
|
|
uint8_t cacheBit = 1u << (cacheIndex % 8);
|
|
|
|
|
|
|
|
if (mBorderCacheValid[cacheBitIndex] & cacheBit) {
|
|
|
|
*aResult = mBorderCache[cacheIndex];
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get our info.
|
|
|
|
RECT outerRect; // Create a fake outer rect.
|
|
|
|
outerRect.top = outerRect.left = 100;
|
|
|
|
outerRect.right = outerRect.bottom = 200;
|
|
|
|
RECT contentRect(outerRect);
|
2017-07-17 23:55:28 +03:00
|
|
|
HRESULT res = GetThemeBackgroundContentRect(aTheme, nullptr, aPart, aState, &outerRect, &contentRect);
|
2017-06-21 23:43:27 +03:00
|
|
|
|
|
|
|
if (FAILED(res)) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now compute the delta in each direction and place it in our
|
|
|
|
// nsIntMargin struct.
|
|
|
|
aResult->top = contentRect.top - outerRect.top;
|
|
|
|
aResult->bottom = outerRect.bottom - contentRect.bottom;
|
|
|
|
aResult->left = contentRect.left - outerRect.left;
|
|
|
|
aResult->right = outerRect.right - contentRect.right;
|
|
|
|
|
|
|
|
mBorderCacheValid[cacheBitIndex] |= cacheBit;
|
|
|
|
mBorderCache[cacheIndex] = *aResult;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-06-22 23:19:13 +03:00
|
|
|
nsresult nsNativeThemeWin::GetCachedMinimumWidgetSize(nsIFrame * aFrame, HANDLE aTheme,
|
|
|
|
nsUXThemeClass aThemeClass, uint8_t aWidgetType,
|
|
|
|
int32_t aPart, int32_t aState, THEMESIZE aSizeReq,
|
|
|
|
mozilla::LayoutDeviceIntSize * aResult)
|
|
|
|
{
|
2017-07-07 20:15:32 +03:00
|
|
|
int32_t cachePart = aPart;
|
|
|
|
|
2017-07-17 23:55:28 +03:00
|
|
|
if (aWidgetType == NS_THEME_BUTTON && aSizeReq == TS_MIN) {
|
|
|
|
// In practice, NS_THEME_BUTTON is the only widget type which has an aSizeReq
|
|
|
|
// that varies for us, and it can only be TS_MIN or TS_TRUE. Just stuff that
|
|
|
|
// extra bit into the aPart part of the cache, since BP_Count is well below
|
|
|
|
// THEME_PART_DISTINCT_VALUE_COUNT anyway.
|
|
|
|
cachePart = BP_Count;
|
2017-07-07 20:15:32 +03:00
|
|
|
}
|
|
|
|
|
2017-06-22 23:19:13 +03:00
|
|
|
MOZ_ASSERT(aPart < THEME_PART_DISTINCT_VALUE_COUNT);
|
2017-07-07 20:15:32 +03:00
|
|
|
int32_t cacheIndex = aThemeClass * THEME_PART_DISTINCT_VALUE_COUNT + cachePart;
|
2017-06-22 23:19:13 +03:00
|
|
|
int32_t cacheBitIndex = cacheIndex / 8;
|
|
|
|
uint8_t cacheBit = 1u << (cacheIndex % 8);
|
|
|
|
|
|
|
|
if (mMinimumWidgetSizeCacheValid[cacheBitIndex] & cacheBit) {
|
|
|
|
*aResult = mMinimumWidgetSizeCache[cacheIndex];
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HDC hdc = ::GetDC(NULL);
|
|
|
|
if (!hdc) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
SIZE sz;
|
|
|
|
GetThemePartSize(aTheme, hdc, aPart, aState, nullptr, aSizeReq, &sz);
|
|
|
|
aResult->width = sz.cx;
|
|
|
|
aResult->height = sz.cy;
|
|
|
|
|
|
|
|
switch (aWidgetType) {
|
2017-11-29 05:43:13 +03:00
|
|
|
case NS_THEME_INNER_SPIN_BUTTON:
|
2017-06-22 23:19:13 +03:00
|
|
|
case NS_THEME_SPINNER_UPBUTTON:
|
|
|
|
case NS_THEME_SPINNER_DOWNBUTTON:
|
|
|
|
aResult->width++;
|
|
|
|
aResult->height = aResult->height / 2 + 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_THEME_MENUSEPARATOR:
|
|
|
|
{
|
|
|
|
SIZE gutterSize(GetGutterSize(aTheme, hdc));
|
|
|
|
aResult->width += gutterSize.cx;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NS_THEME_MENUARROW:
|
|
|
|
{
|
|
|
|
// Use the width of the arrow glyph as padding. See the drawing
|
|
|
|
// code for details.
|
|
|
|
aResult->width *= 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
::ReleaseDC(nullptr, hdc);
|
|
|
|
|
|
|
|
mMinimumWidgetSizeCacheValid[cacheBitIndex] |= cacheBit;
|
|
|
|
mMinimumWidgetSizeCache[cacheIndex] = *aResult;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-06-21 23:43:27 +03:00
|
|
|
mozilla::Maybe<nsUXThemeClass> nsNativeThemeWin::GetThemeClass(uint8_t aWidgetType)
|
|
|
|
{
|
2005-08-20 11:11:56 +04:00
|
|
|
switch (aWidgetType) {
|
|
|
|
case NS_THEME_BUTTON:
|
|
|
|
case NS_THEME_RADIO:
|
2007-05-09 23:17:17 +04:00
|
|
|
case NS_THEME_CHECKBOX:
|
2009-03-12 05:11:01 +03:00
|
|
|
case NS_THEME_GROUPBOX:
|
2017-06-21 23:43:27 +03:00
|
|
|
return Some(eUXButton);
|
2013-12-09 03:23:28 +04:00
|
|
|
case NS_THEME_NUMBER_INPUT:
|
2005-08-20 11:12:07 +04:00
|
|
|
case NS_THEME_TEXTFIELD:
|
2008-07-17 21:19:10 +04:00
|
|
|
case NS_THEME_TEXTFIELD_MULTILINE:
|
2014-06-14 16:48:08 +04:00
|
|
|
case NS_THEME_FOCUS_OUTLINE:
|
2017-06-21 23:43:27 +03:00
|
|
|
return Some(eUXEdit);
|
2008-07-17 21:19:10 +04:00
|
|
|
case NS_THEME_TOOLTIP:
|
2017-06-21 23:43:27 +03:00
|
|
|
return Some(eUXTooltip);
|
2008-07-17 21:19:10 +04:00
|
|
|
case NS_THEME_TOOLBOX:
|
2017-06-21 23:43:27 +03:00
|
|
|
return Some(eUXRebar);
|
2008-07-17 21:19:10 +04:00
|
|
|
case NS_THEME_WIN_MEDIA_TOOLBOX:
|
2017-06-21 23:43:27 +03:00
|
|
|
return Some(eUXMediaRebar);
|
2008-07-17 21:19:10 +04:00
|
|
|
case NS_THEME_WIN_COMMUNICATIONS_TOOLBOX:
|
2017-06-21 23:43:27 +03:00
|
|
|
return Some(eUXCommunicationsRebar);
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_WIN_BROWSERTABBAR_TOOLBOX:
|
2017-06-21 23:43:27 +03:00
|
|
|
return Some(eUXBrowserTabBarRebar);
|
2005-08-20 11:11:56 +04:00
|
|
|
case NS_THEME_TOOLBAR:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_TOOLBARBUTTON:
|
|
|
|
case NS_THEME_SEPARATOR:
|
2017-06-21 23:43:27 +03:00
|
|
|
return Some(eUXToolbar);
|
2005-08-20 11:11:59 +04:00
|
|
|
case NS_THEME_PROGRESSBAR:
|
|
|
|
case NS_THEME_PROGRESSBAR_VERTICAL:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_PROGRESSCHUNK:
|
|
|
|
case NS_THEME_PROGRESSCHUNK_VERTICAL:
|
2017-06-21 23:43:27 +03:00
|
|
|
return Some(eUXProgress);
|
2005-08-20 11:11:56 +04:00
|
|
|
case NS_THEME_TAB:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_TABPANEL:
|
|
|
|
case NS_THEME_TABPANELS:
|
2017-06-21 23:43:27 +03:00
|
|
|
return Some(eUXTab);
|
2005-08-20 11:11:56 +04:00
|
|
|
case NS_THEME_SCROLLBAR:
|
2007-07-14 01:46:28 +04:00
|
|
|
case NS_THEME_SCROLLBAR_SMALL:
|
2015-12-22 07:05:00 +03:00
|
|
|
case NS_THEME_SCROLLBAR_VERTICAL:
|
|
|
|
case NS_THEME_SCROLLBAR_HORIZONTAL:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SCROLLBARBUTTON_UP:
|
|
|
|
case NS_THEME_SCROLLBARBUTTON_DOWN:
|
|
|
|
case NS_THEME_SCROLLBARBUTTON_LEFT:
|
|
|
|
case NS_THEME_SCROLLBARBUTTON_RIGHT:
|
|
|
|
case NS_THEME_SCROLLBARTHUMB_VERTICAL:
|
|
|
|
case NS_THEME_SCROLLBARTHUMB_HORIZONTAL:
|
2017-06-21 23:43:27 +03:00
|
|
|
return Some(eUXScrollbar);
|
2013-04-03 14:07:12 +04:00
|
|
|
case NS_THEME_RANGE:
|
|
|
|
case NS_THEME_RANGE_THUMB:
|
2006-05-30 17:50:48 +04:00
|
|
|
case NS_THEME_SCALE_HORIZONTAL:
|
|
|
|
case NS_THEME_SCALE_VERTICAL:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SCALETHUMB_HORIZONTAL:
|
|
|
|
case NS_THEME_SCALETHUMB_VERTICAL:
|
2017-06-21 23:43:27 +03:00
|
|
|
return Some(eUXTrackbar);
|
2017-11-29 05:43:13 +03:00
|
|
|
case NS_THEME_INNER_SPIN_BUTTON:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SPINNER_UPBUTTON:
|
|
|
|
case NS_THEME_SPINNER_DOWNBUTTON:
|
2017-06-21 23:43:27 +03:00
|
|
|
return Some(eUXSpin);
|
2005-08-20 11:11:57 +04:00
|
|
|
case NS_THEME_STATUSBAR:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_STATUSBARPANEL:
|
2016-05-19 11:58:00 +03:00
|
|
|
case NS_THEME_RESIZERPANEL:
|
2005-08-20 11:11:57 +04:00
|
|
|
case NS_THEME_RESIZER:
|
2017-06-21 23:43:27 +03:00
|
|
|
return Some(eUXStatus);
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_MENULIST:
|
|
|
|
case NS_THEME_MENULIST_BUTTON:
|
2017-06-21 23:43:27 +03:00
|
|
|
return Some(eUXCombobox);
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_TREEHEADERCELL:
|
|
|
|
case NS_THEME_TREEHEADERSORTARROW:
|
2017-06-21 23:43:27 +03:00
|
|
|
return Some(eUXHeader);
|
2005-08-20 11:12:55 +04:00
|
|
|
case NS_THEME_LISTBOX:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_LISTITEM:
|
2005-08-20 11:12:55 +04:00
|
|
|
case NS_THEME_TREEVIEW:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_TREETWISTYOPEN:
|
|
|
|
case NS_THEME_TREEITEM:
|
2017-06-21 23:43:27 +03:00
|
|
|
return Some(eUXListview);
|
2007-08-06 21:45:57 +04:00
|
|
|
case NS_THEME_MENUBAR:
|
|
|
|
case NS_THEME_MENUPOPUP:
|
|
|
|
case NS_THEME_MENUITEM:
|
|
|
|
case NS_THEME_CHECKMENUITEM:
|
|
|
|
case NS_THEME_RADIOMENUITEM:
|
|
|
|
case NS_THEME_MENUCHECKBOX:
|
|
|
|
case NS_THEME_MENURADIO:
|
|
|
|
case NS_THEME_MENUSEPARATOR:
|
|
|
|
case NS_THEME_MENUARROW:
|
|
|
|
case NS_THEME_MENUIMAGE:
|
|
|
|
case NS_THEME_MENUITEMTEXT:
|
2017-06-21 23:43:27 +03:00
|
|
|
return Some(eUXMenu);
|
2010-08-10 05:49:35 +04:00
|
|
|
case NS_THEME_WINDOW_TITLEBAR:
|
|
|
|
case NS_THEME_WINDOW_TITLEBAR_MAXIMIZED:
|
|
|
|
case NS_THEME_WINDOW_FRAME_LEFT:
|
|
|
|
case NS_THEME_WINDOW_FRAME_RIGHT:
|
|
|
|
case NS_THEME_WINDOW_FRAME_BOTTOM:
|
|
|
|
case NS_THEME_WINDOW_BUTTON_CLOSE:
|
|
|
|
case NS_THEME_WINDOW_BUTTON_MINIMIZE:
|
|
|
|
case NS_THEME_WINDOW_BUTTON_MAXIMIZE:
|
|
|
|
case NS_THEME_WINDOW_BUTTON_RESTORE:
|
2010-08-10 05:49:35 +04:00
|
|
|
case NS_THEME_WINDOW_BUTTON_BOX:
|
|
|
|
case NS_THEME_WINDOW_BUTTON_BOX_MAXIMIZED:
|
2010-10-19 21:02:25 +04:00
|
|
|
case NS_THEME_WIN_GLASS:
|
|
|
|
case NS_THEME_WIN_BORDERLESS_GLASS:
|
2017-06-21 23:43:27 +03:00
|
|
|
return Some(eUXWindowFrame);
|
|
|
|
}
|
|
|
|
return Nothing();
|
|
|
|
}
|
|
|
|
|
|
|
|
HANDLE
|
|
|
|
nsNativeThemeWin::GetTheme(uint8_t aWidgetType)
|
|
|
|
{
|
|
|
|
mozilla::Maybe<nsUXThemeClass> themeClass = GetThemeClass(aWidgetType);
|
|
|
|
if (themeClass.isNothing()) {
|
|
|
|
return nullptr;
|
2005-08-20 11:11:56 +04:00
|
|
|
}
|
2017-06-21 23:43:27 +03:00
|
|
|
return nsUXThemeData::GetTheme(themeClass.value());
|
2005-08-20 11:11:56 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t
|
|
|
|
nsNativeThemeWin::StandardGetState(nsIFrame* aFrame, uint8_t aWidgetType,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool wantFocused)
|
2008-02-29 08:10:12 +03:00
|
|
|
{
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates eventState = GetContentState(aFrame, aWidgetType);
|
2010-10-20 15:26:32 +04:00
|
|
|
if (eventState.HasAllStates(NS_EVENT_STATE_HOVER | NS_EVENT_STATE_ACTIVE))
|
2008-02-29 08:10:12 +03:00
|
|
|
return TS_ACTIVE;
|
2010-10-20 15:26:32 +04:00
|
|
|
if (eventState.HasState(NS_EVENT_STATE_HOVER))
|
2008-02-29 08:10:12 +03:00
|
|
|
return TS_HOVER;
|
2011-06-30 00:15:58 +04:00
|
|
|
if (wantFocused && eventState.HasState(NS_EVENT_STATE_FOCUS))
|
|
|
|
return TS_FOCUSED;
|
2008-02-29 08:10:12 +03:00
|
|
|
|
|
|
|
return TS_NORMAL;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2012-08-22 19:56:38 +04:00
|
|
|
nsNativeThemeWin::IsMenuActive(nsIFrame *aFrame, uint8_t aWidgetType)
|
2008-02-29 08:10:12 +03:00
|
|
|
{
|
2009-07-25 17:10:17 +04:00
|
|
|
nsIContent* content = aFrame->GetContent();
|
2015-03-03 14:08:59 +03:00
|
|
|
if (content->IsXULElement() &&
|
2011-10-14 22:11:22 +04:00
|
|
|
content->NodeInfo()->Equals(nsGkAtoms::richlistitem))
|
|
|
|
return CheckBooleanAttr(aFrame, nsGkAtoms::selected);
|
2009-07-25 17:10:17 +04:00
|
|
|
|
2011-10-14 22:11:22 +04:00
|
|
|
return CheckBooleanAttr(aFrame, nsGkAtoms::menuactive);
|
2008-02-29 08:10:12 +03:00
|
|
|
}
|
|
|
|
|
2010-06-11 02:53:57 +04:00
|
|
|
/**
|
|
|
|
* aPart is filled in with the UXTheme part code. On return, values > 0
|
|
|
|
* are the actual UXTheme part code; -1 means the widget will be drawn by
|
|
|
|
* us; 0 means that we should use part code 0, which isn't a real part code
|
|
|
|
* but elicits some kind of default behaviour from UXTheme when drawing
|
|
|
|
* (but isThemeBackgroundPartiallyTransparent may not work).
|
|
|
|
*/
|
2005-08-20 11:11:56 +04:00
|
|
|
nsresult
|
2012-08-22 19:56:38 +04:00
|
|
|
nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType,
|
|
|
|
int32_t& aPart, int32_t& aState)
|
2005-08-20 11:11:56 +04:00
|
|
|
{
|
|
|
|
switch (aWidgetType) {
|
|
|
|
case NS_THEME_BUTTON: {
|
2005-08-20 11:11:59 +04:00
|
|
|
aPart = BP_BUTTON;
|
2005-08-20 11:11:56 +04:00
|
|
|
if (!aFrame) {
|
2005-08-20 11:11:59 +04:00
|
|
|
aState = TS_NORMAL;
|
2005-08-20 11:11:56 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates eventState = GetContentState(aFrame, aWidgetType);
|
2010-09-28 05:25:18 +04:00
|
|
|
if (IsDisabled(aFrame, eventState)) {
|
2005-08-20 11:11:59 +04:00
|
|
|
aState = TS_DISABLED;
|
2005-08-20 11:11:56 +04:00
|
|
|
return NS_OK;
|
2009-03-13 15:23:26 +03:00
|
|
|
} else if (IsOpenButton(aFrame) ||
|
|
|
|
IsCheckedButton(aFrame)) {
|
2008-07-12 13:15:07 +04:00
|
|
|
aState = TS_ACTIVE;
|
|
|
|
return NS_OK;
|
2005-08-20 11:11:56 +04:00
|
|
|
}
|
2008-02-29 08:10:12 +03:00
|
|
|
|
2011-10-02 06:16:19 +04:00
|
|
|
aState = StandardGetState(aFrame, aWidgetType, true);
|
2005-08-20 11:11:56 +04:00
|
|
|
|
2005-08-20 11:12:06 +04:00
|
|
|
// Check for default dialog buttons. These buttons should always look
|
|
|
|
// focused.
|
2005-08-20 11:13:56 +04:00
|
|
|
if (aState == TS_NORMAL && IsDefaultButton(aFrame))
|
2005-08-20 11:12:06 +04:00
|
|
|
aState = TS_FOCUSED;
|
2005-08-20 11:11:56 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
case NS_THEME_CHECKBOX:
|
2008-11-03 16:12:59 +03:00
|
|
|
case NS_THEME_RADIO: {
|
|
|
|
bool isCheckbox = (aWidgetType == NS_THEME_CHECKBOX);
|
2007-05-09 23:17:17 +04:00
|
|
|
aPart = isCheckbox ? BP_CHECKBOX : BP_RADIO;
|
2005-08-20 11:12:47 +04:00
|
|
|
|
2009-02-05 11:17:08 +03:00
|
|
|
enum InputState {
|
|
|
|
UNCHECKED = 0, CHECKED, INDETERMINATE
|
|
|
|
};
|
|
|
|
InputState inputState = UNCHECKED;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isXULCheckboxRadio = false;
|
2009-02-05 11:17:08 +03:00
|
|
|
|
|
|
|
if (!aFrame) {
|
2005-08-20 11:11:59 +04:00
|
|
|
aState = TS_NORMAL;
|
2009-02-05 11:17:08 +03:00
|
|
|
} else {
|
|
|
|
if (GetCheckedOrSelected(aFrame, !isCheckbox)) {
|
|
|
|
inputState = CHECKED;
|
2015-09-28 08:57:52 +03:00
|
|
|
} if (isCheckbox && GetIndeterminate(aFrame)) {
|
2009-02-05 11:17:08 +03:00
|
|
|
inputState = INDETERMINATE;
|
2005-08-20 11:12:47 +04:00
|
|
|
}
|
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates eventState =
|
|
|
|
GetContentState(isXULCheckboxRadio ? aFrame->GetParent() : aFrame,
|
|
|
|
aWidgetType);
|
2010-09-28 05:25:18 +04:00
|
|
|
if (IsDisabled(aFrame, eventState)) {
|
2005-08-20 11:12:08 +04:00
|
|
|
aState = TS_DISABLED;
|
2009-02-05 11:17:08 +03:00
|
|
|
} else {
|
2011-10-02 06:16:19 +04:00
|
|
|
aState = StandardGetState(aFrame, aWidgetType, false);
|
2005-08-20 11:12:08 +04:00
|
|
|
}
|
2005-08-20 11:11:56 +04:00
|
|
|
}
|
|
|
|
|
2009-02-05 11:17:08 +03:00
|
|
|
// 4 unchecked states, 4 checked states, 4 indeterminate states.
|
|
|
|
aState += inputState * 4;
|
2005-08-20 11:11:56 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2009-03-12 05:11:01 +03:00
|
|
|
case NS_THEME_GROUPBOX: {
|
|
|
|
aPart = BP_GROUPBOX;
|
|
|
|
aState = TS_NORMAL;
|
|
|
|
// Since we don't support groupbox disabled and GBS_DISABLED looks the
|
|
|
|
// same as GBS_NORMAL don't bother supporting GBS_DISABLED.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2013-12-09 03:23:28 +04:00
|
|
|
case NS_THEME_NUMBER_INPUT:
|
2005-08-20 11:12:07 +04:00
|
|
|
case NS_THEME_TEXTFIELD:
|
2008-02-29 08:10:12 +03:00
|
|
|
case NS_THEME_TEXTFIELD_MULTILINE: {
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates eventState = GetContentState(aFrame, aWidgetType);
|
2010-09-20 05:16:49 +04:00
|
|
|
|
2016-12-23 05:13:31 +03:00
|
|
|
/* Note: the NOSCROLL type has a rounded corner in each corner. The more
|
|
|
|
* specific HSCROLL, VSCROLL, HVSCROLL types have side and/or top/bottom
|
|
|
|
* edges rendered as straight horizontal lines with sharp corners to
|
|
|
|
* accommodate a scrollbar. However, the scrollbar gets rendered on top
|
|
|
|
* of this for us, so we don't care, and can just use NOSCROLL here.
|
|
|
|
*/
|
|
|
|
aPart = TFP_EDITBORDER_NOSCROLL;
|
2008-03-06 03:23:38 +03:00
|
|
|
|
2016-12-23 05:13:31 +03:00
|
|
|
if (!aFrame) {
|
|
|
|
aState = TFS_EDITBORDER_NORMAL;
|
|
|
|
} else if (IsDisabled(aFrame, eventState)) {
|
|
|
|
aState = TFS_EDITBORDER_DISABLED;
|
|
|
|
} else if (IsReadOnly(aFrame)) {
|
|
|
|
/* no special read-only state */
|
|
|
|
aState = TFS_EDITBORDER_NORMAL;
|
2008-03-06 03:23:38 +03:00
|
|
|
} else {
|
2016-12-23 05:13:31 +03:00
|
|
|
nsIContent* content = aFrame->GetContent();
|
|
|
|
|
|
|
|
/* XUL textboxes don't get focused themselves, because they have child
|
|
|
|
* html:input.. but we can check the XUL focused attributes on them
|
|
|
|
*/
|
|
|
|
if (content && content->IsXULElement() && IsFocused(aFrame))
|
|
|
|
aState = TFS_EDITBORDER_FOCUSED;
|
|
|
|
else if (eventState.HasAtLeastOneOfStates(NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_FOCUS))
|
|
|
|
aState = TFS_EDITBORDER_FOCUSED;
|
|
|
|
else if (eventState.HasState(NS_EVENT_STATE_HOVER))
|
|
|
|
aState = TFS_EDITBORDER_HOVER;
|
2008-03-06 03:23:38 +03:00
|
|
|
else
|
2016-12-23 05:13:31 +03:00
|
|
|
aState = TFS_EDITBORDER_NORMAL;
|
2005-08-20 11:12:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2014-06-14 16:48:08 +04:00
|
|
|
case NS_THEME_FOCUS_OUTLINE: {
|
2016-12-23 05:13:31 +03:00
|
|
|
// XXX the EDITBORDER values don't respect DTBG_OMITCONTENT
|
|
|
|
aPart = TFP_TEXTFIELD; //TFP_EDITBORDER_NOSCROLL;
|
|
|
|
aState = TS_FOCUSED; //TFS_EDITBORDER_FOCUSED;
|
2014-06-14 16:48:08 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2005-08-20 11:12:00 +04:00
|
|
|
case NS_THEME_TOOLTIP: {
|
|
|
|
aPart = TTP_STANDARD;
|
|
|
|
aState = TS_NORMAL;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2013-02-25 04:27:22 +04:00
|
|
|
case NS_THEME_PROGRESSBAR:
|
2013-02-25 04:16:16 +04:00
|
|
|
case NS_THEME_PROGRESSBAR_VERTICAL: {
|
2013-02-25 04:27:22 +04:00
|
|
|
// Note IsVerticalProgress only tests for orient css attrribute,
|
|
|
|
// NS_THEME_PROGRESSBAR_VERTICAL is dedicated to -moz-appearance:
|
|
|
|
// progressbar-vertical.
|
|
|
|
bool vertical = IsVerticalProgress(aFrame) ||
|
|
|
|
aWidgetType == NS_THEME_PROGRESSBAR_VERTICAL;
|
|
|
|
aPart = vertical ? PP_BARVERT : PP_BAR;
|
2013-02-25 04:16:16 +04:00
|
|
|
aState = PBBS_NORMAL;
|
2005-08-20 11:11:59 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_PROGRESSCHUNK:
|
|
|
|
case NS_THEME_PROGRESSCHUNK_VERTICAL: {
|
2013-02-25 04:27:22 +04:00
|
|
|
nsIFrame* parentFrame = aFrame->GetParent();
|
2016-05-18 20:29:56 +03:00
|
|
|
if (aWidgetType == NS_THEME_PROGRESSCHUNK_VERTICAL ||
|
2013-02-25 04:27:22 +04:00
|
|
|
IsVerticalProgress(parentFrame)) {
|
2016-12-23 05:13:31 +03:00
|
|
|
aPart = PP_FILLVERT;
|
2011-05-17 20:39:22 +04:00
|
|
|
} else {
|
2016-12-23 05:13:31 +03:00
|
|
|
aPart = PP_FILL;
|
2011-05-17 20:39:22 +04:00
|
|
|
}
|
|
|
|
|
2013-02-25 04:27:22 +04:00
|
|
|
aState = PBBVS_NORMAL;
|
2005-08-20 11:11:59 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_TOOLBARBUTTON: {
|
2005-08-20 11:11:59 +04:00
|
|
|
aPart = BP_BUTTON;
|
2005-08-20 11:11:56 +04:00
|
|
|
if (!aFrame) {
|
2005-08-20 11:11:59 +04:00
|
|
|
aState = TS_NORMAL;
|
2005-08-20 11:11:56 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates eventState = GetContentState(aFrame, aWidgetType);
|
2010-09-28 05:25:18 +04:00
|
|
|
if (IsDisabled(aFrame, eventState)) {
|
2005-08-20 11:11:59 +04:00
|
|
|
aState = TS_DISABLED;
|
2005-08-20 11:11:56 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2009-03-13 15:23:26 +03:00
|
|
|
if (IsOpenButton(aFrame)) {
|
|
|
|
aState = TS_ACTIVE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2010-09-20 05:16:49 +04:00
|
|
|
|
2010-10-20 15:26:32 +04:00
|
|
|
if (eventState.HasAllStates(NS_EVENT_STATE_HOVER | NS_EVENT_STATE_ACTIVE))
|
2005-08-20 11:11:59 +04:00
|
|
|
aState = TS_ACTIVE;
|
2010-10-20 15:26:32 +04:00
|
|
|
else if (eventState.HasState(NS_EVENT_STATE_HOVER)) {
|
2005-08-20 11:14:26 +04:00
|
|
|
if (IsCheckedButton(aFrame))
|
|
|
|
aState = TB_HOVER_CHECKED;
|
|
|
|
else
|
|
|
|
aState = TS_HOVER;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (IsCheckedButton(aFrame))
|
|
|
|
aState = TB_CHECKED;
|
|
|
|
else
|
|
|
|
aState = TS_NORMAL;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:56 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SEPARATOR: {
|
2007-08-26 00:30:43 +04:00
|
|
|
aPart = TP_SEPARATOR;
|
|
|
|
aState = TS_NORMAL;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SCROLLBARBUTTON_UP:
|
|
|
|
case NS_THEME_SCROLLBARBUTTON_DOWN:
|
|
|
|
case NS_THEME_SCROLLBARBUTTON_LEFT:
|
|
|
|
case NS_THEME_SCROLLBARBUTTON_RIGHT: {
|
2005-08-20 11:11:56 +04:00
|
|
|
aPart = SP_BUTTON;
|
2016-05-18 20:29:56 +03:00
|
|
|
aState = (aWidgetType - NS_THEME_SCROLLBARBUTTON_UP)*4;
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates eventState = GetContentState(aFrame, aWidgetType);
|
2005-08-20 11:11:56 +04:00
|
|
|
if (!aFrame)
|
2005-08-20 11:11:59 +04:00
|
|
|
aState += TS_NORMAL;
|
2010-09-28 05:25:18 +04:00
|
|
|
else if (IsDisabled(aFrame, eventState))
|
2005-08-20 11:11:59 +04:00
|
|
|
aState += TS_DISABLED;
|
2005-08-20 11:11:56 +04:00
|
|
|
else {
|
2007-08-18 00:47:33 +04:00
|
|
|
nsIFrame *parent = aFrame->GetParent();
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates parentState =
|
2017-05-21 12:15:00 +03:00
|
|
|
GetContentState(parent, parent->StyleDisplay()->mAppearance);
|
2010-10-20 15:26:32 +04:00
|
|
|
if (eventState.HasAllStates(NS_EVENT_STATE_HOVER | NS_EVENT_STATE_ACTIVE))
|
2005-08-20 11:11:59 +04:00
|
|
|
aState += TS_ACTIVE;
|
2010-10-20 15:26:32 +04:00
|
|
|
else if (eventState.HasState(NS_EVENT_STATE_HOVER))
|
2005-08-20 11:11:59 +04:00
|
|
|
aState += TS_HOVER;
|
2016-12-23 05:13:31 +03:00
|
|
|
else if (parentState.HasState(NS_EVENT_STATE_HOVER))
|
2016-05-18 20:29:56 +03:00
|
|
|
aState = (aWidgetType - NS_THEME_SCROLLBARBUTTON_UP) + SP_BUTTON_IMPLICIT_HOVER_BASE;
|
2005-08-20 11:13:11 +04:00
|
|
|
else
|
2005-08-20 11:11:59 +04:00
|
|
|
aState += TS_NORMAL;
|
2005-08-20 11:11:56 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2015-12-22 07:05:00 +03:00
|
|
|
case NS_THEME_SCROLLBAR_HORIZONTAL:
|
|
|
|
case NS_THEME_SCROLLBAR_VERTICAL: {
|
|
|
|
aPart = (aWidgetType == NS_THEME_SCROLLBAR_HORIZONTAL) ?
|
2005-08-20 11:11:57 +04:00
|
|
|
SP_TRACKSTARTHOR : SP_TRACKSTARTVERT;
|
2005-08-20 11:11:59 +04:00
|
|
|
aState = TS_NORMAL;
|
2005-08-20 11:11:56 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SCROLLBARTHUMB_HORIZONTAL:
|
|
|
|
case NS_THEME_SCROLLBARTHUMB_VERTICAL: {
|
|
|
|
aPart = (aWidgetType == NS_THEME_SCROLLBARTHUMB_HORIZONTAL) ?
|
2005-08-20 11:11:57 +04:00
|
|
|
SP_THUMBHOR : SP_THUMBVERT;
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates eventState = GetContentState(aFrame, aWidgetType);
|
2005-08-20 11:11:56 +04:00
|
|
|
if (!aFrame)
|
2005-08-20 11:11:59 +04:00
|
|
|
aState = TS_NORMAL;
|
2010-09-28 05:25:18 +04:00
|
|
|
else if (IsDisabled(aFrame, eventState))
|
2005-08-20 11:11:59 +04:00
|
|
|
aState = TS_DISABLED;
|
2005-08-20 11:11:56 +04:00
|
|
|
else {
|
2010-10-20 15:26:32 +04:00
|
|
|
if (eventState.HasState(NS_EVENT_STATE_ACTIVE)) // Hover is not also a requirement for
|
|
|
|
// the thumb, since the drag is not canceled
|
|
|
|
// when you move outside the thumb.
|
2005-08-20 11:11:59 +04:00
|
|
|
aState = TS_ACTIVE;
|
2010-10-20 15:26:32 +04:00
|
|
|
else if (eventState.HasState(NS_EVENT_STATE_HOVER))
|
2005-08-20 11:11:59 +04:00
|
|
|
aState = TS_HOVER;
|
2005-08-20 11:11:56 +04:00
|
|
|
else
|
2005-08-20 11:11:59 +04:00
|
|
|
aState = TS_NORMAL;
|
2005-08-20 11:11:56 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2013-04-03 14:07:12 +04:00
|
|
|
case NS_THEME_RANGE:
|
2006-05-30 17:50:48 +04:00
|
|
|
case NS_THEME_SCALE_HORIZONTAL:
|
|
|
|
case NS_THEME_SCALE_VERTICAL: {
|
2013-04-03 14:07:12 +04:00
|
|
|
if (aWidgetType == NS_THEME_SCALE_HORIZONTAL ||
|
|
|
|
(aWidgetType == NS_THEME_RANGE &&
|
|
|
|
IsRangeHorizontal(aFrame))) {
|
|
|
|
aPart = TKP_TRACK;
|
|
|
|
aState = TRS_NORMAL;
|
|
|
|
} else {
|
|
|
|
aPart = TKP_TRACKVERT;
|
|
|
|
aState = TRVS_NORMAL;
|
|
|
|
}
|
2006-05-30 17:50:48 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2013-04-03 14:07:12 +04:00
|
|
|
case NS_THEME_RANGE_THUMB:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SCALETHUMB_HORIZONTAL:
|
|
|
|
case NS_THEME_SCALETHUMB_VERTICAL: {
|
2013-04-03 14:07:12 +04:00
|
|
|
if (aWidgetType == NS_THEME_RANGE_THUMB) {
|
|
|
|
if (IsRangeHorizontal(aFrame)) {
|
|
|
|
aPart = TKP_THUMBBOTTOM;
|
|
|
|
} else {
|
|
|
|
aPart = IsFrameRTL(aFrame) ? TKP_THUMBLEFT : TKP_THUMBRIGHT;
|
|
|
|
}
|
|
|
|
} else {
|
2016-05-18 20:29:56 +03:00
|
|
|
aPart = (aWidgetType == NS_THEME_SCALETHUMB_HORIZONTAL) ?
|
2013-04-03 14:07:12 +04:00
|
|
|
TKP_THUMB : TKP_THUMBVERT;
|
|
|
|
}
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates eventState = GetContentState(aFrame, aWidgetType);
|
2006-05-30 17:50:48 +04:00
|
|
|
if (!aFrame)
|
|
|
|
aState = TS_NORMAL;
|
2010-09-28 05:25:18 +04:00
|
|
|
else if (IsDisabled(aFrame, eventState)) {
|
2006-05-30 17:50:48 +04:00
|
|
|
aState = TKP_DISABLED;
|
|
|
|
}
|
|
|
|
else {
|
2010-10-20 15:26:32 +04:00
|
|
|
if (eventState.HasState(NS_EVENT_STATE_ACTIVE)) // Hover is not also a requirement for
|
|
|
|
// the thumb, since the drag is not canceled
|
|
|
|
// when you move outside the thumb.
|
2006-05-30 17:50:48 +04:00
|
|
|
aState = TS_ACTIVE;
|
2010-10-20 15:26:32 +04:00
|
|
|
else if (eventState.HasState(NS_EVENT_STATE_FOCUS))
|
2006-05-30 17:50:48 +04:00
|
|
|
aState = TKP_FOCUSED;
|
2010-10-20 15:26:32 +04:00
|
|
|
else if (eventState.HasState(NS_EVENT_STATE_HOVER))
|
2006-05-30 17:50:48 +04:00
|
|
|
aState = TS_HOVER;
|
|
|
|
else
|
|
|
|
aState = TS_NORMAL;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2017-11-29 05:43:13 +03:00
|
|
|
case NS_THEME_INNER_SPIN_BUTTON:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SPINNER_UPBUTTON:
|
|
|
|
case NS_THEME_SPINNER_DOWNBUTTON: {
|
|
|
|
aPart = (aWidgetType == NS_THEME_SPINNER_UPBUTTON) ?
|
2006-07-13 21:40:49 +04:00
|
|
|
SPNP_UP : SPNP_DOWN;
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates eventState = GetContentState(aFrame, aWidgetType);
|
2006-07-13 21:40:49 +04:00
|
|
|
if (!aFrame)
|
|
|
|
aState = TS_NORMAL;
|
2010-09-28 05:25:18 +04:00
|
|
|
else if (IsDisabled(aFrame, eventState))
|
2006-07-13 21:40:49 +04:00
|
|
|
aState = TS_DISABLED;
|
2008-02-29 08:10:12 +03:00
|
|
|
else
|
2011-10-02 06:16:19 +04:00
|
|
|
aState = StandardGetState(aFrame, aWidgetType, false);
|
2006-07-13 21:40:49 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2005-08-20 11:11:56 +04:00
|
|
|
case NS_THEME_TOOLBOX:
|
2008-05-08 13:29:38 +04:00
|
|
|
case NS_THEME_WIN_MEDIA_TOOLBOX:
|
|
|
|
case NS_THEME_WIN_COMMUNICATIONS_TOOLBOX:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_WIN_BROWSERTABBAR_TOOLBOX:
|
2005-08-20 11:11:57 +04:00
|
|
|
case NS_THEME_STATUSBAR:
|
2007-07-14 01:46:28 +04:00
|
|
|
case NS_THEME_SCROLLBAR:
|
|
|
|
case NS_THEME_SCROLLBAR_SMALL: {
|
2008-02-29 08:10:38 +03:00
|
|
|
aState = 0;
|
2016-12-23 05:13:31 +03:00
|
|
|
aPart = RP_BACKGROUND;
|
2008-02-29 08:10:38 +03:00
|
|
|
return NS_OK;
|
2005-08-20 11:11:56 +04:00
|
|
|
}
|
2005-10-07 04:31:36 +04:00
|
|
|
case NS_THEME_TOOLBAR: {
|
|
|
|
// Use -1 to indicate we don't wish to have the theme background drawn
|
|
|
|
// for this item. We will pass any nessessary information via aState,
|
|
|
|
// and will render the item using separate code.
|
|
|
|
aPart = -1;
|
|
|
|
aState = 0;
|
|
|
|
if (aFrame) {
|
|
|
|
nsIContent* content = aFrame->GetContent();
|
|
|
|
nsIContent* parent = content->GetParent();
|
2007-07-14 19:11:37 +04:00
|
|
|
// XXXzeniko hiding the first toolbar will result in an unwanted margin
|
2012-01-25 11:50:07 +04:00
|
|
|
if (parent && parent->GetFirstChild() == content) {
|
2005-10-07 04:31:36 +04:00
|
|
|
aState = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_STATUSBARPANEL:
|
2016-05-19 11:58:00 +03:00
|
|
|
case NS_THEME_RESIZERPANEL:
|
2005-08-20 11:11:57 +04:00
|
|
|
case NS_THEME_RESIZER: {
|
2016-05-18 20:29:56 +03:00
|
|
|
aPart = (aWidgetType - NS_THEME_STATUSBARPANEL) + 1;
|
2005-08-20 11:11:59 +04:00
|
|
|
aState = TS_NORMAL;
|
2005-08-20 11:11:57 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2005-08-20 11:12:55 +04:00
|
|
|
case NS_THEME_TREEVIEW:
|
|
|
|
case NS_THEME_LISTBOX: {
|
|
|
|
aPart = TREEVIEW_BODY;
|
|
|
|
aState = TS_NORMAL;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_TABPANELS: {
|
2005-08-20 11:12:02 +04:00
|
|
|
aPart = TABP_PANELS;
|
|
|
|
aState = TS_NORMAL;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_TABPANEL: {
|
2005-08-20 11:12:02 +04:00
|
|
|
aPart = TABP_PANEL;
|
|
|
|
aState = TS_NORMAL;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2009-01-04 17:01:48 +03:00
|
|
|
case NS_THEME_TAB: {
|
2005-08-20 11:11:56 +04:00
|
|
|
aPart = TABP_TAB;
|
|
|
|
if (!aFrame) {
|
2005-08-20 11:11:59 +04:00
|
|
|
aState = TS_NORMAL;
|
2005-08-20 11:11:56 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2010-09-20 05:16:49 +04:00
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates eventState = GetContentState(aFrame, aWidgetType);
|
2010-09-28 05:25:18 +04:00
|
|
|
if (IsDisabled(aFrame, eventState)) {
|
2005-08-20 11:11:59 +04:00
|
|
|
aState = TS_DISABLED;
|
2005-08-20 11:11:56 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:13:56 +04:00
|
|
|
if (IsSelectedTab(aFrame)) {
|
2005-08-20 11:11:56 +04:00
|
|
|
aPart = TABP_TAB_SELECTED;
|
2005-08-20 11:11:59 +04:00
|
|
|
aState = TS_ACTIVE; // The selected tab is always "pressed".
|
2005-08-20 11:11:56 +04:00
|
|
|
}
|
2008-02-29 08:10:12 +03:00
|
|
|
else
|
2011-10-02 06:16:19 +04:00
|
|
|
aState = StandardGetState(aFrame, aWidgetType, true);
|
2005-08-20 11:11:56 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_TREEHEADERSORTARROW: {
|
2005-08-20 11:13:09 +04:00
|
|
|
// XXX Probably will never work due to a bug in the Luna theme.
|
|
|
|
aPart = 4;
|
|
|
|
aState = 1;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_TREEHEADERCELL: {
|
2005-08-20 11:13:09 +04:00
|
|
|
aPart = 1;
|
|
|
|
if (!aFrame) {
|
|
|
|
aState = TS_NORMAL;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-10-02 06:16:19 +04:00
|
|
|
aState = StandardGetState(aFrame, aWidgetType, true);
|
2008-02-29 08:10:12 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_MENULIST: {
|
2008-02-29 08:10:12 +03:00
|
|
|
nsIContent* content = aFrame->GetContent();
|
2015-03-03 14:08:59 +03:00
|
|
|
bool isHTML = content && content->IsHTMLElement();
|
2017-01-12 02:58:15 +03:00
|
|
|
bool isChrome = aFrame->GetContent()->IsInChromeDocument();
|
|
|
|
bool useDropBorder = isHTML || (isChrome && IsMenuListEditable(aFrame));
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates eventState = GetContentState(aFrame, aWidgetType);
|
2008-03-06 03:23:38 +03:00
|
|
|
|
2011-07-01 14:20:45 +04:00
|
|
|
/* On Vista/Win7, we use CBP_DROPBORDER instead of DROPFRAME for HTML
|
|
|
|
* content or for editable menulists; this gives us the thin outline,
|
|
|
|
* instead of the gradient-filled background */
|
|
|
|
if (useDropBorder)
|
2008-02-29 08:10:12 +03:00
|
|
|
aPart = CBP_DROPBORDER;
|
|
|
|
else
|
|
|
|
aPart = CBP_DROPFRAME;
|
|
|
|
|
2010-09-28 05:25:18 +04:00
|
|
|
if (IsDisabled(aFrame, eventState)) {
|
2008-03-12 03:54:51 +03:00
|
|
|
aState = TS_DISABLED;
|
|
|
|
} else if (IsReadOnly(aFrame)) {
|
|
|
|
aState = TS_NORMAL;
|
2009-03-13 15:23:26 +03:00
|
|
|
} else if (IsOpenButton(aFrame)) {
|
2008-02-29 08:10:12 +03:00
|
|
|
aState = TS_ACTIVE;
|
2008-03-06 03:23:38 +03:00
|
|
|
} else {
|
2011-07-01 14:20:45 +04:00
|
|
|
if (useDropBorder && (eventState.HasState(NS_EVENT_STATE_FOCUS) || IsFocused(aFrame)))
|
2008-03-06 03:23:38 +03:00
|
|
|
aState = TS_ACTIVE;
|
2010-10-20 15:26:32 +04:00
|
|
|
else if (eventState.HasAllStates(NS_EVENT_STATE_HOVER | NS_EVENT_STATE_ACTIVE))
|
2008-03-06 03:23:38 +03:00
|
|
|
aState = TS_ACTIVE;
|
2010-10-20 15:26:32 +04:00
|
|
|
else if (eventState.HasState(NS_EVENT_STATE_HOVER))
|
2008-03-06 03:23:38 +03:00
|
|
|
aState = TS_HOVER;
|
|
|
|
else
|
|
|
|
aState = TS_NORMAL;
|
2008-02-29 08:10:12 +03:00
|
|
|
}
|
|
|
|
|
2005-08-20 11:13:09 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_MENULIST_BUTTON: {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isHTML = IsHTMLContent(aFrame);
|
2005-08-20 11:13:33 +04:00
|
|
|
nsIFrame* parentFrame = aFrame->GetParent();
|
2017-04-30 18:30:08 +03:00
|
|
|
bool isMenulist = !isHTML && parentFrame->IsMenuFrame();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isOpen = false;
|
2009-03-13 15:23:26 +03:00
|
|
|
|
|
|
|
// HTML select and XUL menulist dropdown buttons get state from the parent.
|
|
|
|
if (isHTML || isMenulist)
|
2008-02-29 08:10:12 +03:00
|
|
|
aFrame = parentFrame;
|
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates eventState = GetContentState(aFrame, aWidgetType);
|
2016-12-23 05:13:31 +03:00
|
|
|
aPart = CBP_DROPMARKER_VISTA;
|
2008-03-06 03:23:38 +03:00
|
|
|
|
2008-07-12 13:08:23 +04:00
|
|
|
// For HTML controls with author styling, we should fall
|
|
|
|
// back to the old dropmarker style to avoid clashes with
|
|
|
|
// author-specified backgrounds and borders (bug #441034)
|
2016-05-18 20:29:56 +03:00
|
|
|
if (isHTML && IsWidgetStyled(aFrame->PresContext(), aFrame, NS_THEME_MENULIST))
|
2008-07-12 13:08:23 +04:00
|
|
|
aPart = CBP_DROPMARKER;
|
|
|
|
|
2010-09-28 05:25:18 +04:00
|
|
|
if (IsDisabled(aFrame, eventState)) {
|
2008-03-06 03:23:38 +03:00
|
|
|
aState = TS_DISABLED;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2009-03-13 15:23:26 +03:00
|
|
|
if (isHTML) {
|
|
|
|
nsIComboboxControlFrame* ccf = do_QueryFrame(aFrame);
|
2016-08-08 15:42:54 +03:00
|
|
|
isOpen = (ccf && ccf->IsDroppedDownOrHasParentPopup());
|
2009-03-13 15:23:26 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
isOpen = IsOpenButton(aFrame);
|
|
|
|
|
2017-01-12 02:58:15 +03:00
|
|
|
bool isChrome = aFrame->GetContent()->IsInChromeDocument();
|
|
|
|
if (isHTML || (isChrome && IsMenuListEditable(aFrame))) {
|
2016-12-23 05:13:31 +03:00
|
|
|
if (isOpen) {
|
|
|
|
/* Hover is propagated, but we need to know whether we're hovering
|
|
|
|
* just the combobox frame, not the dropdown frame. But, we can't get
|
|
|
|
* that information, since hover is on the content node, and they
|
|
|
|
* share the same content node. So, instead, we cheat -- if the
|
|
|
|
* dropdown is open, we always show the hover state. This looks fine
|
|
|
|
* in practice.
|
2008-04-24 01:01:16 +04:00
|
|
|
*/
|
2016-12-23 05:13:31 +03:00
|
|
|
aState = TS_HOVER;
|
2009-03-13 15:23:26 +03:00
|
|
|
return NS_OK;
|
2008-03-06 03:23:38 +03:00
|
|
|
}
|
2016-12-23 05:13:31 +03:00
|
|
|
} else {
|
|
|
|
/* The dropdown indicator on a menulist button in chrome is not given a
|
|
|
|
* hover effect. When the frame isn't isn't HTML content, we cheat and
|
|
|
|
* force the dropdown state to be normal. (Bug 430434)
|
|
|
|
*/
|
|
|
|
aState = TS_NORMAL;
|
|
|
|
return NS_OK;
|
2005-08-20 11:12:07 +04:00
|
|
|
}
|
2008-03-06 03:23:38 +03:00
|
|
|
|
2009-03-13 15:23:26 +03:00
|
|
|
aState = TS_NORMAL;
|
|
|
|
|
|
|
|
// Dropdown button active state doesn't need :hover.
|
2010-10-20 15:26:32 +04:00
|
|
|
if (eventState.HasState(NS_EVENT_STATE_ACTIVE)) {
|
2009-03-13 15:23:26 +03:00
|
|
|
if (isOpen && (isHTML || isMenulist)) {
|
|
|
|
// XXX Button should look active until the mouse is released, but
|
|
|
|
// without making it look active when the popup is clicked.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
aState = TS_ACTIVE;
|
|
|
|
}
|
2010-10-20 15:26:32 +04:00
|
|
|
else if (eventState.HasState(NS_EVENT_STATE_HOVER)) {
|
2009-03-13 15:23:26 +03:00
|
|
|
// No hover effect for XUL menulists and autocomplete dropdown buttons
|
|
|
|
// while the dropdown menu is open.
|
|
|
|
if (isOpen) {
|
|
|
|
// XXX HTML select dropdown buttons should have the hover effect when
|
|
|
|
// hovering the combobox frame, but not the popup frame.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
aState = TS_HOVER;
|
|
|
|
}
|
2005-08-20 11:12:07 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2007-08-06 21:45:57 +04:00
|
|
|
case NS_THEME_MENUPOPUP: {
|
|
|
|
aPart = MENU_POPUPBACKGROUND;
|
|
|
|
aState = MB_ACTIVE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
case NS_THEME_MENUITEM:
|
|
|
|
case NS_THEME_CHECKMENUITEM:
|
|
|
|
case NS_THEME_RADIOMENUITEM: {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isTopLevel = false;
|
|
|
|
bool isOpen = false;
|
|
|
|
bool isHover = false;
|
2011-07-11 18:05:07 +04:00
|
|
|
nsMenuFrame *menuFrame = do_QueryFrame(aFrame);
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates eventState = GetContentState(aFrame, aWidgetType);
|
2007-08-06 21:45:57 +04:00
|
|
|
|
|
|
|
isTopLevel = IsTopLevelMenu(aFrame);
|
|
|
|
|
|
|
|
if (menuFrame)
|
|
|
|
isOpen = menuFrame->IsOpen();
|
2008-02-29 08:10:12 +03:00
|
|
|
|
2008-03-06 23:56:47 +03:00
|
|
|
isHover = IsMenuActive(aFrame, aWidgetType);
|
2007-08-06 21:45:57 +04:00
|
|
|
|
|
|
|
if (isTopLevel) {
|
|
|
|
aPart = MENU_BARITEM;
|
|
|
|
|
|
|
|
if (isOpen)
|
|
|
|
aState = MBI_PUSHED;
|
|
|
|
else if (isHover)
|
|
|
|
aState = MBI_HOT;
|
|
|
|
else
|
|
|
|
aState = MBI_NORMAL;
|
|
|
|
|
|
|
|
// the disabled states are offset by 3
|
2010-09-28 05:25:18 +04:00
|
|
|
if (IsDisabled(aFrame, eventState))
|
2007-08-06 21:45:57 +04:00
|
|
|
aState += 3;
|
|
|
|
} else {
|
|
|
|
aPart = MENU_POPUPITEM;
|
|
|
|
|
|
|
|
if (isHover)
|
|
|
|
aState = MPI_HOT;
|
|
|
|
else
|
|
|
|
aState = MPI_NORMAL;
|
|
|
|
|
|
|
|
// the disabled states are offset by 2
|
2010-09-28 05:25:18 +04:00
|
|
|
if (IsDisabled(aFrame, eventState))
|
2007-08-06 21:45:57 +04:00
|
|
|
aState += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
case NS_THEME_MENUSEPARATOR:
|
|
|
|
aPart = MENU_POPUPSEPARATOR;
|
|
|
|
aState = 0;
|
|
|
|
return NS_OK;
|
|
|
|
case NS_THEME_MENUARROW:
|
2010-09-20 05:16:49 +04:00
|
|
|
{
|
|
|
|
aPart = MENU_POPUPSUBMENU;
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates eventState = GetContentState(aFrame, aWidgetType);
|
2010-09-28 05:25:18 +04:00
|
|
|
aState = IsDisabled(aFrame, eventState) ? MSM_DISABLED : MSM_NORMAL;
|
2010-09-20 05:16:49 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2007-08-06 21:45:57 +04:00
|
|
|
case NS_THEME_MENUCHECKBOX:
|
|
|
|
case NS_THEME_MENURADIO:
|
|
|
|
{
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates eventState = GetContentState(aFrame, aWidgetType);
|
2007-08-06 21:45:57 +04:00
|
|
|
|
|
|
|
aPart = MENU_POPUPCHECK;
|
|
|
|
aState = MC_CHECKMARKNORMAL;
|
|
|
|
|
|
|
|
// Radio states are offset by 2
|
|
|
|
if (aWidgetType == NS_THEME_MENURADIO)
|
|
|
|
aState += 2;
|
|
|
|
|
|
|
|
// the disabled states are offset by 1
|
2010-09-28 05:25:18 +04:00
|
|
|
if (IsDisabled(aFrame, eventState))
|
2007-08-06 21:45:57 +04:00
|
|
|
aState += 1;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
case NS_THEME_MENUITEMTEXT:
|
|
|
|
case NS_THEME_MENUIMAGE:
|
|
|
|
aPart = -1;
|
|
|
|
aState = 0;
|
|
|
|
return NS_OK;
|
2010-08-10 05:49:35 +04:00
|
|
|
|
|
|
|
case NS_THEME_WINDOW_TITLEBAR:
|
|
|
|
aPart = mozilla::widget::themeconst::WP_CAPTION;
|
|
|
|
aState = GetTopLevelWindowActiveState(aFrame);
|
|
|
|
return NS_OK;
|
|
|
|
case NS_THEME_WINDOW_TITLEBAR_MAXIMIZED:
|
|
|
|
aPart = mozilla::widget::themeconst::WP_MAXCAPTION;
|
|
|
|
aState = GetTopLevelWindowActiveState(aFrame);
|
|
|
|
return NS_OK;
|
|
|
|
case NS_THEME_WINDOW_FRAME_LEFT:
|
|
|
|
aPart = mozilla::widget::themeconst::WP_FRAMELEFT;
|
|
|
|
aState = GetTopLevelWindowActiveState(aFrame);
|
|
|
|
return NS_OK;
|
|
|
|
case NS_THEME_WINDOW_FRAME_RIGHT:
|
|
|
|
aPart = mozilla::widget::themeconst::WP_FRAMERIGHT;
|
|
|
|
aState = GetTopLevelWindowActiveState(aFrame);
|
|
|
|
return NS_OK;
|
|
|
|
case NS_THEME_WINDOW_FRAME_BOTTOM:
|
|
|
|
aPart = mozilla::widget::themeconst::WP_FRAMEBOTTOM;
|
|
|
|
aState = GetTopLevelWindowActiveState(aFrame);
|
|
|
|
return NS_OK;
|
|
|
|
case NS_THEME_WINDOW_BUTTON_CLOSE:
|
|
|
|
aPart = mozilla::widget::themeconst::WP_CLOSEBUTTON;
|
|
|
|
aState = GetWindowFrameButtonState(aFrame, GetContentState(aFrame, aWidgetType));
|
|
|
|
return NS_OK;
|
|
|
|
case NS_THEME_WINDOW_BUTTON_MINIMIZE:
|
|
|
|
aPart = mozilla::widget::themeconst::WP_MINBUTTON;
|
|
|
|
aState = GetWindowFrameButtonState(aFrame, GetContentState(aFrame, aWidgetType));
|
|
|
|
return NS_OK;
|
|
|
|
case NS_THEME_WINDOW_BUTTON_MAXIMIZE:
|
|
|
|
aPart = mozilla::widget::themeconst::WP_MAXBUTTON;
|
|
|
|
aState = GetWindowFrameButtonState(aFrame, GetContentState(aFrame, aWidgetType));
|
|
|
|
return NS_OK;
|
|
|
|
case NS_THEME_WINDOW_BUTTON_RESTORE:
|
|
|
|
aPart = mozilla::widget::themeconst::WP_RESTOREBUTTON;
|
|
|
|
aState = GetWindowFrameButtonState(aFrame, GetContentState(aFrame, aWidgetType));
|
|
|
|
return NS_OK;
|
2010-08-10 05:49:35 +04:00
|
|
|
case NS_THEME_WINDOW_BUTTON_BOX:
|
|
|
|
case NS_THEME_WINDOW_BUTTON_BOX_MAXIMIZED:
|
2010-10-19 21:02:25 +04:00
|
|
|
case NS_THEME_WIN_GLASS:
|
|
|
|
case NS_THEME_WIN_BORDERLESS_GLASS:
|
2010-08-10 05:49:35 +04:00
|
|
|
aPart = -1;
|
|
|
|
aState = 0;
|
|
|
|
return NS_OK;
|
2005-08-20 11:11:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
aPart = 0;
|
|
|
|
aState = 0;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2013-01-07 15:06:11 +04:00
|
|
|
static bool
|
|
|
|
AssumeThemePartAndStateAreTransparent(int32_t aPart, int32_t aState)
|
|
|
|
{
|
2017-09-22 13:07:15 +03:00
|
|
|
if (!(IsWin8Point1OrLater() && nsUXThemeData::IsHighContrastOn()) &&
|
|
|
|
aPart == MENU_POPUPITEM && aState == MBI_NORMAL) {
|
2013-01-07 15:06:11 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-12-02 23:54:26 +03:00
|
|
|
// When running with per-monitor DPI (on Win8.1+), and rendering on a display
|
2016-01-28 18:08:33 +03:00
|
|
|
// with a different DPI setting from the system's default scaling, we need to
|
2015-12-02 23:54:26 +03:00
|
|
|
// apply scaling to native-themed elements as the Windows theme APIs assume
|
2016-01-28 18:08:33 +03:00
|
|
|
// the system default resolution.
|
2016-01-18 16:28:26 +03:00
|
|
|
static inline double
|
2015-12-02 23:54:26 +03:00
|
|
|
GetThemeDpiScaleFactor(nsIFrame* aFrame)
|
|
|
|
{
|
2017-04-09 04:00:08 +03:00
|
|
|
if (WinUtils::IsPerMonitorDPIAware() ||
|
|
|
|
nsIWidget::DefaultScaleOverride() > 0.0) {
|
2016-01-18 16:28:26 +03:00
|
|
|
nsIWidget* rootWidget = aFrame->PresContext()->GetRootWidget();
|
|
|
|
if (rootWidget) {
|
2016-01-28 18:08:33 +03:00
|
|
|
double systemScale = WinUtils::SystemScaleFactor();
|
|
|
|
return rootWidget->GetDefaultScale().scale / systemScale;
|
2016-01-18 16:28:26 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1.0;
|
2015-12-02 23:54:26 +03:00
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:56 +04:00
|
|
|
NS_IMETHODIMP
|
2017-06-09 22:14:53 +03:00
|
|
|
nsNativeThemeWin::DrawWidgetBackground(gfxContext* aContext,
|
2005-08-20 11:11:56 +04:00
|
|
|
nsIFrame* aFrame,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t aWidgetType,
|
2005-08-20 11:11:56 +04:00
|
|
|
const nsRect& aRect,
|
2014-03-17 12:42:48 +04:00
|
|
|
const nsRect& aDirtyRect)
|
2005-08-20 11:11:56 +04:00
|
|
|
{
|
|
|
|
HANDLE theme = GetTheme(aWidgetType);
|
|
|
|
if (!theme)
|
2008-07-25 03:01:59 +04:00
|
|
|
return ClassicDrawWidgetBackground(aContext, aFrame, aWidgetType, aRect, aDirtyRect);
|
2005-08-20 11:13:11 +04:00
|
|
|
|
2010-10-19 21:02:25 +04:00
|
|
|
// ^^ without the right sdk, assume xp theming and fall through.
|
|
|
|
if (nsUXThemeData::CheckForCompositor()) {
|
|
|
|
switch (aWidgetType) {
|
|
|
|
case NS_THEME_WINDOW_TITLEBAR:
|
|
|
|
case NS_THEME_WINDOW_TITLEBAR_MAXIMIZED:
|
|
|
|
case NS_THEME_WINDOW_FRAME_LEFT:
|
|
|
|
case NS_THEME_WINDOW_FRAME_RIGHT:
|
|
|
|
case NS_THEME_WINDOW_FRAME_BOTTOM:
|
|
|
|
// Nothing to draw, these areas are glass. Minimum dimensions
|
|
|
|
// should be set, so xul content should be layed out correctly.
|
|
|
|
return NS_OK;
|
|
|
|
break;
|
|
|
|
case NS_THEME_WINDOW_BUTTON_CLOSE:
|
|
|
|
case NS_THEME_WINDOW_BUTTON_MINIMIZE:
|
|
|
|
case NS_THEME_WINDOW_BUTTON_MAXIMIZE:
|
|
|
|
case NS_THEME_WINDOW_BUTTON_RESTORE:
|
|
|
|
// Not conventional bitmaps, can't be retrieved. If we fall
|
|
|
|
// through here and call the theme library we'll get aero
|
|
|
|
// basic bitmaps.
|
|
|
|
return NS_OK;
|
|
|
|
break;
|
|
|
|
case NS_THEME_WIN_GLASS:
|
|
|
|
case NS_THEME_WIN_BORDERLESS_GLASS:
|
|
|
|
// Nothing to draw, this is the glass background.
|
|
|
|
return NS_OK;
|
2014-03-17 12:42:48 +04:00
|
|
|
case NS_THEME_WINDOW_BUTTON_BOX:
|
|
|
|
case NS_THEME_WINDOW_BUTTON_BOX_MAXIMIZED:
|
|
|
|
// We handle these through nsIWidget::UpdateThemeGeometries
|
|
|
|
return NS_OK;
|
2010-10-19 21:02:25 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t part, state;
|
2005-08-20 11:11:56 +04:00
|
|
|
nsresult rv = GetThemePartAndState(aFrame, aWidgetType, part, state);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
2013-01-07 15:06:11 +04:00
|
|
|
if (AssumeThemePartAndStateAreTransparent(part, state)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-06-09 22:14:53 +03:00
|
|
|
RefPtr<gfxContext> ctx = aContext;
|
2015-12-02 23:54:26 +03:00
|
|
|
gfxContextMatrixAutoSaveRestore save(ctx);
|
|
|
|
|
|
|
|
double themeScale = GetThemeDpiScaleFactor(aFrame);
|
|
|
|
if (themeScale != 1.0) {
|
2017-07-05 18:18:49 +03:00
|
|
|
ctx->SetMatrix(ctx->CurrentMatrix().PreScale(themeScale, themeScale));
|
2015-12-02 23:54:26 +03:00
|
|
|
}
|
|
|
|
|
2014-06-20 10:42:30 +04:00
|
|
|
gfxFloat p2a = gfxFloat(aFrame->PresContext()->AppUnitsPerDevPixel());
|
2005-08-20 11:11:56 +04:00
|
|
|
RECT widgetRect;
|
|
|
|
RECT clipRect;
|
2018-01-10 19:14:16 +03:00
|
|
|
gfxRect tr(aRect.X(), aRect.Y(), aRect.Width(), aRect.Height()),
|
|
|
|
dr(aDirtyRect.X(), aDirtyRect.Y(), aDirtyRect.Width(), aDirtyRect.Height());
|
2006-02-09 04:24:30 +03:00
|
|
|
|
2017-07-05 18:22:00 +03:00
|
|
|
tr.Scale(1.0 / (p2a * themeScale));
|
|
|
|
dr.Scale(1.0 / (p2a * themeScale));
|
2006-02-09 04:24:30 +03:00
|
|
|
|
2008-07-25 03:01:59 +04:00
|
|
|
gfxWindowsNativeDrawing nativeDrawing(ctx, dr, GetWidgetNativeDrawingFlags(aWidgetType));
|
2006-02-09 04:24:30 +03:00
|
|
|
|
2007-03-03 03:18:34 +03:00
|
|
|
RENDER_AGAIN:
|
2006-02-09 04:24:30 +03:00
|
|
|
|
2007-03-03 03:18:34 +03:00
|
|
|
HDC hdc = nativeDrawing.BeginNativeDrawing();
|
2007-08-09 22:54:17 +04:00
|
|
|
if (!hdc)
|
|
|
|
return NS_ERROR_FAILURE;
|
2006-02-09 04:24:30 +03:00
|
|
|
|
2007-03-03 03:18:34 +03:00
|
|
|
nativeDrawing.TransformToNativeRect(tr, widgetRect);
|
2008-07-25 03:01:59 +04:00
|
|
|
nativeDrawing.TransformToNativeRect(dr, clipRect);
|
2005-10-06 08:02:10 +04:00
|
|
|
|
2006-06-06 03:16:25 +04:00
|
|
|
#if 0
|
2007-03-03 03:18:34 +03:00
|
|
|
{
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(gWindowsLog, LogLevel::Error,
|
2014-06-17 21:35:51 +04:00
|
|
|
(stderr, "xform: %f %f %f %f [%f %f]\n", m._11, m._21, m._12, m._22,
|
|
|
|
m._31, m._32));
|
2015-06-04 01:25:57 +03:00
|
|
|
MOZ_LOG(gWindowsLog, LogLevel::Error,
|
2011-08-16 23:30:44 +04:00
|
|
|
(stderr, "tr: [%d %d %d %d]\ndr: [%d %d %d %d]\noff: [%f %f]\n",
|
|
|
|
tr.x, tr.y, tr.width, tr.height, dr.x, dr.y, dr.width, dr.height,
|
|
|
|
offset.x, offset.y));
|
2007-03-03 03:18:34 +03:00
|
|
|
}
|
2006-06-06 03:16:25 +04:00
|
|
|
#endif
|
|
|
|
|
2010-11-29 19:19:17 +03:00
|
|
|
if (aWidgetType == NS_THEME_WINDOW_TITLEBAR) {
|
|
|
|
// Clip out the left and right corners of the frame, all we want in
|
|
|
|
// is the middle section.
|
|
|
|
widgetRect.left -= GetSystemMetrics(SM_CXFRAME);
|
|
|
|
widgetRect.right += GetSystemMetrics(SM_CXFRAME);
|
|
|
|
} else if (aWidgetType == NS_THEME_WINDOW_TITLEBAR_MAXIMIZED) {
|
|
|
|
// The origin of the window is off screen when maximized and windows
|
|
|
|
// doesn't compensate for this in rendering the background. Push the
|
|
|
|
// top of the bitmap down by SM_CYFRAME so we get the full graphic.
|
|
|
|
widgetRect.top += GetSystemMetrics(SM_CYFRAME);
|
|
|
|
} else if (aWidgetType == NS_THEME_TAB) {
|
|
|
|
// For left edge and right edge tabs, we need to adjust the widget
|
|
|
|
// rects and clip rects so that the edges don't get drawn.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isLeft = IsLeftToSelectedTab(aFrame);
|
|
|
|
bool isRight = !isLeft && IsRightToSelectedTab(aFrame);
|
2009-01-04 17:01:48 +03:00
|
|
|
|
|
|
|
if (isLeft || isRight) {
|
|
|
|
// HACK ALERT: There appears to be no way to really obtain this value, so we're forced
|
|
|
|
// to just use the default value for Luna (which also happens to be correct for
|
|
|
|
// all the other skins I've tried).
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t edgeSize = 2;
|
2005-08-20 11:12:01 +04:00
|
|
|
|
2009-01-04 17:01:48 +03:00
|
|
|
// Armed with the size of the edge, we now need to either shift to the left or to the
|
|
|
|
// right. The clip rect won't include this extra area, so we know that we're
|
|
|
|
// effectively shifting the edge out of view (such that it won't be painted).
|
|
|
|
if (isLeft)
|
|
|
|
// The right edge should not be drawn. Extend our rect by the edge size.
|
|
|
|
widgetRect.right += edgeSize;
|
|
|
|
else
|
|
|
|
// The left edge should not be drawn. Move the widget rect's left coord back.
|
|
|
|
widgetRect.left -= edgeSize;
|
|
|
|
}
|
2005-08-20 11:12:01 +04:00
|
|
|
}
|
2010-11-29 19:19:17 +03:00
|
|
|
else if (aWidgetType == NS_THEME_WINDOW_BUTTON_MINIMIZE) {
|
|
|
|
OffsetBackgroundRect(widgetRect, CAPTIONBUTTON_MINIMIZE);
|
|
|
|
}
|
|
|
|
else if (aWidgetType == NS_THEME_WINDOW_BUTTON_MAXIMIZE ||
|
|
|
|
aWidgetType == NS_THEME_WINDOW_BUTTON_RESTORE) {
|
|
|
|
OffsetBackgroundRect(widgetRect, CAPTIONBUTTON_RESTORE);
|
|
|
|
}
|
|
|
|
else if (aWidgetType == NS_THEME_WINDOW_BUTTON_CLOSE) {
|
|
|
|
OffsetBackgroundRect(widgetRect, CAPTIONBUTTON_CLOSE);
|
|
|
|
}
|
2005-10-07 04:31:36 +04:00
|
|
|
|
2006-05-30 17:50:48 +04:00
|
|
|
// widgetRect is the bounding box for a widget, yet the scale track is only
|
|
|
|
// a small portion of this size, so the edges of the scale need to be
|
|
|
|
// adjusted to the real size of the track.
|
2013-04-03 14:07:12 +04:00
|
|
|
if (aWidgetType == NS_THEME_RANGE ||
|
|
|
|
aWidgetType == NS_THEME_SCALE_HORIZONTAL ||
|
2006-05-30 17:50:48 +04:00
|
|
|
aWidgetType == NS_THEME_SCALE_VERTICAL) {
|
|
|
|
RECT contentRect;
|
2012-02-23 18:53:55 +04:00
|
|
|
GetThemeBackgroundContentRect(theme, hdc, part, state, &widgetRect, &contentRect);
|
2006-05-30 17:50:48 +04:00
|
|
|
|
|
|
|
SIZE siz;
|
2012-02-23 18:53:55 +04:00
|
|
|
GetThemePartSize(theme, hdc, part, state, &widgetRect, TS_TRUE, &siz);
|
2006-05-30 17:50:48 +04:00
|
|
|
|
2013-04-03 14:07:12 +04:00
|
|
|
// When rounding is necessary, we round the position of the track
|
|
|
|
// away from the chevron of the thumb to make it look better.
|
|
|
|
if (aWidgetType == NS_THEME_SCALE_HORIZONTAL ||
|
|
|
|
(aWidgetType == NS_THEME_RANGE && IsRangeHorizontal(aFrame))) {
|
|
|
|
contentRect.top += (contentRect.bottom - contentRect.top - siz.cy) / 2;
|
|
|
|
contentRect.bottom = contentRect.top + siz.cy;
|
2006-05-30 17:50:48 +04:00
|
|
|
}
|
|
|
|
else {
|
2013-04-03 14:07:12 +04:00
|
|
|
if (!IsFrameRTL(aFrame)) {
|
|
|
|
contentRect.left += (contentRect.right - contentRect.left - siz.cx) / 2;
|
|
|
|
contentRect.right = contentRect.left + siz.cx;
|
|
|
|
} else {
|
|
|
|
contentRect.right -= (contentRect.right - contentRect.left - siz.cx) / 2;
|
|
|
|
contentRect.left = contentRect.right - siz.cx;
|
|
|
|
}
|
2006-05-30 17:50:48 +04:00
|
|
|
}
|
|
|
|
|
2012-02-23 18:53:55 +04:00
|
|
|
DrawThemeBackground(theme, hdc, part, state, &contentRect, &clipRect);
|
2006-05-30 17:50:48 +04:00
|
|
|
}
|
2007-08-06 21:45:57 +04:00
|
|
|
else if (aWidgetType == NS_THEME_MENUCHECKBOX || aWidgetType == NS_THEME_MENURADIO)
|
|
|
|
{
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isChecked = false;
|
2011-10-14 22:11:22 +04:00
|
|
|
isChecked = CheckBooleanAttr(aFrame, nsGkAtoms::checked);
|
2007-08-06 21:45:57 +04:00
|
|
|
|
|
|
|
if (isChecked)
|
|
|
|
{
|
|
|
|
int bgState = MCB_NORMAL;
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates eventState = GetContentState(aFrame, aWidgetType);
|
2007-08-06 21:45:57 +04:00
|
|
|
|
|
|
|
// the disabled states are offset by 1
|
2010-09-28 05:25:18 +04:00
|
|
|
if (IsDisabled(aFrame, eventState))
|
2007-08-06 21:45:57 +04:00
|
|
|
bgState += 1;
|
|
|
|
|
2009-08-25 02:13:01 +04:00
|
|
|
SIZE checkboxBGSize(GetCheckboxBGSize(theme, hdc));
|
2007-08-06 21:45:57 +04:00
|
|
|
|
2009-08-25 02:13:01 +04:00
|
|
|
RECT checkBGRect = widgetRect;
|
2008-07-19 00:55:25 +04:00
|
|
|
if (IsFrameRTL(aFrame)) {
|
2009-08-25 02:13:01 +04:00
|
|
|
checkBGRect.left = checkBGRect.right-checkboxBGSize.cx;
|
2008-07-19 00:55:25 +04:00
|
|
|
} else {
|
2009-08-25 02:13:01 +04:00
|
|
|
checkBGRect.right = checkBGRect.left+checkboxBGSize.cx;
|
2008-07-19 00:55:25 +04:00
|
|
|
}
|
2007-08-06 21:45:57 +04:00
|
|
|
|
2009-08-25 02:13:01 +04:00
|
|
|
// Center the checkbox background vertically in the menuitem
|
|
|
|
checkBGRect.top += (checkBGRect.bottom - checkBGRect.top)/2 - checkboxBGSize.cy/2;
|
|
|
|
checkBGRect.bottom = checkBGRect.top + checkboxBGSize.cy;
|
|
|
|
|
2012-02-23 18:53:55 +04:00
|
|
|
DrawThemeBackground(theme, hdc, MENU_POPUPCHECKBACKGROUND, bgState, &checkBGRect, &clipRect);
|
2007-08-06 21:45:57 +04:00
|
|
|
|
2009-08-25 02:13:01 +04:00
|
|
|
MARGINS checkMargins = GetCheckboxMargins(theme, hdc);
|
|
|
|
RECT checkRect = checkBGRect;
|
|
|
|
checkRect.left += checkMargins.cxLeftWidth;
|
|
|
|
checkRect.right -= checkMargins.cxRightWidth;
|
|
|
|
checkRect.top += checkMargins.cyTopHeight;
|
|
|
|
checkRect.bottom -= checkMargins.cyBottomHeight;
|
2012-02-23 18:53:55 +04:00
|
|
|
DrawThemeBackground(theme, hdc, MENU_POPUPCHECK, state, &checkRect, &clipRect);
|
2007-08-06 21:45:57 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (aWidgetType == NS_THEME_MENUPOPUP)
|
|
|
|
{
|
2012-02-23 18:53:55 +04:00
|
|
|
DrawThemeBackground(theme, hdc, MENU_POPUPBORDERS, /* state */ 0, &widgetRect, &clipRect);
|
2007-08-06 21:45:57 +04:00
|
|
|
SIZE borderSize;
|
2013-10-08 22:48:20 +04:00
|
|
|
GetThemePartSize(theme, hdc, MENU_POPUPBORDERS, 0, nullptr, TS_TRUE, &borderSize);
|
2007-08-06 21:45:57 +04:00
|
|
|
|
|
|
|
RECT bgRect = widgetRect;
|
|
|
|
bgRect.top += borderSize.cy;
|
|
|
|
bgRect.bottom -= borderSize.cy;
|
|
|
|
bgRect.left += borderSize.cx;
|
|
|
|
bgRect.right -= borderSize.cx;
|
|
|
|
|
2012-02-23 18:53:55 +04:00
|
|
|
DrawThemeBackground(theme, hdc, MENU_POPUPBACKGROUND, /* state */ 0, &bgRect, &clipRect);
|
2007-08-06 21:45:57 +04:00
|
|
|
|
|
|
|
SIZE gutterSize(GetGutterSize(theme, hdc));
|
|
|
|
|
|
|
|
RECT gutterRect;
|
|
|
|
gutterRect.top = bgRect.top;
|
|
|
|
gutterRect.bottom = bgRect.bottom;
|
2008-07-19 00:55:25 +04:00
|
|
|
if (IsFrameRTL(aFrame)) {
|
|
|
|
gutterRect.right = bgRect.right;
|
|
|
|
gutterRect.left = gutterRect.right-gutterSize.cx;
|
|
|
|
} else {
|
|
|
|
gutterRect.left = bgRect.left;
|
|
|
|
gutterRect.right = gutterRect.left+gutterSize.cx;
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawThemeBGRTLAware(theme, hdc, MENU_POPUPGUTTER, /* state */ 0,
|
|
|
|
&gutterRect, &clipRect, IsFrameRTL(aFrame));
|
2007-08-06 21:45:57 +04:00
|
|
|
}
|
|
|
|
else if (aWidgetType == NS_THEME_MENUSEPARATOR)
|
|
|
|
{
|
|
|
|
SIZE gutterSize(GetGutterSize(theme,hdc));
|
|
|
|
|
|
|
|
RECT sepRect = widgetRect;
|
2008-07-19 00:55:25 +04:00
|
|
|
if (IsFrameRTL(aFrame))
|
|
|
|
sepRect.right -= gutterSize.cx;
|
|
|
|
else
|
|
|
|
sepRect.left += gutterSize.cx;
|
|
|
|
|
2012-02-23 18:53:55 +04:00
|
|
|
DrawThemeBackground(theme, hdc, MENU_POPUPSEPARATOR, /* state */ 0, &sepRect, &clipRect);
|
2007-08-06 21:45:57 +04:00
|
|
|
}
|
2014-05-05 22:32:54 +04:00
|
|
|
else if (aWidgetType == NS_THEME_MENUARROW)
|
|
|
|
{
|
2014-06-17 21:35:51 +04:00
|
|
|
// We're dpi aware and as such on systems that have dpi > 96 set, the
|
|
|
|
// theme library expects us to do proper positioning and scaling of glyphs.
|
|
|
|
// For NS_THEME_MENUARROW, layout may hand us a widget rect larger than the
|
|
|
|
// glyph rect we request in GetMinimumWidgetSize. To prevent distortion we
|
|
|
|
// have to position and scale what we draw.
|
2014-05-05 22:32:54 +04:00
|
|
|
|
|
|
|
SIZE glyphSize;
|
|
|
|
GetThemePartSize(theme, hdc, part, state, nullptr, TS_TRUE, &glyphSize);
|
|
|
|
|
|
|
|
int32_t widgetHeight = widgetRect.bottom - widgetRect.top;
|
|
|
|
|
|
|
|
RECT renderRect = widgetRect;
|
|
|
|
|
|
|
|
// We request (glyph width * 2, glyph height) in GetMinimumWidgetSize. In
|
|
|
|
// Firefox some menu items provide the full height of the item to us, in
|
|
|
|
// others our widget rect is the exact dims of our arrow glyph. Adjust the
|
|
|
|
// vertical position by the added space, if any exists.
|
|
|
|
renderRect.top += ((widgetHeight - glyphSize.cy) / 2);
|
|
|
|
renderRect.bottom = renderRect.top + glyphSize.cy;
|
|
|
|
// I'm using the width of the arrow glyph for the arrow-side padding.
|
|
|
|
// AFAICT there doesn't appear to be a theme constant we can query
|
|
|
|
// for this value. Generally this looks correct, and has the added
|
|
|
|
// benefit of being a dpi adjusted value.
|
|
|
|
if (!IsFrameRTL(aFrame)) {
|
|
|
|
renderRect.right = widgetRect.right - glyphSize.cx;
|
|
|
|
renderRect.left = renderRect.right - glyphSize.cx;
|
|
|
|
} else {
|
|
|
|
renderRect.left = glyphSize.cx;
|
|
|
|
renderRect.right = renderRect.left + glyphSize.cx;
|
|
|
|
}
|
|
|
|
DrawThemeBGRTLAware(theme, hdc, part, state, &renderRect, &clipRect,
|
|
|
|
IsFrameRTL(aFrame));
|
|
|
|
}
|
2008-07-19 00:55:25 +04:00
|
|
|
// The following widgets need to be RTL-aware
|
2014-05-05 22:32:54 +04:00
|
|
|
else if (aWidgetType == NS_THEME_RESIZER ||
|
2016-05-18 20:29:56 +03:00
|
|
|
aWidgetType == NS_THEME_MENULIST_BUTTON)
|
2009-01-18 13:28:19 +03:00
|
|
|
{
|
2008-07-19 00:55:25 +04:00
|
|
|
DrawThemeBGRTLAware(theme, hdc, part, state,
|
|
|
|
&widgetRect, &clipRect, IsFrameRTL(aFrame));
|
|
|
|
}
|
2014-10-28 05:36:00 +03:00
|
|
|
else if (aWidgetType == NS_THEME_NUMBER_INPUT ||
|
|
|
|
aWidgetType == NS_THEME_TEXTFIELD ||
|
|
|
|
aWidgetType == NS_THEME_TEXTFIELD_MULTILINE) {
|
|
|
|
DrawThemeBackground(theme, hdc, part, state, &widgetRect, &clipRect);
|
|
|
|
if (state == TFS_EDITBORDER_DISABLED) {
|
|
|
|
InflateRect(&widgetRect, -1, -1);
|
|
|
|
::FillRect(hdc, &widgetRect, reinterpret_cast<HBRUSH>(COLOR_BTNFACE+1));
|
|
|
|
}
|
|
|
|
}
|
2013-02-25 04:16:16 +04:00
|
|
|
else if (aWidgetType == NS_THEME_PROGRESSBAR ||
|
|
|
|
aWidgetType == NS_THEME_PROGRESSBAR_VERTICAL) {
|
|
|
|
// DrawThemeBackground renders each corner with a solid white pixel.
|
|
|
|
// Restore these pixels to the underlying color. Tracks are rendered
|
|
|
|
// using alpha recovery, so this makes the corners transparent.
|
|
|
|
COLORREF color;
|
|
|
|
color = GetPixel(hdc, widgetRect.left, widgetRect.top);
|
|
|
|
DrawThemeBackground(theme, hdc, part, state, &widgetRect, &clipRect);
|
|
|
|
SetPixel(hdc, widgetRect.left, widgetRect.top, color);
|
|
|
|
SetPixel(hdc, widgetRect.right-1, widgetRect.top, color);
|
|
|
|
SetPixel(hdc, widgetRect.right-1, widgetRect.bottom-1, color);
|
|
|
|
SetPixel(hdc, widgetRect.left, widgetRect.bottom-1, color);
|
|
|
|
}
|
2016-05-18 20:29:56 +03:00
|
|
|
else if (aWidgetType == NS_THEME_PROGRESSCHUNK ||
|
|
|
|
aWidgetType == NS_THEME_PROGRESSCHUNK_VERTICAL) {
|
2013-02-25 04:27:22 +04:00
|
|
|
DrawThemedProgressMeter(aFrame, aWidgetType, theme, hdc, part, state,
|
2016-12-23 05:13:31 +03:00
|
|
|
&widgetRect, &clipRect);
|
2013-02-25 04:27:22 +04:00
|
|
|
}
|
2014-06-14 16:48:08 +04:00
|
|
|
else if (aWidgetType == NS_THEME_FOCUS_OUTLINE) {
|
|
|
|
// Inflate 'widgetRect' with the focus outline size.
|
|
|
|
nsIntMargin border;
|
|
|
|
if (NS_SUCCEEDED(GetWidgetBorder(aFrame->PresContext()->DeviceContext(),
|
|
|
|
aFrame, aWidgetType, &border))) {
|
|
|
|
widgetRect.left -= border.left;
|
|
|
|
widgetRect.right += border.right;
|
|
|
|
widgetRect.top -= border.top;
|
|
|
|
widgetRect.bottom += border.bottom;
|
|
|
|
}
|
|
|
|
|
|
|
|
DTBGOPTS opts = {
|
|
|
|
sizeof(DTBGOPTS),
|
|
|
|
DTBG_OMITCONTENT | DTBG_CLIPRECT,
|
|
|
|
clipRect
|
|
|
|
};
|
|
|
|
DrawThemeBackgroundEx(theme, hdc, part, state, &widgetRect, &opts);
|
|
|
|
}
|
2005-10-07 04:31:36 +04:00
|
|
|
// If part is negative, the element wishes us to not render a themed
|
|
|
|
// background, instead opting to be drawn specially below.
|
2006-05-30 17:50:48 +04:00
|
|
|
else if (part >= 0) {
|
2012-02-23 18:53:55 +04:00
|
|
|
DrawThemeBackground(theme, hdc, part, state, &widgetRect, &clipRect);
|
2006-05-30 17:50:48 +04:00
|
|
|
}
|
2005-08-20 11:13:11 +04:00
|
|
|
|
2016-10-22 09:28:53 +03:00
|
|
|
// Draw focus rectangles for range and scale elements
|
2005-08-20 11:13:11 +04:00
|
|
|
// XXX it'd be nice to draw these outside of the frame
|
2016-10-22 09:28:53 +03:00
|
|
|
if (aWidgetType == NS_THEME_RANGE ||
|
2006-05-30 17:50:48 +04:00
|
|
|
aWidgetType == NS_THEME_SCALE_HORIZONTAL ||
|
|
|
|
aWidgetType == NS_THEME_SCALE_VERTICAL) {
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates contentState = GetContentState(aFrame, aWidgetType);
|
2009-02-19 02:56:51 +03:00
|
|
|
|
2010-10-20 15:26:32 +04:00
|
|
|
if (contentState.HasState(NS_EVENT_STATE_FOCUS)) {
|
2006-07-12 03:13:21 +04:00
|
|
|
POINT vpOrg;
|
2012-07-30 18:20:58 +04:00
|
|
|
HPEN hPen = nullptr;
|
2009-02-19 02:56:51 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t id = SaveDC(hdc);
|
2009-02-19 02:56:51 +03:00
|
|
|
|
2013-10-08 22:48:20 +04:00
|
|
|
::SelectClipRgn(hdc, nullptr);
|
2006-07-12 03:13:21 +04:00
|
|
|
::GetViewportOrgEx(hdc, &vpOrg);
|
2013-10-08 22:48:20 +04:00
|
|
|
::SetBrushOrgEx(hdc, vpOrg.x + widgetRect.left, vpOrg.y + widgetRect.top, nullptr);
|
2016-10-22 09:28:53 +03:00
|
|
|
::SetTextColor(hdc, 0);
|
|
|
|
::DrawFocusRect(hdc, &widgetRect);
|
2009-02-19 02:56:51 +03:00
|
|
|
::RestoreDC(hdc, id);
|
|
|
|
if (hPen) {
|
|
|
|
::DeleteObject(hPen);
|
|
|
|
}
|
2005-08-20 11:13:11 +04:00
|
|
|
}
|
|
|
|
}
|
2007-07-14 19:11:37 +04:00
|
|
|
else if (aWidgetType == NS_THEME_TOOLBAR && state == 0) {
|
|
|
|
// Draw toolbar separator lines above all toolbars except the first one.
|
|
|
|
// The lines are part of the Rebar theme, which is loaded for NS_THEME_TOOLBOX.
|
|
|
|
theme = GetTheme(NS_THEME_TOOLBOX);
|
|
|
|
if (!theme)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
widgetRect.bottom = widgetRect.top + TB_SEPARATOR_HEIGHT;
|
2013-10-08 22:48:20 +04:00
|
|
|
DrawThemeEdge(theme, hdc, RP_BAND, 0, &widgetRect, EDGE_ETCHED, BF_TOP, nullptr);
|
2005-10-07 04:31:36 +04:00
|
|
|
}
|
2016-05-18 20:29:56 +03:00
|
|
|
else if (aWidgetType == NS_THEME_SCROLLBARTHUMB_HORIZONTAL ||
|
|
|
|
aWidgetType == NS_THEME_SCROLLBARTHUMB_VERTICAL)
|
2012-03-08 05:15:57 +04:00
|
|
|
{
|
|
|
|
// Draw the decorative gripper for the scrollbar thumb button, if it fits
|
|
|
|
|
|
|
|
SIZE gripSize;
|
|
|
|
MARGINS thumbMgns;
|
2016-05-18 20:29:56 +03:00
|
|
|
int gripPart = (aWidgetType == NS_THEME_SCROLLBARTHUMB_HORIZONTAL) ?
|
2012-03-08 05:15:57 +04:00
|
|
|
SP_GRIPPERHOR : SP_GRIPPERVERT;
|
|
|
|
|
2013-10-08 22:48:20 +04:00
|
|
|
if (GetThemePartSize(theme, hdc, gripPart, state, nullptr, TS_TRUE, &gripSize) == S_OK &&
|
|
|
|
GetThemeMargins(theme, hdc, part, state, TMT_CONTENTMARGINS, nullptr, &thumbMgns) == S_OK &&
|
2012-03-08 05:15:57 +04:00
|
|
|
gripSize.cx + thumbMgns.cxLeftWidth + thumbMgns.cxRightWidth <= widgetRect.right - widgetRect.left &&
|
|
|
|
gripSize.cy + thumbMgns.cyTopHeight + thumbMgns.cyBottomHeight <= widgetRect.bottom - widgetRect.top)
|
|
|
|
{
|
|
|
|
DrawThemeBackground(theme, hdc, gripPart, state, &widgetRect, &clipRect);
|
|
|
|
}
|
|
|
|
}
|
2010-10-19 21:02:24 +04:00
|
|
|
|
2007-03-03 03:18:34 +03:00
|
|
|
nativeDrawing.EndNativeDrawing();
|
2006-08-10 00:25:07 +04:00
|
|
|
|
2007-03-03 03:18:34 +03:00
|
|
|
if (nativeDrawing.ShouldRenderAgain())
|
|
|
|
goto RENDER_AGAIN;
|
2006-08-10 00:25:07 +04:00
|
|
|
|
2007-03-03 03:18:34 +03:00
|
|
|
nativeDrawing.PaintToContext();
|
2006-01-19 01:42:30 +03:00
|
|
|
|
2005-08-20 11:11:56 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-12-02 23:54:26 +03:00
|
|
|
static void
|
|
|
|
ScaleForFrameDPI(nsIntMargin* aMargin, nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
double themeScale = GetThemeDpiScaleFactor(aFrame);
|
|
|
|
if (themeScale != 1.0) {
|
|
|
|
aMargin->top = NSToIntRound(aMargin->top * themeScale);
|
|
|
|
aMargin->left = NSToIntRound(aMargin->left * themeScale);
|
|
|
|
aMargin->bottom = NSToIntRound(aMargin->bottom * themeScale);
|
|
|
|
aMargin->right = NSToIntRound(aMargin->right * themeScale);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ScaleForFrameDPI(LayoutDeviceIntSize* aSize, nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
double themeScale = GetThemeDpiScaleFactor(aFrame);
|
|
|
|
if (themeScale != 1.0) {
|
|
|
|
aSize->width = NSToIntRound(aSize->width * themeScale);
|
|
|
|
aSize->height = NSToIntRound(aSize->height * themeScale);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:56 +04:00
|
|
|
NS_IMETHODIMP
|
2011-04-17 05:22:44 +04:00
|
|
|
nsNativeThemeWin::GetWidgetBorder(nsDeviceContext* aContext,
|
2005-08-20 11:11:57 +04:00
|
|
|
nsIFrame* aFrame,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t aWidgetType,
|
2009-01-15 06:27:09 +03:00
|
|
|
nsIntMargin* aResult)
|
2005-08-20 11:11:56 +04:00
|
|
|
{
|
2017-06-21 23:43:27 +03:00
|
|
|
mozilla::Maybe<nsUXThemeClass> themeClass = GetThemeClass(aWidgetType);
|
2017-07-17 23:55:28 +03:00
|
|
|
HTHEME theme = NULL;
|
|
|
|
if (!themeClass.isNothing()) {
|
|
|
|
theme = nsUXThemeData::GetTheme(themeClass.value());
|
|
|
|
}
|
2015-12-02 23:54:26 +03:00
|
|
|
nsresult rv = NS_OK;
|
2017-07-17 23:55:28 +03:00
|
|
|
if (!theme) {
|
2015-12-02 23:54:26 +03:00
|
|
|
rv = ClassicGetWidgetBorder(aContext, aFrame, aWidgetType, aResult);
|
|
|
|
ScaleForFrameDPI(aResult, aFrame);
|
|
|
|
return rv;
|
|
|
|
}
|
2005-08-20 11:11:56 +04:00
|
|
|
|
2015-12-02 23:54:26 +03:00
|
|
|
aResult->top = aResult->bottom = aResult->left = aResult->right = 0;
|
2005-08-20 11:11:59 +04:00
|
|
|
|
2005-08-20 11:12:07 +04:00
|
|
|
if (!WidgetIsContainer(aWidgetType) ||
|
2005-10-07 04:31:36 +04:00
|
|
|
aWidgetType == NS_THEME_TOOLBOX ||
|
2008-05-08 13:29:38 +04:00
|
|
|
aWidgetType == NS_THEME_WIN_MEDIA_TOOLBOX ||
|
|
|
|
aWidgetType == NS_THEME_WIN_COMMUNICATIONS_TOOLBOX ||
|
2016-05-18 20:29:56 +03:00
|
|
|
aWidgetType == NS_THEME_WIN_BROWSERTABBAR_TOOLBOX ||
|
2005-08-20 11:11:57 +04:00
|
|
|
aWidgetType == NS_THEME_STATUSBAR ||
|
2016-05-18 20:29:56 +03:00
|
|
|
aWidgetType == NS_THEME_RESIZER || aWidgetType == NS_THEME_TABPANEL ||
|
2015-12-22 07:05:00 +03:00
|
|
|
aWidgetType == NS_THEME_SCROLLBAR_HORIZONTAL ||
|
|
|
|
aWidgetType == NS_THEME_SCROLLBAR_VERTICAL ||
|
2007-08-06 21:45:57 +04:00
|
|
|
aWidgetType == NS_THEME_MENUITEM || aWidgetType == NS_THEME_CHECKMENUITEM ||
|
|
|
|
aWidgetType == NS_THEME_RADIOMENUITEM || aWidgetType == NS_THEME_MENUPOPUP ||
|
2007-08-26 00:30:43 +04:00
|
|
|
aWidgetType == NS_THEME_MENUIMAGE || aWidgetType == NS_THEME_MENUITEMTEXT ||
|
2016-05-18 20:29:56 +03:00
|
|
|
aWidgetType == NS_THEME_SEPARATOR ||
|
2010-11-29 19:19:17 +03:00
|
|
|
aWidgetType == NS_THEME_WINDOW_TITLEBAR ||
|
|
|
|
aWidgetType == NS_THEME_WINDOW_TITLEBAR_MAXIMIZED ||
|
2010-10-19 21:02:25 +04:00
|
|
|
aWidgetType == NS_THEME_WIN_GLASS || aWidgetType == NS_THEME_WIN_BORDERLESS_GLASS)
|
2005-08-20 11:11:56 +04:00
|
|
|
return NS_OK; // Don't worry about it.
|
2005-10-07 04:31:36 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t part, state;
|
2015-12-02 23:54:26 +03:00
|
|
|
rv = GetThemePartAndState(aFrame, aWidgetType, part, state);
|
2005-08-20 11:11:56 +04:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
2007-07-14 19:11:37 +04:00
|
|
|
if (aWidgetType == NS_THEME_TOOLBAR) {
|
|
|
|
// make space for the separator line above all toolbars but the first
|
|
|
|
if (state == 0)
|
|
|
|
aResult->top = TB_SEPARATOR_HEIGHT;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-07-17 23:55:28 +03:00
|
|
|
rv = GetCachedWidgetBorder(aFrame, theme, themeClass.value(), aWidgetType, part, state, aResult);
|
2017-06-21 23:43:27 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2005-08-20 11:12:01 +04:00
|
|
|
|
|
|
|
// Remove the edges for tabs that are before or after the selected tab,
|
2009-01-04 17:01:48 +03:00
|
|
|
if (aWidgetType == NS_THEME_TAB) {
|
|
|
|
if (IsLeftToSelectedTab(aFrame))
|
|
|
|
// Remove the right edge, since we won't be drawing it.
|
|
|
|
aResult->right = 0;
|
|
|
|
else if (IsRightToSelectedTab(aFrame))
|
|
|
|
// Remove the left edge, since we won't be drawing it.
|
|
|
|
aResult->left = 0;
|
|
|
|
}
|
2005-08-20 11:12:01 +04:00
|
|
|
|
2013-12-09 03:23:28 +04:00
|
|
|
if (aFrame && (aWidgetType == NS_THEME_NUMBER_INPUT ||
|
|
|
|
aWidgetType == NS_THEME_TEXTFIELD ||
|
|
|
|
aWidgetType == NS_THEME_TEXTFIELD_MULTILINE)) {
|
2005-08-20 11:13:33 +04:00
|
|
|
nsIContent* content = aFrame->GetContent();
|
2015-03-03 14:08:59 +03:00
|
|
|
if (content && content->IsHTMLElement()) {
|
2005-08-20 11:13:10 +04:00
|
|
|
// We need to pad textfields by 1 pixel, since the caret will draw
|
|
|
|
// flush against the edge by default if we don't.
|
2006-03-15 14:59:22 +03:00
|
|
|
aResult->top++;
|
2005-08-20 11:13:10 +04:00
|
|
|
aResult->left++;
|
2006-03-15 14:59:22 +03:00
|
|
|
aResult->bottom++;
|
2005-08-20 11:13:10 +04:00
|
|
|
aResult->right++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-02 23:54:26 +03:00
|
|
|
ScaleForFrameDPI(aResult, aFrame);
|
|
|
|
return rv;
|
2005-08-20 11:11:56 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2011-04-17 05:22:44 +04:00
|
|
|
nsNativeThemeWin::GetWidgetPadding(nsDeviceContext* aContext,
|
2005-08-20 11:14:07 +04:00
|
|
|
nsIFrame* aFrame,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t aWidgetType,
|
2009-01-15 06:27:09 +03:00
|
|
|
nsIntMargin* aResult)
|
2005-08-20 11:14:07 +04:00
|
|
|
{
|
2008-03-07 20:57:34 +03:00
|
|
|
switch (aWidgetType) {
|
|
|
|
// Radios and checkboxes return a fixed size in GetMinimumWidgetSize
|
|
|
|
// and have a meaningful baseline, so they can't have
|
|
|
|
// author-specified padding.
|
|
|
|
case NS_THEME_CHECKBOX:
|
|
|
|
case NS_THEME_RADIO:
|
|
|
|
aResult->SizeTo(0, 0, 0, 0);
|
2011-10-02 06:16:19 +04:00
|
|
|
return true;
|
2008-03-07 20:57:34 +03:00
|
|
|
}
|
|
|
|
|
2015-12-02 23:54:26 +03:00
|
|
|
bool ok = true;
|
2010-08-10 05:49:35 +04:00
|
|
|
|
|
|
|
if (aWidgetType == NS_THEME_WINDOW_BUTTON_BOX ||
|
|
|
|
aWidgetType == NS_THEME_WINDOW_BUTTON_BOX_MAXIMIZED) {
|
|
|
|
aResult->SizeTo(0, 0, 0, 0);
|
|
|
|
|
|
|
|
// aero glass doesn't display custom buttons
|
|
|
|
if (nsUXThemeData::CheckForCompositor())
|
2011-10-02 06:16:19 +04:00
|
|
|
return true;
|
2010-08-10 05:49:35 +04:00
|
|
|
|
|
|
|
// button padding for standard windows
|
|
|
|
if (aWidgetType == NS_THEME_WINDOW_BUTTON_BOX) {
|
|
|
|
aResult->top = GetSystemMetrics(SM_CXFRAME);
|
|
|
|
}
|
2015-12-02 23:54:26 +03:00
|
|
|
ScaleForFrameDPI(aResult, aFrame);
|
|
|
|
return ok;
|
2010-08-10 05:49:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Content padding
|
|
|
|
if (aWidgetType == NS_THEME_WINDOW_TITLEBAR ||
|
|
|
|
aWidgetType == NS_THEME_WINDOW_TITLEBAR_MAXIMIZED) {
|
|
|
|
aResult->SizeTo(0, 0, 0, 0);
|
2012-01-13 19:10:05 +04:00
|
|
|
// XXX Maximized windows have an offscreen offset equal to
|
|
|
|
// the border padding. This should be addressed in nsWindow,
|
|
|
|
// but currently can't be, see UpdateNonClientMargins.
|
2010-08-10 05:49:35 +04:00
|
|
|
if (aWidgetType == NS_THEME_WINDOW_TITLEBAR_MAXIMIZED)
|
2012-08-20 23:11:31 +04:00
|
|
|
aResult->top = GetSystemMetrics(SM_CXFRAME)
|
|
|
|
+ GetSystemMetrics(SM_CXPADDEDBORDER);
|
2015-12-02 23:54:26 +03:00
|
|
|
return ok;
|
2010-08-10 05:49:35 +04:00
|
|
|
}
|
|
|
|
|
2015-12-02 23:54:26 +03:00
|
|
|
HANDLE theme = GetTheme(aWidgetType);
|
|
|
|
if (!theme) {
|
|
|
|
ok = ClassicGetWidgetPadding(aContext, aFrame, aWidgetType, aResult);
|
|
|
|
ScaleForFrameDPI(aResult, aFrame);
|
|
|
|
return ok;
|
|
|
|
}
|
2007-08-06 21:45:57 +04:00
|
|
|
|
|
|
|
if (aWidgetType == NS_THEME_MENUPOPUP)
|
|
|
|
{
|
|
|
|
SIZE popupSize;
|
2013-10-08 22:48:20 +04:00
|
|
|
GetThemePartSize(theme, nullptr, MENU_POPUPBORDERS, /* state */ 0, nullptr, TS_TRUE, &popupSize);
|
2007-08-06 21:45:57 +04:00
|
|
|
aResult->top = aResult->bottom = popupSize.cy;
|
|
|
|
aResult->left = aResult->right = popupSize.cx;
|
2015-12-02 23:54:26 +03:00
|
|
|
ScaleForFrameDPI(aResult, aFrame);
|
|
|
|
return ok;
|
2007-08-06 21:45:57 +04:00
|
|
|
}
|
|
|
|
|
2016-12-23 05:13:31 +03:00
|
|
|
if (aWidgetType == NS_THEME_NUMBER_INPUT ||
|
|
|
|
aWidgetType == NS_THEME_TEXTFIELD ||
|
|
|
|
aWidgetType == NS_THEME_TEXTFIELD_MULTILINE ||
|
|
|
|
aWidgetType == NS_THEME_MENULIST)
|
|
|
|
{
|
|
|
|
// If we have author-specified padding for these elements, don't do the
|
|
|
|
// fixups below.
|
|
|
|
if (aFrame->PresContext()->HasAuthorSpecifiedRules(aFrame, NS_AUTHOR_SPECIFIED_PADDING))
|
|
|
|
return false;
|
|
|
|
}
|
2008-04-26 03:12:45 +04:00
|
|
|
|
2016-12-23 05:13:31 +03:00
|
|
|
/* textfields need extra pixels on all sides, otherwise they wrap their
|
|
|
|
* content too tightly. The actual border is drawn 1px inside the specified
|
|
|
|
* rectangle, so Gecko will end up making the contents look too small.
|
|
|
|
* Instead, we add 2px padding for the contents and fix this. (Used to be 1px
|
|
|
|
* added, see bug 430212)
|
|
|
|
*/
|
|
|
|
if (aWidgetType == NS_THEME_NUMBER_INPUT ||
|
|
|
|
aWidgetType == NS_THEME_TEXTFIELD ||
|
|
|
|
aWidgetType == NS_THEME_TEXTFIELD_MULTILINE) {
|
|
|
|
aResult->top = aResult->bottom = 2;
|
|
|
|
aResult->left = aResult->right = 2;
|
|
|
|
ScaleForFrameDPI(aResult, aFrame);
|
|
|
|
return ok;
|
|
|
|
} else if (IsHTMLContent(aFrame) && aWidgetType == NS_THEME_MENULIST) {
|
|
|
|
/* For content menulist controls, we need an extra pixel so that we have
|
|
|
|
* room to draw our focus rectangle stuff. Otherwise, the focus rect might
|
|
|
|
* overlap the control's border.
|
2008-02-29 08:10:12 +03:00
|
|
|
*/
|
2016-12-23 05:13:31 +03:00
|
|
|
aResult->top = aResult->bottom = 1;
|
|
|
|
aResult->left = aResult->right = 1;
|
|
|
|
ScaleForFrameDPI(aResult, aFrame);
|
|
|
|
return ok;
|
2008-02-29 08:10:12 +03:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t right, left, top, bottom;
|
2007-08-06 21:45:57 +04:00
|
|
|
right = left = top = bottom = 0;
|
|
|
|
switch (aWidgetType)
|
|
|
|
{
|
|
|
|
case NS_THEME_MENUIMAGE:
|
2008-05-09 04:18:46 +04:00
|
|
|
right = 8;
|
2007-08-06 21:45:57 +04:00
|
|
|
left = 3;
|
|
|
|
break;
|
|
|
|
case NS_THEME_MENUCHECKBOX:
|
|
|
|
case NS_THEME_MENURADIO:
|
2007-08-18 01:07:26 +04:00
|
|
|
right = 8;
|
2007-08-06 21:45:57 +04:00
|
|
|
left = 0;
|
|
|
|
break;
|
|
|
|
case NS_THEME_MENUITEMTEXT:
|
2008-05-09 04:18:46 +04:00
|
|
|
// There seem to be exactly 4 pixels from the edge
|
|
|
|
// of the gutter to the text: 2px margin (CSS) + 2px padding (here)
|
2008-06-19 22:32:52 +04:00
|
|
|
{
|
2013-10-08 22:48:20 +04:00
|
|
|
SIZE size(GetGutterSize(theme, nullptr));
|
2008-06-19 22:32:52 +04:00
|
|
|
left = size.cx + 2;
|
|
|
|
}
|
2007-08-06 21:45:57 +04:00
|
|
|
break;
|
|
|
|
case NS_THEME_MENUSEPARATOR:
|
|
|
|
{
|
2013-10-08 22:48:20 +04:00
|
|
|
SIZE size(GetGutterSize(theme, nullptr));
|
2007-08-06 21:45:57 +04:00
|
|
|
left = size.cx + 5;
|
|
|
|
top = 10;
|
|
|
|
bottom = 7;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2011-10-02 06:16:19 +04:00
|
|
|
return false;
|
2007-08-06 21:45:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (IsFrameRTL(aFrame))
|
|
|
|
{
|
|
|
|
aResult->right = left;
|
|
|
|
aResult->left = right;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aResult->right = right;
|
|
|
|
aResult->left = left;
|
|
|
|
}
|
2015-12-02 23:54:26 +03:00
|
|
|
|
|
|
|
ScaleForFrameDPI(aResult, aFrame);
|
|
|
|
return ok;
|
2005-08-20 11:14:07 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2011-04-17 05:22:44 +04:00
|
|
|
nsNativeThemeWin::GetWidgetOverflow(nsDeviceContext* aContext,
|
2008-02-29 08:10:12 +03:00
|
|
|
nsIFrame* aFrame,
|
2014-06-14 16:48:08 +04:00
|
|
|
uint8_t aWidgetType,
|
|
|
|
nsRect* aOverflowRect)
|
2008-02-29 08:10:12 +03:00
|
|
|
{
|
2008-03-03 09:59:06 +03:00
|
|
|
/* This is disabled for now, because it causes invalidation problems --
|
2010-07-15 02:25:41 +04:00
|
|
|
* see bug 420381. The effect of not updating the overflow area is that
|
2008-03-03 09:59:06 +03:00
|
|
|
* for dropdown buttons in content areas, there is a 1px border on 3 sides
|
|
|
|
* where, if invalidated, the dropdown control probably won't be repainted.
|
|
|
|
* This is fairly minor, as by default there is nothing in that area, and
|
|
|
|
* a border only shows up if the widget is being hovered.
|
|
|
|
*/
|
|
|
|
#if 0
|
2016-12-23 05:13:31 +03:00
|
|
|
/* We explicitly draw dropdown buttons in HTML content 1px bigger up, right,
|
|
|
|
* and bottom so that they overlap the dropdown's border like they're
|
|
|
|
* supposed to.
|
|
|
|
*/
|
|
|
|
if (aWidgetType == NS_THEME_MENULIST_BUTTON &&
|
|
|
|
IsHTMLContent(aFrame) &&
|
|
|
|
!IsWidgetStyled(aFrame->GetParent()->PresContext(),
|
|
|
|
aFrame->GetParent(),
|
|
|
|
NS_THEME_MENULIST))
|
|
|
|
{
|
|
|
|
int32_t p2a = aContext->AppUnitsPerDevPixel();
|
|
|
|
/* Note: no overflow on the left */
|
|
|
|
nsMargin m(p2a, p2a, p2a, 0);
|
|
|
|
aOverflowRect->Inflate (m);
|
|
|
|
return true;
|
2008-02-29 08:10:12 +03:00
|
|
|
}
|
2008-03-03 09:59:06 +03:00
|
|
|
#endif
|
2008-02-29 08:10:12 +03:00
|
|
|
|
2014-06-14 16:48:08 +04:00
|
|
|
if (aWidgetType == NS_THEME_FOCUS_OUTLINE) {
|
|
|
|
nsIntMargin border;
|
|
|
|
nsresult rv = GetWidgetBorder(aContext, aFrame, aWidgetType, &border);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
int32_t p2a = aContext->AppUnitsPerDevPixel();
|
|
|
|
nsMargin m(NSIntPixelsToAppUnits(border.top, p2a),
|
|
|
|
NSIntPixelsToAppUnits(border.right, p2a),
|
|
|
|
NSIntPixelsToAppUnits(border.bottom, p2a),
|
|
|
|
NSIntPixelsToAppUnits(border.left, p2a));
|
|
|
|
aOverflowRect->Inflate(m);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-02 06:16:19 +04:00
|
|
|
return false;
|
2008-02-29 08:10:12 +03:00
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:56 +04:00
|
|
|
NS_IMETHODIMP
|
2014-06-27 13:19:00 +04:00
|
|
|
nsNativeThemeWin::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aFrame,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t aWidgetType,
|
2015-03-30 18:36:14 +03:00
|
|
|
LayoutDeviceIntSize* aResult, bool* aIsOverridable)
|
2005-08-20 11:11:56 +04:00
|
|
|
{
|
2015-12-02 23:54:26 +03:00
|
|
|
aResult->width = aResult->height = 0;
|
2011-10-02 06:16:19 +04:00
|
|
|
*aIsOverridable = true;
|
2015-12-02 23:54:26 +03:00
|
|
|
nsresult rv = NS_OK;
|
2005-08-20 11:11:59 +04:00
|
|
|
|
2017-06-22 23:19:13 +03:00
|
|
|
mozilla::Maybe<nsUXThemeClass> themeClass = GetThemeClass(aWidgetType);
|
2017-07-17 23:55:28 +03:00
|
|
|
HTHEME theme = NULL;
|
|
|
|
if (!themeClass.isNothing()) {
|
|
|
|
theme = nsUXThemeData::GetTheme(themeClass.value());
|
|
|
|
}
|
|
|
|
if (!theme) {
|
2015-12-02 23:54:26 +03:00
|
|
|
rv = ClassicGetMinimumWidgetSize(aFrame, aWidgetType, aResult, aIsOverridable);
|
|
|
|
ScaleForFrameDPI(aResult, aFrame);
|
|
|
|
return rv;
|
2015-12-07 04:15:53 +03:00
|
|
|
}
|
2017-06-22 23:19:13 +03:00
|
|
|
|
2009-03-21 23:38:24 +03:00
|
|
|
switch (aWidgetType) {
|
2009-10-15 00:46:43 +04:00
|
|
|
case NS_THEME_GROUPBOX:
|
2013-12-09 03:23:28 +04:00
|
|
|
case NS_THEME_NUMBER_INPUT:
|
2009-03-21 23:38:24 +03:00
|
|
|
case NS_THEME_TEXTFIELD:
|
|
|
|
case NS_THEME_TOOLBOX:
|
|
|
|
case NS_THEME_WIN_MEDIA_TOOLBOX:
|
|
|
|
case NS_THEME_WIN_COMMUNICATIONS_TOOLBOX:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_WIN_BROWSERTABBAR_TOOLBOX:
|
2009-03-21 23:38:24 +03:00
|
|
|
case NS_THEME_TOOLBAR:
|
|
|
|
case NS_THEME_STATUSBAR:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_PROGRESSCHUNK:
|
|
|
|
case NS_THEME_PROGRESSCHUNK_VERTICAL:
|
|
|
|
case NS_THEME_TABPANELS:
|
|
|
|
case NS_THEME_TABPANEL:
|
2009-03-21 23:38:24 +03:00
|
|
|
case NS_THEME_LISTBOX:
|
|
|
|
case NS_THEME_TREEVIEW:
|
|
|
|
case NS_THEME_MENUITEMTEXT:
|
2010-10-19 21:02:25 +04:00
|
|
|
case NS_THEME_WIN_GLASS:
|
|
|
|
case NS_THEME_WIN_BORDERLESS_GLASS:
|
2009-03-21 23:38:24 +03:00
|
|
|
return NS_OK; // Don't worry about it.
|
|
|
|
}
|
2005-08-20 11:11:56 +04:00
|
|
|
|
2007-08-06 21:45:57 +04:00
|
|
|
if (aWidgetType == NS_THEME_MENUITEM && IsTopLevelMenu(aFrame))
|
|
|
|
return NS_OK; // Don't worry about it for top level menus
|
|
|
|
|
2005-08-20 11:13:11 +04:00
|
|
|
// Call GetSystemMetrics to determine size for WinXP scrollbars
|
|
|
|
// (GetThemeSysSize API returns the optimal size for the theme, but
|
|
|
|
// Windows appears to always use metrics when drawing standard scrollbars)
|
2012-02-23 18:53:55 +04:00
|
|
|
THEMESIZE sizeReq = TS_TRUE; // Best-fit size
|
2005-08-20 11:13:11 +04:00
|
|
|
switch (aWidgetType) {
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SCROLLBARTHUMB_VERTICAL:
|
|
|
|
case NS_THEME_SCROLLBARTHUMB_HORIZONTAL:
|
|
|
|
case NS_THEME_SCROLLBARBUTTON_UP:
|
|
|
|
case NS_THEME_SCROLLBARBUTTON_DOWN:
|
|
|
|
case NS_THEME_SCROLLBARBUTTON_LEFT:
|
|
|
|
case NS_THEME_SCROLLBARBUTTON_RIGHT:
|
2015-12-22 07:05:00 +03:00
|
|
|
case NS_THEME_SCROLLBAR_HORIZONTAL:
|
|
|
|
case NS_THEME_SCROLLBAR_VERTICAL:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_MENULIST_BUTTON: {
|
2015-12-02 23:54:26 +03:00
|
|
|
rv = ClassicGetMinimumWidgetSize(aFrame, aWidgetType, aResult, aIsOverridable);
|
|
|
|
ScaleForFrameDPI(aResult, aFrame);
|
|
|
|
return rv;
|
|
|
|
}
|
2007-08-06 21:45:57 +04:00
|
|
|
case NS_THEME_MENUITEM:
|
|
|
|
case NS_THEME_CHECKMENUITEM:
|
|
|
|
case NS_THEME_RADIOMENUITEM:
|
|
|
|
if(!IsTopLevelMenu(aFrame))
|
|
|
|
{
|
2017-09-06 00:40:00 +03:00
|
|
|
SIZE gutterSize(GetCachedGutterSize(theme));
|
2007-08-06 21:45:57 +04:00
|
|
|
aResult->width = gutterSize.cx;
|
|
|
|
aResult->height = gutterSize.cy;
|
2015-12-02 23:54:26 +03:00
|
|
|
ScaleForFrameDPI(aResult, aFrame);
|
|
|
|
return rv;
|
2007-08-06 21:45:57 +04:00
|
|
|
}
|
|
|
|
break;
|
2010-08-10 05:49:34 +04:00
|
|
|
|
2007-08-06 21:45:57 +04:00
|
|
|
case NS_THEME_MENUIMAGE:
|
|
|
|
case NS_THEME_MENUCHECKBOX:
|
|
|
|
case NS_THEME_MENURADIO:
|
|
|
|
{
|
2017-09-06 00:40:00 +03:00
|
|
|
SIZE boxSize(GetCachedGutterSize(theme));
|
2008-05-09 04:18:46 +04:00
|
|
|
aResult->width = boxSize.cx+2;
|
2007-08-06 21:45:57 +04:00
|
|
|
aResult->height = boxSize.cy;
|
2011-10-02 06:16:19 +04:00
|
|
|
*aIsOverridable = false;
|
2015-12-02 23:54:26 +03:00
|
|
|
ScaleForFrameDPI(aResult, aFrame);
|
|
|
|
return rv;
|
2007-08-06 21:45:57 +04:00
|
|
|
}
|
2010-08-10 05:49:34 +04:00
|
|
|
|
2007-08-06 21:45:57 +04:00
|
|
|
case NS_THEME_MENUITEMTEXT:
|
|
|
|
return NS_OK;
|
2010-08-10 05:49:34 +04:00
|
|
|
|
|
|
|
case NS_THEME_PROGRESSBAR:
|
|
|
|
case NS_THEME_PROGRESSBAR_VERTICAL:
|
|
|
|
// Best-fit size for progress meters is too large for most
|
|
|
|
// themes. We want these widgets to be able to really shrink
|
|
|
|
// down, so use the min-size request value (of 0).
|
|
|
|
sizeReq = TS_MIN;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_THEME_RESIZER:
|
2011-10-02 06:16:19 +04:00
|
|
|
*aIsOverridable = false;
|
2010-08-10 05:49:34 +04:00
|
|
|
break;
|
|
|
|
|
2013-04-03 14:07:12 +04:00
|
|
|
case NS_THEME_RANGE_THUMB:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SCALETHUMB_HORIZONTAL:
|
|
|
|
case NS_THEME_SCALETHUMB_VERTICAL:
|
2010-08-10 05:49:34 +04:00
|
|
|
{
|
2011-10-02 06:16:19 +04:00
|
|
|
*aIsOverridable = false;
|
2016-12-23 05:13:31 +03:00
|
|
|
// On Vista, GetThemePartAndState returns odd values for
|
2010-08-10 05:49:34 +04:00
|
|
|
// scale thumbs, so use a hardcoded size instead.
|
2016-12-23 05:13:31 +03:00
|
|
|
if (aWidgetType == NS_THEME_SCALETHUMB_HORIZONTAL ||
|
|
|
|
(aWidgetType == NS_THEME_RANGE_THUMB && IsRangeHorizontal(aFrame))) {
|
|
|
|
aResult->width = 12;
|
|
|
|
aResult->height = 20;
|
|
|
|
} else {
|
|
|
|
aResult->width = 20;
|
|
|
|
aResult->height = 12;
|
2008-02-06 17:12:24 +03:00
|
|
|
}
|
2016-12-23 05:13:31 +03:00
|
|
|
ScaleForFrameDPI(aResult, aFrame);
|
|
|
|
return rv;
|
2008-02-06 17:12:24 +03:00
|
|
|
}
|
2010-08-10 05:49:34 +04:00
|
|
|
|
2013-11-11 19:19:54 +04:00
|
|
|
case NS_THEME_SCROLLBAR:
|
|
|
|
{
|
|
|
|
if (nsLookAndFeel::GetInt(
|
|
|
|
nsLookAndFeel::eIntID_UseOverlayScrollbars) != 0) {
|
|
|
|
aResult->SizeTo(::GetSystemMetrics(SM_CXHSCROLL),
|
|
|
|
::GetSystemMetrics(SM_CYVSCROLL));
|
2015-12-02 23:54:26 +03:00
|
|
|
ScaleForFrameDPI(aResult, aFrame);
|
|
|
|
return rv;
|
2013-11-11 19:19:54 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SEPARATOR:
|
2010-08-10 05:49:34 +04:00
|
|
|
// that's 2px left margin, 2px right margin and 2px separator
|
|
|
|
// (the margin is drawn as part of the separator, though)
|
|
|
|
aResult->width = 6;
|
2015-12-02 23:54:26 +03:00
|
|
|
ScaleForFrameDPI(aResult, aFrame);
|
|
|
|
return rv;
|
2010-08-10 05:49:34 +04:00
|
|
|
|
|
|
|
case NS_THEME_BUTTON:
|
|
|
|
// We should let HTML buttons shrink to their min size.
|
|
|
|
// FIXME bug 403934: We should probably really separate
|
|
|
|
// GetPreferredWidgetSize from GetMinimumWidgetSize, so callers can
|
|
|
|
// use the one they want.
|
2015-03-03 14:08:59 +03:00
|
|
|
if (aFrame->GetContent()->IsHTMLElement()) {
|
2010-08-10 05:49:34 +04:00
|
|
|
sizeReq = TS_MIN;
|
|
|
|
}
|
|
|
|
break;
|
2010-08-10 05:49:35 +04:00
|
|
|
|
|
|
|
case NS_THEME_WINDOW_BUTTON_MAXIMIZE:
|
|
|
|
case NS_THEME_WINDOW_BUTTON_RESTORE:
|
|
|
|
// The only way to get accurate titlebar button info is to query a
|
|
|
|
// window w/buttons when it's visible. nsWindow takes care of this and
|
|
|
|
// stores that info in nsUXThemeData.
|
2017-06-12 23:11:44 +03:00
|
|
|
aResult->width = nsUXThemeData::GetCommandButtonMetrics(CMDBUTTONIDX_RESTORE).cx;
|
|
|
|
aResult->height = nsUXThemeData::GetCommandButtonMetrics(CMDBUTTONIDX_RESTORE).cy;
|
2010-11-29 19:19:17 +03:00
|
|
|
AddPaddingRect(aResult, CAPTIONBUTTON_RESTORE);
|
2011-10-02 06:16:19 +04:00
|
|
|
*aIsOverridable = false;
|
2015-12-02 23:54:26 +03:00
|
|
|
return rv;
|
2010-08-10 05:49:35 +04:00
|
|
|
|
|
|
|
case NS_THEME_WINDOW_BUTTON_MINIMIZE:
|
2017-06-12 23:11:44 +03:00
|
|
|
aResult->width = nsUXThemeData::GetCommandButtonMetrics(CMDBUTTONIDX_MINIMIZE).cx;
|
|
|
|
aResult->height = nsUXThemeData::GetCommandButtonMetrics(CMDBUTTONIDX_MINIMIZE).cy;
|
2010-11-29 19:19:17 +03:00
|
|
|
AddPaddingRect(aResult, CAPTIONBUTTON_MINIMIZE);
|
2011-10-02 06:16:19 +04:00
|
|
|
*aIsOverridable = false;
|
2015-12-02 23:54:26 +03:00
|
|
|
return rv;
|
2010-08-10 05:49:35 +04:00
|
|
|
|
|
|
|
case NS_THEME_WINDOW_BUTTON_CLOSE:
|
2017-06-12 23:11:44 +03:00
|
|
|
aResult->width = nsUXThemeData::GetCommandButtonMetrics(CMDBUTTONIDX_CLOSE).cx;
|
|
|
|
aResult->height = nsUXThemeData::GetCommandButtonMetrics(CMDBUTTONIDX_CLOSE).cy;
|
2010-11-29 19:19:17 +03:00
|
|
|
AddPaddingRect(aResult, CAPTIONBUTTON_CLOSE);
|
2011-10-02 06:16:19 +04:00
|
|
|
*aIsOverridable = false;
|
2015-12-02 23:54:26 +03:00
|
|
|
return rv;
|
2010-08-10 05:49:35 +04:00
|
|
|
|
|
|
|
case NS_THEME_WINDOW_TITLEBAR:
|
|
|
|
case NS_THEME_WINDOW_TITLEBAR_MAXIMIZED:
|
|
|
|
aResult->height = GetSystemMetrics(SM_CYCAPTION);
|
|
|
|
aResult->height += GetSystemMetrics(SM_CYFRAME);
|
2012-11-17 03:34:31 +04:00
|
|
|
aResult->height += GetSystemMetrics(SM_CXPADDEDBORDER);
|
2016-05-17 17:35:58 +03:00
|
|
|
// On Win8.1, we don't want this scaling, because Windows doesn't scale
|
|
|
|
// the non-client area of the window, and we can end up with ugly overlap
|
|
|
|
// of the window frame controls into the tab bar or content area. But on
|
|
|
|
// Win10, we render the window controls ourselves, and the result looks
|
|
|
|
// better if we do apply this scaling (particularly with themes such as
|
|
|
|
// DevEdition; see bug 1267636).
|
|
|
|
if (IsWin10OrLater()) {
|
|
|
|
ScaleForFrameDPI(aResult, aFrame);
|
|
|
|
}
|
2011-10-02 06:16:19 +04:00
|
|
|
*aIsOverridable = false;
|
2015-12-02 23:54:26 +03:00
|
|
|
return rv;
|
2010-08-10 05:49:35 +04:00
|
|
|
|
2010-10-19 21:02:24 +04:00
|
|
|
case NS_THEME_WINDOW_BUTTON_BOX:
|
|
|
|
case NS_THEME_WINDOW_BUTTON_BOX_MAXIMIZED:
|
2010-10-22 21:08:39 +04:00
|
|
|
if (nsUXThemeData::CheckForCompositor()) {
|
2017-06-12 23:11:44 +03:00
|
|
|
aResult->width = nsUXThemeData::GetCommandButtonBoxMetrics().cx;
|
|
|
|
aResult->height = nsUXThemeData::GetCommandButtonBoxMetrics().cy
|
2012-11-17 03:34:31 +04:00
|
|
|
- GetSystemMetrics(SM_CYFRAME)
|
|
|
|
- GetSystemMetrics(SM_CXPADDEDBORDER);
|
2010-10-22 21:08:39 +04:00
|
|
|
if (aWidgetType == NS_THEME_WINDOW_BUTTON_BOX_MAXIMIZED) {
|
|
|
|
aResult->width += 1;
|
|
|
|
aResult->height -= 2;
|
|
|
|
}
|
2011-10-02 06:16:19 +04:00
|
|
|
*aIsOverridable = false;
|
2015-12-02 23:54:26 +03:00
|
|
|
return rv;
|
2010-10-19 21:02:24 +04:00
|
|
|
}
|
2010-10-22 21:08:39 +04:00
|
|
|
break;
|
2010-10-19 21:02:24 +04:00
|
|
|
|
2010-08-10 05:49:35 +04:00
|
|
|
case NS_THEME_WINDOW_FRAME_LEFT:
|
|
|
|
case NS_THEME_WINDOW_FRAME_RIGHT:
|
|
|
|
case NS_THEME_WINDOW_FRAME_BOTTOM:
|
|
|
|
aResult->width = GetSystemMetrics(SM_CXFRAME);
|
|
|
|
aResult->height = GetSystemMetrics(SM_CYFRAME);
|
2011-10-02 06:16:19 +04:00
|
|
|
*aIsOverridable = false;
|
2015-12-02 23:54:26 +03:00
|
|
|
return rv;
|
2007-08-26 00:30:43 +04:00
|
|
|
}
|
2006-05-30 17:50:48 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t part, state;
|
2015-12-02 23:54:26 +03:00
|
|
|
rv = GetThemePartAndState(aFrame, aWidgetType, part, state);
|
2005-08-20 11:11:56 +04:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
2017-06-22 23:19:13 +03:00
|
|
|
rv = GetCachedMinimumWidgetSize(aFrame, theme, themeClass.value(), aWidgetType, part,
|
|
|
|
state, sizeReq, aResult);
|
2015-12-02 23:54:26 +03:00
|
|
|
|
|
|
|
ScaleForFrameDPI(aResult, aFrame);
|
|
|
|
return rv;
|
2005-08-20 11:11:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsNativeThemeWin::WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* aAttribute, bool* aShouldRepaint,
|
2016-04-21 02:49:09 +03:00
|
|
|
const nsAttrValue* aOldValue)
|
2005-08-20 11:11:56 +04:00
|
|
|
{
|
|
|
|
// Some widget types just never change state.
|
2008-02-29 08:10:38 +03:00
|
|
|
if (aWidgetType == NS_THEME_TOOLBOX ||
|
2008-05-08 13:29:38 +04:00
|
|
|
aWidgetType == NS_THEME_WIN_MEDIA_TOOLBOX ||
|
|
|
|
aWidgetType == NS_THEME_WIN_COMMUNICATIONS_TOOLBOX ||
|
2016-05-18 20:29:56 +03:00
|
|
|
aWidgetType == NS_THEME_WIN_BROWSERTABBAR_TOOLBOX ||
|
2008-02-29 08:10:38 +03:00
|
|
|
aWidgetType == NS_THEME_TOOLBAR ||
|
2016-05-18 20:29:56 +03:00
|
|
|
aWidgetType == NS_THEME_STATUSBAR || aWidgetType == NS_THEME_STATUSBARPANEL ||
|
2016-05-19 11:58:00 +03:00
|
|
|
aWidgetType == NS_THEME_RESIZERPANEL ||
|
2016-05-18 20:29:56 +03:00
|
|
|
aWidgetType == NS_THEME_PROGRESSCHUNK ||
|
|
|
|
aWidgetType == NS_THEME_PROGRESSCHUNK_VERTICAL ||
|
2005-08-20 11:11:59 +04:00
|
|
|
aWidgetType == NS_THEME_PROGRESSBAR ||
|
2005-08-20 11:12:00 +04:00
|
|
|
aWidgetType == NS_THEME_PROGRESSBAR_VERTICAL ||
|
2005-08-20 11:12:02 +04:00
|
|
|
aWidgetType == NS_THEME_TOOLTIP ||
|
2016-05-18 20:29:56 +03:00
|
|
|
aWidgetType == NS_THEME_TABPANELS ||
|
|
|
|
aWidgetType == NS_THEME_TABPANEL ||
|
|
|
|
aWidgetType == NS_THEME_SEPARATOR ||
|
2010-10-19 21:02:25 +04:00
|
|
|
aWidgetType == NS_THEME_WIN_GLASS ||
|
|
|
|
aWidgetType == NS_THEME_WIN_BORDERLESS_GLASS) {
|
2011-10-02 06:16:19 +04:00
|
|
|
*aShouldRepaint = false;
|
2005-08-20 11:11:56 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-08-10 05:49:35 +04:00
|
|
|
if (aWidgetType == NS_THEME_WINDOW_TITLEBAR ||
|
|
|
|
aWidgetType == NS_THEME_WINDOW_TITLEBAR_MAXIMIZED ||
|
|
|
|
aWidgetType == NS_THEME_WINDOW_FRAME_LEFT ||
|
|
|
|
aWidgetType == NS_THEME_WINDOW_FRAME_RIGHT ||
|
|
|
|
aWidgetType == NS_THEME_WINDOW_FRAME_BOTTOM ||
|
|
|
|
aWidgetType == NS_THEME_WINDOW_BUTTON_CLOSE ||
|
|
|
|
aWidgetType == NS_THEME_WINDOW_BUTTON_MINIMIZE ||
|
2014-06-20 02:52:02 +04:00
|
|
|
aWidgetType == NS_THEME_WINDOW_BUTTON_MAXIMIZE ||
|
2010-08-10 05:49:35 +04:00
|
|
|
aWidgetType == NS_THEME_WINDOW_BUTTON_RESTORE) {
|
2011-10-02 06:16:19 +04:00
|
|
|
*aShouldRepaint = true;
|
2010-08-10 05:49:35 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-03-06 03:23:38 +03:00
|
|
|
// We need to repaint the dropdown arrow in vista HTML combobox controls when
|
|
|
|
// the control is closed to get rid of the hover effect.
|
2016-12-23 05:13:31 +03:00
|
|
|
if ((aWidgetType == NS_THEME_MENULIST || aWidgetType == NS_THEME_MENULIST_BUTTON) &&
|
2008-03-06 03:23:38 +03:00
|
|
|
IsHTMLContent(aFrame))
|
|
|
|
{
|
2011-10-02 06:16:19 +04:00
|
|
|
*aShouldRepaint = true;
|
2008-03-06 03:23:38 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:56 +04:00
|
|
|
// XXXdwh Not sure what can really be done here. Can at least guess for
|
|
|
|
// specific widgets that they're highly unlikely to have certain states.
|
|
|
|
// For example, a toolbar doesn't care about any states.
|
|
|
|
if (!aAttribute) {
|
|
|
|
// Hover/focus/active changed. Always repaint.
|
2011-10-02 06:16:19 +04:00
|
|
|
*aShouldRepaint = true;
|
2005-08-20 11:11:56 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Check the attribute to see if it's relevant.
|
|
|
|
// disabled, checked, dlgtype, default, etc.
|
2011-10-02 06:16:19 +04:00
|
|
|
*aShouldRepaint = false;
|
2011-10-14 22:11:22 +04:00
|
|
|
if (aAttribute == nsGkAtoms::disabled ||
|
|
|
|
aAttribute == nsGkAtoms::checked ||
|
|
|
|
aAttribute == nsGkAtoms::selected ||
|
2015-03-16 21:30:41 +03:00
|
|
|
aAttribute == nsGkAtoms::visuallyselected ||
|
2011-10-14 22:11:22 +04:00
|
|
|
aAttribute == nsGkAtoms::readonly ||
|
|
|
|
aAttribute == nsGkAtoms::open ||
|
|
|
|
aAttribute == nsGkAtoms::menuactive ||
|
|
|
|
aAttribute == nsGkAtoms::focused)
|
2011-10-02 06:16:19 +04:00
|
|
|
*aShouldRepaint = true;
|
2005-08-20 11:11:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsNativeThemeWin::ThemeChanged()
|
|
|
|
{
|
2008-07-17 21:19:10 +04:00
|
|
|
nsUXThemeData::Invalidate();
|
2017-06-21 23:43:27 +03:00
|
|
|
memset(mBorderCacheValid, 0, sizeof(mBorderCacheValid));
|
2017-06-22 23:19:13 +03:00
|
|
|
memset(mMinimumWidgetSizeCacheValid, 0, sizeof(mMinimumWidgetSizeCacheValid));
|
2017-09-06 00:40:00 +03:00
|
|
|
mGutterSizeCacheValid = false;
|
2005-08-20 11:11:56 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2005-08-20 11:14:04 +04:00
|
|
|
nsNativeThemeWin::ThemeSupportsWidget(nsPresContext* aPresContext,
|
2005-08-20 11:13:11 +04:00
|
|
|
nsIFrame* aFrame,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t aWidgetType)
|
2005-08-20 11:13:11 +04:00
|
|
|
{
|
|
|
|
// XXXdwh We can go even further and call the API to ask if support exists for
|
|
|
|
// specific widgets.
|
|
|
|
|
2014-06-14 16:48:08 +04:00
|
|
|
if (aWidgetType == NS_THEME_FOCUS_OUTLINE) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-10-08 22:48:20 +04:00
|
|
|
HANDLE theme = nullptr;
|
2005-08-20 11:13:11 +04:00
|
|
|
if (aWidgetType == NS_THEME_CHECKBOX_CONTAINER)
|
|
|
|
theme = GetTheme(NS_THEME_CHECKBOX);
|
|
|
|
else if (aWidgetType == NS_THEME_RADIO_CONTAINER)
|
|
|
|
theme = GetTheme(NS_THEME_RADIO);
|
|
|
|
else
|
|
|
|
theme = GetTheme(aWidgetType);
|
2015-12-07 04:15:53 +03:00
|
|
|
|
2014-10-09 10:55:00 +04:00
|
|
|
if (theme && aWidgetType == NS_THEME_RESIZER)
|
|
|
|
return true;
|
2005-08-20 11:13:11 +04:00
|
|
|
|
2015-12-07 04:15:53 +03:00
|
|
|
if ((theme) || (!theme && ClassicThemeSupportsWidget(aFrame, aWidgetType)))
|
2005-08-20 11:13:11 +04:00
|
|
|
// turn off theming for some HTML widgets styled by the page
|
2005-08-20 11:13:24 +04:00
|
|
|
return (!IsWidgetStyled(aPresContext, aFrame, aWidgetType));
|
2015-12-07 04:15:53 +03:00
|
|
|
|
2011-10-02 06:16:19 +04:00
|
|
|
return false;
|
2005-08-20 11:11:56 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2012-08-22 19:56:38 +04:00
|
|
|
nsNativeThemeWin::WidgetIsContainer(uint8_t aWidgetType)
|
2005-08-20 11:12:07 +04:00
|
|
|
{
|
|
|
|
// XXXdwh At some point flesh all of this out.
|
2016-05-18 20:29:56 +03:00
|
|
|
if (aWidgetType == NS_THEME_MENULIST_BUTTON ||
|
2008-11-03 16:12:59 +03:00
|
|
|
aWidgetType == NS_THEME_RADIO ||
|
|
|
|
aWidgetType == NS_THEME_CHECKBOX)
|
2011-10-02 06:16:19 +04:00
|
|
|
return false;
|
|
|
|
return true;
|
2005-08-20 11:12:07 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2013-05-14 03:47:03 +04:00
|
|
|
nsNativeThemeWin::ThemeDrawsFocusForWidget(uint8_t aWidgetType)
|
2007-02-16 04:53:43 +03:00
|
|
|
{
|
2011-10-02 06:16:19 +04:00
|
|
|
return false;
|
2007-02-16 04:53:43 +03:00
|
|
|
}
|
2005-08-20 11:13:11 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2007-05-18 07:04:04 +04:00
|
|
|
nsNativeThemeWin::ThemeNeedsComboboxDropmarker()
|
|
|
|
{
|
2011-10-02 06:16:19 +04:00
|
|
|
return true;
|
2007-05-18 07:04:04 +04:00
|
|
|
}
|
|
|
|
|
2013-09-27 19:24:32 +04:00
|
|
|
bool
|
|
|
|
nsNativeThemeWin::WidgetAppearanceDependsOnWindowFocus(uint8_t aWidgetType)
|
|
|
|
{
|
|
|
|
switch (aWidgetType) {
|
|
|
|
case NS_THEME_WINDOW_TITLEBAR:
|
|
|
|
case NS_THEME_WINDOW_TITLEBAR_MAXIMIZED:
|
|
|
|
case NS_THEME_WINDOW_FRAME_LEFT:
|
|
|
|
case NS_THEME_WINDOW_FRAME_RIGHT:
|
|
|
|
case NS_THEME_WINDOW_FRAME_BOTTOM:
|
|
|
|
case NS_THEME_WINDOW_BUTTON_CLOSE:
|
|
|
|
case NS_THEME_WINDOW_BUTTON_MINIMIZE:
|
|
|
|
case NS_THEME_WINDOW_BUTTON_MAXIMIZE:
|
|
|
|
case NS_THEME_WINDOW_BUTTON_RESTORE:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-05 01:25:18 +03:00
|
|
|
nsITheme::ThemeGeometryType
|
|
|
|
nsNativeThemeWin::ThemeGeometryTypeForWidget(nsIFrame* aFrame,
|
|
|
|
uint8_t aWidgetType)
|
|
|
|
{
|
|
|
|
switch (aWidgetType) {
|
|
|
|
case NS_THEME_WINDOW_BUTTON_BOX:
|
|
|
|
case NS_THEME_WINDOW_BUTTON_BOX_MAXIMIZED:
|
|
|
|
return eThemeGeometryTypeWindowButtons;
|
|
|
|
default:
|
|
|
|
return eThemeGeometryTypeUnknown;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-03 22:21:09 +04:00
|
|
|
bool
|
|
|
|
nsNativeThemeWin::ShouldHideScrollbars()
|
|
|
|
{
|
|
|
|
return WinUtils::ShouldHideScrollbars();
|
|
|
|
}
|
|
|
|
|
2010-06-11 02:53:57 +04:00
|
|
|
nsITheme::Transparency
|
2012-08-22 19:56:38 +04:00
|
|
|
nsNativeThemeWin::GetWidgetTransparency(nsIFrame* aFrame, uint8_t aWidgetType)
|
2008-12-11 17:37:38 +03:00
|
|
|
{
|
2010-08-28 03:15:08 +04:00
|
|
|
switch (aWidgetType) {
|
|
|
|
case NS_THEME_SCROLLBAR_SMALL:
|
|
|
|
case NS_THEME_SCROLLBAR:
|
|
|
|
case NS_THEME_STATUSBAR:
|
|
|
|
// Knowing that scrollbars and statusbars are opaque improves
|
|
|
|
// performance, because we create layers for them. This better be
|
|
|
|
// true across all Windows themes! If it's not true, we should
|
|
|
|
// paint an opaque background for them to make it true!
|
|
|
|
return eOpaque;
|
2010-10-19 21:02:25 +04:00
|
|
|
case NS_THEME_WIN_GLASS:
|
|
|
|
case NS_THEME_WIN_BORDERLESS_GLASS:
|
2011-01-28 00:10:52 +03:00
|
|
|
case NS_THEME_SCALE_HORIZONTAL:
|
|
|
|
case NS_THEME_SCALE_VERTICAL:
|
2013-02-25 04:16:16 +04:00
|
|
|
case NS_THEME_PROGRESSBAR:
|
|
|
|
case NS_THEME_PROGRESSBAR_VERTICAL:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_PROGRESSCHUNK:
|
|
|
|
case NS_THEME_PROGRESSCHUNK_VERTICAL:
|
2013-04-03 14:07:12 +04:00
|
|
|
case NS_THEME_RANGE:
|
2010-10-19 21:02:25 +04:00
|
|
|
return eTransparent;
|
2010-08-28 03:15:08 +04:00
|
|
|
}
|
|
|
|
|
2010-06-11 02:53:57 +04:00
|
|
|
HANDLE theme = GetTheme(aWidgetType);
|
|
|
|
// For the classic theme we don't really have a way of knowing
|
2011-02-11 00:15:51 +03:00
|
|
|
if (!theme) {
|
2011-02-16 01:01:25 +03:00
|
|
|
// menu backgrounds and tooltips which can't be themed are opaque
|
|
|
|
if (aWidgetType == NS_THEME_MENUPOPUP || aWidgetType == NS_THEME_TOOLTIP) {
|
2011-02-11 00:15:51 +03:00
|
|
|
return eOpaque;
|
|
|
|
}
|
2010-06-11 02:53:57 +04:00
|
|
|
return eUnknownTransparency;
|
2011-02-11 00:15:51 +03:00
|
|
|
}
|
2010-06-11 02:53:57 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t part, state;
|
2010-06-11 02:53:57 +04:00
|
|
|
nsresult rv = GetThemePartAndState(aFrame, aWidgetType, part, state);
|
|
|
|
// Fail conservatively
|
|
|
|
NS_ENSURE_SUCCESS(rv, eUnknownTransparency);
|
|
|
|
|
|
|
|
if (part <= 0) {
|
2012-02-23 18:53:55 +04:00
|
|
|
// Not a real part code, so IsThemeBackgroundPartiallyTransparent may
|
2010-06-11 02:53:57 +04:00
|
|
|
// not work, so don't call it.
|
|
|
|
return eUnknownTransparency;
|
|
|
|
}
|
|
|
|
|
2012-02-23 18:53:55 +04:00
|
|
|
if (IsThemeBackgroundPartiallyTransparent(theme, part, state))
|
2010-06-11 02:53:57 +04:00
|
|
|
return eTransparent;
|
|
|
|
return eOpaque;
|
2008-12-11 17:37:38 +03:00
|
|
|
}
|
|
|
|
|
2005-08-20 11:13:11 +04:00
|
|
|
/* Windows 9x/NT/2000/Classic XP Theme Support */
|
|
|
|
|
2015-12-07 04:15:53 +03:00
|
|
|
bool
|
|
|
|
nsNativeThemeWin::ClassicThemeSupportsWidget(nsIFrame* aFrame,
|
|
|
|
uint8_t aWidgetType)
|
2005-08-20 11:13:11 +04:00
|
|
|
{
|
|
|
|
switch (aWidgetType) {
|
2010-06-21 16:37:35 +04:00
|
|
|
case NS_THEME_RESIZER:
|
|
|
|
{
|
|
|
|
// The classic native resizer has an opaque grey background which doesn't
|
|
|
|
// match the usually white background of the scrollable container, so
|
|
|
|
// only support the native resizer if not in a scrollframe.
|
|
|
|
nsIFrame* parentFrame = aFrame->GetParent();
|
2017-04-30 18:30:08 +03:00
|
|
|
return !parentFrame || !parentFrame->IsScrollFrame();
|
2010-06-21 16:37:35 +04:00
|
|
|
}
|
2007-07-14 19:11:37 +04:00
|
|
|
case NS_THEME_MENUBAR:
|
|
|
|
case NS_THEME_MENUPOPUP:
|
|
|
|
// Classic non-flat menus are handled almost entirely through CSS.
|
2008-07-17 21:19:10 +04:00
|
|
|
if (!nsUXThemeData::sFlatMenus)
|
2011-10-02 06:16:19 +04:00
|
|
|
return false;
|
2005-08-20 11:13:11 +04:00
|
|
|
case NS_THEME_BUTTON:
|
2013-12-09 03:23:28 +04:00
|
|
|
case NS_THEME_NUMBER_INPUT:
|
2005-08-20 11:13:11 +04:00
|
|
|
case NS_THEME_TEXTFIELD:
|
2007-05-07 06:06:58 +04:00
|
|
|
case NS_THEME_TEXTFIELD_MULTILINE:
|
2005-08-20 11:13:11 +04:00
|
|
|
case NS_THEME_CHECKBOX:
|
|
|
|
case NS_THEME_RADIO:
|
2013-04-03 14:07:12 +04:00
|
|
|
case NS_THEME_RANGE:
|
|
|
|
case NS_THEME_RANGE_THUMB:
|
2009-03-12 05:11:01 +03:00
|
|
|
case NS_THEME_GROUPBOX:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SCROLLBARBUTTON_UP:
|
|
|
|
case NS_THEME_SCROLLBARBUTTON_DOWN:
|
|
|
|
case NS_THEME_SCROLLBARBUTTON_LEFT:
|
|
|
|
case NS_THEME_SCROLLBARBUTTON_RIGHT:
|
|
|
|
case NS_THEME_SCROLLBARTHUMB_VERTICAL:
|
|
|
|
case NS_THEME_SCROLLBARTHUMB_HORIZONTAL:
|
2015-12-22 07:05:00 +03:00
|
|
|
case NS_THEME_SCROLLBAR_VERTICAL:
|
|
|
|
case NS_THEME_SCROLLBAR_HORIZONTAL:
|
2013-11-22 22:57:26 +04:00
|
|
|
case NS_THEME_SCROLLBAR_NON_DISAPPEARING:
|
2006-05-30 17:50:48 +04:00
|
|
|
case NS_THEME_SCALE_HORIZONTAL:
|
|
|
|
case NS_THEME_SCALE_VERTICAL:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SCALETHUMB_HORIZONTAL:
|
|
|
|
case NS_THEME_SCALETHUMB_VERTICAL:
|
|
|
|
case NS_THEME_MENULIST_BUTTON:
|
2017-11-29 05:43:13 +03:00
|
|
|
case NS_THEME_INNER_SPIN_BUTTON:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SPINNER_UPBUTTON:
|
|
|
|
case NS_THEME_SPINNER_DOWNBUTTON:
|
2005-08-20 11:13:11 +04:00
|
|
|
case NS_THEME_LISTBOX:
|
|
|
|
case NS_THEME_TREEVIEW:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_MENULIST_TEXTFIELD:
|
|
|
|
case NS_THEME_MENULIST:
|
2005-08-20 11:13:11 +04:00
|
|
|
case NS_THEME_TOOLTIP:
|
|
|
|
case NS_THEME_STATUSBAR:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_STATUSBARPANEL:
|
2016-05-19 11:58:00 +03:00
|
|
|
case NS_THEME_RESIZERPANEL:
|
2005-08-20 11:13:11 +04:00
|
|
|
case NS_THEME_PROGRESSBAR:
|
|
|
|
case NS_THEME_PROGRESSBAR_VERTICAL:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_PROGRESSCHUNK:
|
|
|
|
case NS_THEME_PROGRESSCHUNK_VERTICAL:
|
2005-08-20 11:13:11 +04:00
|
|
|
case NS_THEME_TAB:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_TABPANEL:
|
|
|
|
case NS_THEME_TABPANELS:
|
2005-10-07 04:31:36 +04:00
|
|
|
case NS_THEME_MENUITEM:
|
|
|
|
case NS_THEME_CHECKMENUITEM:
|
|
|
|
case NS_THEME_RADIOMENUITEM:
|
2007-07-14 19:11:37 +04:00
|
|
|
case NS_THEME_MENUCHECKBOX:
|
|
|
|
case NS_THEME_MENURADIO:
|
|
|
|
case NS_THEME_MENUARROW:
|
2007-08-06 21:45:57 +04:00
|
|
|
case NS_THEME_MENUSEPARATOR:
|
|
|
|
case NS_THEME_MENUITEMTEXT:
|
2010-08-10 05:49:35 +04:00
|
|
|
case NS_THEME_WINDOW_TITLEBAR:
|
|
|
|
case NS_THEME_WINDOW_TITLEBAR_MAXIMIZED:
|
|
|
|
case NS_THEME_WINDOW_FRAME_LEFT:
|
|
|
|
case NS_THEME_WINDOW_FRAME_RIGHT:
|
|
|
|
case NS_THEME_WINDOW_FRAME_BOTTOM:
|
|
|
|
case NS_THEME_WINDOW_BUTTON_CLOSE:
|
|
|
|
case NS_THEME_WINDOW_BUTTON_MINIMIZE:
|
|
|
|
case NS_THEME_WINDOW_BUTTON_MAXIMIZE:
|
|
|
|
case NS_THEME_WINDOW_BUTTON_RESTORE:
|
2010-08-10 05:49:35 +04:00
|
|
|
case NS_THEME_WINDOW_BUTTON_BOX:
|
|
|
|
case NS_THEME_WINDOW_BUTTON_BOX_MAXIMIZED:
|
2011-10-02 06:16:19 +04:00
|
|
|
return true;
|
2005-08-20 11:13:11 +04:00
|
|
|
}
|
2011-10-02 06:16:19 +04:00
|
|
|
return false;
|
2005-08-20 11:13:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2011-04-17 05:22:44 +04:00
|
|
|
nsNativeThemeWin::ClassicGetWidgetBorder(nsDeviceContext* aContext,
|
2005-08-20 11:13:11 +04:00
|
|
|
nsIFrame* aFrame,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t aWidgetType,
|
2009-01-15 06:27:09 +03:00
|
|
|
nsIntMargin* aResult)
|
2005-08-20 11:13:11 +04:00
|
|
|
{
|
|
|
|
switch (aWidgetType) {
|
2009-03-12 05:11:01 +03:00
|
|
|
case NS_THEME_GROUPBOX:
|
2007-10-01 20:40:35 +04:00
|
|
|
case NS_THEME_BUTTON:
|
|
|
|
(*aResult).top = (*aResult).left = (*aResult).bottom = (*aResult).right = 2;
|
|
|
|
break;
|
2005-08-20 11:13:11 +04:00
|
|
|
case NS_THEME_STATUSBAR:
|
|
|
|
(*aResult).bottom = (*aResult).left = (*aResult).right = 0;
|
|
|
|
(*aResult).top = 2;
|
|
|
|
break;
|
|
|
|
case NS_THEME_LISTBOX:
|
|
|
|
case NS_THEME_TREEVIEW:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_MENULIST:
|
|
|
|
case NS_THEME_MENULIST_TEXTFIELD:
|
2005-08-20 11:13:11 +04:00
|
|
|
case NS_THEME_TAB:
|
2013-12-09 03:23:28 +04:00
|
|
|
case NS_THEME_NUMBER_INPUT:
|
2006-03-15 14:59:22 +03:00
|
|
|
case NS_THEME_TEXTFIELD:
|
2007-05-07 06:06:58 +04:00
|
|
|
case NS_THEME_TEXTFIELD_MULTILINE:
|
2014-06-14 16:48:08 +04:00
|
|
|
case NS_THEME_FOCUS_OUTLINE:
|
2005-08-20 11:13:11 +04:00
|
|
|
(*aResult).top = (*aResult).left = (*aResult).bottom = (*aResult).right = 2;
|
|
|
|
break;
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_STATUSBARPANEL:
|
2016-05-19 11:58:00 +03:00
|
|
|
case NS_THEME_RESIZERPANEL: {
|
2005-08-20 11:13:11 +04:00
|
|
|
(*aResult).top = 1;
|
|
|
|
(*aResult).left = 1;
|
|
|
|
(*aResult).bottom = 1;
|
2005-08-20 11:13:33 +04:00
|
|
|
(*aResult).right = aFrame->GetNextSibling() ? 3 : 1;
|
2005-08-20 11:13:11 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NS_THEME_TOOLTIP:
|
|
|
|
(*aResult).top = (*aResult).left = (*aResult).bottom = (*aResult).right = 1;
|
|
|
|
break;
|
2005-08-20 11:14:29 +04:00
|
|
|
case NS_THEME_PROGRESSBAR:
|
|
|
|
case NS_THEME_PROGRESSBAR_VERTICAL:
|
|
|
|
(*aResult).top = (*aResult).left = (*aResult).bottom = (*aResult).right = 1;
|
|
|
|
break;
|
2005-10-07 04:31:36 +04:00
|
|
|
case NS_THEME_MENUBAR:
|
|
|
|
(*aResult).top = (*aResult).left = (*aResult).bottom = (*aResult).right = 0;
|
|
|
|
break;
|
|
|
|
case NS_THEME_MENUPOPUP:
|
2007-07-14 19:11:37 +04:00
|
|
|
(*aResult).top = (*aResult).left = (*aResult).bottom = (*aResult).right = 3;
|
2005-10-07 04:31:36 +04:00
|
|
|
break;
|
2011-06-22 14:32:50 +04:00
|
|
|
default:
|
|
|
|
(*aResult).top = (*aResult).bottom = (*aResult).left = (*aResult).right = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2011-06-22 14:32:50 +04:00
|
|
|
nsNativeThemeWin::ClassicGetWidgetPadding(nsDeviceContext* aContext,
|
|
|
|
nsIFrame* aFrame,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t aWidgetType,
|
2011-06-22 14:32:50 +04:00
|
|
|
nsIntMargin* aResult)
|
|
|
|
{
|
|
|
|
switch (aWidgetType) {
|
2005-10-07 04:31:36 +04:00
|
|
|
case NS_THEME_MENUITEM:
|
|
|
|
case NS_THEME_CHECKMENUITEM:
|
|
|
|
case NS_THEME_RADIOMENUITEM: {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t part, state;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool focused;
|
2005-10-07 04:31:36 +04:00
|
|
|
|
2011-06-22 14:32:50 +04:00
|
|
|
if (NS_FAILED(ClassicGetThemePartAndState(aFrame, aWidgetType, part, state, focused)))
|
2011-10-02 06:16:19 +04:00
|
|
|
return false;
|
2005-10-07 04:31:36 +04:00
|
|
|
|
2011-06-22 14:32:50 +04:00
|
|
|
if (part == 1) { // top-level menu
|
2008-07-17 21:19:10 +04:00
|
|
|
if (nsUXThemeData::sFlatMenus || !(state & DFCS_PUSHED)) {
|
2007-07-14 19:11:37 +04:00
|
|
|
(*aResult).top = (*aResult).bottom = (*aResult).left = (*aResult).right = 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// make top-level menus look sunken when pushed in the Classic look
|
|
|
|
(*aResult).top = (*aResult).left = 3;
|
|
|
|
(*aResult).bottom = (*aResult).right = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2008-09-05 07:20:18 +04:00
|
|
|
(*aResult).top = 0;
|
|
|
|
(*aResult).bottom = (*aResult).left = (*aResult).right = 2;
|
2005-10-07 04:31:36 +04:00
|
|
|
}
|
2011-10-02 06:16:19 +04:00
|
|
|
return true;
|
2005-10-07 04:31:36 +04:00
|
|
|
}
|
2011-06-22 22:44:18 +04:00
|
|
|
case NS_THEME_PROGRESSBAR:
|
|
|
|
case NS_THEME_PROGRESSBAR_VERTICAL:
|
|
|
|
(*aResult).top = (*aResult).left = (*aResult).bottom = (*aResult).right = 1;
|
2011-10-02 06:16:19 +04:00
|
|
|
return true;
|
2005-08-20 11:13:11 +04:00
|
|
|
default:
|
2011-10-02 06:16:19 +04:00
|
|
|
return false;
|
2005-08-20 11:13:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2015-12-07 04:15:53 +03:00
|
|
|
nsNativeThemeWin::ClassicGetMinimumWidgetSize(nsIFrame* aFrame,
|
|
|
|
uint8_t aWidgetType,
|
|
|
|
LayoutDeviceIntSize* aResult,
|
|
|
|
bool* aIsOverridable)
|
2005-08-20 11:13:11 +04:00
|
|
|
{
|
|
|
|
(*aResult).width = (*aResult).height = 0;
|
2011-10-02 06:16:19 +04:00
|
|
|
*aIsOverridable = true;
|
2005-08-20 11:13:11 +04:00
|
|
|
switch (aWidgetType) {
|
|
|
|
case NS_THEME_RADIO:
|
2007-05-09 23:17:17 +04:00
|
|
|
case NS_THEME_CHECKBOX:
|
2005-08-20 11:13:11 +04:00
|
|
|
(*aResult).width = (*aResult).height = 13;
|
|
|
|
break;
|
2007-07-14 19:11:37 +04:00
|
|
|
case NS_THEME_MENUCHECKBOX:
|
|
|
|
case NS_THEME_MENURADIO:
|
|
|
|
case NS_THEME_MENUARROW:
|
|
|
|
(*aResult).width = ::GetSystemMetrics(SM_CXMENUCHECK);
|
|
|
|
(*aResult).height = ::GetSystemMetrics(SM_CYMENUCHECK);
|
|
|
|
break;
|
2017-11-29 05:43:13 +03:00
|
|
|
case NS_THEME_INNER_SPIN_BUTTON:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SPINNER_UPBUTTON:
|
|
|
|
case NS_THEME_SPINNER_DOWNBUTTON:
|
2014-02-04 05:10:37 +04:00
|
|
|
(*aResult).width = ::GetSystemMetrics(SM_CXVSCROLL);
|
|
|
|
(*aResult).height = 8; // No good metrics available for this
|
|
|
|
*aIsOverridable = false;
|
|
|
|
break;
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SCROLLBARBUTTON_UP:
|
|
|
|
case NS_THEME_SCROLLBARBUTTON_DOWN:
|
2005-08-20 11:13:11 +04:00
|
|
|
(*aResult).width = ::GetSystemMetrics(SM_CXVSCROLL);
|
|
|
|
(*aResult).height = ::GetSystemMetrics(SM_CYVSCROLL);
|
2011-10-02 06:16:19 +04:00
|
|
|
*aIsOverridable = false;
|
2005-08-20 11:13:11 +04:00
|
|
|
break;
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SCROLLBARBUTTON_LEFT:
|
|
|
|
case NS_THEME_SCROLLBARBUTTON_RIGHT:
|
2005-08-20 11:13:11 +04:00
|
|
|
(*aResult).width = ::GetSystemMetrics(SM_CXHSCROLL);
|
|
|
|
(*aResult).height = ::GetSystemMetrics(SM_CYHSCROLL);
|
2011-10-02 06:16:19 +04:00
|
|
|
*aIsOverridable = false;
|
2005-08-20 11:13:11 +04:00
|
|
|
break;
|
2015-12-22 07:05:00 +03:00
|
|
|
case NS_THEME_SCROLLBAR_VERTICAL:
|
2005-08-20 11:13:32 +04:00
|
|
|
// XXX HACK We should be able to have a minimum height for the scrollbar
|
|
|
|
// track. However, this causes problems when uncollapsing a scrollbar
|
|
|
|
// inside a tree. See bug 201379 for details.
|
|
|
|
|
|
|
|
// (*aResult).height = ::GetSystemMetrics(SM_CYVTHUMB) << 1;
|
2005-08-20 11:13:11 +04:00
|
|
|
break;
|
2013-11-22 22:57:26 +04:00
|
|
|
case NS_THEME_SCROLLBAR_NON_DISAPPEARING:
|
|
|
|
{
|
|
|
|
aResult->SizeTo(::GetSystemMetrics(SM_CXHSCROLL),
|
|
|
|
::GetSystemMetrics(SM_CYVSCROLL));
|
|
|
|
break;
|
|
|
|
}
|
2013-04-03 14:07:12 +04:00
|
|
|
case NS_THEME_RANGE_THUMB: {
|
|
|
|
if (IsRangeHorizontal(aFrame)) {
|
|
|
|
(*aResult).width = 12;
|
|
|
|
(*aResult).height = 20;
|
|
|
|
} else {
|
|
|
|
(*aResult).width = 20;
|
|
|
|
(*aResult).height = 12;
|
|
|
|
}
|
|
|
|
*aIsOverridable = false;
|
|
|
|
break;
|
|
|
|
}
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SCALETHUMB_HORIZONTAL:
|
2006-05-30 17:50:48 +04:00
|
|
|
(*aResult).width = 12;
|
|
|
|
(*aResult).height = 20;
|
2011-10-02 06:16:19 +04:00
|
|
|
*aIsOverridable = false;
|
2006-05-30 17:50:48 +04:00
|
|
|
break;
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SCALETHUMB_VERTICAL:
|
2006-05-30 17:50:48 +04:00
|
|
|
(*aResult).width = 20;
|
|
|
|
(*aResult).height = 12;
|
2011-10-02 06:16:19 +04:00
|
|
|
*aIsOverridable = false;
|
2006-05-30 17:50:48 +04:00
|
|
|
break;
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_MENULIST_BUTTON:
|
2005-08-20 11:13:11 +04:00
|
|
|
(*aResult).width = ::GetSystemMetrics(SM_CXVSCROLL);
|
|
|
|
break;
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_MENULIST:
|
2005-08-20 11:13:11 +04:00
|
|
|
case NS_THEME_BUTTON:
|
2009-03-12 05:11:01 +03:00
|
|
|
case NS_THEME_GROUPBOX:
|
2005-08-20 11:13:11 +04:00
|
|
|
case NS_THEME_LISTBOX:
|
|
|
|
case NS_THEME_TREEVIEW:
|
2013-12-09 03:23:28 +04:00
|
|
|
case NS_THEME_NUMBER_INPUT:
|
2007-05-07 06:06:58 +04:00
|
|
|
case NS_THEME_TEXTFIELD:
|
|
|
|
case NS_THEME_TEXTFIELD_MULTILINE:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_MENULIST_TEXTFIELD:
|
2005-08-20 11:13:11 +04:00
|
|
|
case NS_THEME_STATUSBAR:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_STATUSBARPANEL:
|
2016-05-19 11:58:00 +03:00
|
|
|
case NS_THEME_RESIZERPANEL:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_PROGRESSCHUNK:
|
|
|
|
case NS_THEME_PROGRESSCHUNK_VERTICAL:
|
2005-08-20 11:13:11 +04:00
|
|
|
case NS_THEME_TOOLTIP:
|
|
|
|
case NS_THEME_PROGRESSBAR:
|
|
|
|
case NS_THEME_PROGRESSBAR_VERTICAL:
|
|
|
|
case NS_THEME_TAB:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_TABPANEL:
|
|
|
|
case NS_THEME_TABPANELS:
|
2005-08-20 11:13:11 +04:00
|
|
|
// no minimum widget size
|
|
|
|
break;
|
|
|
|
case NS_THEME_RESIZER: {
|
|
|
|
NONCLIENTMETRICS nc;
|
|
|
|
nc.cbSize = sizeof(nc);
|
|
|
|
if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(nc), &nc, 0))
|
|
|
|
(*aResult).width = (*aResult).height = abs(nc.lfStatusFont.lfHeight) + 4;
|
|
|
|
else
|
|
|
|
(*aResult).width = (*aResult).height = 15;
|
2011-10-02 06:16:19 +04:00
|
|
|
*aIsOverridable = false;
|
2005-08-20 11:13:11 +04:00
|
|
|
break;
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SCROLLBARTHUMB_VERTICAL:
|
2009-08-24 06:03:03 +04:00
|
|
|
(*aResult).width = ::GetSystemMetrics(SM_CXVSCROLL);
|
|
|
|
(*aResult).height = ::GetSystemMetrics(SM_CYVTHUMB);
|
|
|
|
// Without theming, divide the thumb size by two in order to look more
|
|
|
|
// native
|
|
|
|
if (!GetTheme(aWidgetType))
|
|
|
|
(*aResult).height >>= 1;
|
2011-10-02 06:16:19 +04:00
|
|
|
*aIsOverridable = false;
|
2005-08-20 11:14:19 +04:00
|
|
|
break;
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SCROLLBARTHUMB_HORIZONTAL:
|
2009-08-24 06:03:03 +04:00
|
|
|
(*aResult).width = ::GetSystemMetrics(SM_CXHTHUMB);
|
|
|
|
(*aResult).height = ::GetSystemMetrics(SM_CYHSCROLL);
|
|
|
|
// Without theming, divide the thumb size by two in order to look more
|
|
|
|
// native
|
|
|
|
if (!GetTheme(aWidgetType))
|
|
|
|
(*aResult).width >>= 1;
|
2011-10-02 06:16:19 +04:00
|
|
|
*aIsOverridable = false;
|
2005-08-20 11:14:19 +04:00
|
|
|
break;
|
2015-12-22 07:05:00 +03:00
|
|
|
case NS_THEME_SCROLLBAR_HORIZONTAL:
|
2005-08-20 11:14:19 +04:00
|
|
|
(*aResult).width = ::GetSystemMetrics(SM_CXHTHUMB) << 1;
|
|
|
|
break;
|
2005-08-20 11:13:11 +04:00
|
|
|
}
|
2007-08-06 21:45:57 +04:00
|
|
|
case NS_THEME_MENUSEPARATOR:
|
|
|
|
{
|
|
|
|
aResult->width = 0;
|
|
|
|
aResult->height = 10;
|
|
|
|
break;
|
|
|
|
}
|
2010-08-10 05:49:35 +04:00
|
|
|
|
|
|
|
case NS_THEME_WINDOW_TITLEBAR_MAXIMIZED:
|
|
|
|
case NS_THEME_WINDOW_TITLEBAR:
|
|
|
|
aResult->height = GetSystemMetrics(SM_CYCAPTION);
|
|
|
|
aResult->height += GetSystemMetrics(SM_CYFRAME);
|
|
|
|
aResult->width = 0;
|
|
|
|
break;
|
|
|
|
case NS_THEME_WINDOW_FRAME_LEFT:
|
|
|
|
case NS_THEME_WINDOW_FRAME_RIGHT:
|
|
|
|
aResult->width = GetSystemMetrics(SM_CXFRAME);
|
|
|
|
aResult->height = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_THEME_WINDOW_FRAME_BOTTOM:
|
|
|
|
aResult->height = GetSystemMetrics(SM_CYFRAME);
|
|
|
|
aResult->width = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_THEME_WINDOW_BUTTON_CLOSE:
|
|
|
|
case NS_THEME_WINDOW_BUTTON_MINIMIZE:
|
|
|
|
case NS_THEME_WINDOW_BUTTON_MAXIMIZE:
|
|
|
|
case NS_THEME_WINDOW_BUTTON_RESTORE:
|
|
|
|
aResult->width = GetSystemMetrics(SM_CXSIZE);
|
|
|
|
aResult->height = GetSystemMetrics(SM_CYSIZE);
|
|
|
|
// XXX I have no idea why these caption metrics are always off,
|
|
|
|
// but they are.
|
|
|
|
aResult->width -= 2;
|
|
|
|
aResult->height -= 4;
|
2010-11-29 19:19:17 +03:00
|
|
|
if (aWidgetType == NS_THEME_WINDOW_BUTTON_MINIMIZE) {
|
|
|
|
AddPaddingRect(aResult, CAPTIONBUTTON_MINIMIZE);
|
|
|
|
}
|
|
|
|
else if (aWidgetType == NS_THEME_WINDOW_BUTTON_MAXIMIZE ||
|
|
|
|
aWidgetType == NS_THEME_WINDOW_BUTTON_RESTORE) {
|
|
|
|
AddPaddingRect(aResult, CAPTIONBUTTON_RESTORE);
|
|
|
|
}
|
|
|
|
else if (aWidgetType == NS_THEME_WINDOW_BUTTON_CLOSE) {
|
|
|
|
AddPaddingRect(aResult, CAPTIONBUTTON_CLOSE);
|
|
|
|
}
|
2010-08-10 05:49:35 +04:00
|
|
|
break;
|
|
|
|
|
2005-08-20 11:13:11 +04:00
|
|
|
default:
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
nsresult nsNativeThemeWin::ClassicGetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType,
|
|
|
|
int32_t& aPart, int32_t& aState, bool& aFocused)
|
2005-08-20 11:13:11 +04:00
|
|
|
{
|
2011-10-02 06:16:19 +04:00
|
|
|
aFocused = false;
|
2005-08-20 11:13:11 +04:00
|
|
|
switch (aWidgetType) {
|
|
|
|
case NS_THEME_BUTTON: {
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates contentState;
|
2005-08-20 11:13:11 +04:00
|
|
|
|
|
|
|
aPart = DFC_BUTTON;
|
|
|
|
aState = DFCS_BUTTONPUSH;
|
2011-10-02 06:16:19 +04:00
|
|
|
aFocused = false;
|
2005-08-20 11:13:11 +04:00
|
|
|
|
2005-08-20 11:13:56 +04:00
|
|
|
contentState = GetContentState(aFrame, aWidgetType);
|
2010-09-28 05:25:18 +04:00
|
|
|
if (IsDisabled(aFrame, contentState))
|
2005-08-20 11:13:11 +04:00
|
|
|
aState |= DFCS_INACTIVE;
|
2009-03-13 15:23:26 +03:00
|
|
|
else if (IsOpenButton(aFrame))
|
2008-07-12 13:15:07 +04:00
|
|
|
aState |= DFCS_PUSHED;
|
2009-03-13 15:23:26 +03:00
|
|
|
else if (IsCheckedButton(aFrame))
|
2008-07-12 13:15:07 +04:00
|
|
|
aState |= DFCS_CHECKED;
|
2005-08-20 11:13:11 +04:00
|
|
|
else {
|
2010-10-20 15:26:32 +04:00
|
|
|
if (contentState.HasAllStates(NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_HOVER)) {
|
2005-08-20 11:13:11 +04:00
|
|
|
aState |= DFCS_PUSHED;
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleUserInterface *uiData = aFrame->StyleUserInterface();
|
2005-08-20 11:13:11 +04:00
|
|
|
// The down state is flat if the button is focusable
|
2016-07-25 09:26:40 +03:00
|
|
|
if (uiData->mUserFocus == StyleUserFocus::Normal) {
|
2015-03-03 14:08:59 +03:00
|
|
|
if (!aFrame->GetContent()->IsHTMLElement())
|
2005-08-20 11:13:11 +04:00
|
|
|
aState |= DFCS_FLAT;
|
2011-04-25 07:10:12 +04:00
|
|
|
|
2011-10-02 06:16:19 +04:00
|
|
|
aFocused = true;
|
2005-08-20 11:13:11 +04:00
|
|
|
}
|
|
|
|
}
|
2010-10-20 15:26:32 +04:00
|
|
|
if (contentState.HasState(NS_EVENT_STATE_FOCUS) ||
|
|
|
|
(aState == DFCS_BUTTONPUSH && IsDefaultButton(aFrame))) {
|
2011-10-02 06:16:19 +04:00
|
|
|
aFocused = true;
|
2005-08-20 11:13:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
case NS_THEME_CHECKBOX:
|
2008-11-03 16:12:59 +03:00
|
|
|
case NS_THEME_RADIO: {
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates contentState;
|
2011-10-02 06:16:19 +04:00
|
|
|
aFocused = false;
|
2005-08-20 11:13:11 +04:00
|
|
|
|
|
|
|
aPart = DFC_BUTTON;
|
2009-02-05 11:17:08 +03:00
|
|
|
aState = 0;
|
2005-08-20 11:13:33 +04:00
|
|
|
nsIContent* content = aFrame->GetContent();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isCheckbox = (aWidgetType == NS_THEME_CHECKBOX);
|
|
|
|
bool isChecked = GetCheckedOrSelected(aFrame, !isCheckbox);
|
|
|
|
bool isIndeterminate = isCheckbox && GetIndeterminate(aFrame);
|
2009-02-05 11:17:08 +03:00
|
|
|
|
|
|
|
if (isCheckbox) {
|
|
|
|
// indeterminate state takes precedence over checkedness.
|
|
|
|
if (isIndeterminate) {
|
|
|
|
aState = DFCS_BUTTON3STATE | DFCS_CHECKED;
|
|
|
|
} else {
|
|
|
|
aState = DFCS_BUTTONCHECK;
|
2005-08-20 11:13:11 +04:00
|
|
|
}
|
2009-02-05 11:17:08 +03:00
|
|
|
} else {
|
|
|
|
aState = DFCS_BUTTONRADIO;
|
2005-08-20 11:13:11 +04:00
|
|
|
}
|
2009-02-05 11:17:08 +03:00
|
|
|
if (isChecked) {
|
|
|
|
aState |= DFCS_CHECKED;
|
2005-08-20 11:13:11 +04:00
|
|
|
}
|
|
|
|
|
2009-02-05 11:17:08 +03:00
|
|
|
contentState = GetContentState(aFrame, aWidgetType);
|
2015-03-03 14:08:59 +03:00
|
|
|
if (!content->IsXULElement() &&
|
2010-10-20 15:26:32 +04:00
|
|
|
contentState.HasState(NS_EVENT_STATE_FOCUS)) {
|
2011-10-02 06:16:19 +04:00
|
|
|
aFocused = true;
|
2009-02-05 11:17:08 +03:00
|
|
|
}
|
|
|
|
|
2010-09-28 05:25:18 +04:00
|
|
|
if (IsDisabled(aFrame, contentState)) {
|
2005-08-20 11:13:11 +04:00
|
|
|
aState |= DFCS_INACTIVE;
|
2010-10-20 15:26:32 +04:00
|
|
|
} else if (contentState.HasAllStates(NS_EVENT_STATE_ACTIVE |
|
|
|
|
NS_EVENT_STATE_HOVER)) {
|
2005-08-20 11:13:11 +04:00
|
|
|
aState |= DFCS_PUSHED;
|
2009-02-05 11:17:08 +03:00
|
|
|
}
|
|
|
|
|
2005-08-20 11:13:11 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2005-10-07 04:31:36 +04:00
|
|
|
case NS_THEME_MENUITEM:
|
|
|
|
case NS_THEME_CHECKMENUITEM:
|
|
|
|
case NS_THEME_RADIOMENUITEM: {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isTopLevel = false;
|
|
|
|
bool isOpen = false;
|
2011-07-11 18:05:07 +04:00
|
|
|
nsMenuFrame *menuFrame = do_QueryFrame(aFrame);
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates eventState = GetContentState(aFrame, aWidgetType);
|
2005-10-07 04:31:36 +04:00
|
|
|
|
|
|
|
// We indicate top-level-ness using aPart. 0 is a normal menu item,
|
|
|
|
// 1 is a top-level menu item. The state of the item is composed of
|
|
|
|
// DFCS_* flags only.
|
|
|
|
aPart = 0;
|
|
|
|
aState = 0;
|
|
|
|
|
|
|
|
if (menuFrame) {
|
|
|
|
// If this is a real menu item, we should check if it is part of the
|
|
|
|
// main menu bar or not, and if it is a container, as these affect
|
|
|
|
// rendering.
|
2007-07-04 19:49:38 +04:00
|
|
|
isTopLevel = menuFrame->IsOnMenuBar();
|
|
|
|
isOpen = menuFrame->IsOpen();
|
2005-10-07 04:31:36 +04:00
|
|
|
}
|
|
|
|
|
2010-09-28 05:25:18 +04:00
|
|
|
if (IsDisabled(aFrame, eventState))
|
2005-10-07 04:31:36 +04:00
|
|
|
aState |= DFCS_INACTIVE;
|
|
|
|
|
|
|
|
if (isTopLevel) {
|
|
|
|
aPart = 1;
|
|
|
|
if (isOpen)
|
|
|
|
aState |= DFCS_PUSHED;
|
|
|
|
}
|
|
|
|
|
2008-03-06 23:56:47 +03:00
|
|
|
if (IsMenuActive(aFrame, aWidgetType))
|
2005-10-07 04:31:36 +04:00
|
|
|
aState |= DFCS_HOT;
|
|
|
|
|
2007-07-14 19:11:37 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
case NS_THEME_MENUCHECKBOX:
|
|
|
|
case NS_THEME_MENURADIO:
|
2008-02-29 08:10:12 +03:00
|
|
|
case NS_THEME_MENUARROW: {
|
2007-07-14 19:11:37 +04:00
|
|
|
aState = 0;
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates eventState = GetContentState(aFrame, aWidgetType);
|
2010-09-20 05:16:49 +04:00
|
|
|
|
2010-09-28 05:25:18 +04:00
|
|
|
if (IsDisabled(aFrame, eventState))
|
2007-07-14 19:11:37 +04:00
|
|
|
aState |= DFCS_INACTIVE;
|
2008-03-06 23:56:47 +03:00
|
|
|
if (IsMenuActive(aFrame, aWidgetType))
|
2007-07-14 19:11:37 +04:00
|
|
|
aState |= DFCS_HOT;
|
2008-02-29 08:10:12 +03:00
|
|
|
|
2007-07-14 19:11:37 +04:00
|
|
|
if (aWidgetType == NS_THEME_MENUCHECKBOX || aWidgetType == NS_THEME_MENURADIO) {
|
2005-10-07 04:31:36 +04:00
|
|
|
if (IsCheckedButton(aFrame))
|
|
|
|
aState |= DFCS_CHECKED;
|
2008-07-19 00:55:25 +04:00
|
|
|
} else if (IsFrameRTL(aFrame)) {
|
2007-07-14 19:11:37 +04:00
|
|
|
aState |= DFCS_RTL;
|
2005-10-07 04:31:36 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
2008-02-29 08:10:12 +03:00
|
|
|
}
|
2005-08-20 11:13:11 +04:00
|
|
|
case NS_THEME_LISTBOX:
|
|
|
|
case NS_THEME_TREEVIEW:
|
2013-12-09 03:23:28 +04:00
|
|
|
case NS_THEME_NUMBER_INPUT:
|
2014-06-14 16:48:08 +04:00
|
|
|
case NS_THEME_FOCUS_OUTLINE:
|
2005-08-20 11:13:11 +04:00
|
|
|
case NS_THEME_TEXTFIELD:
|
2007-05-07 06:06:58 +04:00
|
|
|
case NS_THEME_TEXTFIELD_MULTILINE:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_MENULIST:
|
|
|
|
case NS_THEME_MENULIST_TEXTFIELD:
|
2013-04-03 14:07:12 +04:00
|
|
|
case NS_THEME_RANGE:
|
|
|
|
case NS_THEME_RANGE_THUMB:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SCROLLBARTHUMB_VERTICAL:
|
|
|
|
case NS_THEME_SCROLLBARTHUMB_HORIZONTAL:
|
2015-12-22 07:05:00 +03:00
|
|
|
case NS_THEME_SCROLLBAR_VERTICAL:
|
|
|
|
case NS_THEME_SCROLLBAR_HORIZONTAL:
|
2006-05-30 17:50:48 +04:00
|
|
|
case NS_THEME_SCALE_HORIZONTAL:
|
|
|
|
case NS_THEME_SCALE_VERTICAL:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SCALETHUMB_HORIZONTAL:
|
|
|
|
case NS_THEME_SCALETHUMB_VERTICAL:
|
2005-08-20 11:13:11 +04:00
|
|
|
case NS_THEME_STATUSBAR:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_STATUSBARPANEL:
|
2016-05-19 11:58:00 +03:00
|
|
|
case NS_THEME_RESIZERPANEL:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_PROGRESSCHUNK:
|
|
|
|
case NS_THEME_PROGRESSCHUNK_VERTICAL:
|
2005-08-20 11:13:11 +04:00
|
|
|
case NS_THEME_TOOLTIP:
|
|
|
|
case NS_THEME_PROGRESSBAR:
|
|
|
|
case NS_THEME_PROGRESSBAR_VERTICAL:
|
|
|
|
case NS_THEME_TAB:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_TABPANEL:
|
|
|
|
case NS_THEME_TABPANELS:
|
2005-10-07 04:31:36 +04:00
|
|
|
case NS_THEME_MENUBAR:
|
|
|
|
case NS_THEME_MENUPOPUP:
|
2009-03-12 05:11:01 +03:00
|
|
|
case NS_THEME_GROUPBOX:
|
2005-08-20 11:13:11 +04:00
|
|
|
// these don't use DrawFrameControl
|
|
|
|
return NS_OK;
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_MENULIST_BUTTON: {
|
2005-08-20 11:13:11 +04:00
|
|
|
|
|
|
|
aPart = DFC_SCROLL;
|
|
|
|
aState = DFCS_SCROLLCOMBOBOX;
|
2009-03-13 15:23:26 +03:00
|
|
|
|
2005-08-20 11:13:33 +04:00
|
|
|
nsIFrame* parentFrame = aFrame->GetParent();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isHTML = IsHTMLContent(aFrame);
|
2017-04-30 18:30:08 +03:00
|
|
|
bool isMenulist = !isHTML && parentFrame->IsMenuFrame();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isOpen = false;
|
2005-08-20 11:13:11 +04:00
|
|
|
|
2009-03-13 15:23:26 +03:00
|
|
|
// HTML select and XUL menulist dropdown buttons get state from the parent.
|
|
|
|
if (isHTML || isMenulist)
|
|
|
|
aFrame = parentFrame;
|
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates eventState = GetContentState(aFrame, aWidgetType);
|
2010-09-20 05:16:49 +04:00
|
|
|
|
2010-09-28 05:25:18 +04:00
|
|
|
if (IsDisabled(aFrame, eventState)) {
|
2005-08-20 11:13:11 +04:00
|
|
|
aState |= DFCS_INACTIVE;
|
2009-03-13 15:23:26 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isHTML) {
|
|
|
|
nsIComboboxControlFrame* ccf = do_QueryFrame(aFrame);
|
2016-08-08 15:42:54 +03:00
|
|
|
isOpen = (ccf && ccf->IsDroppedDownOrHasParentPopup());
|
2005-08-20 11:13:11 +04:00
|
|
|
}
|
2009-03-13 15:23:26 +03:00
|
|
|
else
|
|
|
|
isOpen = IsOpenButton(aFrame);
|
|
|
|
|
|
|
|
// XXX Button should look active until the mouse is released, but
|
|
|
|
// without making it look active when the popup is clicked.
|
|
|
|
if (isOpen && (isHTML || isMenulist))
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
// Dropdown button active state doesn't need :hover.
|
2010-10-20 15:26:32 +04:00
|
|
|
if (eventState.HasState(NS_EVENT_STATE_ACTIVE))
|
2009-03-13 15:23:26 +03:00
|
|
|
aState |= DFCS_PUSHED | DFCS_FLAT;
|
2005-08-20 11:13:11 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SCROLLBARBUTTON_UP:
|
|
|
|
case NS_THEME_SCROLLBARBUTTON_DOWN:
|
|
|
|
case NS_THEME_SCROLLBARBUTTON_LEFT:
|
|
|
|
case NS_THEME_SCROLLBARBUTTON_RIGHT: {
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates contentState = GetContentState(aFrame, aWidgetType);
|
2005-08-20 11:13:11 +04:00
|
|
|
|
|
|
|
aPart = DFC_SCROLL;
|
|
|
|
switch (aWidgetType) {
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SCROLLBARBUTTON_UP:
|
2005-08-20 11:13:11 +04:00
|
|
|
aState = DFCS_SCROLLUP;
|
|
|
|
break;
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SCROLLBARBUTTON_DOWN:
|
2005-08-20 11:13:11 +04:00
|
|
|
aState = DFCS_SCROLLDOWN;
|
|
|
|
break;
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SCROLLBARBUTTON_LEFT:
|
2005-08-20 11:13:11 +04:00
|
|
|
aState = DFCS_SCROLLLEFT;
|
|
|
|
break;
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SCROLLBARBUTTON_RIGHT:
|
2005-08-20 11:13:11 +04:00
|
|
|
aState = DFCS_SCROLLRIGHT;
|
|
|
|
break;
|
2010-09-20 05:16:49 +04:00
|
|
|
}
|
|
|
|
|
2010-09-28 05:25:18 +04:00
|
|
|
if (IsDisabled(aFrame, contentState))
|
2005-08-20 11:13:11 +04:00
|
|
|
aState |= DFCS_INACTIVE;
|
|
|
|
else {
|
2010-10-20 15:26:32 +04:00
|
|
|
if (contentState.HasAllStates(NS_EVENT_STATE_HOVER | NS_EVENT_STATE_ACTIVE))
|
|
|
|
aState |= DFCS_PUSHED | DFCS_FLAT;
|
2005-08-20 11:13:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2017-11-29 05:43:13 +03:00
|
|
|
case NS_THEME_INNER_SPIN_BUTTON:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SPINNER_UPBUTTON:
|
|
|
|
case NS_THEME_SPINNER_DOWNBUTTON: {
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates contentState = GetContentState(aFrame, aWidgetType);
|
2005-08-20 11:13:11 +04:00
|
|
|
|
|
|
|
aPart = DFC_SCROLL;
|
|
|
|
switch (aWidgetType) {
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SPINNER_UPBUTTON:
|
2005-08-20 11:13:11 +04:00
|
|
|
aState = DFCS_SCROLLUP;
|
|
|
|
break;
|
2017-11-29 05:43:13 +03:00
|
|
|
case NS_THEME_INNER_SPIN_BUTTON:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SPINNER_DOWNBUTTON:
|
2005-08-20 11:13:11 +04:00
|
|
|
aState = DFCS_SCROLLDOWN;
|
|
|
|
break;
|
2010-09-20 05:16:49 +04:00
|
|
|
}
|
|
|
|
|
2010-09-28 05:25:18 +04:00
|
|
|
if (IsDisabled(aFrame, contentState))
|
2005-08-20 11:13:11 +04:00
|
|
|
aState |= DFCS_INACTIVE;
|
|
|
|
else {
|
2010-10-20 15:26:32 +04:00
|
|
|
if (contentState.HasAllStates(NS_EVENT_STATE_HOVER | NS_EVENT_STATE_ACTIVE))
|
2005-08-20 11:13:11 +04:00
|
|
|
aState |= DFCS_PUSHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
case NS_THEME_RESIZER:
|
|
|
|
aPart = DFC_SCROLL;
|
2009-01-18 13:28:19 +03:00
|
|
|
aState = (IsFrameRTL(aFrame)) ?
|
|
|
|
DFCS_SCROLLSIZEGRIPRIGHT : DFCS_SCROLLSIZEGRIP;
|
2005-08-20 11:13:11 +04:00
|
|
|
return NS_OK;
|
2007-08-06 21:45:57 +04:00
|
|
|
case NS_THEME_MENUSEPARATOR:
|
|
|
|
aPart = 0;
|
|
|
|
aState = 0;
|
|
|
|
return NS_OK;
|
2010-08-10 05:49:35 +04:00
|
|
|
case NS_THEME_WINDOW_TITLEBAR:
|
|
|
|
aPart = mozilla::widget::themeconst::WP_CAPTION;
|
|
|
|
aState = GetTopLevelWindowActiveState(aFrame);
|
|
|
|
return NS_OK;
|
|
|
|
case NS_THEME_WINDOW_TITLEBAR_MAXIMIZED:
|
|
|
|
aPart = mozilla::widget::themeconst::WP_MAXCAPTION;
|
|
|
|
aState = GetTopLevelWindowActiveState(aFrame);
|
|
|
|
return NS_OK;
|
|
|
|
case NS_THEME_WINDOW_FRAME_LEFT:
|
|
|
|
aPart = mozilla::widget::themeconst::WP_FRAMELEFT;
|
|
|
|
aState = GetTopLevelWindowActiveState(aFrame);
|
|
|
|
return NS_OK;
|
|
|
|
case NS_THEME_WINDOW_FRAME_RIGHT:
|
|
|
|
aPart = mozilla::widget::themeconst::WP_FRAMERIGHT;
|
|
|
|
aState = GetTopLevelWindowActiveState(aFrame);
|
|
|
|
return NS_OK;
|
|
|
|
case NS_THEME_WINDOW_FRAME_BOTTOM:
|
|
|
|
aPart = mozilla::widget::themeconst::WP_FRAMEBOTTOM;
|
|
|
|
aState = GetTopLevelWindowActiveState(aFrame);
|
|
|
|
return NS_OK;
|
|
|
|
case NS_THEME_WINDOW_BUTTON_CLOSE:
|
|
|
|
aPart = DFC_CAPTION;
|
|
|
|
aState = DFCS_CAPTIONCLOSE |
|
|
|
|
GetClassicWindowFrameButtonState(GetContentState(aFrame,
|
|
|
|
aWidgetType));
|
|
|
|
return NS_OK;
|
|
|
|
case NS_THEME_WINDOW_BUTTON_MINIMIZE:
|
|
|
|
aPart = DFC_CAPTION;
|
|
|
|
aState = DFCS_CAPTIONMIN |
|
|
|
|
GetClassicWindowFrameButtonState(GetContentState(aFrame,
|
|
|
|
aWidgetType));
|
|
|
|
return NS_OK;
|
|
|
|
case NS_THEME_WINDOW_BUTTON_MAXIMIZE:
|
|
|
|
aPart = DFC_CAPTION;
|
|
|
|
aState = DFCS_CAPTIONMAX |
|
|
|
|
GetClassicWindowFrameButtonState(GetContentState(aFrame,
|
|
|
|
aWidgetType));
|
|
|
|
return NS_OK;
|
|
|
|
case NS_THEME_WINDOW_BUTTON_RESTORE:
|
|
|
|
aPart = DFC_CAPTION;
|
|
|
|
aState = DFCS_CAPTIONRESTORE |
|
|
|
|
GetClassicWindowFrameButtonState(GetContentState(aFrame,
|
|
|
|
aWidgetType));
|
|
|
|
return NS_OK;
|
2005-08-20 11:13:11 +04:00
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw classic Windows tab
|
|
|
|
// (no system API for this, but DrawEdge can draw all the parts of a tab)
|
2012-08-22 19:56:38 +04:00
|
|
|
static void DrawTab(HDC hdc, const RECT& R, int32_t aPosition, bool aSelected,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aDrawLeft, bool aDrawRight)
|
2005-08-20 11:13:11 +04:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t leftFlag, topFlag, rightFlag, lightFlag, shadeFlag;
|
2005-08-20 11:13:11 +04:00
|
|
|
RECT topRect, sideRect, bottomRect, lightRect, shadeRect;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t selectedOffset, lOffset, rOffset;
|
2005-08-20 11:13:11 +04:00
|
|
|
|
|
|
|
selectedOffset = aSelected ? 1 : 0;
|
|
|
|
lOffset = aDrawLeft ? 2 : 0;
|
|
|
|
rOffset = aDrawRight ? 2 : 0;
|
|
|
|
|
|
|
|
// Get info for tab orientation/position (Left, Top, Right, Bottom)
|
|
|
|
switch (aPosition) {
|
|
|
|
case BF_LEFT:
|
|
|
|
leftFlag = BF_TOP; topFlag = BF_LEFT;
|
|
|
|
rightFlag = BF_BOTTOM;
|
|
|
|
lightFlag = BF_DIAGONAL_ENDTOPRIGHT;
|
|
|
|
shadeFlag = BF_DIAGONAL_ENDBOTTOMRIGHT;
|
|
|
|
|
|
|
|
::SetRect(&topRect, R.left, R.top+lOffset, R.right, R.bottom-rOffset);
|
|
|
|
::SetRect(&sideRect, R.left+2, R.top, R.right-2+selectedOffset, R.bottom);
|
|
|
|
::SetRect(&bottomRect, R.right-2, R.top, R.right, R.bottom);
|
|
|
|
::SetRect(&lightRect, R.left, R.top, R.left+3, R.top+3);
|
|
|
|
::SetRect(&shadeRect, R.left+1, R.bottom-2, R.left+2, R.bottom-1);
|
|
|
|
break;
|
|
|
|
case BF_TOP:
|
|
|
|
leftFlag = BF_LEFT; topFlag = BF_TOP;
|
|
|
|
rightFlag = BF_RIGHT;
|
|
|
|
lightFlag = BF_DIAGONAL_ENDTOPRIGHT;
|
|
|
|
shadeFlag = BF_DIAGONAL_ENDBOTTOMRIGHT;
|
|
|
|
|
|
|
|
::SetRect(&topRect, R.left+lOffset, R.top, R.right-rOffset, R.bottom);
|
|
|
|
::SetRect(&sideRect, R.left, R.top+2, R.right, R.bottom-1+selectedOffset);
|
|
|
|
::SetRect(&bottomRect, R.left, R.bottom-1, R.right, R.bottom);
|
|
|
|
::SetRect(&lightRect, R.left, R.top, R.left+3, R.top+3);
|
|
|
|
::SetRect(&shadeRect, R.right-2, R.top+1, R.right-1, R.top+2);
|
|
|
|
break;
|
|
|
|
case BF_RIGHT:
|
|
|
|
leftFlag = BF_TOP; topFlag = BF_RIGHT;
|
|
|
|
rightFlag = BF_BOTTOM;
|
|
|
|
lightFlag = BF_DIAGONAL_ENDTOPLEFT;
|
|
|
|
shadeFlag = BF_DIAGONAL_ENDBOTTOMLEFT;
|
|
|
|
|
|
|
|
::SetRect(&topRect, R.left, R.top+lOffset, R.right, R.bottom-rOffset);
|
|
|
|
::SetRect(&sideRect, R.left+2-selectedOffset, R.top, R.right-2, R.bottom);
|
|
|
|
::SetRect(&bottomRect, R.left, R.top, R.left+2, R.bottom);
|
|
|
|
::SetRect(&lightRect, R.right-3, R.top, R.right-1, R.top+2);
|
|
|
|
::SetRect(&shadeRect, R.right-2, R.bottom-3, R.right, R.bottom-1);
|
|
|
|
break;
|
|
|
|
case BF_BOTTOM:
|
|
|
|
leftFlag = BF_LEFT; topFlag = BF_BOTTOM;
|
|
|
|
rightFlag = BF_RIGHT;
|
|
|
|
lightFlag = BF_DIAGONAL_ENDTOPLEFT;
|
|
|
|
shadeFlag = BF_DIAGONAL_ENDBOTTOMLEFT;
|
|
|
|
|
|
|
|
::SetRect(&topRect, R.left+lOffset, R.top, R.right-rOffset, R.bottom);
|
|
|
|
::SetRect(&sideRect, R.left, R.top+2-selectedOffset, R.right, R.bottom-2);
|
|
|
|
::SetRect(&bottomRect, R.left, R.top, R.right, R.top+2);
|
|
|
|
::SetRect(&lightRect, R.left, R.bottom-3, R.left+2, R.bottom-1);
|
|
|
|
::SetRect(&shadeRect, R.right-2, R.bottom-3, R.right, R.bottom-1);
|
|
|
|
break;
|
2015-02-23 14:15:53 +03:00
|
|
|
default:
|
|
|
|
MOZ_CRASH();
|
2005-08-20 11:13:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Background
|
|
|
|
::FillRect(hdc, &R, (HBRUSH) (COLOR_3DFACE+1) );
|
|
|
|
|
|
|
|
// Tab "Top"
|
|
|
|
::DrawEdge(hdc, &topRect, EDGE_RAISED, BF_SOFT | topFlag);
|
|
|
|
|
|
|
|
// Tab "Bottom"
|
|
|
|
if (!aSelected)
|
|
|
|
::DrawEdge(hdc, &bottomRect, EDGE_RAISED, BF_SOFT | topFlag);
|
|
|
|
|
|
|
|
// Tab "Sides"
|
|
|
|
if (!aDrawLeft)
|
|
|
|
leftFlag = 0;
|
|
|
|
if (!aDrawRight)
|
|
|
|
rightFlag = 0;
|
|
|
|
::DrawEdge(hdc, &sideRect, EDGE_RAISED, BF_SOFT | leftFlag | rightFlag);
|
|
|
|
|
|
|
|
// Tab Diagonal Corners
|
|
|
|
if (aDrawLeft)
|
|
|
|
::DrawEdge(hdc, &lightRect, EDGE_RAISED, BF_SOFT | lightFlag);
|
|
|
|
|
|
|
|
if (aDrawRight)
|
|
|
|
::DrawEdge(hdc, &shadeRect, EDGE_RAISED, BF_SOFT | shadeFlag);
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static void DrawMenuImage(HDC hdc, const RECT& rc, int32_t aComponent, uint32_t aColor)
|
2005-10-07 04:31:36 +04:00
|
|
|
{
|
|
|
|
// This procedure creates a memory bitmap to contain the check mark, draws
|
|
|
|
// it into the bitmap (it is a mask image), then composes it onto the menu
|
|
|
|
// item in appropriate colors.
|
|
|
|
HDC hMemoryDC = ::CreateCompatibleDC(hdc);
|
|
|
|
if (hMemoryDC) {
|
|
|
|
// XXXjgr We should ideally be caching these, but we wont be notified when
|
|
|
|
// they change currently, so we can't do so easily. Same for the bitmap.
|
|
|
|
int checkW = ::GetSystemMetrics(SM_CXMENUCHECK);
|
|
|
|
int checkH = ::GetSystemMetrics(SM_CYMENUCHECK);
|
|
|
|
|
2013-10-08 22:48:20 +04:00
|
|
|
HBITMAP hMonoBitmap = ::CreateBitmap(checkW, checkH, 1, 1, nullptr);
|
2005-10-07 04:31:36 +04:00
|
|
|
if (hMonoBitmap) {
|
|
|
|
|
|
|
|
HBITMAP hPrevBitmap = (HBITMAP) ::SelectObject(hMemoryDC, hMonoBitmap);
|
|
|
|
if (hPrevBitmap) {
|
|
|
|
|
|
|
|
// XXXjgr This will go pear-shaped if the image is bigger than the
|
|
|
|
// provided rect. What should we do?
|
|
|
|
RECT imgRect = { 0, 0, checkW, checkH };
|
|
|
|
POINT imgPos = {
|
|
|
|
rc.left + (rc.right - rc.left - checkW) / 2,
|
|
|
|
rc.top + (rc.bottom - rc.top - checkH) / 2
|
|
|
|
};
|
|
|
|
|
2007-07-14 19:11:37 +04:00
|
|
|
// XXXzeniko Windows renders these 1px lower than you'd expect
|
|
|
|
if (aComponent == DFCS_MENUCHECK || aComponent == DFCS_MENUBULLET)
|
|
|
|
imgPos.y++;
|
|
|
|
|
2005-10-07 04:31:36 +04:00
|
|
|
::DrawFrameControl(hMemoryDC, &imgRect, DFC_MENU, aComponent);
|
|
|
|
COLORREF oldTextCol = ::SetTextColor(hdc, 0x00000000);
|
|
|
|
COLORREF oldBackCol = ::SetBkColor(hdc, 0x00FFFFFF);
|
|
|
|
::BitBlt(hdc, imgPos.x, imgPos.y, checkW, checkH, hMemoryDC, 0, 0, SRCAND);
|
|
|
|
::SetTextColor(hdc, ::GetSysColor(aColor));
|
|
|
|
::SetBkColor(hdc, 0x00000000);
|
|
|
|
::BitBlt(hdc, imgPos.x, imgPos.y, checkW, checkH, hMemoryDC, 0, 0, SRCPAINT);
|
|
|
|
::SetTextColor(hdc, oldTextCol);
|
|
|
|
::SetBkColor(hdc, oldBackCol);
|
|
|
|
::SelectObject(hMemoryDC, hPrevBitmap);
|
|
|
|
}
|
|
|
|
::DeleteObject(hMonoBitmap);
|
|
|
|
}
|
|
|
|
::DeleteDC(hMemoryDC);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void nsNativeThemeWin::DrawCheckedRect(HDC hdc, const RECT& rc, int32_t fore, int32_t back,
|
2006-05-30 17:50:48 +04:00
|
|
|
HBRUSH defaultBack)
|
|
|
|
{
|
|
|
|
static WORD patBits[8] = {
|
|
|
|
0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55
|
|
|
|
};
|
|
|
|
|
|
|
|
HBITMAP patBmp = ::CreateBitmap(8, 8, 1, 1, patBits);
|
|
|
|
if (patBmp) {
|
|
|
|
HBRUSH brush = (HBRUSH) ::CreatePatternBrush(patBmp);
|
|
|
|
if (brush) {
|
|
|
|
COLORREF oldForeColor = ::SetTextColor(hdc, ::GetSysColor(fore));
|
|
|
|
COLORREF oldBackColor = ::SetBkColor(hdc, ::GetSysColor(back));
|
2006-07-12 03:13:21 +04:00
|
|
|
POINT vpOrg;
|
2006-05-30 17:50:48 +04:00
|
|
|
|
|
|
|
::UnrealizeObject(brush);
|
2006-07-12 03:13:21 +04:00
|
|
|
::GetViewportOrgEx(hdc, &vpOrg);
|
2013-10-08 22:48:20 +04:00
|
|
|
::SetBrushOrgEx(hdc, vpOrg.x + rc.left, vpOrg.y + rc.top, nullptr);
|
2006-05-30 17:50:48 +04:00
|
|
|
HBRUSH oldBrush = (HBRUSH) ::SelectObject(hdc, brush);
|
|
|
|
::FillRect(hdc, &rc, brush);
|
|
|
|
::SetTextColor(hdc, oldForeColor);
|
|
|
|
::SetBkColor(hdc, oldBackColor);
|
|
|
|
::SelectObject(hdc, oldBrush);
|
|
|
|
::DeleteObject(brush);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
::FillRect(hdc, &rc, defaultBack);
|
|
|
|
|
|
|
|
::DeleteObject(patBmp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-09 22:14:53 +03:00
|
|
|
nsresult nsNativeThemeWin::ClassicDrawWidgetBackground(gfxContext* aContext,
|
2005-08-20 11:13:11 +04:00
|
|
|
nsIFrame* aFrame,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t aWidgetType,
|
2005-08-20 11:13:11 +04:00
|
|
|
const nsRect& aRect,
|
2008-07-25 03:01:59 +04:00
|
|
|
const nsRect& aDirtyRect)
|
2007-03-03 03:18:34 +03:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t part, state;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool focused;
|
2005-08-20 11:13:11 +04:00
|
|
|
nsresult rv;
|
|
|
|
rv = ClassicGetThemePartAndState(aFrame, aWidgetType, part, state, focused);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
2013-01-07 15:06:11 +04:00
|
|
|
if (AssumeThemePartAndStateAreTransparent(part, state)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-06-20 10:42:30 +04:00
|
|
|
gfxFloat p2a = gfxFloat(aFrame->PresContext()->AppUnitsPerDevPixel());
|
2005-08-20 11:13:11 +04:00
|
|
|
RECT widgetRect;
|
2018-01-10 19:14:16 +03:00
|
|
|
gfxRect tr(aRect.X(), aRect.Y(), aRect.Width(), aRect.Height()),
|
|
|
|
dr(aDirtyRect.X(), aDirtyRect.Y(), aDirtyRect.Width(), aDirtyRect.Height());
|
2005-08-20 11:13:11 +04:00
|
|
|
|
2017-07-05 18:22:00 +03:00
|
|
|
tr.Scale(1.0 / p2a);
|
|
|
|
dr.Scale(1.0 / p2a);
|
2006-02-09 04:24:30 +03:00
|
|
|
|
2017-06-09 22:14:53 +03:00
|
|
|
RefPtr<gfxContext> ctx = aContext;
|
2006-06-06 23:01:58 +04:00
|
|
|
|
2008-07-25 03:01:59 +04:00
|
|
|
gfxWindowsNativeDrawing nativeDrawing(ctx, dr, GetWidgetNativeDrawingFlags(aWidgetType));
|
2006-02-09 04:24:30 +03:00
|
|
|
|
2007-03-03 03:18:34 +03:00
|
|
|
RENDER_AGAIN:
|
2006-02-09 04:24:30 +03:00
|
|
|
|
2007-03-03 03:18:34 +03:00
|
|
|
HDC hdc = nativeDrawing.BeginNativeDrawing();
|
2007-08-09 22:54:17 +04:00
|
|
|
if (!hdc)
|
|
|
|
return NS_ERROR_FAILURE;
|
2006-02-09 04:24:30 +03:00
|
|
|
|
2007-03-03 03:18:34 +03:00
|
|
|
nativeDrawing.TransformToNativeRect(tr, widgetRect);
|
2005-10-06 08:02:10 +04:00
|
|
|
|
2005-11-16 16:51:47 +03:00
|
|
|
rv = NS_OK;
|
2005-08-20 11:13:11 +04:00
|
|
|
switch (aWidgetType) {
|
|
|
|
// Draw button
|
|
|
|
case NS_THEME_BUTTON: {
|
|
|
|
if (focused) {
|
|
|
|
// draw dark button focus border first
|
|
|
|
HBRUSH brush;
|
|
|
|
brush = ::GetSysColorBrush(COLOR_3DDKSHADOW);
|
|
|
|
if (brush)
|
|
|
|
::FrameRect(hdc, &widgetRect, brush);
|
|
|
|
InflateRect(&widgetRect, -1, -1);
|
|
|
|
}
|
|
|
|
// fall-through...
|
|
|
|
}
|
|
|
|
// Draw controls supported by DrawFrameControl
|
|
|
|
case NS_THEME_CHECKBOX:
|
|
|
|
case NS_THEME_RADIO:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SCROLLBARBUTTON_UP:
|
|
|
|
case NS_THEME_SCROLLBARBUTTON_DOWN:
|
|
|
|
case NS_THEME_SCROLLBARBUTTON_LEFT:
|
|
|
|
case NS_THEME_SCROLLBARBUTTON_RIGHT:
|
2017-11-29 05:43:13 +03:00
|
|
|
case NS_THEME_INNER_SPIN_BUTTON:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SPINNER_UPBUTTON:
|
|
|
|
case NS_THEME_SPINNER_DOWNBUTTON:
|
|
|
|
case NS_THEME_MENULIST_BUTTON:
|
2005-10-07 04:31:36 +04:00
|
|
|
case NS_THEME_RESIZER: {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t oldTA;
|
2005-08-20 11:13:11 +04:00
|
|
|
// setup DC to make DrawFrameControl draw correctly
|
|
|
|
oldTA = ::SetTextAlign(hdc, TA_TOP | TA_LEFT | TA_NOUPDATECP);
|
|
|
|
::DrawFrameControl(hdc, &widgetRect, part, state);
|
|
|
|
::SetTextAlign(hdc, oldTA);
|
2005-11-16 16:51:47 +03:00
|
|
|
break;
|
2005-08-20 11:13:11 +04:00
|
|
|
}
|
|
|
|
// Draw controls with 2px 3D inset border
|
2013-12-09 03:23:28 +04:00
|
|
|
case NS_THEME_NUMBER_INPUT:
|
2005-08-20 11:13:11 +04:00
|
|
|
case NS_THEME_TEXTFIELD:
|
2007-05-07 06:06:58 +04:00
|
|
|
case NS_THEME_TEXTFIELD_MULTILINE:
|
2005-08-20 11:13:56 +04:00
|
|
|
case NS_THEME_LISTBOX:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_MENULIST:
|
|
|
|
case NS_THEME_MENULIST_TEXTFIELD: {
|
2005-08-20 11:13:11 +04:00
|
|
|
// Draw inset edge
|
|
|
|
::DrawEdge(hdc, &widgetRect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates eventState = GetContentState(aFrame, aWidgetType);
|
2005-08-20 11:13:11 +04:00
|
|
|
|
2005-08-20 11:13:24 +04:00
|
|
|
// Fill in background
|
2010-09-28 05:25:18 +04:00
|
|
|
if (IsDisabled(aFrame, eventState) ||
|
2015-03-03 14:08:59 +03:00
|
|
|
(aFrame->GetContent()->IsXULElement() &&
|
2005-08-20 11:13:33 +04:00
|
|
|
IsReadOnly(aFrame)))
|
2005-08-20 11:13:24 +04:00
|
|
|
::FillRect(hdc, &widgetRect, (HBRUSH) (COLOR_BTNFACE+1));
|
|
|
|
else
|
|
|
|
::FillRect(hdc, &widgetRect, (HBRUSH) (COLOR_WINDOW+1));
|
2005-10-06 08:02:10 +04:00
|
|
|
|
2005-11-16 16:51:47 +03:00
|
|
|
break;
|
2005-08-20 11:13:24 +04:00
|
|
|
}
|
|
|
|
case NS_THEME_TREEVIEW: {
|
|
|
|
// Draw inset edge
|
|
|
|
::DrawEdge(hdc, &widgetRect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
|
|
|
|
|
2005-08-20 11:13:11 +04:00
|
|
|
// Fill in window color background
|
|
|
|
::FillRect(hdc, &widgetRect, (HBRUSH) (COLOR_WINDOW+1));
|
2005-10-06 08:02:10 +04:00
|
|
|
|
2005-11-16 16:51:47 +03:00
|
|
|
break;
|
2005-08-20 11:13:11 +04:00
|
|
|
}
|
|
|
|
// Draw ToolTip background
|
|
|
|
case NS_THEME_TOOLTIP:
|
2007-06-30 09:00:02 +04:00
|
|
|
::FrameRect(hdc, &widgetRect, ::GetSysColorBrush(COLOR_WINDOWFRAME));
|
2005-08-20 11:13:11 +04:00
|
|
|
InflateRect(&widgetRect, -1, -1);
|
2007-06-30 09:00:02 +04:00
|
|
|
::FillRect(hdc, &widgetRect, ::GetSysColorBrush(COLOR_INFOBK));
|
2005-10-06 08:02:10 +04:00
|
|
|
|
2009-03-12 05:11:01 +03:00
|
|
|
break;
|
|
|
|
case NS_THEME_GROUPBOX:
|
|
|
|
::DrawEdge(hdc, &widgetRect, EDGE_ETCHED, BF_RECT | BF_ADJUST);
|
|
|
|
::FillRect(hdc, &widgetRect, (HBRUSH) (COLOR_BTNFACE+1));
|
2005-11-16 16:51:47 +03:00
|
|
|
break;
|
2005-08-20 11:13:11 +04:00
|
|
|
// Draw 3D face background controls
|
|
|
|
case NS_THEME_PROGRESSBAR:
|
|
|
|
case NS_THEME_PROGRESSBAR_VERTICAL:
|
2005-08-20 11:14:29 +04:00
|
|
|
// Draw 3D border
|
|
|
|
::DrawEdge(hdc, &widgetRect, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE);
|
|
|
|
InflateRect(&widgetRect, -1, -1);
|
|
|
|
// fall through
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_TABPANEL:
|
2005-08-20 11:13:11 +04:00
|
|
|
case NS_THEME_STATUSBAR:
|
2016-05-19 11:58:00 +03:00
|
|
|
case NS_THEME_RESIZERPANEL: {
|
2005-08-20 11:13:11 +04:00
|
|
|
::FillRect(hdc, &widgetRect, (HBRUSH) (COLOR_BTNFACE+1));
|
2005-10-06 08:02:10 +04:00
|
|
|
|
2005-11-16 16:51:47 +03:00
|
|
|
break;
|
2005-08-20 11:13:11 +04:00
|
|
|
}
|
|
|
|
// Draw 3D inset statusbar panel
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_STATUSBARPANEL: {
|
2005-08-20 11:13:33 +04:00
|
|
|
if (aFrame->GetNextSibling())
|
2005-08-20 11:13:11 +04:00
|
|
|
widgetRect.right -= 2; // space between sibling status panels
|
|
|
|
|
|
|
|
::DrawEdge(hdc, &widgetRect, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE);
|
2005-10-06 08:02:10 +04:00
|
|
|
|
2005-11-16 16:51:47 +03:00
|
|
|
break;
|
2005-08-20 11:13:11 +04:00
|
|
|
}
|
|
|
|
// Draw scrollbar thumb
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SCROLLBARTHUMB_VERTICAL:
|
|
|
|
case NS_THEME_SCROLLBARTHUMB_HORIZONTAL:
|
2005-08-20 11:13:11 +04:00
|
|
|
::DrawEdge(hdc, &widgetRect, EDGE_RAISED, BF_RECT | BF_MIDDLE);
|
2005-10-06 08:02:10 +04:00
|
|
|
|
2006-05-30 17:50:48 +04:00
|
|
|
break;
|
2013-04-03 14:07:12 +04:00
|
|
|
case NS_THEME_RANGE_THUMB:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SCALETHUMB_VERTICAL:
|
|
|
|
case NS_THEME_SCALETHUMB_HORIZONTAL: {
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates eventState = GetContentState(aFrame, aWidgetType);
|
2010-09-20 05:16:49 +04:00
|
|
|
|
2006-05-30 17:50:48 +04:00
|
|
|
::DrawEdge(hdc, &widgetRect, EDGE_RAISED, BF_RECT | BF_SOFT | BF_MIDDLE | BF_ADJUST);
|
2010-09-28 05:25:18 +04:00
|
|
|
if (IsDisabled(aFrame, eventState)) {
|
2006-05-30 17:50:48 +04:00
|
|
|
DrawCheckedRect(hdc, widgetRect, COLOR_3DFACE, COLOR_3DHILIGHT,
|
|
|
|
(HBRUSH) COLOR_3DHILIGHT);
|
|
|
|
}
|
|
|
|
|
2005-11-16 16:51:47 +03:00
|
|
|
break;
|
2010-09-20 05:16:49 +04:00
|
|
|
}
|
2005-08-20 11:13:11 +04:00
|
|
|
// Draw scrollbar track background
|
2015-12-22 07:05:00 +03:00
|
|
|
case NS_THEME_SCROLLBAR_VERTICAL:
|
|
|
|
case NS_THEME_SCROLLBAR_HORIZONTAL: {
|
2005-08-20 11:13:11 +04:00
|
|
|
|
|
|
|
// Windows fills in the scrollbar track differently
|
|
|
|
// depending on whether these are equal
|
|
|
|
DWORD color3D, colorScrollbar, colorWindow;
|
|
|
|
|
|
|
|
color3D = ::GetSysColor(COLOR_3DFACE);
|
|
|
|
colorWindow = ::GetSysColor(COLOR_WINDOW);
|
|
|
|
colorScrollbar = ::GetSysColor(COLOR_SCROLLBAR);
|
|
|
|
|
|
|
|
if ((color3D != colorScrollbar) && (colorWindow != colorScrollbar))
|
|
|
|
// Use solid brush
|
|
|
|
::FillRect(hdc, &widgetRect, (HBRUSH) (COLOR_SCROLLBAR+1));
|
|
|
|
else
|
|
|
|
{
|
2006-05-30 17:50:48 +04:00
|
|
|
DrawCheckedRect(hdc, widgetRect, COLOR_3DHILIGHT, COLOR_3DFACE,
|
|
|
|
(HBRUSH) COLOR_SCROLLBAR+1);
|
2005-08-20 11:13:11 +04:00
|
|
|
}
|
|
|
|
// XXX should invert the part of the track being clicked here
|
|
|
|
// but the track is never :active
|
2005-10-06 08:02:10 +04:00
|
|
|
|
2005-11-16 16:51:47 +03:00
|
|
|
break;
|
2005-08-20 11:13:11 +04:00
|
|
|
}
|
2006-05-30 17:50:48 +04:00
|
|
|
// Draw scale track background
|
2013-04-03 14:07:12 +04:00
|
|
|
case NS_THEME_RANGE:
|
2006-05-30 17:50:48 +04:00
|
|
|
case NS_THEME_SCALE_VERTICAL:
|
2013-04-03 14:07:12 +04:00
|
|
|
case NS_THEME_SCALE_HORIZONTAL: {
|
|
|
|
const int32_t trackWidth = 4;
|
|
|
|
// When rounding is necessary, we round the position of the track
|
|
|
|
// away from the chevron of the thumb to make it look better.
|
|
|
|
if (aWidgetType == NS_THEME_SCALE_HORIZONTAL ||
|
|
|
|
(aWidgetType == NS_THEME_RANGE && IsRangeHorizontal(aFrame))) {
|
|
|
|
widgetRect.top += (widgetRect.bottom - widgetRect.top - trackWidth) / 2;
|
|
|
|
widgetRect.bottom = widgetRect.top + trackWidth;
|
2006-05-30 17:50:48 +04:00
|
|
|
}
|
|
|
|
else {
|
2013-04-03 14:07:12 +04:00
|
|
|
if (!IsFrameRTL(aFrame)) {
|
|
|
|
widgetRect.left += (widgetRect.right - widgetRect.left - trackWidth) / 2;
|
|
|
|
widgetRect.right = widgetRect.left + trackWidth;
|
|
|
|
} else {
|
|
|
|
widgetRect.right -= (widgetRect.right - widgetRect.left - trackWidth) / 2;
|
|
|
|
widgetRect.left = widgetRect.right - trackWidth;
|
|
|
|
}
|
2006-05-30 17:50:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
::DrawEdge(hdc, &widgetRect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
|
|
|
|
::FillRect(hdc, &widgetRect, (HBRUSH) GetStockObject(GRAY_BRUSH));
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_PROGRESSCHUNK_VERTICAL:
|
2005-08-20 11:13:11 +04:00
|
|
|
::FillRect(hdc, &widgetRect, (HBRUSH) (COLOR_HIGHLIGHT+1));
|
2011-07-22 23:23:46 +04:00
|
|
|
break;
|
|
|
|
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_PROGRESSCHUNK: {
|
2011-07-22 23:23:46 +04:00
|
|
|
nsIFrame* stateFrame = aFrame->GetParent();
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates eventStates = GetContentState(stateFrame, aWidgetType);
|
2011-07-22 23:23:46 +04:00
|
|
|
|
2013-02-25 04:27:26 +04:00
|
|
|
bool indeterminate = IsIndeterminateProgress(stateFrame, eventStates);
|
|
|
|
bool vertical = IsVerticalProgress(stateFrame) ||
|
2016-05-18 20:29:56 +03:00
|
|
|
aWidgetType == NS_THEME_PROGRESSCHUNK_VERTICAL;
|
2013-02-25 04:27:26 +04:00
|
|
|
|
|
|
|
nsIContent* content = aFrame->GetContent();
|
|
|
|
if (!indeterminate || !content) {
|
2011-07-22 23:23:46 +04:00
|
|
|
::FillRect(hdc, &widgetRect, (HBRUSH) (COLOR_HIGHLIGHT+1));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-02-25 04:27:26 +04:00
|
|
|
RECT overlayRect =
|
|
|
|
CalculateProgressOverlayRect(aFrame, &widgetRect, vertical,
|
|
|
|
indeterminate, true);
|
2011-07-22 23:23:46 +04:00
|
|
|
|
2013-02-25 04:27:26 +04:00
|
|
|
::FillRect(hdc, &overlayRect, (HBRUSH) (COLOR_HIGHLIGHT+1));
|
2011-07-22 23:23:46 +04:00
|
|
|
|
2013-02-25 04:27:26 +04:00
|
|
|
if (!QueueAnimatedContentForRefresh(aFrame->GetContent(), 30)) {
|
|
|
|
NS_WARNING("unable to animate progress widget!");
|
2011-07-22 23:23:46 +04:00
|
|
|
}
|
2005-11-16 16:51:47 +03:00
|
|
|
break;
|
2011-07-22 23:23:46 +04:00
|
|
|
}
|
|
|
|
|
2005-08-20 11:13:11 +04:00
|
|
|
// Draw Tab
|
2009-01-04 17:01:48 +03:00
|
|
|
case NS_THEME_TAB: {
|
2005-08-20 11:13:11 +04:00
|
|
|
DrawTab(hdc, widgetRect,
|
|
|
|
IsBottomTab(aFrame) ? BF_BOTTOM : BF_TOP,
|
2005-08-20 11:13:56 +04:00
|
|
|
IsSelectedTab(aFrame),
|
2009-01-04 17:01:48 +03:00
|
|
|
!IsRightToSelectedTab(aFrame),
|
|
|
|
!IsLeftToSelectedTab(aFrame));
|
2005-08-20 11:13:11 +04:00
|
|
|
|
2005-11-16 16:51:47 +03:00
|
|
|
break;
|
2005-08-20 11:13:11 +04:00
|
|
|
}
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_TABPANELS:
|
2005-08-20 11:13:11 +04:00
|
|
|
::DrawEdge(hdc, &widgetRect, EDGE_RAISED, BF_SOFT | BF_MIDDLE |
|
|
|
|
BF_LEFT | BF_RIGHT | BF_BOTTOM);
|
2005-10-06 08:02:10 +04:00
|
|
|
|
2005-11-16 16:51:47 +03:00
|
|
|
break;
|
2005-10-07 04:31:36 +04:00
|
|
|
case NS_THEME_MENUBAR:
|
2005-11-16 16:51:47 +03:00
|
|
|
break;
|
2005-10-07 04:31:36 +04:00
|
|
|
case NS_THEME_MENUPOPUP:
|
2008-07-17 21:19:10 +04:00
|
|
|
NS_ASSERTION(nsUXThemeData::sFlatMenus, "Classic menus are styled entirely through CSS");
|
2007-07-14 19:11:37 +04:00
|
|
|
::FillRect(hdc, &widgetRect, (HBRUSH) (COLOR_MENU+1));
|
|
|
|
::FrameRect(hdc, &widgetRect, ::GetSysColorBrush(COLOR_BTNSHADOW));
|
2005-11-16 16:51:47 +03:00
|
|
|
break;
|
2005-10-07 04:31:36 +04:00
|
|
|
case NS_THEME_MENUITEM:
|
|
|
|
case NS_THEME_CHECKMENUITEM:
|
2007-07-14 19:11:37 +04:00
|
|
|
case NS_THEME_RADIOMENUITEM:
|
2005-10-07 04:31:36 +04:00
|
|
|
// part == 0 for normal items
|
|
|
|
// part == 1 for top-level menu items
|
2008-07-17 21:19:10 +04:00
|
|
|
if (nsUXThemeData::sFlatMenus) {
|
2005-10-07 04:31:36 +04:00
|
|
|
// Not disabled and hot/pushed.
|
|
|
|
if ((state & (DFCS_HOT | DFCS_PUSHED)) != 0) {
|
|
|
|
::FillRect(hdc, &widgetRect, (HBRUSH) (COLOR_MENUHILIGHT+1));
|
|
|
|
::FrameRect(hdc, &widgetRect, ::GetSysColorBrush(COLOR_HIGHLIGHT));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (part == 1) {
|
|
|
|
if ((state & DFCS_INACTIVE) == 0) {
|
|
|
|
if ((state & DFCS_PUSHED) != 0) {
|
|
|
|
::DrawEdge(hdc, &widgetRect, BDR_SUNKENOUTER, BF_RECT);
|
|
|
|
} else if ((state & DFCS_HOT) != 0) {
|
|
|
|
::DrawEdge(hdc, &widgetRect, BDR_RAISEDINNER, BF_RECT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ((state & (DFCS_HOT | DFCS_PUSHED)) != 0) {
|
|
|
|
::FillRect(hdc, &widgetRect, (HBRUSH) (COLOR_HIGHLIGHT+1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-07-14 19:11:37 +04:00
|
|
|
break;
|
|
|
|
case NS_THEME_MENUCHECKBOX:
|
|
|
|
case NS_THEME_MENURADIO:
|
|
|
|
if (!(state & DFCS_CHECKED))
|
|
|
|
break; // nothin' to do
|
|
|
|
case NS_THEME_MENUARROW: {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t color = COLOR_MENUTEXT;
|
2007-07-14 19:11:37 +04:00
|
|
|
if ((state & DFCS_INACTIVE))
|
|
|
|
color = COLOR_GRAYTEXT;
|
|
|
|
else if ((state & DFCS_HOT))
|
|
|
|
color = COLOR_HIGHLIGHTTEXT;
|
|
|
|
|
|
|
|
if (aWidgetType == NS_THEME_MENUCHECKBOX)
|
|
|
|
DrawMenuImage(hdc, widgetRect, DFCS_MENUCHECK, color);
|
|
|
|
else if (aWidgetType == NS_THEME_MENURADIO)
|
|
|
|
DrawMenuImage(hdc, widgetRect, DFCS_MENUBULLET, color);
|
|
|
|
else if (aWidgetType == NS_THEME_MENUARROW)
|
|
|
|
DrawMenuImage(hdc, widgetRect,
|
|
|
|
(state & DFCS_RTL) ? DFCS_MENUARROWRIGHT : DFCS_MENUARROW,
|
|
|
|
color);
|
2005-11-16 16:51:47 +03:00
|
|
|
break;
|
2005-10-07 04:31:36 +04:00
|
|
|
}
|
2007-08-06 21:45:57 +04:00
|
|
|
case NS_THEME_MENUSEPARATOR: {
|
|
|
|
// separators are offset by a bit (see menu.css)
|
|
|
|
widgetRect.left++;
|
|
|
|
widgetRect.right--;
|
|
|
|
|
|
|
|
// This magic number is brought to you by the value in menu.css
|
|
|
|
widgetRect.top += 4;
|
|
|
|
// Our rectangles are 1 pixel high (see border size in menu.css)
|
|
|
|
widgetRect.bottom = widgetRect.top+1;
|
|
|
|
::FillRect(hdc, &widgetRect, (HBRUSH)(COLOR_3DSHADOW+1));
|
|
|
|
widgetRect.top++;
|
|
|
|
widgetRect.bottom++;
|
|
|
|
::FillRect(hdc, &widgetRect, (HBRUSH)(COLOR_3DHILIGHT+1));
|
|
|
|
break;
|
|
|
|
}
|
2010-08-10 05:49:35 +04:00
|
|
|
|
|
|
|
case NS_THEME_WINDOW_TITLEBAR:
|
|
|
|
case NS_THEME_WINDOW_TITLEBAR_MAXIMIZED:
|
|
|
|
{
|
|
|
|
RECT rect = widgetRect;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t offset = GetSystemMetrics(SM_CXFRAME);
|
2010-10-26 21:50:29 +04:00
|
|
|
|
|
|
|
// first fill the area to the color of the window background
|
|
|
|
FillRect(hdc, &rect, (HBRUSH)(COLOR_3DFACE+1));
|
|
|
|
|
|
|
|
// inset the caption area so it doesn't overflow.
|
2010-08-10 05:49:35 +04:00
|
|
|
rect.top += offset;
|
|
|
|
// if enabled, draw a gradient titlebar background, otherwise
|
|
|
|
// fill with a solid color.
|
|
|
|
BOOL bFlag = TRUE;
|
2010-08-20 22:19:38 +04:00
|
|
|
SystemParametersInfo(SPI_GETGRADIENTCAPTIONS, 0, &bFlag, 0);
|
2010-08-10 05:49:35 +04:00
|
|
|
if (!bFlag) {
|
|
|
|
if (state == mozilla::widget::themeconst::FS_ACTIVE)
|
|
|
|
FillRect(hdc, &rect, (HBRUSH)(COLOR_ACTIVECAPTION+1));
|
|
|
|
else
|
|
|
|
FillRect(hdc, &rect, (HBRUSH)(COLOR_INACTIVECAPTION+1));
|
|
|
|
} else {
|
|
|
|
DWORD startColor, endColor;
|
|
|
|
if (state == mozilla::widget::themeconst::FS_ACTIVE) {
|
|
|
|
startColor = GetSysColor(COLOR_ACTIVECAPTION);
|
|
|
|
endColor = GetSysColor(COLOR_GRADIENTACTIVECAPTION);
|
|
|
|
} else {
|
|
|
|
startColor = GetSysColor(COLOR_INACTIVECAPTION);
|
|
|
|
endColor = GetSysColor(COLOR_GRADIENTINACTIVECAPTION);
|
|
|
|
}
|
|
|
|
|
|
|
|
TRIVERTEX vertex[2];
|
|
|
|
vertex[0].x = rect.left;
|
|
|
|
vertex[0].y = rect.top;
|
|
|
|
vertex[0].Red = GetRValue(startColor) << 8;
|
|
|
|
vertex[0].Green = GetGValue(startColor) << 8;
|
|
|
|
vertex[0].Blue = GetBValue(startColor) << 8;
|
|
|
|
vertex[0].Alpha = 0;
|
|
|
|
|
|
|
|
vertex[1].x = rect.right;
|
|
|
|
vertex[1].y = rect.bottom;
|
|
|
|
vertex[1].Red = GetRValue(endColor) << 8;
|
|
|
|
vertex[1].Green = GetGValue(endColor) << 8;
|
|
|
|
vertex[1].Blue = GetBValue(endColor) << 8;
|
|
|
|
vertex[1].Alpha = 0;
|
|
|
|
|
|
|
|
GRADIENT_RECT gRect;
|
|
|
|
gRect.UpperLeft = 0;
|
|
|
|
gRect.LowerRight = 1;
|
|
|
|
// available on win2k & up
|
|
|
|
GradientFill(hdc, vertex, 2, &gRect, 1, GRADIENT_FILL_RECT_H);
|
|
|
|
}
|
|
|
|
|
2010-11-29 19:19:17 +03:00
|
|
|
if (aWidgetType == NS_THEME_WINDOW_TITLEBAR) {
|
|
|
|
// frame things up with a top raised border.
|
|
|
|
DrawEdge(hdc, &widgetRect, EDGE_RAISED, BF_TOP);
|
|
|
|
}
|
2010-08-10 05:49:35 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NS_THEME_WINDOW_FRAME_LEFT:
|
|
|
|
DrawEdge(hdc, &widgetRect, EDGE_RAISED, BF_LEFT);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_THEME_WINDOW_FRAME_RIGHT:
|
|
|
|
DrawEdge(hdc, &widgetRect, EDGE_RAISED, BF_RIGHT);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_THEME_WINDOW_FRAME_BOTTOM:
|
|
|
|
DrawEdge(hdc, &widgetRect, EDGE_RAISED, BF_BOTTOM);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_THEME_WINDOW_BUTTON_CLOSE:
|
|
|
|
case NS_THEME_WINDOW_BUTTON_MINIMIZE:
|
|
|
|
case NS_THEME_WINDOW_BUTTON_MAXIMIZE:
|
|
|
|
case NS_THEME_WINDOW_BUTTON_RESTORE:
|
|
|
|
{
|
2010-11-29 19:19:17 +03:00
|
|
|
if (aWidgetType == NS_THEME_WINDOW_BUTTON_MINIMIZE) {
|
|
|
|
OffsetBackgroundRect(widgetRect, CAPTIONBUTTON_MINIMIZE);
|
|
|
|
}
|
|
|
|
else if (aWidgetType == NS_THEME_WINDOW_BUTTON_MAXIMIZE ||
|
|
|
|
aWidgetType == NS_THEME_WINDOW_BUTTON_RESTORE) {
|
|
|
|
OffsetBackgroundRect(widgetRect, CAPTIONBUTTON_RESTORE);
|
|
|
|
}
|
|
|
|
else if (aWidgetType == NS_THEME_WINDOW_BUTTON_CLOSE) {
|
|
|
|
OffsetBackgroundRect(widgetRect, CAPTIONBUTTON_CLOSE);
|
|
|
|
}
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t oldTA = SetTextAlign(hdc, TA_TOP | TA_LEFT | TA_NOUPDATECP);
|
2010-08-10 05:49:35 +04:00
|
|
|
DrawFrameControl(hdc, &widgetRect, part, state);
|
|
|
|
SetTextAlign(hdc, oldTA);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-11-16 16:51:47 +03:00
|
|
|
default:
|
|
|
|
rv = NS_ERROR_FAILURE;
|
|
|
|
break;
|
2005-08-20 11:13:11 +04:00
|
|
|
}
|
2006-01-20 07:14:05 +03:00
|
|
|
|
2007-03-03 03:18:34 +03:00
|
|
|
nativeDrawing.EndNativeDrawing();
|
2006-08-10 00:25:07 +04:00
|
|
|
|
2007-03-03 03:18:34 +03:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
2006-08-10 00:25:07 +04:00
|
|
|
|
2007-03-03 03:18:34 +03:00
|
|
|
if (nativeDrawing.ShouldRenderAgain())
|
|
|
|
goto RENDER_AGAIN;
|
|
|
|
|
|
|
|
nativeDrawing.PaintToContext();
|
2006-01-20 07:14:05 +03:00
|
|
|
|
2005-11-16 16:51:47 +03:00
|
|
|
return rv;
|
2005-08-20 11:13:11 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t
|
|
|
|
nsNativeThemeWin::GetWidgetNativeDrawingFlags(uint8_t aWidgetType)
|
2007-03-03 03:18:34 +03:00
|
|
|
{
|
|
|
|
switch (aWidgetType) {
|
|
|
|
case NS_THEME_BUTTON:
|
2013-12-09 03:23:28 +04:00
|
|
|
case NS_THEME_NUMBER_INPUT:
|
2014-06-14 16:48:08 +04:00
|
|
|
case NS_THEME_FOCUS_OUTLINE:
|
2007-03-03 03:18:34 +03:00
|
|
|
case NS_THEME_TEXTFIELD:
|
2007-05-07 06:06:58 +04:00
|
|
|
case NS_THEME_TEXTFIELD_MULTILINE:
|
2007-03-03 03:18:34 +03:00
|
|
|
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_MENULIST:
|
|
|
|
case NS_THEME_MENULIST_TEXTFIELD:
|
2007-03-03 03:18:34 +03:00
|
|
|
return
|
|
|
|
gfxWindowsNativeDrawing::CANNOT_DRAW_TO_COLOR_ALPHA |
|
|
|
|
gfxWindowsNativeDrawing::CAN_AXIS_ALIGNED_SCALE |
|
|
|
|
gfxWindowsNativeDrawing::CANNOT_COMPLEX_TRANSFORM;
|
|
|
|
|
|
|
|
// need to check these others
|
2013-04-03 14:07:12 +04:00
|
|
|
case NS_THEME_RANGE:
|
|
|
|
case NS_THEME_RANGE_THUMB:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SCROLLBARBUTTON_UP:
|
|
|
|
case NS_THEME_SCROLLBARBUTTON_DOWN:
|
|
|
|
case NS_THEME_SCROLLBARBUTTON_LEFT:
|
|
|
|
case NS_THEME_SCROLLBARBUTTON_RIGHT:
|
|
|
|
case NS_THEME_SCROLLBARTHUMB_VERTICAL:
|
|
|
|
case NS_THEME_SCROLLBARTHUMB_HORIZONTAL:
|
2015-12-22 07:05:00 +03:00
|
|
|
case NS_THEME_SCROLLBAR_VERTICAL:
|
|
|
|
case NS_THEME_SCROLLBAR_HORIZONTAL:
|
2007-03-03 03:18:34 +03:00
|
|
|
case NS_THEME_SCALE_HORIZONTAL:
|
|
|
|
case NS_THEME_SCALE_VERTICAL:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SCALETHUMB_HORIZONTAL:
|
|
|
|
case NS_THEME_SCALETHUMB_VERTICAL:
|
2017-11-29 05:43:13 +03:00
|
|
|
case NS_THEME_INNER_SPIN_BUTTON:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_SPINNER_UPBUTTON:
|
|
|
|
case NS_THEME_SPINNER_DOWNBUTTON:
|
2007-03-03 03:18:34 +03:00
|
|
|
case NS_THEME_LISTBOX:
|
|
|
|
case NS_THEME_TREEVIEW:
|
|
|
|
case NS_THEME_TOOLTIP:
|
|
|
|
case NS_THEME_STATUSBAR:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_STATUSBARPANEL:
|
2016-05-19 11:58:00 +03:00
|
|
|
case NS_THEME_RESIZERPANEL:
|
2007-03-03 03:18:34 +03:00
|
|
|
case NS_THEME_RESIZER:
|
|
|
|
case NS_THEME_PROGRESSBAR:
|
|
|
|
case NS_THEME_PROGRESSBAR_VERTICAL:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_PROGRESSCHUNK:
|
|
|
|
case NS_THEME_PROGRESSCHUNK_VERTICAL:
|
2007-03-03 03:18:34 +03:00
|
|
|
case NS_THEME_TAB:
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_TABPANEL:
|
|
|
|
case NS_THEME_TABPANELS:
|
2007-03-03 03:18:34 +03:00
|
|
|
case NS_THEME_MENUBAR:
|
|
|
|
case NS_THEME_MENUPOPUP:
|
|
|
|
case NS_THEME_MENUITEM:
|
|
|
|
break;
|
|
|
|
|
|
|
|
// the dropdown button /almost/ renders correctly with scaling,
|
|
|
|
// except that the graphic in the dropdown button (the downward arrow)
|
|
|
|
// doesn't get scaled up.
|
2016-05-18 20:29:56 +03:00
|
|
|
case NS_THEME_MENULIST_BUTTON:
|
2007-03-03 03:18:34 +03:00
|
|
|
// these are definitely no; they're all graphics that don't get scaled up
|
|
|
|
case NS_THEME_CHECKBOX:
|
|
|
|
case NS_THEME_RADIO:
|
2009-03-12 05:11:01 +03:00
|
|
|
case NS_THEME_GROUPBOX:
|
2007-03-03 03:18:34 +03:00
|
|
|
case NS_THEME_CHECKMENUITEM:
|
|
|
|
case NS_THEME_RADIOMENUITEM:
|
2007-07-14 19:11:37 +04:00
|
|
|
case NS_THEME_MENUCHECKBOX:
|
|
|
|
case NS_THEME_MENURADIO:
|
|
|
|
case NS_THEME_MENUARROW:
|
2007-03-03 03:18:34 +03:00
|
|
|
return
|
|
|
|
gfxWindowsNativeDrawing::CANNOT_DRAW_TO_COLOR_ALPHA |
|
|
|
|
gfxWindowsNativeDrawing::CANNOT_AXIS_ALIGNED_SCALE |
|
|
|
|
gfxWindowsNativeDrawing::CANNOT_COMPLEX_TRANSFORM;
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
gfxWindowsNativeDrawing::CANNOT_DRAW_TO_COLOR_ALPHA |
|
|
|
|
gfxWindowsNativeDrawing::CANNOT_AXIS_ALIGNED_SCALE |
|
|
|
|
gfxWindowsNativeDrawing::CANNOT_COMPLEX_TRANSFORM;
|
|
|
|
}
|
2005-08-20 11:13:11 +04:00
|
|
|
|
2005-08-20 11:11:56 +04:00
|
|
|
///////////////////////////////////////////
|
|
|
|
// Creation Routine
|
|
|
|
///////////////////////////////////////////
|
2009-02-18 21:38:37 +03:00
|
|
|
|
|
|
|
// from nsWindow.cpp
|
2011-09-29 10:19:26 +04:00
|
|
|
extern bool gDisableNativeTheme;
|
2009-02-18 21:38:37 +03:00
|
|
|
|
2010-06-10 22:11:40 +04:00
|
|
|
nsresult NS_NewNativeTheme(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
2005-08-20 11:11:56 +04:00
|
|
|
{
|
2009-02-18 21:38:37 +03:00
|
|
|
if (gDisableNativeTheme)
|
|
|
|
return NS_ERROR_NO_INTERFACE;
|
|
|
|
|
2005-08-20 11:11:56 +04:00
|
|
|
if (aOuter)
|
|
|
|
return NS_ERROR_NO_AGGREGATION;
|
|
|
|
|
|
|
|
nsNativeThemeWin* theme = new nsNativeThemeWin();
|
|
|
|
if (!theme)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
return theme->QueryInterface(aIID, aResult);
|
2005-08-20 11:13:13 +04:00
|
|
|
}
|