Qt 4.8
qwindowsvistastyle.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qwindowsvistastyle.h"
43 #include "qwindowsvistastyle_p.h"
44 #include <private/qstylehelper_p.h>
45 #include <private/qsystemlibrary_p.h>
46 
47 #if !defined(QT_NO_STYLE_WINDOWSVISTA) || defined(QT_PLUGIN)
48 
50 
51 static const int windowsItemFrame = 2; // menu item frame width
52 static const int windowsItemHMargin = 3; // menu item hor text margin
53 static const int windowsItemVMargin = 4; // menu item ver text margin
54 static const int windowsArrowHMargin = 6; // arrow horizontal margin
55 static const int windowsRightBorder = 15; // right border on windows
56 
57 #ifndef TMT_CONTENTMARGINS
58 # define TMT_CONTENTMARGINS 3602
59 #endif
60 #ifndef TMT_SIZINGMARGINS
61 # define TMT_SIZINGMARGINS 3601
62 #endif
63 #ifndef LISS_NORMAL
64 # define LISS_NORMAL 1
65 # define LISS_HOT 2
66 # define LISS_SELECTED 3
67 # define LISS_DISABLED 4
68 # define LISS_SELECTEDNOTFOCUS 5
69 # define LISS_HOTSELECTED 6
70 #endif
71 #ifndef BP_COMMANDLINK
72 # define BP_COMMANDLINK 6
73 # define BP_COMMANDLINKGLYPH 7
74 # define CMDLGS_NORMAL 1
75 # define CMDLGS_HOT 2
76 # define CMDLGS_PRESSED 3
77 # define CMDLGS_DISABLED 4
78 #endif
79 #ifndef PP_TRANSPARENTBAR
80 # define PP_TRANSPARENTBAR 11
81 # define PP_TRANSPARENTBARVERT 12
82 #endif
83 
84 // Runtime resolved theme engine function calls
85 
86 
87 typedef HRESULT (WINAPI *PtrGetThemePartSize)(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, OPTIONAL RECT *prc, enum THEMESIZE eSize, OUT SIZE *psz);
88 typedef HTHEME (WINAPI *PtrOpenThemeData)(HWND hwnd, LPCWSTR pszClassList);
89 typedef HTHEME (WINAPI *PtrOpenThemeData)(HWND hwnd, LPCWSTR pszClassList);
90 typedef HRESULT (WINAPI *PtrCloseThemeData)(HTHEME hTheme);
91 typedef HRESULT (WINAPI *PtrDrawThemeBackground)(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, OPTIONAL const RECT *pClipRect);
92 typedef HRESULT (WINAPI *PtrDrawThemeBackgroundEx)(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, OPTIONAL const DTBGOPTS *pOptions);
93 typedef HRESULT (WINAPI *PtrGetCurrentThemeName)(OUT LPWSTR pszThemeFileName, int cchMaxNameChars, OUT OPTIONAL LPWSTR pszColorBuff, int cchMaxColorChars, OUT OPTIONAL LPWSTR pszSizeBuff, int cchMaxSizeChars);
94 typedef HRESULT (WINAPI *PtrGetThemeBool)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT BOOL *pfVal);
95 typedef HRESULT (WINAPI *PtrGetThemeColor)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT COLORREF *pColor);
96 typedef HRESULT (WINAPI *PtrGetThemeEnumValue)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT int *piVal);
97 typedef HRESULT (WINAPI *PtrGetThemeFilename)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT LPWSTR pszThemeFileName, int cchMaxBuffChars);
98 typedef HRESULT (WINAPI *PtrGetThemeFont)(HTHEME hTheme, OPTIONAL HDC hdc, int iPartId, int iStateId, int iPropId, OUT LOGFONT *pFont);
99 typedef HRESULT (WINAPI *PtrGetThemeInt)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT int *piVal);
100 typedef HRESULT (WINAPI *PtrGetThemeIntList)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT INTLIST *pIntList);
101 typedef HRESULT (WINAPI *PtrGetThemeMargins)(HTHEME hTheme, OPTIONAL HDC hdc, int iPartId, int iStateId, int iPropId, OPTIONAL RECT *prc, OUT MARGINS *pMargins);
102 typedef HRESULT (WINAPI *PtrGetThemeMetric)(HTHEME hTheme, OPTIONAL HDC hdc, int iPartId, int iStateId, int iPropId, OUT int *piVal);
103 typedef HRESULT (WINAPI *PtrGetThemePartSize)(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, OPTIONAL RECT *prc, enum THEMESIZE eSize, OUT SIZE *psz);
104 typedef HRESULT (WINAPI *PtrGetThemePosition)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT POINT *pPoint);
105 typedef HRESULT (WINAPI *PtrGetThemeRect)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT RECT *pRect);
106 typedef HRESULT (WINAPI *PtrGetThemeString)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT LPWSTR pszBuff, int cchMaxBuffChars);
107 typedef HRESULT (WINAPI *PtrGetThemeTransitionDuration)(HTHEME hTheme, int iPartId, int iStateFromId, int iStateToId, int iPropId, int *pDuration);
108 typedef HRESULT (WINAPI *PtrIsThemePartDefined)(HTHEME hTheme, int iPartId, int iStateId);
109 typedef HRESULT (WINAPI *PtrSetWindowTheme)(HWND hwnd, LPCWSTR pszSubAppName, LPCWSTR pszSubIdList);
110 typedef HRESULT (WINAPI *PtrGetThemePropertyOrigin)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT enum PROPERTYORIGIN *pOrigin);
111 
134 
135 /* \internal
136  Checks if we should use Vista style , or if we should
137  fall back to Windows style.
138 */
140 {
144 }
145 
166 {
167 }
168 
169 //convert Qt state flags to uxtheme button states
170 static int buttonStateId(int flags, int partId)
171 {
172  int stateId = 0;
173  if (partId == BP_RADIOBUTTON || partId == BP_CHECKBOX) {
174  if (!(flags & QStyle::State_Enabled))
175  stateId = RBS_UNCHECKEDDISABLED;
176  else if (flags & QStyle::State_Sunken)
177  stateId = RBS_UNCHECKEDPRESSED;
178  else if (flags & QStyle::State_MouseOver)
179  stateId = RBS_UNCHECKEDHOT;
180  else
181  stateId = RBS_UNCHECKEDNORMAL;
182 
183  if (flags & QStyle::State_On)
184  stateId += RBS_CHECKEDNORMAL-1;
185 
186  } else if (partId == BP_PUSHBUTTON) {
187  if (!(flags & QStyle::State_Enabled))
188  stateId = PBS_DISABLED;
189  else if (flags & (QStyle::State_Sunken | QStyle::State_On))
190  stateId = PBS_PRESSED;
191  else if (flags & QStyle::State_MouseOver)
192  stateId = PBS_HOT;
193  else
194  stateId = PBS_NORMAL;
195  } else {
196  Q_ASSERT(1);
197  }
198  return stateId;
199 }
200 
202 {
203  Q_UNUSED(option);
204  Q_UNUSED(painter);
205 }
206 
216 void QWindowsVistaAnimation::drawBlendedImage(QPainter *painter, QRect rect, float alpha) {
217  if (_secondaryImage.isNull() || _primaryImage.isNull())
218  return;
219 
220  if (_tempImage.isNull())
221  _tempImage = _secondaryImage;
222 
223  const int a = qRound(alpha*256);
224  const int ia = 256 - a;
225  const int sw = _primaryImage.width();
226  const int sh = _primaryImage.height();
227  const int bpl = _primaryImage.bytesPerLine();
228  switch(_primaryImage.depth()) {
229  case 32:
230  {
231  uchar *mixed_data = _tempImage.bits();
232  const uchar *back_data = _primaryImage.bits();
233  const uchar *front_data = _secondaryImage.bits();
234  for (int sy = 0; sy < sh; sy++) {
235  quint32* mixed = (quint32*)mixed_data;
236  const quint32* back = (const quint32*)back_data;
237  const quint32* front = (const quint32*)front_data;
238  for (int sx = 0; sx < sw; sx++) {
239  quint32 bp = back[sx];
240  quint32 fp = front[sx];
241  mixed[sx] = qRgba ((qRed(bp)*ia + qRed(fp)*a)>>8,
242  (qGreen(bp)*ia + qGreen(fp)*a)>>8,
243  (qBlue(bp)*ia + qBlue(fp)*a)>>8,
244  (qAlpha(bp)*ia + qAlpha(fp)*a)>>8);
245  }
246  mixed_data += bpl;
247  back_data += bpl;
248  front_data += bpl;
249  }
250  }
251  default:
252  break;
253  }
254  painter->drawImage(rect, _tempImage);
255 }
256 
266 {
267  float alpha = 1.0;
268  if (_duration > 0) {
269  QTime current = QTime::currentTime();
270 
271  if (_startTime > current)
272  _startTime = current;
273 
274  int timeDiff = _startTime.msecsTo(current);
275  alpha = timeDiff/(float)_duration;
276  if (timeDiff > _duration) {
277  _running = false;
278  alpha = 1.0;
279  }
280  }
281  else {
282  _running = false;
283  }
284  drawBlendedImage(painter, option->rect, alpha);
285 }
286 
295 void QWindowsVistaPulse::paint(QPainter *painter, const QStyleOption *option)
296 {
297  float alpha = 1.0;
298  if (_duration > 0) {
299  QTime current = QTime::currentTime();
300 
301  if (_startTime > current)
302  _startTime = current;
303 
304  int timeDiff = _startTime.msecsTo(current) % _duration*2;
305  if (timeDiff > _duration)
306  timeDiff = _duration*2 - timeDiff;
307  alpha = timeDiff/(float)_duration;
308  } else {
309  _running = false;
310  }
311  drawBlendedImage(painter, option->rect, alpha);
312 }
313 
314 
346  QPainter *painter, const QWidget *widget) const
347 {
348  QWindowsVistaStylePrivate *d = const_cast<QWindowsVistaStylePrivate*>(d_func());
349 
350  int state = option->state;
352  QWindowsStyle::drawPrimitive(element, option, painter, widget);
353  return;
354  }
355 
356  QRect oldRect;
357  QRect newRect;
358 
359  if (widget && d->transitionsEnabled())
360  {
361  /* all widgets that supports state transitions : */
362  if (
363 #ifndef QT_NO_LINEEDIT
364  (qobject_cast<const QLineEdit*>(widget) && element == PE_FrameLineEdit) ||
365 #endif // QT_NO_LINEEDIT
366  (qobject_cast<const QRadioButton*>(widget)&& element == PE_IndicatorRadioButton) ||
367  (qobject_cast<const QCheckBox*>(widget) && element == PE_IndicatorCheckBox) ||
368  (qobject_cast<const QGroupBox *>(widget)&& element == PE_IndicatorCheckBox) ||
369  (qobject_cast<const QToolButton*>(widget) && element == PE_PanelButtonBevel)
370  )
371  {
372  // Retrieve and update the dynamic properties tracking
373  // the previous state of the widget:
374  QWidget *w = const_cast<QWidget *> (widget);
375  int oldState = w->property("_q_stylestate").toInt();
376  oldRect = w->property("_q_stylerect").toRect();
377  newRect = w->rect();
378  w->setProperty("_q_stylestate", (int)option->state);
379  w->setProperty("_q_stylerect", w->rect());
380 
381  bool doTransition = oldState &&
382  ((state & State_Sunken) != (oldState & State_Sunken) ||
383  (state & State_On) != (oldState & State_On) ||
384  (state & State_MouseOver) != (oldState & State_MouseOver));
385 
386  if (oldRect != newRect ||
387  (state & State_Enabled) != (oldState & State_Enabled) ||
388  (state & State_Active) != (oldState & State_Active))
389  d->stopAnimation(widget);
390 
391 #ifndef QT_NO_LINEEDIT
392  if (const QLineEdit *edit = qobject_cast<const QLineEdit *>(widget))
393  if (edit->isReadOnly() && element == PE_FrameLineEdit) // Do not animate read only line edits
394  doTransition = false;
395 #endif // QT_NO_LINEEDIT
396 
397  if (doTransition) {
398 
399  // We create separate images for the initial and final transition states and store them in the
400  // Transition object.
401  QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
403  QStyleOption opt = *option;
404 
405  opt.rect.setRect(0, 0, option->rect.width(), option->rect.height());
406  opt.state = (QStyle::State)oldState;
407  startImage.fill(0);
408  QPainter startPainter(&startImage);
409 
410  QWindowsVistaAnimation *anim = d->widgetAnimation(widget);
412  t->setWidget(w);
413 
414  // If we have a running animation on the widget already, we will use that to paint the initial
415  // state of the new transition, this ensures a smooth transition from a current animation such as a
416  // pulsating default button into the intended target state.
417 
418  if (!anim)
419  proxy()->drawPrimitive(element, &opt, &startPainter, 0); // Note that the widget pointer is intentionally 0
420  else // this ensures that we do not recurse in the animation logic above
421  anim->paint(&startPainter, &opt);
422 
423  d->startAnimation(t);
424  t->setStartImage(startImage);
425 
426  // The end state of the transition is simply the result we would have painted
427  // if the style was not animated.
428 
429  QPainter endPainter(&endImage);
430  endImage.fill(0);
431  QStyleOption opt2 = opt;
432  opt2.state = option->state;
433  proxy()->drawPrimitive(element, &opt2, &endPainter, 0); // Note that the widget pointer is intentionally 0
434  // this ensures that we do not recurse in the animation logic above
435  t->setEndImage(endImage);
436 
437  HTHEME theme;
438  int partId;
439  int duration;
440  int fromState = 0;
441  int toState = 0;
442 
443  //translate state flags to UXTHEME states :
444  if (element == PE_FrameLineEdit) {
445  theme = pOpenThemeData(0, L"Edit");
446  partId = EP_EDITBORDER_NOSCROLL;
447 
448  if (oldState & State_MouseOver)
449  fromState = ETS_HOT;
450  else if (oldState & State_HasFocus)
451  fromState = ETS_FOCUSED;
452  else
453  fromState = ETS_NORMAL;
454 
455  if (state & State_MouseOver)
456  toState = ETS_HOT;
457  else if (state & State_HasFocus)
458  toState = ETS_FOCUSED;
459  else
460  toState = ETS_NORMAL;
461 
462  } else {
463  theme = pOpenThemeData(0, L"Button");
464  if (element == PE_IndicatorRadioButton)
465  partId = BP_RADIOBUTTON;
466  else if (element == PE_IndicatorCheckBox)
467  partId = BP_CHECKBOX;
468  else
469  partId = BP_PUSHBUTTON;
470 
471  fromState = buttonStateId(oldState, partId);
472  toState = buttonStateId(option->state, partId);
473  }
474 
475  // Retrieve the transition time between the states from the system.
476  if (theme && pGetThemeTransitionDuration(theme, partId, fromState, toState,
477  TMT_TRANSITIONDURATIONS, &duration) == S_OK)
478  {
479  t->setDuration(duration);
480  }
482  }
483  }
484  } // End of animation part
485 
486 
487  QRect rect = option->rect;
488 
489  switch (element) {
491  if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
492  int stateId = HSAS_SORTEDDOWN;
493  if (header->sortIndicator & QStyleOptionHeader::SortDown)
494  stateId = HSAS_SORTEDUP; //note that the uxtheme sort down indicator is the inverse of ours
495  XPThemeData theme(widget, painter, QLatin1String("HEADER"), HP_HEADERSORTARROW, stateId, option->rect);
496  d->drawBackground(theme);
497  }
498  break;
499 
500  case PE_IndicatorBranch:
501  {
502  XPThemeData theme(d->treeViewHelper(), painter, QLatin1String("TREEVIEW"));
503  static int decoration_size = 0;
504  if (theme.isValid() && !decoration_size) {
505  SIZE size;
506  pGetThemePartSize(theme.handle(), 0, TVP_HOTGLYPH, GLPS_OPENED, 0, TS_TRUE, &size);
507  decoration_size = qMax(size.cx, size.cy);
508  }
509  int mid_h = option->rect.x() + option->rect.width() / 2;
510  int mid_v = option->rect.y() + option->rect.height() / 2;
511  int bef_h = mid_h;
512  int bef_v = mid_v;
513  int aft_h = mid_h;
514  int aft_v = mid_v;
515  if (option->state & State_Children) {
516  int delta = decoration_size / 2;
517  theme.rect = QRect(bef_h - delta, bef_v - delta, decoration_size, decoration_size);
518  theme.partId = option->state & State_MouseOver ? TVP_HOTGLYPH : TVP_GLYPH;
519  theme.stateId = option->state & QStyle::State_Open ? GLPS_OPENED : GLPS_CLOSED;
520  if (option->direction == Qt::RightToLeft)
521  theme.mirrorHorizontally = true;
522  d->drawBackground(theme);
523  bef_h -= delta + 2;
524  bef_v -= delta + 2;
525  aft_h += delta - 2;
526  aft_v += delta - 2;
527  }
528 #if 0
529  QBrush brush(option->palette.dark().color(), Qt::Dense4Pattern);
530  if (option->state & State_Item) {
531  if (option->direction == Qt::RightToLeft)
532  painter->fillRect(option->rect.left(), mid_v, bef_h - option->rect.left(), 1, brush);
533  else
534  painter->fillRect(aft_h, mid_v, option->rect.right() - aft_h + 1, 1, brush);
535  }
536  if (option->state & State_Sibling && option->rect.bottom() > aft_v)
537  painter->fillRect(mid_h, aft_v, 1, option->rect.bottom() - aft_v + 1, brush);
538  if (option->state & (State_Open | State_Children | State_Item | State_Sibling) && (bef_v > option->rect.y()))
539  painter->fillRect(mid_h, option->rect.y(), 1, bef_v - option->rect.y(), brush);
540 #endif
541  }
542  break;
543 
544  case PE_PanelButtonBevel:
547  {
548  if (QWindowsVistaAnimation *a = d->widgetAnimation(widget)) {
549  a->paint(painter, option);
550  } else {
551  QWindowsXPStyle::drawPrimitive(element, option, painter, widget);
552  }
553  }
554  break;
555 
556  case PE_FrameMenu:
557  {
558  int stateId = option->state & State_Active ? MB_ACTIVE : MB_INACTIVE;
559  XPThemeData theme(widget, painter, QLatin1String("MENU"), MENU_POPUPBORDERS, stateId, option->rect);
560  d->drawBackground(theme);
561  }
562  break;
563  case PE_Frame:
564 #ifndef QT_NO_TEXTEDIT
565  if (const QTextEdit *edit = qobject_cast<const QTextEdit*>(widget)) {
566  painter->save();
567  int stateId = ETS_NORMAL;
568  if (!(state & State_Enabled))
569  stateId = ETS_DISABLED;
570  else if (edit->isReadOnly())
571  stateId = ETS_READONLY;
572  else if (state & State_HasFocus)
573  stateId = ETS_SELECTED;
574  XPThemeData theme(widget, painter, QLatin1String("EDIT"), EP_EDITBORDER_HVSCROLL, stateId, option->rect);
575  // Since EP_EDITBORDER_HVSCROLL does not us borderfill, theme.noContent cannot be used for clipping
576  int borderSize = 1;
577  pGetThemeInt(theme.handle(), theme.partId, theme.stateId, TMT_BORDERSIZE, &borderSize);
578  QRegion clipRegion = option->rect;
579  QRegion content = option->rect.adjusted(borderSize, borderSize, -borderSize, -borderSize);
580  clipRegion ^= content;
581  painter->setClipRegion(clipRegion);
582  d->drawBackground(theme);
583  painter->restore();
584  } else
585 #endif // QT_NO_TEXTEDIT
586  QWindowsXPStyle::drawPrimitive(element, option, painter, widget);
587  break;
588 
589  case PE_PanelLineEdit:
590  if (const QStyleOptionFrame *panel = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
591  QBrush bg;
592  bool usePalette = false;
593  bool isEnabled = option->state & State_Enabled;
594  uint resolve_mask = panel->palette.resolve();
595  if (widget) {
596  //Since spin box and combo box includes a line edit we need to resolve the palette on the parent instead
597 #ifndef QT_NO_SPINBOX
598  if (QAbstractSpinBox *spinbox = qobject_cast<QAbstractSpinBox*>(widget->parentWidget()))
599  resolve_mask = spinbox->palette().resolve();
600 #endif // QT_NO_SPINBOX
601  }
602  if (resolve_mask & (1 << QPalette::Base)) {
603  // Base color is set for this widget, so use it
604  bg = panel->palette.brush(QPalette::Base);
605  usePalette = true;
606  }
607  if (usePalette) {
608  painter->fillRect(panel->rect, bg);
609  } else {
610  int partId = EP_BACKGROUND;
611  int stateId = EBS_NORMAL;
612  if (!isEnabled)
613  stateId = EBS_DISABLED;
614  else if (state & State_ReadOnly)
615  stateId = EBS_READONLY;
616  else if (state & State_MouseOver)
617  stateId = EBS_HOT;
618 
619  XPThemeData theme(0, painter, QLatin1String("EDIT"), partId, stateId, rect);
620  if (!theme.isValid()) {
621  QWindowsStyle::drawPrimitive(element, option, painter, widget);
622  return;
623  }
624  int bgType;
625  pGetThemeEnumValue( theme.handle(),
626  partId,
627  stateId,
628  TMT_BGTYPE,
629  &bgType);
630  if( bgType == BT_IMAGEFILE ) {
631  d->drawBackground(theme);
632  } else {
633  QBrush fillColor = option->palette.brush(QPalette::Base);
634  if (!isEnabled) {
635  PROPERTYORIGIN origin = PO_NOTFOUND;
636  pGetThemePropertyOrigin(theme.handle(), theme.partId, theme.stateId, TMT_FILLCOLOR, &origin);
637  // Use only if the fill property comes from our part
638  if ((origin == PO_PART || origin == PO_STATE)) {
639  COLORREF bgRef;
640  pGetThemeColor(theme.handle(), partId, stateId, TMT_FILLCOLOR, &bgRef);
641  fillColor = QBrush(qRgb(GetRValue(bgRef), GetGValue(bgRef), GetBValue(bgRef)));
642  }
643  }
644  painter->fillRect(option->rect, fillColor);
645  }
646  }
647  if (panel->lineWidth > 0)
648  proxy()->drawPrimitive(PE_FrameLineEdit, panel, painter, widget);
649  return;
650  }
651  break;
652 
653  case PE_FrameLineEdit:
654  if (QWindowsVistaAnimation *anim = d->widgetAnimation(widget)) {
655  anim->paint(painter, option);
656  } else {
657  QPainter *p = painter;
659  // we try to check if this lineedit is a delegate on a QAbstractItemView-derived class.
660  QPen oldPen = p->pen();
661  // Inner white border
662  p->setPen(QPen(option->palette.base().color(), 1));
663  p->drawRect(option->rect.adjusted(1, 1, -2, -2));
664  // Outer dark border
665  p->setPen(QPen(option->palette.shadow().color(), 1));
666  p->drawRect(option->rect.adjusted(0, 0, -1, -1));
667  p->setPen(oldPen);
668  return;
669  } else {
670  int stateId = ETS_NORMAL;
671  if (!(state & State_Enabled))
672  stateId = ETS_DISABLED;
673  else if (state & State_ReadOnly)
674  stateId = ETS_READONLY;
675  else if (state & State_MouseOver)
676  stateId = ETS_HOT;
677  else if (state & State_HasFocus)
678  stateId = ETS_SELECTED;
679  XPThemeData theme(widget, painter, QLatin1String("EDIT"), EP_EDITBORDER_NOSCROLL, stateId, option->rect);
680  painter->save();
681  QRegion clipRegion = option->rect;
682  clipRegion -= option->rect.adjusted(2, 2, -2, -2);
683  painter->setClipRegion(clipRegion);
684  d->drawBackground(theme);
685  painter->restore();
686  }
687  }
688  break;
689 
691  {
692  XPThemeData theme;
693  QRect rect;
694  if (option->state & State_Horizontal) {
695  theme = XPThemeData(widget, painter, QLatin1String("REBAR"), RP_GRIPPER, ETS_NORMAL, option->rect.adjusted(0, 1, -2, -2));
696  rect = option->rect.adjusted(0, 1, 0, -2);
697  rect.setWidth(4);
698  } else {
699  theme = XPThemeData(widget, painter, QLatin1String("REBAR"), RP_GRIPPERVERT, ETS_NORMAL, option->rect.adjusted(0, 1, -2, -2));
700  rect = option->rect.adjusted(1, 0, -1, 0);
701  rect.setHeight(4);
702  }
703  theme.rect = rect;
704  d->drawBackground(theme);
705  }
706  break;
707 
709  {
710  QPen pen = painter->pen();
711  int margin = 3;
712  painter->setPen(option->palette.background().color().darker(114));
713  if (option->state & State_Horizontal) {
714  int x1 = option->rect.center().x();
715  painter->drawLine(QPoint(x1, option->rect.top() + margin), QPoint(x1, option->rect.bottom() - margin));
716  } else {
717  int y1 = option->rect.center().y();
718  painter->drawLine(QPoint(option->rect.left() + margin, y1), QPoint(option->rect.right() - margin, y1));
719  }
720  painter->setPen(pen);
721  }
722  break;
723 
724  case PE_PanelTipLabel: {
725  XPThemeData theme(widget, painter, QLatin1String("TOOLTIP"), TTP_STANDARD, TTSS_NORMAL, option->rect);
726  d->drawBackground(theme);
727  break;
728  }
729 
731  {
732  const QStyleOptionViewItemV4 *vopt;
733  const QAbstractItemView *view = qobject_cast<const QAbstractItemView *>(widget);
734  bool newStyle = true;
735 
736  if (qobject_cast<const QTableView*>(widget))
737  newStyle = false;
738 
739  if (newStyle && view && (vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option))) {
740  bool selected = vopt->state & QStyle::State_Selected;
741  bool hover = vopt->state & QStyle::State_MouseOver;
742  bool active = vopt->state & QStyle::State_Active;
743 
745  painter->fillRect(vopt->rect, vopt->palette.alternateBase());
746 
749  if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active))
750  cg = QPalette::Inactive;
751 
752  QRect itemRect = subElementRect(QStyle::SE_ItemViewItemFocusRect, option, widget).adjusted(-1, 0, 1, 0);
753  itemRect.setTop(vopt->rect.top());
754  itemRect.setBottom(vopt->rect.bottom());
755 
756  QSize sectionSize = itemRect.size();
757  if (vopt->showDecorationSelected)
758  sectionSize = vopt->rect.size();
759 
761  sectionSize.setWidth(vopt->rect.width());
763  hover = false;
764  QPixmap pixmap;
765 
766  if (vopt->backgroundBrush.style() != Qt::NoBrush) {
767  const QPointF oldBrushOrigin = painter->brushOrigin();
768  painter->setBrushOrigin(vopt->rect.topLeft());
769  painter->fillRect(vopt->rect, vopt->backgroundBrush);
770  painter->setBrushOrigin(oldBrushOrigin);
771  }
772 
773  if (hover || selected) {
774  if (sectionSize.width() > 0 && sectionSize.height() > 0) {
775  QString key = QString::fromLatin1("qvdelegate-%1-%2-%3-%4-%5").arg(sectionSize.width())
776  .arg(sectionSize.height()).arg(selected).arg(active).arg(hover);
777  if (!QPixmapCache::find(key, pixmap)) {
778  pixmap = QPixmap(sectionSize);
779  pixmap.fill(Qt::transparent);
780 
781  int state;
782  if (selected && hover)
783  state = LISS_HOTSELECTED;
784  else if (selected && !active)
785  state = LISS_SELECTEDNOTFOCUS;
786  else if (selected)
787  state = LISS_SELECTED;
788  else
789  state = LISS_HOT;
790 
791  QPainter pixmapPainter(&pixmap);
792  XPThemeData theme(d->treeViewHelper(), &pixmapPainter, QLatin1String("TREEVIEW"),
793  LVP_LISTITEM, state, QRect(0, 0, sectionSize.width(), sectionSize.height()));
794  if (theme.isValid()) {
795  d->drawBackground(theme);
796  } else {
797  QWindowsXPStyle::drawPrimitive(PE_PanelItemViewItem, option, painter, widget);
798  break;;
799  }
800  QPixmapCache::insert(key, pixmap);
801  }
802  }
803 
804  if (vopt->showDecorationSelected) {
805  const int frame = 2; //Assumes a 2 pixel pixmap border
806  QRect srcRect = QRect(0, 0, sectionSize.width(), sectionSize.height());
807  QRect pixmapRect = vopt->rect;
808  bool reverse = vopt->direction == Qt::RightToLeft;
809  bool leftSection = vopt->viewItemPosition == QStyleOptionViewItemV4::Beginning;
810  bool rightSection = vopt->viewItemPosition == QStyleOptionViewItemV4::End;
813  painter->drawPixmap(pixmapRect.topLeft(), pixmap);
814  else if (reverse ? rightSection : leftSection){
815  painter->drawPixmap(QRect(pixmapRect.topLeft(),
816  QSize(frame, pixmapRect.height())), pixmap,
817  QRect(QPoint(0, 0), QSize(frame, pixmapRect.height())));
818  painter->drawPixmap(pixmapRect.adjusted(frame, 0, 0, 0),
819  pixmap, srcRect.adjusted(frame, 0, -frame, 0));
820  } else if (reverse ? leftSection : rightSection) {
821  painter->drawPixmap(QRect(pixmapRect.topRight() - QPoint(frame - 1, 0),
822  QSize(frame, pixmapRect.height())), pixmap,
823  QRect(QPoint(pixmapRect.width() - frame, 0),
824  QSize(frame, pixmapRect.height())));
825  painter->drawPixmap(pixmapRect.adjusted(0, 0, -frame, 0),
826  pixmap, srcRect.adjusted(frame, 0, -frame, 0));
828  painter->drawPixmap(pixmapRect, pixmap,
829  srcRect.adjusted(frame, 0, -frame, 0));
830  } else {
831  if (vopt->text.isEmpty() && vopt->icon.isNull())
832  break;
833  painter->drawPixmap(itemRect.topLeft(), pixmap);
834  }
835  }
836  } else {
837  QWindowsXPStyle::drawPrimitive(element, option, painter, widget);
838  }
839  break;
840  }
841  case PE_Widget:
842  {
843  const QDialogButtonBox *buttonBox = 0;
844 
845  if (qobject_cast<const QMessageBox *> (widget))
846  buttonBox = widget->findChild<const QDialogButtonBox *>(QLatin1String("qt_msgbox_buttonbox"));
847 #ifndef QT_NO_INPUTDIALOG
848  else if (qobject_cast<const QInputDialog *> (widget))
849  buttonBox = widget->findChild<const QDialogButtonBox *>(QLatin1String("qt_inputdlg_buttonbox"));
850 #endif // QT_NO_INPUTDIALOG
851 
852  if (buttonBox) {
853  //draw white panel part
854  XPThemeData theme(widget, painter, QLatin1String("TASKDIALOG"), TDLG_PRIMARYPANEL, 0, option->rect);
855  QRect toprect = option->rect;
856  toprect.setBottom(buttonBox->geometry().top());
857  theme.rect = toprect;
858  d->drawBackground(theme);
859 
860  //draw bottom panel part
861  QRect buttonRect = option->rect;
862  buttonRect.setTop(buttonBox->geometry().top());
863  theme.rect = buttonRect;
864  theme.partId = TDLG_SECONDARYPANEL;
865  d->drawBackground(theme);
866  }
867  }
868  break;
869  default:
870  QWindowsXPStyle::drawPrimitive(element, option, painter, widget);
871  break;
872  }
873 }
874 
875 
882  QPainter *painter, const QWidget *widget) const
883 {
884  QWindowsVistaStylePrivate *d = const_cast<QWindowsVistaStylePrivate*>(d_func());
885 
887  QWindowsStyle::drawControl(element, option, painter, widget);
888  return;
889  }
890 
891  bool selected = option->state & State_Selected;
892  bool pressed = option->state & State_Sunken;
893  bool disabled = !(option->state & State_Enabled);
894 
895  int state = option->state;
896  QString name;
897 
898  QRect rect(option->rect);
899  State flags = option->state;
900  int partId = 0;
901  int stateId = 0;
902 
903  QRect oldRect;
904  QRect newRect;
905 
906  if (d->transitionsEnabled() && widget) {
907  if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
908  if ((qobject_cast<const QPushButton*>(widget) && element == CE_PushButtonBevel))
909  {
910  QWidget *w = const_cast<QWidget *> (widget);
911  int oldState = w->property("_q_stylestate").toInt();
912  oldRect = w->property("_q_stylerect").toRect();
913  newRect = w->rect();
914  w->setProperty("_q_stylestate", (int)option->state);
915  w->setProperty("_q_stylerect", w->rect());
916 
917  bool wasDefault = w->property("_q_isdefault").toBool();
918  bool isDefault = button->features & QStyleOptionButton::DefaultButton;
919  w->setProperty("_q_isdefault", isDefault);
920 
921  bool doTransition = ((state & State_Sunken) != (oldState & State_Sunken) ||
922  (state & State_On) != (oldState & State_On) ||
923  (state & State_MouseOver) != (oldState & State_MouseOver));
924 
925  if (oldRect != newRect || (wasDefault && !isDefault))
926  {
927  doTransition = false;
928  d->stopAnimation(widget);
929  }
930 
931  if (doTransition) {
932  QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
934  QWindowsVistaAnimation *anim = d->widgetAnimation(widget);
935 
936  QStyleOptionButton opt = *button;
937  opt.state = (QStyle::State)oldState;
938 
939  startImage.fill(0);
941  t->setWidget(w);
942  QPainter startPainter(&startImage);
943 
944  if (!anim) {
945  proxy()->drawControl(element, &opt, &startPainter, 0 /* Intentional */);
946  } else {
947  anim->paint(&startPainter, &opt);
948  d->stopAnimation(widget);
949  }
950 
951  t->setStartImage(startImage);
952  d->startAnimation(t);
953 
954  endImage.fill(0);
955  QPainter endPainter(&endImage);
956  proxy()->drawControl(element, option, &endPainter, 0 /* Intentional */);
957  t->setEndImage(endImage);
958  int duration = 0;
959  HTHEME theme = pOpenThemeData(0, L"Button");
960 
961  int fromState = buttonStateId(oldState, BP_PUSHBUTTON);
962  int toState = buttonStateId(option->state, BP_PUSHBUTTON);
963  if (pGetThemeTransitionDuration(theme, BP_PUSHBUTTON, fromState, toState, TMT_TRANSITIONDURATIONS, &duration) == S_OK)
964  t->setDuration(duration);
965  else
966  t->setDuration(0);
968  }
969  }
970  }
971  }
972  switch (element) {
973  case CE_PushButtonBevel:
974  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option))
975  {
976 
977  QWindowsVistaAnimation *anim = d->widgetAnimation(widget);
978  if (anim && (btn->state & State_Enabled)) {
979  anim->paint(painter, option);
980  } else {
981  name = QLatin1String("BUTTON");
982  partId = BP_PUSHBUTTON;
983  if (btn->features & QStyleOptionButton::CommandLinkButton)
984  partId = BP_COMMANDLINK;
985  bool justFlat = (btn->features & QStyleOptionButton::Flat) && !(flags & (State_On|State_Sunken));
986  if (!(flags & State_Enabled) && !(btn->features & QStyleOptionButton::Flat))
987  stateId = PBS_DISABLED;
988  else if (justFlat)
989  ;
990  else if (flags & (State_Sunken | State_On))
991  stateId = PBS_PRESSED;
992  else if (flags & State_MouseOver)
993  stateId = PBS_HOT;
994  else if (btn->features & QStyleOptionButton::DefaultButton && (state & State_Active))
995  stateId = PBS_DEFAULTED;
996  else
997  stateId = PBS_NORMAL;
998 
999  if (!justFlat) {
1000 
1001  if (widget && d->transitionsEnabled() && (btn->features & QStyleOptionButton::DefaultButton) &&
1002  !(state & (State_Sunken | State_On)) && !(state & State_MouseOver) &&
1003  (state & State_Enabled) && (state & State_Active))
1004  {
1005  if (!anim && widget) {
1006  QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
1007  startImage.fill(0);
1008  QImage alternateImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
1009  alternateImage.fill(0);
1010 
1012  pulse->setWidget(const_cast<QWidget*>(widget));
1013 
1014  QPainter startPainter(&startImage);
1015  stateId = PBS_DEFAULTED;
1016  XPThemeData theme(widget, &startPainter, name, partId, stateId, rect);
1017  d->drawBackground(theme);
1018 
1019  QPainter alternatePainter(&alternateImage);
1021  theme.painter = &alternatePainter;
1022  d->drawBackground(theme);
1023  pulse->setPrimaryImage(startImage);
1024  pulse->setAlternateImage(alternateImage);
1025  pulse->setStartTime(QTime::currentTime());
1026  pulse->setDuration(2000);
1027  d->startAnimation(pulse);
1028  anim = pulse;
1029  }
1030 
1031  if (anim)
1032  anim->paint(painter, option);
1033  else {
1034  XPThemeData theme(widget, painter, name, partId, stateId, rect);
1035  d->drawBackground(theme);
1036  }
1037  }
1038  else {
1039  d->stopAnimation(widget);
1040  XPThemeData theme(widget, painter, name, partId, stateId, rect);
1041  d->drawBackground(theme);
1042  }
1043  }
1044  }
1045  if (btn->features & QStyleOptionButton::HasMenu) {
1046  int mbiw = 0, mbih = 0;
1047  XPThemeData theme(widget, 0, QLatin1String("TOOLBAR"), TP_DROPDOWNBUTTON);
1048  if (theme.isValid()) {
1049  SIZE size;
1050  if (pGetThemePartSize(theme.handle(), 0, theme.partId, theme.stateId, 0, TS_TRUE, &size) == S_OK) {
1051  mbiw = size.cx;
1052  mbih = size.cy;
1053  }
1054  }
1055  QRect ir = subElementRect(SE_PushButtonContents, option, 0);
1056  QStyleOptionButton newBtn = *btn;
1057  newBtn.rect = QStyle::visualRect(option->direction, option->rect,
1058  QRect(ir.right() - mbiw - 2,
1059  option->rect.top() + (option->rect.height()/2) - (mbih/2),
1060  mbiw + 1, mbih + 1));
1061  proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget);
1062  }
1063  return;
1064  }
1065  break;
1066 #ifndef QT_NO_PROGRESSBAR
1067  case CE_ProgressBarGroove:
1068  {
1070  if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option))
1071  orient = pb2->orientation;
1072  partId = (orient == Qt::Horizontal) ? PP_TRANSPARENTBAR : PP_TRANSPARENTBARVERT;
1073  name = QLatin1String("PROGRESS");
1074  stateId = 1;
1075 
1076  XPThemeData theme(widget, painter, name, partId, stateId, rect);
1077  d->drawBackground(theme);
1078  }
1079  break;
1081  if (const QStyleOptionProgressBar *bar
1082  = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
1083  bool isIndeterminate = (bar->minimum == 0 && bar->maximum == 0);
1084  bool vertical = false;
1085  bool inverted = false;
1086  if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) {
1087  vertical = (pb2->orientation == Qt::Vertical);
1088  inverted = pb2->invertedAppearance;
1089  }
1090 
1091  if (const QProgressBar *progressbar = qobject_cast<const QProgressBar *>(widget)) {
1092  if (isIndeterminate || (progressbar->value() > 0 && (progressbar->value() < progressbar->maximum()) && d->transitionsEnabled())) {
1093  if (!d->widgetAnimation(progressbar)) {
1095  a->setWidget(const_cast<QWidget*>(widget));
1097  d->startAnimation(a);
1098  }
1099  } else {
1100  d->stopAnimation(progressbar);
1101  }
1102  }
1103 
1104  XPThemeData theme(widget, painter, QLatin1String("PROGRESS"), vertical ? PP_FILLVERT : PP_FILL);
1105  theme.rect = option->rect;
1106  bool reverse = (bar->direction == Qt::LeftToRight && inverted) || (bar->direction == Qt::RightToLeft && !inverted);
1107  QTime current = QTime::currentTime();
1108 
1109  if (isIndeterminate) {
1110  if (QWindowsVistaAnimation *a = d->widgetAnimation(widget)) {
1111  int glowSize = 120;
1112  int animationWidth = glowSize * 2 + (vertical ? theme.rect.height() : theme.rect.width());
1113  int animOffset = a->startTime().msecsTo(current) / 4;
1114  if (animOffset > animationWidth)
1115  a->setStartTime(QTime::currentTime());
1116  painter->save();
1117  painter->setClipRect(theme.rect);
1118  QRect animRect;
1119  QSize pixmapSize(14, 14);
1120  if (vertical) {
1121  animRect = QRect(theme.rect.left(),
1122  inverted ? rect.top() - glowSize + animOffset :
1123  rect.bottom() + glowSize - animOffset,
1124  rect.width(), glowSize);
1125  pixmapSize.setHeight(animRect.height());
1126  } else {
1127  animRect = QRect(rect.left() - glowSize + animOffset,
1128  rect.top(), glowSize, rect.height());
1129  animRect = QStyle::visualRect(reverse ? Qt::RightToLeft : Qt::LeftToRight,
1130  option->rect, animRect);
1131  pixmapSize.setWidth(animRect.width());
1132  }
1133  QString name = QString::fromLatin1("qiprogress-%1-%2").arg(pixmapSize.width()).arg(pixmapSize.height());
1134  QPixmap pixmap;
1135  if (!QPixmapCache::find(name, pixmap)) {
1136  QImage image(pixmapSize, QImage::Format_ARGB32);
1137  image.fill(Qt::transparent);
1138  QPainter imagePainter(&image);
1139  theme.painter = &imagePainter;
1140  theme.partId = vertical ? PP_FILLVERT : PP_FILL;
1141  theme.rect = QRect(QPoint(0,0), theme.rect.size());
1142  QLinearGradient alphaGradient(0, 0, vertical ? 0 : image.width(),
1143  vertical ? image.height() : 0);
1144  alphaGradient.setColorAt(0, QColor(0, 0, 0, 0));
1145  alphaGradient.setColorAt(0.5, QColor(0, 0, 0, 220));
1146  alphaGradient.setColorAt(1, QColor(0, 0, 0, 0));
1147  imagePainter.fillRect(image.rect(), alphaGradient);
1149  d->drawBackground(theme);
1150  imagePainter.end();
1151  pixmap = QPixmap::fromImage(image);
1152  QPixmapCache::insert(name, pixmap);
1153  }
1154  painter->drawPixmap(animRect, pixmap);
1155  painter->restore();
1156  }
1157  }
1158  else {
1159  qint64 progress = qMax<qint64>(bar->progress, bar->minimum); // workaround for bug in QProgressBar
1160 
1161  if (vertical) {
1162  int maxHeight = option->rect.height();
1163  int minHeight = 0;
1164  double vc6_workaround = ((progress - qint64(bar->minimum)) / qMax(double(1.0), double(qint64(bar->maximum) - qint64(bar->minimum))) * maxHeight);
1165  int height = isIndeterminate ? maxHeight: qMax(int(vc6_workaround), minHeight);
1166  theme.rect.setHeight(height);
1167  if (!inverted)
1168  theme.rect.moveTop(rect.height() - theme.rect.height());
1169  } else {
1170  int maxWidth = option->rect.width();
1171  int minWidth = 0;
1172  double vc6_workaround = ((progress - qint64(bar->minimum)) / qMax(double(1.0), double(qint64(bar->maximum) - qint64(bar->minimum))) * maxWidth);
1173  int width = isIndeterminate ? maxWidth : qMax(int(vc6_workaround), minWidth);
1174  theme.rect.setWidth(width);
1176  option->rect, theme.rect);
1177  }
1178  d->drawBackground(theme);
1179 
1180  if (QWindowsVistaAnimation *a = d->widgetAnimation(widget)) {
1181  int glowSize = 140;
1182  int animationWidth = glowSize * 2 + (vertical ? theme.rect.height() : theme.rect.width());
1183  int animOffset = a->startTime().msecsTo(current) / 4;
1184  theme.partId = vertical ? PP_MOVEOVERLAYVERT : PP_MOVEOVERLAY;
1185  if (animOffset > animationWidth) {
1186  if (bar->progress < bar->maximum)
1187  a->setStartTime(QTime::currentTime());
1188  else
1189  d->stopAnimation(widget); //we stop the glow motion only after it has
1190  //moved out of view
1191  }
1192  painter->save();
1193  painter->setClipRect(theme.rect);
1194  if (vertical) {
1195  theme.rect = QRect(theme.rect.left(),
1196  inverted ? rect.top() - glowSize + animOffset :
1197  rect.bottom() + glowSize - animOffset,
1198  rect.width(), glowSize);
1199  } else {
1200  theme.rect = QRect(rect.left() - glowSize + animOffset,rect.top(), glowSize, rect.height());
1201  theme.rect = QStyle::visualRect(reverse ? Qt::RightToLeft : Qt::LeftToRight, option->rect, theme.rect);
1202  }
1203  d->drawBackground(theme);
1204  painter->restore();
1205  }
1206  }
1207  }
1208  break;
1209 #endif // QT_NO_PROGRESSBAR
1210  case CE_MenuBarItem:
1211  {
1212 
1213  if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option))
1214  {
1215  if (mbi->menuItemType == QStyleOptionMenuItem::DefaultItem)
1216  break;
1217 
1219  QPixmap pix = mbi->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), QIcon::Normal);
1220 
1222  if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget))
1223  alignment |= Qt::TextHideMnemonic;
1224 
1225  //The rect adjustment is a workaround for the menu not really filling its background.
1226  XPThemeData theme(widget, painter, QLatin1String("MENU"), MENU_BARBACKGROUND, 0, option->rect.adjusted(-1, 0, 2, 1));
1227  d->drawBackground(theme);
1228 
1229  int stateId = MBI_NORMAL;
1230  if (disabled)
1231  stateId = MBI_DISABLED;
1232  else if (pressed)
1233  stateId = MBI_PUSHED;
1234  else if (selected)
1235  stateId = MBI_HOT;
1236 
1237  XPThemeData theme2(widget, painter, QLatin1String("MENU"), MENU_BARITEM, stateId, option->rect);
1238  d->drawBackground(theme2);
1239 
1240  if (!pix.isNull())
1241  drawItemPixmap(painter, mbi->rect, alignment, pix);
1242  else
1243  drawItemText(painter, mbi->rect, alignment, mbi->palette, mbi->state & State_Enabled, mbi->text, textRole);
1244  }
1245  }
1246  break;
1247 #ifndef QT_NO_MENU
1248  case CE_MenuItem:
1249  if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
1250  // windows always has a check column, regardless whether we have an icon or not
1251  int checkcol = 25;
1252  {
1253  SIZE size;
1254  MARGINS margins;
1255  XPThemeData theme(widget, 0, QLatin1String("MENU"), MENU_POPUPCHECKBACKGROUND, MBI_HOT);
1256  pGetThemePartSize(theme.handle(), NULL, MENU_POPUPCHECK, 0, NULL,TS_TRUE, &size);
1257  pGetThemeMargins(theme.handle(), NULL, MENU_POPUPCHECK, 0, TMT_CONTENTMARGINS, NULL, &margins);
1258  checkcol = qMax(menuitem->maxIconWidth, int(3 + size.cx + margins.cxLeftWidth + margins.cxRightWidth));
1259  }
1260  QRect rect = option->rect;
1261 
1262  //draw vertical menu line
1263  if (option->direction == Qt::LeftToRight)
1264  checkcol += rect.x();
1265  QPoint p1 = QStyle::visualPos(option->direction, menuitem->rect, QPoint(checkcol, rect.top()));
1266  QPoint p2 = QStyle::visualPos(option->direction, menuitem->rect, QPoint(checkcol, rect.bottom()));
1267  QRect gutterRect(p1.x(), p1.y(), 3, p2.y() - p1.y() + 1);
1268  XPThemeData theme2(widget, painter, QLatin1String("MENU"), MENU_POPUPGUTTER, stateId, gutterRect);
1269  d->drawBackground(theme2);
1270 
1271  int x, y, w, h;
1272  menuitem->rect.getRect(&x, &y, &w, &h);
1273  int tab = menuitem->tabWidth;
1274  bool dis = !(menuitem->state & State_Enabled);
1275  bool checked = menuitem->checkType != QStyleOptionMenuItem::NotCheckable
1276  ? menuitem->checked : false;
1277  bool act = menuitem->state & State_Selected;
1278 
1279  if (menuitem->menuItemType == QStyleOptionMenuItem::Separator) {
1280  int yoff = y-2 + h / 2;
1281  QPoint p1 = QPoint(x + checkcol, yoff);
1282  QPoint p2 = QPoint(x + w + 6 , yoff);
1283  stateId = MBI_HOT;
1284  QRect subRect(p1.x(), p1.y(), p2.x() - p1.x(), 6);
1285  subRect = QStyle::visualRect(option->direction, option->rect, subRect );
1286  XPThemeData theme2(widget, painter, QLatin1String("MENU"), MENU_POPUPSEPARATOR, stateId, subRect);
1287  d->drawBackground(theme2);
1288  return;
1289  }
1290 
1291  QRect vCheckRect = visualRect(option->direction, menuitem->rect, QRect(menuitem->rect.x(),
1292  menuitem->rect.y(), checkcol - 6, menuitem->rect.height()));
1293 
1294  if (act) {
1295  stateId = dis ? MBI_DISABLED : MBI_HOT;
1296  XPThemeData theme2(widget, painter, QLatin1String("MENU"), MENU_POPUPITEM, stateId, option->rect);
1297  d->drawBackground(theme2);
1298  }
1299 
1300  if (checked) {
1301  XPThemeData theme(widget, painter, QLatin1String("MENU"), MENU_POPUPCHECKBACKGROUND,
1302  menuitem->icon.isNull() ? MBI_HOT : MBI_PUSHED, vCheckRect);
1303  SIZE size;
1304  MARGINS margins;
1305  pGetThemePartSize(theme.handle(), NULL, MENU_POPUPCHECK, 0, NULL,TS_TRUE, &size);
1306  pGetThemeMargins(theme.handle(), NULL, MENU_POPUPCHECK, 0,
1307  TMT_CONTENTMARGINS, NULL, &margins);
1308  QRect checkRect(0, 0, size.cx + margins.cxLeftWidth + margins.cxRightWidth ,
1309  size.cy + margins.cyBottomHeight + margins.cyTopHeight);
1310  checkRect.moveCenter(vCheckRect.center());
1311  theme.rect = checkRect;
1312 
1313  d->drawBackground(theme);
1314 
1315  if (menuitem->icon.isNull()) {
1316  checkRect = QRect(0, 0, size.cx, size.cy);
1317  checkRect.moveCenter(theme.rect.center());
1318  theme.rect = checkRect;
1319 
1320  theme.partId = MENU_POPUPCHECK;
1321  bool bullet = menuitem->checkType & QStyleOptionMenuItem::Exclusive;
1322  if (dis)
1323  theme.stateId = bullet ? MC_BULLETDISABLED: MC_CHECKMARKDISABLED;
1324  else
1325  theme.stateId = bullet ? MC_BULLETNORMAL: MC_CHECKMARKNORMAL;
1326  d->drawBackground(theme);
1327  }
1328  }
1329 
1330  if (!menuitem->icon.isNull()) {
1331  QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
1332  if (act && !dis)
1333  mode = QIcon::Active;
1334  QPixmap pixmap;
1335  if (checked)
1336  pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), mode, QIcon::On);
1337  else
1338  pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), mode);
1339  int pixw = pixmap.width();
1340  int pixh = pixmap.height();
1341  QRect pmr(0, 0, pixw, pixh);
1342  pmr.moveCenter(vCheckRect.center());
1343  painter->setPen(menuitem->palette.text().color());
1344  painter->drawPixmap(pmr.topLeft(), pixmap);
1345  }
1346 
1347  painter->setPen(menuitem->palette.buttonText().color());
1348 
1349  const QColor textColor = menuitem->palette.text().color();
1350  if (dis)
1351  painter->setPen(textColor);
1352 
1353  int xm = windowsItemFrame + checkcol + windowsItemHMargin;
1354  int xpos = menuitem->rect.x() + xm;
1355  QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin);
1356  QRect vTextRect = visualRect(option->direction, menuitem->rect, textRect);
1357  QString s = menuitem->text;
1358  if (!s.isEmpty()) { // draw text
1359  painter->save();
1360  int t = s.indexOf(QLatin1Char('\t'));
1362  if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget))
1363  text_flags |= Qt::TextHideMnemonic;
1364  text_flags |= Qt::AlignLeft;
1365  if (t >= 0) {
1366  QRect vShortcutRect = visualRect(option->direction, menuitem->rect,
1367  QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom())));
1368  painter->drawText(vShortcutRect, text_flags, s.mid(t + 1));
1369  s = s.left(t);
1370  }
1371  QFont font = menuitem->font;
1372  if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem)
1373  font.setBold(true);
1374  painter->setFont(font);
1375  painter->setPen(textColor);
1376  painter->drawText(vTextRect, text_flags, s.left(t));
1377  painter->restore();
1378  }
1379  if (menuitem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow
1380  int dim = (h - 2 * windowsItemFrame) / 2;
1381  PrimitiveElement arrow;
1383  xpos = x + w - windowsArrowHMargin - windowsItemFrame - dim;
1384  QRect vSubMenuRect = visualRect(option->direction, menuitem->rect, QRect(xpos, y + h / 2 - dim / 2, dim, dim));
1385  QStyleOptionMenuItem newMI = *menuitem;
1386  newMI.rect = vSubMenuRect;
1387  newMI.state = dis ? State_None : State_Enabled;
1388  proxy()->drawPrimitive(arrow, &newMI, painter, widget);
1389  }
1390  }
1391  break;
1392 #endif // QT_NO_MENU
1393  case CE_HeaderSection:
1394  if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
1395  name = QLatin1String("HEADER");
1396  partId = HP_HEADERITEM;
1397  if (flags & State_Sunken)
1398  stateId = HIS_PRESSED;
1399  else if (flags & State_MouseOver)
1400  stateId = HIS_HOT;
1401  else
1402  stateId = HIS_NORMAL;
1403 
1404  if (header->sortIndicator != QStyleOptionHeader::None)
1405  stateId += 3;
1406 
1407  XPThemeData theme(widget, painter, name, partId, stateId, option->rect);
1408  d->drawBackground(theme);
1409  }
1410  break;
1411  case CE_MenuBarEmptyArea:
1412  {
1413  stateId = MBI_NORMAL;
1414  if (!(state & State_Enabled))
1415  stateId = MBI_DISABLED;
1416  XPThemeData theme(widget, painter, QLatin1String("MENU"), MENU_BARBACKGROUND, stateId, option->rect);
1417  d->drawBackground(theme);
1418  }
1419  break;
1420  case CE_ToolBar:
1421  if (const QStyleOptionToolBar *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(option)) {
1422  QPalette pal = option->palette;
1423  pal.setColor(QPalette::Dark, option->palette.background().color().darker(130));
1424  QStyleOptionToolBar copyOpt = *toolbar;
1425  copyOpt.palette = pal;
1426  QWindowsStyle::drawControl(element, &copyOpt, painter, widget);
1427  }
1428  break;
1429  case CE_DockWidgetTitle:
1430  if (const QDockWidget *dockWidget = qobject_cast<const QDockWidget *>(widget)) {
1431  QRect rect = option->rect;
1432  if (dockWidget->isFloating()) {
1433  QWindowsXPStyle::drawControl(element, option, painter, widget);
1434  break; //otherwise fall through
1435  }
1436 
1437  if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(option)) {
1438 
1439  const QStyleOptionDockWidgetV2 *v2
1441  bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
1442 
1443  if (verticalTitleBar) {
1444  QSize s = rect.size();
1445  s.transpose();
1446  rect.setSize(s);
1447 
1448  painter->translate(rect.left() - 1, rect.top() + rect.width());
1449  painter->rotate(-90);
1450  painter->translate(-rect.left() + 1, -rect.top());
1451  }
1452 
1453  painter->setBrush(option->palette.background().color().darker(110));
1454  painter->setPen(option->palette.background().color().darker(130));
1455  painter->drawRect(rect.adjusted(0, 1, -1, -3));
1456 
1457  int buttonMargin = 4;
1458  int mw = proxy()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, dwOpt, widget);
1459  int fw = proxy()->pixelMetric(PM_DockWidgetFrameWidth, dwOpt, widget);
1460  const QDockWidget *dw = qobject_cast<const QDockWidget *>(widget);
1461  bool isFloating = dw != 0 && dw->isFloating();
1462 
1463  QRect r = option->rect.adjusted(0, 2, -1, -3);
1464  QRect titleRect = r;
1465 
1466  if (dwOpt->closable) {
1467  QSize sz = standardIcon(QStyle::SP_TitleBarCloseButton, dwOpt, widget).actualSize(QSize(10, 10));
1468  titleRect.adjust(0, 0, -sz.width() - mw - buttonMargin, 0);
1469  }
1470 
1471  if (dwOpt->floatable) {
1472  QSize sz = standardIcon(QStyle::SP_TitleBarMaxButton, dwOpt, widget).actualSize(QSize(10, 10));
1473  titleRect.adjust(0, 0, -sz.width() - mw - buttonMargin, 0);
1474  }
1475 
1476  if (isFloating) {
1477  titleRect.adjust(0, -fw, 0, 0);
1478  if (widget != 0 && widget->windowIcon().cacheKey() != QApplication::windowIcon().cacheKey())
1479  titleRect.adjust(titleRect.height() + mw, 0, 0, 0);
1480  } else {
1481  titleRect.adjust(mw, 0, 0, 0);
1482  if (!dwOpt->floatable && !dwOpt->closable)
1483  titleRect.adjust(0, 0, -mw, 0);
1484  }
1485  if (!verticalTitleBar)
1486  titleRect = visualRect(dwOpt->direction, r, titleRect);
1487 
1488  if (!dwOpt->title.isEmpty()) {
1489  QString titleText = painter->fontMetrics().elidedText(dwOpt->title, Qt::ElideRight,
1490  verticalTitleBar ? titleRect.height() : titleRect.width());
1491  const int indent = painter->fontMetrics().descent();
1492  drawItemText(painter, rect.adjusted(indent + 1, 1, -indent - 1, -1),
1493  Qt::AlignLeft | Qt::AlignVCenter, dwOpt->palette,
1494  dwOpt->state & State_Enabled, titleText,
1496  }
1497  }
1498  break;
1499  }
1500 #ifndef QT_NO_ITEMVIEWS
1501  case CE_ItemViewItem:
1502  {
1503  const QStyleOptionViewItemV4 *vopt;
1504  const QAbstractItemView *view = qobject_cast<const QAbstractItemView *>(widget);
1505  bool newStyle = true;
1506 
1507  if (qobject_cast<const QTableView*>(widget))
1508  newStyle = false;
1509 
1510  if (newStyle && view && (vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option))) {
1511  /*
1512  // We cannot currently get the correct selection color for "explorer style" views
1513  COLORREF cref = 0;
1514  XPThemeData theme(d->treeViewHelper(), 0, QLatin1String("LISTVIEW"), 0, 0);
1515  unsigned int res = pGetThemeColor(theme.handle(), LVP_LISTITEM, LISS_SELECTED, TMT_TEXTCOLOR, &cref);
1516  QColor textColor(GetRValue(cref), GetGValue(cref), GetBValue(cref));
1517  */
1518  QPalette palette = vopt->palette;
1520  // Note that setting a saturated color here results in ugly XOR colors in the focus rect
1521  palette.setColor(QPalette::All, QPalette::Highlight, palette.base().color().darker(108));
1522  QStyleOptionViewItemV4 adjustedOption = *vopt;
1523  adjustedOption.palette = palette;
1524  // We hide the focusrect in singleselection as it is not required
1526  && !(vopt->state & State_KeyboardFocusChange))
1527  adjustedOption.state &= ~State_HasFocus;
1528  QWindowsXPStyle::drawControl(element, &adjustedOption, painter, widget);
1529  } else {
1530  QWindowsXPStyle::drawControl(element, option, painter, widget);
1531  }
1532  break;
1533  }
1534 #endif // QT_NO_ITEMVIEWS
1535 
1536  default:
1537  QWindowsXPStyle::drawControl(element, option, painter, widget);
1538  break;
1539  }
1540 }
1541 
1549  QPainter *painter, const QWidget *widget) const
1550 {
1551  QWindowsVistaStylePrivate *d = const_cast<QWindowsVistaStylePrivate*>(d_func());
1553  QWindowsStyle::drawComplexControl(control, option, painter, widget);
1554  return;
1555  }
1556 
1557  State state = option->state;
1558  SubControls sub = option->subControls;
1559  QRect r = option->rect;
1560 
1561  int partId = 0;
1562  int stateId = 0;
1563 
1564  State flags = option->state;
1565  if (widget && widget->testAttribute(Qt::WA_UnderMouse) && widget->isActiveWindow())
1566  flags |= State_MouseOver;
1567 
1568  if (d->transitionsEnabled() && widget) {
1569  if ((qobject_cast<const QScrollBar *>(widget) && control == CC_ScrollBar)
1570 #ifndef QT_NO_SPINBOX
1571  || (qobject_cast<const QAbstractSpinBox*>(widget) && control == CC_SpinBox)
1572 #endif // QT_NO_SPINBOX
1573 #ifndef QT_NO_COMBOBOX
1574  || (qobject_cast<const QComboBox*>(widget) && control == CC_ComboBox)
1575 #endif // QT_NO_COMBOBOX
1576  )
1577  {
1578  QWidget *w = const_cast<QWidget *> (widget);
1579 
1580  int oldState = w->property("_q_stylestate").toInt();
1581  int oldActiveControls = w->property("_q_stylecontrols").toInt();
1582  QRect oldRect = w->property("_q_stylerect").toRect();
1583  w->setProperty("_q_stylestate", (int)option->state);
1584  w->setProperty("_q_stylecontrols", (int)option->activeSubControls);
1585  w->setProperty("_q_stylerect", w->rect());
1586 
1587  bool doTransition = ((state & State_Sunken) != (oldState & State_Sunken) ||
1588  (state & State_On) != (oldState & State_On) ||
1589  (state & State_MouseOver) != (oldState & State_MouseOver) ||
1590  oldActiveControls != option->activeSubControls);
1591 
1592 
1593  if (qstyleoption_cast<const QStyleOptionSlider *>(option)) {
1594  QRect oldSliderPos = w->property("_q_stylesliderpos").toRect();
1595  QRect currentPos = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);
1596  w->setProperty("_q_stylesliderpos", currentPos);
1597  if (oldSliderPos != currentPos) {
1598  doTransition = false;
1599  d->stopAnimation(widget);
1600  }
1601  } else if (control == CC_SpinBox) {
1602  //spinboxes have a transition when focus changes
1603  if (!doTransition)
1604  doTransition = (state & State_HasFocus) != (oldState & State_HasFocus);
1605  }
1606 
1607  if (oldRect != option->rect) {
1608  doTransition = false;
1609  d->stopAnimation(widget);
1610  }
1611 
1612  if (doTransition) {
1613  QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
1614  QImage endImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
1615  QWindowsVistaAnimation *anim = d->widgetAnimation(widget);
1617  t->setWidget(w);
1618  if (!anim) {
1619  if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox*>(option)) {
1620  //Combo boxes are special cased to avoid cleartype issues
1621  startImage.fill(0);
1622  QPainter startPainter(&startImage);
1623  QStyleOptionComboBox startCombo = *combo;
1624  startCombo.state = (QStyle::State)oldState;
1625  startCombo.activeSubControls = (QStyle::SubControl)oldActiveControls;
1626  proxy()->drawComplexControl(control, &startCombo, &startPainter, 0 /* Intentional */);
1627  t->setStartImage(startImage);
1628  } else if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider*>(option)) {
1629  //This is a workaround for the direct3d engine as it currently has some issues with grabWindow
1630  startImage.fill(0);
1631  QPainter startPainter(&startImage);
1632  QStyleOptionSlider startSlider = *slider;
1633  startSlider.state = (QStyle::State)oldState;
1634  startSlider.activeSubControls = (QStyle::SubControl)oldActiveControls;
1635  proxy()->drawComplexControl(control, &startSlider, &startPainter, 0 /* Intentional */);
1636  t->setStartImage(startImage);
1637  } else {
1638  QPoint offset(0, 0);
1639  if (!widget->internalWinId())
1640  offset = widget->mapTo(widget->nativeParentWidget(), offset);
1641  t->setStartImage(QPixmap::grabWindow(widget->effectiveWinId(), offset.x(), offset.y(),
1642  option->rect.width(), option->rect.height()).toImage());
1643  }
1644  } else {
1645  startImage.fill(0);
1646  QPainter startPainter(&startImage);
1647  anim->paint(&startPainter, option);
1648  t->setStartImage(startImage);
1649  }
1650  d->startAnimation(t);
1651  endImage.fill(0);
1652  QPainter endPainter(&endImage);
1653  proxy()->drawComplexControl(control, option, &endPainter, 0 /* Intentional */);
1654  t->setEndImage(endImage);
1656 
1657  if (option->state & State_MouseOver || option->state & State_Sunken)
1658  t->setDuration(150);
1659  else
1660  t->setDuration(500);
1661  }
1662 
1663  if (QWindowsVistaAnimation *anim = d->widgetAnimation(widget)) {
1664  anim->paint(painter, option);
1665  return;
1666  }
1667 
1668  }
1669  }
1670 
1671  switch (control) {
1672  case CC_ComboBox:
1673  if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option))
1674  {
1675  if (cmb->editable) {
1676  if (sub & SC_ComboBoxEditField) {
1677  partId = EP_EDITBORDER_NOSCROLL;
1678  if (!(flags & State_Enabled))
1679  stateId = ETS_DISABLED;
1680  else if (flags & State_MouseOver)
1681  stateId = ETS_HOT;
1682  else if (flags & State_HasFocus)
1683  stateId = ETS_FOCUSED;
1684  else
1685  stateId = ETS_NORMAL;
1686 
1687  XPThemeData theme(widget, painter, QLatin1String("EDIT"), partId, stateId, r);
1688 
1689  d->drawBackground(theme);
1690  }
1691  if (sub & SC_ComboBoxArrow) {
1692  QRect subRect = proxy()->subControlRect(CC_ComboBox, option, SC_ComboBoxArrow, widget);
1693  XPThemeData theme(widget, painter, QLatin1String("COMBOBOX"));
1694  theme.rect = subRect;
1696 
1697  if (!(cmb->state & State_Enabled))
1698  stateId = CBXS_DISABLED;
1699  else if (cmb->state & State_Sunken || cmb->state & State_On)
1700  stateId = CBXS_PRESSED;
1701  else if (cmb->state & State_MouseOver && option->activeSubControls & SC_ComboBoxArrow)
1702  stateId = CBXS_HOT;
1703  else
1704  stateId = CBXS_NORMAL;
1705 
1706  theme.partId = partId;
1707  theme.stateId = stateId;
1708  d->drawBackground(theme);
1709  }
1710 
1711  } else {
1712  if (sub & SC_ComboBoxFrame) {
1713  QStyleOptionButton btn;
1714  btn.QStyleOption::operator=(*option);
1715  btn.rect = option->rect.adjusted(-1, -1, 1, 1);
1716  if (sub & SC_ComboBoxArrow)
1718  proxy()->drawControl(QStyle::CE_PushButton, &btn, painter, widget);
1719  }
1720  }
1721  }
1722  break;
1723  case CC_ScrollBar:
1724  if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(option))
1725  {
1726  XPThemeData theme(widget, painter, QLatin1String("SCROLLBAR"));
1727 
1728  bool maxedOut = (scrollbar->maximum == scrollbar->minimum);
1729  if (maxedOut)
1730  flags &= ~State_Enabled;
1731 
1732  bool isHorz = flags & State_Horizontal;
1733  bool isRTL = option->direction == Qt::RightToLeft;
1734  if (sub & SC_ScrollBarAddLine) {
1735  theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarAddLine, widget);
1736  partId = SBP_ARROWBTN;
1737  if (!(flags & State_Enabled))
1738  stateId = (isHorz ? (isRTL ? ABS_LEFTDISABLED : ABS_RIGHTDISABLED) : ABS_DOWNDISABLED);
1739  else if (scrollbar->activeSubControls & SC_ScrollBarAddLine && (scrollbar->state & State_Sunken))
1740  stateId = (isHorz ? (isRTL ? ABS_LEFTPRESSED : ABS_RIGHTPRESSED) : ABS_DOWNPRESSED);
1741  else if (scrollbar->activeSubControls & SC_ScrollBarAddLine && (scrollbar->state & State_MouseOver))
1742  stateId = (isHorz ? (isRTL ? ABS_LEFTHOT : ABS_RIGHTHOT) : ABS_DOWNHOT);
1743  else if (scrollbar->state & State_MouseOver)
1744  stateId = (isHorz ? (isRTL ? ABS_LEFTHOVER : ABS_RIGHTHOVER) : ABS_DOWNHOVER);
1745  else
1746  stateId = (isHorz ? (isRTL ? ABS_LEFTNORMAL : ABS_RIGHTNORMAL) : ABS_DOWNNORMAL);
1747  theme.partId = partId;
1748  theme.stateId = stateId;
1749  d->drawBackground(theme);
1750  }
1751  if (sub & SC_ScrollBarSubLine) {
1752  theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSubLine, widget);
1753  partId = SBP_ARROWBTN;
1754  if (!(flags & State_Enabled))
1755  stateId = (isHorz ? (isRTL ? ABS_RIGHTDISABLED : ABS_LEFTDISABLED) : ABS_UPDISABLED);
1756  else if (scrollbar->activeSubControls & SC_ScrollBarSubLine && (scrollbar->state & State_Sunken))
1757  stateId = (isHorz ? (isRTL ? ABS_RIGHTPRESSED : ABS_LEFTPRESSED) : ABS_UPPRESSED);
1758  else if (scrollbar->activeSubControls & SC_ScrollBarSubLine && (scrollbar->state & State_MouseOver))
1759  stateId = (isHorz ? (isRTL ? ABS_RIGHTHOT : ABS_LEFTHOT) : ABS_UPHOT);
1760  else if (scrollbar->state & State_MouseOver)
1761  stateId = (isHorz ? (isRTL ? ABS_RIGHTHOVER : ABS_LEFTHOVER) : ABS_UPHOVER);
1762  else
1763  stateId = (isHorz ? (isRTL ? ABS_RIGHTNORMAL : ABS_LEFTNORMAL) : ABS_UPNORMAL);
1764  theme.partId = partId;
1765  theme.stateId = stateId;
1766  d->drawBackground(theme);
1767  }
1768  if (maxedOut) {
1769  theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);
1770  theme.rect = theme.rect.united(proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSubPage, widget));
1771  theme.rect = theme.rect.united(proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarAddPage, widget));
1772  partId = flags & State_Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT;
1773  stateId = SCRBS_DISABLED;
1774  theme.partId = partId;
1775  theme.stateId = stateId;
1776  d->drawBackground(theme);
1777  } else {
1778  if (sub & SC_ScrollBarSubPage) {
1779  theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSubPage, widget);
1780  partId = flags & State_Horizontal ? SBP_UPPERTRACKHORZ : SBP_UPPERTRACKVERT;
1781  if (!(flags & State_Enabled))
1782  stateId = SCRBS_DISABLED;
1783  else if (scrollbar->activeSubControls & SC_ScrollBarSubPage && (scrollbar->state & State_Sunken))
1784  stateId = SCRBS_PRESSED;
1785  else if (scrollbar->activeSubControls & SC_ScrollBarSubPage && (scrollbar->state & State_MouseOver))
1786  stateId = SCRBS_HOT;
1787  else
1788  stateId = SCRBS_NORMAL;
1789  theme.partId = partId;
1790  theme.stateId = stateId;
1791  d->drawBackground(theme);
1792  }
1793  if (sub & SC_ScrollBarAddPage) {
1794  theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarAddPage, widget);
1795  partId = flags & State_Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT;
1796  if (!(flags & State_Enabled))
1797  stateId = SCRBS_DISABLED;
1798  else if (scrollbar->activeSubControls & SC_ScrollBarAddPage && (scrollbar->state & State_Sunken))
1799  stateId = SCRBS_PRESSED;
1800  else if (scrollbar->activeSubControls & SC_ScrollBarAddPage && (scrollbar->state & State_MouseOver))
1801  stateId = SCRBS_HOT;
1802  else
1803  stateId = SCRBS_NORMAL;
1804  theme.partId = partId;
1805  theme.stateId = stateId;
1806  d->drawBackground(theme);
1807  }
1808  if (sub & SC_ScrollBarSlider) {
1809  theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);
1810  if (!(flags & State_Enabled))
1811  stateId = SCRBS_DISABLED;
1812  else if (scrollbar->activeSubControls & SC_ScrollBarSlider && (scrollbar->state & State_Sunken))
1813  stateId = SCRBS_PRESSED;
1814  else if (scrollbar->activeSubControls & SC_ScrollBarSlider && (scrollbar->state & State_MouseOver))
1815  stateId = SCRBS_HOT;
1816  else if (option->state & State_MouseOver)
1817  stateId = SCRBS_HOVER;
1818  else
1819  stateId = SCRBS_NORMAL;
1820 
1821  // Draw handle
1822  theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);
1823  theme.partId = flags & State_Horizontal ? SBP_THUMBBTNHORZ : SBP_THUMBBTNVERT;
1824  theme.stateId = stateId;
1825  d->drawBackground(theme);
1826 
1827  // Calculate rect of gripper
1828  const int swidth = theme.rect.width();
1829  const int sheight = theme.rect.height();
1830 
1831  MARGINS contentsMargin;
1832  RECT rect = theme.toRECT(theme.rect);
1833  pGetThemeMargins(theme.handle(), 0, theme.partId, theme.stateId, TMT_SIZINGMARGINS, &rect, &contentsMargin);
1834 
1835  SIZE size;
1836  theme.partId = flags & State_Horizontal ? SBP_GRIPPERHORZ : SBP_GRIPPERVERT;
1837  pGetThemePartSize(theme.handle(), 0, theme.partId, theme.stateId, 0, TS_TRUE, &size);
1838  int gw = size.cx, gh = size.cy;
1839 
1841  QRect gripperBounds;
1842  if (flags & State_Horizontal && ((swidth - contentsMargin.cxLeftWidth - contentsMargin.cxRightWidth) > gw)) {
1843  gripperBounds.setLeft(theme.rect.left() + swidth/2 - gw/2);
1844  gripperBounds.setTop(theme.rect.top() + sheight/2 - gh/2);
1845  gripperBounds.setWidth(gw);
1846  gripperBounds.setHeight(gh);
1847  } else if ((sheight - contentsMargin.cyTopHeight - contentsMargin.cyBottomHeight) > gh) {
1848  gripperBounds.setLeft(theme.rect.left() + swidth/2 - gw/2);
1849  gripperBounds.setTop(theme.rect.top() + sheight/2 - gh/2);
1850  gripperBounds.setWidth(gw);
1851  gripperBounds.setHeight(gh);
1852  }
1853 
1854  // Draw gripper if there is enough space
1855  if (!gripperBounds.isEmpty() && flags & State_Enabled) {
1856  painter->save();
1857  XPThemeData grippBackground = theme;
1858  grippBackground.partId = flags & State_Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT;
1859  theme.rect = gripperBounds;
1860  painter->setClipRegion(d->region(theme));// Only change inside the region of the gripper
1861  d->drawBackground(grippBackground);// The gutter is the grippers background
1862  d->drawBackground(theme); // Transparent gripper ontop of background
1863  painter->restore();
1864  }
1865  }
1866  }
1867  }
1868  }
1869  break;
1870 #ifndef QT_NO_SPINBOX
1871  case CC_SpinBox:
1872  if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(option))
1873  {
1874  XPThemeData theme(widget, painter, QLatin1String("SPIN"));
1875  if (sb->frame && (sub & SC_SpinBoxFrame)) {
1876  partId = EP_EDITBORDER_NOSCROLL;
1877  if (!(flags & State_Enabled))
1878  stateId = ETS_DISABLED;
1879  else if (flags & State_MouseOver)
1880  stateId = ETS_HOT;
1881  else if (flags & State_HasFocus)
1882  stateId = ETS_SELECTED;
1883  else
1884  stateId = ETS_NORMAL;
1885 
1886  XPThemeData ftheme(widget, painter, QLatin1String("EDIT"), partId, stateId, r);
1887  ftheme.noContent = true;
1888  d->drawBackground(ftheme);
1889  }
1890  if (sub & SC_SpinBoxUp) {
1891  theme.rect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget).adjusted(0, 0, 0, 1);
1892  partId = SPNP_UP;
1893  if (!(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled) || !(flags & State_Enabled))
1894  stateId = UPS_DISABLED;
1895  else if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_Sunken))
1896  stateId = UPS_PRESSED;
1897  else if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_MouseOver))
1898  stateId = UPS_HOT;
1899  else
1900  stateId = UPS_NORMAL;
1901  theme.partId = partId;
1902  theme.stateId = stateId;
1903  d->drawBackground(theme);
1904  }
1905  if (sub & SC_SpinBoxDown) {
1906  theme.rect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget);
1907  partId = SPNP_DOWN;
1908  if (!(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled) || !(flags & State_Enabled))
1909  stateId = DNS_DISABLED;
1910  else if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_Sunken))
1911  stateId = DNS_PRESSED;
1912  else if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_MouseOver))
1913  stateId = DNS_HOT;
1914  else
1915  stateId = DNS_NORMAL;
1916  theme.partId = partId;
1917  theme.stateId = stateId;
1918  d->drawBackground(theme);
1919  }
1920  }
1921  break;
1922 #endif // QT_NO_SPINBOX
1923  default:
1924  QWindowsXPStyle::drawComplexControl(control, option, painter, widget);
1925  break;
1926  }
1927 }
1928 
1933  const QSize &size, const QWidget *widget) const
1934 {
1936  return QWindowsStyle::sizeFromContents(type, option, size, widget);
1937 
1938  QSize sz(size);
1939  switch (type) {
1940  case CT_MenuItem:
1941  sz = QWindowsXPStyle::sizeFromContents(type, option, size, widget);
1942  int minimumHeight;
1943  {
1944  SIZE size;
1945  MARGINS margins;
1946  XPThemeData theme(widget, 0, QLatin1String("MENU"), MENU_POPUPCHECKBACKGROUND, MBI_HOT);
1947  pGetThemePartSize(theme.handle(), NULL, MENU_POPUPCHECK, 0, NULL,TS_TRUE, &size);
1948  pGetThemeMargins(theme.handle(), NULL, MENU_POPUPCHECK, 0, TMT_CONTENTMARGINS, NULL, &margins);
1949  minimumHeight = qMax<qint32>(size.cy + margins.cyBottomHeight+ margins.cyTopHeight, sz.height());
1950  sz.rwidth() += size.cx + margins.cxLeftWidth + margins.cxRightWidth;
1951  }
1952 
1953  if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
1954  if (menuitem->menuItemType != QStyleOptionMenuItem::Separator)
1955  sz.setHeight(minimumHeight);
1956  }
1957  return sz;
1958 #ifndef QT_NO_MENUBAR
1959  case CT_MenuBarItem:
1960  if (!sz.isEmpty())
1961  sz += QSize(windowsItemHMargin * 5 + 1, 5);
1962  return sz;
1963  break;
1964 #endif
1965  case CT_ItemViewItem:
1966  sz = QWindowsXPStyle::sizeFromContents(type, option, size, widget);
1967  sz.rheight() += 2;
1968  return sz;
1969  case CT_SpinBox:
1970  {
1971  //Spinbox adds frame twice
1972  sz = QWindowsStyle::sizeFromContents(type, option, size, widget);
1973  int border = proxy()->pixelMetric(PM_SpinBoxFrameWidth, option, widget);
1974  sz -= QSize(2*border, 2*border);
1975  }
1976  return sz;
1977  default:
1978  break;
1979  }
1980  return QWindowsXPStyle::sizeFromContents(type, option, size, widget);
1981 }
1982 
1987 {
1989  return QWindowsStyle::subElementRect(element, option, widget);
1990 
1991  QRect rect = QWindowsXPStyle::subElementRect(element, option, widget);
1992  switch (element) {
1993 
1994  case SE_PushButtonContents:
1995  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
1996  MARGINS borderSize;
1997  HTHEME theme = pOpenThemeData(widget ? QWindowsVistaStylePrivate::winId(widget) : 0, L"Button");
1998  if (theme) {
1999  int stateId = PBS_NORMAL;
2000  if (!(option->state & State_Enabled))
2001  stateId = PBS_DISABLED;
2002  else if (option->state & State_Sunken)
2003  stateId = PBS_PRESSED;
2004  else if (option->state & State_MouseOver)
2005  stateId = PBS_HOT;
2006  else if (btn->features & QStyleOptionButton::DefaultButton)
2007  stateId = PBS_DEFAULTED;
2008 
2009  int border = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget);
2010  rect = option->rect.adjusted(border, border, -border, -border);
2011 
2012  int result = pGetThemeMargins(theme,
2013  NULL,
2014  BP_PUSHBUTTON,
2015  stateId,
2017  NULL,
2018  &borderSize);
2019 
2020  if (result == S_OK) {
2021  rect.adjust(borderSize.cxLeftWidth, borderSize.cyTopHeight,
2022  -borderSize.cxRightWidth, -borderSize.cyBottomHeight);
2023  rect = visualRect(option->direction, option->rect, rect);
2024  }
2025  }
2026  }
2027  break;
2028 
2029  case SE_HeaderArrow:
2030  {
2031  QRect r = rect;
2032  int h = option->rect.height();
2033  int w = option->rect.width();
2034  int x = option->rect.x();
2035  int y = option->rect.y();
2036  int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, option, widget);
2037 
2038  XPThemeData theme(widget, 0, QLatin1String("HEADER"), HP_HEADERSORTARROW, HSAS_SORTEDDOWN, option->rect);
2039 
2040  int arrowWidth = 13;
2041  int arrowHeight = 5;
2042  if (theme.isValid()) {
2043  SIZE size;
2044  if (pGetThemePartSize(theme.handle(), 0, theme.partId, theme.stateId, 0, TS_TRUE, &size) == S_OK) {
2045  arrowWidth = size.cx;
2046  arrowHeight = size.cy;
2047  }
2048  }
2049  if (option->state & State_Horizontal) {
2050  r.setRect(x + w/2 - arrowWidth/2, y , arrowWidth, arrowHeight);
2051  } else {
2052  int vert_size = w / 2;
2053  r.setRect(x + 5, y + h - margin * 2 - vert_size,
2054  w - margin * 2 - 5, vert_size);
2055  }
2056  rect = visualRect(option->direction, option->rect, r);
2057  }
2058  break;
2059 
2060  case SE_HeaderLabel:
2061  {
2062  int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, option, widget);
2063  QRect r = option->rect;
2064  r.setRect(option->rect.x() + margin, option->rect.y() + margin,
2065  option->rect.width() - margin * 2, option->rect.height() - margin * 2);
2066  if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
2067  // Subtract width needed for arrow, if there is one
2068  if (header->sortIndicator != QStyleOptionHeader::None) {
2069  if (!(option->state & State_Horizontal)) //horizontal arrows are positioned on top
2070  r.setHeight(r.height() - (option->rect.width() / 2) - (margin * 2));
2071  }
2072  }
2073  rect = visualRect(option->direction, option->rect, r);
2074  }
2075  break;
2077  rect = QCommonStyle::subElementRect(SE_ProgressBarGroove, option, widget);
2078  break;
2080  if (qstyleoption_cast<const QStyleOptionViewItemV4 *>(option))
2081  rect.adjust(-2, 0, 2, 0);
2082  break;
2084  if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) {
2085  QRect textRect = subElementRect(QStyle::SE_ItemViewItemText, option, widget);
2086  QRect displayRect = subElementRect(QStyle::SE_ItemViewItemDecoration, option, widget);
2087  if (!vopt->icon.isNull())
2088  rect = textRect.united(displayRect);
2089  else
2090  rect = textRect;
2091  rect = rect.adjusted(1, 0, -1, 0);
2092  }
2093  break;
2094  default:
2095  break;
2096  }
2097  return rect;
2098 }
2099 
2100 
2101 /*
2102  This function is used by subControlRect to check if a button
2103  should be drawn for the given subControl given a set of window flags.
2104 */
2105 static bool buttonVisible(const QStyle::SubControl sc, const QStyleOptionTitleBar *tb){
2106 
2107  bool isMinimized = tb->titleBarState & Qt::WindowMinimized;
2108  bool isMaximized = tb->titleBarState & Qt::WindowMaximized;
2109  const uint flags = tb->titleBarFlags;
2110  bool retVal = false;
2111  switch (sc) {
2113  if (flags & Qt::WindowContextHelpButtonHint)
2114  retVal = true;
2115  break;
2117  if (!isMinimized && (flags & Qt::WindowMinimizeButtonHint))
2118  retVal = true;
2119  break;
2121  if (isMinimized && (flags & Qt::WindowMinimizeButtonHint))
2122  retVal = true;
2123  else if (isMaximized && (flags & Qt::WindowMaximizeButtonHint))
2124  retVal = true;
2125  break;
2127  if (!isMaximized && (flags & Qt::WindowMaximizeButtonHint))
2128  retVal = true;
2129  break;
2131  if (!isMinimized && flags & Qt::WindowShadeButtonHint)
2132  retVal = true;
2133  break;
2135  if (isMinimized && flags & Qt::WindowShadeButtonHint)
2136  retVal = true;
2137  break;
2139  if (flags & Qt::WindowSystemMenuHint)
2140  retVal = true;
2141  break;
2143  if (flags & Qt::WindowSystemMenuHint)
2144  retVal = true;
2145  break;
2146  default :
2147  retVal = true;
2148  }
2149  return retVal;
2150 }
2151 
2152 
2155  QStyleHintReturn *returnData) const
2156 {
2157  QWindowsVistaStylePrivate *d = const_cast<QWindowsVistaStylePrivate*>(d_func());
2158  int ret = 0;
2159  switch (hint) {
2161  ret = false;
2162  break;
2163  case SH_ToolTip_Mask:
2164  if (option) {
2165  if (QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(returnData)) {
2166  ret = true;
2167  XPThemeData themeData(widget, 0, QLatin1String("TOOLTIP"), TTP_STANDARD, TTSS_NORMAL, option->rect);
2168  mask->region = d->region(themeData);
2169  }
2170  }
2171  break;
2173  if (option)
2174  ret = option->palette.color(QPalette::Base).darker(118).rgb();
2175  else
2176  ret = -1;
2177  break;
2178  default:
2179  ret = QWindowsXPStyle::styleHint(hint, option, widget, returnData);
2180  break;
2181  }
2182  return ret;
2183 }
2184 
2185 
2190  SubControl subControl, const QWidget *widget) const
2191 {
2193  return QWindowsStyle::subControlRect(control, option, subControl, widget);
2194 
2195  QRect rect = QWindowsXPStyle::subControlRect(control, option, subControl, widget);
2196  switch (control) {
2197 #ifndef QT_NO_COMBOBOX
2198  case CC_ComboBox:
2199  if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
2200  int x = cb->rect.x(),
2201  y = cb->rect.y(),
2202  wi = cb->rect.width(),
2203  he = cb->rect.height();
2204  int xpos = x;
2205  int margin = cb->frame ? 3 : 0;
2206  int bmarg = cb->frame ? 2 : 0;
2207  int arrowButtonWidth = bmarg + 16;
2208  xpos += wi - arrowButtonWidth;
2209 
2210  switch (subControl) {
2211  case SC_ComboBoxFrame:
2212  rect = cb->rect;
2213  break;
2214  case SC_ComboBoxArrow:
2215  rect.setRect(xpos, y , arrowButtonWidth, he);
2216  break;
2217  case SC_ComboBoxEditField:
2218  rect.setRect(x + margin, y + margin, wi - 2 * margin - 16, he - 2 * margin);
2219  break;
2221  rect = cb->rect;
2222  break;
2223  default:
2224  break;
2225  }
2226  rect = visualRect(cb->direction, cb->rect, rect);
2227  return rect;
2228  }
2229 #endif // QT_NO_COMBOBOX
2230  case CC_TitleBar:
2231  if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(option)) {
2232  if (!buttonVisible(subControl, tb))
2233  return rect;
2234  const bool isToolTitle = false;
2235  const int height = tb->rect.height();
2236  const int width = tb->rect.width();
2237  int buttonWidth = GetSystemMetrics(SM_CXSIZE) - 4;
2238 
2239  const int frameWidth = proxy()->pixelMetric(PM_MdiSubWindowFrameWidth, option, widget);
2240  const bool sysmenuHint = (tb->titleBarFlags & Qt::WindowSystemMenuHint) != 0;
2241  const bool minimizeHint = (tb->titleBarFlags & Qt::WindowMinimizeButtonHint) != 0;
2242  const bool maximizeHint = (tb->titleBarFlags & Qt::WindowMaximizeButtonHint) != 0;
2243  const bool contextHint = (tb->titleBarFlags & Qt::WindowContextHelpButtonHint) != 0;
2244  const bool shadeHint = (tb->titleBarFlags & Qt::WindowShadeButtonHint) != 0;
2245 
2246  switch (subControl) {
2247  case SC_TitleBarLabel:
2248  rect = QRect(frameWidth, 0, width - (buttonWidth + frameWidth + 10), height);
2249  if (isToolTitle) {
2250  if (sysmenuHint) {
2251  rect.adjust(0, 0, -buttonWidth - 3, 0);
2252  }
2253  if (minimizeHint || maximizeHint)
2254  rect.adjust(0, 0, -buttonWidth - 2, 0);
2255  } else {
2256  if (sysmenuHint) {
2257  const int leftOffset = height - 8;
2258  rect.adjust(leftOffset, 0, 0, 4);
2259  }
2260  if (minimizeHint)
2261  rect.adjust(0, 0, -buttonWidth - 2, 0);
2262  if (maximizeHint)
2263  rect.adjust(0, 0, -buttonWidth - 2, 0);
2264  if (contextHint)
2265  rect.adjust(0, 0, -buttonWidth - 2, 0);
2266  if (shadeHint)
2267  rect.adjust(0, 0, -buttonWidth - 2, 0);
2268  }
2269  rect.translate(0, 2);
2270  rect = visualRect(option->direction, option->rect, rect);
2271  break;
2272  case SC_TitleBarSysMenu:
2273  {
2274  const int controlTop = 6;
2275  const int controlHeight = height - controlTop - 3;
2276  int iconExtent = proxy()->pixelMetric(PM_SmallIconSize);
2277  QSize iconSize = tb->icon.actualSize(QSize(iconExtent, iconExtent));
2278  if (tb->icon.isNull())
2279  iconSize = QSize(controlHeight, controlHeight);
2280  int hPad = (controlHeight - iconSize.height())/2;
2281  int vPad = (controlHeight - iconSize.width())/2;
2282  rect = QRect(frameWidth + hPad, controlTop + vPad, iconSize.width(), iconSize.height());
2283  rect.translate(0, 3);
2284  rect = visualRect(option->direction, option->rect, rect);
2285  }
2286  break;
2287  default:
2288  break;
2289  }
2290  }
2291  break;
2292  default:
2293  break;
2294  }
2295  return rect;
2296 }
2297 
2302 {
2304  switch (e->type()) {
2305  case QEvent::Timer:
2306  {
2308  if (d->animationTimer.timerId() == timerEvent->timerId()) {
2309  d->timerEvent();
2310  e->accept();
2311  return true;
2312  }
2313  }
2314  break;
2315  default:
2316  break;
2317  }
2318  return QWindowsXPStyle::event(e);
2319 }
2320 
2325  const QPoint &pos, const QWidget *widget) const
2326 {
2328  return QWindowsStyle::hitTestComplexControl(control, option, pos, widget);
2329  }
2330  return QWindowsXPStyle::hitTestComplexControl(control, option, pos, widget);
2331 }
2332 
2337 {
2339  return QWindowsStyle::pixelMetric(metric, option, widget);
2340  }
2341  switch (metric) {
2342 
2344  return int(QStyleHelper::dpiScaled(5.));
2345  case PM_ScrollBarSliderMin:
2346  return int(QStyleHelper::dpiScaled(18.));
2347  case PM_MenuHMargin:
2348  case PM_MenuVMargin:
2349  return 0;
2350  case PM_MenuPanelWidth:
2351  return 3;
2352  default:
2353  break;
2354  }
2355  return QWindowsXPStyle::pixelMetric(metric, option, widget);
2356 }
2357 
2362 {
2364 }
2365 
2370 {
2372 }
2373 
2378 {
2379  QWindowsXPStyle::polish(widget);
2380 #ifndef QT_NO_LINEEDIT
2381  if (qobject_cast<QLineEdit*>(widget))
2382  widget->setAttribute(Qt::WA_Hover);
2383  else
2384 #endif // QT_NO_LINEEDIT
2385  if (qobject_cast<QGroupBox*>(widget))
2386  widget->setAttribute(Qt::WA_Hover);
2387  else if (qobject_cast<QCommandLinkButton*>(widget)) {
2388  QFont buttonFont = widget->font();
2389  buttonFont.setFamily(QLatin1String("Segoe UI"));
2390  widget->setFont(buttonFont);
2391  }
2392  else if (widget->inherits("QTipLabel")){
2393  //note that since tooltips are not reused
2394  //we do not have to care about unpolishing
2395  widget->setContentsMargins(3, 0, 4, 0);
2396  COLORREF bgRef;
2397  HTHEME theme = pOpenThemeData(widget ? QWindowsVistaStylePrivate::winId(widget) : 0, L"TOOLTIP");
2398  if (theme) {
2399  if (pGetThemeColor(theme, TTP_STANDARD, TTSS_NORMAL, TMT_TEXTCOLOR, &bgRef) == S_OK) {
2400  QColor textColor = QColor::fromRgb(bgRef);
2401  QPalette pal;
2402  pal.setColor(QPalette::All, QPalette::ToolTipText, textColor);
2403  widget->setPalette(pal);
2404  }
2405  }
2406  } else if (qobject_cast<QMessageBox *> (widget)) {
2408  QDialogButtonBox *buttonBox = widget->findChild<QDialogButtonBox *>(QLatin1String("qt_msgbox_buttonbox"));
2409  if (buttonBox)
2410  buttonBox->setContentsMargins(0, 9, 0, 0);
2411  }
2412 #ifndef QT_NO_INPUTDIALOG
2413  else if (qobject_cast<QInputDialog *> (widget)) {
2415  QDialogButtonBox *buttonBox = widget->findChild<QDialogButtonBox *>(QLatin1String("qt_inputdlg_buttonbox"));
2416  if (buttonBox)
2417  buttonBox->setContentsMargins(0, 9, 0, 0);
2418  }
2419 #endif // QT_NO_INPUTDIALOG
2420  else if (QTreeView *tree = qobject_cast<QTreeView *> (widget)) {
2421  tree->viewport()->setAttribute(Qt::WA_Hover);
2422  }
2423  else if (QListView *list = qobject_cast<QListView *> (widget)) {
2424  list->viewport()->setAttribute(Qt::WA_Hover);
2425  }
2426 }
2427 
2432 {
2433  QWindowsXPStyle::unpolish(widget);
2434 
2435  QWindowsVistaStylePrivate *d = const_cast<QWindowsVistaStylePrivate*>(d_func());
2436  d->stopAnimation(widget);
2437 
2438 #ifndef QT_NO_LINEEDIT
2439  if (qobject_cast<QLineEdit*>(widget))
2440  widget->setAttribute(Qt::WA_Hover, false);
2441  else
2442 #endif // QT_NO_LINEEDIT
2443  if (qobject_cast<QGroupBox*>(widget))
2444  widget->setAttribute(Qt::WA_Hover, false);
2445  else if (qobject_cast<QMessageBox *> (widget)) {
2446  widget->setAttribute(Qt::WA_StyledBackground, false);
2447  QDialogButtonBox *buttonBox = widget->findChild<QDialogButtonBox *>(QLatin1String("qt_msgbox_buttonbox"));
2448  if (buttonBox)
2449  buttonBox->setContentsMargins(0, 0, 0, 0);
2450  }
2451 #ifndef QT_NO_INPUTDIALOG
2452  else if (qobject_cast<QInputDialog *> (widget)) {
2453  widget->setAttribute(Qt::WA_StyledBackground, false);
2454  QDialogButtonBox *buttonBox = widget->findChild<QDialogButtonBox *>(QLatin1String("qt_inputdlg_buttonbox"));
2455  if (buttonBox)
2456  buttonBox->setContentsMargins(0, 0, 0, 0);
2457  }
2458 #endif // QT_NO_INPUTDIALOG
2459  else if (QTreeView *tree = qobject_cast<QTreeView *> (widget)) {
2460  tree->viewport()->setAttribute(Qt::WA_Hover, false);
2461  } else if (qobject_cast<QCommandLinkButton*>(widget)) {
2462  QFont font = QApplication::font("QCommandLinkButton");
2463  QFont widgetFont = widget->font();
2464  widgetFont.setFamily(font.family()); //Only family set by polish
2465  widget->setFont(widgetFont);
2466  }
2467 }
2468 
2469 
2474 {
2476 }
2477 
2482 {
2483  QWindowsStyle::polish(pal);
2484  pal.setBrush(QPalette::AlternateBase, pal.base().color().darker(104));
2485 }
2486 
2491  const QWidget *widget) const
2492 {
2494  return QWindowsStyle::standardPixmap(standardPixmap, option, widget);
2495  }
2496  return QWindowsXPStyle::standardPixmap(standardPixmap, option, widget);
2497 }
2498 
2500  QWindowsXPStylePrivate(), m_treeViewHelper(0)
2501 {
2502  resolveSymbols();
2503 }
2504 
2506 {
2508  delete m_treeViewHelper;
2509 }
2510 
2512 {
2513  for (int i = animations.size() - 1 ; i >= 0 ; --i) {
2514 
2515  if (animations[i]->widget())
2516  animations[i]->widget()->update();
2517 
2518  if (!animations[i]->widget() ||
2519  !animations[i]->widget()->isVisible() ||
2520  animations[i]->widget()->window()->isMinimized() ||
2521  !animations[i]->running() ||
2523  {
2525  delete a;
2526  }
2527  }
2528  if (animations.size() == 0 && animationTimer.isActive()) {
2529  animationTimer.stop();
2530  }
2531 }
2532 
2534 {
2535  for (int i = animations.size() - 1 ; i >= 0 ; --i) {
2536  if (animations[i]->widget() == w) {
2538  delete a;
2539  break;
2540  }
2541  }
2542 }
2543 
2545 {
2547  stopAnimation(t->widget());
2548  animations.append(t);
2549  if (animations.size() > 0 && !animationTimer.isActive()) {
2550  animationTimer.start(45, q);
2551  }
2552 }
2553 
2555 {
2556  BOOL animEnabled = false;
2557  if (SystemParametersInfo(SPI_GETCLIENTAREAANIMATION, 0, &animEnabled, 0))
2558  {
2559  if (animEnabled)
2560  return true;
2561  }
2562  return false;
2563 }
2564 
2565 
2567 {
2568  if (!widget)
2569  return 0;
2570  foreach (QWindowsVistaAnimation *a, animations) {
2571  if (a->widget() == widget)
2572  return a;
2573  }
2574  return 0;
2575 }
2576 
2577 
2586 {
2587  static bool tried = false;
2588  if (!tried) {
2589  QSystemLibrary themeLib(QLatin1String("uxtheme"));
2590  pSetWindowTheme = (PtrSetWindowTheme )themeLib.resolve("SetWindowTheme");
2591  pIsThemePartDefined = (PtrIsThemePartDefined )themeLib.resolve("IsThemePartDefined");
2592  pGetThemePartSize = (PtrGetThemePartSize )themeLib.resolve("GetThemePartSize");
2593  pOpenThemeData = (PtrOpenThemeData )themeLib.resolve("OpenThemeData");
2594  pCloseThemeData = (PtrCloseThemeData )themeLib.resolve("CloseThemeData");
2595  pDrawThemeBackground = (PtrDrawThemeBackground )themeLib.resolve("DrawThemeBackground");
2596  pDrawThemeBackgroundEx = (PtrDrawThemeBackgroundEx )themeLib.resolve("DrawThemeBackgroundEx");
2597  pGetCurrentThemeName = (PtrGetCurrentThemeName )themeLib.resolve("GetCurrentThemeName");
2598  pGetThemeBool = (PtrGetThemeBool )themeLib.resolve("GetThemeBool");
2599  pGetThemeColor = (PtrGetThemeColor )themeLib.resolve("GetThemeColor");
2600  pGetThemeEnumValue = (PtrGetThemeEnumValue )themeLib.resolve("GetThemeEnumValue");
2601  pGetThemeFilename = (PtrGetThemeFilename )themeLib.resolve("GetThemeFilename");
2602  pGetThemeFont = (PtrGetThemeFont )themeLib.resolve("GetThemeFont");
2603  pGetThemeInt = (PtrGetThemeInt )themeLib.resolve("GetThemeInt");
2604  pGetThemeIntList = (PtrGetThemeIntList )themeLib.resolve("GetThemeIntList");
2605  pGetThemeMargins = (PtrGetThemeMargins )themeLib.resolve("GetThemeMargins");
2606  pGetThemeMetric = (PtrGetThemeMetric )themeLib.resolve("GetThemeMetric");
2607  pGetThemePartSize = (PtrGetThemePartSize )themeLib.resolve("GetThemePartSize");
2608  pGetThemePosition = (PtrGetThemePosition )themeLib.resolve("GetThemePosition");
2609  pGetThemeRect = (PtrGetThemeRect )themeLib.resolve("GetThemeRect");
2610  pGetThemeString = (PtrGetThemeString )themeLib.resolve("GetThemeString");
2611  pGetThemeTransitionDuration = (PtrGetThemeTransitionDuration)themeLib.resolve("GetThemeTransitionDuration");
2612  pGetThemePropertyOrigin = (PtrGetThemePropertyOrigin)themeLib.resolve("GetThemePropertyOrigin");
2613  tried = true;
2614  }
2615  return pGetThemeTransitionDuration != 0;
2616 }
2617 
2618 /*
2619  * We need to set the windows explorer theme explicitly on a native widget
2620  * in order to get Vista-style item view themes
2621  */
2623 {
2624  if (!m_treeViewHelper) {
2625  m_treeViewHelper = new QWidget(0);
2626  pSetWindowTheme(m_treeViewHelper->winId(), L"explorer", NULL);
2627  }
2628  return m_treeViewHelper;
2629 }
2630 
2631 
2636  const QStyleOption *option,
2637  const QWidget *widget) const
2638 {
2640  return QWindowsStyle::standardIconImplementation(standardIcon, option, widget);
2641  }
2642 
2643  QWindowsVistaStylePrivate *d = const_cast<QWindowsVistaStylePrivate *>(d_func());
2644  switch(standardIcon) {
2645  case SP_CommandLink:
2646  {
2648  if (theme.isValid()) {
2649  SIZE size;
2650  pGetThemePartSize(theme.handle(), 0, theme.partId, theme.stateId, 0, TS_TRUE, &size);
2651  QIcon linkGlyph;
2652  QPixmap pm = QPixmap(size.cx, size.cy);
2653  pm.fill(Qt::transparent);
2654  QPainter p(&pm);
2655  theme.painter = &p;
2656  theme.rect = QRect(0, 0, size.cx, size.cy);
2657  d->drawBackground(theme);
2658  linkGlyph.addPixmap(pm, QIcon::Normal, QIcon::Off); // Normal
2659  pm.fill(Qt::transparent);
2660 
2661  theme.stateId = CMDLGS_PRESSED;
2662  d->drawBackground(theme);
2663  linkGlyph.addPixmap(pm, QIcon::Normal, QIcon::On); // Pressed
2664  pm.fill(Qt::transparent);
2665 
2666  theme.stateId = CMDLGS_HOT;
2667  d->drawBackground(theme);
2668  linkGlyph.addPixmap(pm, QIcon::Active, QIcon::Off); // Hover
2669  pm.fill(Qt::transparent);
2670 
2671  theme.stateId = CMDLGS_DISABLED;
2672  d->drawBackground(theme);
2673  linkGlyph.addPixmap(pm, QIcon::Disabled, QIcon::Off); // Disabled
2674  return linkGlyph;
2675  }
2676  }
2677  break;
2678  default:
2679  break;
2680  }
2681  return QWindowsXPStyle::standardIconImplementation(standardIcon, option, widget);
2682 }
2683 
2685 
2686 #endif //QT_NO_WINDOWSVISTA
void setDuration(int duration)
QPixmap standardPixmap(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget=0) const
Reimplemented Function
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget=0) const
The QWindowsVistaStyle class provides a look and feel suitable for applications on Microsoft Windows ...
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
void polish(QApplication *)
Reimplemented Function
virtual void paint(QPainter *painter, const QStyleOption *option)
#define MBI_PUSHED
#define MC_CHECKMARKDISABLED
QPainter * painter
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
void unpolish(QWidget *widget)
#define LISS_HOTSELECTED
The QApplication class manages the GUI application&#39;s control flow and main settings.
Definition: qapplication.h:99
void setFont(const QFont &)
Use the single-argument overload instead.
Definition: qwidget.cpp:4996
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
Definition: qpixmap.cpp:2197
int styleHint(StyleHint hint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const
#define CMDLGS_HOT
QRect subElementRect(SubElement r, const QStyleOption *option, const QWidget *widget=0) const
Reimplemented Function
QRect adjusted(int x1, int y1, int x2, int y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition: qrect.h:431
void setHeight(int h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:445
const QBrush & base() const
Returns the base brush of the current color group.
Definition: qpalette.h:130
int type
Definition: qmetatype.cpp:239
SubControl
This enum describes the available sub controls.
Definition: qstyle.h:402
StyleHint
This enum describes the available style hints.
Definition: qstyle.h:640
virtual void paint(QPainter *painter, const QStyleOption *option)
Paints a pulse.
#define disabled
The QStyleHintReturn class provides style hints that return more than basic data types.
Definition: qstyleoption.h:907
void setBottom(int pos)
Sets the bottom edge of the rectangle to the given y coordinate.
Definition: qrect.h:267
void setColorAt(qreal pos, const QColor &color)
Creates a stop point at the given position with the given color.
Definition: qbrush.cpp:1475
void setWidget(QWidget *widget)
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
The QStyleOptionDockWidget class is used to describe the parameters for drawing a dock widget...
Definition: qstyleoption.h:504
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
static PtrGetThemeBool pGetThemeBool
int width() const
Returns the width of the pixmap.
Definition: qpixmap.cpp:630
QPointer< QWidget > widget
QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
#define TMT_TEXTCOLOR
ColorRole
The ColorRole enum defines the different symbolic color roles used in current GUIs.
Definition: qpalette.h:93
static PtrGetThemeTransitionDuration pGetThemeTransitionDuration
static QPoint visualPos(Qt::LayoutDirection direction, const QRect &boundingRect, const QPoint &logicalPos)
Returns the given logicalPosition converted to screen coordinates based on the specified direction...
Definition: qstyle.cpp:2109
static PtrGetThemeFilename pGetThemeFilename
const QBrush & dark() const
Returns the dark brush of the current color group.
Definition: qpalette.h:127
HRESULT(WINAPI * PtrDrawThemeBackground)(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, OPTIONAL const RECT *pClipRect)
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
bool isActiveWindow
whether this widget&#39;s window is the active window
Definition: qwidget.h:186
QPoint mapTo(QWidget *, const QPoint &) const
Translates the widget coordinate pos to the coordinate system of parent.
Definition: qwidget.cpp:4409
#define BP_COMMANDLINKGLYPH
HRESULT(WINAPI * PtrGetThemeColor)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT COLORREF *pColor)
QIcon icon
The icon (if any) to be drawn in the view item.
Definition: qstyleoption.h:617
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
HRESULT(WINAPI * PtrCloseThemeData)(HTHEME hTheme)
The QStyleOptionMenuItem class is used to describe the parameter necessary for drawing a menu item...
Definition: qstyleoption.h:435
The QStyleOptionHeader class is used to describe the parameters for drawing a header.
Definition: qstyleoption.h:251
static PtrGetThemeRect pGetThemeRect
int descent() const
Returns the descent of the font.
Q_GUI_EXPORT_INLINE int qAlpha(QRgb rgb)
Definition: qrgb.h:66
HRESULT(WINAPI * PtrSetWindowTheme)(HWND hwnd, LPCWSTR pszSubAppName, LPCWSTR pszSubIdList)
WId effectiveWinId() const
Returns the effective window system identifier of the widget, i.
Definition: qwidget.cpp:2654
static const int windowsItemVMargin
#define PP_TRANSPARENTBAR
virtual QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget=0) const =0
Returns the rectangle containing the specified subControl of the given complex control (with the styl...
void rotate(qreal a)
Rotates the coordinate system the given angle clockwise.
Definition: qpainter.cpp:3287
const QBrush & background() const
Use window() instead.
Definition: qpalette.h:134
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
int msecsTo(const QTime &) const
Returns the number of milliseconds from this time to t.
Definition: qdatetime.cpp:1832
static PtrGetThemeInt pGetThemeInt
ComplexControl
This enum describes the available complex controls.
Definition: qstyle.h:386
HTHEME(WINAPI * PtrOpenThemeData)(HWND hwnd, LPCWSTR pszClassList)
void fill(uint pixel)
Fills the entire image with the given pixelValue.
Definition: qimage.cpp:2032
QRect united(const QRect &other) const
Returns the bounding rectangle of this rectangle and the given rectangle.
Definition: qrect.h:491
static C reverse(const C &l)
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip region to the given rectangle using the given clip operation...
Definition: qpainter.cpp:2801
QBrush backgroundBrush
The QBrush that should be used to paint the view items background.
Definition: qstyleoption.h:620
#define TVP_HOTGLYPH
QFont font
the font currently set for the widget
Definition: qwidget.h:181
void drawBlendedImage(QPainter *painter, QRect rect, float value)
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
#define LISS_SELECTEDNOTFOCUS
#define CP_DROPDOWNBUTTONLEFT
HRESULT(WINAPI * PtrDrawThemeBackgroundEx)(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, OPTIONAL const DTBGOPTS *pOptions)
The QStyleOptionTitleBar class is used to describe the parameters for drawing a title bar...
Definition: qstyleoption.h:816
static PtrOpenThemeData pOpenThemeData
void restore()
Restores the current painter state (pops a saved state off the stack).
Definition: qpainter.cpp:1620
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QStyleOptionViewItemV4 class is used to describe the parameters necessary for drawing a frame in ...
Definition: qstyleoption.h:609
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object&#39;s name property to value.
Definition: qobject.cpp:3755
PixelMetric
This enum describes the various available pixel metrics.
Definition: qstyle.h:474
virtual void paint(QPainter *painter, const QStyleOption *option)
Paints a transition state.
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
#define SPI_GETCLIENTAREAANIMATION
bool isActive() const
Returns true if the timer is running and has not been stopped; otherwise returns false.
Definition: qbasictimer.h:62
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
The QStyleOptionToolBar class is used to describe the parameters for drawing a toolbar.
Definition: qstyleoption.h:369
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget=0) const
#define MB_INACTIVE
static PtrDrawThemeBackground pDrawThemeBackground
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool toBool() const
Returns the variant as a bool if the variant has type() Bool.
Definition: qvariant.cpp:2691
virtual void drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole=QPalette::NoRole) const
Draws the given text in the specified rectangle using the provided painter and palette.
Definition: qstyle.cpp:532
long ASN1_INTEGER_get ASN1_INTEGER * a
void drawBackground(XPThemeData &themeData)
Main theme drawing function.
QStyle::SubControls activeSubControls
This variable holds a bitwise OR of the sub-controls that are active for the complex control...
Definition: qstyleoption.h:694
void drawLine(const QLineF &line)
Draws a line defined by line.
Definition: qpainter.h:573
The QProgressBar widget provides a horizontal or vertical progress bar.
Definition: qprogressbar.h:58
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
static const WinVersion WindowsVersion
the version of the Windows operating system on which the application is run (Windows only) ...
Definition: qglobal.h:1613
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
The QString class provides a Unicode character string.
Definition: qstring.h:83
QRect rect() const
Returns the enclosing rectangle (0, 0, width(), height()) of the image.
Definition: qimage.cpp:1603
void setHeight(int h)
Sets the height to the given height.
Definition: qsize.h:135
#define BT_IMAGEFILE
T * qobject_cast(QObject *object)
Definition: qobject.h:375
#define MENU_POPUPSEPARATOR
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *option, SubControl sc, const QWidget *widget=0) const
Reimplemented Function
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
#define Q_D(Class)
Definition: qglobal.h:2482
#define PP_MOVEOVERLAY
#define CMDLGS_PRESSED
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition: qpalette.h:107
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
void setBrushOrigin(int x, int y)
Sets the brush&#39;s origin to point (x, y).
Definition: qpainter.h:825
static PtrIsThemePartDefined pIsThemePartDefined
void stopAnimation(const QWidget *)
#define SIZE(large, small, mini)
#define MENU_BARBACKGROUND
QIcon windowIcon
the widget&#39;s icon
Definition: qwidget.h:199
NSToolbar * toolbar
static PtrGetCurrentThemeName pGetCurrentThemeName
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
SelectionMode selectionMode
which selection mode the view operates in
QString elidedText(const QString &text, Qt::TextElideMode mode, int width, int flags=0) const
If the string text is wider than width, returns an elided version of the string (i.
#define EP_EDITBORDER_HVSCROLL
StandardPixmap
This enum describes the available standard pixmaps.
Definition: qstyle.h:755
static QPixmap * find(const QString &key)
Q_GUI_EXPORT_INLINE int qRed(QRgb rgb)
Definition: qrgb.h:57
#define Q_Q(Class)
Definition: qglobal.h:2483
static QFont font()
Returns the default application font.
ColorGroup
Definition: qpalette.h:92
#define LISS_HOT
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
#define SCRBS_HOVER
void setFamily(const QString &)
Sets the family name of the font.
Definition: qfont.cpp:924
void setWidth(int w)
Sets the width to the given width.
Definition: qsize.h:132
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
HRESULT(WINAPI * PtrGetThemeBool)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT BOOL *pfVal)
HRESULT(WINAPI * PtrGetThemeFilename)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT LPWSTR pszThemeFileName, int cchMaxBuffChars)
#define PBS_DEFAULTED_ANIMATING
QColor darker(int f=200) const
Returns a darker (or lighter) color, but does not change this object.
Definition: qcolor.h:301
unsigned char uchar
Definition: qglobal.h:994
The QStyleOptionProgressBarV2 class is used to describe the parameters necessary for drawing a progre...
Definition: qstyleoption.h:417
NSWindow * window
int width() const
Returns the width.
Definition: qsize.h:126
static QIcon windowIcon()
void drawText(const QPointF &p, const QString &s)
Draws the given text with the currently defined text direction, beginning at the given position...
Definition: qpainter.cpp:6231
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option=0, const QWidget *widget=0) const
Returns an icon for the given standardIcon.
Definition: qstyle.cpp:2327
The QTime class provides clock time functions.
Definition: qdatetime.h:148
The QRadioButton widget provides a radio button with a text label.
Definition: qradiobutton.h:56
const QPen & pen() const
Returns the painter&#39;s current pen.
Definition: qpainter.cpp:4152
#define TMT_BGTYPE
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QWidget * nativeParentWidget() const
Returns the native parent for this widget, i.
Definition: qwidget.cpp:4514
QFontMetrics fontMetrics() const
Returns the font metrics for the painter if the painter is active.
Definition: qpainter.cpp:2077
void setBrush(ColorRole cr, const QBrush &brush)
Sets the brush for the given color role to the specified brush for all groups in the palette...
Definition: qpalette.h:206
Q_GUI_EXPORT_INLINE QRgb qRgba(int r, int g, int b, int a)
Definition: qrgb.h:72
void setBold(bool)
If enable is true sets the font&#39;s weight to QFont::Bold ; otherwise sets the weight to QFont::Normal...
Definition: qfont.h:352
ViewItemFeatures features
a bitwise OR of the features that describe this view item
Definition: qstyleoption.h:577
#define ABS_UPHOVER
#define TDLG_SECONDARYPANEL
QPoint brushOrigin() const
Returns the currently set brush origin.
Definition: qpainter.cpp:2168
HRESULT(WINAPI * PtrIsThemePartDefined)(HTHEME hTheme, int iPartId, int iStateId)
void drawControl(ControlElement element, const QStyleOption *option, QPainter *p, const QWidget *wwidget=0) const
Reimplemented Function
static PtrDrawThemeBackgroundEx pDrawThemeBackgroundEx
#define MC_BULLETNORMAL
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
The QStyleOption class stores the parameters used by QStyle functions.
Definition: qstyleoption.h:67
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
#define TMT_TRANSITIONDURATIONS
#define PP_TRANSPARENTBARVERT
HRESULT(WINAPI * PtrGetThemePosition)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT POINT *pPoint)
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget=0) const
#define PP_FILL
ContentsType
This enum describes the available contents types.
Definition: qstyle.h:602
void setContentsMargins(int left, int top, int right, int bottom)
Sets the margins around the contents of the widget to have the sizes left, top, right, and bottom.
Definition: qwidget.cpp:7449
The QTreeView class provides a default model/view implementation of a tree view.
Definition: qtreeview.h:58
The QStyleOptionSpinBox class is used to describe the parameters necessary for drawing a spin box...
Definition: qstyleoption.h:729
void setTop(int pos)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:261
void drawPrimitive(PrimitiveElement pe, const QStyleOption *option, QPainter *p, const QWidget *widget=0) const
Reimplemented Function
const char * name
#define MENU_POPUPITEM
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
Mode
This enum type describes the mode for which a pixmap is intended to be used.
Definition: qicon.h:63
HRESULT(WINAPI * PtrGetThemeString)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT LPWSTR pszBuff, int cchMaxBuffChars)
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
Definition: qicon.cpp:769
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
The QComboBox widget is a combined button and popup list.
Definition: qcombobox.h:62
#define EBS_DISABLED
HRESULT(WINAPI * PtrGetThemeMargins)(HTHEME hTheme, OPTIONAL HDC hdc, int iPartId, int iStateId, int iPropId, OPTIONAL RECT *prc, OUT MARGINS *pMargins)
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given primitive element with the provided painter using the style options specified by opti...
int styleHint(StyleHint hint, const QStyleOption *option=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const
Reimplemented Function
void setSize(const QSize &s)
Sets the size of the rectangle to the given size.
Definition: qrect.h:448
void unpolish(QApplication *)
Reimplemented Function
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
Definition: qcoreevent.h:346
bool showDecorationSelected
whether the decoration should be highlighted on selected items
Definition: qstyleoption.h:553
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
void transpose()
Swaps the width and height values.
Definition: qsize.cpp:196
void setEndImage(const QImage &image)
The QStyleOptionFrame class is used to describe the parameters for drawing a frame.
Definition: qstyleoption.h:118
void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
unsigned int uint
Definition: qglobal.h:996
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
static int buttonStateId(int flags, int partId)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
T findChild(const QString &aName=QString()) const
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object.
Definition: qobject.h:158
int pixelMetric(PixelMetric pm, const QStyleOption *option=0, const QWidget *widget=0) const
Reimplemented Function
#define CMDLGS_NORMAL
The QGroupBox widget provides a group box frame with a title.
Definition: qgroupbox.h:57
HRESULT(WINAPI * PtrGetCurrentThemeName)(OUT LPWSTR pszThemeFileName, int cchMaxNameChars, OUT OPTIONAL LPWSTR pszColorBuff, int cchMaxColorChars, OUT OPTIONAL LPWSTR pszSizeBuff, int cchMaxSizeChars)
static const int windowsItemHMargin
QSize sizeFromContents(ContentsType ct, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget=0) const
Reimplemented Function
HRESULT(WINAPI * PtrGetThemePropertyOrigin)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT enum PROPERTYORIGIN *pOrigin)
#define MENU_POPUPCHECKBACKGROUND
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
HRESULT(WINAPI * PtrGetThemeTransitionDuration)(HTHEME hTheme, int iPartId, int iStateFromId, int iStateToId, int iPropId, int *pDuration)
static bool isItemViewDelegateLineEdit(const QWidget *widget)
#define LISS_SELECTED
static PtrGetThemeFont pGetThemeFont
virtual void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget=0) const =0
Draws the given control using the provided painter with the style options specified by option...
__int64 qint64
Definition: qglobal.h:942
ButtonFeatures features
a bitwise OR of the features that describe this button
Definition: qstyleoption.h:289
The QAbstractSpinBox class provides a spinbox and a line edit to display values.
void timerEvent(QTimerEvent *event)
Reimplemented Function
Qt::BrushStyle style() const
Returns the brush style.
Definition: qbrush.h:182
The State element defines configurations of objects and properties.
void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
HRESULT(WINAPI * PtrGetThemeIntList)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT INTLIST *pIntList)
Q_GUI_EXPORT_INLINE int qBlue(QRgb rgb)
Definition: qrgb.h:63
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
Definition: qobject.h:275
static PtrGetThemeString pGetThemeString
static PtrGetThemeEnumValue pGetThemeEnumValue
#define BP_COMMANDLINK
const QBrush & brush(ColorGroup cg, ColorRole cr) const
Returns the brush in the specified color group, used for the given color role.
Definition: qpalette.cpp:874
#define CP_DROPDOWNBUTTONRIGHT
#define MENU_POPUPCHECK
bool event(QEvent *event)
void stop()
Stops the timer.
void moveCenter(const QPoint &p)
Moves the rectangle, leaving the center point at the given position.
Definition: qrect.cpp:840
The QWindowsXPStyle class provides a Microsoft Windows XP-like look and feel.
static PtrGetThemeColor pGetThemeColor
#define EBS_READONLY
ViewItemPosition viewItemPosition
Gives the position of this view item relative to other items.
Definition: qstyleoption.h:619
qreal dpiScaled(qreal value)
QPoint topRight() const
Returns the position of the rectangle&#39;s top-right corner.
Definition: qrect.h:294
RECT toRECT(const QRect &qr)
static PtrCloseThemeData pCloseThemeData
void fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
Definition: qpixmap.cpp:1080
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Definition: qrect.h:234
QPalette palette
the palette that should be used when painting the control
Definition: qstyleoption.h:92
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
QPoint center() const
Returns the center point of the rectangle.
Definition: qrect.h:300
static bool buttonVisible(const QStyle::SubControl sc, const QStyleOptionTitleBar *tb)
const QBrush & shadow() const
Returns the shadow brush of the current color group.
Definition: qpalette.h:139
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
virtual void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const
Draws the given pixmap in the specified rectangle, according to the specified alignment, using the provided painter.
Definition: qstyle.cpp:570
The QAbstractItemView class provides the basic functionality for item view classes.
The QStyleHintReturnMask class provides style hints that return a QRegion.
Definition: qstyleoption.h:923
long HRESULT
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction...
Definition: qstyle.cpp:2087
static PtrGetThemePropertyOrigin pGetThemePropertyOrigin
HRESULT(WINAPI * PtrGetThemeInt)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT int *piVal)
void * resolve(const char *symbol)
The QListView class provides a list or icon view onto a model.
Definition: qlistview.h:57
void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *option, QPainter *p, const QWidget *widget=0) const
Reimplemented Function
void setClipRegion(const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
Sets the clip region to the given region using the specified clip operation.
Definition: qpainter.cpp:2917
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
void setCompositionMode(CompositionMode mode)
Sets the composition mode to the given mode.
Definition: qpainter.cpp:2422
PrimitiveElement
This enum describes the various primitive elements.
Definition: qstyle.h:145
void polish(QWidget *widget)
The QTimerEvent class contains parameters that describe a timer event.
Definition: qcoreevent.h:341
HRESULT(WINAPI * PtrGetThemeEnumValue)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT int *piVal)
void setLeft(int pos)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:258
QRegion region(XPThemeData &themeData)
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168
The QLinearGradient class is used in combination with QBrush to specify a linear gradient brush...
Definition: qbrush.h:280
State
Definition: qaudio.h:59
qint64 cacheKey() const
Returns a number that identifies the contents of this QIcon object.
Definition: qicon.cpp:679
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget=0) const
static QTime currentTime()
Returns the current time as reported by the system clock.
Definition: qdatetime.cpp:3125
QRect toRect() const
Returns the variant as a QRect if the variant has type() Rect ; otherwise returns an invalid QRect...
Definition: qvariant.cpp:2416
int pixelMetric(PixelMetric pm, const QStyleOption *option=0, const QWidget *widget=0) const
Reimplemented Function
#define MBI_HOT
T qstyleoption_cast(const QStyleOption *opt)
Definition: qstyleoption.h:885
void setPrimaryImage(const QImage &image)
QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *widget=0) const
Reimplemented Function
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
QString family() const
Returns the requested font family name, i.e.
Definition: qfont.cpp:906
SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, const QPoint &pos, const QWidget *widget=0) const
QSize actualSize(const QSize &size, Mode mode=Normal, State state=Off) const
Returns the actual size of the icon for the requested size, mode, and state.
Definition: qicon.cpp:730
void setAlternateImage(const QImage &image)
void startAnimation(QWindowsVistaAnimation *)
QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
void setRect(int x, int y, int w, int h)
Sets the coordinates of the rectangle&#39;s top-left corner to ({x}, {y}), and its size to the given widt...
Definition: qrect.h:400
#define CMDLGS_DISABLED
Q_GUI_EXPORT_INLINE QRgb qRgb(int r, int g, int b)
Definition: qrgb.h:69
static const QStyle::SubControl SubControls[]
static HWND winId(const QWidget *widget)
This function will always return a valid window handle, and might create a limbo widget to do so...
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
int key
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
Definition: qpalette.h:201
#define MBI_DISABLED
static PtrSetWindowTheme pSetWindowTheme
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
#define MENU_BARITEM
virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given element with the provided painter with the style options specified by option...
unsigned int quint32
Definition: qglobal.h:938
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
static const int windowsArrowHMargin
The QStyleOptionComboBox class is used to describe the parameter for drawing a combobox.
Definition: qstyleoption.h:796
int & rheight()
Returns a reference to the height.
Definition: qsize.h:144
void setWidth(int w)
Sets the width of the rectangle to the given width.
Definition: qrect.h:442
void setPen(const QColor &color)
Sets the painter&#39;s pen to have style Qt::SolidLine, width 0 and the specified color.
Definition: qpainter.cpp:4047
int height() const
Returns the height.
Definition: qsize.h:129
Qt::LayoutDirection direction
the text layout direction that should be used when drawing text in the control
Definition: qstyleoption.h:89
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
static bool useXP(bool update=false)
bool isFloating() const
Definition: qdockwidget.h:96
SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *w=0) const
Reimplemented Function
#define MC_CHECKMARKNORMAL
static PtrGetThemeMetric pGetThemeMetric
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572
T takeAt(int i)
Removes the item at index position i and returns it.
Definition: qlist.h:484
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
Definition: qpainter.h:650
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
The QLineEdit widget is a one-line text editor.
Definition: qlineedit.h:66
void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect, Qt::ImageConversionFlags flags=Qt::AutoColor)
Definition: qpainter.cpp:5936
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
#define EBS_HOT
const QStyle * proxy() const
Definition: qstyle.cpp:2546
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const
QVariant property(const char *name) const
Returns the value of the object&#39;s name property.
Definition: qobject.cpp:3807
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
Q_GUI_EXPORT_INLINE int qGreen(QRgb rgb)
Definition: qrgb.h:60
static QColor fromRgb(QRgb rgb)
Static convenience function that returns a QColor constructed from the given QRgb value rgb...
Definition: qcolor.cpp:1958
#define MBI_NORMAL
static const int windowsRightBorder
static const int windowsItemFrame
HRESULT(WINAPI * PtrGetThemePartSize)(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, OPTIONAL RECT *prc, enum THEMESIZE eSize, OUT SIZE *psz)
HRESULT(WINAPI * PtrGetThemeMetric)(HTHEME hTheme, OPTIONAL HDC hdc, int iPartId, int iStateId, int iPropId, OUT int *piVal)
#define MB_ACTIVE
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device...
Definition: qpainter.cpp:5619
int height() const
Returns the height of the pixmap.
Definition: qpixmap.cpp:645
ControlElement
This enum represents a control element.
Definition: qstyle.h:217
The QStyleOptionSlider class is used to describe the parameters needed for drawing a slider...
Definition: qstyleoption.h:701
const QBrush & alternateBase() const
Returns the alternate base brush of the current color group.
Definition: qpalette.h:131
static PtrGetThemeMargins pGetThemeMargins
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
Definition: qcoreevent.h:309
#define EP_BACKGROUND
#define PP_FILLVERT
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void setFont(const QFont &f)
Sets the painter&#39;s font to the given font.
Definition: qpainter.cpp:4288
WId winId() const
Returns the window system identifier of the widget.
Definition: qwidget.cpp:2557
static QPixmap grabWindow(WId, int x=0, int y=0, int w=-1, int h=-1)
Creates and returns a pixmap constructed by grabbing the contents of the given window restricted by Q...
QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
#define TMT_BORDERSIZE
Qt::WindowFlags titleBarFlags
the widget flags for the title bar
Definition: qstyleoption.h:825
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
The QStyleOptionComplex class is used to hold parameters that are common to all complex controls...
Definition: qstyleoption.h:687
HRESULT(WINAPI * PtrGetThemeRect)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT RECT *pRect)
static PtrGetThemePartSize pGetThemePartSize
int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const
void moveTop(int pos)
Moves the rectangle vertically, leaving the rectangle&#39;s top edge at the given y coordinate.
Definition: qrect.h:353
void polish(QApplication *)
Reimplemented Function
bool isEmpty() const
Returns true if either of the width and height is less than or equal to 0; otherwise returns false...
Definition: qsize.h:120
The QToolButton class provides a quick-access button to commands or options, usually used inside a QT...
Definition: qtoolbutton.h:59
QList< QWindowsVistaAnimation * > animations
#define MC_BULLETDISABLED
#define TMT_SIZINGMARGINS
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615
The QStyleOptionProgressBar class is used to describe the parameters necessary for drawing a progress...
Definition: qstyleoption.h:396
const QRect & geometry() const
#define EP_EDITBORDER_NOSCROLL
void setStartImage(const QImage &image)
#define ABS_RIGHTHOVER
QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const
#define MENU_POPUPBORDERS
void translate(int dx, int dy)
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position...
Definition: qrect.h:312
void setDuration(int duration)
The QCheckBox widget provides a checkbox with a text label.
Definition: qcheckbox.h:56
int titleBarState
the state of the title bar
Definition: qstyleoption.h:824
Orientation
Definition: qnamespace.h:174
SelectionBehavior selectionBehavior
which selection behavior the view uses
#define ABS_DOWNHOVER
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
QPalette standardPalette() const
Reimplemented Function
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
#define PP_MOVEOVERLAYVERT
The QStyleOptionButton class is used to describe the parameters for drawing buttons.
Definition: qstyleoption.h:279
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget=0) const
QPalette standardPalette() const
#define TDLG_PRIMARYPANEL
#define TMT_FILLCOLOR
#define ABS_LEFTHOVER
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
#define MENU_POPUPGUTTER
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
static PtrGetThemeIntList pGetThemeIntList
QStyle::SubControls subControls
This variable holds a bitwise OR of the sub-controls to be drawn for the complex control.
Definition: qstyleoption.h:693
QWindowsVistaStyle()
Constructs a QWindowsVistaStyle object.
void setStartTime(const QTime &startTime)
QRgb rgb() const
Returns the RGB value of the color.
Definition: qcolor.cpp:1051
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
void setPalette(const QPalette &)
Use the single-argument overload instead.
Definition: qwidget.cpp:4858
void start(int msec, QObject *obj)
Starts (or restarts) the timer with a msec milliseconds timeout.
bool end()
Ends painting.
Definition: qpainter.cpp:1929
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70
QWindowsVistaAnimation * widgetAnimation(const QWidget *) const
int & rwidth()
Returns a reference to the width.
Definition: qsize.h:141
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Definition: qpainter.cpp:7420
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *w=0) const
Reimplemented Function
SubElement
This enum represents a sub-area of a widget.
Definition: qstyle.h:289
QString text
The text (if any) to be drawn in the view item.
Definition: qstyleoption.h:618
HRESULT(WINAPI * PtrGetThemeFont)(HTHEME hTheme, OPTIONAL HDC hdc, int iPartId, int iStateId, int iPropId, OUT LOGFONT *pFont)
#define EBS_NORMAL
static bool resolveSymbols()
Returns true if all the necessary theme engine symbols were resolved.
#define QT_NO_LINEEDIT
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288
static PtrGetThemePosition pGetThemePosition
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
Definition: qpainter.cpp:3311
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60
#define TMT_CONTENTMARGINS