1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
14 * The Original Code is mozilla.org code.
16 * The Initial Developer of the Original Code is
17 * David Hyatt (hyatt@netscape.com).
18 * Portions created by the Initial Developer are Copyright (C) 2001
19 * the Initial Developer. All Rights Reserved.
22 * Lars Knoll <knoll@kde.org>
23 * Zack Rusin <zack@kde.org>
24 * Tim Hill (tim@prismelite.com)
25 * Vladimir Vukicevic <vladimir@pobox.com>
27 * Alternatively, the contents of this file may be used under the terms of
28 * either of the GNU General Public License Version 2 or later (the "GPL"),
29 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 * in which case the provisions of the GPL or the LGPL are applicable instead
31 * of those above. If you wish to allow use of your version of this file only
32 * under the terms of either the GPL or the LGPL, and not to allow others to
33 * use your version of this file under the terms of the MPL, indicate your
34 * decision by deleting the provisions above and replace them with the notice
35 * and other provisions required by the GPL or the LGPL. If you do not delete
36 * the provisions above, a recipient may use your version of this file under
37 * the terms of any one of the MPL, the GPL or the LGPL.
39 * ***** END LICENSE BLOCK ***** */
43 #include <QApplication>
48 #include <QStyleOption>
49 #include <QStyleOptionFrameV2>
50 #include <QStyleOptionButton>
52 #include <QStyleOptionComboBox>
55 #include "nsNativeThemeQt.h"
56 #include "nsIDeviceContext.h"
57 #include "nsPresContext.h"
61 #include "nsTransform2D.h"
62 #include "nsThemeConstants.h"
63 #include "nsILookAndFeel.h"
64 #include "nsIServiceManager.h"
65 #include "nsIEventStateManager.h"
66 #include "nsIDOMHTMLInputElement.h"
70 #include "gfxASurface.h"
71 #include "gfxContext.h"
72 #include "gfxQPainterSurface.h"
73 #include "nsIRenderingContext.h"
75 nsNativeThemeQt::nsNativeThemeQt()
77 mNoBackgroundPalette
.setColor(QPalette::Window
, Qt::transparent
);
81 nsNativeThemeQt::~nsNativeThemeQt()
85 NS_IMPL_ISUPPORTS1(nsNativeThemeQt
, nsITheme
)
87 static inline QRect
qRectInPixels(const nsRect
&aRect
,
90 return QRect(NSAppUnitsToIntPixels(aRect
.x
, p2a
),
91 NSAppUnitsToIntPixels(aRect
.y
, p2a
),
92 NSAppUnitsToIntPixels(aRect
.width
, p2a
),
93 NSAppUnitsToIntPixels(aRect
.height
, p2a
));
97 nsNativeThemeQt::DrawWidgetBackground(nsIRenderingContext
* aContext
,
101 const nsRect
& aClipRect
)
103 gfxContext
* context
= aContext
->ThebesContext();
104 nsRefPtr
<gfxASurface
> surface
= context
->CurrentSurface();
106 context
->UpdateSurfaceClip();
108 if (surface
->GetType() != gfxASurface::SurfaceTypeQPainter
)
109 return NS_ERROR_NOT_IMPLEMENTED
;
111 gfxQPainterSurface
* qSurface
= (gfxQPainterSurface
*) (surface
.get());
112 QPainter
* qPainter
= qSurface
->GetQPainter();
114 NS_ASSERTION(qPainter
, "Where'd my QPainter go?");
116 if (qPainter
== nsnull
)
119 QStyle
* style
= qApp
->style();
123 gfxPoint offs
= surface
->GetDeviceOffset();
124 qPainter
->translate(offs
.x
, offs
.y
);
126 gfxMatrix ctm
= context
->CurrentMatrix();
127 if (!ctm
.HasNonTranslation()) {
128 ctm
.x0
= NSToCoordRound(ctm
.x0
);
129 ctm
.y0
= NSToCoordRound(ctm
.y0
);
132 QMatrix
qctm(ctm
.xx
, ctm
.xy
, ctm
.yx
, ctm
.yy
, ctm
.x0
, ctm
.y0
);
133 qPainter
->setWorldMatrix(qctm
, true);
135 PRInt32 p2a
= GetAppUnitsPerDevPixel(aContext
);
137 QRect r
= qRectInPixels(aRect
, p2a
);
138 QRect cr
= qRectInPixels(aClipRect
, p2a
);
140 QStyle::State extraFlags
= QStyle::State_None
;
142 switch (aWidgetType
) {
144 case NS_THEME_RADIO_SMALL
:
145 case NS_THEME_CHECKBOX
:
146 case NS_THEME_CHECKBOX_SMALL
: {
147 QStyleOptionButton opt
;
148 InitButtonStyle (aWidgetType
, aFrame
, r
, opt
);
150 if (aWidgetType
== NS_THEME_CHECKBOX
||
151 aWidgetType
== NS_THEME_CHECKBOX_SMALL
)
153 style
->drawPrimitive (QStyle::PE_IndicatorCheckBox
, &opt
, qPainter
);
155 style
->drawPrimitive (QStyle::PE_IndicatorRadioButton
, &opt
, qPainter
);
159 case NS_THEME_BUTTON
:
160 case NS_THEME_BUTTON_BEVEL
: {
161 QStyleOptionButton opt
;
162 InitButtonStyle (aWidgetType
, aFrame
, r
, opt
);
164 if (aWidgetType
== NS_THEME_BUTTON
) {
165 style
->drawPrimitive(QStyle::PE_PanelButtonCommand
, &opt
, qPainter
);
166 if (IsDefaultButton(aFrame
))
167 style
->drawPrimitive(QStyle::PE_FrameDefaultButton
, &opt
, qPainter
);
169 style
->drawPrimitive(QStyle::PE_PanelButtonBevel
, &opt
, qPainter
);
170 style
->drawPrimitive(QStyle::PE_FrameButtonBevel
, &opt
, qPainter
);
174 case NS_THEME_SCROLLBAR
: {
175 qPainter
->fillRect(r
, qApp
->palette().brush(QPalette::Normal
, QPalette::Window
));
178 case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL
: {
179 qPainter
->fillRect(r
, qApp
->palette().brush(QPalette::Active
, QPalette::Window
));
182 case NS_THEME_SCROLLBAR_TRACK_VERTICAL
: {
183 qPainter
->fillRect(r
, qApp
->palette().brush(QPalette::Active
, QPalette::Window
));
186 case NS_THEME_SCROLLBAR_BUTTON_LEFT
: {
187 QStyleOptionSlider opt
;
188 InitPlainStyle(aWidgetType
, aFrame
, r
, (QStyleOption
&)opt
, QStyle::State_Horizontal
);
189 opt
.orientation
= Qt::Horizontal
;
190 style
->drawControl(QStyle::CE_ScrollBarSubLine
, &opt
, qPainter
, NULL
);
193 case NS_THEME_SCROLLBAR_BUTTON_RIGHT
: {
194 QStyleOptionSlider opt
;
195 InitPlainStyle(aWidgetType
, aFrame
, r
, (QStyleOption
&)opt
, QStyle::State_Horizontal
);
196 opt
.orientation
= Qt::Horizontal
;
197 style
->drawControl(QStyle::CE_ScrollBarAddLine
, &opt
, qPainter
, NULL
);
200 case NS_THEME_SCROLLBAR_BUTTON_UP
: {
201 QStyleOptionSlider opt
;
202 InitPlainStyle(aWidgetType
, aFrame
, r
, (QStyleOption
&)opt
);
203 opt
.orientation
= Qt::Vertical
;
204 style
->drawControl(QStyle::CE_ScrollBarSubLine
, &opt
, qPainter
, NULL
);
207 case NS_THEME_SCROLLBAR_BUTTON_DOWN
: {
208 QStyleOptionSlider opt
;
209 InitPlainStyle(aWidgetType
, aFrame
, r
, (QStyleOption
&)opt
);
210 opt
.orientation
= Qt::Vertical
;
211 style
->drawControl(QStyle::CE_ScrollBarAddLine
, &opt
, qPainter
, NULL
);
214 case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL
: {
215 extraFlags
|= QStyle::State_Horizontal
;
216 QStyleOptionSlider option
;
217 InitPlainStyle(aWidgetType
, aFrame
, r
, (QStyleOption
&)option
, extraFlags
);
218 option
.orientation
= Qt::Horizontal
;
219 style
->drawControl(QStyle::CE_ScrollBarSlider
, &option
, qPainter
, NULL
);
222 case NS_THEME_SCROLLBAR_THUMB_VERTICAL
: {
223 QStyleOptionSlider option
;
224 InitPlainStyle(aWidgetType
, aFrame
, r
, (QStyleOption
&)option
, extraFlags
);
225 option
.orientation
= Qt::Vertical
;
226 style
->drawControl(QStyle::CE_ScrollBarSlider
, &option
, qPainter
, NULL
);
229 case NS_THEME_DROPDOWN
: {
230 QStyleOptionComboBox comboOpt
;
232 InitComboStyle(aWidgetType
, aFrame
, r
, comboOpt
);
234 style
->drawComplexControl(QStyle::CC_ComboBox
, &comboOpt
, qPainter
);
237 case NS_THEME_DROPDOWN_BUTTON
: {
238 QStyleOptionComboBox option
;
240 InitComboStyle(aWidgetType
, aFrame
, r
, option
);
242 style
->drawPrimitive(QStyle::PE_FrameDefaultButton
, &option
, qPainter
);
243 style
->drawPrimitive(QStyle::PE_IndicatorSpinDown
, &option
, qPainter
);
246 case NS_THEME_DROPDOWN_TEXT
:
247 case NS_THEME_DROPDOWN_TEXTFIELD
:
248 case NS_THEME_TEXTFIELD
:
249 case NS_THEME_TEXTFIELD_MULTILINE
:
250 case NS_THEME_LISTBOX
: {
251 QStyleOptionFrameV2 frameOpt
;
253 if (!IsDisabled(aFrame
))
254 frameOpt
.state
|= QStyle::State_Enabled
;
257 frameOpt
.features
= QStyleOptionFrameV2::Flat
;
259 if (aWidgetType
== NS_THEME_TEXTFIELD
|| aWidgetType
== NS_THEME_TEXTFIELD_MULTILINE
) {
260 QRect contentRect
= style
->subElementRect(QStyle::SE_LineEditContents
, &frameOpt
);
261 contentRect
.adjust(mFrameWidth
, mFrameWidth
, -mFrameWidth
, -mFrameWidth
);
262 qPainter
->fillRect(contentRect
, QBrush(Qt::white
));
265 frameOpt
.palette
= mNoBackgroundPalette
;
266 style
->drawPrimitive(QStyle::PE_FrameLineEdit
, &frameOpt
, qPainter
, NULL
);
269 case NS_THEME_MENUPOPUP
: {
270 QStyleOptionMenuItem option
;
271 InitPlainStyle(aWidgetType
, aFrame
, r
, (QStyleOption
&)option
, extraFlags
);
272 style
->drawPrimitive(QStyle::PE_FrameMenu
, &option
, qPainter
, NULL
);
284 nsNativeThemeQt::GetWidgetBorder(nsIDeviceContext
* aContext
,
289 (*aResult
).top
= (*aResult
).bottom
= (*aResult
).left
= (*aResult
).right
= 0;
291 QStyle
* style
= qApp
->style();
292 switch(aWidgetType
) {
293 // case NS_THEME_TEXTFIELD:
294 // case NS_THEME_LISTBOX:
295 case NS_THEME_MENUPOPUP
: {
296 (*aResult
).top
= (*aResult
).bottom
= (*aResult
).left
= (*aResult
).right
= style
->pixelMetric(QStyle::PM_MenuPanelWidth
);
307 nsNativeThemeQt::GetWidgetPadding(nsIDeviceContext
* ,
308 nsIFrame
*, PRUint8 aWidgetType
,
311 // XXX: Where to get padding values, framewidth?
312 if (aWidgetType
== NS_THEME_TEXTFIELD
||
313 aWidgetType
== NS_THEME_TEXTFIELD_MULTILINE
||
314 aWidgetType
== NS_THEME_DROPDOWN
) {
315 aResult
->SizeTo(2, 2, 2, 2);
323 nsNativeThemeQt::GetMinimumWidgetSize(nsIRenderingContext
* aContext
, nsIFrame
* aFrame
,
325 nsSize
* aResult
, PRBool
* aIsOverridable
)
327 (*aResult
).width
= (*aResult
).height
= 0;
328 *aIsOverridable
= PR_TRUE
;
330 QStyle
*s
= qApp
->style();
332 PRInt32 p2a
= GetAppUnitsPerDevPixel(aContext
);
334 switch (aWidgetType
) {
335 case NS_THEME_RADIO_SMALL
:
337 case NS_THEME_CHECKBOX_SMALL
:
338 case NS_THEME_CHECKBOX
: {
339 nsRect frameRect
= aFrame
->GetRect();
341 QRect qRect
= qRectInPixels(frameRect
, p2a
);
343 QStyleOptionButton option
;
345 InitButtonStyle(aWidgetType
, aFrame
, qRect
, option
);
347 QRect rect
= s
->subElementRect(
348 (aWidgetType
== NS_THEME_CHECKBOX
|| aWidgetType
== NS_THEME_CHECKBOX_SMALL
) ?
349 QStyle::SE_CheckBoxIndicator
:
350 QStyle::SE_RadioButtonIndicator
,
354 (*aResult
).width
= rect
.width();
355 (*aResult
).height
= rect
.height();
358 case NS_THEME_BUTTON
: {
359 nsRect frameRect
= aFrame
->GetRect();
361 QRect qRect
= qRectInPixels(frameRect
, p2a
);
363 QStyleOptionButton option
;
365 InitButtonStyle(aWidgetType
, aFrame
, qRect
, option
);
367 QRect rect
= s
->subElementRect(
368 QStyle::SE_PushButtonFocusRect
,
372 (*aResult
).width
= rect
.width();
373 (*aResult
).height
= rect
.height();
376 case NS_THEME_SCROLLBAR_BUTTON_UP
:
377 case NS_THEME_SCROLLBAR_BUTTON_DOWN
: {
378 (*aResult
).width
= s
->pixelMetric(QStyle::PM_ScrollBarExtent
);
379 (*aResult
).height
= (*aResult
).width
;
380 //*aIsOverridable = PR_FALSE;
383 case NS_THEME_SCROLLBAR_BUTTON_LEFT
:
384 case NS_THEME_SCROLLBAR_BUTTON_RIGHT
: {
385 (*aResult
).height
= s
->pixelMetric(QStyle::PM_ScrollBarExtent
);
386 (*aResult
).width
= (*aResult
).height
;
387 //*aIsOverridable = PR_FALSE;
390 case NS_THEME_SCROLLBAR_THUMB_VERTICAL
: {
391 (*aResult
).width
= s
->pixelMetric(QStyle::PM_ScrollBarExtent
);
392 (*aResult
).height
= s
->pixelMetric(QStyle::PM_ScrollBarSliderMin
);
393 //*aIsOverridable = PR_FALSE;
396 case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL
: {
397 (*aResult
).width
= s
->pixelMetric(QStyle::PM_ScrollBarSliderMin
);
398 (*aResult
).height
= s
->pixelMetric(QStyle::PM_ScrollBarExtent
);
399 //*aIsOverridable = PR_FALSE;
402 case NS_THEME_SCROLLBAR_TRACK_VERTICAL
: {
403 (*aResult
).width
= s
->pixelMetric(QStyle::PM_ScrollBarExtent
);
404 (*aResult
).height
= s
->pixelMetric(QStyle::PM_SliderLength
);
407 case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL
: {
408 (*aResult
).width
= s
->pixelMetric(QStyle::PM_SliderLength
);
409 (*aResult
).height
= s
->pixelMetric(QStyle::PM_ScrollBarExtent
);
412 case NS_THEME_DROPDOWN_BUTTON
: {
413 QStyleOptionComboBox comboOpt
;
415 nsRect frameRect
= aFrame
->GetRect();
416 QRect qRect
= qRectInPixels(frameRect
, p2a
);
417 comboOpt
.rect
= qRect
;
419 InitComboStyle(aWidgetType
, aFrame
, qRect
, comboOpt
);
421 QRect subRect
= s
->subControlRect(QStyle::CC_ComboBox
, &comboOpt
, QStyle::SC_ComboBoxArrow
, NULL
);
423 (*aResult
).width
= subRect
.width();
424 (*aResult
).height
= subRect
.height();
425 //*aIsOverridable = PR_FALSE;
428 case NS_THEME_DROPDOWN
: {
429 QStyleOptionComboBox comboOpt
;
431 nsRect frameRect
= aFrame
->GetRect();
432 QRect qRect
= qRectInPixels(frameRect
, p2a
);
433 comboOpt
.rect
= qRect
;
435 InitComboStyle(aWidgetType
, aFrame
, qRect
, comboOpt
);
437 QRect subRect
= s
->subControlRect(QStyle::CC_ComboBox
,
439 QStyle::SC_ComboBoxFrame
,
442 (*aResult
).width
= subRect
.width();
443 (*aResult
).height
= subRect
.height();
444 //*aIsOverridable = PR_FALSE;
447 case NS_THEME_DROPDOWN_TEXT
: {
448 QStyleOptionComboBox comboOpt
;
450 nsRect frameRect
= aFrame
->GetRect();
452 QRect qRect
= qRectInPixels(frameRect
, p2a
);
454 comboOpt
.rect
= qRect
;
456 QRect subRect
= s
->subControlRect(QStyle::CC_ComboBox
, &comboOpt
, QStyle::SC_ComboBoxEditField
, NULL
);
458 (*aResult
).width
= subRect
.width();
459 (*aResult
).height
= subRect
.height();
460 //*aIsOverridable = PR_FALSE;
463 case NS_THEME_DROPDOWN_TEXTFIELD
: {
464 QStyleOptionComboBox comboOpt
;
466 nsRect frameRect
= aFrame
->GetRect();
468 QRect qRect
= qRectInPixels(frameRect
, p2a
);
470 comboOpt
.rect
= qRect
;
472 QRect subRect
= s
->subControlRect(QStyle::CC_ComboBox
, &comboOpt
, QStyle::SC_ComboBoxArrow
, NULL
);
473 QRect subRect2
= s
->subControlRect(QStyle::CC_ComboBox
, &comboOpt
, QStyle::SC_ComboBoxFrame
, NULL
);
475 (*aResult
).width
= subRect
.width() + subRect2
.width();
476 (*aResult
).height
= std::max(subRect
.height(), subRect2
.height());
477 //*aIsOverridable = PR_FALSE;
480 case NS_THEME_TEXTFIELD
:
481 case NS_THEME_TEXTFIELD_MULTILINE
:
488 nsNativeThemeQt::WidgetStateChanged(nsIFrame
* aFrame
, PRUint8 aWidgetType
,
489 nsIAtom
* aAttribute
, PRBool
* aShouldRepaint
)
491 *aShouldRepaint
= TRUE
;
497 nsNativeThemeQt::ThemeChanged()
499 QStyle
*s
= qApp
->style();
501 mFrameWidth
= s
->pixelMetric(QStyle::PM_DefaultFrameWidth
);
506 nsNativeThemeQt::ThemeSupportsWidget(nsPresContext
* aPresContext
,
510 switch (aWidgetType
) {
511 case NS_THEME_SCROLLBAR
:
512 case NS_THEME_SCROLLBAR_BUTTON_UP
:
513 case NS_THEME_SCROLLBAR_BUTTON_DOWN
:
514 case NS_THEME_SCROLLBAR_BUTTON_LEFT
:
515 case NS_THEME_SCROLLBAR_BUTTON_RIGHT
:
516 case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL
:
517 case NS_THEME_SCROLLBAR_THUMB_VERTICAL
:
518 //case NS_THEME_SCROLLBAR_GRIPPER_HORIZONTAL:
519 //case NS_THEME_SCROLLBAR_GRIPPER_VERTICAL:
520 case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL
:
521 case NS_THEME_SCROLLBAR_TRACK_VERTICAL
:
523 case NS_THEME_RADIO_SMALL
:
524 case NS_THEME_CHECKBOX
:
525 case NS_THEME_CHECKBOX_SMALL
:
526 case NS_THEME_BUTTON_BEVEL
:
527 case NS_THEME_BUTTON
:
528 case NS_THEME_DROPDOWN
:
529 case NS_THEME_DROPDOWN_BUTTON
:
530 case NS_THEME_DROPDOWN_TEXT
:
531 case NS_THEME_DROPDOWN_TEXTFIELD
:
532 case NS_THEME_TEXTFIELD
:
533 case NS_THEME_TEXTFIELD_MULTILINE
:
534 case NS_THEME_LISTBOX
:
535 case NS_THEME_MENUPOPUP
:
536 return !IsWidgetStyled(aPresContext
, aFrame
, aWidgetType
);
544 nsNativeThemeQt::WidgetIsContainer(PRUint8 aWidgetType
)
546 // if (aWidgetType == NS_THEME_DROPDOWN_BUTTON ||
547 // aWidgetType == NS_THEME_RADIO ||
548 // aWidgetType == NS_THEME_CHECKBOX) {
556 nsNativeThemeQt::ThemeDrawsFocusForWidget(nsPresContext
* aPresContext
, nsIFrame
* aFrame
, PRUint8 aWidgetType
)
558 if (aWidgetType
== NS_THEME_DROPDOWN
||
559 aWidgetType
== NS_THEME_BUTTON
||
560 aWidgetType
== NS_THEME_TREEVIEW_HEADER_CELL
) {
568 nsNativeThemeQt::ThemeNeedsComboboxDropmarker()
574 nsNativeThemeQt::InitButtonStyle(PRUint8 aWidgetType
,
577 QStyleOptionButton
&opt
)
579 PRInt32 eventState
= GetContentState(aFrame
, aWidgetType
);
582 opt
.palette
= mNoBackgroundPalette
;
584 PRBool disabled
= IsDisabled(aFrame
);
587 opt
.state
|= QStyle::State_Enabled
;
588 if (eventState
& NS_EVENT_STATE_HOVER
)
589 opt
.state
|= QStyle::State_MouseOver
;
590 if (eventState
& NS_EVENT_STATE_FOCUS
)
591 opt
.state
|= QStyle::State_HasFocus
;
592 if (!disabled
&& eventState
& NS_EVENT_STATE_ACTIVE
)
593 // Don't allow sunken when disabled
594 opt
.state
|= QStyle::State_Sunken
;
596 switch (aWidgetType
) {
598 case NS_THEME_RADIO_SMALL
:
599 case NS_THEME_CHECKBOX
:
600 case NS_THEME_CHECKBOX_SMALL
:
601 if (IsChecked(aFrame
))
602 opt
.state
|= QStyle::State_On
;
604 opt
.state
|= QStyle::State_Off
;
608 if (!(eventState
& NS_EVENT_STATE_ACTIVE
))
609 opt
.state
|= QStyle::State_Raised
;
615 nsNativeThemeQt::InitPlainStyle(PRUint8 aWidgetType
,
619 QStyle::State extraFlags
)
621 PRInt32 eventState
= GetContentState(aFrame
, aWidgetType
);
625 if (!IsDisabled(aFrame
))
626 opt
.state
|= QStyle::State_Enabled
;
627 if (eventState
& NS_EVENT_STATE_HOVER
)
628 opt
.state
|= QStyle::State_MouseOver
;
629 if (eventState
& NS_EVENT_STATE_FOCUS
)
630 opt
.state
|= QStyle::State_HasFocus
;
632 opt
.state
|= extraFlags
;
636 nsNativeThemeQt::InitComboStyle(PRUint8 aWidgetType
,
639 QStyleOptionComboBox
&opt
)
641 PRInt32 eventState
= GetContentState(aFrame
, aWidgetType
);
643 PRBool disabled
= IsDisabled(aFrame
);
646 opt
.state
|= QStyle::State_Enabled
;
647 if (eventState
& NS_EVENT_STATE_HOVER
)
648 opt
.state
|= QStyle::State_MouseOver
;
649 if (eventState
& NS_EVENT_STATE_FOCUS
)
650 opt
.state
|= QStyle::State_HasFocus
;
651 if (!(eventState
& NS_EVENT_STATE_ACTIVE
))
652 opt
.state
|= QStyle::State_Raised
;
653 if (!disabled
&& eventState
& NS_EVENT_STATE_ACTIVE
)
654 // Don't allow sunken when disabled
655 opt
.state
|= QStyle::State_Sunken
;
658 opt
.palette
= mNoBackgroundPalette
;