Qt 4.8
qmotifstyle.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 "qmotifstyle.h"
43 #include "qcdestyle.h"
44 
45 #if !defined(QT_NO_STYLE_MOTIF) || defined(QT_PLUGIN)
46 
47 #include "qmenu.h"
48 #include "qapplication.h"
49 #include "qpainter.h"
50 #include "qdrawutil.h"
51 #include "qpixmap.h"
52 #include "qpalette.h"
53 #include "qwidget.h"
54 #include "qpushbutton.h"
55 #include "qscrollbar.h"
56 #include "qtabbar.h"
57 #include "qtabwidget.h"
58 #include "qlistview.h"
59 #include "qsplitter.h"
60 #include "qslider.h"
61 #include "qcombobox.h"
62 #include "qlineedit.h"
63 #include "qprogressbar.h"
64 #include "qimage.h"
65 #include "qfocusframe.h"
66 #include "qdebug.h"
67 #include "qpainterpath.h"
68 #include "qmotifstyle_p.h"
69 #include "qdialogbuttonbox.h"
70 #include "qformlayout.h"
71 #include <limits.h>
72 #include <QtGui/qgraphicsproxywidget.h>
73 #include <QtGui/qgraphicsview.h>
74 
75 #ifdef Q_WS_X11
76 #include "qx11info_x11.h"
77 #endif
78 
80 
81 // old constants that might still be useful...
82 static const int motifItemFrame = 2; // menu item frame width
83 static const int motifSepHeight = 2; // separator item height
84 static const int motifItemHMargin = 3; // menu item hor text margin
85 static const int motifItemVMargin = 2; // menu item ver text margin
86 static const int motifArrowHMargin = 6; // arrow horizontal margin
87 static const int motifTabSpacing = 12; // space between text and tab
88 static const int motifCheckMarkHMargin = 2; // horiz. margins of check mark
89 static const int motifCheckMarkSpace = 16;
90 
91 
123 QMotifStyle::QMotifStyle(bool useHighlightCols)
125 {
126  focus = 0;
127  highlightCols = useHighlightCols;
128 }
129 
130 
135  : QCommonStyle(dd)
136 {
137  focus = 0;
139 }
140 
141 
151 {
152  delete focus;
153 }
154 
160 {
161 #ifndef QT_NO_PROGRESSBAR
162  Q_D(QMotifStyle);
163  switch(e->type()) {
164  case QEvent::StyleChange:
165  case QEvent::Show:
166  if (QProgressBar *bar = qobject_cast<QProgressBar *>(o)) {
167  d->bars << bar;
168  if (d->bars.size() == 1) {
169  Q_ASSERT(d->animationFps> 0);
170  d->animateTimer = startTimer(1000 / d->animationFps);
171  }
172  }
173  break;
174  case QEvent::Destroy:
175  case QEvent::Hide:
176  // reinterpret_cast because there is no type info when getting
177  // the destroy event. We know that it is a QProgressBar.
178  if (QProgressBar *bar = reinterpret_cast<QProgressBar *>(o)) {
179  d->bars.removeAll(bar);
180  if (d->bars.isEmpty() && d->animateTimer) {
181  killTimer(d->animateTimer);
182  d->animateTimer = 0;
183  }
184  }
185  default:
186  break;
187  }
188 #endif // QT_NO_PROGRESSBAR
189  return QStyle::eventFilter(o, e);
190 }
191 
196  const QWidget *widget) const
197 {
198  return QCommonStyle::standardIconImplementation(standardIcon, opt, widget);
199 }
200 
205 {
206 #ifndef QT_NO_PROGRESSBAR
207  Q_D(QMotifStyle);
208  if (event->timerId() == d->animateTimer) {
209  Q_ASSERT(d->animationFps > 0);
210  d->animateStep = d->startTime.elapsed() / (1000 / d->animationFps);
211  foreach (QProgressBar *bar, d->bars) {
212  if ((bar->minimum() == 0 && bar->maximum() == 0))
213  bar->update();
214  }
215  }
216 #endif // QT_NO_PROGRESSBAR
217  event->ignore();
218 }
219 
220 
222 #ifndef QT_NO_PROGRESSBAR
223  : animationFps(25), animateTimer(0), animateStep(0)
224 #endif
225 {
226 }
227 
240 {
241  highlightCols = arg;
242 }
243 
251 {
252  return highlightCols;
253 }
254 
258 {
260  QColor nlight = pal.color(QPalette::Active, QPalette::Light).darker(108);
264  }
265 
266  if (highlightCols)
267  return;
268 
269  // force the ugly motif way of highlighting *sigh*
282 }
283 
293 {
294  QStyle::polish(widget);
295 #ifndef QT_NO_PROGRESSBAR
296  if (qobject_cast<QProgressBar *>(widget))
297  widget->installEventFilter(this);
298 #endif
299 }
300 
310 {
311  QCommonStyle::unpolish(widget);
312 #ifndef QT_NO_PROGRESSBAR
313  if (qobject_cast<QProgressBar *>(widget)) {
314  Q_D(QMotifStyle);
315  widget->removeEventFilter(this);
316  d->bars.removeAll(static_cast<QProgressBar*>(widget));
317  }
318 #endif
319 }
320 
321 
331 {
333 }
334 
335 
345 {
347 }
348 
349 static void rot(QPolygon& a, int n)
350 {
351  QPolygon r(a.size());
352  for (int i = 0; i < (int)a.size(); i++) {
353  switch (n) {
354  case 1: r.setPoint(i,-a[i].y(),a[i].x()); break;
355  case 2: r.setPoint(i,-a[i].x(),-a[i].y()); break;
356  case 3: r.setPoint(i,a[i].y(),-a[i].x()); break;
357  }
358  }
359  a = r;
360 }
361 
362 
367  const QWidget *w) const
368 {
369  switch(pe) {
371  if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) {
372  if (lv->items.isEmpty())
373  return;
374 
375  if (lv->state & State_Enabled)
376  p->setPen(QPen(opt->palette.text().color()));
377  else
378  p->setPen(QPen(lv->palette.color(QPalette::Disabled, QPalette::Text)));
379  QPolygon a;
380 
381  int cx = opt->rect.width()/2 - 1;
382  int cy = opt->rect.height()/2;
383  int e = opt->rect.width()/2 - 1;
384  for (int i = 0; i < 3; i++) { //penWidth 2 doesn't quite work
385  a.setPoints(4, cx-e, cy, cx, cy-e, cx+e, cy, cx, cy+e);
386  p->drawPolygon(a);
387  e--;
388  }
389  if (opt->state & State_On) {
390  if (lv->state & State_Enabled)
391  p->setPen(QPen(opt->palette.text().color()));
392  else
393  p->setPen(QPen(lv->palette.color(QPalette::Disabled,
394  QPalette::Text)));
395  QBrush saveBrush = p->brush();
396  p->setBrush(opt->palette.text());
397  e = e - 2;
398  a.setPoints(4, cx-e, cy, cx, cy-e, cx+e, cy, cx, cy+e);
399  p->drawPolygon(a);
400  p->setBrush(saveBrush);
401  }
402  }
403  break;
404 
405  case PE_FrameTabWidget:
406  case PE_FrameWindow:
408  break;
409  case PE_FrameFocusRect:
410  if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(opt)) {
411  if ((fropt->state & State_HasFocus) && focus && focus->isVisible()
412  && !(fropt->state & QStyle::State_Item))
413  break;
414  QCommonStyle::drawPrimitive(pe, opt, p, w);
415  }
416  break;
417 
419  p->save();
420  p->translate(opt->rect.x(), opt->rect.y());
421 
422  QColor dark(opt->palette.dark().color());
423  QColor light(opt->palette.light().color());
424  int i;
425  if (opt->state & State_Horizontal) {
426  int h = opt->rect.height();
427  if (h > 6) {
428  if (opt->state & State_On)
429  p->fillRect(1, 1, 8, h - 2, opt->palette.highlight());
430  QPolygon a(2 * ((h-6)/3));
431  int y = 3 + (h%3)/2;
432  p->setPen(dark);
433  p->drawLine(8, 1, 8, h-2);
434  for (i=0; 2*i < a.size(); ++i) {
435  a.setPoint(2*i, 5, y+1+3*i);
436  a.setPoint(2*i+1, 2, y+2+3*i);
437  }
438  p->drawPoints(a);
439  p->setPen(light);
440  p->drawLine(9, 1, 9, h-2);
441  for (i=0; 2*i < a.size(); i++) {
442  a.setPoint(2*i, 4, y+3*i);
443  a.setPoint(2*i+1, 1, y+1+3*i);
444  }
445  p->drawPoints(a);
446  // if (drawBorder) {
447  // p->setPen(QPen(Qt::darkGray));
448  // p->drawLine(0, opt->rect.height() - 1,
449  // tbExtent, opt->rect.height() - 1);
450  // }
451  }
452  } else {
453  int w = opt->rect.width();
454  if (w > 6) {
455  if (opt->state & State_On)
456  p->fillRect(1, 1, w - 2, 9, opt->palette.highlight());
457  QPolygon a(2 * ((w-6)/3));
458 
459  int x = 3 + (w%3)/2;
460  p->setPen(dark);
461  p->drawLine(1, 8, w-2, 8);
462  for (i=0; 2*i < a.size(); ++i) {
463  a.setPoint(2*i, x+1+3*i, 6);
464  a.setPoint(2*i+1, x+2+3*i, 3);
465  }
466  p->drawPoints(a);
467  p->setPen(light);
468  p->drawLine(1, 9, w-2, 9);
469  for (i=0; 2*i < a.size(); ++i) {
470  a.setPoint(2*i, x+3*i, 5);
471  a.setPoint(2*i+1, x+1+3*i, 2);
472  }
473  p->drawPoints(a);
474  // if (drawBorder) {
475  // p->setPen(QPen(Qt::darkGray));
476  // p->drawLine(opt->rect.width() - 1, 0,
477  // opt->rect.width() - 1, tbExtent);
478  // }
479  }
480  }
481  p->restore();
482  break; }
483 
485  case PE_PanelButtonBevel:
486  case PE_PanelButtonTool: {
487  QBrush fill;
488  if (opt->state & State_Sunken)
489  fill = opt->palette.brush(QPalette::Mid);
490  else if ((opt->state & State_On) && (opt->state & State_Enabled))
491  fill = QBrush(opt->palette.mid().color(), Qt::Dense4Pattern);
492  else
493  fill = opt->palette.brush(QPalette::Button);
494  if ((opt->state & State_Enabled || opt->state & State_On) || !(opt->state & State_AutoRaise))
495  qDrawShadePanel(p, opt->rect, opt->palette, bool(opt->state & (State_Sunken | State_On)),
497  break; }
498 
499  case PE_IndicatorCheckBox: {
500  bool on = opt->state & State_On;
501  bool down = opt->state & State_Sunken;
502  bool showUp = !(down ^ on);
503  QBrush fill = opt->palette.brush((showUp || opt->state & State_NoChange) ?QPalette::Button : QPalette::Mid);
504  if (opt->state & State_NoChange) {
505  qDrawPlainRect(p, opt->rect, opt->palette.text().color(),
506  1, &fill);
507  p->drawLine(opt->rect.x() + opt->rect.width() - 1, opt->rect.y(),
508  opt->rect.x(), opt->rect.y() + opt->rect.height() - 1);
509  } else {
510  qDrawShadePanel(p, opt->rect, opt->palette, !showUp,
512  }
515  break; }
516 
518 #define INTARRLEN(x) sizeof(x)/(sizeof(int)*2)
519  int inner_pts[] = { // used for filling diamond
520  2,opt->rect.height()/2,
521  opt->rect.width()/2,2,
522  opt->rect.width()-3,opt->rect.height()/2,
523  opt->rect.width()/2,opt->rect.height()-3
524  };
525  int top_pts[] = { // top (^) of diamond
526  0,opt->rect.height()/2,
527  opt->rect.width()/2,0,
528  opt->rect.width()-2,opt->rect.height()/2-1,
529  opt->rect.width()-3,opt->rect.height()/2-1,
530  opt->rect.width()/2,1,
531  1,opt->rect.height()/2,
532  2,opt->rect.height()/2,
533  opt->rect.width()/2,2,
534  opt->rect.width()-4,opt->rect.height()/2-1
535  };
536  int bottom_pts[] = { // bottom (v) of diamond
537  1,opt->rect.height()/2+1,
538  opt->rect.width()/2,opt->rect.height()-1,
539  opt->rect.width()-1,opt->rect.height()/2,
540  opt->rect.width()-2,opt->rect.height()/2,
541  opt->rect.width()/2,opt->rect.height()-2,
542  2,opt->rect.height()/2+1,
543  3,opt->rect.height()/2+1,
544  opt->rect.width()/2,opt->rect.height()-3,
545  opt->rect.width()-3,opt->rect.height()/2
546  };
547  bool on = opt->state & State_On;
548  bool down = opt->state & State_Sunken;
549  bool showUp = !(down ^ on);
550  QPen oldPen = p->pen();
551  QBrush oldBrush = p->brush();
552  QPolygon a(INTARRLEN(inner_pts), inner_pts);
553  p->setPen(Qt::NoPen);
554  p->setBrush(opt->palette.brush(showUp ? QPalette::Button : QPalette::Mid));
555  a.translate(opt->rect.x(), opt->rect.y());
556  p->drawPolygon(a);
557  p->setPen(showUp ? opt->palette.light().color() : opt->palette.dark().color());
558  p->setBrush(Qt::NoBrush);
559  a.setPoints(INTARRLEN(top_pts), top_pts);
560  a.translate(opt->rect.x(), opt->rect.y());
561  p->drawPolyline(a);
562  p->setPen(showUp ? opt->palette.dark().color() : opt->palette.light().color());
563  a.setPoints(INTARRLEN(bottom_pts), bottom_pts);
564  a.translate(opt->rect.x(), opt->rect.y());
565  p->drawPolyline(a);
568  p->setPen(oldPen);
569  p->setBrush(oldBrush);
570  break; }
571 
572  case PE_IndicatorSpinUp:
576  case PE_IndicatorArrowUp:
579  case PE_IndicatorArrowLeft: {
580  QRect rect = opt->rect;
581  QPolygon bFill;
582  QPolygon bTop;
583  QPolygon bBot;
584  QPolygon bLeft;
585  if (pe == PE_IndicatorSpinPlus || pe == PE_IndicatorSpinUp)
586  pe = PE_IndicatorArrowUp;
587  else if (pe == PE_IndicatorSpinMinus || pe == PE_IndicatorSpinDown)
589  bool vertical = pe == PE_IndicatorArrowUp || pe == PE_IndicatorArrowDown;
590  bool horizontal = !vertical;
591  int dim = rect.width() < rect.height() ? rect.width() : rect.height();
592  int colspec = 0x0000;
593 
594  if (!(opt->state & State_Enabled))
595  dim -= 2;
596  if(dim < 2)
597  break;
598 
599  // adjust size and center (to fix rotation below)
600  if (rect.width() > dim) {
601  rect.setX(rect.x() + ((rect.width() - dim) / 2));
602  rect.setWidth(dim);
603  }
604  if (rect.height() > dim) {
605  rect.setY(rect.y() + ((rect.height() - dim) / 2));
606  rect.setHeight(dim);
607  }
608 
609  if (dim > 3) {
610  if (pixelMetric(PM_DefaultFrameWidth) < 2) { // thin style
611  bFill.resize( dim & 1 ? 3 : 4 );
612  bTop.resize( 2 );
613  bBot.resize( 2 );
614  bLeft.resize( 2 );
615  bLeft.putPoints( 0, 2, 0, 0, 0, dim-1 );
616  bTop.putPoints( 0, 2, 1, 0, dim-1, dim/2 );
617  bBot.putPoints( 0, 2, 1, dim-1, dim-1, dim/2 );
618 
619  if ( dim > 6 ) { // dim>6: must fill interior
620  bFill.putPoints( 0, 2, 0, dim-1, 0, 0 );
621  if ( dim & 1 ) // if size is an odd number
622  bFill.setPoint( 2, dim - 1, dim / 2 );
623  else
624  bFill.putPoints( 2, 2, dim-1, dim/2-1, dim-1, dim/2 );
625  }
626  } else {
627  if (dim > 6)
628  bFill.resize(dim & 1 ? 3 : 4);
629  bTop.resize((dim/2)*2);
630  bBot.resize(dim & 1 ? dim + 1 : dim);
631  bLeft.resize(dim > 4 ? 4 : 2);
632  bLeft.putPoints(0, 2, 0,0, 0,dim-1);
633  if (dim > 4)
634  bLeft.putPoints(2, 2, 1,2, 1,dim-3);
635  bTop.putPoints(0, 4, 1,0, 1,1, 2,1, 3,1);
636  bBot.putPoints(0, 4, 1,dim-1, 1,dim-2, 2,dim-2, 3,dim-2);
637 
638  for(int i=0; i<dim/2-2 ; i++) {
639  bTop.putPoints(i*2+4, 2, 2+i*2,2+i, 5+i*2, 2+i);
640  bBot.putPoints(i*2+4, 2, 2+i*2,dim-3-i, 5+i*2,dim-3-i);
641  }
642  if (dim & 1) // odd number size: extra line
643  bBot.putPoints(dim-1, 2, dim-3,dim/2, dim-1,dim/2);
644  if (dim > 6) { // dim>6: must fill interior
645  bFill.putPoints(0, 2, 1,dim-3, 1,2);
646  if (dim & 1) // if size is an odd number
647  bFill.setPoint(2, dim - 3, dim / 2);
648  else
649  bFill.putPoints(2, 2, dim-4,dim/2-1, dim-4,dim/2);
650  }
651  }
652  } else {
653  if (dim == 3) { // 3x3 arrow pattern
654  bLeft.setPoints(4, 0,0, 0,2, 1,1, 1,1);
655  bTop .setPoints(2, 1,0, 1,0);
656  bBot .setPoints(2, 1,2, 2,1);
657  }
658  else { // 2x2 arrow pattern
659  bLeft.setPoints(2, 0,0, 0,1);
660  bTop .setPoints(2, 1,0, 1,0);
661  bBot .setPoints(2, 1,1, 1,1);
662  }
663  }
664 
665  // We use rot() and translate() as it is more efficient that
666  // matrix transformations on the painter, and because it still
667  // works with QT_NO_TRANSFORMATIONS defined.
668 
669  if (pe == PE_IndicatorArrowUp || pe == PE_IndicatorArrowLeft) {
670  if (vertical) {
671  rot(bFill,3);
672  rot(bLeft,3);
673  rot(bTop,3);
674  rot(bBot,3);
675  bFill.translate(0, rect.height() - 1);
676  bLeft.translate(0, rect.height() - 1);
677  bTop.translate(0, rect.height() - 1);
678  bBot.translate(0, rect.height() - 1);
679  } else {
680  rot(bFill,2);
681  rot(bLeft,2);
682  rot(bTop,2);
683  rot(bBot,2);
684  bFill.translate(rect.width() - 1, rect.height() - 1);
685  bLeft.translate(rect.width() - 1, rect.height() - 1);
686  bTop.translate(rect.width() - 1, rect.height() - 1);
687  bBot.translate(rect.width() - 1, rect.height() - 1);
688  }
689  if (opt->state & State_Sunken)
690  colspec = horizontal ? 0x2334 : 0x2343;
691  else
692  colspec = horizontal ? 0x1443 : 0x1434;
693  } else {
694  if (vertical) {
695  rot(bFill,1);
696  rot(bLeft,1);
697  rot(bTop,1);
698  rot(bBot,1);
699  bFill.translate(rect.width() - 1, 0);
700  bLeft.translate(rect.width() - 1, 0);
701  bTop.translate(rect.width() - 1, 0);
702  bBot.translate(rect.width() - 1, 0);
703  }
704  if (opt->state & State_Sunken)
705  colspec = horizontal ? 0x2443 : 0x2434;
706  else
707  colspec = horizontal ? 0x1334 : 0x1343;
708  }
709  bFill.translate(rect.x(), rect.y());
710  bLeft.translate(rect.x(), rect.y());
711  bTop.translate(rect.x(), rect.y());
712  bBot.translate(rect.x(), rect.y());
713 
714  const QColor *cols[5];
715  if (opt->state & State_Enabled) {
716  cols[0] = 0;
717  cols[1] = &opt->palette.button().color();
718  cols[2] = &opt->palette.mid().color();
719  cols[3] = &opt->palette.light().color();
720  cols[4] = &opt->palette.dark().color();
721  } else {
722  cols[0] = 0;
723  cols[1] = &opt->palette.mid().color();
724  cols[2] = &opt->palette.mid().color();
725  cols[3] = &opt->palette.mid().color();
726  cols[4] = &opt->palette.mid().color();
727  }
728 
729 #define CMID *cols[(colspec>>12) & 0xf]
730 #define CLEFT *cols[(colspec>>8) & 0xf]
731 #define CTOP *cols[(colspec>>4) & 0xf]
732 #define CBOT *cols[colspec & 0xf]
733 
734  QPen savePen = p->pen();
735  QBrush saveBrush = p->brush();
736  QPen pen(Qt::NoPen);
737  QBrush brush = opt->palette.brush((opt->state & State_Enabled) ?
739  p->setPen(pen);
740  p->setBrush(brush);
741  p->drawPolygon(bFill);
742  p->setBrush(Qt::NoBrush);
743 
744  p->setPen(CLEFT);
745  p->drawPolyline(bLeft);
746  p->setPen(CTOP);
747  p->drawPolyline(bTop);
748  p->setPen(CBOT);
749  p->drawPolyline(bBot);
750 
751  p->setBrush(saveBrush);
752  p->setPen(savePen);
753 #undef CMID
754 #undef CLEFT
755 #undef CTOP
756 #undef CBOT
759  break; }
760 
762  const int motifOffset = 10;
763  int sw = proxy()->pixelMetric(PM_SplitterWidth);
764  if (opt->state & State_Horizontal) {
765  int yPos = opt->rect.y() + opt->rect.height() / 2;
766  int kPos = opt->rect.right() - motifOffset - sw;
767  int kSize = sw - 2;
768 
769  qDrawShadeLine(p, opt->rect.left(), yPos, kPos, yPos, opt->palette);
770  qDrawShadePanel(p, kPos, yPos - sw / 2 + 1, kSize, kSize,
771  opt->palette, false, 1, &opt->palette.brush(QPalette::Button));
772  qDrawShadeLine(p, kPos + kSize - 1, yPos, opt->rect.right(), yPos, opt->palette);
773  } else {
774  int xPos = opt->rect.x() + opt->rect.width() / 2;
775  int kPos = motifOffset;
776  int kSize = sw - 2;
777 
778  qDrawShadeLine(p, xPos, opt->rect.top() + kPos + kSize - 1, xPos, opt->rect.bottom(), opt->palette);
779  qDrawShadePanel(p, xPos - sw / 2 + 1, opt->rect.top() + kPos, kSize, kSize, opt->palette,
780  false, 1, &opt->palette.brush(QPalette::Button));
781  qDrawShadeLine(p, xPos, opt->rect.top(), xPos, opt->rect.top() + kPos, opt->palette);
782  }
783  break; }
784 
786  const int markW = 6;
787  const int markH = 6;
788  int posX = opt->rect.x() + (opt->rect.width() - markW) / 2 - 1;
789  int posY = opt->rect.y() + (opt->rect.height() - markH) / 2;
790  int dfw = proxy()->pixelMetric(PM_DefaultFrameWidth);
791 
792  if (dfw < 2) {
793  // Could do with some optimizing/caching...
794  QPolygon a(7*2);
795  int i, xx, yy;
796  xx = posX;
797  yy = 3 + posY;
798  for (i=0; i<3; i++) {
799  a.setPoint(2*i, xx, yy);
800  a.setPoint(2*i+1, xx, yy+2);
801  xx++; yy++;
802  }
803  yy -= 2;
804  for (i=3; i<7; i++) {
805  a.setPoint(2*i, xx, yy);
806  a.setPoint(2*i+1, xx, yy+2);
807  xx++; yy--;
808  }
809  if (! (opt->state & State_Enabled) && ! (opt->state & State_On)) {
810  int pnt;
811  p->setPen(opt->palette.highlightedText().color());
812  QPoint offset(1,1);
813  for (pnt = 0; pnt < (int)a.size(); pnt++)
814  a[pnt] += offset;
815  p->drawPolyline(a);
816  for (pnt = 0; pnt < (int)a.size(); pnt++)
817  a[pnt] -= offset;
818  }
819  p->setPen(opt->palette.text().color());
820  p->drawPolyline(a);
821 
822  qDrawShadePanel(p, posX-2, posY-2, markW+4, markH+6, opt->palette, true, dfw);
823  } else
824  qDrawShadePanel(p, posX, posY, markW, markH, opt->palette, true, dfw,
825  &opt->palette.brush(QPalette::Mid));
826 
827  break; }
828 
830  {
831  bool vertical = false;
832  if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt))
833  vertical = (pb2->orientation == Qt::Vertical);
834  if (!vertical) {
835  p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width(),
837  } else {
838  p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width(), opt->rect.height(),
840  }
841  }
842  break;
843 
844  default:
845  QCommonStyle::drawPrimitive(pe, opt, p, w);
846  break;
847  }
848 }
849 
850 
855  const QWidget *widget) const
856 {
857  switch(element) {
858  case CE_Splitter: {
859  QStyleOption handleOpt = *opt;
860  if (handleOpt.state & State_Horizontal)
861  handleOpt.state &= ~State_Horizontal;
862  else
863  handleOpt.state |= State_Horizontal;
864  proxy()->drawPrimitive(PE_IndicatorDockWidgetResizeHandle, &handleOpt, p, widget);
865  break; }
866 
867  case CE_ScrollBarSubLine:
868  case CE_ScrollBarAddLine:{
869  PrimitiveElement pe;
870  if (element == CE_ScrollBarAddLine)
872  else
873  pe = (opt->state & State_Horizontal) ? (opt->direction == Qt::LeftToRight ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight) : PE_IndicatorArrowUp;
874  QStyleOption arrowOpt = *opt;
875  arrowOpt.state |= State_Enabled;
876  proxy()->drawPrimitive(pe, &arrowOpt, p, widget);
879  p->fillRect(opt->rect.adjusted(fw, fw, -fw, -fw), QBrush(p->background().color(), Qt::Dense5Pattern));
880  }
881  }break;
882 
883  case CE_ScrollBarSubPage:
884  case CE_ScrollBarAddPage:
886  break;
887 
888  case CE_ScrollBarSlider: {
889  QStyleOption bevelOpt = *opt;
890  bevelOpt.state |= State_Raised;
891  bevelOpt.state &= ~(State_Sunken | State_On);
892  p->save();
893  p->setBrushOrigin(bevelOpt.rect.topLeft());
894  proxy()->drawPrimitive(PE_PanelButtonBevel, &bevelOpt, p, widget);
895  p->restore();
898  break; }
899 
900  case CE_RadioButton:
901  case CE_CheckBox:
902  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
903  bool isRadio = (element == CE_RadioButton);
904  QStyleOptionButton subopt = *btn;
905  subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator
906  : SE_CheckBoxIndicator, btn, widget);
908  &subopt, p, widget);
909  subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents
910  : SE_CheckBoxContents, btn, widget);
911  proxy()->drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, p, widget);
912  if ((btn->state & State_HasFocus) && (!focus || !focus->isVisible())) {
913  QStyleOptionFocusRect fropt;
914  fropt.QStyleOption::operator=(*btn);
916  : SE_CheckBoxFocusRect, btn, widget);
917  proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
918  }
919  }
920  break;
921  case CE_PushButton:
922  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
923  proxy()->drawControl(CE_PushButtonBevel, btn, p, widget);
924  QStyleOptionButton subopt = *btn;
925  subopt.rect = subElementRect(SE_PushButtonContents, btn, widget);
926  proxy()->drawControl(CE_PushButtonLabel, &subopt, p, widget);
927  if ((btn->state & State_HasFocus) && (!focus || !focus->isVisible())) {
928  QStyleOptionFocusRect fropt;
929  fropt.QStyleOption::operator=(*btn);
930  fropt.rect = subElementRect(SE_PushButtonFocusRect, btn, widget);
931  proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
932  }
933  }
934  break;
935  case CE_PushButtonBevel:
936  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
937  int diw, x1, y1, x2, y2;
938  p->setPen(opt->palette.foreground().color());
941  opt->rect.getCoords(&x1, &y1, &x2, &y2);
943  x1 += diw;
944  y1 += diw;
945  x2 -= diw;
946  y2 -= diw;
947  }
948  if (btn->features & QStyleOptionButton::DefaultButton) {
949  if (diw == 0) {
950  QPolygon a;
951  a.setPoints(9,
952  x1, y1, x2, y1, x2, y2, x1, y2, x1, y1+1,
953  x2-1, y1+1, x2-1, y2-1, x1+1, y2-1, x1+1, y1+1);
954  p->setPen(opt->palette.shadow().color());
955  p->drawPolygon(a);
956  x1 += 2;
957  y1 += 2;
958  x2 -= 2;
959  y2 -= 2;
960  } else {
961  qDrawShadePanel(p, opt->rect.adjusted(1, 1, -1, -1), opt->palette, true);
962  }
963  }
964  if (!(btn->features & QStyleOptionButton::Flat) ||
965  (btn->state & (State_Sunken | State_On))) {
966  QStyleOptionButton newOpt = *btn;
967  newOpt.rect = QRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
968  p->setBrushOrigin(p->brushOrigin());
969  proxy()->drawPrimitive(PE_PanelButtonCommand, &newOpt, p, widget);
970  }
971  if (btn->features & QStyleOptionButton::HasMenu) {
972  int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, btn, widget);
973  QRect ir = btn->rect;
974  QStyleOptionButton newBtn = *btn;
975  newBtn.rect = QRect(ir.right() - mbi - 3, ir.y() + 4, mbi, ir.height() - 8);
976  proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget);
977  }
978  break;
979  }
980 
981 #ifndef QT_NO_TABBAR
982  case CE_TabBarTabShape:
983  if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
984  const int default_frame = proxy()->pixelMetric(PM_DefaultFrameWidth, tab, widget);
985  const int frame_offset = (default_frame > 1) ? 1 : 0;
986 
987  if (tab->shape == QTabBar::RoundedNorth || tab->shape == QTabBar::RoundedEast ||
988  tab->shape == QTabBar::RoundedSouth || tab->shape == QTabBar::RoundedWest) {
989  p->save();
990  QRect tabRect = opt->rect;
991  QColor tabLight = opt->palette.light().color();
992  QColor tabDark = opt->palette.dark().color();
993 
994  p->fillRect(opt->rect.adjusted(default_frame, default_frame,
995  -default_frame, -default_frame),
996  tab->palette.background());
997 
998  if(tab->shape == QTabBar::RoundedWest) {
999  tabDark = opt->palette.light().color();
1000  tabLight = opt->palette.dark().color();
1001  tabRect = QRect(0, 0, tabRect.height(), tabRect.width());
1002  p->translate(opt->rect.left(), opt->rect.bottom());
1003  p->rotate(-90);
1004  } else if(tab->shape == QTabBar::RoundedSouth) {
1005  tabDark = opt->palette.light().color();
1006  tabLight = opt->palette.dark().color();
1007  tabRect = QRect(0, 0, tabRect.width(), tabRect.height());
1008  p->translate(opt->rect.right(), opt->rect.bottom());
1009  p->rotate(180);
1010  } else if(tab->shape == QTabBar::RoundedEast) {
1011  tabRect = QRect(0, 0, tabRect.height(), tabRect.width());
1012  p->translate(opt->rect.right(), opt->rect.top());
1013  p->rotate(90);
1014  }
1015 
1016  if (default_frame > 1) {
1017  p->setPen(tabLight);
1018  p->drawLine(tabRect.left(), tabRect.bottom(),
1019  tabRect.right(), tabRect.bottom());
1020  p->setPen(tabLight);
1021  p->drawLine(tabRect.left(), tabRect.bottom()-1,
1022  tabRect.right(), tabRect.bottom()-1);
1023  if (tabRect.left() == 0)
1024  p->drawPoint(tabRect.bottomLeft());
1025  } else {
1026  p->setPen(tabLight);
1027  p->drawLine(tabRect.left(), tabRect.bottom(),
1028  tabRect.right(), tabRect.bottom());
1029  }
1030 
1031  if (opt->state & State_Selected) {
1032  p->fillRect(QRect(tabRect.left()+1, tabRect.bottom()-frame_offset,
1033  tabRect.width()-3, 2),
1034  tab->palette.brush(QPalette::Active, QPalette::Background));
1035  p->setPen(tab->palette.background().color());
1036  p->drawLine(tabRect.left()+1, tabRect.bottom(),
1037  tabRect.left()+1, tabRect.top()+2);
1038  p->setPen(tabLight);
1039  } else {
1040  p->setPen(tabLight);
1041  }
1042  p->drawLine(tabRect.left(), tabRect.bottom()-1,
1043  tabRect.left(), tabRect.top() + 2);
1044  p->drawPoint(tabRect.left()+1, tabRect.top() + 1);
1045  p->drawLine(tabRect.left()+2, tabRect.top(),
1046  tabRect.right() - 2, tabRect.top());
1047  p->drawPoint(tabRect.left(), tabRect.bottom());
1048 
1049  if (default_frame > 1) {
1050  p->drawLine(tabRect.left()+1, tabRect.bottom(),
1051  tabRect.left()+1, tabRect.top() + 2);
1052  p->drawLine(tabRect.left()+2, tabRect.top()+1,
1053  tabRect.right() - 2, tabRect.top()+1);
1054  }
1055 
1056  p->setPen(tabDark);
1057  p->drawLine(tabRect.right() - 1, tabRect.top() + 2,
1058  tabRect.right() - 1, tabRect.bottom() - 1 +
1059  ((opt->state & State_Selected) ? frame_offset : -frame_offset));
1060  if (default_frame > 1) {
1061  p->drawPoint(tabRect.right() - 1, tabRect.top() + 1);
1062  p->drawLine(tabRect.right(), tabRect.top() + 2, tabRect.right(),
1063  tabRect.bottom() -
1064  ((opt->state & State_Selected) ?
1065  ((tab->position == QStyleOptionTab::End) ? 0:1):1+frame_offset));
1066  p->drawPoint(tabRect.right() - 1, tabRect.top() + 1);
1067  }
1068  p->restore();
1069  } else {
1070  QCommonStyle::drawControl(element, opt, p, widget);
1071  }
1072  break; }
1073 #endif // QT_NO_TABBAR
1074  case CE_ProgressBarGroove:
1075  qDrawShadePanel(p, opt->rect, opt->palette, true, 2);
1076  break;
1077 
1078  case CE_ProgressBarLabel:
1079  if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
1080  QTransform oldMatrix = p->transform();
1081  QRect rect = pb->rect;
1082  bool vertical = false;
1083  bool invert = false;
1084  bool bottomToTop = false;
1085  if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) {
1086  vertical = (pb2->orientation == Qt::Vertical);
1087  invert = pb2->invertedAppearance;
1088  bottomToTop = pb2->bottomToTop;
1089  }
1090  if (vertical) {
1091  QTransform m;
1092  rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height
1093  if (bottomToTop) {
1094  m.translate(0.0, rect.width());
1095  m.rotate(-90);
1096  } else {
1097  m.translate(rect.height(), 0.0);
1098  m.rotate(90);
1099  }
1100  p->setTransform(m, true);
1101  }
1102  const int unit_width = proxy()->pixelMetric(PM_ProgressBarChunkWidth, opt, widget);
1103  int u = rect.width() / unit_width;
1104  int p_v = pb->progress - pb->minimum;
1105  int t_s = qMax(0, pb->maximum - pb->minimum);
1106  if (u > 0 && pb->progress >= INT_MAX / u && t_s >= u) {
1107  // scale down to something usable.
1108  p_v /= u;
1109  t_s /= u;
1110  }
1111  if (pb->textVisible && t_s) {
1112  int nu = (u * p_v + t_s/2) / t_s;
1113  int x = unit_width * nu;
1114  QRect left(rect.x(), rect.y(), x, rect.height());
1115  QRect right(rect.x() + x, rect.y(), rect.width() - x, rect.height());
1116  Qt::LayoutDirection dir;
1117  dir = vertical ? (bottomToTop ? Qt::LeftToRight : Qt::RightToLeft) : pb->direction;
1118  if (invert)
1119  dir = (dir == Qt::LeftToRight) ? Qt::RightToLeft : Qt::LeftToRight;
1120  const QRect highlighted = visualRect(dir, rect, left);
1121  const QRect background = visualRect(dir, rect, right);
1122  p->setPen(opt->palette.highlightedText().color());
1123  p->setClipRect(highlighted);
1124  p->drawText(rect, Qt::AlignCenter | Qt::TextSingleLine, pb->text);
1125 
1126  if (pb->progress != pb->maximum) {
1127  p->setClipRect(background);
1128  p->setPen(opt->palette.highlight().color());
1129  p->drawText(rect, Qt::AlignCenter | Qt::TextSingleLine, pb->text);
1130  }
1131  }
1132  p->setTransform(oldMatrix, false);
1133  break;
1134  }
1135 
1136  case CE_MenuTearoff: {
1137  if(opt->state & State_Selected) {
1138  if(pixelMetric(PM_MenuPanelWidth, opt, widget) > 1)
1139  qDrawShadePanel(p, opt->rect.x(), opt->rect.y(), opt->rect.width(),
1140  opt->rect.height(), opt->palette, false, motifItemFrame,
1141  &opt->palette.brush(QPalette::Button));
1142  else
1143  qDrawShadePanel(p, opt->rect.x()+1, opt->rect.y()+1, opt->rect.width()-2,
1144  opt->rect.height()-2, opt->palette, true, 1, &opt->palette.brush(QPalette::Button));
1145  } else {
1146  p->fillRect(opt->rect, opt->palette.brush(QPalette::Button));
1147  }
1148  p->setPen(QPen(opt->palette.dark().color(), 1, Qt::DashLine));
1149  p->drawLine(opt->rect.x()+2, opt->rect.y()+opt->rect.height()/2-1, opt->rect.x()+opt->rect.width()-4,
1150  opt->rect.y()+opt->rect.height()/2-1);
1151  p->setPen(QPen(opt->palette.light().color(), 1, Qt::DashLine));
1152  p->drawLine(opt->rect.x()+2, opt->rect.y()+opt->rect.height()/2, opt->rect.x()+opt->rect.width()-4,
1153  opt->rect.y()+opt->rect.height()/2);
1154  break; }
1155 
1156  case CE_MenuItem:
1157  if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
1158  int maxpmw = menuitem->maxIconWidth;
1159  if(menuitem->menuHasCheckableItems)
1160  maxpmw = qMax(maxpmw, motifCheckMarkSpace);
1161 
1162  int x, y, w, h;
1163  opt->rect.getRect(&x, &y, &w, &h);
1164 
1165  if (menuitem->menuItemType == QStyleOptionMenuItem::Separator) { // draw separator
1166  int textWidth = 0;
1167  if (!menuitem->text.isEmpty()) {
1168  QFont oldFont = p->font();
1169  p->setFont(menuitem->font);
1170  p->fillRect(x, y, w, h, opt->palette.brush(QPalette::Button));
1171  proxy()->drawItemText(p, menuitem->rect.adjusted(10, 0, -5, 0), Qt::AlignLeft | Qt::AlignVCenter,
1172  menuitem->palette, menuitem->state & State_Enabled, menuitem->text,
1173  QPalette::Text);
1174  textWidth = menuitem->fontMetrics.width(menuitem->text) + 10;
1175  y += menuitem->fontMetrics.height() / 2;
1176  p->setFont(oldFont);
1177  }
1178  p->setPen(opt->palette.dark().color());
1179  p->drawLine(x, y, x + 5, y);
1180  p->drawLine(x + 5 + textWidth, y, x+w, y);
1181  p->setPen(opt->palette.light().color());
1182  p->drawLine(x, y + 1, x + 5, y + 1);
1183  p->drawLine(x + 5 + textWidth, y + 1, x+w, y + 1);
1184  return;
1185  }
1186 
1187  int pw = motifItemFrame;
1188  if((opt->state & State_Selected) && (opt->state & State_Enabled)) { // active item frame
1189  if(pixelMetric(PM_MenuPanelWidth, opt) > 1)
1190  qDrawShadePanel(p, x, y, w, h, opt->palette, false, pw,
1191  &opt->palette.brush(QPalette::Button));
1192  else
1193  qDrawShadePanel(p, x+1, y+1, w-2, h-2, opt->palette, true, 1,
1194  &opt->palette.brush(QPalette::Button));
1195  } else { // incognito frame
1196  p->fillRect(x, y, w, h, opt->palette.brush(QPalette::Button));
1197  }
1198 
1199  QRect vrect = visualRect(opt->direction, opt->rect,
1200  QRect(x+motifItemFrame, y+motifItemFrame, maxpmw,
1201  h-2*motifItemFrame));
1202  int xvis = vrect.x();
1203  if (menuitem->checked) {
1204  if(!menuitem->icon.isNull())
1205  qDrawShadePanel(p, xvis, y+motifItemFrame, maxpmw, h-2*motifItemFrame,
1206  opt->palette, true, 1, &opt->palette.brush(QPalette::Midlight));
1207  } else if (!(opt->state & State_Selected)) {
1208  p->fillRect(xvis, y+motifItemFrame, maxpmw, h-2*motifItemFrame,
1210  }
1211 
1212  if(!menuitem->icon.isNull()) { // draw icon
1213  QIcon::Mode mode = QIcon::Normal; // no disabled icons in Motif
1214  if ((opt->state & State_Selected) && !!(opt->state & State_Enabled))
1215  mode = QIcon::Active;
1216  QPixmap pixmap;
1217  if (menuitem->checkType != QStyleOptionMenuItem::NotCheckable && menuitem->checked)
1218  pixmap = menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize, opt, widget), mode, QIcon::On);
1219  else
1220  pixmap = menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize, opt, widget), mode);
1221 
1222  int pixw = pixmap.width();
1223  int pixh = pixmap.height();
1224  QRect pmr(0, 0, pixw, pixh);
1225  pmr.moveCenter(vrect.center());
1226  p->setPen(opt->palette.text().color());
1227  p->drawPixmap(pmr.topLeft(), pixmap);
1228 
1229  } else if (menuitem->checkType != QStyleOptionMenuItem::NotCheckable) { // just "checking"...
1230  int mh = h - 2*motifItemFrame;
1231 
1232  QStyleOptionButton newMenuItem;
1233  newMenuItem.state = menuitem->checked ? State_On : State_None;
1234  if (opt->state & State_Enabled) {
1235  newMenuItem.state |= State_Enabled;
1236  if (menuitem->state & State_Sunken)
1237  newMenuItem.state |= State_Sunken;
1238  }
1239  if (menuitem->checkType & QStyleOptionMenuItem::Exclusive) {
1240  newMenuItem.rect.setRect(xvis + 2, y + motifItemFrame + mh / 4, 11, 11);
1241  proxy()->drawPrimitive(PE_IndicatorRadioButton, &newMenuItem, p, widget);
1242  } else {
1243  newMenuItem.rect.setRect(xvis + 5, y + motifItemFrame + mh / 4, 9, 9);
1244  proxy()->drawPrimitive(PE_IndicatorCheckBox, &newMenuItem, p, widget);
1245  }
1246  }
1247 
1248  p->setPen(opt->palette.buttonText().color());
1249 
1250  QColor discol;
1251  if (!(opt->state & State_Enabled)) {
1252  discol = opt->palette.text().color();
1253  p->setPen(discol);
1254  }
1255 
1256  int xm = motifItemFrame + maxpmw + motifItemHMargin;
1257 
1258  vrect = visualRect(opt->direction, opt->rect,
1259  QRect(x+xm, y+motifItemVMargin, w-xm-menuitem->tabWidth,
1260  h-2*motifItemVMargin));
1261  xvis = vrect.x();
1262 
1263  QString s = menuitem->text;
1264  if (!s.isNull()) { // draw text
1265  int t = s.indexOf(QLatin1Char('\t'));
1266  int m = motifItemVMargin;
1268  text_flags |= Qt::AlignLeft;
1269  QFont oldFont = p->font();
1270  p->setFont(menuitem->font);
1271  if (t >= 0) { // draw tab text
1272  QRect vr = visualRect(opt->direction, opt->rect,
1273  QRect(x+w-menuitem->tabWidth-motifItemHMargin-motifItemFrame,
1274  y+motifItemVMargin, menuitem->tabWidth,
1275  h-2*motifItemVMargin));
1276  int xv = vr.x();
1277  QRect tr(xv, y+m, menuitem->tabWidth, h-2*m);
1278  p->drawText(tr, text_flags, s.mid(t+1));
1281  s = s.left(t);
1282  }
1283  QRect tr(xvis, y+m, w - xm - menuitem->tabWidth + 1, h-2*m);
1284  p->drawText(tr, text_flags, s.left(t));
1285  p->setFont(oldFont);
1288  }
1289  if (menuitem->menuItemType == QStyleOptionMenuItem::SubMenu) { // draw sub menu arrow
1290  int dim = (h-2*motifItemFrame) / 2;
1292  QStyleOption arrowOpt = *opt;
1293  arrowOpt.rect = visualRect(opt->direction, opt->rect,
1294  QRect(x+w - motifArrowHMargin - motifItemFrame - dim,
1295  y+h/2-dim/2, dim, dim));
1296  if ((opt->state & State_Selected))
1297  arrowOpt.state = (State_Sunken | ((opt->state & State_Enabled) ? State_Enabled : State_None));
1298  else
1299  arrowOpt.state = ((opt->state & State_Enabled) ? State_Enabled : State_None);
1300  proxy()->drawPrimitive(arrow, &arrowOpt, p, widget);
1301  }
1302  break; }
1303 
1304  case CE_MenuBarItem:
1305  if (opt->state & State_Selected) // active item
1306  qDrawShadePanel(p, opt->rect, opt->palette, false, motifItemFrame,
1307  &opt->palette.brush(QPalette::Button));
1308  else // other item
1309  p->fillRect(opt->rect, opt->palette.brush(QPalette::Button));
1310  QCommonStyle::drawControl(element, opt, p, widget);
1311  break;
1312 
1313  case CE_HeaderSection:
1314  p->save();
1315  p->setBrushOrigin(opt->rect.topLeft());
1316  qDrawShadePanel(p, opt->rect, opt->palette, bool(opt->state & (State_Sunken|State_On)),
1319  p->restore();
1320  break;
1321  case CE_RubberBand: {
1322  QPixmap tiledPixmap(16, 16);
1323  QPainter pixmapPainter(&tiledPixmap);
1324  pixmapPainter.setPen(Qt::NoPen);
1325  pixmapPainter.setBrush(Qt::Dense4Pattern);
1326  pixmapPainter.setBackground(QBrush(opt->palette.base()));
1327  pixmapPainter.setBackgroundMode(Qt::OpaqueMode);
1328  pixmapPainter.drawRect(0, 0, tiledPixmap.width(), tiledPixmap.height());
1329  pixmapPainter.end();
1330  // ### workaround for borked XRENDER
1331  tiledPixmap = QPixmap::fromImage(tiledPixmap.toImage());
1332 
1333  p->save();
1334  QRect r = opt->rect;
1335  QStyleHintReturnMask mask;
1336  if (styleHint(QStyle::SH_RubberBand_Mask, opt, widget, &mask))
1337  p->setClipRegion(mask.region);
1338  p->drawTiledPixmap(r.x(), r.y(), r.width(), r.height(), tiledPixmap);
1339  p->restore();
1340  }
1341  break;
1342 #ifndef QT_NO_PROGRESSBAR
1344  if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
1345  QRect rect = pb->rect;
1346  bool vertical = false;
1347  bool inverted = false;
1348 
1349  // Get extra style options if version 2
1351  if (pb2) {
1352  vertical = (pb2->orientation == Qt::Vertical);
1353  inverted = pb2->invertedAppearance;
1354  }
1355 
1356  QTransform m;
1357  if (vertical) {
1358  rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height
1359  m.rotate(90);
1360  m.translate(0, -(rect.height() + rect.y()*2));
1361  }
1362 
1363  QPalette pal2 = pb->palette;
1364  // Correct the highlight color if it is the same as the background
1365  if (pal2.highlight() == pal2.background())
1366  pal2.setColor(QPalette::Highlight, pb->palette.color(QPalette::Active,
1368  bool reverse = ((!vertical && (pb->direction == Qt::RightToLeft)) || vertical);
1369  if (inverted)
1370  reverse = !reverse;
1371  int w = rect.width();
1372  if (pb->minimum == 0 && pb->maximum == 0) {
1373  QRect progressBar;
1374  Q_D(const QMotifStyle);
1375  // draw busy indicator
1376  int x = (d->animateStep*8)% (w * 2);
1377  if (x > w)
1378  x = 2 * w - x;
1379  x = reverse ? rect.right() - x : x + rect.x();
1380  p->setTransform(m, true);
1381  p->setPen(QPen(pal2.highlight().color(), 4));
1382  p->drawLine(x, rect.y(), x, rect.height());
1383 
1384  } else
1385  QCommonStyle::drawControl(element, opt, p, widget);
1386  }
1387  break;
1388 #endif // QT_NO_PROGRESSBAR
1389  default:
1390  QCommonStyle::drawControl(element, opt, p, widget);
1391  break; }
1392 }
1393 
1394 static int get_combo_extra_width(int h, int w, int *return_awh=0)
1395 {
1396  int awh,
1397  tmp;
1398  if (h < 8) {
1399  awh = 6;
1400  } else if (h < 14) {
1401  awh = h - 2;
1402  } else {
1403  awh = h/2;
1404  }
1405  tmp = (awh * 3) / 2;
1406  if (tmp > w / 2) {
1407  awh = w / 2 - 3;
1408  tmp = w / 2 + 3;
1409  }
1410 
1411  if (return_awh)
1412  *return_awh = awh;
1413 
1414  return tmp;
1415 }
1416 
1417 static void get_combo_parameters(const QRect &r,
1418  int &ew, int &awh, int &ax,
1419  int &ay, int &sh, int &dh,
1420  int &sy)
1421 {
1422  ew = get_combo_extra_width(r.height(), r.width(), &awh);
1423 
1424  sh = (awh+3)/4;
1425  if (sh < 3)
1426  sh = 3;
1427  dh = sh/2 + 1;
1428 
1429  ay = r.y() + (r.height()-awh-sh-dh)/2;
1430  if (ay < 0) {
1431  //panic mode
1432  ay = 0;
1433  sy = r.height();
1434  } else {
1435  sy = ay+awh+dh;
1436  }
1437  ax = r.x() + r.width() - ew;
1438  ax += (ew-awh)/2;
1439 }
1440 
1445  const QWidget *widget) const
1446 {
1447  switch (cc) {
1448  case CC_ToolButton:
1449  if (const QStyleOptionToolButton *toolbutton
1450  = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
1451  QRect button, menuarea;
1452  button = proxy()->subControlRect(cc, toolbutton, SC_ToolButton, widget);
1453  menuarea = proxy()->subControlRect(cc, toolbutton, SC_ToolButtonMenu, widget);
1454 
1455  State bflags = toolbutton->state & ~State_Sunken;
1456  if (bflags & State_AutoRaise) {
1457  if (!(bflags & State_MouseOver) || !(bflags & State_Enabled)) {
1458  bflags &= ~State_Raised;
1459  }
1460  }
1461  State mflags = bflags;
1462  if (toolbutton->state & State_Sunken) {
1463  if (toolbutton->activeSubControls & SC_ToolButton)
1464  bflags |= State_Sunken;
1465  mflags |= State_Sunken;
1466  }
1467 
1468  QStyleOption tool(0);
1469  tool.palette = toolbutton->palette;
1470  if (toolbutton->subControls & SC_ToolButton) {
1471  if (bflags & (State_Sunken | State_On | State_Raised)) {
1472  tool.rect = button;
1473  tool.state = bflags;
1474  proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget);
1475  }
1476  }
1477 
1478  if ((toolbutton->state & State_HasFocus) && (!focus || !focus->isVisible())) {
1480  fr.QStyleOption::operator=(*toolbutton);
1481  fr.rect = toolbutton->rect.adjusted(3, 3, -3, -3);
1482  proxy()->drawPrimitive(PE_FrameFocusRect, &fr, p, widget);
1483  }
1484  QStyleOptionToolButton label = *toolbutton;
1485  label.state = bflags;
1486  int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget);
1487  label.rect = button.adjusted(fw, fw, -fw, -fw);
1488  proxy()->drawControl(CE_ToolButtonLabel, &label, p, widget);
1489 
1490  if (toolbutton->subControls & SC_ToolButtonMenu) {
1491  tool.rect = menuarea;
1492  tool.state = mflags;
1493  if (mflags & (State_Sunken | State_On | State_Raised))
1494  proxy()->drawPrimitive(PE_IndicatorButtonDropDown, &tool, p, widget);
1495  proxy()->drawPrimitive(PE_IndicatorArrowDown, &tool, p, widget);
1496  } else if (toolbutton->features & QStyleOptionToolButton::HasMenu) {
1497  int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, toolbutton, widget);
1498  QRect ir = toolbutton->rect;
1499  QStyleOptionToolButton newBtn = *toolbutton;
1500  newBtn.rect = QRect(ir.right() + 5 - mbi, ir.height() - mbi + 4, mbi - 6, mbi - 6);
1501  proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget);
1502  }
1503  }
1504  break;
1505 #ifndef QT_NO_SPINBOX
1506  case CC_SpinBox:
1507  if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
1508  QStyleOptionSpinBox copy = *spinbox;
1509  PrimitiveElement pe;
1510 
1511  if (spinbox->frame && (spinbox->subControls & SC_SpinBoxFrame)) {
1512  QRect r = proxy()->subControlRect(CC_SpinBox, spinbox, SC_SpinBoxFrame, widget);
1514 
1516  r = proxy()->subControlRect(CC_SpinBox, spinbox, SC_SpinBoxEditField, widget).adjusted(-fw,-fw,fw,fw);
1517  QStyleOptionFrame lineOpt;
1518  lineOpt.QStyleOption::operator=(*opt);
1519  lineOpt.rect = r;
1520  lineOpt.lineWidth = fw;
1521  lineOpt.midLineWidth = 0;
1522  lineOpt.state |= QStyle::State_Sunken;
1523  proxy()->drawPrimitive(QStyle::PE_FrameLineEdit, &lineOpt, p, widget);
1524  }
1525 
1526  if (spinbox->subControls & SC_SpinBoxUp) {
1527  copy.subControls = SC_SpinBoxUp;
1528  QPalette pal2 = spinbox->palette;
1529  if (!(spinbox->stepEnabled & QAbstractSpinBox::StepUpEnabled)) {
1531  copy.state &= ~State_Enabled;
1532  }
1533 
1534  copy.palette = pal2;
1535 
1536  if (spinbox->activeSubControls == SC_SpinBoxUp && (spinbox->state & State_Sunken)) {
1537  copy.state |= State_On;
1538  copy.state |= State_Sunken;
1539  } else {
1540  copy.state |= State_Raised;
1541  copy.state &= ~State_Sunken;
1542  }
1543  pe = (spinbox->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus
1544  : PE_IndicatorSpinUp);
1545 
1546  copy.rect = proxy()->subControlRect(CC_SpinBox, spinbox, SC_SpinBoxUp, widget);
1547  proxy()->drawPrimitive(pe, &copy, p, widget);
1548  }
1549 
1550  if (spinbox->subControls & SC_SpinBoxDown) {
1551  copy.subControls = SC_SpinBoxDown;
1552  copy.state = spinbox->state;
1553  QPalette pal2 = spinbox->palette;
1554  if (!(spinbox->stepEnabled & QAbstractSpinBox::StepDownEnabled)) {
1556  copy.state &= ~State_Enabled;
1557  }
1558  copy.palette = pal2;
1559 
1560  if (spinbox->activeSubControls == SC_SpinBoxDown && (spinbox->state & State_Sunken)) {
1561  copy.state |= State_On;
1562  copy.state |= State_Sunken;
1563  } else {
1564  copy.state |= State_Raised;
1565  copy.state &= ~State_Sunken;
1566  }
1567  pe = (spinbox->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus
1569 
1570  copy.rect = proxy()->subControlRect(CC_SpinBox, spinbox, SC_SpinBoxDown, widget);
1571  proxy()->drawPrimitive(pe, &copy, p, widget);
1572  }
1573  }
1574  break;
1575 #endif // QT_NO_SPINBOX
1576 #ifndef QT_NO_SLIDER
1577  case CC_Slider:
1578  if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
1579  QRect groove = proxy()->subControlRect(CC_Slider, opt, SC_SliderGroove, widget),
1580  handle = proxy()->subControlRect(CC_Slider, opt, SC_SliderHandle, widget);
1581 
1582  if ((opt->subControls & SC_SliderGroove) && groove.isValid()) {
1583  qDrawShadePanel(p, groove, opt->palette, true, proxy()->pixelMetric(PM_DefaultFrameWidth),
1585  if ((opt->state & State_HasFocus) && (!focus || !focus->isVisible())) {
1586  QStyleOption focusOpt = *opt;
1587  focusOpt.rect = subElementRect(SE_SliderFocusRect, opt, widget);
1588  proxy()->drawPrimitive(PE_FrameFocusRect, &focusOpt, p, widget);
1589  }
1590  }
1591 
1592  if ((opt->subControls & SC_SliderHandle) && handle.isValid()) {
1593  QStyleOption bevelOpt = *opt;
1594  bevelOpt.state = (opt->state | State_Raised) & ~State_Sunken;
1595  bevelOpt.rect = handle;
1596  p->save();
1597  p->setBrushOrigin(bevelOpt.rect.topLeft());
1598  proxy()->drawPrimitive(PE_PanelButtonBevel, &bevelOpt, p, widget);
1599  p->restore();
1600 
1601  if (slider->orientation == Qt::Horizontal) {
1602  int mid = handle.x() + handle.width() / 2;
1603  qDrawShadeLine(p, mid, handle.y(), mid, handle.y() + handle.height() - 2,
1604  opt->palette, true, 1);
1605  } else {
1606  int mid = handle.y() + handle.height() / 2;
1607  qDrawShadeLine(p, handle.x(), mid, handle.x() + handle.width() - 2, mid, opt->palette,
1608  true, 1);
1609  }
1611  p->fillRect(handle, QBrush(p->background().color(), Qt::Dense5Pattern));
1612  }
1613 
1614  if (slider->subControls & SC_SliderTickmarks) {
1615  QStyleOptionSlider tmpSlider = *slider;
1616  tmpSlider.subControls = SC_SliderTickmarks;
1617  int frameWidth = proxy()->pixelMetric(PM_DefaultFrameWidth);
1618  tmpSlider.rect.translate(frameWidth - 1, 0);
1619  QCommonStyle::drawComplexControl(cc, &tmpSlider, p, widget);
1620  }
1621  }
1622  break;
1623 #endif // QT_NO_SLIDER
1624  case CC_ComboBox:
1625  if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
1626  if (opt->subControls & SC_ComboBoxArrow) {
1627  int awh, ax, ay, sh, sy, dh, ew;
1628  int fw = cb->frame ? proxy()->pixelMetric(PM_ComboBoxFrameWidth, opt, widget) : 0;
1629 
1630  if (cb->frame) {
1631  QStyleOptionButton btn;
1632  btn.QStyleOption::operator=(*cb);
1633  btn.state |= QStyle::State_Raised;
1634  proxy()->drawPrimitive(PE_PanelButtonCommand, &btn, p, widget);
1635  } else {
1636  p->fillRect(opt->rect, opt->palette.brush(QPalette::Button));
1637  }
1638 
1639  QRect tr = opt->rect;
1640  tr.adjust(fw, fw, -fw, -fw);
1641  get_combo_parameters(tr, ew, awh, ax, ay, sh, dh, sy);
1642 
1643  QRect ar = QStyle::visualRect(opt->direction, opt->rect, QRect(ax,ay,awh,awh));
1644 
1645  QStyleOption arrowOpt = *opt;
1646  arrowOpt.rect = ar;
1647  arrowOpt.state |= State_Enabled;
1648  proxy()->drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget);
1649 
1650 
1651  // draws the shaded line under the arrow
1652  p->setPen(opt->palette.light().color());
1653  p->drawLine(ar.x(), sy, ar.x()+awh-1, sy);
1654  p->drawLine(ar.x(), sy, ar.x(), sy+sh-1);
1655  p->setPen(opt->palette.dark().color());
1656  p->drawLine(ar.x()+1, sy+sh-1, ar.x()+awh-1, sy+sh-1);
1657  p->drawLine(ar.x()+awh-1, sy+1, ar.x()+awh-1, sy+sh-1);
1658 
1659  if ((cb->state & State_HasFocus) && (!focus || !focus->isVisible())) {
1661  focus.QStyleOption::operator=(*opt);
1662  focus.rect = subElementRect(SE_ComboBoxFocusRect, opt, widget);
1663  focus.backgroundColor = opt->palette.button().color();
1664  proxy()->drawPrimitive(PE_FrameFocusRect, &focus, p, widget);
1665  }
1666  }
1667 
1668  if (opt->subControls & SC_ComboBoxEditField) {
1669  if (cb->editable) {
1671  er.adjust(-1, -1, 1, 1);
1672  qDrawShadePanel(p, er, opt->palette, true, 1,
1673  &opt->palette.brush(QPalette::Base));
1674  }
1675  }
1676  p->setPen(opt->palette.buttonText().color());
1677  }
1678  break;
1679 
1680 #ifndef QT_NO_SCROLLBAR
1681  case CC_ScrollBar: {
1682  if (opt->subControls & SC_ScrollBarGroove)
1683  qDrawShadePanel(p, opt->rect, opt->palette, true,
1684  proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget),
1686 
1687  if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
1688  QStyleOptionSlider newScrollbar = *scrollbar;
1689  if (scrollbar->minimum == scrollbar->maximum)
1690  newScrollbar.state |= State_Enabled; // make sure that the slider is drawn.
1691  QCommonStyle::drawComplexControl(cc, &newScrollbar, p, widget);
1692  }
1693  break; }
1694 #endif
1695 
1696  case CC_Q3ListView:
1698  int i;
1699  if (opt->subControls & SC_Q3ListView)
1700  QCommonStyle::drawComplexControl(cc, opt, p, widget);
1701  if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) {
1702  QStyleOptionQ3ListViewItem item = lv->items.at(0);
1703  int y = opt->rect.y();
1704  int c;
1705  QPolygon dotlines;
1706  if ((opt->activeSubControls & SC_All) && (opt->subControls & SC_Q3ListViewExpand)) {
1707  c = 2;
1708  dotlines.resize(2);
1709  dotlines[0] = QPoint(opt->rect.right(), opt->rect.top());
1710  dotlines[1] = QPoint(opt->rect.right(), opt->rect.bottom());
1711  } else {
1712  int linetop = 0, linebot = 0;
1713  // each branch needs at most two lines, ie. four end points
1714  dotlines.resize(item.childCount * 4);
1715  c = 0;
1716 
1717  // skip the stuff above the exposed rectangle
1718  for (i = 1; i < lv->items.size(); ++i) {
1719  QStyleOptionQ3ListViewItem child = lv->items.at(i);
1720  if (child.height + y > 0)
1721  break;
1722  y += child.totalHeight;
1723  }
1724 
1725  int bx = opt->rect.width() / 2;
1726 
1727  // paint stuff in the magical area
1728  while (i < lv->items.size() && y < lv->rect.height()) {
1729  QStyleOptionQ3ListViewItem child = lv->items.at(i);
1731  int lh;
1733  lh = child.height;
1734  else
1735  lh = p->fontMetrics().height() + 2 * lv->itemMargin;
1736  lh = qMax(lh, QApplication::globalStrut().height());
1737  if (lh % 2 > 0)
1738  lh++;
1739  linebot = y + lh/2;
1740  if ((child.features & QStyleOptionQ3ListViewItem::Expandable || child.childCount > 0) &&
1741  child.height > 0) {
1742  // needs a box
1743  p->setPen(opt->palette.text().color());
1744  p->drawRect(bx-4, linebot-4, 9, 9);
1745  QPolygon a;
1746  if ((child.state & State_Open))
1747  a.setPoints(3, bx-2, linebot-2,
1748  bx, linebot+2,
1749  bx+2, linebot-2); //Qt::RightArrow
1750  else
1751  a.setPoints(3, bx-2, linebot-2,
1752  bx+2, linebot,
1753  bx-2, linebot+2); //Qt::DownArrow
1754  p->setBrush(opt->palette.text());
1755  p->drawPolygon(a);
1756  p->setBrush(Qt::NoBrush);
1757  // dotlinery
1758  dotlines[c++] = QPoint(bx, linetop);
1759  dotlines[c++] = QPoint(bx, linebot - 5);
1760  dotlines[c++] = QPoint(bx + 5, linebot);
1761  dotlines[c++] = QPoint(opt->rect.width(), linebot);
1762  linetop = linebot + 5;
1763  } else {
1764  // just dotlinery
1765  dotlines[c++] = QPoint(bx+1, linebot);
1766  dotlines[c++] = QPoint(opt->rect.width(), linebot);
1767  }
1768  y += child.totalHeight;
1769  }
1770  ++i;
1771  }
1772 
1773  // Expand line height to edge of rectangle if there's any
1774  // visible child below
1775  while (i < lv->items.size() && lv->items.at(i).height <= 0)
1776  ++i;
1777  if (i < lv->items.size())
1778  linebot = opt->rect.height();
1779 
1780  if (linetop < linebot) {
1781  dotlines[c++] = QPoint(bx, linetop);
1782  dotlines[c++] = QPoint(bx, linebot);
1783  }
1784  }
1785 
1786  int line; // index into dotlines
1787  p->setPen(opt->palette.text().color());
1788  if (opt->subControls & SC_Q3ListViewBranch) for(line = 0; line < c; line += 2) {
1789  p->drawLine(dotlines[line].x(), dotlines[line].y(),
1790  dotlines[line+1].x(), dotlines[line+1].y());
1791  }
1792  }
1793  break; }
1794 
1795  default:
1796  QCommonStyle::drawComplexControl(cc, opt, p, widget);
1797  break;
1798  }
1799 }
1800 
1801 
1804  const QWidget *widget) const
1805 {
1806  int ret = 0;
1807 
1808  switch(pm) {
1810  ret = 5;
1811  break;
1812 
1815  ret = 10;
1816  break;
1817 
1818  case PM_ToolBarFrameWidth:
1820  break;
1821 
1822  case PM_ToolBarItemMargin:
1823  ret = 1;
1824  break;
1825 
1828  ret = 0;
1829  break;
1830 
1831  case PM_SplitterWidth:
1832  ret = qMax(10, QApplication::globalStrut().width());
1833  break;
1834 
1835  case PM_SliderLength:
1836  ret = 30;
1837  break;
1838 
1839  case PM_SliderThickness:
1840  ret = 16 + 4 * proxy()->pixelMetric(PM_DefaultFrameWidth);
1841  break;
1842 #ifndef QT_NO_SLIDER
1844  if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
1845  int space = (sl->orientation == Qt::Horizontal) ? sl->rect.height() : sl->rect.width();
1846  int ticks = sl->tickPosition;
1847  int n = 0;
1848  if (ticks & QSlider::TicksAbove)
1849  n++;
1850  if (ticks & QSlider::TicksBelow)
1851  n++;
1852  if (!n) {
1853  ret = space;
1854  break;
1855  }
1856 
1857  int thick = 6; // Magic constant to get 5 + 16 + 5
1858 
1859  space -= thick;
1860  //### the two sides may be unequal in size
1861  if (space > 0)
1862  thick += (space * 2) / (n + 2);
1863  ret = thick;
1864  }
1865  break;
1866 
1868  if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
1869  if (sl->orientation == Qt::Horizontal)
1870  ret = sl->rect.width() - proxy()->pixelMetric(PM_SliderLength, opt, widget) - 2 * proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget);
1871  else
1872  ret = sl->rect.height() - proxy()->pixelMetric(PM_SliderLength, opt, widget) - 2 * proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget);
1873  }
1874  break;
1875 #endif // QT_NO_SLIDER
1877  ret = 2;
1878  break;
1879 
1881  ret = 9;
1882  break;
1883 
1885  ret = 1;
1886  break;
1887 
1890  ret = 13;
1891  break;
1892 
1893  case PM_MenuBarHMargin:
1894  ret = 2; // really ugly, but Motif
1895  break;
1896 
1898  if (!opt)
1899  ret = 12;
1900  else
1901  ret = qMax(12, (opt->rect.height() - 4) / 3);
1902  break;
1903  default:
1904  ret = QCommonStyle::pixelMetric(pm, opt, widget);
1905  break;
1906  }
1907  return ret;
1908 }
1909 
1910 
1914 QRect
1916  SubControl sc, const QWidget *widget) const
1917 {
1918  switch (cc) {
1919 #ifndef QT_NO_SPINBOX
1920  case CC_SpinBox:
1921  if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
1922  int fw = spinbox->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0;
1923  QSize bs;
1924  bs.setHeight(opt->rect.height()/2 - fw);
1925  bs.setWidth(qMin(bs.height() * 8 / 5, opt->rect.width() / 4)); // 1.6 -approximate golden mean
1927  int y = fw + spinbox->rect.y();
1928  int x, lx, rx;
1929  x = spinbox->rect.x() + opt->rect.width() - fw - bs.width();
1930  lx = fw;
1931  rx = x - fw * 2;
1932  const int margin = spinbox->frame ? 4 : 0;
1933  switch (sc) {
1934  case SC_SpinBoxUp:
1935  if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
1936  return QRect();
1937  return visualRect(spinbox->direction, spinbox->rect,
1938  QRect(x, y, bs.width(), bs.height() - 1));
1939  case SC_SpinBoxDown:
1940  if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
1941  return QRect();
1942  return visualRect(spinbox->direction, spinbox->rect,
1943  QRect(x, y + bs.height() + 1, bs.width(), bs.height() - 1));
1944  case SC_SpinBoxEditField:
1945  if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
1946  return visualRect(spinbox->direction, spinbox->rect,
1947  QRect(lx + margin, y + margin,
1948  spinbox->rect.width() - 2*fw - 2*margin,
1949  spinbox->rect.height() - 2*fw - 2*margin));
1950 
1951  return visualRect(spinbox->direction, spinbox->rect,
1952  QRect(lx + margin, y + margin, rx - margin,
1953  spinbox->rect.height() - 2*fw - 2 * margin));
1954  case SC_SpinBoxFrame:
1955  return visualRect(spinbox->direction, spinbox->rect, spinbox->rect);
1956  default:
1957  break;
1958  }
1959  break; }
1960 #endif // QT_NO_SPINBOX
1961 #ifndef QT_NO_SLIDER
1962  case CC_Slider:
1963  if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
1964  if (sc == SC_SliderHandle) {
1965  int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, opt, widget);
1966  int thickness = proxy()->pixelMetric(PM_SliderControlThickness, opt, widget);
1967  bool horizontal = slider->orientation == Qt::Horizontal;
1968  int len = proxy()->pixelMetric(PM_SliderLength, opt, widget);
1969  int motifBorder = proxy()->pixelMetric(PM_DefaultFrameWidth);
1970  int sliderPos = sliderPositionFromValue(slider->minimum, slider->maximum, slider->sliderPosition,
1971  horizontal ? slider->rect.width() - len - 2 * motifBorder
1972  : slider->rect.height() - len - 2 * motifBorder,
1973  slider->upsideDown);
1974  if (horizontal)
1975  return visualRect(slider->direction, slider->rect,
1976  QRect(sliderPos + motifBorder, tickOffset + motifBorder, len,
1977  thickness - 2 * motifBorder));
1978  return visualRect(slider->direction, slider->rect,
1979  QRect(tickOffset + motifBorder, sliderPos + motifBorder,
1980  thickness - 2 * motifBorder, len));
1981  }
1982  }
1983  break;
1984 #endif // QT_NO_SLIDER
1985 #ifndef QT_NO_SCROLLBAR
1986  case CC_ScrollBar:
1987  if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
1988  int dfw = proxy()->pixelMetric(PM_DefaultFrameWidth);
1989  QRect rect = visualRect(scrollbar->direction, scrollbar->rect,
1990  QCommonStyle::subControlRect(cc, scrollbar, sc, widget));
1991  if (sc == SC_ScrollBarSlider) {
1992  if (scrollbar->orientation == Qt::Horizontal)
1993  rect.adjust(-dfw, dfw, dfw, -dfw);
1994  else
1995  rect.adjust(dfw, -dfw, -dfw, dfw);
1996  } else if (sc != SC_ScrollBarGroove) {
1997  if (scrollbar->orientation == Qt::Horizontal)
1998  rect.adjust(0, dfw, 0, -dfw);
1999  else
2000  rect.adjust(dfw, 0, -dfw, 0);
2001  }
2002  return visualRect(scrollbar->direction, scrollbar->rect, rect);
2003  }
2004  break;
2005 #endif // QT_NO_SCROLLBAR
2006 #ifndef QT_NO_COMBOBOX
2007  case CC_ComboBox:
2008  if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
2009  switch (sc) {
2010  case SC_ComboBoxArrow: {
2011  int ew, awh, sh, dh, ax, ay, sy;
2012  int fw = cb->frame ? proxy()->pixelMetric(PM_ComboBoxFrameWidth, opt, widget) : 0;
2013  QRect cr = opt->rect;
2014  cr.adjust(fw, fw, -fw, -fw);
2015  get_combo_parameters(cr, ew, awh, ax, ay, sh, dh, sy);
2016  return visualRect(cb->direction, cb->rect, QRect(QPoint(ax, ay), cr.bottomRight()));
2017  }
2018 
2019  case SC_ComboBoxEditField: {
2020  int fw = cb->frame ? proxy()->pixelMetric(PM_ComboBoxFrameWidth, opt, widget) : 0;
2021  QRect rect = opt->rect;
2022  rect.adjust(fw, fw, -fw, -fw);
2023  int ew = get_combo_extra_width(rect.height(), rect.width());
2024  rect.adjust(1, 1, -1-ew, -1);
2025  return visualRect(cb->direction, cb->rect, rect);
2026  }
2027 
2028  default:
2029  break;
2030  }
2031  }
2032  break;
2033 #endif // QT_NO_SCROLLBAR
2034  default:
2035  break;
2036  }
2037  return QCommonStyle::subControlRect(cc, opt, sc, widget);
2038 }
2039 
2043 QSize
2045  const QSize &contentsSize, const QWidget *widget) const
2046 {
2047  QSize sz(contentsSize);
2048 
2049  switch(ct) {
2050  case CT_RadioButton:
2051  case CT_CheckBox:
2052  sz = QCommonStyle::sizeFromContents(ct, opt, contentsSize, widget);
2053  sz.rwidth() += motifItemFrame;
2054  break;
2055 
2056  case CT_PushButton:
2057  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
2058  sz = QCommonStyle::sizeFromContents(ct, opt, contentsSize, widget);
2059  if (!btn->text.isEmpty() && (btn->features & (QStyleOptionButton::AutoDefaultButton|QStyleOptionButton::DefaultButton)))
2060  sz.setWidth(qMax(75, sz.width()));
2061  sz += QSize(0, 1); // magical extra pixel
2062  }
2063  break;
2064 
2065  case CT_MenuBarItem: {
2066  if(!sz.isEmpty())
2068  break; }
2069 
2070  case CT_MenuItem:
2071  if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
2072  sz = QCommonStyle::sizeFromContents(ct, opt, sz, widget);
2073  int w = sz.width(), h = sz.height();
2074 
2075  if (mi->menuItemType == QStyleOptionMenuItem::Separator) {
2076  w = 10;
2077  h = (mi->text.isEmpty()) ? motifSepHeight : mi->fontMetrics.height();
2078  }
2079 
2080  // a little bit of border can never harm
2081  w += 2*motifItemHMargin + 2*motifItemFrame;
2082 
2083  if (!mi->text.isNull() && mi->text.indexOf(QLatin1Char('\t')) >= 0)
2084  // string contains tab
2085  w += motifTabSpacing;
2086  else if (mi->menuItemType == QStyleOptionMenuItem::SubMenu)
2087  // submenu indicator needs some room if we don't have a tab column
2089 
2090  int checkColumn = mi->maxIconWidth;
2091  if (mi->menuHasCheckableItems)
2092  checkColumn = qMax(checkColumn, motifCheckMarkSpace);
2093  if (checkColumn > 0)
2094  w += checkColumn + motifCheckMarkHMargin;
2095 
2096  sz = QSize(w, h);
2097  }
2098  break;
2099 
2100 
2101  default:
2102  sz = QCommonStyle::sizeFromContents(ct, opt, contentsSize, widget);
2103  break;
2104  }
2105 
2106  return sz;
2107 }
2108 
2112 QRect
2114 {
2115  QRect rect;
2116 
2117  switch (sr) {
2118  case SE_SliderFocusRect:
2119  rect = QCommonStyle::subElementRect(sr, opt, widget);
2120  rect.adjust(2, 2, -2, -2);
2121  break;
2122 
2123  case SE_CheckBoxIndicator:
2125  {
2126  rect = visualRect(opt->direction, opt->rect,
2127  QCommonStyle::subElementRect(sr, opt, widget));
2129  rect = visualRect(opt->direction, opt->rect, rect);
2130  }
2131  break;
2132 
2133  case SE_ComboBoxFocusRect:
2134  {
2135  int awh, ax, ay, sh, sy, dh, ew;
2136  int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget);
2137  QRect tr = opt->rect;
2138 
2139  tr.adjust(fw, fw, -fw, -fw);
2140  get_combo_parameters(tr, ew, awh, ax, ay, sh, dh, sy);
2141  rect.setRect(ax-2, ay-2, awh+4, awh+sh+dh+4);
2142  break;
2143  }
2144 
2146  if (const QStyleOptionQ3DockWindow *dw = qstyleoption_cast<const QStyleOptionQ3DockWindow *>(opt)) {
2147  if (!dw->docked || !dw->closeEnabled)
2148  rect.setRect(0, 0, opt->rect.width(), opt->rect.height());
2149  else {
2150  if (dw->state == State_Horizontal)
2151  rect.setRect(2, 15, opt->rect.width()-2, opt->rect.height() - 15);
2152  else
2153  rect.setRect(0, 2, opt->rect.width() - 15, opt->rect.height() - 2);
2154  }
2155  rect = visualRect(dw->direction, dw->rect, rect);
2156  }
2157  break;
2158 
2159  case SE_ProgressBarLabel:
2160  case SE_ProgressBarGroove:
2162  if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
2163  int textw = 0;
2164  if (pb->textVisible)
2165  textw = pb->fontMetrics.width(QLatin1String("100%")) + 6;
2166 
2167  if (pb->textAlignment == Qt::AlignLeft || pb->textAlignment == Qt::AlignCenter) {
2168  rect = opt->rect;
2169  } else {
2170  if(sr == SE_ProgressBarLabel)
2171  rect.setCoords(opt->rect.right() - textw, opt->rect.top(),
2172  opt->rect.right(), opt->rect.bottom());
2173  else
2174  rect.setCoords(opt->rect.left(), opt->rect.top(),
2175  opt->rect.right() - textw, opt->rect.bottom());
2176  }
2177  if (sr == SE_ProgressBarContents)
2178  rect.adjust(2, 2, -2, -2);
2179  rect = visualRect(pb->direction, pb->rect, rect);
2180  }
2181  break;
2182  case SE_CheckBoxClickRect:
2184  rect = visualRect(opt->direction, opt->rect, opt->rect);
2185  break;
2186 
2187  default:
2188  rect = QCommonStyle::subElementRect(sr, opt, widget);
2189  }
2190  return rect;
2191 }
2192 
2193 #ifndef QT_NO_IMAGEFORMAT_XPM
2194 static const char * const qt_menu_xpm[] = {
2195 "16 16 11 1",
2196 " c #000000",
2197 ", c #336600",
2198 ". c #99CC00",
2199 "X c #666600",
2200 "o c #999933",
2201 "+ c #333300",
2202 "@ c #669900",
2203 "# c #999900",
2204 "$ c #336633",
2205 "% c #666633",
2206 "& c #99CC33",
2207 "................",
2208 "................",
2209 ".....#,++X#.....",
2210 "....X X....",
2211 "...X Xo#% X&..",
2212 "..# o..&@o o..",
2213 ".., X..#+ @X X..",
2214 "..+ o.o+ +o# +..",
2215 "..+ #o+ +## +..",
2216 ".., %@ ++ +, X..",
2217 "..# o@oo+ #..",
2218 "...X X##$ o..",
2219 "....X X..",
2220 "....&oX++X#oX...",
2221 "................",
2222 "................"};
2223 
2224 
2225 static const char * const qt_close_xpm[] = {
2226  "12 12 2 1",
2227  " s None c None",
2228  ". c black",
2229  " ",
2230  " ",
2231  " . . ",
2232  " ... ... ",
2233  " ...... ",
2234  " .... ",
2235  " .... ",
2236  " ...... ",
2237  " ... ... ",
2238  " . . ",
2239  " ",
2240  " "};
2241 
2242 static const char * const qt_maximize_xpm[] = {
2243  "12 12 2 1",
2244  " s None c None",
2245  ". c black",
2246  " ",
2247  " ",
2248  " ",
2249  " . ",
2250  " ... ",
2251  " ..... ",
2252  " ....... ",
2253  " ......... ",
2254  " ",
2255  " ",
2256  " ",
2257  " "};
2258 
2259 static const char * const qt_minimize_xpm[] = {
2260  "12 12 2 1",
2261  " s None c None",
2262  ". c black",
2263  " ",
2264  " ",
2265  " ",
2266  " ",
2267  " ......... ",
2268  " ....... ",
2269  " ..... ",
2270  " ... ",
2271  " . ",
2272  " ",
2273  " ",
2274  " "};
2275 
2276 #if 0 // ### not used???
2277 static const char * const qt_normalize_xpm[] = {
2278  "12 12 2 1",
2279  " s None c None",
2280  ". c black",
2281  " ",
2282  " ",
2283  " . ",
2284  " .. ",
2285  " ... ",
2286  " .... ",
2287  " ..... ",
2288  " ...... ",
2289  " ....... ",
2290  " ",
2291  " ",
2292  " "};
2293 #endif
2294 
2295 static const char * const qt_normalizeup_xpm[] = {
2296  "12 12 2 1",
2297  " s None c None",
2298  ". c black",
2299  " ",
2300  " ",
2301  " ",
2302  " ....... ",
2303  " ...... ",
2304  " ..... ",
2305  " .... ",
2306  " ... ",
2307  " .. ",
2308  " . ",
2309  " ",
2310  " "};
2311 
2312 static const char * const qt_shade_xpm[] = {
2313  "12 12 2 1", "# c #000000",
2314  ". c None",
2315  "............",
2316  "............",
2317  ".#########..",
2318  ".#########..",
2319  "............",
2320  "............",
2321  "............",
2322  "............",
2323  "............",
2324  "............",
2325  "............",
2326  "............"};
2327 
2328 
2329 static const char * const qt_unshade_xpm[] = {
2330  "12 12 2 1",
2331  "# c #000000",
2332  ". c None",
2333  "............",
2334  "............",
2335  ".#########..",
2336  ".#########..",
2337  ".#.......#..",
2338  ".#.......#..",
2339  ".#.......#..",
2340  ".#.......#..",
2341  ".#.......#..",
2342  ".#########..",
2343  "............",
2344  "............"};
2345 
2346 
2347 static const char * dock_window_close_xpm[] = {
2348  "8 8 2 1",
2349  "# c #000000",
2350  ". c None",
2351  "##....##",
2352  ".##..##.",
2353  "..####..",
2354  "...##...",
2355  "..####..",
2356  ".##..##.",
2357  "##....##",
2358  "........"};
2359 
2360 // Message box icons, from page 210 of the Windows style guide.
2361 
2362 // Hand-drawn to resemble Microsoft's icons, but in the Mac/Netscape palette.
2363 // Thanks to TrueColor displays, it is slightly more efficient to have
2364 // them duplicated.
2365 /* XPM */
2366 static const char * const information_xpm[]={
2367  "32 32 5 1",
2368  ". c None",
2369  "c c #000000",
2370  "* c #999999",
2371  "a c #ffffff",
2372  "b c #0000ff",
2373  "...........********.............",
2374  "........***aaaaaaaa***..........",
2375  "......**aaaaaaaaaaaaaa**........",
2376  ".....*aaaaaaaaaaaaaaaaaa*.......",
2377  "....*aaaaaaaabbbbaaaaaaaac......",
2378  "...*aaaaaaaabbbbbbaaaaaaaac.....",
2379  "..*aaaaaaaaabbbbbbaaaaaaaaac....",
2380  ".*aaaaaaaaaaabbbbaaaaaaaaaaac...",
2381  ".*aaaaaaaaaaaaaaaaaaaaaaaaaac*..",
2382  "*aaaaaaaaaaaaaaaaaaaaaaaaaaaac*.",
2383  "*aaaaaaaaaabbbbbbbaaaaaaaaaaac*.",
2384  "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
2385  "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
2386  "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
2387  "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
2388  "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
2389  ".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
2390  ".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
2391  "..*aaaaaaaaaabbbbbaaaaaaaaac***.",
2392  "...caaaaaaabbbbbbbbbaaaaaac****.",
2393  "....caaaaaaaaaaaaaaaaaaaac****..",
2394  ".....caaaaaaaaaaaaaaaaaac****...",
2395  "......ccaaaaaaaaaaaaaacc****....",
2396  ".......*cccaaaaaaaaccc*****.....",
2397  "........***cccaaaac*******......",
2398  "..........****caaac*****........",
2399  ".............*caaac**...........",
2400  "...............caac**...........",
2401  "................cac**...........",
2402  ".................cc**...........",
2403  "..................***...........",
2404  "...................**..........."};
2405 /* XPM */
2406 static const char* const warning_xpm[]={
2407  "32 32 4 1",
2408  ". c None",
2409  "a c #ffff00",
2410  "* c #000000",
2411  "b c #999999",
2412  ".............***................",
2413  "............*aaa*...............",
2414  "...........*aaaaa*b.............",
2415  "...........*aaaaa*bb............",
2416  "..........*aaaaaaa*bb...........",
2417  "..........*aaaaaaa*bb...........",
2418  ".........*aaaaaaaaa*bb..........",
2419  ".........*aaaaaaaaa*bb..........",
2420  "........*aaaaaaaaaaa*bb.........",
2421  "........*aaaa***aaaa*bb.........",
2422  ".......*aaaa*****aaaa*bb........",
2423  ".......*aaaa*****aaaa*bb........",
2424  "......*aaaaa*****aaaaa*bb.......",
2425  "......*aaaaa*****aaaaa*bb.......",
2426  ".....*aaaaaa*****aaaaaa*bb......",
2427  ".....*aaaaaa*****aaaaaa*bb......",
2428  "....*aaaaaaaa***aaaaaaaa*bb.....",
2429  "....*aaaaaaaa***aaaaaaaa*bb.....",
2430  "...*aaaaaaaaa***aaaaaaaaa*bb....",
2431  "...*aaaaaaaaaa*aaaaaaaaaa*bb....",
2432  "..*aaaaaaaaaaa*aaaaaaaaaaa*bb...",
2433  "..*aaaaaaaaaaaaaaaaaaaaaaa*bb...",
2434  ".*aaaaaaaaaaaa**aaaaaaaaaaa*bb..",
2435  ".*aaaaaaaaaaa****aaaaaaaaaa*bb..",
2436  "*aaaaaaaaaaaa****aaaaaaaaaaa*bb.",
2437  "*aaaaaaaaaaaaa**aaaaaaaaaaaa*bb.",
2438  "*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
2439  "*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
2440  ".*aaaaaaaaaaaaaaaaaaaaaaaaa*bbbb",
2441  "..*************************bbbbb",
2442  "....bbbbbbbbbbbbbbbbbbbbbbbbbbb.",
2443  ".....bbbbbbbbbbbbbbbbbbbbbbbbb.."};
2444 /* XPM */
2445 static const char* const critical_xpm[]={
2446  "32 32 4 1",
2447  ". c None",
2448  "a c #999999",
2449  "* c #ff0000",
2450  "b c #ffffff",
2451  "...........********.............",
2452  ".........************...........",
2453  ".......****************.........",
2454  "......******************........",
2455  ".....********************a......",
2456  "....**********************a.....",
2457  "...************************a....",
2458  "..*******b**********b*******a...",
2459  "..******bbb********bbb******a...",
2460  ".******bbbbb******bbbbb******a..",
2461  ".*******bbbbb****bbbbb*******a..",
2462  "*********bbbbb**bbbbb*********a.",
2463  "**********bbbbbbbbbb**********a.",
2464  "***********bbbbbbbb***********aa",
2465  "************bbbbbb************aa",
2466  "************bbbbbb************aa",
2467  "***********bbbbbbbb***********aa",
2468  "**********bbbbbbbbbb**********aa",
2469  "*********bbbbb**bbbbb*********aa",
2470  ".*******bbbbb****bbbbb*******aa.",
2471  ".******bbbbb******bbbbb******aa.",
2472  "..******bbb********bbb******aaa.",
2473  "..*******b**********b*******aa..",
2474  "...************************aaa..",
2475  "....**********************aaa...",
2476  "....a********************aaa....",
2477  ".....a******************aaa.....",
2478  "......a****************aaa......",
2479  ".......aa************aaaa.......",
2480  ".........aa********aaaaa........",
2481  "...........aaaaaaaaaaa..........",
2482  ".............aaaaaaa............"};
2483 /* XPM */
2484 static const char *const question_xpm[] = {
2485  "32 32 5 1",
2486  ". c None",
2487  "c c #000000",
2488  "* c #999999",
2489  "a c #ffffff",
2490  "b c #0000ff",
2491  "...........********.............",
2492  "........***aaaaaaaa***..........",
2493  "......**aaaaaaaaaaaaaa**........",
2494  ".....*aaaaaaaaaaaaaaaaaa*.......",
2495  "....*aaaaaaaaaaaaaaaaaaaac......",
2496  "...*aaaaaaaabbbbbbaaaaaaaac.....",
2497  "..*aaaaaaaabaaabbbbaaaaaaaac....",
2498  ".*aaaaaaaabbaaaabbbbaaaaaaaac...",
2499  ".*aaaaaaaabbbbaabbbbaaaaaaaac*..",
2500  "*aaaaaaaaabbbbaabbbbaaaaaaaaac*.",
2501  "*aaaaaaaaaabbaabbbbaaaaaaaaaac*.",
2502  "*aaaaaaaaaaaaabbbbaaaaaaaaaaac**",
2503  "*aaaaaaaaaaaaabbbaaaaaaaaaaaac**",
2504  "*aaaaaaaaaaaaabbaaaaaaaaaaaaac**",
2505  "*aaaaaaaaaaaaabbaaaaaaaaaaaaac**",
2506  "*aaaaaaaaaaaaaaaaaaaaaaaaaaaac**",
2507  ".*aaaaaaaaaaaabbaaaaaaaaaaaac***",
2508  ".*aaaaaaaaaaabbbbaaaaaaaaaaac***",
2509  "..*aaaaaaaaaabbbbaaaaaaaaaac***.",
2510  "...caaaaaaaaaabbaaaaaaaaaac****.",
2511  "....caaaaaaaaaaaaaaaaaaaac****..",
2512  ".....caaaaaaaaaaaaaaaaaac****...",
2513  "......ccaaaaaaaaaaaaaacc****....",
2514  ".......*cccaaaaaaaaccc*****.....",
2515  "........***cccaaaac*******......",
2516  "..........****caaac*****........",
2517  ".............*caaac**...........",
2518  "...............caac**...........",
2519  "................cac**...........",
2520  ".................cc**...........",
2521  "..................***...........",
2522  "...................**...........",
2523 };
2524 #endif
2525 
2529 QPixmap
2531  const QWidget *widget) const
2532 {
2533 #ifndef QT_NO_IMAGEFORMAT_XPM
2534  switch (standardPixmap) {
2535  case SP_TitleBarMenuButton:
2536  return QPixmap(qt_menu_xpm);
2538  return QPixmap(qt_shade_xpm);
2540  return QPixmap(qt_unshade_xpm);
2542  return QPixmap(qt_normalizeup_xpm);
2543  case SP_TitleBarMinButton:
2544  return QPixmap(qt_minimize_xpm);
2545  case SP_TitleBarMaxButton:
2546  return QPixmap(qt_maximize_xpm);
2548  return QPixmap(qt_close_xpm);
2550  return QPixmap(dock_window_close_xpm);
2551 
2553  case SP_MessageBoxWarning:
2554  case SP_MessageBoxCritical:
2555  case SP_MessageBoxQuestion:
2556  {
2557  const char * const * xpm_data;
2558  switch (standardPixmap) {
2560  xpm_data = information_xpm;
2561  break;
2562  case SP_MessageBoxWarning:
2563  xpm_data = warning_xpm;
2564  break;
2565  case SP_MessageBoxCritical:
2566  xpm_data = critical_xpm;
2567  break;
2568  case SP_MessageBoxQuestion:
2569  xpm_data = question_xpm;
2570  break;
2571  default:
2572  xpm_data = 0;
2573  break;
2574  }
2575  QPixmap pm;
2576  if (xpm_data) {
2577  QImage image((const char **) xpm_data);
2578  // All that color looks ugly in Motif
2579  const QPalette &pal = QApplication::palette();
2580  switch (standardPixmap) {
2582  case SP_MessageBoxQuestion:
2583  image.setColor(2, 0xff000000 |
2585  image.setColor(3, 0xff000000 |
2587  image.setColor(4, 0xff000000 |
2589  break;
2590  case SP_MessageBoxWarning:
2591  image.setColor(1, 0xff000000 |
2593  image.setColor(2, 0xff000000 |
2595  image.setColor(3, 0xff000000 |
2597  break;
2598  case SP_MessageBoxCritical:
2599  image.setColor(1, 0xff000000 |
2601  image.setColor(2, 0xff000000 |
2603  image.setColor(3, 0xff000000 |
2605  break;
2606  default:
2607  break;
2608  }
2609  pm = QPixmap::fromImage(image);
2610  }
2611  return pm;
2612  }
2613 
2614  default:
2615  break;
2616  }
2617 #endif
2618 
2619  return QCommonStyle::standardPixmap(standardPixmap, opt, widget);
2620 }
2621 
2624 {
2625  if(e->type() == QEvent::FocusIn) {
2626  if (QWidget *focusWidget = QApplication::focusWidget()) {
2627 #ifndef QT_NO_GRAPHICSVIEW
2628  if (QGraphicsView *graphicsView = qobject_cast<QGraphicsView *>(focusWidget)) {
2629  QGraphicsItem *focusItem = graphicsView->scene() ? graphicsView->scene()->focusItem() : 0;
2630  if (focusItem && focusItem->type() == QGraphicsProxyWidget::Type) {
2631  QGraphicsProxyWidget *proxy = static_cast<QGraphicsProxyWidget *>(focusItem);
2632  if (proxy->widget())
2633  focusWidget = proxy->widget()->focusWidget();
2634  }
2635  }
2636 #endif
2637  if(!focus)
2638  focus = new QFocusFrame(focusWidget);
2639  focus->setWidget(focusWidget);
2640  } else {
2641  if(focus)
2642  focus->setWidget(0);
2643  }
2644  } else if(e->type() == QEvent::FocusOut) {
2645  if(focus)
2646  focus->setWidget(0);
2647  }
2648  return QCommonStyle::event(e);
2649 }
2650 
2651 
2653 int
2655  QStyleHintReturn *returnData) const
2656 {
2657  int ret;
2658 
2659  switch (hint) {
2660 #ifdef QT3_SUPPORT
2661  case SH_GUIStyle:
2662  ret = Qt::MotifStyle;
2663  break;
2664 #endif
2666  ret = true;
2667  break;
2668 
2674  case SH_DitherDisabledText:
2675  ret = 1;
2676  break;
2677 
2679  ret = 96;
2680  break;
2681 
2684  break;
2685 
2687  ret = 0;
2688  break;
2689 
2691  ret = 1;
2692  break;
2693 
2695  ret = QPalette::Mid;
2696  break;
2697 
2698  case SH_DialogButtonLayout:
2700  break;
2702  ret = '*';
2703  break;
2705  ret = 0;
2706  break;
2707  default:
2708  ret = QCommonStyle::styleHint(hint, opt, widget, returnData);
2709  break;
2710  }
2711 
2712  return ret;
2713 }
2714 
2717 {
2718 #ifdef Q_WS_X11
2719  QColor background(0xcf, 0xcf, 0xcf);
2720  if (QX11Info::appDepth() <= 8)
2721  background = QColor(0xc0, 0xc0, 0xc0);
2722 #else
2723  QColor background = QColor(0xcf, 0xcf, 0xcf);
2724 #endif
2725 
2726  QColor light = background.lighter();
2727  QColor mid = QColor(0xa6, 0xa6, 0xa6);
2728  QColor dark = QColor(0x79, 0x7d, 0x79);
2729  QPalette palette(Qt::black, background, light, dark, mid, Qt::black, Qt::white);
2731  palette.setBrush(QPalette::Disabled, QPalette::Text, dark);
2733  palette.setBrush(QPalette::Disabled, QPalette::Base, background);
2734  return palette;
2735 }
2736 
2738 
2739 #endif // !defined(QT_NO_STYLE_MOTIF) || defined(QT_PLUGIN)
void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
int startTimer(int interval)
Starts a timer and returns a timer identifier, or returns zero if it could not start a timer...
Definition: qobject.cpp:1623
void setTransform(const QTransform &transform, bool combine=false)
Sets the world transformation matrix.
Definition: qpainter.cpp:9547
void setBackgroundMode(Qt::BGMode mode)
Sets the background mode of the painter to the given mode.
Definition: qpainter.cpp:3998
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
int height
the height of the item
Definition: qstyleoption.h:474
static const int motifCheckMarkHMargin
Definition: qmotifstyle.cpp:88
QImage toImage() const
Converts the pixmap to a QImage.
Definition: qpixmap.cpp:542
const QBrush & highlight() const
Returns the highlight brush of the current color group.
Definition: qpalette.h:140
The QApplication class manages the GUI application&#39;s control flow and main settings.
Definition: qapplication.h:99
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
QWidget * focusWidget() const
Returns the last child of this widget that setFocus had been called on.
Definition: qwidget.cpp:6863
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
static const char *const information_xpm[]
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
static void get_combo_parameters(const QRect &r, int &ew, int &awh, int &ax, int &ay, int &sh, int &dh, int &sy)
SubControl
This enum describes the available sub controls.
Definition: qstyle.h:402
void setColor(int i, QRgb c)
Sets the color at the given index in the color table, to the given to colorValue. ...
Definition: qimage.cpp:1850
StyleHint
This enum describes the available style hints.
Definition: qstyle.h:640
The QStyleHintReturn class provides style hints that return more than basic data types.
Definition: qstyleoption.h:907
unsigned char c[8]
Definition: qnumeric_p.h:62
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
const QTransform & transform() const
Returns the world transformation matrix.
Definition: qpainter.cpp:9558
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
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
void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &c, int lineWidth, const QBrush *fill)
Definition: qdrawutil.cpp:511
static int get_combo_extra_width(int h, int w, int *return_awh=0)
const QBrush & dark() const
Returns the dark brush of the current color group.
Definition: qpalette.h:127
void drawPoints(const QPointF *points, int pointCount)
Draws the first pointCount points in the array points using the current pen&#39;s color.
Definition: qpainter.cpp:3816
const QBrush & background() const
Returns the current background brush.
Definition: qpainter.cpp:2482
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
The QStyleOptionMenuItem class is used to describe the parameter necessary for drawing a menu item...
Definition: qstyleoption.h:435
void unpolish(QWidget *)
Keep QStyle::polish() visible.
static int appDepth(int screen=-1)
Returns the color depth (bits per pixel) used by the application on the given screen.
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...
bool isVisible() const
Definition: qwidget.h:1005
static QSize globalStrut()
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.
static const char *const qt_normalizeup_xpm[]
ComplexControl
This enum describes the available complex controls.
Definition: qstyle.h:386
static const char *const qt_menu_xpm[]
The QStyleOptionQ3ListView class is used to describe the parameters for drawing a Q3ListView...
Definition: qstyleoption.h:747
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
QPalette standardPalette() const
Reimplemented Function
Qt::Orientation orientation
the progress bar&#39;s orientation (horizontal or vertical); the default orentation is Qt::Horizontal ...
Definition: qstyleoption.h:422
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
void removeEventFilter(QObject *)
Removes an event filter object obj from this object.
Definition: qobject.cpp:2099
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
PixelMetric
This enum describes the various available pixel metrics.
Definition: qstyle.h:474
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
static const int motifCheckMarkSpace
Definition: qmotifstyle.cpp:89
QSize expandedTo(const QSize &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
Definition: qsize.h:187
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int childCount
the number of children the item has
Definition: qstyleoption.h:477
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
const QBrush & foreground() const
Use windowText() instead.
Definition: qpalette.h:123
quint16 u
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
static QPalette palette()
Returns the application palette.
void setWidget(QWidget *widget)
QFocusFrame will track changes to widget and resize itself automatically.
void putPoints(int index, int nPoints, const int *points)
Copies nPoints points from the points coord array into this point array, and resizes the point array ...
Definition: qpolygon.cpp:406
QStyle::SubControls activeSubControls
This variable holds a bitwise OR of the sub-controls that are active for the complex control...
Definition: qstyleoption.h:694
The QPolygon class provides a vector of points using integer precision.
Definition: qpolygon.h:60
static const int motifSepHeight
Definition: qmotifstyle.cpp:83
void timerEvent(QTimerEvent *event)
Reimplemented Function
QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
QTransform & translate(qreal dx, qreal dy)
Moves the coordinate system dx along the x axis and dy along the y axis, and returns a reference to t...
Definition: qtransform.cpp:417
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
void setY(int y)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:285
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
void setHeight(int h)
Sets the height to the given height.
Definition: qsize.h:135
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
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
#define Q_D(Class)
Definition: qglobal.h:2482
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
QPixmap standardPixmap(StandardPixmap sp, const QStyleOption *opt=0, const QWidget *widget=0) const
Reimplemented Function
bool highlightCols
Definition: qmotifstyle.h:119
void drawPoint(const QPointF &pt)
Draws a single point at the given position using the current pen&#39;s color.
Definition: qpainter.h:676
static int sliderPositionFromValue(int min, int max, int val, int space, bool upsideDown=false)
Converts the given logicalValue to a pixel position.
Definition: qstyle.cpp:2176
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
The QStyleOptionToolButton class is used to describe the parameters for drawing a tool button...
Definition: qstyleoption.h:768
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
static const char *const qt_shade_xpm[]
#define CTOP
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
StandardPixmap
This enum describes the available standard pixmaps.
Definition: qstyle.h:755
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
void setWidth(int w)
Sets the width to the given width.
Definition: qsize.h:132
QColor backgroundColor
the background color on which the focus rectangle is being drawn
Definition: qstyleoption.h:109
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
void setCurrentColorGroup(ColorGroup cg)
Set the palette&#39;s current color group to cg.
Definition: qpalette.h:105
QColor darker(int f=200) const
Returns a darker (or lighter) color, but does not change this object.
Definition: qcolor.h:301
void getCoords(int *x1, int *y1, int *x2, int *y2) const
Extracts the position of the rectangle&#39;s top-left corner to *x1 and *y1, and the position of the bott...
Definition: qrect.h:408
int lineWidth
the line width for drawing the frame
Definition: qstyleoption.h:124
The QStyleOptionProgressBarV2 class is used to describe the parameters necessary for drawing a progre...
Definition: qstyleoption.h:417
int width() const
Returns the width.
Definition: qsize.h:126
void translate(int dx, int dy)
Translates all points in the polygon by ({dx}, {dy}).
Definition: qpolygon.cpp:238
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
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option=0, const QWidget *widget=0) const
Returns an icon for the given standardIcon.
Definition: qstyle.cpp:2327
const QPen & pen() const
Returns the painter&#39;s current pen.
Definition: qpainter.cpp:4152
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
virtual ~QMotifStyle()
Destroys the style.
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
int totalHeight
the total height of the item, including its children
Definition: qstyleoption.h:475
static const char *const qt_close_xpm[]
The QStyleOptionQ3ListViewItem class is used to describe an item drawn in a Q3ListView.
Definition: qstyleoption.h:463
QGraphicsItem * focusItem() const
When the scene is active, this functions returns the scene&#39;s current focus item, or 0 if no item curr...
static const int motifItemHMargin
Definition: qmotifstyle.cpp:84
QPoint bottomRight() const
Returns the position of the rectangle&#39;s bottom-right corner.
Definition: qrect.h:291
QPoint brushOrigin() const
Returns the currently set brush origin.
Definition: qpainter.cpp:2168
const QBrush & light() const
Returns the light brush of the current color group.
Definition: qpalette.h:126
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
static const char * dock_window_close_xpm[]
The QStyleOption class stores the parameters used by QStyle functions.
Definition: qstyleoption.h:67
static void rot(QPolygon &a, int n)
ContentsType
This enum describes the available contents types.
Definition: qstyle.h:602
The QStyleOptionSpinBox class is used to describe the parameters necessary for drawing a spin box...
Definition: qstyleoption.h:729
const QFont & font() const
Returns the currently set font used for drawing text.
Definition: qpainter.cpp:4312
QMotifStyle(bool useHighlightCols=false)
Constructs a QMotifStyle.
QTransform & rotate(qreal a, Qt::Axis axis=Qt::ZAxis)
Rotates the coordinate system counterclockwise by the given angle about the specified axis and return...
Definition: qtransform.cpp:615
bool eventFilter(QObject *o, QEvent *e)
Mode
This enum type describes the mode for which a pixmap is intended to be used.
Definition: qicon.h:63
The QStyleOptionQ3DockWindow class is used to describe the parameters for drawing various parts of a ...
Definition: qstyleoption.h:488
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
#define CBOT
int maximum
the progress bar&#39;s maximum value
Definition: qprogressbar.h:63
LayoutDirection
Definition: qnamespace.h:1580
const QBrush & mid() const
Returns the mid brush of the current color group.
Definition: qpalette.h:128
virtual int type() const
Returns the type of an item as an int.
static const int motifArrowHMargin
Definition: qmotifstyle.cpp:86
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...
The QStyleOptionFocusRect class is used to describe the parameters for drawing a focus rectangle with...
Definition: qstyleoption.h:103
Q3ListViewItemFeatures features
the features for this item
Definition: qstyleoption.h:473
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
Definition: qcoreevent.h:346
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
The QStyleOptionFrame class is used to describe the parameters for drawing a frame.
Definition: qstyleoption.h:118
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
void setUseHighlightColors(bool)
If arg is false, the style will polish the application&#39;s color palette to emulate the Motif way of hi...
#define INTARRLEN(x)
QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *widget=0) const
Reimplemented Function
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule=Qt::OddEvenFill)
Draws the polygon defined by the first pointCount points in the array points using the current pen an...
Definition: qpainter.cpp:5205
void qDrawShadePanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, int lineWidth, const QBrush *fill)
Definition: qdrawutil.cpp:303
int pixelMetric(PixelMetric m, const QStyleOption *opt=0, const QWidget *widget=0) const
Reimplemented Function
void polish(QPalette &)
Reimplemented Function
The State element defines configurations of objects and properties.
void setCoords(int x1, int y1, int x2, int y2)
Sets the coordinates of the rectangle&#39;s top-left corner to (x1, y1), and the coordinates of its botto...
Definition: qrect.h:416
void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
void setX(int x)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:282
The QMotifStyle class provides Motif look and feel.
Definition: qmotifstyle.h:60
void unpolish(QWidget *widget)
Reimplemented Function
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
virtual bool eventFilter(QObject *, QEvent *)
Filters events if this object has been installed as an event filter for the watched object...
Definition: qobject.cpp:1375
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
void moveCenter(const QPoint &p)
Moves the rectangle, leaving the center point at the given position.
Definition: qrect.cpp:840
QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *widget=0) const
Reimplemented Function
const QBrush & brush() const
Returns the painter&#39;s current brush.
Definition: qpainter.cpp:4232
void drawTiledPixmap(const QRectF &rect, const QPixmap &pm, const QPointF &offset=QPointF())
Draws a tiled pixmap, inside the given rectangle with its origin at the given position.
Definition: qpainter.cpp:7146
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
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
QPoint center() const
Returns the center point of the rectangle.
Definition: qrect.h:300
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
The QStyleHintReturnMask class provides style hints that return a QRegion.
Definition: qstyleoption.h:923
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
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
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
QPoint bottomLeft() const
Returns the position of the rectangle&#39;s bottom-left corner.
Definition: qrect.h:297
PrimitiveElement
This enum describes the various primitive elements.
Definition: qstyle.h:145
static const int motifItemFrame
Definition: qmotifstyle.cpp:82
The QTimerEvent class contains parameters that describe a timer event.
Definition: qcoreevent.h:341
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
const QBrush & highlightedText() const
Returns the highlighted text brush of the current color group.
Definition: qpalette.h:141
void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
int midLineWidth
the mid-line width for drawing the frame
Definition: qstyleoption.h:125
T qstyleoption_cast(const QStyleOption *opt)
Definition: qstyleoption.h:885
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
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
QPointer< QFocusFrame > focus
Definition: qmotifstyle.h:110
The QCommonStyle class encapsulates the common Look and Feel of a GUI.
Definition: qcommonstyle.h:54
static const char *const qt_unshade_xpm[]
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
void installEventFilter(QObject *)
Installs an event filter filterObj on this object.
Definition: qobject.cpp:2070
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
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...
The QStyleOptionComboBox class is used to describe the parameter for drawing a combobox.
Definition: qstyleoption.h:796
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
static const char *const qt_maximize_xpm[]
if(void) toggleToolbarShown
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void setPoint(int index, int x, int y)
Sets the point at the given index to the point specified by ({x}, {y}).
Definition: qpolygon.h:120
void getRect(int *x, int *y, int *w, int *h) const
Extracts the position of the rectangle&#39;s top-left corner to *x and *y, and its dimensions to *width a...
Definition: qrect.h:392
#define CLEFT
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
Definition: qpainter.h:650
const QStyle * proxy() const
Definition: qstyle.cpp:2546
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
void polish(QPalette &)
Reimplemented Function
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
The QStyleOptionTab class is used to describe the parameters for drawing a tab bar.
Definition: qstyleoption.h:304
The QFocusFrame widget provides a focus frame which can be outside of a widget&#39;s normal paintable are...
Definition: qfocusframe.h:56
virtual void polish(QWidget *)
Initializes the appearance of the given widget.
Definition: qstyle.cpp:390
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
Definition: qgraphicsview.h:64
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
static const char *const critical_xpm[]
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
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget=0) const
Reimplemented Function
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
void setPoints(int nPoints, const int *points)
Resizes the polygon to nPoints and populates it with the given points.
Definition: qpolygon.cpp:350
const QBrush & buttonText() const
Returns the button text foreground brush of the current color group.
Definition: qpalette.h:138
QGraphicsScene * scene() const
Returns the current scene for the item, or 0 if the item is not stored in a scene.
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt=0, const QWidget *widget=0) const
The QStyleOptionComplex class is used to hold parameters that are common to all complex controls...
Definition: qstyleoption.h:687
QRegion region
the region for style hints that return a QRegion
Definition: qstyleoption.h:930
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
int minimum
the progress bar&#39;s minimum value
Definition: qprogressbar.h:62
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
static const char *const warning_xpm[]
The QStyleOptionProgressBar class is used to describe the parameters necessary for drawing a progress...
Definition: qstyleoption.h:396
QColor lighter(int f=150) const
Returns a lighter (or darker) color, but does not change this object.
Definition: qcolor.h:298
int height() const
Returns the height of the font.
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
bool event(QEvent *)
Reimplemented Function
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
int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const
Reimplemented Function
const QBrush & button() const
Returns the button brush of the current color group.
Definition: qpalette.h:125
void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2, const QPalette &pal, bool sunken, int lineWidth, int midLineWidth)
Definition: qdrawutil.cpp:93
bool invertedAppearance
whether the progress bar&#39;s appearance is inverted
Definition: qstyleoption.h:423
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
void drawPolyline(const QPointF *points, int pointCount)
Draws the polyline defined by the first pointCount points in points using the current pen...
Definition: qpainter.cpp:5055
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
static QWidget * focusWidget()
Returns the application widget that has the keyboard input focus, or 0 if no widget in this applicati...
The QStyleOptionButton class is used to describe the parameters for drawing buttons.
Definition: qstyleoption.h:279
int styleHint(StyleHint hint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const
Reimplemented Function
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt=0, const QWidget *widget=0) const
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
#define INT_MAX
static const int motifItemVMargin
Definition: qmotifstyle.cpp:85
static const int motifTabSpacing
Definition: qmotifstyle.cpp:87
bool useHighlightColors() const
Returns true if the style treats the highlight colors of the palette in a Motif-like manner...
QStyle::SubControls subControls
This variable holds a bitwise OR of the sub-controls to be drawn for the complex control.
Definition: qstyleoption.h:693
QRgb rgb() const
Returns the RGB value of the color.
Definition: qcolor.cpp:1051
void setBackground(const QBrush &bg)
Sets the background brush of the painter to the given brush.
Definition: qpainter.cpp:4258
bool end()
Ends painting.
Definition: qpainter.cpp:1929
QWidget * widget() const
Returns a pointer to the embedded widget.
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
const QBrush & text() const
Returns the text foreground brush of the current color group.
Definition: qpalette.h:129
SubElement
This enum represents a sub-area of a widget.
Definition: qstyle.h:289
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
int styleHint(StyleHint sh, const QStyleOption *opt=0, const QWidget *w=0, QStyleHintReturn *shret=0) const
Reimplemented Function
static const char *const qt_minimize_xpm[]
void killTimer(int id)
Kills the timer with timer identifier, id.
Definition: qobject.cpp:1650
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288
static const char *const question_xpm[]
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