2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2008-04-19 15:43:48 +00:00
|
|
|
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QStyle>
|
|
|
|
#include <QPalette>
|
|
|
|
#include <QRect>
|
|
|
|
#include <QPainter>
|
|
|
|
#include <QStyleOption>
|
2008-04-19 15:44:03 +00:00
|
|
|
#include <QStyleOptionFrameV2>
|
|
|
|
#include <QStyleOptionButton>
|
|
|
|
#include <QFlags>
|
2008-04-21 11:20:32 +00:00
|
|
|
#include <QStyleOptionComboBox>
|
2008-04-19 15:43:48 +00:00
|
|
|
|
2010-03-04 21:51:42 +00:00
|
|
|
#include "nsIFrame.h"
|
|
|
|
|
2008-04-19 15:44:03 +00:00
|
|
|
#include "nsCoord.h"
|
2008-04-19 15:43:48 +00:00
|
|
|
#include "nsNativeThemeQt.h"
|
2008-04-21 11:20:32 +00:00
|
|
|
#include "nsPresContext.h"
|
2008-04-19 15:44:07 +00:00
|
|
|
|
2008-04-19 15:43:48 +00:00
|
|
|
#include "nsRect.h"
|
|
|
|
#include "nsSize.h"
|
|
|
|
#include "nsTransform2D.h"
|
|
|
|
#include "nsThemeConstants.h"
|
|
|
|
#include "nsIServiceManager.h"
|
2008-04-19 15:53:54 +00:00
|
|
|
#include "nsIDOMHTMLInputElement.h"
|
2008-04-19 15:43:48 +00:00
|
|
|
|
2008-04-19 15:44:03 +00:00
|
|
|
|
2008-04-19 15:43:48 +00:00
|
|
|
#include "gfxASurface.h"
|
|
|
|
#include "gfxContext.h"
|
2010-02-20 03:46:54 +00:00
|
|
|
#include "gfxQtPlatform.h"
|
2008-04-19 15:43:48 +00:00
|
|
|
#include "gfxQPainterSurface.h"
|
2010-02-20 03:46:54 +00:00
|
|
|
#ifdef MOZ_X11
|
|
|
|
#include "gfxXlibSurface.h"
|
|
|
|
#endif
|
2011-04-08 01:04:40 +00:00
|
|
|
#include "nsRenderingContext.h"
|
2008-04-19 15:43:48 +00:00
|
|
|
|
2008-04-19 16:06:26 +00:00
|
|
|
nsNativeThemeQt::nsNativeThemeQt()
|
2008-04-19 15:43:48 +00:00
|
|
|
{
|
2008-04-19 16:07:29 +00:00
|
|
|
mNoBackgroundPalette.setColor(QPalette::Window, Qt::transparent);
|
2008-04-19 15:43:48 +00:00
|
|
|
ThemeChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsNativeThemeQt::~nsNativeThemeQt()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-11-13 08:19:38 +00:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED1(nsNativeThemeQt, nsNativeTheme, nsITheme)
|
2008-04-19 15:43:48 +00:00
|
|
|
|
2008-04-19 16:06:26 +00:00
|
|
|
static inline QRect qRectInPixels(const nsRect &aRect,
|
2012-08-22 15:56:38 +00:00
|
|
|
const int32_t p2a)
|
2008-04-19 15:43:48 +00:00
|
|
|
{
|
2008-04-19 16:06:26 +00:00
|
|
|
return QRect(NSAppUnitsToIntPixels(aRect.x, p2a),
|
|
|
|
NSAppUnitsToIntPixels(aRect.y, p2a),
|
|
|
|
NSAppUnitsToIntPixels(aRect.width, p2a),
|
|
|
|
NSAppUnitsToIntPixels(aRect.height, p2a));
|
2008-04-19 15:43:48 +00:00
|
|
|
}
|
|
|
|
|
2010-02-20 03:46:54 +00:00
|
|
|
static inline QImage::Format
|
2013-09-24 20:45:13 +00:00
|
|
|
_qimage_from_gfximage_format (gfxImageFormat aFormat)
|
2010-02-20 03:46:54 +00:00
|
|
|
{
|
|
|
|
switch (aFormat) {
|
2014-01-23 18:26:40 +00:00
|
|
|
case gfxImageFormat::ARGB32:
|
2010-02-20 03:46:54 +00:00
|
|
|
return QImage::Format_ARGB32_Premultiplied;
|
2014-01-23 18:26:40 +00:00
|
|
|
case gfxImageFormat::RGB24:
|
2010-02-20 03:46:54 +00:00
|
|
|
return QImage::Format_RGB32;
|
2014-01-23 18:26:40 +00:00
|
|
|
case gfxImageFormat::RGB16_565:
|
2010-06-11 09:33:22 +00:00
|
|
|
return QImage::Format_RGB16;
|
2014-01-23 18:26:40 +00:00
|
|
|
case gfxImageFormat::A8:
|
2010-02-20 03:46:54 +00:00
|
|
|
return QImage::Format_Indexed8;
|
2014-01-23 18:26:40 +00:00
|
|
|
case gfxImageFormat::A1:
|
2010-02-20 03:46:54 +00:00
|
|
|
#ifdef WORDS_BIGENDIAN
|
|
|
|
return QImage::Format_Mono;
|
|
|
|
#else
|
|
|
|
return QImage::Format_MonoLSB;
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
return QImage::Format_Invalid;
|
|
|
|
}
|
|
|
|
|
|
|
|
return QImage::Format_Mono;
|
|
|
|
}
|
|
|
|
|
2008-04-19 15:43:48 +00:00
|
|
|
NS_IMETHODIMP
|
2011-04-08 01:04:40 +00:00
|
|
|
nsNativeThemeQt::DrawWidgetBackground(nsRenderingContext* aContext,
|
2008-04-19 15:43:48 +00:00
|
|
|
nsIFrame* aFrame,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t aWidgetType,
|
2008-04-19 15:43:48 +00:00
|
|
|
const nsRect& aRect,
|
|
|
|
const nsRect& aClipRect)
|
|
|
|
{
|
|
|
|
gfxContext* context = aContext->ThebesContext();
|
2008-04-19 15:44:03 +00:00
|
|
|
nsRefPtr<gfxASurface> surface = context->CurrentSurface();
|
2008-04-19 16:06:26 +00:00
|
|
|
|
2010-10-05 06:15:57 +00:00
|
|
|
#ifdef CAIRO_HAS_QT_SURFACE
|
2014-01-23 18:26:40 +00:00
|
|
|
if (surface->GetType() == gfxSurfaceType::QPainter) {
|
2010-02-20 03:46:54 +00:00
|
|
|
gfxQPainterSurface* qSurface = (gfxQPainterSurface*) (surface.get());
|
|
|
|
QPainter *painter = qSurface->GetQPainter();
|
|
|
|
NS_ASSERTION(painter, "Where'd my QPainter go?");
|
|
|
|
if (!painter)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
return DrawWidgetBackground(painter, aContext,
|
|
|
|
aFrame, aWidgetType,
|
|
|
|
aRect, aClipRect);
|
2010-10-05 06:15:57 +00:00
|
|
|
} else
|
|
|
|
#endif
|
2014-01-23 18:26:40 +00:00
|
|
|
if (surface->GetType() == gfxSurfaceType::Image) {
|
2010-02-20 03:46:54 +00:00
|
|
|
gfxImageSurface* qSurface = (gfxImageSurface*) (surface.get());
|
|
|
|
QImage tempQImage(qSurface->Data(),
|
|
|
|
qSurface->Width(),
|
|
|
|
qSurface->Height(),
|
|
|
|
qSurface->Stride(),
|
|
|
|
_qimage_from_gfximage_format(qSurface->Format()));
|
|
|
|
QPainter painter(&tempQImage);
|
|
|
|
return DrawWidgetBackground(&painter, aContext,
|
|
|
|
aFrame, aWidgetType,
|
|
|
|
aRect, aClipRect);
|
|
|
|
}
|
2012-03-22 23:24:40 +00:00
|
|
|
#if defined(MOZ_X11) && defined(Q_WS_X11)
|
2014-01-23 18:26:40 +00:00
|
|
|
else if (surface->GetType() == gfxSurfaceType::Xlib) {
|
2010-02-20 03:46:54 +00:00
|
|
|
gfxXlibSurface* qSurface = (gfxXlibSurface*) (surface.get());
|
|
|
|
QPixmap pixmap(QPixmap::fromX11Pixmap(qSurface->XDrawable()));
|
|
|
|
QPainter painter(&pixmap);
|
|
|
|
return DrawWidgetBackground(&painter, aContext,
|
|
|
|
aFrame, aWidgetType,
|
|
|
|
aRect, aClipRect);
|
|
|
|
}
|
|
|
|
#endif
|
2008-04-19 16:07:29 +00:00
|
|
|
|
2010-02-20 03:46:54 +00:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
2008-04-19 16:06:26 +00:00
|
|
|
|
2010-02-20 03:46:54 +00:00
|
|
|
nsresult
|
|
|
|
nsNativeThemeQt::DrawWidgetBackground(QPainter *qPainter,
|
2011-04-08 01:04:40 +00:00
|
|
|
nsRenderingContext* aContext,
|
2010-02-20 03:46:54 +00:00
|
|
|
nsIFrame* aFrame,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t aWidgetType,
|
2010-02-20 03:46:54 +00:00
|
|
|
const nsRect& aRect,
|
|
|
|
const nsRect& aClipRect)
|
2008-04-19 15:43:48 +00:00
|
|
|
|
2010-02-20 03:46:54 +00:00
|
|
|
{
|
|
|
|
gfxContext* context = aContext->ThebesContext();
|
|
|
|
nsRefPtr<gfxASurface> surface = context->CurrentSurface();
|
2008-04-19 16:07:29 +00:00
|
|
|
|
2010-02-20 03:46:54 +00:00
|
|
|
context->UpdateSurfaceClip();
|
2008-04-19 15:43:48 +00:00
|
|
|
|
|
|
|
QStyle* style = qApp->style();
|
|
|
|
|
2008-04-19 16:06:26 +00:00
|
|
|
qPainter->save();
|
2008-04-19 15:43:48 +00:00
|
|
|
|
2008-04-19 16:06:26 +00:00
|
|
|
gfxPoint offs = surface->GetDeviceOffset();
|
|
|
|
qPainter->translate(offs.x, offs.y);
|
2008-04-19 15:44:07 +00:00
|
|
|
|
2008-04-19 16:06:26 +00:00
|
|
|
gfxMatrix ctm = context->CurrentMatrix();
|
|
|
|
if (!ctm.HasNonTranslation()) {
|
|
|
|
ctm.x0 = NSToCoordRound(ctm.x0);
|
|
|
|
ctm.y0 = NSToCoordRound(ctm.y0);
|
|
|
|
}
|
|
|
|
|
2009-06-13 01:41:41 +00:00
|
|
|
QMatrix qctm(ctm.xx, ctm.yx, ctm.xy, ctm.yy, ctm.x0, ctm.y0);
|
2008-04-19 16:06:26 +00:00
|
|
|
qPainter->setWorldMatrix(qctm, true);
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t p2a = aContext->AppUnitsPerDevPixel();
|
2008-04-19 16:06:26 +00:00
|
|
|
|
|
|
|
QRect r = qRectInPixels(aRect, p2a);
|
|
|
|
QRect cr = qRectInPixels(aClipRect, p2a);
|
2008-04-19 15:43:48 +00:00
|
|
|
|
2008-04-19 16:07:29 +00:00
|
|
|
QStyle::State extraFlags = QStyle::State_None;
|
2008-04-19 15:43:48 +00:00
|
|
|
|
|
|
|
switch (aWidgetType) {
|
|
|
|
case NS_THEME_RADIO:
|
2008-11-03 13:12:59 +00:00
|
|
|
case NS_THEME_CHECKBOX: {
|
2008-04-19 16:07:29 +00:00
|
|
|
QStyleOptionButton opt;
|
|
|
|
InitButtonStyle (aWidgetType, aFrame, r, opt);
|
|
|
|
|
2008-11-03 13:12:59 +00:00
|
|
|
if (aWidgetType == NS_THEME_CHECKBOX)
|
2008-04-19 16:07:29 +00:00
|
|
|
{
|
|
|
|
style->drawPrimitive (QStyle::PE_IndicatorCheckBox, &opt, qPainter);
|
|
|
|
} else {
|
|
|
|
style->drawPrimitive (QStyle::PE_IndicatorRadioButton, &opt, qPainter);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NS_THEME_BUTTON:
|
|
|
|
case NS_THEME_BUTTON_BEVEL: {
|
|
|
|
QStyleOptionButton opt;
|
|
|
|
InitButtonStyle (aWidgetType, aFrame, r, opt);
|
|
|
|
|
|
|
|
if (aWidgetType == NS_THEME_BUTTON) {
|
|
|
|
style->drawPrimitive(QStyle::PE_PanelButtonCommand, &opt, qPainter);
|
|
|
|
if (IsDefaultButton(aFrame))
|
|
|
|
style->drawPrimitive(QStyle::PE_FrameDefaultButton, &opt, qPainter);
|
|
|
|
} else {
|
|
|
|
style->drawPrimitive(QStyle::PE_PanelButtonBevel, &opt, qPainter);
|
|
|
|
style->drawPrimitive(QStyle::PE_FrameButtonBevel, &opt, qPainter);
|
|
|
|
}
|
2008-04-19 15:43:48 +00:00
|
|
|
break;
|
2008-04-19 15:44:03 +00:00
|
|
|
}
|
2008-04-19 15:53:24 +00:00
|
|
|
case NS_THEME_SCROLLBAR: {
|
2008-04-21 14:48:12 +00:00
|
|
|
qPainter->fillRect(r, qApp->palette().brush(QPalette::Normal, QPalette::Window));
|
2008-04-19 15:43:48 +00:00
|
|
|
break;
|
2008-04-19 15:53:24 +00:00
|
|
|
}
|
|
|
|
case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL: {
|
2008-04-21 14:48:12 +00:00
|
|
|
qPainter->fillRect(r, qApp->palette().brush(QPalette::Active, QPalette::Window));
|
2008-04-19 15:53:24 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NS_THEME_SCROLLBAR_TRACK_VERTICAL: {
|
2008-04-21 14:48:12 +00:00
|
|
|
qPainter->fillRect(r, qApp->palette().brush(QPalette::Active, QPalette::Window));
|
2008-04-19 15:53:24 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-04-21 14:48:12 +00:00
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_LEFT: {
|
2008-05-06 13:41:32 +00:00
|
|
|
QStyleOptionSlider opt;
|
|
|
|
InitPlainStyle(aWidgetType, aFrame, r, (QStyleOption&)opt, QStyle::State_Horizontal);
|
|
|
|
opt.orientation = Qt::Horizontal;
|
2013-10-08 18:47:49 +00:00
|
|
|
style->drawControl(QStyle::CE_ScrollBarSubLine, &opt, qPainter, nullptr);
|
2008-04-21 14:48:12 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_RIGHT: {
|
2008-05-06 13:41:32 +00:00
|
|
|
QStyleOptionSlider opt;
|
|
|
|
InitPlainStyle(aWidgetType, aFrame, r, (QStyleOption&)opt, QStyle::State_Horizontal);
|
|
|
|
opt.orientation = Qt::Horizontal;
|
2013-10-08 18:47:49 +00:00
|
|
|
style->drawControl(QStyle::CE_ScrollBarAddLine, &opt, qPainter, nullptr);
|
2008-04-21 14:48:12 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-05-06 13:41:32 +00:00
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_UP: {
|
|
|
|
QStyleOptionSlider opt;
|
|
|
|
InitPlainStyle(aWidgetType, aFrame, r, (QStyleOption&)opt);
|
|
|
|
opt.orientation = Qt::Vertical;
|
2013-10-08 18:47:49 +00:00
|
|
|
style->drawControl(QStyle::CE_ScrollBarSubLine, &opt, qPainter, nullptr);
|
2008-05-06 13:41:32 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-04-21 14:48:12 +00:00
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_DOWN: {
|
2008-05-06 13:41:32 +00:00
|
|
|
QStyleOptionSlider opt;
|
|
|
|
InitPlainStyle(aWidgetType, aFrame, r, (QStyleOption&)opt);
|
|
|
|
opt.orientation = Qt::Vertical;
|
2013-10-08 18:47:49 +00:00
|
|
|
style->drawControl(QStyle::CE_ScrollBarAddLine, &opt, qPainter, nullptr);
|
2008-04-19 15:53:24 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-04-21 14:48:12 +00:00
|
|
|
case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL: {
|
2008-04-19 16:07:29 +00:00
|
|
|
extraFlags |= QStyle::State_Horizontal;
|
2008-04-21 14:48:12 +00:00
|
|
|
QStyleOptionSlider option;
|
|
|
|
InitPlainStyle(aWidgetType, aFrame, r, (QStyleOption&)option, extraFlags);
|
|
|
|
option.orientation = Qt::Horizontal;
|
2013-10-08 18:47:49 +00:00
|
|
|
style->drawControl(QStyle::CE_ScrollBarSlider, &option, qPainter, nullptr);
|
2008-04-21 14:48:12 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-04-19 15:53:28 +00:00
|
|
|
case NS_THEME_SCROLLBAR_THUMB_VERTICAL: {
|
2008-04-21 14:48:12 +00:00
|
|
|
QStyleOptionSlider option;
|
|
|
|
InitPlainStyle(aWidgetType, aFrame, r, (QStyleOption&)option, extraFlags);
|
|
|
|
option.orientation = Qt::Vertical;
|
2013-10-08 18:47:49 +00:00
|
|
|
style->drawControl(QStyle::CE_ScrollBarSlider, &option, qPainter, nullptr);
|
2008-04-21 11:20:32 +00:00
|
|
|
break;
|
2008-04-19 15:44:03 +00:00
|
|
|
}
|
2008-04-21 11:20:32 +00:00
|
|
|
case NS_THEME_DROPDOWN: {
|
|
|
|
QStyleOptionComboBox comboOpt;
|
|
|
|
|
|
|
|
InitComboStyle(aWidgetType, aFrame, r, comboOpt);
|
|
|
|
|
|
|
|
style->drawComplexControl(QStyle::CC_ComboBox, &comboOpt, qPainter);
|
2008-04-19 15:43:48 +00:00
|
|
|
break;
|
2008-04-21 11:20:32 +00:00
|
|
|
}
|
2008-09-20 08:05:36 +00:00
|
|
|
case NS_THEME_DROPDOWN_BUTTON: {
|
|
|
|
QStyleOptionComboBox option;
|
|
|
|
|
|
|
|
InitComboStyle(aWidgetType, aFrame, r, option);
|
|
|
|
|
|
|
|
style->drawPrimitive(QStyle::PE_FrameDefaultButton, &option, qPainter);
|
|
|
|
style->drawPrimitive(QStyle::PE_IndicatorSpinDown, &option, qPainter);
|
2008-04-19 15:43:48 +00:00
|
|
|
break;
|
2008-09-20 08:05:36 +00:00
|
|
|
}
|
2008-04-19 15:43:48 +00:00
|
|
|
case NS_THEME_DROPDOWN_TEXT:
|
|
|
|
case NS_THEME_DROPDOWN_TEXTFIELD:
|
2013-12-08 23:23:28 +00:00
|
|
|
case NS_THEME_NUMBER_INPUT:
|
2008-04-19 15:43:48 +00:00
|
|
|
case NS_THEME_TEXTFIELD:
|
2008-04-19 15:53:50 +00:00
|
|
|
case NS_THEME_TEXTFIELD_MULTILINE:
|
2008-04-19 15:43:48 +00:00
|
|
|
case NS_THEME_LISTBOX: {
|
2008-04-19 16:07:29 +00:00
|
|
|
QStyleOptionFrameV2 frameOpt;
|
2010-10-20 11:26:32 +00:00
|
|
|
nsEventStates eventState = GetContentState(aFrame, aWidgetType);
|
2010-09-20 01:16:49 +00:00
|
|
|
|
2010-09-28 01:25:18 +00:00
|
|
|
if (!IsDisabled(aFrame, eventState))
|
2008-04-19 16:07:29 +00:00
|
|
|
frameOpt.state |= QStyle::State_Enabled;
|
2008-04-19 15:44:16 +00:00
|
|
|
|
2008-04-19 16:07:29 +00:00
|
|
|
frameOpt.rect = r;
|
|
|
|
frameOpt.features = QStyleOptionFrameV2::Flat;
|
2008-04-19 15:53:24 +00:00
|
|
|
|
2013-12-08 23:23:28 +00:00
|
|
|
if (aWidgetType == NS_THEME_NUMBER_INPUT ||
|
|
|
|
aWidgetType == NS_THEME_TEXTFIELD ||
|
|
|
|
aWidgetType == NS_THEME_TEXTFIELD_MULTILINE) {
|
2008-04-19 16:10:01 +00:00
|
|
|
QRect contentRect = style->subElementRect(QStyle::SE_LineEditContents, &frameOpt);
|
2008-04-21 11:20:32 +00:00
|
|
|
contentRect.adjust(mFrameWidth, mFrameWidth, -mFrameWidth, -mFrameWidth);
|
2008-04-19 16:10:01 +00:00
|
|
|
qPainter->fillRect(contentRect, QBrush(Qt::white));
|
|
|
|
}
|
|
|
|
|
|
|
|
frameOpt.palette = mNoBackgroundPalette;
|
2013-10-08 18:47:49 +00:00
|
|
|
style->drawPrimitive(QStyle::PE_FrameLineEdit, &frameOpt, qPainter, nullptr);
|
2008-04-19 15:43:48 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-09-17 14:40:06 +00:00
|
|
|
case NS_THEME_MENUPOPUP: {
|
|
|
|
QStyleOptionMenuItem option;
|
|
|
|
InitPlainStyle(aWidgetType, aFrame, r, (QStyleOption&)option, extraFlags);
|
2013-10-08 18:47:49 +00:00
|
|
|
style->drawPrimitive(QStyle::PE_FrameMenu, &option, qPainter, nullptr);
|
2008-09-17 14:40:06 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-04-19 15:43:48 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-04-19 15:44:03 +00:00
|
|
|
|
2008-04-19 15:44:16 +00:00
|
|
|
qPainter->restore();
|
2008-04-19 15:43:48 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-04-17 01:22:44 +00:00
|
|
|
nsNativeThemeQt::GetWidgetBorder(nsDeviceContext* ,
|
2008-04-19 15:43:48 +00:00
|
|
|
nsIFrame* aFrame,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t aWidgetType,
|
2009-02-11 13:51:06 +00:00
|
|
|
nsIntMargin* aResult)
|
2008-04-19 15:43:48 +00:00
|
|
|
{
|
|
|
|
(*aResult).top = (*aResult).bottom = (*aResult).left = (*aResult).right = 0;
|
|
|
|
|
2008-09-17 14:40:06 +00:00
|
|
|
QStyle* style = qApp->style();
|
|
|
|
switch(aWidgetType) {
|
2008-04-19 15:44:03 +00:00
|
|
|
// case NS_THEME_TEXTFIELD:
|
|
|
|
// case NS_THEME_LISTBOX:
|
2008-09-17 14:40:06 +00:00
|
|
|
case NS_THEME_MENUPOPUP: {
|
|
|
|
(*aResult).top = (*aResult).bottom = (*aResult).left = (*aResult).right = style->pixelMetric(QStyle::PM_MenuPanelWidth);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-04-19 15:43:48 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2011-04-17 01:22:44 +00:00
|
|
|
nsNativeThemeQt::GetWidgetPadding(nsDeviceContext* ,
|
2012-08-22 15:56:38 +00:00
|
|
|
nsIFrame*, uint8_t aWidgetType,
|
2009-02-11 13:51:06 +00:00
|
|
|
nsIntMargin* aResult)
|
2008-04-19 15:43:48 +00:00
|
|
|
{
|
2008-04-19 16:10:01 +00:00
|
|
|
// XXX: Where to get padding values, framewidth?
|
2013-12-08 23:23:28 +00:00
|
|
|
if (aWidgetType == NS_THEME_NUMBER_INPUT ||
|
|
|
|
aWidgetType == NS_THEME_TEXTFIELD ||
|
2008-04-21 11:20:32 +00:00
|
|
|
aWidgetType == NS_THEME_TEXTFIELD_MULTILINE ||
|
|
|
|
aWidgetType == NS_THEME_DROPDOWN) {
|
|
|
|
aResult->SizeTo(2, 2, 2, 2);
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2008-04-21 11:20:32 +00:00
|
|
|
}
|
2008-04-22 09:33:33 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2008-04-19 15:43:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-04-08 01:04:40 +00:00
|
|
|
nsNativeThemeQt::GetMinimumWidgetSize(nsRenderingContext* aContext, nsIFrame* aFrame,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t aWidgetType,
|
2011-09-29 06:19:26 +00:00
|
|
|
nsIntSize* aResult, bool* aIsOverridable)
|
2008-04-19 15:43:48 +00:00
|
|
|
{
|
|
|
|
(*aResult).width = (*aResult).height = 0;
|
2011-10-17 14:59:28 +00:00
|
|
|
*aIsOverridable = true;
|
2008-04-19 15:43:48 +00:00
|
|
|
|
|
|
|
QStyle *s = qApp->style();
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t p2a = aContext->AppUnitsPerDevPixel();
|
2008-04-19 16:06:26 +00:00
|
|
|
|
2008-04-19 15:43:48 +00:00
|
|
|
switch (aWidgetType) {
|
2008-04-19 15:44:16 +00:00
|
|
|
case NS_THEME_RADIO:
|
|
|
|
case NS_THEME_CHECKBOX: {
|
2008-04-19 15:44:07 +00:00
|
|
|
nsRect frameRect = aFrame->GetRect();
|
|
|
|
|
2008-04-19 16:06:26 +00:00
|
|
|
QRect qRect = qRectInPixels(frameRect, p2a);
|
2008-04-19 15:44:07 +00:00
|
|
|
|
|
|
|
QStyleOptionButton option;
|
|
|
|
|
2008-04-19 16:07:29 +00:00
|
|
|
InitButtonStyle(aWidgetType, aFrame, qRect, option);
|
2008-04-19 15:44:07 +00:00
|
|
|
|
|
|
|
QRect rect = s->subElementRect(
|
2008-11-03 13:12:59 +00:00
|
|
|
(aWidgetType == NS_THEME_CHECKBOX) ?
|
2008-04-19 15:44:16 +00:00
|
|
|
QStyle::SE_CheckBoxIndicator :
|
|
|
|
QStyle::SE_RadioButtonIndicator,
|
|
|
|
&option,
|
2013-10-08 18:47:49 +00:00
|
|
|
nullptr);
|
2008-04-19 15:44:07 +00:00
|
|
|
|
|
|
|
(*aResult).width = rect.width();
|
|
|
|
(*aResult).height = rect.height();
|
|
|
|
break;
|
|
|
|
}
|
2008-04-19 15:44:16 +00:00
|
|
|
case NS_THEME_BUTTON: {
|
|
|
|
nsRect frameRect = aFrame->GetRect();
|
|
|
|
|
2008-04-19 16:06:26 +00:00
|
|
|
QRect qRect = qRectInPixels(frameRect, p2a);
|
2008-04-19 15:44:16 +00:00
|
|
|
|
|
|
|
QStyleOptionButton option;
|
|
|
|
|
2008-04-19 16:07:29 +00:00
|
|
|
InitButtonStyle(aWidgetType, aFrame, qRect, option);
|
2008-04-19 15:44:16 +00:00
|
|
|
|
|
|
|
QRect rect = s->subElementRect(
|
|
|
|
QStyle::SE_PushButtonFocusRect,
|
|
|
|
&option,
|
2013-10-08 18:47:49 +00:00
|
|
|
nullptr);
|
2008-04-19 15:44:03 +00:00
|
|
|
|
2008-04-19 15:43:48 +00:00
|
|
|
(*aResult).width = rect.width();
|
|
|
|
(*aResult).height = rect.height();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_UP:
|
2008-04-22 09:33:33 +00:00
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_DOWN: {
|
2008-04-19 15:43:48 +00:00
|
|
|
(*aResult).width = s->pixelMetric(QStyle::PM_ScrollBarExtent);
|
|
|
|
(*aResult).height = (*aResult).width;
|
2011-10-17 14:59:28 +00:00
|
|
|
//*aIsOverridable = false;
|
2008-04-19 15:43:48 +00:00
|
|
|
break;
|
2008-04-22 09:33:33 +00:00
|
|
|
}
|
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_LEFT:
|
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_RIGHT: {
|
|
|
|
(*aResult).height = s->pixelMetric(QStyle::PM_ScrollBarExtent);
|
|
|
|
(*aResult).width = (*aResult).height;
|
2011-10-17 14:59:28 +00:00
|
|
|
//*aIsOverridable = false;
|
2008-04-22 09:33:33 +00:00
|
|
|
break;
|
2008-04-21 11:20:32 +00:00
|
|
|
}
|
|
|
|
case NS_THEME_SCROLLBAR_THUMB_VERTICAL: {
|
2008-04-19 15:43:48 +00:00
|
|
|
(*aResult).width = s->pixelMetric(QStyle::PM_ScrollBarExtent);
|
|
|
|
(*aResult).height = s->pixelMetric(QStyle::PM_ScrollBarSliderMin);
|
2011-10-17 14:59:28 +00:00
|
|
|
//*aIsOverridable = false;
|
2008-04-19 15:43:48 +00:00
|
|
|
break;
|
2008-04-21 11:20:32 +00:00
|
|
|
}
|
|
|
|
case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL: {
|
2008-04-19 15:43:48 +00:00
|
|
|
(*aResult).width = s->pixelMetric(QStyle::PM_ScrollBarSliderMin);
|
|
|
|
(*aResult).height = s->pixelMetric(QStyle::PM_ScrollBarExtent);
|
2011-10-17 14:59:28 +00:00
|
|
|
//*aIsOverridable = false;
|
2008-04-19 15:43:48 +00:00
|
|
|
break;
|
2008-04-21 11:20:32 +00:00
|
|
|
}
|
|
|
|
case NS_THEME_SCROLLBAR_TRACK_VERTICAL: {
|
2008-04-19 15:53:24 +00:00
|
|
|
(*aResult).width = s->pixelMetric(QStyle::PM_ScrollBarExtent);
|
|
|
|
(*aResult).height = s->pixelMetric(QStyle::PM_SliderLength);
|
2008-04-19 15:43:48 +00:00
|
|
|
break;
|
2008-04-21 11:20:32 +00:00
|
|
|
}
|
|
|
|
case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL: {
|
2008-04-19 15:53:24 +00:00
|
|
|
(*aResult).width = s->pixelMetric(QStyle::PM_SliderLength);
|
|
|
|
(*aResult).height = s->pixelMetric(QStyle::PM_ScrollBarExtent);
|
2008-04-19 15:43:48 +00:00
|
|
|
break;
|
2008-04-21 11:20:32 +00:00
|
|
|
}
|
2008-04-19 15:43:48 +00:00
|
|
|
case NS_THEME_DROPDOWN_BUTTON: {
|
2008-04-21 11:20:32 +00:00
|
|
|
QStyleOptionComboBox comboOpt;
|
|
|
|
|
|
|
|
nsRect frameRect = aFrame->GetRect();
|
|
|
|
QRect qRect = qRectInPixels(frameRect, p2a);
|
|
|
|
comboOpt.rect = qRect;
|
|
|
|
|
|
|
|
InitComboStyle(aWidgetType, aFrame, qRect, comboOpt);
|
|
|
|
|
2013-10-08 18:47:49 +00:00
|
|
|
QRect subRect = s->subControlRect(QStyle::CC_ComboBox, &comboOpt,
|
|
|
|
QStyle::SC_ComboBoxArrow, nullptr);
|
2008-04-21 11:20:32 +00:00
|
|
|
|
|
|
|
(*aResult).width = subRect.width();
|
|
|
|
(*aResult).height = subRect.height();
|
2011-10-17 14:59:28 +00:00
|
|
|
//*aIsOverridable = false;
|
2008-04-21 11:20:32 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NS_THEME_DROPDOWN: {
|
|
|
|
QStyleOptionComboBox comboOpt;
|
|
|
|
|
2008-04-22 11:18:32 +00:00
|
|
|
nsRect frameRect = aFrame->GetRect();
|
2008-04-21 11:20:32 +00:00
|
|
|
QRect qRect = qRectInPixels(frameRect, p2a);
|
|
|
|
comboOpt.rect = qRect;
|
|
|
|
|
|
|
|
InitComboStyle(aWidgetType, aFrame, qRect, comboOpt);
|
|
|
|
|
|
|
|
QRect subRect = s->subControlRect(QStyle::CC_ComboBox,
|
|
|
|
&comboOpt,
|
|
|
|
QStyle::SC_ComboBoxFrame,
|
2013-10-08 18:47:49 +00:00
|
|
|
nullptr);
|
2008-04-21 11:20:32 +00:00
|
|
|
|
|
|
|
(*aResult).width = subRect.width();
|
|
|
|
(*aResult).height = subRect.height();
|
2011-10-17 14:59:28 +00:00
|
|
|
//*aIsOverridable = false;
|
2008-04-21 11:20:32 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NS_THEME_DROPDOWN_TEXT: {
|
|
|
|
QStyleOptionComboBox comboOpt;
|
|
|
|
|
|
|
|
nsRect frameRect = aFrame->GetRect();
|
|
|
|
|
|
|
|
QRect qRect = qRectInPixels(frameRect, p2a);
|
|
|
|
|
|
|
|
comboOpt.rect = qRect;
|
|
|
|
|
2013-10-08 18:47:49 +00:00
|
|
|
QRect subRect = s->subControlRect(QStyle::CC_ComboBox, &comboOpt,
|
|
|
|
QStyle::SC_ComboBoxEditField, nullptr);
|
2008-04-21 11:20:32 +00:00
|
|
|
|
|
|
|
(*aResult).width = subRect.width();
|
|
|
|
(*aResult).height = subRect.height();
|
2011-10-17 14:59:28 +00:00
|
|
|
//*aIsOverridable = false;
|
2008-04-21 11:20:32 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NS_THEME_DROPDOWN_TEXTFIELD: {
|
|
|
|
QStyleOptionComboBox comboOpt;
|
|
|
|
|
|
|
|
nsRect frameRect = aFrame->GetRect();
|
|
|
|
|
|
|
|
QRect qRect = qRectInPixels(frameRect, p2a);
|
|
|
|
|
|
|
|
comboOpt.rect = qRect;
|
|
|
|
|
2013-10-08 18:47:49 +00:00
|
|
|
QRect subRect = s->subControlRect(QStyle::CC_ComboBox, &comboOpt,
|
|
|
|
QStyle::SC_ComboBoxArrow, nullptr);
|
|
|
|
QRect subRect2 = s->subControlRect(QStyle::CC_ComboBox, &comboOpt,
|
|
|
|
QStyle::SC_ComboBoxFrame, nullptr);
|
2008-04-21 11:20:32 +00:00
|
|
|
|
|
|
|
(*aResult).width = subRect.width() + subRect2.width();
|
|
|
|
(*aResult).height = std::max(subRect.height(), subRect2.height());
|
2011-10-17 14:59:28 +00:00
|
|
|
//*aIsOverridable = false;
|
2008-04-19 15:43:48 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-12-08 23:23:28 +00:00
|
|
|
case NS_THEME_NUMBER_INPUT:
|
2008-04-19 15:43:48 +00:00
|
|
|
case NS_THEME_TEXTFIELD:
|
2008-04-19 15:53:50 +00:00
|
|
|
case NS_THEME_TEXTFIELD_MULTILINE:
|
2008-04-19 15:43:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsNativeThemeQt::WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType,
|
2011-09-29 06:19:26 +00:00
|
|
|
nsIAtom* aAttribute, bool* aShouldRepaint)
|
2008-04-19 15:43:48 +00:00
|
|
|
{
|
2013-02-25 20:25:16 +00:00
|
|
|
*aShouldRepaint = true;
|
2008-04-19 15:43:48 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsNativeThemeQt::ThemeChanged()
|
|
|
|
{
|
|
|
|
QStyle *s = qApp->style();
|
|
|
|
if (s)
|
2008-04-21 11:20:32 +00:00
|
|
|
mFrameWidth = s->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
2008-04-19 15:43:48 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2008-04-19 15:43:48 +00:00
|
|
|
nsNativeThemeQt::ThemeSupportsWidget(nsPresContext* aPresContext,
|
|
|
|
nsIFrame* aFrame,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t aWidgetType)
|
2008-04-19 15:43:48 +00:00
|
|
|
{
|
|
|
|
switch (aWidgetType) {
|
2008-04-19 15:53:24 +00:00
|
|
|
case NS_THEME_SCROLLBAR:
|
2008-04-19 15:44:16 +00:00
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_UP:
|
2008-04-19 15:53:24 +00:00
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_DOWN:
|
2008-04-19 15:53:28 +00:00
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_LEFT:
|
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_RIGHT:
|
|
|
|
case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
|
|
|
|
case NS_THEME_SCROLLBAR_THUMB_VERTICAL:
|
2008-04-19 15:44:03 +00:00
|
|
|
//case NS_THEME_SCROLLBAR_GRIPPER_HORIZONTAL:
|
|
|
|
//case NS_THEME_SCROLLBAR_GRIPPER_VERTICAL:
|
2008-04-19 15:53:24 +00:00
|
|
|
case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL:
|
|
|
|
case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
|
2008-04-19 15:43:48 +00:00
|
|
|
case NS_THEME_RADIO:
|
|
|
|
case NS_THEME_CHECKBOX:
|
|
|
|
case NS_THEME_BUTTON_BEVEL:
|
|
|
|
case NS_THEME_BUTTON:
|
2008-04-21 11:20:32 +00:00
|
|
|
case NS_THEME_DROPDOWN:
|
2008-04-29 10:24:51 +00:00
|
|
|
case NS_THEME_DROPDOWN_BUTTON:
|
2008-04-21 11:20:32 +00:00
|
|
|
case NS_THEME_DROPDOWN_TEXT:
|
2008-04-19 15:53:50 +00:00
|
|
|
case NS_THEME_DROPDOWN_TEXTFIELD:
|
2013-12-08 23:23:28 +00:00
|
|
|
case NS_THEME_NUMBER_INPUT:
|
2008-04-19 15:43:48 +00:00
|
|
|
case NS_THEME_TEXTFIELD:
|
2008-04-19 15:53:50 +00:00
|
|
|
case NS_THEME_TEXTFIELD_MULTILINE:
|
2008-04-21 11:20:32 +00:00
|
|
|
case NS_THEME_LISTBOX:
|
2008-09-17 14:40:06 +00:00
|
|
|
case NS_THEME_MENUPOPUP:
|
2008-04-29 08:03:54 +00:00
|
|
|
return !IsWidgetStyled(aPresContext, aFrame, aWidgetType);
|
2008-04-19 15:43:48 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2008-04-19 15:43:48 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2012-08-22 15:56:38 +00:00
|
|
|
nsNativeThemeQt::WidgetIsContainer(uint8_t aWidgetType)
|
2008-04-19 15:43:48 +00:00
|
|
|
{
|
2008-04-21 11:20:32 +00:00
|
|
|
// if (aWidgetType == NS_THEME_DROPDOWN_BUTTON ||
|
|
|
|
// aWidgetType == NS_THEME_RADIO ||
|
|
|
|
// aWidgetType == NS_THEME_CHECKBOX) {
|
2011-10-17 14:59:28 +00:00
|
|
|
// return false;
|
2008-04-21 11:20:32 +00:00
|
|
|
// }
|
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2008-04-19 15:43:48 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2013-05-13 23:47:03 +00:00
|
|
|
nsNativeThemeQt::ThemeDrawsFocusForWidget(uint8_t aWidgetType)
|
2008-04-19 15:43:48 +00:00
|
|
|
{
|
|
|
|
if (aWidgetType == NS_THEME_DROPDOWN ||
|
|
|
|
aWidgetType == NS_THEME_BUTTON ||
|
|
|
|
aWidgetType == NS_THEME_TREEVIEW_HEADER_CELL) {
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2008-04-19 15:43:48 +00:00
|
|
|
}
|
2008-04-21 11:20:32 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2008-04-19 15:43:48 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2008-04-19 15:43:48 +00:00
|
|
|
nsNativeThemeQt::ThemeNeedsComboboxDropmarker()
|
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2008-04-19 15:43:48 +00:00
|
|
|
}
|
2008-04-19 15:44:07 +00:00
|
|
|
|
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsNativeThemeQt::InitButtonStyle(uint8_t aWidgetType,
|
2008-04-19 16:07:29 +00:00
|
|
|
nsIFrame* aFrame,
|
|
|
|
QRect rect,
|
|
|
|
QStyleOptionButton &opt)
|
2008-04-19 15:44:07 +00:00
|
|
|
{
|
2010-10-20 11:26:32 +00:00
|
|
|
nsEventStates eventState = GetContentState(aFrame, aWidgetType);
|
2008-04-19 15:44:07 +00:00
|
|
|
|
2008-04-19 16:07:29 +00:00
|
|
|
opt.rect = rect;
|
|
|
|
opt.palette = mNoBackgroundPalette;
|
2008-04-19 15:44:07 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool isDisabled = IsDisabled(aFrame, eventState);
|
2010-09-28 01:25:18 +00:00
|
|
|
|
|
|
|
if (!isDisabled)
|
2008-04-19 16:07:29 +00:00
|
|
|
opt.state |= QStyle::State_Enabled;
|
2010-10-20 11:26:32 +00:00
|
|
|
if (eventState.HasState(NS_EVENT_STATE_HOVER))
|
2008-04-19 16:07:29 +00:00
|
|
|
opt.state |= QStyle::State_MouseOver;
|
2010-10-20 11:26:32 +00:00
|
|
|
if (eventState.HasState(NS_EVENT_STATE_FOCUS))
|
2008-04-19 16:07:29 +00:00
|
|
|
opt.state |= QStyle::State_HasFocus;
|
2010-10-20 11:26:32 +00:00
|
|
|
if (!isDisabled && eventState.HasState(NS_EVENT_STATE_ACTIVE))
|
2008-04-19 16:07:29 +00:00
|
|
|
// Don't allow sunken when disabled
|
|
|
|
opt.state |= QStyle::State_Sunken;
|
2008-04-19 15:44:16 +00:00
|
|
|
|
2008-04-19 16:07:29 +00:00
|
|
|
switch (aWidgetType) {
|
|
|
|
case NS_THEME_RADIO:
|
|
|
|
case NS_THEME_CHECKBOX:
|
|
|
|
if (IsChecked(aFrame))
|
|
|
|
opt.state |= QStyle::State_On;
|
|
|
|
else
|
|
|
|
opt.state |= QStyle::State_Off;
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
2010-10-20 11:26:32 +00:00
|
|
|
if (!eventState.HasState(NS_EVENT_STATE_ACTIVE))
|
2008-04-19 16:07:29 +00:00
|
|
|
opt.state |= QStyle::State_Raised;
|
|
|
|
break;
|
|
|
|
}
|
2008-04-19 15:44:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsNativeThemeQt::InitPlainStyle(uint8_t aWidgetType,
|
2008-04-19 16:07:29 +00:00
|
|
|
nsIFrame* aFrame,
|
|
|
|
QRect rect,
|
|
|
|
QStyleOption &opt,
|
|
|
|
QStyle::State extraFlags)
|
2008-04-19 15:44:16 +00:00
|
|
|
{
|
2010-10-20 11:26:32 +00:00
|
|
|
nsEventStates eventState = GetContentState(aFrame, aWidgetType);
|
2008-04-19 16:07:29 +00:00
|
|
|
|
|
|
|
opt.rect = rect;
|
|
|
|
|
2010-09-28 01:25:18 +00:00
|
|
|
if (!IsDisabled(aFrame, eventState))
|
2008-04-19 16:07:29 +00:00
|
|
|
opt.state |= QStyle::State_Enabled;
|
2010-10-20 11:26:32 +00:00
|
|
|
if (eventState.HasState(NS_EVENT_STATE_HOVER))
|
2008-04-19 16:07:29 +00:00
|
|
|
opt.state |= QStyle::State_MouseOver;
|
2010-10-20 11:26:32 +00:00
|
|
|
if (eventState.HasState(NS_EVENT_STATE_FOCUS))
|
2008-04-19 16:07:29 +00:00
|
|
|
opt.state |= QStyle::State_HasFocus;
|
2008-04-19 15:44:16 +00:00
|
|
|
|
2008-04-19 16:07:29 +00:00
|
|
|
opt.state |= extraFlags;
|
2008-04-19 15:44:16 +00:00
|
|
|
}
|
2008-04-21 11:20:32 +00:00
|
|
|
|
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsNativeThemeQt::InitComboStyle(uint8_t aWidgetType,
|
2008-04-21 11:20:32 +00:00
|
|
|
nsIFrame* aFrame,
|
|
|
|
QRect rect,
|
2008-04-22 09:33:33 +00:00
|
|
|
QStyleOptionComboBox &opt)
|
2008-04-21 11:20:32 +00:00
|
|
|
{
|
2010-10-20 11:26:32 +00:00
|
|
|
nsEventStates eventState = GetContentState(aFrame, aWidgetType);
|
2011-09-29 06:19:26 +00:00
|
|
|
bool isDisabled = IsDisabled(aFrame, eventState);
|
2008-04-21 11:20:32 +00:00
|
|
|
|
2010-09-28 01:25:18 +00:00
|
|
|
if (!isDisabled)
|
2008-04-21 11:20:32 +00:00
|
|
|
opt.state |= QStyle::State_Enabled;
|
2010-10-20 11:26:32 +00:00
|
|
|
if (eventState.HasState(NS_EVENT_STATE_HOVER))
|
2008-04-21 11:20:32 +00:00
|
|
|
opt.state |= QStyle::State_MouseOver;
|
2010-10-20 11:26:32 +00:00
|
|
|
if (eventState.HasState(NS_EVENT_STATE_FOCUS))
|
2008-04-21 11:20:32 +00:00
|
|
|
opt.state |= QStyle::State_HasFocus;
|
2010-10-20 11:26:32 +00:00
|
|
|
if (!eventState.HasState(NS_EVENT_STATE_ACTIVE))
|
2008-04-21 11:20:32 +00:00
|
|
|
opt.state |= QStyle::State_Raised;
|
2010-10-20 11:26:32 +00:00
|
|
|
if (!isDisabled && eventState.HasState(NS_EVENT_STATE_ACTIVE))
|
2008-04-21 11:20:32 +00:00
|
|
|
// Don't allow sunken when disabled
|
2008-04-22 09:33:33 +00:00
|
|
|
opt.state |= QStyle::State_Sunken;
|
2008-04-21 11:20:32 +00:00
|
|
|
|
|
|
|
opt.rect = rect;
|
|
|
|
opt.palette = mNoBackgroundPalette;
|
|
|
|
}
|