2008-04-19 08:43:48 -07:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* David Hyatt (hyatt@netscape.com).
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2001
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Lars Knoll <knoll@kde.org>
|
|
|
|
* Zack Rusin <zack@kde.org>
|
|
|
|
* Tim Hill (tim@prismelite.com)
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QStyle>
|
|
|
|
#include <QPalette>
|
|
|
|
#include <QComboBox>
|
|
|
|
#include <QRect>
|
|
|
|
#include <QPainter>
|
|
|
|
#include <QStyleOption>
|
2008-04-19 08:44:03 -07:00
|
|
|
#include <QStyleOptionFrameV2>
|
|
|
|
#include <QStyleOptionButton>
|
|
|
|
#include <QFlags>
|
2008-04-19 08:43:48 -07:00
|
|
|
|
2008-04-19 08:44:03 -07:00
|
|
|
#include "nsCoord.h"
|
2008-04-19 08:43:48 -07:00
|
|
|
#include "nsNativeThemeQt.h"
|
2008-04-19 08:44:03 -07:00
|
|
|
#include "nsIDeviceContext.h"
|
|
|
|
|
2008-04-19 08:43:48 -07:00
|
|
|
#include "nsRect.h"
|
|
|
|
#include "nsSize.h"
|
|
|
|
#include "nsTransform2D.h"
|
|
|
|
#include "nsThemeConstants.h"
|
|
|
|
#include "nsILookAndFeel.h"
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIEventStateManager.h"
|
|
|
|
#include <malloc.h>
|
|
|
|
|
2008-04-19 08:44:03 -07:00
|
|
|
|
2008-04-19 08:43:48 -07:00
|
|
|
#include "gfxASurface.h"
|
|
|
|
#include "gfxContext.h"
|
|
|
|
#include "gfxQPainterSurface.h"
|
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
|
|
|
|
nsNativeThemeQt::nsNativeThemeQt()
|
|
|
|
{
|
|
|
|
combo = new QComboBox((QWidget *)0);
|
|
|
|
combo->resize(0, 0);
|
|
|
|
ThemeChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsNativeThemeQt::~nsNativeThemeQt()
|
|
|
|
{
|
|
|
|
delete combo;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS1(nsNativeThemeQt, nsITheme)
|
|
|
|
|
2008-04-19 08:44:03 -07:00
|
|
|
static QRect qRectInPixels(const nsRect &aRect,
|
|
|
|
const nsTransform2D *aTrans, const PRInt32 p2a)
|
2008-04-19 08:43:48 -07:00
|
|
|
{
|
|
|
|
int x = aRect.x;
|
|
|
|
int y = aRect.y;
|
|
|
|
int w = aRect.width;
|
|
|
|
int h = aRect.height;
|
|
|
|
aTrans->TransformCoord(&x,&y,&w,&h);
|
2008-04-19 08:44:03 -07:00
|
|
|
return QRect(
|
|
|
|
NSAppUnitsToIntPixels(x, p2a),
|
|
|
|
NSAppUnitsToIntPixels(y, p2a),
|
|
|
|
NSAppUnitsToIntPixels(w, p2a),
|
|
|
|
NSAppUnitsToIntPixels(h, p2a));
|
2008-04-19 08:43:48 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsNativeThemeQt::DrawWidgetBackground(nsIRenderingContext* aContext,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
PRUint8 aWidgetType,
|
|
|
|
const nsRect& aRect,
|
|
|
|
const nsRect& aClipRect)
|
|
|
|
{
|
2008-04-19 08:44:03 -07:00
|
|
|
qDebug("%s : %d", __PRETTY_FUNCTION__, IsDisabled(aFrame));
|
2008-04-19 08:43:48 -07:00
|
|
|
|
|
|
|
gfxContext* context = aContext->ThebesContext();
|
2008-04-19 08:44:03 -07:00
|
|
|
nsRefPtr<gfxASurface> surface = context->CurrentSurface();
|
2008-04-19 08:43:48 -07:00
|
|
|
gfxASurface* raw = surface;
|
|
|
|
gfxQPainterSurface* qsurface = (gfxQPainterSurface*)raw;
|
|
|
|
QPainter* qpainter = qsurface->GetQPainter();
|
|
|
|
|
|
|
|
// qDebug("aWidgetType = %d", aWidgetType);
|
|
|
|
if (!qpainter)
|
|
|
|
return NS_OK;
|
|
|
|
|
2008-04-19 08:44:03 -07:00
|
|
|
nsCOMPtr<nsIDeviceContext> dctx = nsnull;
|
|
|
|
aContext->GetDeviceContext(*getter_AddRefs(dctx));
|
|
|
|
PRInt32 p2a = dctx->AppUnitsPerDevPixel();
|
|
|
|
|
2008-04-19 08:43:48 -07:00
|
|
|
QStyle* style = qApp->style();
|
2008-04-19 08:44:03 -07:00
|
|
|
// const QPalette::ColorGroup cg = qApp->palette().currentColorGroup();
|
2008-04-19 08:43:48 -07:00
|
|
|
|
|
|
|
nsTransform2D* curTrans;
|
|
|
|
aContext->GetCurrentTransform(curTrans);
|
|
|
|
|
2008-04-19 08:44:03 -07:00
|
|
|
QRect r = qRectInPixels(aRect, curTrans, p2a);
|
|
|
|
QRect cr = qRectInPixels(aClipRect, curTrans, p2a);
|
2008-04-19 08:43:48 -07:00
|
|
|
// context->UpdateGC();
|
|
|
|
qpainter->save();
|
|
|
|
qpainter->translate(r.x(), r.y());
|
|
|
|
r.translate(-r.x(), -r.y());
|
|
|
|
|
2008-04-19 08:44:03 -07:00
|
|
|
// qDebug("rect=%d %d %d %d\nr=%d %d %d %d",
|
|
|
|
// aRect.x, aRect.y, aRect.width, aRect.height,
|
|
|
|
// r.x(), r.y(), r.width(), r.height());
|
|
|
|
|
2008-04-19 08:43:48 -07:00
|
|
|
// QStyleOption option;
|
|
|
|
// option.direction = QApplication::layoutDirection();
|
|
|
|
// option.rect = r;
|
|
|
|
|
|
|
|
QStyle::PrimitiveElement pe = QStyle::PE_CustomBase;
|
|
|
|
|
2008-04-19 08:44:03 -07:00
|
|
|
QStyle::ControlElement ce = QStyle::CE_CustomBase;
|
2008-04-19 08:43:48 -07:00
|
|
|
|
|
|
|
QStyle::State flags = IsDisabled(aFrame) ?
|
|
|
|
QStyle::State_None :
|
|
|
|
QStyle::State_Enabled;
|
|
|
|
|
|
|
|
PRInt32 eventState = GetContentState(aFrame, aWidgetType);
|
|
|
|
// qDebug("eventState = %d", eventState);
|
|
|
|
|
2008-04-19 08:44:03 -07:00
|
|
|
if (eventState & NS_EVENT_STATE_HOVER) {
|
|
|
|
qDebug("NS_EVENT_STATE_HOVER");
|
2008-04-19 08:43:48 -07:00
|
|
|
flags |= QStyle::State_MouseOver;
|
2008-04-19 08:44:03 -07:00
|
|
|
}
|
|
|
|
if (eventState & NS_EVENT_STATE_FOCUS) {
|
|
|
|
qDebug("NS_EVENT_STATE_FOCUS");
|
2008-04-19 08:43:48 -07:00
|
|
|
flags |= QStyle::State_HasFocus;
|
2008-04-19 08:44:03 -07:00
|
|
|
}
|
|
|
|
if (eventState & NS_EVENT_STATE_ACTIVE) {
|
|
|
|
qDebug("NS_EVENT_STATE_ACTIVE");
|
2008-04-19 08:43:48 -07:00
|
|
|
flags |= QStyle::State_DownArrow;
|
2008-04-19 08:44:03 -07:00
|
|
|
}
|
2008-04-19 08:43:48 -07:00
|
|
|
|
|
|
|
switch (aWidgetType) {
|
|
|
|
case NS_THEME_RADIO:
|
2008-04-19 08:44:03 -07:00
|
|
|
case NS_THEME_RADIO_SMALL: {
|
|
|
|
qDebug("NS_THEME_RADIO");
|
|
|
|
|
|
|
|
flags |= IsChecked(aFrame) ? QStyle::State_On : QStyle::State_Off;
|
|
|
|
ce = QStyle::CE_RadioButton;
|
|
|
|
|
|
|
|
QStyleOptionButton option;
|
|
|
|
option.direction = QApplication::layoutDirection();
|
|
|
|
option.rect = r;
|
|
|
|
option.type = QStyleOption::SO_Button;
|
|
|
|
option.state = flags;
|
|
|
|
option.features = QStyleOptionButton::None;
|
|
|
|
|
|
|
|
style->drawControl(ce, &option, qpainter, NULL);
|
2008-04-19 08:43:48 -07:00
|
|
|
break;
|
2008-04-19 08:44:03 -07:00
|
|
|
}
|
|
|
|
case NS_THEME_CHECKBOX: {
|
|
|
|
qDebug("NS_THEME_CHECKBOX");
|
|
|
|
|
|
|
|
flags |= (IsChecked(aFrame) ? QStyle::State_On : QStyle::State_Off);
|
|
|
|
pe = QStyle::PE_IndicatorCheckBox;
|
|
|
|
|
|
|
|
QStyleOptionButton option;
|
|
|
|
option.direction = QApplication::layoutDirection();
|
|
|
|
option.rect = r;
|
|
|
|
option.type = QStyleOption::SO_Button;
|
|
|
|
option.state = flags;
|
|
|
|
option.features = QStyleOptionButton::None;
|
|
|
|
|
|
|
|
style->drawPrimitive(pe, &option, qpainter, NULL);
|
2008-04-19 08:43:48 -07:00
|
|
|
break;
|
2008-04-19 08:44:03 -07:00
|
|
|
}
|
2008-04-19 08:43:48 -07:00
|
|
|
case NS_THEME_SCROLLBAR:
|
|
|
|
case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL:
|
|
|
|
case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
|
2008-04-19 08:44:03 -07:00
|
|
|
qDebug("NS_THEME_SCROLLBAR 1");
|
|
|
|
qpainter->fillRect(r, qApp->palette().brush(QPalette::Active, QPalette::Background));
|
2008-04-19 08:43:48 -07:00
|
|
|
break;
|
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_LEFT:
|
|
|
|
// flags |= QStyle::State_Horizontal;
|
|
|
|
// fall through
|
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_UP:
|
|
|
|
// ce = QStyle::CE_ScrollBarSubLine;
|
2008-04-19 08:44:03 -07:00
|
|
|
qDebug("NS_THEME_SCROLLBAR_BUTTON 1");
|
2008-04-19 08:43:48 -07:00
|
|
|
break;
|
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_RIGHT:
|
|
|
|
// flags |= QStyle::State_Horizontal;
|
|
|
|
// fall through
|
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_DOWN:
|
|
|
|
// ce = QStyle::CE_ScrollBarAddLine;
|
2008-04-19 08:44:03 -07:00
|
|
|
qDebug("NS_THEME_SCROLLBAR_BUTTON 2");
|
2008-04-19 08:43:48 -07:00
|
|
|
break;
|
|
|
|
case NS_THEME_SCROLLBAR_GRIPPER_HORIZONTAL:
|
|
|
|
case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
|
|
|
|
// flags |= QStyle::State_Horizontal;
|
|
|
|
// fall through
|
|
|
|
case NS_THEME_SCROLLBAR_GRIPPER_VERTICAL:
|
|
|
|
case NS_THEME_SCROLLBAR_THUMB_VERTICAL:
|
2008-04-19 08:44:03 -07:00
|
|
|
qDebug("NS_THEME_SCROLLBAR 2");
|
2008-04-19 08:43:48 -07:00
|
|
|
// ce = QStyle::CE_ScrollBarSlider;
|
|
|
|
break;
|
|
|
|
case NS_THEME_BUTTON_BEVEL:
|
2008-04-19 08:44:03 -07:00
|
|
|
qDebug("NS_THEME_BUTTON_BEVEL");
|
2008-04-19 08:43:48 -07:00
|
|
|
// ce = QStyle::CE_PushButtonBevel;
|
|
|
|
// flags |= QStyle::State_Raised;
|
|
|
|
break;
|
2008-04-19 08:44:03 -07:00
|
|
|
case NS_THEME_BUTTON: {
|
|
|
|
qDebug("NS_THEME_BUTTON %d", IsDefaultButton(aFrame));
|
|
|
|
|
|
|
|
ce = QStyle::CE_PushButton;
|
|
|
|
flags |= QStyle::State_Raised;
|
|
|
|
|
|
|
|
QStyleOptionButton option;
|
|
|
|
option.direction = QApplication::layoutDirection();
|
|
|
|
option.rect = r;
|
|
|
|
option.type = QStyleOption::SO_Button;
|
|
|
|
option.state = flags;
|
|
|
|
option.features = QStyleOptionButton::None;
|
|
|
|
|
|
|
|
style->drawControl(ce, &option, qpainter, NULL);
|
2008-04-19 08:43:48 -07:00
|
|
|
break;
|
2008-04-19 08:44:03 -07:00
|
|
|
}
|
2008-04-19 08:43:48 -07:00
|
|
|
case NS_THEME_DROPDOWN:
|
2008-04-19 08:44:03 -07:00
|
|
|
qDebug("NS_THEME_DROPDOWN");
|
2008-04-19 08:43:48 -07:00
|
|
|
// style.drawComplexControl(QStyle::CC_ComboBox, qpainter, combo, r, cg, flags, QStyle::SC_ComboBoxFrame);
|
|
|
|
break;
|
|
|
|
case NS_THEME_DROPDOWN_BUTTON:
|
2008-04-19 08:44:03 -07:00
|
|
|
qDebug("NS_THEME_DROPDOWN_BUTTON");
|
2008-04-19 08:43:48 -07:00
|
|
|
// r.translate(frameWidth, -frameWidth);
|
|
|
|
// r.setHeight(r.height() + 2*frameWidth);
|
|
|
|
// style.drawComplexControl(QStyle::CC_ComboBox, qpainter, combo, r, cg, flags, QStyle::SC_ComboBoxArrow);
|
|
|
|
break;
|
|
|
|
case NS_THEME_DROPDOWN_TEXT:
|
|
|
|
case NS_THEME_DROPDOWN_TEXTFIELD:
|
2008-04-19 08:44:03 -07:00
|
|
|
qDebug("NS_THEME_DROPDOWN_TEXT");
|
2008-04-19 08:43:48 -07:00
|
|
|
break;
|
|
|
|
case NS_THEME_TEXTFIELD:
|
|
|
|
case NS_THEME_LISTBOX: {
|
2008-04-19 08:44:03 -07:00
|
|
|
qDebug("NS_THEME_TEXTFIELD");
|
2008-04-19 08:43:48 -07:00
|
|
|
|
|
|
|
pe = QStyle::PE_PanelLineEdit;
|
|
|
|
|
|
|
|
QStyleOptionFrameV2 option;
|
|
|
|
option.direction = QApplication::layoutDirection();
|
|
|
|
option.rect = r;
|
|
|
|
option.type = QStyleOption::SO_Frame;
|
|
|
|
option.state = flags;
|
2008-04-19 08:44:03 -07:00
|
|
|
option.lineWidth = 1;
|
|
|
|
option.midLineWidth = 1;
|
2008-04-19 08:43:48 -07:00
|
|
|
option.features = QStyleOptionFrameV2::Flat;
|
2008-04-19 08:44:03 -07:00
|
|
|
|
2008-04-19 08:43:48 -07:00
|
|
|
style->drawPrimitive(pe, &option, qpainter, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-04-19 08:44:03 -07:00
|
|
|
|
2008-04-19 08:43:48 -07:00
|
|
|
qpainter->restore();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsNativeThemeQt::GetWidgetBorder(nsIDeviceContext* aContext,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
PRUint8 aWidgetType,
|
|
|
|
nsMargin* aResult)
|
|
|
|
{
|
2008-04-19 08:44:03 -07:00
|
|
|
// qDebug("%s : %d", __PRETTY_FUNCTION__, frameWidth);
|
2008-04-19 08:43:48 -07:00
|
|
|
|
|
|
|
(*aResult).top = (*aResult).bottom = (*aResult).left = (*aResult).right = 0;
|
|
|
|
|
2008-04-19 08:44:03 -07:00
|
|
|
// switch(aWidgetType) {
|
|
|
|
// case NS_THEME_TEXTFIELD:
|
|
|
|
// case NS_THEME_LISTBOX:
|
|
|
|
// (*aResult).top = (*aResult).bottom = (*aResult).left = (*aResult).right =
|
|
|
|
// frameWidth;
|
|
|
|
// }
|
2008-04-19 08:43:48 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsNativeThemeQt::GetWidgetPadding(nsIDeviceContext* ,
|
|
|
|
nsIFrame*, PRUint8 aWidgetType,
|
|
|
|
nsMargin* aResult)
|
|
|
|
{
|
2008-04-19 08:44:03 -07:00
|
|
|
// qDebug("%s", __PRETTY_FUNCTION__);
|
2008-04-19 08:43:48 -07:00
|
|
|
|
|
|
|
//XXX: is this really correct?
|
2008-04-19 08:44:03 -07:00
|
|
|
// if (aWidgetType == NS_THEME_BUTTON_FOCUS ||
|
|
|
|
// aWidgetType == NS_THEME_TOOLBAR_BUTTON ||
|
|
|
|
// aWidgetType == NS_THEME_TOOLBAR_DUAL_BUTTON) {
|
|
|
|
// aResult->SizeTo(0, 0, 0, 0);
|
|
|
|
// return PR_TRUE;
|
|
|
|
// }
|
2008-04-19 08:43:48 -07:00
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsNativeThemeQt::GetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame* aFrame,
|
|
|
|
PRUint8 aWidgetType,
|
|
|
|
nsSize* aResult, PRBool* aIsOverridable)
|
|
|
|
{
|
2008-04-19 08:44:03 -07:00
|
|
|
// qDebug("%s", __PRETTY_FUNCTION__);
|
2008-04-19 08:43:48 -07:00
|
|
|
|
|
|
|
(*aResult).width = (*aResult).height = 0;
|
|
|
|
*aIsOverridable = PR_TRUE;
|
|
|
|
|
|
|
|
QStyle *s = qApp->style();
|
|
|
|
|
|
|
|
switch (aWidgetType) {
|
|
|
|
case NS_THEME_RADIO:
|
|
|
|
case NS_THEME_CHECKBOX: {
|
|
|
|
QRect rect = s->subElementRect(aWidgetType == NS_THEME_CHECKBOX
|
|
|
|
? QStyle::SE_CheckBoxIndicator
|
|
|
|
: QStyle::SE_RadioButtonIndicator,
|
|
|
|
0);
|
2008-04-19 08:44:03 -07:00
|
|
|
|
2008-04-19 08:43:48 -07:00
|
|
|
(*aResult).width = rect.width();
|
|
|
|
(*aResult).height = rect.height();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_UP:
|
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_DOWN:
|
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_LEFT:
|
|
|
|
case NS_THEME_SCROLLBAR_BUTTON_RIGHT:
|
|
|
|
(*aResult).width = s->pixelMetric(QStyle::PM_ScrollBarExtent);
|
|
|
|
(*aResult).height = (*aResult).width;
|
|
|
|
*aIsOverridable = PR_FALSE;
|
|
|
|
break;
|
|
|
|
case NS_THEME_SCROLLBAR_THUMB_VERTICAL:
|
|
|
|
(*aResult).width = s->pixelMetric(QStyle::PM_ScrollBarExtent);
|
|
|
|
(*aResult).height = s->pixelMetric(QStyle::PM_ScrollBarSliderMin);
|
|
|
|
*aIsOverridable = PR_FALSE;
|
|
|
|
break;
|
|
|
|
case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
|
|
|
|
(*aResult).width = s->pixelMetric(QStyle::PM_ScrollBarSliderMin);
|
|
|
|
(*aResult).height = s->pixelMetric(QStyle::PM_ScrollBarExtent);
|
|
|
|
*aIsOverridable = PR_FALSE;
|
|
|
|
break;
|
|
|
|
case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
|
|
|
|
break;
|
|
|
|
case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL:
|
|
|
|
break;
|
|
|
|
case NS_THEME_DROPDOWN_BUTTON: {
|
|
|
|
// QRect r = s->subControlRect(QStyle::CC_ComboBox, combo, QStyle::SC_ComboBoxArrow);
|
|
|
|
// (*aResult).width = r.width() - 2*frameWidth;
|
|
|
|
// (*aResult).height = r.height() - 2*frameWidth;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NS_THEME_DROPDOWN:
|
|
|
|
case NS_THEME_DROPDOWN_TEXT:
|
|
|
|
case NS_THEME_DROPDOWN_TEXTFIELD:
|
|
|
|
case NS_THEME_TEXTFIELD:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsNativeThemeQt::WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType,
|
|
|
|
nsIAtom* aAttribute, PRBool* aShouldRepaint)
|
|
|
|
{
|
2008-04-19 08:44:03 -07:00
|
|
|
// qDebug("%s", __PRETTY_FUNCTION__);
|
2008-04-19 08:43:48 -07:00
|
|
|
|
|
|
|
*aShouldRepaint = TRUE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsNativeThemeQt::ThemeChanged()
|
|
|
|
{
|
|
|
|
// qDebug("%s", __PRETTY_FUNCTION__);
|
|
|
|
|
|
|
|
QStyle *s = qApp->style();
|
|
|
|
if (s)
|
|
|
|
frameWidth = s->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsNativeThemeQt::ThemeSupportsWidget(nsPresContext* aPresContext,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
PRUint8 aWidgetType)
|
|
|
|
{
|
2008-04-19 08:44:03 -07:00
|
|
|
// qDebug("%s", __PRETTY_FUNCTION__);
|
2008-04-19 08:43:48 -07:00
|
|
|
// return FALSE;
|
|
|
|
|
|
|
|
switch (aWidgetType) {
|
2008-04-19 08:44:03 -07:00
|
|
|
//case NS_THEME_SCROLLBAR:
|
|
|
|
//case NS_THEME_SCROLLBAR_BUTTON_UP:
|
|
|
|
//case NS_THEME_SCROLLBAR_BUTTON_DOWN:
|
|
|
|
//case NS_THEME_SCROLLBAR_BUTTON_LEFT:
|
|
|
|
//case NS_THEME_SCROLLBAR_BUTTON_RIGHT:
|
|
|
|
//case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
|
|
|
|
//case NS_THEME_SCROLLBAR_THUMB_VERTICAL:
|
|
|
|
//case NS_THEME_SCROLLBAR_GRIPPER_HORIZONTAL:
|
|
|
|
//case NS_THEME_SCROLLBAR_GRIPPER_VERTICAL:
|
|
|
|
//case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL:
|
|
|
|
//case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
|
2008-04-19 08:43:48 -07:00
|
|
|
case NS_THEME_RADIO:
|
|
|
|
case NS_THEME_CHECKBOX:
|
|
|
|
case NS_THEME_BUTTON_BEVEL:
|
|
|
|
case NS_THEME_BUTTON:
|
2008-04-19 08:44:03 -07:00
|
|
|
//case NS_THEME_DROPDOWN:
|
|
|
|
//case NS_THEME_DROPDOWN_BUTTON:
|
|
|
|
//case NS_THEME_DROPDOWN_TEXT:
|
|
|
|
//case NS_THEME_DROPDOWN_TEXTFIELD:
|
2008-04-19 08:43:48 -07:00
|
|
|
case NS_THEME_TEXTFIELD:
|
2008-04-19 08:44:03 -07:00
|
|
|
//case NS_THEME_LISTBOX:
|
2008-04-19 08:43:48 -07:00
|
|
|
// qDebug("%s : return PR_TRUE", __PRETTY_FUNCTION__);
|
|
|
|
return PR_TRUE;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// qDebug("%s : return PR_FALSE", __PRETTY_FUNCTION__);
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsNativeThemeQt::WidgetIsContainer(PRUint8 aWidgetType)
|
|
|
|
{
|
2008-04-19 08:44:03 -07:00
|
|
|
// qDebug("%s", __PRETTY_FUNCTION__);
|
2008-04-19 08:43:48 -07:00
|
|
|
// XXXdwh At some point flesh all of this out.
|
2008-04-19 08:44:03 -07:00
|
|
|
/*
|
2008-04-19 08:43:48 -07:00
|
|
|
if (aWidgetType == NS_THEME_DROPDOWN_BUTTON ||
|
|
|
|
aWidgetType == NS_THEME_RADIO ||
|
|
|
|
aWidgetType == NS_THEME_CHECKBOX) {
|
|
|
|
// qDebug("%s : return PR_FALSE", __PRETTY_FUNCTION__);
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
// qDebug("%s : return PR_TRUE", __PRETTY_FUNCTION__);
|
2008-04-19 08:44:03 -07:00
|
|
|
*/
|
2008-04-19 08:43:48 -07:00
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsNativeThemeQt::ThemeDrawsFocusForWidget(nsPresContext* aPresContext, nsIFrame* aFrame, PRUint8 aWidgetType)
|
|
|
|
{
|
2008-04-19 08:44:03 -07:00
|
|
|
// qDebug("%s", __PRETTY_FUNCTION__);
|
|
|
|
/*
|
2008-04-19 08:43:48 -07:00
|
|
|
if (aWidgetType == NS_THEME_DROPDOWN ||
|
|
|
|
aWidgetType == NS_THEME_BUTTON ||
|
|
|
|
aWidgetType == NS_THEME_TREEVIEW_HEADER_CELL) {
|
|
|
|
// qDebug("%s : return PR_TRUE", __PRETTY_FUNCTION__);
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
// qDebug("%s : return PR_FALSE", __PRETTY_FUNCTION__);
|
2008-04-19 08:44:03 -07:00
|
|
|
*/
|
2008-04-19 08:43:48 -07:00
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsNativeThemeQt::ThemeNeedsComboboxDropmarker()
|
|
|
|
{
|
2008-04-19 08:44:03 -07:00
|
|
|
// qDebug("%s", __PRETTY_FUNCTION__);
|
2008-04-19 08:43:48 -07:00
|
|
|
return PR_FALSE;
|
|
|
|
}
|