#include <qcommonstyle.h>
Inheritance diagram for QCommonStyle:


This abstract class implements some of the widget's look and feel that is common to all GUI styles provided and shipped as part of Qt.
Since QCommonStyle inherits QStyle, all of its functions are fully documented in the QStyle documentation. , although the extra functions that QCommonStyle provides, e.g. drawComplexControl(), drawControl(), drawPrimitive(), hitTestComplexControl(), subControlRect(), sizeFromContents(), and subElementRect() are documented here.
Definition at line 35 of file qcommonstyle.h.
| QCommonStyle::QCommonStyle | ( | ) |
Constructs a QCommonStyle.
Definition at line 77 of file qcommonstyle.cpp.
00078 : QStyle(*new QCommonStylePrivate) 00079 { }
| QCommonStyle::~QCommonStyle | ( | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Destroys the style
Definition at line 92 of file qcommonstyle.cpp.
| QCommonStyle::QCommonStyle | ( | QCommonStylePrivate & | dd | ) | [protected] |
| void QCommonStyle::drawPrimitive | ( | PrimitiveElement | pe, | |
| const QStyleOption * | opt, | |||
| QPainter * | p, | |||
| const QWidget * | widget = 0 | |||
| ) | const [virtual] |
Implements QStyle.
Definition at line 99 of file qcommonstyle.cpp.
References a, QRect::adjust(), QRect::adjusted(), QPainter::Antialiasing, QPalette::Base, Qt::black, QRect::bottom(), QRect::bottomRight(), QPalette::brush(), QPalette::Button, check_list_controller_xpm, QBrush::color(), QPalette::dark(), QPalette::Disabled, QStyleOptionQ3ListViewItem::features, QStyleOptionFrameV2::features, QStyleOptionFrameV2::Flat, QPalette::foreground(), QColor::getHsv(), h, header(), QRect::height(), QStyleOptionQ3ListViewItem::height, QPalette::Highlight, i, INTARRLEN, QColor::isValid(), QApplication::layoutDirection(), QRect::left(), Qt::NoPen, p, QStyleOption::palette, QStyleOptionQ3ListViewItem::ParentControl, QWidget::parentWidget(), path, QStyle::PE_Frame, QStyle::PE_FrameButtonBevel, QStyle::PE_FrameButtonTool, QStyle::PE_FrameDockWidget, QStyle::PE_FrameFocusRect, QStyle::PE_FrameGroupBox, QStyle::PE_FrameLineEdit, QStyle::PE_FrameMenu, QStyle::PE_FrameStatusBar, QStyle::PE_FrameTabBarBase, QStyle::PE_FrameTabWidget, QStyle::PE_FrameWindow, QStyle::PE_IndicatorBranch, QStyle::PE_IndicatorButtonDropDown, QStyle::PE_IndicatorCheckBox, QStyle::PE_IndicatorHeaderArrow, QStyle::PE_IndicatorMenuCheckMark, QStyle::PE_IndicatorProgressChunk, QStyle::PE_IndicatorRadioButton, QStyle::PE_IndicatorSpinDown, QStyle::PE_IndicatorSpinMinus, QStyle::PE_IndicatorSpinPlus, QStyle::PE_IndicatorSpinUp, QStyle::PE_IndicatorTabTear, QStyle::PE_IndicatorToolBarHandle, QStyle::PE_IndicatorToolBarSeparator, QStyle::PE_IndicatorViewItemCheck, QStyle::PE_PanelButtonBevel, QStyle::PE_PanelButtonCommand, QStyle::PE_PanelButtonTool, QStyle::PE_PanelLineEdit, QStyle::PE_PanelMenuBar, QStyle::PE_PanelTipLabel, QStyle::PE_PanelToolBar, QStyle::PE_Q3CheckListController, QStyle::PE_Q3CheckListExclusiveIndicator, QStyle::PE_Q3CheckListIndicator, QStyle::PE_Q3DockWindowSeparator, QStyle::PE_Q3Separator, pixelMetric(), QStyle::PM_ButtonShiftHorizontal, QStyle::PM_ButtonShiftVertical, QStyle::PM_DefaultFrameWidth, QStyle::PM_DockWidgetFrameWidth, qDrawPlainRect(), qDrawShadeLine(), qDrawShadePanel(), qDrawShadeRect(), qDrawWinPanel(), QStyleOption::rect, QRect::right(), Qt::RightToLeft, QTabBar::RoundedEast, QTabBar::RoundedNorth, QTabBar::RoundedSouth, QTabBar::RoundedWest, s, QRect::setBottom(), QPolygon::setPoint(), QRect::setTop(), QStyleOptionHeader::SortDown, QStyleOptionHeader::SortUp, QStyleOption::state, QStyle::State_Children, QStyle::State_Enabled, QStyle::State_Horizontal, QStyle::State_Item, QStyle::State_NoChange, QStyle::State_On, QStyle::State_Open, QStyle::State_Raised, QStyle::State_Selected, QStyle::State_Sibling, QStyle::State_Sunken, QPalette::Text, QRect::top(), QRect::topLeft(), tree_branch_closed_xpm, tree_branch_open_xpm, QTabBar::TriangularEast, QTabBar::TriangularNorth, QTabBar::TriangularSouth, QTabBar::TriangularWest, Qt::Vertical, w, Qt::white, QRect::width(), QRect::x(), QPoint::x(), x, QRect::y(), QPoint::y(), and y.
Referenced by drawComplexControl(), drawControl(), QMotifStyle::drawPrimitive(), and QWindowsStyle::drawPrimitive().
00101 { 00102 switch (pe) { 00103 case PE_FrameButtonBevel: 00104 case PE_FrameButtonTool: 00105 qDrawShadeRect(p, opt->rect, opt->palette, 00106 opt->state & (State_Sunken | State_On), 1, 0); 00107 break; 00108 case PE_PanelButtonCommand: 00109 case PE_PanelButtonBevel: 00110 case PE_PanelButtonTool: 00111 case PE_IndicatorButtonDropDown: 00112 qDrawShadePanel(p, opt->rect, opt->palette, 00113 opt->state & (State_Sunken | State_On), 1, 00114 &opt->palette.brush(QPalette::Button)); 00115 break; 00116 case PE_IndicatorViewItemCheck: 00117 drawPrimitive(PE_IndicatorCheckBox, opt, p, widget); 00118 break; 00119 case PE_IndicatorCheckBox: 00120 if (opt->state & State_NoChange) { 00121 p->setPen(opt->palette.foreground().color()); 00122 p->fillRect(opt->rect, opt->palette.brush(QPalette::Button)); 00123 p->drawRect(opt->rect); 00124 p->drawLine(opt->rect.topLeft(), opt->rect.bottomRight()); 00125 } else { 00126 qDrawShadePanel(p, opt->rect.x(), opt->rect.y(), opt->rect.width(), opt->rect.height(), 00127 opt->palette, opt->state & (State_Sunken | State_On), 1, 00128 &opt->palette.brush(QPalette::Button)); 00129 } 00130 break; 00131 case PE_IndicatorRadioButton: { 00132 QRect ir = opt->rect; 00133 p->setPen(opt->palette.dark().color()); 00134 p->drawArc(opt->rect, 0, 5760); 00135 if (opt->state & (State_Sunken | State_On)) { 00136 ir.adjust(2, 2, -2, -2); 00137 p->setBrush(opt->palette.foreground()); 00138 p->drawEllipse(ir); 00139 } 00140 break; } 00141 case PE_FrameFocusRect: 00142 if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(opt)) { 00143 QColor bg = fropt->backgroundColor; 00144 QPen oldPen = p->pen(); 00145 if (bg.isValid()) { 00146 int h, s, v; 00147 bg.getHsv(&h, &s, &v); 00148 if (v >= 128) 00149 p->setPen(Qt::black); 00150 else 00151 p->setPen(Qt::white); 00152 } else { 00153 p->setPen(opt->palette.foreground().color()); 00154 } 00155 QRect focusRect = opt->rect.adjusted(1, 1, -1, -1); 00156 p->drawRect(focusRect.adjusted(0, 0, -1, -1)); //draw pen inclusive 00157 p->setPen(oldPen); 00158 } 00159 break; 00160 case PE_IndicatorMenuCheckMark: { 00161 const int markW = opt->rect.width() > 7 ? 7 : opt->rect.width(); 00162 const int markH = markW; 00163 int posX = opt->rect.x() + (opt->rect.width() - markW)/2 + 1; 00164 int posY = opt->rect.y() + (opt->rect.height() - markH)/2; 00165 00166 QVector<QLineF> a; 00167 a.reserve(markH); 00168 00169 int i, xx, yy; 00170 xx = posX; 00171 yy = 3 + posY; 00172 for (i = 0; i < markW/2; ++i) { 00173 a << QLineF(xx, yy, xx, yy + 2); 00174 ++xx; 00175 ++yy; 00176 } 00177 yy -= 2; 00178 for (; i < markH; ++i) { 00179 a << QLineF(xx, yy, xx, yy + 2); 00180 ++xx; 00181 --yy; 00182 } 00183 if (!(opt->state & State_Enabled) && !(opt->state & State_On)) { 00184 int pnt; 00185 p->setPen(opt->palette.highlightedText().color()); 00186 QPoint offset(1, 1); 00187 for (pnt = 0; pnt < a.size(); ++pnt) 00188 a[pnt].translate(offset.x(), offset.y()); 00189 p->drawLines(a); 00190 for (pnt = 0; pnt < a.size(); ++pnt) 00191 a[pnt].translate(offset.x(), offset.y()); 00192 } 00193 p->setPen(opt->palette.text().color()); 00194 p->drawLines(a); 00195 break; } 00196 case PE_Frame: 00197 case PE_FrameMenu: 00198 if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) { 00199 if (pe == PE_FrameMenu || (frame->state & State_Sunken) || (frame->state & State_Raised)) { 00200 qDrawShadePanel(p, frame->rect, frame->palette, frame->state & State_Sunken, 00201 frame->lineWidth); 00202 } else { 00203 qDrawPlainRect(p, frame->rect, frame->palette.foreground().color(), frame->lineWidth); 00204 } 00205 } 00206 break; 00207 #ifndef QT_NO_TOOLBAR 00208 case PE_PanelMenuBar: 00209 if (widget && qobject_cast<QToolBar *>(widget->parentWidget())) 00210 break; 00211 if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)){ 00212 qDrawShadePanel(p, frame->rect, frame->palette, false, frame->lineWidth, 00213 &frame->palette.brush(QPalette::Button)); 00214 00215 } 00216 else if (const QStyleOptionToolBar *frame = qstyleoption_cast<const QStyleOptionToolBar *>(opt)){ 00217 qDrawShadePanel(p, frame->rect, frame->palette, false, frame->lineWidth, 00218 &frame->palette.brush(QPalette::Button)); 00219 } 00220 00221 break; 00222 case PE_PanelToolBar: 00223 break; 00224 #endif // QT_NO_TOOLBAR 00225 #ifndef QT_NO_PROGRESSBAR 00226 case PE_IndicatorProgressChunk: 00227 { 00228 bool vertical = false; 00229 if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) 00230 vertical = (pb2->orientation == Qt::Vertical); 00231 if (!vertical) { 00232 p->fillRect(opt->rect.x(), opt->rect.y() + 3, opt->rect.width() -2, opt->rect.height() - 6, 00233 opt->palette.brush(QPalette::Highlight)); 00234 } else { 00235 p->fillRect(opt->rect.x() + 2, opt->rect.y(), opt->rect.width() -6, opt->rect.height() - 2, 00236 opt->palette.brush(QPalette::Highlight)); 00237 } 00238 } 00239 break; 00240 #endif // QT_NO_PROGRESSBAR 00241 #ifdef QT3_SUPPORT 00242 case PE_Q3CheckListController: 00243 #ifndef QT_NO_IMAGEFORMAT_XPM 00244 p->drawPixmap(opt->rect.topLeft(), QPixmap(check_list_controller_xpm)); 00245 #endif 00246 break; 00247 case PE_Q3CheckListExclusiveIndicator: 00248 if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) { 00249 if (lv->items.isEmpty()) 00250 return; 00251 int x = lv->rect.x(), 00252 y = lv->rect.y(); 00253 #define INTARRLEN(x) sizeof(x)/(sizeof(int)*2) 00254 static const int pts1[] = { // dark lines 00255 1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 }; 00256 static const int pts2[] = { // black lines 00257 2,8, 1,7, 1,4, 2,3, 2,2, 3,2, 4,1, 7,1, 8,2, 9,2 }; 00258 static const int pts3[] = { // background lines 00259 2,9, 3,9, 4,10, 7,10, 8,9, 9,9, 9,8, 10,7, 10,4, 9,3 }; 00260 static const int pts4[] = { // white lines 00261 2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7, 00262 11,4, 10,3, 10,2 }; 00263 // static const int pts5[] = { // inner fill 00264 // 4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 }; 00265 //QPolygon a; 00266 00267 if (lv->state & State_Enabled) 00268 p->setPen(lv->palette.text().color()); 00269 else 00270 p->setPen(QPen(lv->viewportPalette.color(QPalette::Disabled, QPalette::Text))); 00271 QPolygon a(INTARRLEN(pts1), pts1); 00272 a.translate(x, y); 00273 //p->setPen(pal.dark()); 00274 p->drawPolyline(a); 00275 a.setPoints(INTARRLEN(pts2), pts2); 00276 a.translate(x, y); 00277 p->drawPolyline(a); 00278 a.setPoints(INTARRLEN(pts3), pts3); 00279 a.translate(x, y); 00280 // p->setPen(black); 00281 p->drawPolyline(a); 00282 a.setPoints(INTARRLEN(pts4), pts4); 00283 a.translate(x, y); 00284 // p->setPen(blue); 00285 p->drawPolyline(a); 00286 // a.setPoints(INTARRLEN(pts5), pts5); 00287 // a.translate(x, y); 00288 // QColor fillColor = isDown() ? g.background() : g.base(); 00289 // p->setPen(fillColor); 00290 // p->setBrush(fillColor); 00291 // p->drawPolygon(a); 00292 if (opt->state & State_On) { 00293 p->setPen(Qt::NoPen); 00294 p->setBrush(opt->palette.text()); 00295 p->drawRect(x + 5, y + 4, 2, 4); 00296 p->drawRect(x + 4, y + 5, 4, 2); 00297 } 00298 #undef INTARRLEN 00299 } 00300 break; 00301 case PE_Q3CheckListIndicator: 00302 if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) { 00303 if(lv->items.isEmpty()) 00304 break; 00305 QStyleOptionQ3ListViewItem item = lv->items.at(0); 00306 int x = lv->rect.x(), 00307 y = lv->rect.y(), 00308 w = lv->rect.width(), 00309 h = lv->rect.width(), 00310 marg = lv->itemMargin; 00311 00312 if (lv->state & State_Enabled) 00313 p->setPen(QPen(lv->palette.text().color(), 2)); 00314 else 00315 p->setPen(QPen(lv->viewportPalette.color(QPalette::Disabled, QPalette::Text), 2)); 00316 if (opt->state & State_Selected && !lv->rootIsDecorated 00317 && !(item.features & QStyleOptionQ3ListViewItem::ParentControl)) { 00318 p->fillRect(0, 0, x + marg + w + 4, item.height, 00319 lv->palette.brush(QPalette::Highlight)); 00320 if (item.state & State_Enabled) 00321 p->setPen(QPen(lv->palette.highlightedText().color(), 2)); 00322 } 00323 00324 if (lv->state & State_NoChange) 00325 p->setBrush(lv->palette.brush(QPalette::Button)); 00326 p->drawRect(x + marg, y + 2, w - 4, h - 4); 00328 ++x; 00329 ++y; 00330 if (lv->state & State_On || lv->state & State_NoChange) { 00331 QLineF lines[7]; 00332 int i, 00333 xx = x + 1 + marg, 00334 yy = y + 5; 00335 for (i = 0; i < 3; ++i) { 00336 lines[i] = QLineF(xx, yy, xx, yy + 2); 00337 ++xx; 00338 ++yy; 00339 } 00340 yy -= 2; 00341 for (i = 3; i < 7; ++i) { 00342 lines[i] = QLineF(xx, yy, xx, yy + 2); 00343 ++xx; 00344 --yy; 00345 } 00346 p->drawLines(lines, 7); 00347 } 00348 } 00349 break; 00350 #endif // QT3_SUPPORT 00351 case PE_IndicatorBranch: { 00352 int mid_h = opt->rect.x() + opt->rect.width() / 2; 00353 int mid_v = opt->rect.y() + opt->rect.height() / 2; 00354 int bef_h = mid_h; 00355 int bef_v = mid_v; 00356 int aft_h = mid_h; 00357 int aft_v = mid_v; 00358 #ifndef QT_NO_IMAGEFORMAT_XPM 00359 static const int decoration_size = 9; 00360 static QPixmap open(tree_branch_open_xpm); 00361 static QPixmap closed(tree_branch_closed_xpm); 00362 if (opt->state & State_Children) { 00363 int delta = decoration_size / 2; 00364 bef_h -= delta; 00365 bef_v -= delta; 00366 aft_h += delta; 00367 aft_v += delta; 00368 p->drawPixmap(bef_h, bef_v, opt->state & State_Open ? open : closed); 00369 } 00370 #endif // QT_NO_IMAGEFORMAT_XPM 00371 if (opt->state & State_Item) { 00372 if (opt->direction == Qt::RightToLeft) 00373 p->drawLine(opt->rect.left(), mid_v, bef_h, mid_v); 00374 else 00375 p->drawLine(aft_h, mid_v, opt->rect.right(), mid_v); 00376 } 00377 if (opt->state & State_Sibling) 00378 p->drawLine(mid_h, aft_v, mid_h, opt->rect.bottom()); 00379 if (opt->state & (State_Open | State_Children | State_Item | State_Sibling)) 00380 p->drawLine(mid_h, opt->rect.y(), mid_h, bef_v); 00381 break; } 00382 #ifdef QT3_SUPPORT 00383 case PE_Q3Separator: 00384 qDrawShadeLine(p, opt->rect.left(), opt->rect.top(), opt->rect.right(), opt->rect.bottom(), 00385 opt->palette, opt->state & State_Sunken, 1, 0); 00386 break; 00387 #endif // QT3_SUPPORT 00388 case PE_FrameStatusBar: 00389 qDrawShadeRect(p, opt->rect, opt->palette, true, 1, 0, 0); 00390 break; 00391 case PE_IndicatorHeaderArrow: 00392 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) { 00393 QPen oldPen = p->pen(); 00394 if (header->sortIndicator & QStyleOptionHeader::SortUp) { 00395 QPolygon pa(3); 00396 p->setPen(QPen(opt->palette.light(), 0)); 00397 p->drawLine(opt->rect.x() + opt->rect.width(), opt->rect.y(), 00398 opt->rect.x() + opt->rect.width() / 2, opt->rect.y() + opt->rect.height()); 00399 p->setPen(QPen(opt->palette.dark(), 0)); 00400 pa.setPoint(0, opt->rect.x() + opt->rect.width() / 2, opt->rect.y() + opt->rect.height()); 00401 pa.setPoint(1, opt->rect.x(), opt->rect.y()); 00402 pa.setPoint(2, opt->rect.x() + opt->rect.width(), opt->rect.y()); 00403 p->drawPolyline(pa); 00404 } else if (header->sortIndicator & QStyleOptionHeader::SortDown) { 00405 QPolygon pa(3); 00406 p->setPen(QPen(opt->palette.light(), 0)); 00407 pa.setPoint(0, opt->rect.x(), opt->rect.y() + opt->rect.height()); 00408 pa.setPoint(1, opt->rect.x() + opt->rect.width(), opt->rect.y() + opt->rect.height()); 00409 pa.setPoint(2, opt->rect.x() + opt->rect.width() / 2, opt->rect.y()); 00410 p->drawPolyline(pa); 00411 p->setPen(QPen(opt->palette.dark(), 0)); 00412 p->drawLine(opt->rect.x(), opt->rect.y() + opt->rect.height(), 00413 opt->rect.x() + opt->rect.width() / 2, opt->rect.y()); 00414 } 00415 p->setPen(oldPen); 00416 } 00417 break; 00418 #ifndef QT_NO_TABBAR 00419 case PE_FrameTabBarBase: 00420 if (const QStyleOptionTabBarBase *tbb 00421 = qstyleoption_cast<const QStyleOptionTabBarBase *>(opt)) { 00422 QRegion region(tbb->rect); 00423 region -= tbb->selectedTabRect; 00424 p->save(); 00425 p->setClipRegion(region); 00426 switch (tbb->shape) { 00427 case QTabBar::RoundedNorth: 00428 case QTabBar::TriangularNorth: 00429 p->setPen(QPen(tbb->palette.light(), 0)); 00430 p->drawLine(tbb->rect.topLeft(), tbb->rect.topRight()); 00431 break; 00432 case QTabBar::RoundedWest: 00433 case QTabBar::TriangularWest: 00434 p->setPen(QPen(tbb->palette.light(), 0)); 00435 p->drawLine(tbb->rect.topLeft(), tbb->rect.bottomLeft()); 00436 break; 00437 case QTabBar::RoundedSouth: 00438 case QTabBar::TriangularSouth: 00439 p->setPen(QPen(tbb->palette.shadow(), 0)); 00440 p->drawLine(tbb->rect.left(), tbb->rect.bottom(), 00441 tbb->rect.right(), tbb->rect.bottom()); 00442 p->setPen(QPen(tbb->palette.dark(), 0)); 00443 p->drawLine(tbb->rect.left(), tbb->rect.bottom() - 1, 00444 tbb->rect.right() - 1, tbb->rect.bottom() - 1); 00445 break; 00446 case QTabBar::RoundedEast: 00447 case QTabBar::TriangularEast: 00448 p->setPen(QPen(tbb->palette.dark(), 0)); 00449 p->drawLine(tbb->rect.topRight(), tbb->rect.bottomRight()); 00450 break; 00451 } 00452 p->restore(); 00453 } 00454 break; 00455 #endif // QT_NO_TABBAR 00456 case PE_FrameTabWidget: 00457 case PE_FrameWindow: 00458 qDrawWinPanel(p, opt->rect, opt->palette, false, 0); 00459 break; 00460 case PE_FrameLineEdit: 00461 drawPrimitive(PE_Frame, opt, p, widget); 00462 break; 00463 #ifndef QT_NO_GROUPBOX 00464 case PE_FrameGroupBox: 00465 if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) { 00466 const QStyleOptionFrameV2 *frame2 = qstyleoption_cast<const QStyleOptionFrameV2 *>(opt); 00467 if (frame2 && (frame2->features & QStyleOptionFrameV2::Flat)) { 00468 QRect fr = frame->rect; 00469 QPoint p1(fr.x(), fr.y() + 1); 00470 QPoint p2(fr.x() + fr.width(), p1.y()); 00471 qDrawShadeLine(p, p1, p2, frame->palette, true, 00472 frame->lineWidth, frame->midLineWidth); 00473 } else { 00474 qDrawShadeRect(p, frame->rect.x(), frame->rect.y(), frame->rect.width(), 00475 frame->rect.height(), frame->palette, true, 00476 frame->lineWidth, frame->midLineWidth); 00477 } 00478 } 00479 break; 00480 #endif // QT_NO_GROUPBOX 00481 #ifndef QT_NO_DOCKWIDGET 00482 case PE_FrameDockWidget: 00483 if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) { 00484 int lw = frame->lineWidth; 00485 if (lw <= 0) 00486 lw = pixelMetric(PM_DockWidgetFrameWidth); 00487 00488 qDrawShadePanel(p, frame->rect, frame->palette, false, lw); 00489 } 00490 break; 00491 #endif // QT_NO_DOCKWIDGET 00492 #ifndef QT_NO_TOOLBAR 00493 case PE_IndicatorToolBarHandle: 00494 p->save(); 00495 p->translate(opt->rect.x(), opt->rect.y()); 00496 if (opt->state & State_Horizontal) { 00497 int x = opt->rect.width() / 3; 00498 if (QApplication::layoutDirection() == Qt::RightToLeft) 00499 x -= 2; 00500 if (opt->rect.height() > 4) { 00501 qDrawShadePanel(p, x, 2, 3, opt->rect.height() - 4, 00502 opt->palette, false, 1, 0); 00503 qDrawShadePanel(p, x+3, 2, 3, opt->rect.height() - 4, 00504 opt->palette, false, 1, 0); 00505 } 00506 } else { 00507 if (opt->rect.width() > 4) { 00508 int y = opt->rect.height() / 3; 00509 qDrawShadePanel(p, 2, y, opt->rect.width() - 4, 3, 00510 opt->palette, false, 1, 0); 00511 qDrawShadePanel(p, 2, y+3, opt->rect.width() - 4, 3, 00512 opt->palette, false, 1, 0); 00513 } 00514 } 00515 p->restore(); 00516 break; 00517 case PE_Q3DockWindowSeparator: 00518 drawPrimitive(PE_IndicatorToolBarSeparator, opt, p, widget); 00519 break; 00520 case PE_IndicatorToolBarSeparator: 00521 { 00522 QPoint p1, p2; 00523 if (opt->state & State_Horizontal) { 00524 p1 = QPoint(opt->rect.width()/2, 0); 00525 p2 = QPoint(p1.x(), opt->rect.height()); 00526 } else { 00527 p1 = QPoint(0, opt->rect.height()/2); 00528 p2 = QPoint(opt->rect.width(), p1.y()); 00529 } 00530 qDrawShadeLine(p, p1, p2, opt->palette, 1, 1, 0); 00531 break; 00532 } 00533 #endif // QT_NO_TOOLBAR 00534 #ifndef QT_NO_SPINBOX 00535 case PE_IndicatorSpinPlus: 00536 case PE_IndicatorSpinMinus: { 00537 QRect r = opt->rect; 00538 int fw = pixelMetric(PM_DefaultFrameWidth, opt, widget); 00539 QRect br = r.adjusted(fw, fw, -fw, -fw); 00540 00541 int offset = (opt->state & State_Sunken) ? 1 : 0; 00542 int step = (br.width() + 4) / 5; 00543 p->fillRect(br.x() + offset, br.y() + offset +br.height() / 2 - step / 2, 00544 br.width(), step, 00545 opt->palette.buttonText()); 00546 if (pe == PE_IndicatorSpinPlus) 00547 p->fillRect(br.x() + br.width() / 2 - step / 2 + offset, br.y() + offset, 00548 step, br.height(), 00549 opt->palette.buttonText()); 00550 00551 break; } 00552 case PE_IndicatorSpinUp: 00553 case PE_IndicatorSpinDown: { 00554 QRect r = opt->rect; 00555 int fw = pixelMetric(PM_DefaultFrameWidth, opt, widget); 00556 // QRect br = r.adjusted(fw, fw, -fw, -fw); 00557 int x = r.x(), y = r.y(), w = r.width(), h = r.height(); 00558 int sw = w-4; 00559 if (sw < 3) 00560 break; 00561 else if (!(sw & 1)) 00562 sw--; 00563 sw -= (sw / 7) * 2; // Empty border 00564 int sh = sw/2 + 2; // Must have empty row at foot of arrow 00565 00566 int sx = x + w / 2 - sw / 2; 00567 int sy = y + h / 2 - sh / 2; 00568 00569 if (pe == PE_IndicatorSpinUp && fw) 00570 --sy; 00571 00572 QPolygon a; 00573 if (pe == PE_IndicatorSpinDown) 00574 a.setPoints(3, 0, 1, sw-1, 1, sh-2, sh-1); 00575 else 00576 a.setPoints(3, 0, sh-1, sw-1, sh-1, sh-2, 1); 00577 int bsx = 0; 00578 int bsy = 0; 00579 if (opt->state & State_Sunken) { 00580 bsx = pixelMetric(PM_ButtonShiftHorizontal); 00581 bsy = pixelMetric(PM_ButtonShiftVertical); 00582 } 00583 p->save(); 00584 p->translate(sx + bsx, sy + bsy); 00585 p->setPen(opt->palette.buttonText().color()); 00586 p->setBrush(opt->palette.buttonText()); 00587 p->drawPolygon(a); 00588 p->restore(); 00589 break; } 00590 #endif // QT_NO_SPINBOX 00591 case PE_PanelTipLabel: { 00592 QBrush oldBrush = p->brush(); 00593 QPen oldPen = p->pen(); 00594 p->setPen(opt->palette.foreground().color()); 00595 p->setBrush(opt->palette.background()); 00596 p->drawRect(opt->rect.adjusted(0, 0, -1, -1)); 00597 p->setPen(oldPen); 00598 p->setBrush(oldBrush); 00599 break; 00600 } 00601 #ifndef QT_NO_TABBAR 00602 case PE_IndicatorTabTear: 00603 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) { 00604 bool rtl = tab->direction == Qt::RightToLeft; 00605 QRect rect = tab->rect; 00606 QPainterPath path; 00607 00608 rect.setTop(rect.top() + ((tab->state & State_Selected) ? 1 : 3)); 00609 rect.setBottom(rect.bottom() - ((tab->state & State_Selected) ? 0 : 2)); 00610 00611 path.moveTo(QPoint(rtl ? rect.right() : rect.left(), rect.top())); 00612 int count = 4; 00613 for(int jags = 1; jags <= count; ++jags, rtl = !rtl) 00614 path.lineTo(QPoint(rtl ? rect.left() : rect.right(), rect.top() + jags * rect.height()/count)); 00615 00616 p->setPen(QPen(tab->palette.light(), .8)); 00617 p->setBrush(tab->palette.background()); 00618 p->setRenderHint(QPainter::Antialiasing); 00619 p->drawPath(path); 00620 } 00621 break; 00622 #endif // QT_NO_TABBAR 00623 #ifndef QT_NO_LINEEDIT 00624 case PE_PanelLineEdit: 00625 if (const QStyleOptionFrame *panel = qstyleoption_cast<const QStyleOptionFrame *>(opt)) { 00626 p->fillRect(panel->rect.adjusted(panel->lineWidth, panel->lineWidth, -panel->lineWidth, -panel->lineWidth), 00627 panel->palette.brush(QPalette::Base)); 00628 00629 if (panel->lineWidth > 0) 00630 drawPrimitive(PE_FrameLineEdit, panel, p, widget); 00631 } 00632 break; 00633 #endif // QT_NO_LINEEDIT 00634 default: 00635 break; 00636 } 00637 }
Here is the call graph for this function:

| void QCommonStyle::drawControl | ( | ControlElement | element, | |
| const QStyleOption * | opt, | |||
| QPainter * | p, | |||
| const QWidget * | widget = 0 | |||
| ) | const [virtual] |
Implements QStyle.
Definition at line 671 of file qcommonstyle.cpp.
References a, QIcon::Active, QPalette::Active, QRect::adjust(), QRect::adjusted(), Qt::AlignCenter, QStyle::alignedRect(), Qt::AlignHCenter, Qt::AlignLeft, Qt::AlignVCenter, QPainter::Antialiasing, QStyleOptionToolButton::Arrow, QStyleOptionButton::AutoDefaultButton, QPalette::background(), QPalette::Base, QRect::bottom(), Qt::BottomLeftCorner, Qt::BottomRightCorner, QPalette::Button, QPalette::ButtonText, QStyle::CC_ComboBox, QStyle::CE_CheckBox, QStyle::CE_CheckBoxLabel, QStyle::CE_ComboBoxLabel, QStyle::CE_DockWidgetTitle, QStyle::CE_FocusFrame, QStyle::CE_Header, QStyle::CE_HeaderLabel, QStyle::CE_HeaderSection, QStyle::CE_MenuBarEmptyArea, QStyle::CE_MenuBarItem, QStyle::CE_MenuScroller, QStyle::CE_MenuTearoff, QStyle::CE_ProgressBar, QStyle::CE_ProgressBarContents, QStyle::CE_ProgressBarGroove, QStyle::CE_ProgressBarLabel, QStyle::CE_PushButton, QStyle::CE_PushButtonBevel, QStyle::CE_PushButtonLabel, QStyle::CE_RadioButton, QStyle::CE_RadioButtonLabel, QStyle::CE_RubberBand, QStyle::CE_SizeGrip, QStyle::CE_TabBarTab, QStyle::CE_TabBarTabLabel, QStyle::CE_TabBarTabShape, QStyle::CE_ToolBar, QStyle::CE_ToolBoxTab, QStyle::CE_ToolButtonLabel, QRect::center(), QBrush::color(), d, QColor::dark(), QPalette::Dark, Qt::DashLine, QStyleOptionButton::DefaultButton, Qt::Dense4Pattern, QIcon::Disabled, drawArrow(), QStyle::drawItemPixmap(), QStyle::drawItemText(), drawPrimitive(), QPainter::drawRect(), QPainter::end(), QPixmap::fromImage(), h, QStyleOptionButton::HasMenu, header(), QPixmap::height(), QRect::height(), QSize::height(), QPalette::highlight(), QPalette::Highlight, QPalette::HighlightedText, i, QStyleOptionTab::icon, QStyleOptionTabV2::iconSize, QRect::intersected(), QStyleOptionProgressBarV2::invertedAppearance, QIcon::isNull(), QPixmap::isNull(), QString::isNull(), QRect::isValid(), QApplication::layoutDirection(), QRect::left(), Qt::LeftToRight, QStyleOptionFrame::lineWidth, m, mask, QStyleOptionFrame::midLineWidth, Qt::NoBrush, QStyleOptionHeader::None, Qt::NoPen, QIcon::Normal, QPalette::NoRole, QIcon::Off, QIcon::On, QStyleOptionTab::OnlyOneTab, Qt::OpaqueMode, QStyleOptionProgressBarV2::orientation, p, QWidget::palette(), QStyleOption::palette, QWidget::parentWidget(), path, QStyle::PE_FrameDefaultButton, QStyle::PE_FrameFocusRect, QStyle::PE_IndicatorArrowDown, QStyle::PE_IndicatorArrowUp, QStyle::PE_IndicatorCheckBox, QStyle::PE_IndicatorHeaderArrow, QStyle::PE_IndicatorProgressChunk, QStyle::PE_IndicatorRadioButton, QStyle::PE_PanelButtonCommand, QStyle::PE_PanelToolBar, pixelMetric(), QIcon::pixmap(), QStyle::PM_ButtonDefaultIndicator, QStyle::PM_ButtonShiftHorizontal, QStyle::PM_ButtonShiftVertical, QStyle::PM_DefaultFrameWidth, QStyle::PM_MenuButtonIndicator, QStyle::PM_ProgressBarChunkWidth, QStyle::PM_SmallIconSize, QStyle::PM_TabBarTabOverlap, QStyle::PM_TabBarTabShiftHorizontal, QStyle::PM_TabBarTabShiftVertical, qDrawShadePanel(), qMin(), QStyleOption::rect, QRubberBand::Rectangle, reverse(), right(), QRect::right(), Qt::RightToLeft, QTabBar::RoundedEast, QTabBar::RoundedWest, QPoint::rx(), s, QStyle::SC_ComboBoxEditField, QStyle::SE_CheckBoxContents, QStyle::SE_CheckBoxFocusRect, QStyle::SE_CheckBoxIndicator, QStyle::SE_HeaderArrow, QStyle::SE_HeaderLabel, QStyle::SE_ProgressBarContents, QStyle::SE_ProgressBarGroove, QStyle::SE_ProgressBarLabel, QStyle::SE_PushButtonContents, QStyle::SE_PushButtonFocusRect, QStyle::SE_RadioButtonContents, QStyle::SE_RadioButtonFocusRect, QStyle::SE_RadioButtonIndicator, QPainter::setBackground(), QPainter::setBackgroundMode(), QRect::setBottom(), QPainter::setBrush(), QPalette::setColor(), QRect::setCoords(), QRect::setHeight(), QRect::setLeft(), QPainter::setPen(), QRect::setRect(), QRect::setRight(), QRect::setWidth(), QStyle::SH_RubberBand_Mask, QStyle::SH_UnderlineShortcut, QStyleOptionTab::shape, QRect::size(), QPixmap::size(), QString::size(), QStyleOption::state, QStyle::State_AutoRaise, QStyle::State_DownArrow, QStyle::State_Enabled, QStyle::State_HasFocus, QStyle::State_MouseOver, QStyle::State_None, QStyle::State_On, QStyle::State_Selected, QStyle::State_Sunken, styleHint(), subControlRect(), subElementRect(), tb, QWidget::testAttribute(), Qt::TextDontClip, Qt::TextHideMnemonic, Qt::TextShowMnemonic, Qt::TextSingleLine, QPixmap::toImage(), Qt::ToolButtonIconOnly, Qt::ToolButtonTextOnly, Qt::ToolButtonTextUnderIcon, QRect::top(), Qt::TopLeftCorner, Qt::TopRightCorner, QRect::translate(), QTabBar::TriangularEast, QTabBar::TriangularNorth, QTabBar::TriangularSouth, QTabBar::TriangularWest, u, Qt::Vertical, verticalTabs(), QStyle::visualAlignment(), QStyle::visualPos(), w, Qt::WA_NoSystemBackground, QRect::width(), QPixmap::width(), QSize::width(), QPalette::Window, QPalette::WindowText, QRect::x(), x, QRect::y(), QPoint::y(), and y.
Referenced by drawComplexControl(), QCDEStyle::drawControl(), QPlastiqueStyle::drawControl(), QCleanlooksStyle::drawControl(), QMotifStyle::drawControl(), QWindowsStyle::drawControl(), and QStyleSheetStyle::drawControl().
00673 { 00674 switch (element) { 00675 00676 case CE_PushButton: 00677 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { 00678 drawControl(CE_PushButtonBevel, btn, p, widget); 00679 QStyleOptionButton subopt = *btn; 00680 subopt.rect = subElementRect(SE_PushButtonContents, btn, widget); 00681 drawControl(CE_PushButtonLabel, &subopt, p, widget); 00682 if (btn->state & State_HasFocus) { 00683 QStyleOptionFocusRect fropt; 00684 fropt.QStyleOption::operator=(*btn); 00685 fropt.rect = subElementRect(SE_PushButtonFocusRect, btn, widget); 00686 drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); 00687 } 00688 } 00689 break; 00690 case CE_PushButtonBevel: 00691 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { 00692 QRect br = btn->rect; 00693 int dbi = pixelMetric(PM_ButtonDefaultIndicator, btn, widget); 00694 if (btn->features & QStyleOptionButton::DefaultButton) 00695 drawPrimitive(PE_FrameDefaultButton, opt, p, widget); 00696 if (btn->features & QStyleOptionButton::AutoDefaultButton) 00697 br.setCoords(br.left() + dbi, br.top() + dbi, br.right() - dbi, br.bottom() - dbi); 00698 00699 QStyleOptionButton tmpBtn = *btn; 00700 tmpBtn.rect = br; 00701 drawPrimitive(PE_PanelButtonCommand, &tmpBtn, p, widget); 00702 00703 if (btn->features & QStyleOptionButton::HasMenu) { 00704 int mbi = pixelMetric(PM_MenuButtonIndicator, btn, widget); 00705 QRect ir = btn->rect; 00706 QStyleOptionButton newBtn = *btn; 00707 newBtn.rect = QRect(ir.right() - mbi, ir.height() - 20, mbi, ir.height() - 4); 00708 drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget); 00709 } 00710 } 00711 break; 00712 case CE_PushButtonLabel: 00713 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { 00714 QRect ir = btn->rect; 00715 uint tf = Qt::AlignVCenter | Qt::TextShowMnemonic; 00716 if (!styleHint(SH_UnderlineShortcut, btn, widget)) 00717 tf |= Qt::TextHideMnemonic; 00718 00719 if (btn->state & (State_On | State_Sunken)) 00720 ir.translate(pixelMetric(PM_ButtonShiftHorizontal, opt, widget), 00721 pixelMetric(PM_ButtonShiftVertical, opt, widget)); 00722 if (!btn->icon.isNull()) { 00723 QIcon::Mode mode = btn->state & State_Enabled ? QIcon::Normal 00724 : QIcon::Disabled; 00725 if (mode == QIcon::Normal && btn->state & State_HasFocus) 00726 mode = QIcon::Active; 00727 QIcon::State state = QIcon::Off; 00728 if (btn->state & State_On) 00729 state = QIcon::On; 00730 QPixmap pixmap = btn->icon.pixmap(btn->iconSize, mode, state); 00731 int pixw = pixmap.width(); 00732 int pixh = pixmap.height(); 00733 //Center the icon if there is no text 00734 00735 QPoint point; 00736 if (btn->text.isEmpty()) { 00737 point = QPoint(ir.x() + ir.width() / 2 - pixw / 2, 00738 ir.y() + ir.height() / 2 - pixh / 2); 00739 } else { 00740 point = QPoint(ir.x() + 2, ir.y() + ir.height() / 2 - pixh / 2); 00741 } 00742 if (btn->direction == Qt::RightToLeft) 00743 point.rx() += pixw; 00744 00745 if ((btn->state & (State_On | State_Sunken)) && btn->direction == Qt::RightToLeft) 00746 point.rx() -= pixelMetric(PM_ButtonShiftHorizontal, opt, widget) * 2; 00747 00748 p->drawPixmap(visualPos(btn->direction, btn->rect, point), pixmap); 00749 00750 if (btn->direction == Qt::RightToLeft) 00751 ir.translate(-4, 0); 00752 else 00753 ir.translate(pixw + 4, 0); 00754 ir.setWidth(ir.width() - (pixw + 4)); 00755 // left-align text if there is 00756 if (!btn->text.isEmpty()) 00757 tf |= Qt::AlignLeft; 00758 } else { 00759 tf |= Qt::AlignHCenter; 00760 } 00761 drawItemText(p, ir, tf, btn->palette, (btn->state & State_Enabled), 00762 btn->text, QPalette::ButtonText); 00763 } 00764 break; 00765 case CE_RadioButton: 00766 case CE_CheckBox: 00767 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { 00768 bool isRadio = (element == CE_RadioButton); 00769 QStyleOptionButton subopt = *btn; 00770 subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator 00771 : SE_CheckBoxIndicator, btn, widget); 00772 drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox, 00773 &subopt, p, widget); 00774 subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents 00775 : SE_CheckBoxContents, btn, widget); 00776 drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, p, widget); 00777 if (btn->state & State_HasFocus) { 00778 QStyleOptionFocusRect fropt; 00779 fropt.QStyleOption::operator=(*btn); 00780 fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect 00781 : SE_CheckBoxFocusRect, btn, widget); 00782 drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); 00783 } 00784 } 00785 break; 00786 case CE_RadioButtonLabel: 00787 case CE_CheckBoxLabel: 00788 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { 00789 uint alignment = visualAlignment(btn->direction, Qt::AlignLeft | Qt::AlignVCenter); 00790 00791 if (!styleHint(SH_UnderlineShortcut, btn, widget)) 00792 alignment |= Qt::TextHideMnemonic; 00793 QPixmap pix; 00794 QRect textRect = btn->rect; 00795 if (!btn->icon.isNull()) { 00796 pix = btn->icon.pixmap(btn->iconSize, btn->state & State_Enabled ? QIcon::Normal : QIcon::Disabled); 00797 drawItemPixmap(p, btn->rect, alignment, pix); 00798 if (btn->direction == Qt::RightToLeft) 00799 textRect.setRight(textRect.right() - btn->iconSize.width() - 4); 00800 else 00801 textRect.setLeft(textRect.left() + btn->iconSize.width() + 4); 00802 } 00803 if (!btn->text.isEmpty()){ 00804 drawItemText(p, textRect, alignment | Qt::TextShowMnemonic, 00805 btn->palette, btn->state & State_Enabled, btn->text, QPalette::WindowText); 00806 } 00807 } 00808 break; 00809 #ifndef QT_NO_MENU 00810 case CE_MenuScroller: { 00811 p->fillRect(opt->rect, opt->palette.background()); 00812 QStyleOption arrowOpt = *opt; 00813 arrowOpt.state |= State_Enabled; 00814 drawPrimitive(((opt->state & State_DownArrow) ? PE_IndicatorArrowDown : PE_IndicatorArrowUp), 00815 &arrowOpt, p, widget); 00816 break; } 00817 case CE_MenuTearoff: 00818 if (opt->state & State_Selected) 00819 p->fillRect(opt->rect, opt->palette.brush(QPalette::Highlight)); 00820 else 00821 p->fillRect(opt->rect, opt->palette.brush(QPalette::Button)); 00822 p->setPen(QPen(opt->palette.dark().color(), 1, Qt::DashLine)); 00823 p->drawLine(opt->rect.x() + 2, opt->rect.y() + opt->rect.height() / 2 - 1, 00824 opt->rect.x() + opt->rect.width() - 4, 00825 opt->rect.y() + opt->rect.height() / 2 - 1); 00826 p->setPen(QPen(opt->palette.light().color(), 1, Qt::DashLine)); 00827 p->drawLine(opt->rect.x() + 2, opt->rect.y() + opt->rect.height() / 2, 00828 opt->rect.x() + opt->rect.width() - 4, opt->rect.y() + opt->rect.height() / 2); 00829 break; 00830 #endif // QT_NO_MENU 00831 #ifndef QT_NO_MENUBAR 00832 case CE_MenuBarItem: 00833 if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) { 00834 uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip 00835 | Qt::TextSingleLine; 00836 if (!styleHint(SH_UnderlineShortcut, mbi, widget)) 00837 alignment |= Qt::TextHideMnemonic; 00838 QPixmap pix = mbi->icon.pixmap(pixelMetric(PM_SmallIconSize), (mbi->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled); 00839 if (!pix.isNull()) 00840 drawItemPixmap(p,mbi->rect, alignment, pix); 00841 else 00842 drawItemText(p, mbi->rect, alignment, mbi->palette, mbi->state & State_Enabled, 00843 mbi->text, QPalette::ButtonText); 00844 } 00845 break; 00846 case CE_MenuBarEmptyArea: 00847 if (widget && !widget->testAttribute(Qt::WA_NoSystemBackground)) 00848 p->eraseRect(opt->rect); 00849 break; 00850 #endif // QT_NO_MENUBAR 00851 #ifndef QT_NO_PROGRESSBAR 00852 case CE_ProgressBar: 00853 if (const QStyleOptionProgressBar *pb 00854 = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) { 00855 QStyleOptionProgressBarV2 subopt = *pb; 00856 subopt.rect = subElementRect(SE_ProgressBarGroove, pb, widget); 00857 drawControl(CE_ProgressBarGroove, &subopt, p, widget); 00858 subopt.rect = subElementRect(SE_ProgressBarContents, pb, widget); 00859 drawControl(CE_ProgressBarContents, &subopt, p, widget); 00860 if (pb->textVisible) { 00861 subopt.rect = subElementRect(SE_ProgressBarLabel, pb, widget); 00862 drawControl(CE_ProgressBarLabel, &subopt, p, widget); 00863 } 00864 } 00865 break; 00866 case CE_ProgressBarGroove: 00867 qDrawShadePanel(p, opt->rect, opt->palette, true, 1, 00868 &opt->palette.brush(QPalette::Window)); 00869 break; 00870 case CE_ProgressBarLabel: 00871 if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) { 00872 bool vertical = false; 00873 if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) { 00874 vertical = (pb2->orientation == Qt::Vertical); 00875 } 00876 if (!vertical) { 00877 QPalette::ColorRole textRole = QPalette::NoRole; 00878 if ((pb->textAlignment & Qt::AlignCenter) && pb->textVisible 00879 && ((pb->progress - pb->minimum) * 2 >= (pb->maximum - pb->minimum))) { 00880 textRole = QPalette::HighlightedText; 00881 } 00882 drawItemText(p, pb->rect, Qt::AlignCenter | Qt::TextSingleLine, pb->palette, 00883 pb->state & State_Enabled, pb->text, textRole); 00884 } 00885 } 00886 break; 00887 case CE_ProgressBarContents: 00888 if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) { 00889 00890 QRect rect = pb->rect; 00891 bool vertical = false; 00892 bool inverted = false; 00893 00894 // Get extra style options if version 2 00895 const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt); 00896 if (pb2) { 00897 vertical = (pb2->orientation == Qt::Vertical); 00898 inverted = pb2->invertedAppearance; 00899 } 00900 00901 QMatrix m; 00902 if (vertical) { 00903 rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height 00904 m.translate(rect.height(), 0.0); 00905 m.rotate(90); 00906 } 00907 00908 QPalette pal2 = pb->palette; 00909 // Correct the highlight color if it is the same as the background 00910 if (pal2.highlight() == pal2.background()) 00911 pal2.setColor(QPalette::Highlight, pb->palette.color(QPalette::Active, 00912 QPalette::Highlight)); 00913 bool reverse = ((!vertical && (pb->direction == Qt::RightToLeft)) || vertical); 00914 if (inverted) 00915 reverse = !reverse; 00916 int fw = 2; 00917 int w = rect.width() - 2 * fw; 00918 if (pb->minimum == 0 && pb->maximum == 0) { 00919 // draw busy indicator 00920 int x = (pb->progress - pb->minimum) % (w * 2); 00921 if (x > w) 00922 x = 2 * w - x; 00923 x = reverse ? rect.right() - x : x + rect.x(); 00924 p->setPen(QPen(pal2.highlight().color(), 4)); 00925 p->drawLine(x, rect.y() + 1, x, rect.height() - fw); 00926 } else { 00927 const int unit_width = pixelMetric(PM_ProgressBarChunkWidth, pb, widget); 00928 int u; 00929 if (unit_width > 1) 00930 u = (rect.width() + unit_width / 3) / unit_width; 00931 else 00932 u = w / unit_width; 00933 int p_v = pb->progress - pb->minimum; 00934 int t_s = pb->maximum - pb->minimum ? pb->maximum - pb->minimum : 1; 00935 00936 if (u > 0 && p_v >= INT_MAX / u && t_s >= u) { 00937 // scale down to something usable. 00938 p_v /= u; 00939 t_s /= u; 00940 } 00941 00942 // nu < tnu, if last chunk is only a partial chunk 00943 int tnu, nu; 00944 tnu = nu = p_v * u / t_s; 00945 00946 if (nu * unit_width > w) 00947 --nu; 00948 00949 // Draw nu units out of a possible u of unit_width 00950 // width, each a rectangle bordered by background 00951 // color, all in a sunken panel with a percentage text 00952 // display at the end. 00953 int x = 0; 00954 int x0 = reverse ? rect.right() - ((unit_width > 1) ? unit_width : fw) 00955 : rect.x() + fw; 00956 00957 QStyleOptionProgressBarV2 pbBits = *pb; 00958 pbBits.rect = rect; 00959 pbBits.palette = pal2; 00960 int myY = pbBits.rect.y(); 00961 int myHeight = pbBits.rect.height(); 00962 pbBits.state = State_None; 00963 for (int i = 0; i < nu; ++i) { 00964 pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight); 00965 pbBits.rect = m.mapRect(pbBits.rect); 00966 drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget); 00967 x += reverse ? -unit_width : unit_width; 00968 } 00969 00970 // Draw the last partial chunk to fill up the 00971 // progressbar entirely 00972 if (nu < tnu) { 00973 int pixels_left = w - (nu * unit_width); 00974 int offset = reverse ? x0 + x + unit_width-pixels_left : x0 + x; 00975 pbBits.rect.setRect(offset, myY, pixels_left, myHeight); 00976 pbBits.rect = m.mapRect(pbBits.rect); 00977 drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget); 00978 } 00979 } 00980 } 00981 break; 00982 #endif // QT_NO_PROGRESSBAR 00983 case CE_HeaderLabel: 00984 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) { 00985 QRect rect = header->rect; 00986 if (!header->icon.isNull()) { 00987 QPixmap pixmap 00988 = header->icon.pixmap(pixelMetric(PM_SmallIconSize), (header->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled); 00989 int pixw = pixmap.width(); 00990 00991 QRect aligned = alignedRect(header->direction, QFlag(header->iconAlignment), pixmap.size(), rect); 00992 QRect inter = aligned.intersected(rect); 00993 p->drawPixmap(inter.x(), inter.y(), pixmap, inter.x() - aligned.x(), inter.y() - aligned.y(), inter.width(), inter.height()); 00994 00995 if (header->direction == Qt::LeftToRight) 00996 rect.setLeft(rect.left() + pixw + 2); 00997 else 00998 rect.setRight(rect.right() - pixw - 2); 00999 } 01000 drawItemText(p, rect, header->textAlignment, header->palette, 01001 (header->state & State_Enabled), header->text, QPalette::ButtonText); 01002 } 01003 break; 01004 #ifndef QT_NO_TOOLBUTTON 01005 case CE_ToolButtonLabel: 01006 if (const QStyleOptionToolButton *toolbutton 01007 = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) { 01008 QRect rect = toolbutton->rect; 01009 int shiftX = 0; 01010 int shiftY = 0; 01011 if (toolbutton->state & (State_Sunken | State_On)) { 01012 shiftX = pixelMetric(PM_ButtonShiftHorizontal, toolbutton, widget); 01013 shiftY = pixelMetric(PM_ButtonShiftVertical, toolbutton, widget); 01014 } 01015 // Arrow type always overrules and is always shown 01016 bool hasArrow = toolbutton->features & QStyleOptionToolButton::Arrow; 01017 if ((!hasArrow && toolbutton->icon.isNull()) && !toolbutton->text.isEmpty() 01018 || toolbutton->toolButtonStyle == Qt::ToolButtonTextOnly) { 01019 int alignment = Qt::AlignCenter | Qt::TextShowMnemonic; 01020 if (!styleHint(SH_UnderlineShortcut, opt, widget)) 01021 alignment |= Qt::TextHideMnemonic; 01022 rect.translate(shiftX, shiftY); 01023 drawItemText(p, rect, alignment, toolbutton->palette, 01024 opt->state & State_Enabled, toolbutton->text, 01025 QPalette::ButtonText); 01026 } else { 01027 QPixmap pm; 01028 QSize pmSize = toolbutton->iconSize; 01029 if (!toolbutton->icon.isNull()) { 01030 QIcon::State state = toolbutton->state & State_On ? QIcon::On : QIcon::Off; 01031 QIcon::Mode mode; 01032 if (!(toolbutton->state & State_Enabled)) 01033 mode = QIcon::Disabled; 01034 else if ((opt->state & State_MouseOver) && (opt->state & State_AutoRaise)) 01035 mode = QIcon::Active; 01036 else 01037 mode = QIcon::Normal; 01038 pm = toolbutton->icon.pixmap(toolbutton->rect.size().boundedTo(toolbutton->iconSize), 01039 mode, state); 01040 pmSize = pm.size(); 01041 } 01042 01043 if (toolbutton->toolButtonStyle != Qt::ToolButtonIconOnly) { 01044 p->setFont(toolbutton->font); 01045 QRect pr = rect, 01046 tr = rect; 01047 int alignment = Qt::TextShowMnemonic; 01048 if (!styleHint(SH_UnderlineShortcut, opt, widget)) 01049 alignment |= Qt::TextHideMnemonic; 01050 01051 if (toolbutton->toolButtonStyle == Qt::ToolButtonTextUnderIcon) { 01052 pr.setHeight(pmSize.height() + 6); 01053 01054 tr.adjust(0, pr.bottom(), 0, -3); 01055 pr.translate(shiftX, shiftY); 01056 if (!hasArrow) { 01057 drawItemPixmap(p, pr, Qt::AlignCenter, pm); 01058 } else { 01059 drawArrow(this, toolbutton, pr, p, widget); 01060 } 01061 alignment |= Qt::AlignCenter; 01062 } else { 01063 pr.setWidth(pmSize.width() + 8); 01064 tr.adjust(pr.right(), 0, 0, 0); 01065 pr.translate(shiftX, shiftY); 01066 if (!hasArrow) { 01067 drawItemPixmap(p, pr, Qt::AlignCenter, pm); 01068 } else { 01069 drawArrow(this, toolbutton, pr, p, widget); 01070 } 01071 alignment |= Qt::AlignLeft | Qt::AlignVCenter; 01072 } 01073 tr.translate(shiftX, shiftY); 01074 drawItemText(p, tr, alignment, toolbutton->palette, 01075 toolbutton->state & State_Enabled, toolbutton->text, 01076 QPalette::ButtonText); 01077 } else { 01078 rect.translate(shiftX, shiftY); 01079 if (hasArrow) { 01080 drawArrow(this, toolbutton, rect, p, widget); 01081 } else { 01082 drawItemPixmap(p, rect, Qt::AlignCenter, pm); 01083 } 01084 } 01085 } 01086 } 01087 break; 01088 #endif // QT_NO_TOOLBUTTON 01089 #ifndef QT_NO_TOOLBOX 01090 case CE_ToolBoxTab: 01091 if (const QStyleOptionToolBox *tb = qstyleoption_cast<const QStyleOptionToolBox *>(opt)) { 01092 int d = 20 + tb->rect.height() - 3; 01093 QPolygon a(7); 01094 a.setPoint(0, -1, tb->rect.height() + 1); 01095 a.setPoint(1, -1, 1); 01096 a.setPoint(2, tb->rect.width() - d, 1); 01097 a.setPoint(3, tb->rect.width() - 20, tb->rect.height() - 2); 01098 a.setPoint(4, tb->rect.width() - 1, tb->rect.height() - 2); 01099 a.setPoint(5, tb->rect.width() - 1, tb->rect.height() + 1); 01100 a.setPoint(6, -1, tb->rect.height() + 1); 01101 01102 p->setPen(tb->palette.mid().color().dark(150)); 01103 p->drawPolygon(a); 01104 p->setPen(tb->palette.light().color()); 01105 p->drawLine(0, 2, tb->rect.width() - d, 2); 01106 p->drawLine(tb->rect.width() - d - 1, 2, tb->rect.width() - 21, tb->rect.height() - 1); 01107 p->drawLine(tb->rect.width() - 20, tb->rect.height() - 1, 01108 tb->rect.width(), tb->rect.height() - 1); 01109 p->setBrush(Qt::NoBrush); 01110 } 01111 break; 01112 #endif // QT_NO_TOOLBOX 01113 #ifndef QT_NO_TABBAR 01114 case CE_TabBarTab: 01115 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) { 01116 drawControl(CE_TabBarTabShape, tab, p, widget); 01117 drawControl(CE_TabBarTabLabel, tab, p, widget); 01118 } 01119 break; 01120 case CE_TabBarTabShape: 01121 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) { 01122 p->save(); 01123 01124 QRect rect(tab->rect); 01125 bool selected = tab->state & State_Selected; 01126 bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab; 01127 int tabOverlap = onlyOne ? 0 : pixelMetric(PM_TabBarTabOverlap, opt, widget); 01128 01129 if (!selected) { 01130 switch (tab->shape) { 01131 case QTabBar::TriangularNorth: 01132 rect.adjust(0, 0, 0, -tabOverlap); 01133 if(!selected) 01134 rect.adjust(1, 1, -1, 0); 01135 break; 01136 case QTabBar::TriangularSouth: 01137 rect.adjust(0, tabOverlap, 0, 0); 01138 if(!selected) 01139 rect.adjust(1, 0, -1, -1); 01140 break; 01141 case QTabBar::TriangularEast: 01142 rect.adjust(tabOverlap, 0, 0, 0); 01143 if(!selected) 01144 rect.adjust(0, 1, -1, -1); 01145 break; 01146 case QTabBar::TriangularWest: 01147 rect.adjust(0, 0, -tabOverlap, 0); 01148 if(!selected) 01149 rect.adjust(1, 1, 0, -1); 01150 break; 01151 default: 01152 break; 01153 } 01154 } 01155 01156 p->setPen(QPen(tab->palette.foreground(), 0)); 01157 if (selected) { 01158 p->setBrush(tab->palette.base()); 01159 } else { 01160 if (widget && widget->parentWidget()) 01161 p->setBrush(widget->parentWidget()->palette().background()); 01162 else 01163 p->setBrush(tab->palette.background()); 01164 } 01165 01166 int y; 01167 int x; 01168 QPolygon a(10); 01169 switch (tab->shape) { 01170 case QTabBar::TriangularNorth: 01171 case QTabBar::TriangularSouth: { 01172 a.setPoint(0, 0, -1); 01173 a.setPoint(1, 0, 0); 01174 y = rect.height() - 2; 01175 x = y / 3; 01176 a.setPoint(2, x++, y - 1); 01177 ++x; 01178 a.setPoint(3, x++, y++); 01179 a.setPoint(4, x, y); 01180 01181 int i; 01182 int right = rect.width() - 1; 01183 for (i = 0; i < 5; ++i) 01184 a.setPoint(9 - i, right - a.point(i).x(), a.point(i).y()); 01185 if (tab->shape == QTabBar::TriangularNorth) 01186 for (i = 0; i < 10; ++i) 01187 a.setPoint(i, a.point(i).x(), rect.height() - 1 - a.point(i).y()); 01188 01189 a.translate(rect.left(), rect.top()); 01190 p->setRenderHint(QPainter::Antialiasing); 01191 p->translate(0, 0.5); 01192 01193 QPainterPath path; 01194 path.addPolygon(a); 01195 p->drawPath(path); 01196 break; } 01197 case QTabBar::TriangularEast: 01198 case QTabBar::TriangularWest: { 01199 a.setPoint(0, -1, 0); 01200 a.setPoint(1, 0, 0); 01201 x = rect.width() - 2; 01202 y = x / 3; 01203 a.setPoint(2, x - 1, y++); 01204 ++y; 01205 a.setPoint(3, x++, y++); 01206 a.setPoint(4, x, y); 01207 int i; 01208 int bottom = rect.height() - 1; 01209 for (i = 0; i < 5; ++i) 01210 a.setPoint(9 - i, a.point(i).x(), bottom - a.point(i).y()); 01211 if (tab->shape == QTabBar::TriangularWest) 01212 for (i = 0; i < 10; ++i) 01213 a.setPoint(i, rect.width() - 1 - a.point(i).x(), a.point(i).y()); 01214 a.translate(rect.left(), rect.top()); 01215 p->setRenderHint(QPainter::Antialiasing); 01216 p->translate(0.5, 0); 01217 QPainterPath path; 01218 path.addPolygon(a); 01219 p->drawPath(path); 01220 break; } 01221 default: 01222 break; 01223 } 01224 p->restore(); 01225 } 01226 break; 01227 case CE_TabBarTabLabel: 01228 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) { 01229 QStyleOptionTabV2 tabV2(*tab); 01230 QRect tr = tabV2.rect; 01231 bool verticalTabs = tabV2.shape == QTabBar::RoundedEast 01232 || tabV2.shape == QTabBar::RoundedWest 01233 || tabV2.shape == QTabBar::TriangularEast 01234 || tabV2.shape == QTabBar::TriangularWest; 01235 bool selected = tabV2.state & State_Selected; 01236 if (verticalTabs) { 01237 p->save(); 01238 int newX, newY, newRot; 01239 if (tabV2.shape == QTabBar::RoundedEast || tabV2.shape == QTabBar::TriangularEast) { 01240 newX = tr.width(); 01241 newY = tr.y(); 01242 newRot = 90; 01243 } else { 01244 newX = 0; 01245 newY = tr.y() + tr.height(); 01246 newRot = -90; 01247 } 01248 tr.setRect(0, 0, tr.height(), tr.width()); 01249 QMatrix m; 01250 m.translate(newX, newY); 01251 m.rotate(newRot); 01252 p->setMatrix(m, true); 01253 } 01254 tr.adjust(0, 0, pixelMetric(QStyle::PM_TabBarTabShiftHorizontal, tab, widget), 01255 pixelMetric(QStyle::PM_TabBarTabShiftVertical, tab, widget)); 01256 01257 if (selected) 01258 { 01259 tr.setBottom(tr.bottom() - pixelMetric(QStyle::PM_TabBarTabShiftVertical, tab, 01260 widget)); 01261 tr.setRight(tr.right() - pixelMetric(QStyle::PM_TabBarTabShiftHorizontal, tab, 01262 widget)); 01263 } 01264 01265 int alignment = Qt::AlignCenter | Qt::TextShowMnemonic; 01266 if (!styleHint(SH_UnderlineShortcut, opt, widget)) 01267 alignment |= Qt::TextHideMnemonic; 01268 if (!tabV2.icon.isNull()) { 01269 QSize iconSize = tabV2.iconSize; 01270 if (!iconSize.isValid()) { 01271 int iconExtent = pixelMetric(PM_SmallIconSize); 01272 iconSize = QSize(iconExtent, iconExtent); 01273 } 01274 QPixmap tabIcon = tabV2.icon.pixmap(iconSize, 01275 (tabV2.state & State_Enabled) ? QIcon::Normal 01276 : QIcon::Disabled); 01277 p->drawPixmap(tr.left() + 6, tr.center().y() - tabIcon.height() / 2, tabIcon); 01278 tr.setLeft(tr.left() + iconSize.width() + 4); 01279 } 01280 01281 drawItemText(p, tr, alignment, tab->palette, tab->state & State_Enabled, tab->text, QPalette::WindowText); 01282 if (verticalTabs) 01283 p->restore(); 01284 01285 if (tabV2.state & State_HasFocus) { 01286 const int OFFSET = 1 + pixelMetric(PM_DefaultFrameWidth); 01287 01288 int x1, x2; 01289 x1 = tabV2.rect.left(); 01290 x2 = tabV2.rect.right() - 1; 01291 01292 QStyleOptionFocusRect fropt; 01293 fropt.QStyleOption::operator=(*tab); 01294 fropt.rect.setRect(x1 + 1 + OFFSET, tabV2.rect.y() + OFFSET, 01295 x2 - x1 - 2*OFFSET, tabV2.rect.height() - 2*OFFSET); 01296 drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); 01297 } 01298 } 01299 break; 01300 #endif // QT_NO_TABBAR 01301 #ifndef QT_NO_SIZEGRIP 01302 case CE_SizeGrip: { 01303 p->save(); 01304 int x, y, w, h; 01305 opt->rect.getRect(&x, &y, &w, &h); 01306 01307 int sw = qMin(h, w); 01308 if (h > w) 01309 p->translate(0, h - w); 01310 else 01311 p->translate(w - h, 0); 01312 01313 int sx = x; 01314 int sy = y; 01315 int s = sw / 3; 01316 01317 Qt::Corner corner; 01318 if (const QStyleOptionSizeGrip *sgOpt = qstyleoption_cast<const QStyleOptionSizeGrip *>(opt)) 01319 corner = sgOpt->corner; 01320 else if (opt->direction == Qt::RightToLeft) 01321 corner = Qt::BottomLeftCorner; 01322 else 01323 corner = Qt::BottomRightCorner; 01324 01325 if (corner == Qt::BottomLeftCorner) { 01326 sx = x + sw; 01327 for (int i = 0; i < 4; ++i) { 01328 p->setPen(QPen(opt->palette.light().color(), 1)); 01329 p->drawLine(x, sy - 1 , sx + 1, sw); 01330 p->setPen(QPen(opt->palette.dark().color(), 1)); 01331 p->drawLine(x, sy, sx, sw); 01332 p->setPen(QPen(opt->palette.dark().color(), 1)); 01333 p->drawLine(x, sy + 1, sx - 1, sw); 01334 sx -= s; 01335 sy += s; 01336 } 01337 } else if (corner == Qt::BottomRightCorner) { 01338 for (int i = 0; i < 4; ++i) { 01339 p->setPen(QPen(opt->palette.light().color(), 1)); 01340 p->drawLine(sx - 1, sw, sw, sy - 1); 01341 p->setPen(QPen(opt->palette.dark().color(), 1)); 01342 p->drawLine(sx, sw, sw, sy); 01343 p->setPen(QPen(opt->palette.dark().color(), 1)); 01344 p->drawLine(sx + 1, sw, sw, sy + 1); 01345 sx += s; 01346 sy += s; 01347 } 01348 } else if (corner == Qt::TopRightCorner) { 01349 sy = y + sw; 01350 for (int i = 0; i < 4; ++i) { 01351 p->setPen(QPen(opt->palette.light().color(), 1)); 01352 p->drawLine(sx - 1, y, sw, sy + 1); 01353 p->setPen(QPen(opt->palette.dark().color(), 1)); 01354 p->drawLine(sx, y, sw, sy); 01355 p->setPen(QPen(opt->palette.dark().color(), 1)); 01356 p->drawLine(sx + 1, y, sw, sy - 1); 01357 sx += s; 01358 sy -= s; 01359 } 01360 } else if (corner == Qt::TopLeftCorner) { 01361 for (int i = 0; i < 4; ++i) { 01362 p->setPen(QPen(opt->palette.light().color(), 1)); 01363 p->drawLine(x, sy - 1, sx - 1, y); 01364 p->setPen(QPen(opt->palette.dark().color(), 1)); 01365 p->drawLine(x, sy, sx, y); 01366 p->setPen(QPen(opt->palette.dark().color(), 1)); 01367 p->drawLine(x, sy + 1, sx + 1, y); 01368 sx += s; 01369 sy += s; 01370 } 01371 } 01372 p->restore(); 01373 break; } 01374 #endif // QT_NO_SIZEGRIP 01375 #ifndef QT_NO_RUBBERBAND 01376 case CE_RubberBand: { 01377 if (const QStyleOptionRubberBand *rbOpt = qstyleoption_cast<const QStyleOptionRubberBand *>(opt)) { 01378 QPixmap tiledPixmap(16, 16); 01379 QPainter pixmapPainter(&tiledPixmap); 01380 pixmapPainter.setPen(Qt::NoPen); 01381 pixmapPainter.setBrush(Qt::Dense4Pattern); 01382 pixmapPainter.setBackground(QBrush(opt->palette.base())); 01383 pixmapPainter.setBackgroundMode(Qt::OpaqueMode); 01384 pixmapPainter.drawRect(0, 0, tiledPixmap.width(), tiledPixmap.height()); 01385 pixmapPainter.end(); 01386 // ### workaround for borked XRENDER 01387 tiledPixmap = QPixmap::fromImage(tiledPixmap.toImage()); 01388 01389 p->save(); 01390 QRect r = opt->rect; 01391 QStyleHintReturnMask mask; 01392 if (styleHint(QStyle::SH_RubberBand_Mask, opt, widget, &mask)) 01393 p->setClipRegion(mask.region); 01394 p->drawTiledPixmap(r.x(), r.y(), r.width(), r.height(), tiledPixmap); 01395 p->setPen(opt->palette.color(QPalette::Active, QPalette::WindowText)); 01396 p->setBrush(Qt::NoBrush); 01397 p->drawRect(r.adjusted(0, 0, -1, -1)); 01398 if (rbOpt->shape == QRubberBand::Rectangle) 01399 p->drawRect(r.adjusted(3, 3, -4, -4)); 01400 p->restore(); 01401 } 01402 break; } 01403 #endif // QT_NO_RUBBERBAND 01404 #ifndef QT_NO_DOCKWIDGET 01405 case CE_DockWidgetTitle: 01406 if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(opt)) { 01407 QRect r = dwOpt->rect.adjusted(0, 0, -1, -1); 01408 if (dwOpt->movable) { 01409 p->setPen(dwOpt->palette.color(QPalette::Dark)); 01410 p->drawRect(r); 01411 } 01412 01413 if (!dwOpt->title.isEmpty()) { 01414 const int indent = p->fontMetrics().descent(); 01415 drawItemText(p, r.adjusted(indent + 1, 1, -indent - 1, -1), 01416 Qt::AlignLeft | Qt::AlignVCenter, dwOpt->palette, 01417 dwOpt->state & State_Enabled, dwOpt->title, 01418 QPalette::WindowText); 01419 } 01420 } 01421 break; 01422 #endif // QT_NO_DOCKWIDGET 01423 case CE_Header: 01424 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) { 01425 QRegion clipRegion = p->clipRegion(); 01426 p->setClipRect(opt->rect); 01427 drawControl(CE_HeaderSection, header, p, widget); 01428 QStyleOptionHeader subopt = *header; 01429 subopt.rect = subElementRect(SE_HeaderLabel, header, widget); 01430 if (subopt.rect.isValid()) 01431 drawControl(CE_HeaderLabel, &subopt, p, widget); 01432 if (header->sortIndicator != QStyleOptionHeader::None) { 01433 subopt.rect = subElementRect(SE_HeaderArrow, opt, widget); 01434 drawPrimitive(PE_IndicatorHeaderArrow, &subopt, p, widget); 01435 } 01436 p->setClipRegion(clipRegion); 01437 } 01438 break; 01439 case CE_FocusFrame: 01440 p->fillRect(opt->rect, opt->palette.foreground()); 01441 break; 01442 case CE_HeaderSection: 01443 qDrawShadePanel(p, opt->rect, opt->palette, 01444 opt->state & State_Sunken, 1, 01445 &opt->palette.brush(QPalette::Button)); 01446 break; 01447 #ifndef QT_NO_COMBOBOX 01448 case CE_ComboBoxLabel: 01449 if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) { 01450 QRect editRect = subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget); 01451 p->save(); 01452 p->setClipRect(editRect); 01453 if (!cb->currentIcon.isNull()) { 01454 QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal 01455 : QIcon::Disabled; 01456 QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode); 01457 QRect iconRect(editRect); 01458 iconRect.setWidth(cb->iconSize.width() + 4); 01459 iconRect = alignedRect(QApplication::layoutDirection(), 01460 Qt::AlignLeft | Qt::AlignVCenter, 01461 iconRect.size(), editRect); 01462 if (cb->editable) 01463 p->fillRect(iconRect, opt->palette.brush(QPalette::Base)); 01464 drawItemPixmap(p, iconRect, Qt::AlignCenter, pixmap); 01465 01466 if (cb->direction == Qt::RightToLeft) 01467 editRect.translate(-4 - cb->iconSize.width(), 0); 01468 else 01469 editRect.translate(cb->iconSize.width() + 4, 0); 01470 } 01471 if (!cb->currentText.isEmpty() && !cb->editable) { 01472 drawItemText(p, editRect.adjusted(1, 0, -1, 0), Qt::AlignLeft | Qt::AlignVCenter, cb->palette, 01473 cb->state & State_Enabled, cb->currentText); 01474 } 01475 p->restore(); 01476 } 01477 break; 01478 #endif // QT_NO_COMBOBOX 01479 #ifndef QT_NO_TOOLBAR 01480 case CE_ToolBar: 01481 if (const QStyleOptionToolBar *toolBar = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) { 01482 // Compatibility with styles that use PE_PanelToolBar 01483 QStyleOptionFrame frame; 01484 frame.QStyleOption::operator=(*toolBar); 01485 frame.lineWidth = toolBar->lineWidth; 01486 frame.midLineWidth = toolBar->midLineWidth; 01487 drawPrimitive(PE_PanelToolBar, opt, p, widget); 01488 01489 if (widget && qobject_cast<QToolBar *>(widget->parentWidget())) 01490 break; 01491 qDrawShadePanel(p, toolBar->rect, toolBar->palette, false, toolBar->lineWidth, 01492 &toolBar->palette.brush(QPalette::Button)); 01493 } 01494 break; 01495 #endif // QT_NO_TOOLBAR 01496 default: 01497 break; 01498 } 01499 }
Here is the call graph for this function:

| QRect QCommonStyle::subElementRect | ( | SubElement | sr, | |
| const QStyleOption * | opt, | |||
| const QWidget * | widget = 0 | |||
| ) | const [virtual] |
Implements QStyle.
Definition at line 1505 of file qcommonstyle.cpp.
References QRect::adjust(), QRect::adjusted(), Qt::AlignAbsolute, Qt::AlignCenter, Qt::AlignLeft, Qt::AlignRight, Qt::AlignVCenter, QStyleOptionButton::AutoDefaultButton, h, header(), QRect::height(), Qt::Horizontal, QRect::intersected(), QRect::isEmpty(), QStyle::itemPixmapRect(), QStyle::itemTextRect(), QRect::moveTopLeft(), QStyleOptionHeader::None, QIcon::Normal, pixelMetric(), QStyle::PM_ButtonDefaultIndicator, QStyle::PM_DefaultFrameWidth, QStyle::PM_ExclusiveIndicatorHeight, QStyle::PM_ExclusiveIndicatorWidth, QStyle::PM_HeaderMargin, QStyle::PM_IndicatorHeight, QStyle::PM_IndicatorWidth, QStyle::PM_SliderControlThickness, QStyle::PM_SliderTickmarkOffset, QStyle::PM_TabBarBaseOverlap, qMax(), qMin(), QRect::right(), QTabBar::RoundedEast, QTabBar::RoundedNorth, QTabBar::RoundedSouth, QTabBar::RoundedWest, QStyle::SE_CheckBoxClickRect, QStyle::SE_CheckBoxContents, QStyle::SE_CheckBoxFocusRect, QStyle::SE_CheckBoxIndicator, QStyle::SE_ComboBoxFocusRect, QStyle::SE_FrameContents, QStyle::SE_HeaderArrow, QStyle::SE_HeaderLabel, QStyle::SE_LineEditContents, QStyle::SE_ProgressBarContents, QStyle::SE_ProgressBarGroove, QStyle::SE_ProgressBarLabel, QStyle::SE_PushButtonContents, QStyle::SE_PushButtonFocusRect, QStyle::SE_Q3DockWindowHandleRect, QStyle::SE_RadioButtonClickRect, QStyle::SE_RadioButtonContents, QStyle::SE_RadioButtonFocusRect, QStyle::SE_RadioButtonIndicator, QStyle::SE_SliderFocusRect, QStyle::SE_TabBarTearIndicator, QStyle::SE_TabWidgetLeftCorner, QStyle::SE_TabWidgetRightCorner, QStyle::SE_TabWidgetTabBar, QStyle::SE_TabWidgetTabContents, QStyle::SE_TabWidgetTabPane, QStyle::SE_ToolBoxTabContents, QStyle::SE_TreeViewDisclosureItem, QStyle::SE_ViewItemCheckIndicator, QRect::setCoords(), QRect::setHeight(), QRect::setRect(), QRect::setSize(), QRect::setWidth(), QStyle::SH_TabBar_Alignment, QStyle::State_Enabled, QStyle::State_Horizontal, styleHint(), Qt::TextShowMnemonic, QRect::translate(), QTabBar::TriangularEast, QTabBar::TriangularNorth, QTabBar::TriangularSouth, QTabBar::TriangularWest, Qt::Vertical, QStyle::visualRect(), w, QRect::width(), QRect::x(), x, QRect::y(), and y.
Referenced by drawControl(), sizeFromContents(), QMotifStyle::subElementRect(), and QWindowsStyle::subElementRect().
01506 { 01507 QRect r; 01508 switch (sr) { 01509 case SE_PushButtonContents: 01510 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { 01511 int dx1, dx2; 01512 dx1 = pixelMetric(PM_DefaultFrameWidth, btn, widget); 01513 if (btn->features & QStyleOptionButton::AutoDefaultButton) 01514 dx1 += pixelMetric(PM_ButtonDefaultIndicator, btn, widget); 01515 dx2 = dx1 * 2; 01516 r.setRect(opt->rect.x() + dx1, opt->rect.y() + dx1, opt->rect.width() - dx2, 01517 opt->rect.height() - dx2); 01518 r = visualRect(opt->direction, opt->rect, r); 01519 } 01520 break; 01521 case SE_PushButtonFocusRect: 01522 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { 01523 int dbw1 = 0, dbw2 = 0; 01524 if (btn->features & QStyleOptionButton::AutoDefaultButton){ 01525 dbw1 = pixelMetric(PM_ButtonDefaultIndicator, btn, widget); 01526 dbw2 = dbw1 * 2; 01527 } 01528 01529 int dfw1 = pixelMetric(PM_DefaultFrameWidth, btn, widget) + 1, 01530 dfw2 = dfw1 * 2; 01531 01532 r.setRect(btn->rect.x() + dfw1 + dbw1, btn->rect.y() + dfw1 + dbw1, 01533 btn->rect.width() - dfw2 - dbw2, btn->rect.height()- dfw2 - dbw2); 01534 r = visualRect(opt->direction, opt->rect, r); 01535 } 01536 break; 01537 case SE_ViewItemCheckIndicator: 01538 r = subElementRect(SE_CheckBoxIndicator, opt, widget); 01539 break; 01540 case SE_CheckBoxIndicator: 01541 { 01542 int h = pixelMetric(PM_IndicatorHeight, opt, widget); 01543 r.setRect(opt->rect.x(), opt->rect.y() + ((opt->rect.height() - h) / 2), 01544 pixelMetric(PM_IndicatorWidth, opt, widget), h); 01545 r = visualRect(opt->direction, opt->rect, r); 01546 } 01547 break; 01548 01549 case SE_CheckBoxContents: 01550 { 01551 // Deal with the logical first, then convert it back to screen coords. 01552 QRect ir = visualRect(opt->direction, opt->rect, 01553 subElementRect(SE_CheckBoxIndicator, opt, widget)); 01554 r.setRect(ir.right() + 6, opt->rect.y(), opt->rect.width() - ir.width() - 6, 01555 opt->rect.height()); 01556 r = visualRect(opt->direction, opt->rect, r); 01557 } 01558 break; 01559 01560 case SE_CheckBoxFocusRect: 01561 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { 01562 if (btn->icon.isNull() && btn->text.isEmpty()) { 01563 r = subElementRect(SE_CheckBoxIndicator, opt, widget); 01564 r.adjust(1, 1, -1, -1); 01565 break; 01566 } 01567 // As above, deal with the logical first, then convert it back to screen coords. 01568 QRect cr = visualRect(btn->direction, btn->rect, 01569 subElementRect(SE_CheckBoxContents, btn, widget)); 01570 01571 QRect iconRect, textRect; 01572 if (!btn->text.isEmpty()) { 01573 textRect = itemTextRect(opt->fontMetrics, cr, Qt::AlignAbsolute | Qt::AlignLeft 01574 | Qt::AlignVCenter | Qt::TextShowMnemonic, 01575 btn->state & State_Enabled, btn->text); 01576 } 01577 if (!btn->icon.isNull()) { 01578 iconRect = itemPixmapRect(cr, Qt::AlignAbsolute | Qt::AlignLeft | Qt::AlignVCenter 01579 | Qt::TextShowMnemonic, 01580 btn->icon.pixmap(btn->iconSize, QIcon::Normal)); 01581 if (!textRect.isEmpty()) 01582 textRect.translate(iconRect.right() + 4, 0); 01583 } 01584 r = iconRect | textRect; 01585 r.adjust(-3, -2, 3, 2); 01586 r = r.intersected(btn->rect); 01587 r = visualRect(btn->direction, btn->rect, r); 01588 } 01589 break; 01590 01591 case SE_RadioButtonIndicator: 01592 { 01593 int h = pixelMetric(PM_ExclusiveIndicatorHeight, opt, widget); 01594 r.setRect(opt->rect.x(), opt->rect.y() + ((opt->rect.height() - h) / 2), 01595 pixelMetric(PM_ExclusiveIndicatorWidth, opt, widget), h); 01596 r = visualRect(opt->direction, opt->rect, r); 01597 } 01598 break; 01599 01600 case SE_RadioButtonContents: 01601 { 01602 QRect ir = visualRect(opt->direction, opt->rect, 01603 subElementRect(SE_RadioButtonIndicator, opt, widget)); 01604 r.setRect(ir.right() + 6, opt->rect.y(), 01605 opt->rect.width() - ir.width() - 6, opt->rect.height()); 01606 r = visualRect(opt->direction, opt->rect, r); 01607 break; 01608 } 01609 01610 case SE_RadioButtonFocusRect: 01611 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { 01612 if (btn->icon.isNull() && btn->text.isEmpty()) { 01613 r = subElementRect(SE_RadioButtonIndicator, opt, widget); 01614 r.adjust(1, 1, -1, -1); 01615 break; 01616 } 01617 QRect cr = visualRect(btn->direction, btn->rect, 01618 subElementRect(SE_RadioButtonContents, opt, widget)); 01619 01620 QRect iconRect, textRect; 01621 if (!btn->text.isEmpty()){ 01622 textRect = itemTextRect(opt->fontMetrics, cr, Qt::AlignAbsolute | Qt::AlignLeft | Qt::AlignVCenter 01623 | Qt::TextShowMnemonic, btn->state & State_Enabled, btn->text); 01624 } 01625 if(!btn->icon.isNull()) { 01626 iconRect = itemPixmapRect(cr, Qt::AlignAbsolute | Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, 01627 btn->icon.pixmap(btn->iconSize, QIcon::Normal)); 01628 if (!textRect.isEmpty()) 01629 textRect.translate(iconRect.right() + 4, 0); 01630 } 01631 r = iconRect | textRect; 01632 r.adjust(-3, -2, 3, 2); 01633 r = r.intersected(btn->rect); 01634 r = visualRect(btn->direction, btn->rect, r); 01635 } 01636 break; 01637 #ifndef QT_NO_SLIDER 01638 case SE_SliderFocusRect: 01639 if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { 01640 int tickOffset = pixelMetric(PM_SliderTickmarkOffset, slider, widget); 01641 int thickness = pixelMetric(PM_SliderControlThickness, slider, widget); 01642 if (slider->orientation == Qt::Horizontal) 01643 r.setRect(0, tickOffset - 1, slider->rect.width(), thickness + 2); 01644 else 01645 r.setRect(tickOffset - 1, 0, thickness + 2, slider->rect.height()); 01646 r = r.intersected(slider->rect); 01647 r = visualRect(opt->direction, opt->rect, r); 01648 } 01649 break; 01650 #endif // QT_NO_SLIDER 01651 #ifndef QT_NO_PROGRESSBAR 01652 case SE_ProgressBarGroove: 01653 case SE_ProgressBarContents: 01654 case SE_ProgressBarLabel: 01655 if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) { 01656 int textw = 0; 01657 bool vertical = false; 01658 if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) { 01659 vertical = (pb2->orientation == Qt::Vertical); 01660 } 01661 if (!vertical) { 01662 if (pb->textVisible) 01663 textw = qMax(pb->fontMetrics.width(pb->text), pb->fontMetrics.width(QLatin1String("100%"))) + 6; 01664 } 01665 01666 if ((pb->textAlignment & Qt::AlignCenter) == 0) { 01667 if (sr != SE_ProgressBarLabel) 01668 r.setCoords(pb->rect.left(), pb->rect.top(), 01669 pb->rect.right() - textw, pb->rect.bottom()); 01670 else 01671 r.setCoords(pb->rect.right() - textw, pb->rect.top(), 01672 pb->rect.right(), pb->rect.bottom()); 01673 } else { 01674 r = pb->rect; 01675 } 01676 r = visualRect(pb->direction, pb->rect, r); 01677 } 01678 break; 01679 #endif // QT_NO_PROGRESSBAR 01680 #ifdef QT3_SUPPORT 01681 case SE_Q3DockWindowHandleRect: 01682 if (const QStyleOptionQ3DockWindow *dw = qstyleoption_cast<const QStyleOptionQ3DockWindow *>(opt)) { 01683 if (!dw->docked || !dw->closeEnabled) 01684 r.setRect(0, 0, dw->rect.width(), dw->rect.height()); 01685 else { 01686 if (dw->state & State_Horizontal) 01687 r.setRect(0, 15, dw->rect.width(), dw->rect.height() - 15); 01688 else 01689 r.setRect(0, 1, dw->rect.width() - 15, dw->rect.height() - 1); 01690 } 01691 r = visualRect(opt->direction, opt->rect, r); 01692 } 01693 break; 01694 #endif // QT3_SUPPORT 01695 #ifndef QT_NO_COMBOBOX 01696 case SE_ComboBoxFocusRect: 01697 if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) { 01698 int margin = cb->frame ? 3 : 0; 01699 r.setRect(margin, margin, opt->rect.width() - 2*margin - 16, opt->rect.height() - 2*margin); 01700 r = visualRect(opt->direction, opt->rect, r); 01701 } 01702 break; 01703 #endif // QT_NO_COMBOBOX 01704 #ifndef QT_NO_TOOLBOX 01705 case SE_ToolBoxTabContents: 01706 r = opt->rect; 01707 r.adjust(0, 0, -30, 0); 01708 break; 01709 #endif // QT_NO_TOOLBOX 01710 case SE_HeaderLabel: { 01711 int margin = pixelMetric(QStyle::PM_HeaderMargin, opt, widget); 01712 r.setRect(opt->rect.x() + margin, opt->rect.y() + margin, 01713 opt->rect.width() - margin * 2, opt->rect.height() - margin * 2); 01714 01715 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) { 01716 // Subtract width needed for arrow, if there is one 01717 if (header->sortIndicator != QStyleOptionHeader::None) { 01718 if (opt->state & State_Horizontal) 01719 r.setWidth(r.width() - (opt->rect.height() / 2) - (margin * 2)); 01720 else 01721 r.setHeight(r.height() - (opt->rect.width() / 2) - (margin * 2)); 01722 } 01723 } 01724 r = visualRect(opt->direction, opt->rect, r); 01725 break; } 01726 case SE_HeaderArrow: { 01727 int h = opt->rect.height(); 01728 int w = opt->rect.width(); 01729 int x = opt->rect.x(); 01730 int y = opt->rect.y(); 01731 int margin = pixelMetric(QStyle::PM_HeaderMargin, opt, widget); 01732 01733 if (opt->state & State_Horizontal) { 01734 int horiz_size = h / 2; 01735 r.setRect(x + w - margin * 2 - horiz_size, y + 5, 01736 horiz_size, h - margin * 2 - 5); 01737 } else { 01738 int vert_size = w / 2; 01739 r.setRect(x + 5, y + h - margin * 2 - vert_size, 01740 w - margin * 2 - 5, vert_size); 01741 } 01742 r = visualRect(opt->direction, opt->rect, r); 01743 break; } 01744 01745 case SE_RadioButtonClickRect: 01746 r = subElementRect(SE_RadioButtonFocusRect, opt, widget); 01747 r |= subElementRect(SE_RadioButtonIndicator, opt, widget); 01748 break; 01749 case SE_CheckBoxClickRect: 01750 r = subElementRect(SE_CheckBoxFocusRect, opt, widget); 01751 r |= subElementRect(SE_CheckBoxIndicator, opt, widget); 01752 break; 01753 #ifndef QT_NO_TABWIDGET 01754 case SE_TabWidgetTabBar: 01755 if (const QStyleOptionTabWidgetFrame *twf 01756 = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { 01757 r.setSize(twf->tabBarSize); 01758 switch (twf->shape) { 01759 case QTabBar::RoundedNorth: 01760 case QTabBar::TriangularNorth: 01761 // Constrain the size now, otherwise, center could get off the page 01762 // This of course repeated for all the other directions 01763 r.setWidth(qMin(r.width(), twf->rect.width() 01764 - twf->leftCornerWidgetSize.width() 01765 - twf->rightCornerWidgetSize.width())); 01766 switch (styleHint(SH_TabBar_Alignment, twf, widget)) { 01767 default: 01768 case Qt::AlignLeft: 01769 r.moveTopLeft(QPoint(twf->leftCornerWidgetSize.width(), 0)); 01770 break; 01771 case Qt::AlignCenter: 01772 r.moveTopLeft(QPoint(twf->rect.center().x() - r.width() / 2, 0)); 01773 break; 01774 case Qt::AlignRight: 01775 r.moveTopLeft(QPoint(twf->rect.width() - twf->tabBarSize.width() 01776 - twf->rightCornerWidgetSize.width(), 0)); 01777 break; 01778 } 01779 r = visualRect(twf->direction, twf->rect, r); 01780 break; 01781 case QTabBar::RoundedSouth: 01782 case QTabBar::TriangularSouth: 01783 r.setWidth(qMin(r.width(), twf->rect.width() 01784 - twf->leftCornerWidgetSize.width() 01785 - twf->rightCornerWidgetSize.width())); 01786 switch (styleHint(SH_TabBar_Alignment, twf, widget)) { 01787 default: 01788 case Qt::AlignLeft: 01789 r.moveTopLeft(QPoint(twf->leftCornerWidgetSize.width(), 01790 twf->rect.height() - twf->tabBarSize.height())); 01791 break; 01792 case Qt::AlignCenter: 01793 r.moveTopLeft(QPoint(twf->rect.center().x() - r.width() / 2, 01794 twf->rect.height() - twf->tabBarSize.height())); 01795 break; 01796 case Qt::AlignRight: 01797 r.moveTopLeft(QPoint(twf->rect.width() - twf->tabBarSize.width() 01798 - twf->rightCornerWidgetSize.width(), 01799 twf->rect.height() - twf->tabBarSize.height())); 01800 break; 01801 } 01802 r = visualRect(twf->direction, twf->rect, r); 01803 break; 01804 case QTabBar::RoundedEast: 01805 case QTabBar::TriangularEast: 01806 r.setHeight(qMin(r.height(), twf->rect.height() 01807 - twf->leftCornerWidgetSize.height() 01808 - twf->rightCornerWidgetSize.height())); 01809 switch (styleHint(SH_TabBar_Alignment, twf, widget)) { 01810 default: 01811 case Qt::AlignLeft: 01812 r.moveTopLeft(QPoint(twf->rect.width() - twf->tabBarSize.width(), 01813 twf->leftCornerWidgetSize.height())); 01814 break; 01815 case Qt::AlignCenter: 01816 r.moveTopLeft(QPoint(twf->rect.width() - twf->tabBarSize.width(), 01817 twf->rect.center().y() - r.height() / 2)); 01818 break; 01819 case Qt::AlignRight: 01820 r.moveTopLeft(QPoint(twf->rect.width() - twf->tabBarSize.width(), 01821 twf->rect.height() - twf->tabBarSize.height() 01822 - twf->rightCornerWidgetSize.height())); 01823 break; 01824 } 01825 break; 01826 case QTabBar::RoundedWest: 01827 case QTabBar::TriangularWest: 01828 r.setHeight(qMin(r.height(), twf->rect.height()) 01829 - twf->leftCornerWidgetSize.height() 01830 - twf->rightCornerWidgetSize.height()); 01831 switch (styleHint(SH_TabBar_Alignment, twf, widget)) { 01832 default: 01833 case Qt::AlignLeft: 01834 r.moveTopLeft(QPoint(0, twf->leftCornerWidgetSize.height())); 01835 break; 01836 case Qt::AlignCenter: 01837 r.moveTopLeft(QPoint(0, twf->rect.center().y() - r.height() / 2)); 01838 break; 01839 case Qt::AlignRight: 01840 r.moveTopLeft(QPoint(0, twf->rect.height() - twf->tabBarSize.height() 01841 - twf->rightCornerWidgetSize.height())); 01842 break; 01843 } 01844 break; 01845 } 01846 } 01847 break; 01848 case SE_TabWidgetTabPane: 01849 case SE_TabWidgetTabContents: 01850 if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { 01851 QStyleOptionTab tabopt; 01852 tabopt.shape = twf->shape; 01853 int overlap = pixelMetric(PM_TabBarBaseOverlap, &tabopt, widget); 01854 switch (twf->shape) { 01855 case QTabBar::RoundedNorth: 01856 case QTabBar::TriangularNorth: 01857 r = QRect(QPoint(0,qMax(twf->tabBarSize.height() - overlap, 0)), 01858 QSize(twf->rect.width(), qMin(twf->rect.height() - twf->tabBarSize.height() + overlap, twf->rect.height()))); 01859 break; 01860 case QTabBar::RoundedSouth: 01861 case QTabBar::TriangularSouth: 01862 r = QRect(QPoint(0,0), QSize(twf->rect.width(), qMin(twf->rect.height() - twf->tabBarSize.height() + overlap, twf->rect.height()))); 01863 break; 01864 case QTabBar::RoundedEast: 01865 case QTabBar::TriangularEast: 01866 r = QRect(QPoint(0, 0), QSize(qMin(twf->rect.width() - twf->tabBarSize.width() + overlap, twf->rect.width()), twf->rect.height())); 01867 break; 01868 case QTabBar::RoundedWest: 01869 case QTabBar::TriangularWest: 01870 r = QRect(QPoint(qMax(twf->tabBarSize.width() - overlap, 0), 0), 01871 QSize(qMin(twf->rect.width() - twf->tabBarSize.width() + overlap, twf->rect.width()), twf->rect.height())); 01872 break; 01873 } 01874 if (sr == SE_TabWidgetTabContents) 01875 r.adjust(2, 2, -2, -2); 01876 } 01877 break; 01878 case SE_TabWidgetLeftCorner: 01879 if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { 01880 QRect paneRect = subElementRect(SE_TabWidgetTabPane, twf, widget); 01881 switch (twf->shape) { 01882 case QTabBar::RoundedNorth: 01883 case QTabBar::TriangularNorth: 01884 r = QRect(QPoint(paneRect.x(), paneRect.y() - twf->leftCornerWidgetSize.height()), 01885 twf->leftCornerWidgetSize); 01886 break; 01887 case QTabBar::RoundedSouth: 01888 case QTabBar::TriangularSouth: 01889 r = QRect(QPoint(paneRect.x(), paneRect.height()), twf->leftCornerWidgetSize); 01890 break; 01891 default: 01892 break; 01893 } 01894 r = visualRect(twf->direction, twf->rect, r); 01895 } 01896 break; 01897 case SE_TabWidgetRightCorner: 01898 if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { 01899 QRect paneRect = subElementRect(SE_TabWidgetTabPane, twf, widget); 01900 switch (twf->shape) { 01901 case QTabBar::RoundedNorth: 01902 case QTabBar::TriangularNorth: 01903 r = QRect(QPoint(paneRect.width() - twf->rightCornerWidgetSize.width(), 01904 paneRect.y() - twf->rightCornerWidgetSize.height()), 01905 twf->rightCornerWidgetSize); 01906 break; 01907 case QTabBar::RoundedSouth: 01908 case QTabBar::TriangularSouth: 01909 r = QRect(QPoint(paneRect.width() - twf->rightCornerWidgetSize.width(), 01910 paneRect.height()), twf->rightCornerWidgetSize); 01911 break; 01912 default: 01913 break; 01914 } 01915 r = visualRect(twf->direction, twf->rect, r); 01916 } 01917 break; 01918 #endif // QT_NO_TABWIDGET 01919 #ifndef QT_NO_TABBAR 01920 case SE_TabBarTearIndicator: 01921 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) { 01922 switch (tab->shape) { 01923 case QTabBar::RoundedNorth: 01924 case QTabBar::TriangularNorth: 01925 case QTabBar::RoundedSouth: 01926 case QTabBar::TriangularSouth: 01927 r.setRect(tab->rect.left(), tab->rect.top(), 4, opt->rect.height()); 01928 break; 01929 case QTabBar::RoundedWest: 01930 case QTabBar::TriangularWest: 01931 case QTabBar::RoundedEast: 01932 case QTabBar::TriangularEast: 01933 r.setRect(tab->rect.left(), tab->rect.top(), opt->rect.width(), 4); 01934 break; 01935 default: 01936 break; 01937 } 01938 r = visualRect(opt->direction, opt->rect, r); 01939 } 01940 break; 01941 #endif 01942 case SE_TreeViewDisclosureItem: 01943 r = opt->rect; 01944 break; 01945 case SE_LineEditContents: 01946 if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(opt)) { 01947 r = f->rect.adjusted(f->lineWidth, f->lineWidth, -f->lineWidth, -f->lineWidth); 01948 r = visualRect(opt->direction, opt->rect, r); 01949 } 01950 break; 01951 case SE_FrameContents: 01952 if (const QStyleOptionFrameV2 *f = qstyleoption_cast<const QStyleOptionFrameV2 *>(opt)) { 01953 int fw = pixelMetric(PM_DefaultFrameWidth, f, widget); 01954 r = opt->rect.adjusted(fw, fw, -fw, -fw); 01955 r = visualRect(opt->direction, opt->rect, r); 01956 } 01957 break; 01958 default: 01959 break; 01960 } 01961 return r; 01962 }
Here is the call graph for this function:

| void QCommonStyle::drawComplexControl | ( | ComplexControl | cc, | |
| const QStyleOptionComplex * | opt, | |||
| QPainter * | p, | |||
| const QWidget * | widget = 0 | |||
| ) | const [virtual] |
Implements QStyle.
Definition at line 2077 of file qcommonstyle.cpp.
References a, QRect::adjust(), QRect::adjusted(), Qt::AlignCenter, Qt::AlignHCenter, Qt::AlignLeft, Qt::AlignVCenter, angle(), QPainter::Antialiasing, QPaintEngine::Antialiasing, QPalette::brush(), QPalette::button(), calcArrow(), calcLines(), QStyle::CC_Dial, QStyle::CC_GroupBox, QStyle::CC_Q3ListView, QStyle::CC_ScrollBar, QStyle::CC_Slider, QStyle::CC_SpinBox, QStyle::CC_TitleBar, QStyle::CC_ToolButton, QStyle::CE_ScrollBarAddLine, QStyle::CE_ScrollBarAddPage, QStyle::CE_ScrollBarFirst, QStyle::CE_ScrollBarLast, QStyle::CE_ScrollBarSlider, QStyle::CE_ScrollBarSubLine, QStyle::CE_ScrollBarSubPage, QStyle::CE_ToolButtonLabel, QBrush::color(), TokenEngine::copy(), QPalette::dark(), QPalette::Disabled, drawControl(), QStyle::drawItemPixmap(), QStyle::drawItemText(), drawPrimitive(), QStyleOptionFrameV2::features, QPalette::foreground(), height, QRect::height(), Qt::Horizontal, int, QRect::isValid(), left(), Qt::LeftToRight, len, QPalette::light(), QStyleOptionFrame::lineWidth, QStyleOptionToolButton::Menu, QStyleOptionFrame::midLineWidth, Qt::NoBrush, Qt::NoPen, QPalette::NoRole, p, QStyleOption::palette, QStyle::PE_FrameFocusRect, QStyle::PE_FrameGroupBox, QStyle::PE_IndicatorArrowDown, QStyle::PE_IndicatorButtonDropDown, QStyle::PE_IndicatorCheckBox, QStyle::PE_IndicatorSpinDown, QStyle::PE_IndicatorSpinMinus, QStyle::PE_IndicatorSpinPlus, QStyle::PE_IndicatorSpinUp, QStyle::PE_PanelButtonBevel, QStyle::PE_PanelButtonTool, pixelMetric(), QAbstractSpinBox::PlusMinus, QStyle::PM_ButtonShiftHorizontal, QStyle::PM_ButtonShiftVertical, QStyle::PM_DefaultFrameWidth, QStyle::PM_MenuButtonIndicator, QStyle::PM_SliderControlThickness, QStyle::PM_SliderLength, QStyle::PM_SliderSpaceAvailable, QStyle::PM_SliderTickmarkOffset, qDrawWinPanel(), qMin(), qWarning(), QStyleOption::rect, right(), QStyle::SC_DialTickmarks, QStyle::SC_GroupBoxCheckBox, QStyle::SC_GroupBoxFrame, QStyle::SC_GroupBoxLabel, QStyle::SC_Q3ListView, QStyle::SC_ScrollBarAddLine, QStyle::SC_ScrollBarAddPage, QStyle::SC_ScrollBarFirst, QStyle::SC_ScrollBarLast, QStyle::SC_ScrollBarSlider, QStyle::SC_ScrollBarSubLine, QStyle::SC_ScrollBarSubPage, QStyle::SC_SliderTickmarks, QStyle::SC_SpinBoxDown, QStyle::SC_SpinBoxFrame, QStyle::SC_SpinBoxUp, QStyle::SC_TitleBarCloseButton, QStyle::SC_TitleBarContextHelpButton, QStyle::SC_TitleBarLabel, QStyle::SC_TitleBarMaxButton, QStyle::SC_TitleBarMinButton, QStyle::SC_TitleBarNormalButton, QStyle::SC_TitleBarShadeButton, QStyle::SC_TitleBarSysMenu, QStyle::SC_TitleBarUnshadeButton, QStyle::SC_ToolButton, QStyle::SC_ToolButtonMenu, QPalette::setCurrentColorGroup(), QRect::setRect(), QStyle::SH_Dial_BackgroundRole, QStyle::SH_UnderlineShortcut, QStyle::sliderPositionFromValue(), QStyle::SP_DockWidgetCloseButton, QStyle::SP_TitleBarCloseButton, QStyle::SP_TitleBarContextHelpButton, QStyle::SP_TitleBarMaxButton, QStyle::SP_TitleBarMenuButton, QStyle::SP_TitleBarMinButton, QStyle::SP_TitleBarNormalButton, QStyle::SP_TitleBarShadeButton, QStyle::SP_TitleBarUnshadeButton, standardPixmap(), QStyleOption::state, QStyle::State_AutoRaise, QStyle::State_Enabled, QStyle::State_HasFocus, QStyle::State_MouseOver, QStyle::State_On, QStyle::State_Raised, QStyle::State_Sunken, QAbstractSpinBox::StepDownEnabled, QAbstractSpinBox::StepUpEnabled, styleHint(), subControlRect(), tb, Qt::TextHideMnemonic, Qt::TextShowMnemonic, Qt::TextSingleLine, QSlider::TicksAbove, QSlider::TicksBelow, Qt::Tool, QRect::united(), QRect::width(), width, Qt::WindowContextHelpButtonHint, Qt::WindowMaximizeButtonHint, Qt::WindowMinimizeButtonHint, Qt::WindowSystemMenuHint, QPalette::WindowText, Qt::WindowType_Mask, QRect::x(), and QRect::y().
Referenced by QWindowsStyle::drawComplexControl(), and QMotifStyle::drawComplexControl().
02079 { 02080 switch (cc) { 02081 #ifndef QT_NO_SLIDER 02082 case CC_Slider: 02083 if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { 02084 if (slider->subControls == SC_SliderTickmarks) { 02085 int tickOffset = pixelMetric(PM_SliderTickmarkOffset, slider, widget); 02086 int ticks = slider->tickPosition; 02087 int thickness = pixelMetric(PM_SliderControlThickness, slider, widget); 02088 int len = pixelMetric(PM_SliderLength, slider, widget); 02089 int available = pixelMetric(PM_SliderSpaceAvailable, slider, widget); 02090 int interval = slider->tickInterval; 02091 if (interval <= 0) { 02092 interval = slider->singleStep; 02093 if (QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, interval, 02094 available) 02095 - QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, 02096 0, available) < 3) 02097 interval = slider->pageStep; 02098 } 02099 if (!interval) 02100 interval = 1; 02101 int fudge = len / 2; 02102 int pos; 02103 // Since there is no subrect for tickmarks do a translation here. 02104 p->save(); 02105 p->translate(slider->rect.x(), slider->rect.y()); 02106 p->setPen(slider->palette.foreground().color()); 02107 int v = slider->minimum; 02108 while (v <= slider->maximum) { 02109 pos = QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, 02110 v, available) + fudge; 02111 if (slider->orientation == Qt::Horizontal) { 02112 if (ticks & QSlider::TicksAbove) 02113 p->drawLine(pos, 0, pos, tickOffset - 2); 02114 if (ticks & QSlider::TicksBelow) 02115 p->drawLine(pos, tickOffset + thickness + 1, pos, 02116 tickOffset + thickness + 1 + available - 2); 02117 } else { 02118 if (ticks & QSlider::TicksAbove) 02119 p->drawLine(0, pos, tickOffset - 2, pos); 02120 if (ticks & QSlider::TicksBelow) 02121 p->drawLine(tickOffset + thickness + 1, pos, 02122 tickOffset + thickness + 1 + available - 2, pos); 02123 } 02124 v += interval; 02125 } 02126 p->restore(); 02127 } 02128 } 02129 break; 02130 #endif // QT_NO_SLIDER 02131 #ifndef QT_NO_SCROLLBAR 02132 case CC_ScrollBar: 02133 if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { 02134 // Make a copy here and reset it for each primitive. 02135 QStyleOptionSlider newScrollbar = *scrollbar; 02136 State saveFlags = scrollbar->state; 02137 if (scrollbar->minimum == scrollbar->maximum) 02138 saveFlags |= State_Enabled; 02139 02140 if (scrollbar->subControls & SC_ScrollBarSubLine) { 02141 newScrollbar.state = saveFlags; 02142 newScrollbar.rect = subControlRect(cc, &newScrollbar, SC_ScrollBarSubLine, widget); 02143 if (newScrollbar.rect.isValid()) { 02144 if (!(scrollbar->activeSubControls & SC_ScrollBarSubLine)) 02145 newScrollbar.state &= ~(State_Sunken | State_MouseOver); 02146 drawControl(CE_ScrollBarSubLine, &newScrollbar, p, widget); 02147 } 02148 } 02149 if (scrollbar->subControls & SC_ScrollBarAddLine) { 02150 newScrollbar.rect = scrollbar->rect; 02151 newScrollbar.state = saveFlags; 02152 newScrollbar.rect = subControlRect(cc, &newScrollbar, SC_ScrollBarAddLine, widget); 02153 if (newScrollbar.rect.isValid()) { 02154 if (!(scrollbar->activeSubControls & SC_ScrollBarAddLine)) 02155 newScrollbar.state &= ~(State_Sunken | State_MouseOver); 02156 drawControl(CE_ScrollBarAddLine, &newScrollbar, p, widget); 02157 } 02158 } 02159 if (scrollbar->subControls & SC_ScrollBarSubPage) { 02160 newScrollbar.rect = scrollbar->rect; 02161 newScrollbar.state = saveFlags; 02162 newScrollbar.rect = subControlRect(cc, &newScrollbar, SC_ScrollBarSubPage, widget); 02163 if (newScrollbar.rect.isValid()) { 02164 if (!(scrollbar->activeSubControls & SC_ScrollBarSubPage)) 02165 newScrollbar.state &= ~(State_Sunken | State_MouseOver); 02166 drawControl(CE_ScrollBarSubPage, &newScrollbar, p, widget); 02167 } 02168 } 02169 if (scrollbar->subControls & SC_ScrollBarAddPage) { 02170 newScrollbar.rect = scrollbar->rect; 02171 newScrollbar.state = saveFlags; 02172 newScrollbar.rect = subControlRect(cc, &newScrollbar, SC_ScrollBarAddPage, widget); 02173 if (newScrollbar.rect.isValid()) { 02174 if (!(scrollbar->activeSubControls & SC_ScrollBarAddPage)) 02175 newScrollbar.state &= ~(State_Sunken | State_MouseOver); 02176 drawControl(CE_ScrollBarAddPage, &newScrollbar, p, widget); 02177 } 02178 } 02179 if (scrollbar->subControls & SC_ScrollBarFirst) { 02180 newScrollbar.rect = scrollbar->rect; 02181 newScrollbar.state = saveFlags; 02182 newScrollbar.rect = subControlRect(cc, &newScrollbar, SC_ScrollBarFirst, widget); 02183 if (newScrollbar.rect.isValid()) { 02184 if (!(scrollbar->activeSubControls & SC_ScrollBarFirst)) 02185 newScrollbar.state &= ~(State_Sunken | State_MouseOver); 02186 drawControl(CE_ScrollBarFirst, &newScrollbar, p, widget); 02187 } 02188 } 02189 if (scrollbar->subControls & SC_ScrollBarLast) { 02190 newScrollbar.rect = scrollbar->rect; 02191 newScrollbar.state = saveFlags; 02192 newScrollbar.rect = subControlRect(cc, &newScrollbar, SC_ScrollBarLast, widget); 02193 if (newScrollbar.rect.isValid()) { 02194 if (!(scrollbar->activeSubControls & SC_ScrollBarLast)) 02195 newScrollbar.state &= ~(State_Sunken | State_MouseOver); 02196 drawControl(CE_ScrollBarLast, &newScrollbar, p, widget); 02197 } 02198 } 02199 if (scrollbar->subControls & SC_ScrollBarSlider) { 02200 newScrollbar.rect = scrollbar->rect; 02201 newScrollbar.state = saveFlags; 02202 newScrollbar.rect = subControlRect(cc, &newScrollbar, SC_ScrollBarSlider, widget); 02203 if (newScrollbar.rect.isValid()) { 02204 if (!(scrollbar->activeSubControls & SC_ScrollBarSlider)) 02205 newScrollbar.state &= ~(State_Sunken | State_MouseOver); 02206 drawControl(CE_ScrollBarSlider, &newScrollbar, p, widget); 02207 02208 if (scrollbar->state & State_HasFocus) { 02209 QStyleOptionFocusRect fropt; 02210 fropt.QStyleOption::operator=(newScrollbar); 02211 fropt.rect.setRect(newScrollbar.rect.x() + 2, newScrollbar.rect.y() + 2, 02212 newScrollbar.rect.width() - 5, 02213 newScrollbar.rect.height() - 5); 02214 drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); 02215 } 02216 } 02217 } 02218 } 02219 break; 02220 #endif // QT_NO_SCROLLBAR 02221 #ifdef QT3_SUPPORT 02222 case CC_Q3ListView: 02223 if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) { 02224 if (lv->subControls & SC_Q3ListView) 02225 p->fillRect(lv->rect, lv->viewportPalette.brush(lv->viewportBGRole)); 02226 } 02227 break; 02228 #endif // QT3_SUPPORT 02229 #ifndef QT_NO_SPINBOX 02230 case CC_SpinBox: 02231 if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) { 02232 QStyleOptionSpinBox copy = *sb; 02233 PrimitiveElement pe; 02234 02235 if (sb->frame && (sb->subControls & SC_SpinBoxFrame)) { 02236 QRect r = subControlRect(CC_SpinBox, sb, SC_SpinBoxFrame, widget); 02237 qDrawWinPanel(p, r, sb->palette, true); 02238 } 02239 02240 if (sb->subControls & SC_SpinBoxUp) { 02241 copy.subControls = SC_SpinBoxUp; 02242 QPalette pal2 = sb->palette; 02243 if (!(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled)) { 02244 pal2.setCurrentColorGroup(QPalette::Disabled); 02245 copy.state &= ~State_Enabled; 02246 } 02247 02248 copy.palette = pal2; 02249 02250 if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_Sunken)) { 02251 copy.state |= State_On; 02252 copy.state |= State_Sunken; 02253 } else { 02254 copy.state |= State_Raised; 02255 copy.state &= ~State_Sunken; 02256 } 02257 pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus 02258 : PE_IndicatorSpinUp); 02259 02260 copy.rect = subControlRect(CC_SpinBox, sb, SC_SpinBoxUp, widget); 02261 drawPrimitive(PE_PanelButtonBevel, ©, p, widget); 02262 copy.rect.adjust(3, 0, -4, 0); 02263 drawPrimitive(pe, ©, p, widget); 02264 } 02265 02266 if (sb->subControls & SC_SpinBoxDown) { 02267 copy.subControls = SC_SpinBoxDown; 02268 copy.state = sb->state; 02269 QPalette pal2 = sb->palette; 02270 if (!(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled)) { 02271 pal2.setCurrentColorGroup(QPalette::Disabled); 02272 copy.state &= ~State_Enabled; 02273 } 02274 copy.palette = pal2; 02275 02276 if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_Sunken)) { 02277 copy.state |= State_On; 02278 copy.state |= State_Sunken; 02279 } else { 02280 copy.state |= State_Raised; 02281 copy.state &= ~State_Sunken; 02282 } 02283 pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus 02284 : PE_IndicatorSpinDown); 02285 02286 copy.rect = subControlRect(CC_SpinBox, sb, SC_SpinBoxDown, widget); 02287 drawPrimitive(PE_PanelButtonBevel, ©, p, widget); 02288 copy.rect.adjust(3, 0, -4, 0); 02289 drawPrimitive(pe, ©, p, widget); 02290 } 02291 } 02292 break; 02293 #endif // QT_NO_SPINBOX 02294 #ifndef QT_NO_TOOLBUTTON 02295 case CC_ToolButton: 02296 if (const QStyleOptionToolButton *toolbutton 02297 = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) { 02298 QRect button, menuarea; 02299 button = subControlRect(cc, toolbutton, SC_ToolButton, widget); 02300 menuarea = subControlRect(cc, toolbutton, SC_ToolButtonMenu, widget); 02301 02302 State bflags = toolbutton->state; 02303 02304 if (bflags & State_AutoRaise) { 02305 if (!(bflags & State_MouseOver)) { 02306 bflags &= ~State_Raised; 02307 } 02308 } 02309 State mflags = bflags; 02310 02311 if (toolbutton->activeSubControls & SC_ToolButton) 02312 bflags |= State_Sunken; 02313 if (toolbutton->activeSubControls & SC_ToolButtonMenu) 02314 mflags |= State_Sunken; 02315 02316 QStyleOption tool(0); 02317 tool.palette = toolbutton->palette; 02318 if (toolbutton->subControls & SC_ToolButton) { 02319 if (bflags & (State_Sunken | State_On | State_Raised)) { 02320 tool.rect = button; 02321 tool.state = bflags; 02322 drawPrimitive(PE_PanelButtonTool, &tool, p, widget); 02323 } 02324 } 02325 02326 if (toolbutton->subControls & SC_ToolButtonMenu) { 02327 tool.rect = menuarea; 02328 tool.state = mflags; 02329 if (mflags & (State_Sunken | State_On | State_Raised)) 02330 drawPrimitive(PE_IndicatorButtonDropDown, &tool, p, widget); 02331 drawPrimitive(PE_IndicatorArrowDown, &tool, p, widget); 02332 } 02333 02334 if (toolbutton->state & State_HasFocus) { 02335 QStyleOptionFocusRect fr; 02336 fr.QStyleOption::operator=(*toolbutton); 02337 fr.rect.adjust(3, 3, -3, -3); 02338 if (toolbutton->features & QStyleOptionToolButton::Menu) 02339 fr.rect.adjust(0, 0, -pixelMetric(QStyle::PM_MenuButtonIndicator, 02340 toolbutton, widget), 0); 02341 drawPrimitive(PE_FrameFocusRect, &fr, p, widget); 02342 } 02343 QStyleOptionToolButton label = *toolbutton; 02344 int fw = pixelMetric(PM_DefaultFrameWidth, opt, widget); 02345 label.rect = button.adjusted(fw, fw, -fw, -fw); 02346 drawControl(CE_ToolButtonLabel, &label, p, widget); 02347 } 02348 break; 02349 #endif // QT_NO_TOOLBUTTON 02350 case CC_TitleBar: 02351 if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) { 02352 QRect ir; 02353 if (opt->subControls & SC_TitleBarLabel) { 02354 QColor left = tb->palette.highlight().color(); 02355 QColor right = tb->palette.base().color(); 02356 02357 QBrush fillBrush(left); 02358 if (left != right) { 02