Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / widget / src / qt / nsNativeThemeQt.cpp
blobca35aa4081bc8744a5d9ceb1c3068c419182d4dc
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
12 * License.
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.
21 * Contributor(s):
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 ***** */
41 #include "nsIFrame.h"
43 #include <QApplication>
44 #include <QStyle>
45 #include <QPalette>
46 #include <QRect>
47 #include <QPainter>
48 #include <QStyleOption>
49 #include <QStyleOptionFrameV2>
50 #include <QStyleOptionButton>
51 #include <QFlags>
52 #include <QStyleOptionComboBox>
54 #include "nsCoord.h"
55 #include "nsNativeThemeQt.h"
56 #include "nsIDeviceContext.h"
57 #include "nsPresContext.h"
59 #include "nsRect.h"
60 #include "nsSize.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"
67 #include <malloc.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);
78 ThemeChanged();
81 nsNativeThemeQt::~nsNativeThemeQt()
85 NS_IMPL_ISUPPORTS1(nsNativeThemeQt, nsITheme)
87 static inline QRect qRectInPixels(const nsRect &aRect,
88 const PRInt32 p2a)
90 return QRect(NSAppUnitsToIntPixels(aRect.x, p2a),
91 NSAppUnitsToIntPixels(aRect.y, p2a),
92 NSAppUnitsToIntPixels(aRect.width, p2a),
93 NSAppUnitsToIntPixels(aRect.height, p2a));
96 NS_IMETHODIMP
97 nsNativeThemeQt::DrawWidgetBackground(nsIRenderingContext* aContext,
98 nsIFrame* aFrame,
99 PRUint8 aWidgetType,
100 const nsRect& aRect,
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)
117 return NS_OK;
119 QStyle* style = qApp->style();
121 qPainter->save();
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) {
143 case NS_THEME_RADIO:
144 case NS_THEME_CHECKBOX: {
145 QStyleOptionButton opt;
146 InitButtonStyle (aWidgetType, aFrame, r, opt);
148 if (aWidgetType == NS_THEME_CHECKBOX)
150 style->drawPrimitive (QStyle::PE_IndicatorCheckBox, &opt, qPainter);
151 } else {
152 style->drawPrimitive (QStyle::PE_IndicatorRadioButton, &opt, qPainter);
154 break;
156 case NS_THEME_BUTTON:
157 case NS_THEME_BUTTON_BEVEL: {
158 QStyleOptionButton opt;
159 InitButtonStyle (aWidgetType, aFrame, r, opt);
161 if (aWidgetType == NS_THEME_BUTTON) {
162 style->drawPrimitive(QStyle::PE_PanelButtonCommand, &opt, qPainter);
163 if (IsDefaultButton(aFrame))
164 style->drawPrimitive(QStyle::PE_FrameDefaultButton, &opt, qPainter);
165 } else {
166 style->drawPrimitive(QStyle::PE_PanelButtonBevel, &opt, qPainter);
167 style->drawPrimitive(QStyle::PE_FrameButtonBevel, &opt, qPainter);
169 break;
171 case NS_THEME_SCROLLBAR: {
172 qPainter->fillRect(r, qApp->palette().brush(QPalette::Normal, QPalette::Window));
173 break;
175 case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL: {
176 qPainter->fillRect(r, qApp->palette().brush(QPalette::Active, QPalette::Window));
177 break;
179 case NS_THEME_SCROLLBAR_TRACK_VERTICAL: {
180 qPainter->fillRect(r, qApp->palette().brush(QPalette::Active, QPalette::Window));
181 break;
183 case NS_THEME_SCROLLBAR_BUTTON_LEFT: {
184 QStyleOptionSlider opt;
185 InitPlainStyle(aWidgetType, aFrame, r, (QStyleOption&)opt, QStyle::State_Horizontal);
186 opt.orientation = Qt::Horizontal;
187 style->drawControl(QStyle::CE_ScrollBarSubLine, &opt, qPainter, NULL);
188 break;
190 case NS_THEME_SCROLLBAR_BUTTON_RIGHT: {
191 QStyleOptionSlider opt;
192 InitPlainStyle(aWidgetType, aFrame, r, (QStyleOption&)opt, QStyle::State_Horizontal);
193 opt.orientation = Qt::Horizontal;
194 style->drawControl(QStyle::CE_ScrollBarAddLine, &opt, qPainter, NULL);
195 break;
197 case NS_THEME_SCROLLBAR_BUTTON_UP: {
198 QStyleOptionSlider opt;
199 InitPlainStyle(aWidgetType, aFrame, r, (QStyleOption&)opt);
200 opt.orientation = Qt::Vertical;
201 style->drawControl(QStyle::CE_ScrollBarSubLine, &opt, qPainter, NULL);
202 break;
204 case NS_THEME_SCROLLBAR_BUTTON_DOWN: {
205 QStyleOptionSlider opt;
206 InitPlainStyle(aWidgetType, aFrame, r, (QStyleOption&)opt);
207 opt.orientation = Qt::Vertical;
208 style->drawControl(QStyle::CE_ScrollBarAddLine, &opt, qPainter, NULL);
209 break;
211 case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL: {
212 extraFlags |= QStyle::State_Horizontal;
213 QStyleOptionSlider option;
214 InitPlainStyle(aWidgetType, aFrame, r, (QStyleOption&)option, extraFlags);
215 option.orientation = Qt::Horizontal;
216 style->drawControl(QStyle::CE_ScrollBarSlider, &option, qPainter, NULL);
217 break;
219 case NS_THEME_SCROLLBAR_THUMB_VERTICAL: {
220 QStyleOptionSlider option;
221 InitPlainStyle(aWidgetType, aFrame, r, (QStyleOption&)option, extraFlags);
222 option.orientation = Qt::Vertical;
223 style->drawControl(QStyle::CE_ScrollBarSlider, &option, qPainter, NULL);
224 break;
226 case NS_THEME_DROPDOWN: {
227 QStyleOptionComboBox comboOpt;
229 InitComboStyle(aWidgetType, aFrame, r, comboOpt);
231 style->drawComplexControl(QStyle::CC_ComboBox, &comboOpt, qPainter);
232 break;
234 case NS_THEME_DROPDOWN_BUTTON: {
235 QStyleOptionComboBox option;
237 InitComboStyle(aWidgetType, aFrame, r, option);
239 style->drawPrimitive(QStyle::PE_FrameDefaultButton, &option, qPainter);
240 style->drawPrimitive(QStyle::PE_IndicatorSpinDown, &option, qPainter);
241 break;
243 case NS_THEME_DROPDOWN_TEXT:
244 case NS_THEME_DROPDOWN_TEXTFIELD:
245 case NS_THEME_TEXTFIELD:
246 case NS_THEME_TEXTFIELD_MULTILINE:
247 case NS_THEME_LISTBOX: {
248 QStyleOptionFrameV2 frameOpt;
250 if (!IsDisabled(aFrame))
251 frameOpt.state |= QStyle::State_Enabled;
253 frameOpt.rect = r;
254 frameOpt.features = QStyleOptionFrameV2::Flat;
256 if (aWidgetType == NS_THEME_TEXTFIELD || aWidgetType == NS_THEME_TEXTFIELD_MULTILINE) {
257 QRect contentRect = style->subElementRect(QStyle::SE_LineEditContents, &frameOpt);
258 contentRect.adjust(mFrameWidth, mFrameWidth, -mFrameWidth, -mFrameWidth);
259 qPainter->fillRect(contentRect, QBrush(Qt::white));
262 frameOpt.palette = mNoBackgroundPalette;
263 style->drawPrimitive(QStyle::PE_FrameLineEdit, &frameOpt, qPainter, NULL);
264 break;
266 case NS_THEME_MENUPOPUP: {
267 QStyleOptionMenuItem option;
268 InitPlainStyle(aWidgetType, aFrame, r, (QStyleOption&)option, extraFlags);
269 style->drawPrimitive(QStyle::PE_FrameMenu, &option, qPainter, NULL);
270 break;
272 default:
273 break;
276 qPainter->restore();
277 return NS_OK;
280 NS_IMETHODIMP
281 nsNativeThemeQt::GetWidgetBorder(nsIDeviceContext* aContext,
282 nsIFrame* aFrame,
283 PRUint8 aWidgetType,
284 nsMargin* aResult)
286 (*aResult).top = (*aResult).bottom = (*aResult).left = (*aResult).right = 0;
288 QStyle* style = qApp->style();
289 switch(aWidgetType) {
290 // case NS_THEME_TEXTFIELD:
291 // case NS_THEME_LISTBOX:
292 case NS_THEME_MENUPOPUP: {
293 (*aResult).top = (*aResult).bottom = (*aResult).left = (*aResult).right = style->pixelMetric(QStyle::PM_MenuPanelWidth);
294 break;
296 default:
297 break;
300 return NS_OK;
303 PRBool
304 nsNativeThemeQt::GetWidgetPadding(nsIDeviceContext* ,
305 nsIFrame*, PRUint8 aWidgetType,
306 nsMargin* aResult)
308 // XXX: Where to get padding values, framewidth?
309 if (aWidgetType == NS_THEME_TEXTFIELD ||
310 aWidgetType == NS_THEME_TEXTFIELD_MULTILINE ||
311 aWidgetType == NS_THEME_DROPDOWN) {
312 aResult->SizeTo(2, 2, 2, 2);
313 return PR_TRUE;
316 return PR_FALSE;
319 NS_IMETHODIMP
320 nsNativeThemeQt::GetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame* aFrame,
321 PRUint8 aWidgetType,
322 nsSize* aResult, PRBool* aIsOverridable)
324 (*aResult).width = (*aResult).height = 0;
325 *aIsOverridable = PR_TRUE;
327 QStyle *s = qApp->style();
329 PRInt32 p2a = GetAppUnitsPerDevPixel(aContext);
331 switch (aWidgetType) {
332 case NS_THEME_RADIO:
333 case NS_THEME_CHECKBOX: {
334 nsRect frameRect = aFrame->GetRect();
336 QRect qRect = qRectInPixels(frameRect, p2a);
338 QStyleOptionButton option;
340 InitButtonStyle(aWidgetType, aFrame, qRect, option);
342 QRect rect = s->subElementRect(
343 (aWidgetType == NS_THEME_CHECKBOX) ?
344 QStyle::SE_CheckBoxIndicator :
345 QStyle::SE_RadioButtonIndicator,
346 &option,
347 NULL);
349 (*aResult).width = rect.width();
350 (*aResult).height = rect.height();
351 break;
353 case NS_THEME_BUTTON: {
354 nsRect frameRect = aFrame->GetRect();
356 QRect qRect = qRectInPixels(frameRect, p2a);
358 QStyleOptionButton option;
360 InitButtonStyle(aWidgetType, aFrame, qRect, option);
362 QRect rect = s->subElementRect(
363 QStyle::SE_PushButtonFocusRect,
364 &option,
365 NULL);
367 (*aResult).width = rect.width();
368 (*aResult).height = rect.height();
369 break;
371 case NS_THEME_SCROLLBAR_BUTTON_UP:
372 case NS_THEME_SCROLLBAR_BUTTON_DOWN: {
373 (*aResult).width = s->pixelMetric(QStyle::PM_ScrollBarExtent);
374 (*aResult).height = (*aResult).width;
375 //*aIsOverridable = PR_FALSE;
376 break;
378 case NS_THEME_SCROLLBAR_BUTTON_LEFT:
379 case NS_THEME_SCROLLBAR_BUTTON_RIGHT: {
380 (*aResult).height = s->pixelMetric(QStyle::PM_ScrollBarExtent);
381 (*aResult).width = (*aResult).height;
382 //*aIsOverridable = PR_FALSE;
383 break;
385 case NS_THEME_SCROLLBAR_THUMB_VERTICAL: {
386 (*aResult).width = s->pixelMetric(QStyle::PM_ScrollBarExtent);
387 (*aResult).height = s->pixelMetric(QStyle::PM_ScrollBarSliderMin);
388 //*aIsOverridable = PR_FALSE;
389 break;
391 case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL: {
392 (*aResult).width = s->pixelMetric(QStyle::PM_ScrollBarSliderMin);
393 (*aResult).height = s->pixelMetric(QStyle::PM_ScrollBarExtent);
394 //*aIsOverridable = PR_FALSE;
395 break;
397 case NS_THEME_SCROLLBAR_TRACK_VERTICAL: {
398 (*aResult).width = s->pixelMetric(QStyle::PM_ScrollBarExtent);
399 (*aResult).height = s->pixelMetric(QStyle::PM_SliderLength);
400 break;
402 case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL: {
403 (*aResult).width = s->pixelMetric(QStyle::PM_SliderLength);
404 (*aResult).height = s->pixelMetric(QStyle::PM_ScrollBarExtent);
405 break;
407 case NS_THEME_DROPDOWN_BUTTON: {
408 QStyleOptionComboBox comboOpt;
410 nsRect frameRect = aFrame->GetRect();
411 QRect qRect = qRectInPixels(frameRect, p2a);
412 comboOpt.rect = qRect;
414 InitComboStyle(aWidgetType, aFrame, qRect, comboOpt);
416 QRect subRect = s->subControlRect(QStyle::CC_ComboBox, &comboOpt, QStyle::SC_ComboBoxArrow, NULL);
418 (*aResult).width = subRect.width();
419 (*aResult).height = subRect.height();
420 //*aIsOverridable = PR_FALSE;
421 break;
423 case NS_THEME_DROPDOWN: {
424 QStyleOptionComboBox comboOpt;
426 nsRect frameRect = aFrame->GetRect();
427 QRect qRect = qRectInPixels(frameRect, p2a);
428 comboOpt.rect = qRect;
430 InitComboStyle(aWidgetType, aFrame, qRect, comboOpt);
432 QRect subRect = s->subControlRect(QStyle::CC_ComboBox,
433 &comboOpt,
434 QStyle::SC_ComboBoxFrame,
435 NULL);
437 (*aResult).width = subRect.width();
438 (*aResult).height = subRect.height();
439 //*aIsOverridable = PR_FALSE;
440 break;
442 case NS_THEME_DROPDOWN_TEXT: {
443 QStyleOptionComboBox comboOpt;
445 nsRect frameRect = aFrame->GetRect();
447 QRect qRect = qRectInPixels(frameRect, p2a);
449 comboOpt.rect = qRect;
451 QRect subRect = s->subControlRect(QStyle::CC_ComboBox, &comboOpt, QStyle::SC_ComboBoxEditField, NULL);
453 (*aResult).width = subRect.width();
454 (*aResult).height = subRect.height();
455 //*aIsOverridable = PR_FALSE;
456 break;
458 case NS_THEME_DROPDOWN_TEXTFIELD: {
459 QStyleOptionComboBox comboOpt;
461 nsRect frameRect = aFrame->GetRect();
463 QRect qRect = qRectInPixels(frameRect, p2a);
465 comboOpt.rect = qRect;
467 QRect subRect = s->subControlRect(QStyle::CC_ComboBox, &comboOpt, QStyle::SC_ComboBoxArrow, NULL);
468 QRect subRect2 = s->subControlRect(QStyle::CC_ComboBox, &comboOpt, QStyle::SC_ComboBoxFrame, NULL);
470 (*aResult).width = subRect.width() + subRect2.width();
471 (*aResult).height = std::max(subRect.height(), subRect2.height());
472 //*aIsOverridable = PR_FALSE;
473 break;
475 case NS_THEME_TEXTFIELD:
476 case NS_THEME_TEXTFIELD_MULTILINE:
477 break;
479 return NS_OK;
482 NS_IMETHODIMP
483 nsNativeThemeQt::WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType,
484 nsIAtom* aAttribute, PRBool* aShouldRepaint)
486 *aShouldRepaint = TRUE;
487 return NS_OK;
491 NS_IMETHODIMP
492 nsNativeThemeQt::ThemeChanged()
494 QStyle *s = qApp->style();
495 if (s)
496 mFrameWidth = s->pixelMetric(QStyle::PM_DefaultFrameWidth);
497 return NS_OK;
500 PRBool
501 nsNativeThemeQt::ThemeSupportsWidget(nsPresContext* aPresContext,
502 nsIFrame* aFrame,
503 PRUint8 aWidgetType)
505 switch (aWidgetType) {
506 case NS_THEME_SCROLLBAR:
507 case NS_THEME_SCROLLBAR_BUTTON_UP:
508 case NS_THEME_SCROLLBAR_BUTTON_DOWN:
509 case NS_THEME_SCROLLBAR_BUTTON_LEFT:
510 case NS_THEME_SCROLLBAR_BUTTON_RIGHT:
511 case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
512 case NS_THEME_SCROLLBAR_THUMB_VERTICAL:
513 //case NS_THEME_SCROLLBAR_GRIPPER_HORIZONTAL:
514 //case NS_THEME_SCROLLBAR_GRIPPER_VERTICAL:
515 case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL:
516 case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
517 case NS_THEME_RADIO:
518 case NS_THEME_CHECKBOX:
519 case NS_THEME_BUTTON_BEVEL:
520 case NS_THEME_BUTTON:
521 case NS_THEME_DROPDOWN:
522 case NS_THEME_DROPDOWN_BUTTON:
523 case NS_THEME_DROPDOWN_TEXT:
524 case NS_THEME_DROPDOWN_TEXTFIELD:
525 case NS_THEME_TEXTFIELD:
526 case NS_THEME_TEXTFIELD_MULTILINE:
527 case NS_THEME_LISTBOX:
528 case NS_THEME_MENUPOPUP:
529 return !IsWidgetStyled(aPresContext, aFrame, aWidgetType);
530 default:
531 break;
533 return PR_FALSE;
536 PRBool
537 nsNativeThemeQt::WidgetIsContainer(PRUint8 aWidgetType)
539 // if (aWidgetType == NS_THEME_DROPDOWN_BUTTON ||
540 // aWidgetType == NS_THEME_RADIO ||
541 // aWidgetType == NS_THEME_CHECKBOX) {
542 // return PR_FALSE;
543 // }
545 return PR_TRUE;
548 PRBool
549 nsNativeThemeQt::ThemeDrawsFocusForWidget(nsPresContext* aPresContext, nsIFrame* aFrame, PRUint8 aWidgetType)
551 if (aWidgetType == NS_THEME_DROPDOWN ||
552 aWidgetType == NS_THEME_BUTTON ||
553 aWidgetType == NS_THEME_TREEVIEW_HEADER_CELL) {
554 return PR_TRUE;
557 return PR_FALSE;
560 PRBool
561 nsNativeThemeQt::ThemeNeedsComboboxDropmarker()
563 return PR_TRUE;
566 nsTransparencyMode
567 nsNativeThemeQt::GetWidgetTransparency(PRUint8 aWidgetType)
569 return eTransparencyOpaque;
572 void
573 nsNativeThemeQt::InitButtonStyle(PRUint8 aWidgetType,
574 nsIFrame* aFrame,
575 QRect rect,
576 QStyleOptionButton &opt)
578 PRInt32 eventState = GetContentState(aFrame, aWidgetType);
580 opt.rect = rect;
581 opt.palette = mNoBackgroundPalette;
583 PRBool disabled = IsDisabled(aFrame);
585 if (!disabled)
586 opt.state |= QStyle::State_Enabled;
587 if (eventState & NS_EVENT_STATE_HOVER)
588 opt.state |= QStyle::State_MouseOver;
589 if (eventState & NS_EVENT_STATE_FOCUS)
590 opt.state |= QStyle::State_HasFocus;
591 if (!disabled && eventState & NS_EVENT_STATE_ACTIVE)
592 // Don't allow sunken when disabled
593 opt.state |= QStyle::State_Sunken;
595 switch (aWidgetType) {
596 case NS_THEME_RADIO:
597 case NS_THEME_CHECKBOX:
598 if (IsChecked(aFrame))
599 opt.state |= QStyle::State_On;
600 else
601 opt.state |= QStyle::State_Off;
603 break;
604 default:
605 if (!(eventState & NS_EVENT_STATE_ACTIVE))
606 opt.state |= QStyle::State_Raised;
607 break;
611 void
612 nsNativeThemeQt::InitPlainStyle(PRUint8 aWidgetType,
613 nsIFrame* aFrame,
614 QRect rect,
615 QStyleOption &opt,
616 QStyle::State extraFlags)
618 PRInt32 eventState = GetContentState(aFrame, aWidgetType);
620 opt.rect = rect;
622 if (!IsDisabled(aFrame))
623 opt.state |= QStyle::State_Enabled;
624 if (eventState & NS_EVENT_STATE_HOVER)
625 opt.state |= QStyle::State_MouseOver;
626 if (eventState & NS_EVENT_STATE_FOCUS)
627 opt.state |= QStyle::State_HasFocus;
629 opt.state |= extraFlags;
632 void
633 nsNativeThemeQt::InitComboStyle(PRUint8 aWidgetType,
634 nsIFrame* aFrame,
635 QRect rect,
636 QStyleOptionComboBox &opt)
638 PRInt32 eventState = GetContentState(aFrame, aWidgetType);
640 PRBool disabled = IsDisabled(aFrame);
642 if (!disabled)
643 opt.state |= QStyle::State_Enabled;
644 if (eventState & NS_EVENT_STATE_HOVER)
645 opt.state |= QStyle::State_MouseOver;
646 if (eventState & NS_EVENT_STATE_FOCUS)
647 opt.state |= QStyle::State_HasFocus;
648 if (!(eventState & NS_EVENT_STATE_ACTIVE))
649 opt.state |= QStyle::State_Raised;
650 if (!disabled && eventState & NS_EVENT_STATE_ACTIVE)
651 // Don't allow sunken when disabled
652 opt.state |= QStyle::State_Sunken;
654 opt.rect = rect;
655 opt.palette = mNoBackgroundPalette;