#include <qmotifstyle.h>
Inheritance diagram for QMotifStyle:


This class implements the Motif look and feel. It closely resembles the original Motif look as defined by the Open Group, but with some minor improvements. The Motif style is Qt's default GUI style on Unix platforms.
qmotifstyle.png
Definition at line 40 of file qmotifstyle.h.
Public Member Functions | |
| QMotifStyle (bool useHighlightCols=false) | |
| virtual | ~QMotifStyle () |
| void | setUseHighlightColors (bool) |
| bool | useHighlightColors () const |
| void | polish (QPalette &) |
| void | polish (QWidget *) |
| void | unpolish (QWidget *) |
| void | polish (QApplication *) |
| void | unpolish (QApplication *) |
| void | drawPrimitive (PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const |
| void | drawControl (ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const |
| void | drawComplexControl (ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *w=0) const |
| QRect | subControlRect (ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget=0) const |
| int | pixelMetric (PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const |
| QSize | sizeFromContents (ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *widget=0) const |
| QRect | subElementRect (SubElement r, const QStyleOption *opt, const QWidget *widget=0) const |
| QPixmap | standardPixmap (StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget=0) const |
| int | styleHint (StyleHint hint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const |
| bool | event (QEvent *) |
| QPalette | standardPalette () const |
Protected Slots | |
| QIcon | standardIconImplementation (StandardPixmap standardIcon, const QStyleOption *opt=0, const QWidget *widget=0) const |
Protected Member Functions | |
| QMotifStyle (QMotifStylePrivate &dd, bool useHighlightCols=false) | |
| void | timerEvent (QTimerEvent *event) |
| bool | eventFilter (QObject *o, QEvent *e) |
Protected Attributes | |
| QPointer< QFocusFrame > | focus |
Private Attributes | |
| bool | highlightCols |
| QMotifStyle::QMotifStyle | ( | bool | useHighlightCols = false |
) | [explicit] |
Constructs a QMotifStyle.
If useHighlightCols is false (the default), the style will polish the application's color palette to emulate the Motif way of highlighting, which is a simple inversion between the base and the text color.
Definition at line 97 of file qmotifstyle.cpp.
References focus, and highlightCols.
00098 : QCommonStyle(*new QMotifStylePrivate) 00099 { 00100 focus = 0; 00101 highlightCols = useHighlightCols; 00102 }
| QMotifStyle::~QMotifStyle | ( | ) | [virtual] |
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 121 of file qmotifstyle.cpp.
References focus.
00122 { 00123 delete focus; 00124 }
| QMotifStyle::QMotifStyle | ( | QMotifStylePrivate & | dd, | |
| bool | useHighlightCols = false | |||
| ) | [protected] |
Definition at line 108 of file qmotifstyle.cpp.
References focus, and highlightCols.
00109 : QCommonStyle(dd) 00110 { 00111 focus = 0; 00112 highlightCols = useHighlightColors; 00113 }
| void QMotifStyle::setUseHighlightColors | ( | bool | arg | ) |
If arg is false, the style will polish the application's color palette to emulate the Motif way of highlighting, which is a simple inversion between the base and the text color.
The effect will show up the next time an application palette is set via QApplication::setPalette(). The current color palette of the application remains unchanged.
Definition at line 210 of file qmotifstyle.cpp.
References highlightCols.
00211 { 00212 highlightCols = arg; 00213 }
| bool QMotifStyle::useHighlightColors | ( | ) | const |
Returns true if the style treats the highlight colors of the palette in a Motif-like manner, which is a simple inversion between the base and the text color; otherwise returns false. The default is false.
Definition at line 221 of file qmotifstyle.cpp.
References highlightCols.
00222 { 00223 return highlightCols; 00224 }
| void QMotifStyle::polish | ( | QPalette & | pal | ) | [virtual] |
Reimplemented from QStyle.
Definition at line 228 of file qmotifstyle.cpp.
References QPalette::Active, QPalette::Base, QPalette::brush(), QPalette::color(), QColor::dark(), QPalette::Disabled, QPalette::Highlight, highlightCols, QPalette::HighlightedText, QPalette::Inactive, QPalette::Light, QPalette::setColor(), and QPalette::Text.
00229 { 00230 if (pal.brush(QPalette::Active, QPalette::Light) == pal.brush(QPalette::Active, QPalette::Base)) { 00231 QColor nlight = pal.color(QPalette::Active, QPalette::Light).dark(108); 00232 pal.setColor(QPalette::Active, QPalette::Light, nlight) ; 00233 pal.setColor(QPalette::Disabled, QPalette::Light, nlight) ; 00234 pal.setColor(QPalette::Inactive, QPalette::Light, nlight) ; 00235 } 00236 00237 if (highlightCols) 00238 return; 00239 00240 // force the ugly motif way of highlighting *sigh* 00241 pal.setColor(QPalette::Active, QPalette::Highlight, 00242 pal.color(QPalette::Active, QPalette::Text)); 00243 pal.setColor(QPalette::Active, QPalette::HighlightedText, 00244 pal.color(QPalette::Active, QPalette::Base)); 00245 pal.setColor(QPalette::Disabled, QPalette::Highlight, 00246 pal.color(QPalette::Disabled, QPalette::Text)); 00247 pal.setColor(QPalette::Disabled, QPalette::HighlightedText, 00248 pal.color(QPalette::Disabled, QPalette::Base)); 00249 pal.setColor(QPalette::Inactive, QPalette::Highlight, 00250 pal.color(QPalette::Active, QPalette::Text)); 00251 pal.setColor(QPalette::Inactive, QPalette::HighlightedText, 00252 pal.color(QPalette::Active, QPalette::Base)); 00253 }
Here is the call graph for this function:

| void QMotifStyle::polish | ( | QWidget * | widget | ) | [virtual] |
Reimplemented from QStyle.
Definition at line 260 of file qmotifstyle.cpp.
References QStyle::polish().
00261 { 00262 QStyle::polish(widget); 00263 #ifndef QT_NO_PROGRESSBAR 00264 if (qobject_cast<QProgressBar *>(widget)) 00265 widget->installEventFilter(this); 00266 #endif 00267 }
Here is the call graph for this function:

| void QMotifStyle::unpolish | ( | QWidget * | widget | ) | [virtual] |
Reimplemented from QStyle.
Definition at line 274 of file qmotifstyle.cpp.
References QStyle::unpolish().
00275 { 00276 QCommonStyle::unpolish(widget); 00277 #ifndef QT_NO_PROGRESSBAR 00278 if (qobject_cast<QProgressBar *>(widget)) 00279 widget->removeEventFilter(this); 00280 #endif 00281 }
Here is the call graph for this function:

| void QMotifStyle::polish | ( | QApplication * | a | ) | [virtual] |
Reimplemented from QStyle.
Definition at line 289 of file qmotifstyle.cpp.
References a, and QStyle::polish().
00290 { 00291 QCommonStyle::polish(a); 00292 }
Here is the call graph for this function:

| void QMotifStyle::unpolish | ( | QApplication * | a | ) | [virtual] |
Reimplemented from QStyle.
Definition at line 300 of file qmotifstyle.cpp.
References a, and QStyle::unpolish().
00301 { 00302 QCommonStyle::unpolish(a); 00303 }
Here is the call graph for this function:

| void QMotifStyle::drawPrimitive | ( | PrimitiveElement | pe, | |
| const QStyleOption * | opt, | |||
| QPainter * | p, | |||
| const QWidget * | w = 0 | |||
| ) | const [virtual] |
Reimplemented from QCommonStyle.
Definition at line 322 of file qmotifstyle.cpp.
References a, QPalette::Button, CBOT, CLEFT, CTOP, QColor::dark(), Qt::Dense4Pattern, Qt::Dense5Pattern, QPalette::Disabled, QCommonStyle::drawPrimitive(), QStyleOptionButton::Flat, focus, h, QRect::height(), QPalette::Highlight, i, int, INTARRLEN, QColor::light(), QPalette::Mid, Qt::NoBrush, Qt::NoPen, p, QStyle::PE_FrameFocusRect, QStyle::PE_FrameTabWidget, QStyle::PE_FrameWindow, QStyle::PE_IndicatorArrowDown, QStyle::PE_IndicatorArrowLeft, QStyle::PE_IndicatorArrowRight, QStyle::PE_IndicatorArrowUp, QStyle::PE_IndicatorCheckBox, QStyle::PE_IndicatorDockWidgetResizeHandle, QStyle::PE_IndicatorMenuCheckMark, QStyle::PE_IndicatorProgressChunk, QStyle::PE_IndicatorRadioButton, QStyle::PE_IndicatorSpinDown, QStyle::PE_IndicatorSpinMinus, QStyle::PE_IndicatorSpinPlus, QStyle::PE_IndicatorSpinUp, QStyle::PE_IndicatorToolBarHandle, QStyle::PE_PanelButtonBevel, QStyle::PE_PanelButtonCommand, QStyle::PE_PanelButtonTool, QStyle::PE_Q3CheckListExclusiveIndicator, pixelMetric(), QStyle::PM_DefaultFrameWidth, QStyle::PM_SplitterWidth, QPolygon::putPoints(), qDrawPlainRect(), qDrawShadeLine(), qDrawShadePanel(), QVector< T >::resize(), rot(), QRect::setHeight(), QPolygon::setPoint(), QPolygon::setPoints(), QRect::setWidth(), QRect::setX(), QRect::setY(), QStyle::SH_DitherDisabledText, QStyle::State_AutoRaise, QStyle::State_Enabled, QStyle::State_HasFocus, QStyle::State_Horizontal, QStyle::State_NoChange, QStyle::State_None, QStyle::State_On, QStyle::State_Sunken, styleHint(), QPalette::Text, QPolygon::translate(), Qt::Vertical, w, QRect::width(), QRect::x(), x, QRect::y(), and y.
Referenced by drawComplexControl(), drawControl(), QCDEStyle::drawPrimitive(), and NorwegianWoodStyle::drawPrimitive().
00324 { 00325 switch(pe) { 00326 case PE_Q3CheckListExclusiveIndicator: 00327 if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) { 00328 if (lv->items.isEmpty()) 00329 return; 00330 00331 if (lv->state & State_Enabled) 00332 p->setPen(QPen(opt->palette.text().color())); 00333 else 00334 p->setPen(QPen(lv->palette.color(QPalette::Disabled, QPalette::Text))); 00335 QPolygon a; 00336 00337 int cx = opt->rect.width()/2 - 1; 00338 int cy = opt->rect.height()/2; 00339 int e = opt->rect.width()/2 - 1; 00340 for (int i = 0; i < 3; i++) { //penWidth 2 doesn't quite work 00341 a.setPoints(4, cx-e, cy, cx, cy-e, cx+e, cy, cx, cy+e); 00342 p->drawPolygon(a); 00343 e--; 00344 } 00345 if (opt->state & State_On) { 00346 if (lv->state & State_Enabled) 00347 p->setPen(QPen(opt->palette.text().color())); 00348 else 00349 p->setPen(QPen(lv->palette.color(QPalette::Disabled, 00350 QPalette::Text))); 00351 QBrush saveBrush = p->brush(); 00352 p->setBrush(opt->palette.text()); 00353 e = e - 2; 00354 a.setPoints(4, cx-e, cy, cx, cy-e, cx+e, cy, cx, cy+e); 00355 p->drawPolygon(a); 00356 p->setBrush(saveBrush); 00357 } 00358 } 00359 break; 00360 00361 case PE_FrameTabWidget: 00362 case PE_FrameWindow: 00363 qDrawShadePanel(p, opt->rect, opt->palette, QStyle::State_None, pixelMetric(PM_DefaultFrameWidth)); 00364 break; 00365 case PE_FrameFocusRect: 00366 if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(opt)) { 00367 if ((fropt->state & State_HasFocus) && focus && focus->isVisible()) 00368 break; 00369 QCommonStyle::drawPrimitive(pe, opt, p, w); 00370 } 00371 break; 00372 00373 case PE_IndicatorToolBarHandle: { 00374 p->save(); 00375 p->translate(opt->rect.x(), opt->rect.y()); 00376 00377 QColor dark(opt->palette.dark().color()); 00378 QColor light(opt->palette.light().color()); 00379 int i; 00380 if (opt->state & State_Horizontal) { 00381 int h = opt->rect.height(); 00382 if (h > 6) { 00383 if (opt->state & State_On) 00384 p->fillRect(1, 1, 8, h - 2, opt->palette.highlight()); 00385 QPolygon a(2 * ((h-6)/3)); 00386 int y = 3 + (h%3)/2; 00387 p->setPen(dark); 00388 p->drawLine(8, 1, 8, h-2); 00389 for(i=0; 2*i < a.size(); i ++) { 00390 a.setPoint(2*i, 5, y+1+3*i); 00391 a.setPoint(2*i+1, 2, y+2+3*i); 00392 } 00393 p->drawPoints(a); 00394 p->setPen(light); 00395 p->drawLine(9, 1, 9, h-2); 00396 for(i=0; 2*i < a.size(); i++) { 00397 a.setPoint(2*i, 4, y+3*i); 00398 a.setPoint(2*i+1, 1, y+1+3*i); 00399 } 00400 p->drawPoints(a); 00401 // if (drawBorder) { 00402 // p->setPen(QPen(Qt::darkGray)); 00403 // p->drawLine(0, opt->rect.height() - 1, 00404 // tbExtent, opt->rect.height() - 1); 00405 // } 00406 } 00407 } else { 00408 int w = opt->rect.width(); 00409 if (w > 6) { 00410 if (opt->state & State_On) 00411 p->fillRect(1, 1, w - 2, 9, opt->palette.highlight()); 00412 QPolygon a(2 * ((w-6)/3)); 00413 00414 int x = 3 + (w%3)/2; 00415 p->setPen(dark); 00416 p->drawLine(1, 8, w-2, 8); 00417 for(i=0; 2*i < a.size(); i ++) { 00418 a.setPoint(2*i, x+1+3*i, 6); 00419 a.setPoint(2*i+1, x+2+3*i, 3); 00420 } 00421 p->drawPoints(a); 00422 p->setPen(light); 00423 p->drawLine(1, 9, w-2, 9); 00424 for(i=0; 2*i < a.size(); i++) { 00425 a.setPoint(2*i, x+3*i, 5); 00426 a.setPoint(2*i+1, x+1+3*i, 2); 00427 } 00428 p->drawPoints(a); 00429 // if (drawBorder) { 00430 // p->setPen(QPen(Qt::darkGray)); 00431 // p->drawLine(opt->rect.width() - 1, 0, 00432 // opt->rect.width() - 1, tbExtent); 00433 // } 00434 } 00435 } 00436 p->restore(); 00437 break; } 00438 00439 case PE_PanelButtonCommand: 00440 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { 00441 if ((btn->features & QStyleOptionButton::Flat) 00442 && !(opt->state & (State_Sunken | State_On))) { 00443 p->fillRect(opt->rect, opt->palette.brush(QPalette::Button)); 00444 break; 00445 } 00446 } 00447 // Fall-through 00448 case PE_PanelButtonBevel: 00449 case PE_PanelButtonTool: { 00450 QBrush fill; 00451 if (opt->state & State_Sunken) 00452 fill = opt->palette.brush(QPalette::Mid); 00453 else if ((opt->state & State_On) && (opt->state & State_Enabled)) 00454 fill = QBrush(opt->palette.mid().color(), Qt::Dense4Pattern); 00455 else 00456 fill = opt->palette.brush(QPalette::Button); 00457 if ((opt->state & State_Enabled) || !(opt->state & State_AutoRaise)) 00458 qDrawShadePanel(p, opt->rect, opt->palette, bool(opt->state & (State_Sunken | State_On)), 00459 pixelMetric(PM_DefaultFrameWidth), &fill); 00460 break; } 00461 00462 case PE_IndicatorCheckBox: { 00463 bool on = opt->state & State_On; 00464 bool down = opt->state & State_Sunken; 00465 bool showUp = !(down ^ on); 00466 QBrush fill = opt->palette.brush((showUp || opt->state & State_NoChange) ?QPalette::Button : QPalette::Mid); 00467 if (opt->state & State_NoChange) { 00468 qDrawPlainRect(p, opt->rect, opt->palette.text().color(), 00469 1, &fill); 00470 p->drawLine(opt->rect.x() + opt->rect.width() - 1, opt->rect.y(), 00471 opt->rect.x(), opt->rect.y() + opt->rect.height() - 1); 00472 } else { 00473 qDrawShadePanel(p, opt->rect, opt->palette, !showUp, 00474 pixelMetric(PM_DefaultFrameWidth), &fill); 00475 } 00476 if (!(opt->state & State_Enabled) && styleHint(SH_DitherDisabledText)) 00477 p->fillRect(opt->rect, QBrush(p->background().color(), Qt::Dense5Pattern)); 00478 break; } 00479 00480 case PE_IndicatorRadioButton: { 00481 #define INTARRLEN(x) sizeof(x)/(sizeof(int)*2) 00482 int inner_pts[] = { // used for filling diamond 00483 2,opt->rect.height()/2, 00484 opt->rect.width()/2,2, 00485 opt->rect.width()-3,opt->rect.height()/2, 00486 opt->rect.width()/2,opt->rect.height()-3 00487 }; 00488 int top_pts[] = { // top (^) of diamond 00489 0,opt->rect.height()/2, 00490 opt->rect.width()/2,0, 00491 opt->rect.width()-2,opt->rect.height()/2-1, 00492 opt->rect.width()-3,opt->rect.height()/2-1, 00493 opt->rect.width()/2,1, 00494 1,opt->rect.height()/2, 00495 2,opt->rect.height()/2, 00496 opt->rect.width()/2,2, 00497 opt->rect.width()-4,opt->rect.height()/2-1 00498 }; 00499 int bottom_pts[] = { // bottom (v) of diamond 00500 1,opt->rect.height()/2+1, 00501 opt->rect.width()/2,opt->rect.height()-1, 00502 opt->rect.width()-1,opt->rect.height()/2, 00503 opt->rect.width()-2,opt->rect.height()/2, 00504 opt->rect.width()/2,opt->rect.height()-2, 00505 2,opt->rect.height()/2+1, 00506 3,opt->rect.height()/2+1, 00507 opt->rect.width()/2,opt->rect.height()-3, 00508 opt->rect.width()-3,opt->rect.height()/2 00509 }; 00510 bool on = opt->state & State_On; 00511 bool down = opt->state & State_Sunken; 00512 bool showUp = !(down ^ on); 00513 QPen oldPen = p->pen(); 00514 QBrush oldBrush = p->brush(); 00515 QPolygon a(INTARRLEN(inner_pts), inner_pts); 00516 p->setPen(Qt::NoPen); 00517 p->setBrush(opt->palette.brush(showUp ? QPalette::Button : QPalette::Mid)); 00518 a.translate(opt->rect.x(), opt->rect.y()); 00519 p->drawPolygon(a); 00520 p->setPen(showUp ? opt->palette.light().color() : opt->palette.dark().color()); 00521 p->setBrush(Qt::NoBrush); 00522 a.setPoints(INTARRLEN(top_pts), top_pts); 00523 a.translate(opt->rect.x(), opt->rect.y()); 00524 p->drawPolyline(a); 00525 p->setPen(showUp ? opt->palette.dark().color() : opt->palette.light().color()); 00526 a.setPoints(INTARRLEN(bottom_pts), bottom_pts); 00527 a.translate(opt->rect.x(), opt->rect.y()); 00528 p->drawPolyline(a); 00529 if (!(opt->state & State_Enabled) && styleHint(SH_DitherDisabledText)) 00530 p->fillRect(opt->rect, QBrush(p->background().color(), Qt::Dense5Pattern)); 00531 p->setPen(oldPen); 00532 p->setBrush(oldBrush); 00533 break; } 00534 00535 case PE_IndicatorSpinUp: 00536 case PE_IndicatorSpinPlus: 00537 case PE_IndicatorSpinDown: 00538 case PE_IndicatorSpinMinus: 00539 case PE_IndicatorArrowUp: 00540 case PE_IndicatorArrowDown: 00541 case PE_IndicatorArrowRight: 00542 case PE_IndicatorArrowLeft: { 00543 QRect rect = opt->rect; 00544 QPolygon bFill; 00545 QPolygon bTop; 00546 QPolygon bBot; 00547 QPolygon bLeft; 00548 if (pe == PE_IndicatorSpinPlus || pe == PE_IndicatorSpinUp) 00549 pe = PE_IndicatorArrowUp; 00550 else if (pe == PE_IndicatorSpinMinus || pe == PE_IndicatorSpinDown) 00551 pe = PE_IndicatorArrowDown; 00552 bool vertical = pe == PE_IndicatorArrowUp || pe == PE_IndicatorArrowDown; 00553 bool horizontal = !vertical; 00554 int dim = rect.width() < rect.height() ? rect.width() : rect.height(); 00555 int colspec = 0x0000; 00556 00557 if (!(opt->state & State_Enabled)) 00558 dim -= 2; 00559 if(dim < 2) 00560 break; 00561 00562 // adjust size and center (to fix rotation below) 00563 if (rect.width() > dim) { 00564 rect.setX(rect.x() + ((rect.width() - dim) / 2)); 00565 rect.setWidth(dim); 00566 } 00567 if (rect.height() > dim) { 00568 rect.setY(rect.y() + ((rect.height() - dim) / 2)); 00569 rect.setHeight(dim); 00570 } 00571 00572 if (dim > 3) { 00573 if (pixelMetric(PM_DefaultFrameWidth) < 2) { // thin style 00574 bFill.resize( dim & 1 ? 3 : 4 ); 00575 bTop.resize( 2 ); 00576 bBot.resize( 2 ); 00577 bLeft.resize( 2 ); 00578 bLeft.putPoints( 0, 2, 0, 0, 0, dim-1 ); 00579 bTop.putPoints( 0, 2, 1, 0, dim-1, dim/2 ); 00580 bBot.putPoints( 0, 2, 1, dim-1, dim-1, dim/2 ); 00581 00582 if ( dim > 6 ) { // dim>6: must fill interior 00583 bFill.putPoints( 0, 2, 0, dim-1, 0, 0 ); 00584 if ( dim & 1 ) // if size is an odd number 00585 bFill.setPoint( 2, dim - 1, dim / 2 ); 00586 else 00587 bFill.putPoints( 2, 2, dim-1, dim/2-1, dim-1, dim/2 ); 00588 } 00589 } else { 00590 if (dim > 6) 00591 bFill.resize(dim & 1 ? 3 : 4); 00592 bTop.resize((dim/2)*2); 00593 bBot.resize(dim & 1 ? dim + 1 : dim); 00594 bLeft.resize(dim > 4 ? 4 : 2); 00595 bLeft.putPoints(0, 2, 0,0, 0,dim-1); 00596 if (dim > 4) 00597 bLeft.putPoints(2, 2, 1,2, 1,dim-3); 00598 bTop.putPoints(0, 4, 1,0, 1,1, 2,1, 3,1); 00599 bBot.putPoints(0, 4, 1,dim-1, 1,dim-2, 2,dim-2, 3,dim-2); 00600 00601 for(int i=0; i<dim/2-2 ; i++) { 00602 bTop.putPoints(i*2+4, 2, 2+i*2,2+i, 5+i*2, 2+i); 00603 bBot.putPoints(i*2+4, 2, 2+i*2,dim-3-i, 5+i*2,dim-3-i); 00604 } 00605 if (dim & 1) // odd number size: extra line 00606 bBot.putPoints(dim-1, 2, dim-3,dim/2, dim-1,dim/2); 00607 if (dim > 6) { // dim>6: must fill interior 00608 bFill.putPoints(0, 2, 1,dim-3, 1,2); 00609 if (dim & 1) // if size is an odd number 00610 bFill.setPoint(2, dim - 3, dim / 2); 00611 else 00612 bFill.putPoints(2, 2, dim-4,dim/2-1, dim-4,dim/2); 00613 } 00614 } 00615 } else { 00616 if (dim == 3) { // 3x3 arrow pattern 00617 bLeft.setPoints(4, 0,0, 0,2, 1,1, 1,1); 00618 bTop .setPoints(2, 1,0, 1,0); 00619 bBot .setPoints(2, 1,2, 2,1); 00620 } 00621 else { // 2x2 arrow pattern 00622 bLeft.setPoints(2, 0,0, 0,1); 00623 bTop .setPoints(2, 1,0, 1,0); 00624 bBot .setPoints(2, 1,1, 1,1); 00625 } 00626 } 00627 00628 // We use rot() and translate() as it is more efficient that 00629 // matrix transformations on the painter, and because it still 00630 // works with QT_NO_TRANSFORMATIONS defined. 00631 00632 if (pe == PE_IndicatorArrowUp || pe == PE_IndicatorArrowLeft) { 00633 if (vertical) { 00634 rot(bFill,3); 00635 rot(bLeft,3); 00636 rot(bTop,3); 00637 rot(bBot,3); 00638 bFill.translate(0, rect.height() - 1); 00639 bLeft.translate(0, rect.height() - 1); 00640 bTop.translate(0, rect.height() - 1); 00641 bBot.translate(0, rect.height() - 1); 00642 } else { 00643 rot(bFill,2); 00644 rot(bLeft,2); 00645 rot(bTop,2); 00646 rot(bBot,2); 00647 bFill.translate(rect.width() - 1, rect.height() - 1); 00648 bLeft.translate(rect.width() - 1, rect.height() - 1); 00649 bTop.translate(rect.width() - 1, rect.height() - 1); 00650 bBot.translate(rect.width() - 1, rect.height() - 1); 00651 } 00652 if (opt->state & State_Sunken) 00653 colspec = horizontal ? 0x2334 : 0x2343; 00654 else 00655 colspec = horizontal ? 0x1443 : 0x1434; 00656 } else { 00657 if (vertical) { 00658 rot(bFill,1); 00659 rot(bLeft,1); 00660 rot(bTop,1); 00661 rot(bBot,1); 00662 bFill.translate(rect.width() - 1, 0); 00663 bLeft.translate(rect.width() - 1, 0); 00664 bTop.translate(rect.width() - 1, 0); 00665 bBot.translate(rect.width() - 1, 0); 00666 } 00667 if (opt->state & State_Sunken) 00668 colspec = horizontal ? 0x2443 : 0x2434; 00669 else 00670 colspec = horizontal ? 0x1334 : 0x1343; 00671 } 00672 bFill.translate(rect.x(), rect.y()); 00673 bLeft.translate(rect.x(), rect.y()); 00674 bTop.translate(rect.x(), rect.y()); 00675 bBot.translate(rect.x(), rect.y()); 00676 00677 const QColor *cols[5]; 00678 if (opt->state & State_Enabled) { 00679 cols[0] = 0; 00680 cols[1] = &opt->palette.button().color(); 00681 cols[2] = &opt->palette.mid().color(); 00682 cols[3] = &opt->palette.light().color(); 00683 cols[4] = &opt->palette.dark().color(); 00684 } else { 00685 cols[0] = 0; 00686 cols[1] = &opt->palette.mid().color(); 00687 cols[2] = &opt->palette.mid().color(); 00688 cols[3] = &opt->palette.mid().color(); 00689 cols[4] = &opt->palette.mid().color(); 00690 } 00691 00692 #define CMID *cols[(colspec>>12) & 0xf] 00693 #define CLEFT *cols[(colspec>>8) & 0xf] 00694 #define CTOP *cols[(colspec>>4) & 0xf] 00695 #define CBOT *cols[colspec & 0xf] 00696 00697 QPen savePen = p->pen(); 00698 QBrush saveBrush = p->brush(); 00699 QPen pen(Qt::NoPen); 00700 QBrush brush = opt->palette.brush((opt->state & State_Enabled) ? 00701 QPalette::Button : QPalette::Mid); 00702 p->setPen(pen); 00703 p->setBrush(brush); 00704 p->drawPolygon(bFill); 00705 p->setBrush(Qt::NoBrush); 00706 00707 p->setPen(CLEFT); 00708 p->drawPolyline(bLeft); 00709 p->setPen(CTOP); 00710 p->drawPolyline(bTop); 00711 p->setPen(CBOT); 00712 p->drawPolyline(bBot); 00713 00714 p->setBrush(saveBrush); 00715 p->setPen(savePen); 00716 #undef CMID 00717 #undef CLEFT 00718 #undef CTOP 00719 #undef CBOT 00720 if (!(opt->state & State_Enabled) && styleHint(SH_DitherDisabledText)) 00721 p->fillRect(opt->rect, QBrush(p->background().color(), Qt::Dense5Pattern)); 00722 break; } 00723 00724 case PE_IndicatorDockWidgetResizeHandle: { 00725 const int motifOffset = 10; 00726 int sw = pixelMetric(PM_SplitterWidth); 00727 if (opt->state & State_Horizontal) { 00728 int yPos = opt->rect.y() + opt->rect.height() / 2; 00729 int kPos = opt->rect.right() - motifOffset - sw; 00730 int kSize = sw - 2; 00731 00732 qDrawShadeLine(p, opt->rect.left(), yPos, kPos, yPos, opt->palette); 00733 qDrawShadePanel(p, kPos, yPos - sw / 2 + 1, kSize, kSize, 00734 opt->palette, false, 1, &opt->palette.brush(QPalette::Button)); 00735 qDrawShadeLine(p, kPos + kSize - 1, yPos, opt->rect.right(), yPos, opt->palette); 00736 } else { 00737 int xPos = opt->rect.x() + opt->rect.width() / 2; 00738 int kPos = motifOffset; 00739 int kSize = sw - 2; 00740 00741 qDrawShadeLine(p, xPos, opt->rect.top() + kPos + kSize - 1, xPos, opt->rect.bottom(), opt->palette); 00742 qDrawShadePanel(p, xPos - sw / 2 + 1, opt->rect.top() + kPos, kSize, kSize, opt->palette, 00743 false, 1, &opt->palette.brush(QPalette::Button)); 00744 qDrawShadeLine(p, xPos, opt->rect.top(), xPos, opt->rect.top() + kPos, opt->palette); 00745 } 00746 break; } 00747 00748 case PE_IndicatorMenuCheckMark: { 00749 const int markW = 6; 00750 const int markH = 6; 00751 int posX = opt->rect.x() + (opt->rect.width() - markW) / 2 - 1; 00752 int posY = opt->rect.y() + (opt->rect.height() - markH) / 2; 00753 int dfw = pixelMetric(PM_DefaultFrameWidth); 00754 00755 if (dfw < 2) { 00756 // Could do with some optimizing/caching... 00757 QPolygon a(7*2); 00758 int i, xx, yy; 00759 xx = posX; 00760 yy = 3 + posY; 00761 for (i=0; i<3; i++) { 00762 a.setPoint(2*i, xx, yy); 00763 a.setPoint(2*i+1, xx, yy+2); 00764 xx++; yy++; 00765 } 00766 yy -= 2; 00767 for (i=3; i<7; i++) { 00768 a.setPoint(2*i, xx, yy); 00769 a.setPoint(2*i+1, xx, yy+2); 00770 xx++; yy--; 00771 } 00772 if (! (opt->state & State_Enabled) && ! (opt->state & State_On)) { 00773 int pnt; 00774 p->setPen(opt->palette.highlightedText().color()); 00775 QPoint offset(1,1); 00776 for (pnt = 0; pnt < (int)a.size(); pnt++) 00777 a[pnt] += offset; 00778 p->drawPolyline(a); 00779 for (pnt = 0; pnt < (int)a.size(); pnt++) 00780 a[pnt] -= offset; 00781 } 00782 p->setPen(opt->palette.text().color()); 00783 p->drawPolyline(a); 00784 00785 qDrawShadePanel(p, posX-2, posY-2, markW+4, markH+6, opt->palette, true, dfw); 00786 } else 00787 qDrawShadePanel(p, posX, posY, markW, markH, opt->palette, true, dfw, 00788 &opt->palette.brush(QPalette::Mid)); 00789 00790 break; } 00791 00792 case PE_IndicatorProgressChunk: 00793 { 00794 bool vertical = false; 00795 if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) 00796 vertical = (pb2->orientation == Qt::Vertical); 00797 if (!vertical) { 00798 p->fillRect(opt->rect.x(), opt->rect.y() + 2, opt->rect.width(), 00799 opt->rect.height() - 4, opt->palette.brush(QPalette::Highlight)); 00800 } else { 00801 p->fillRect(opt->rect.x() + 1, opt->rect.y(), opt->rect.width() - 4, opt->rect.height(), 00802 opt->palette.brush(QPalette::Highlight)); 00803 } 00804 } 00805 break; 00806 00807 default: 00808 QCommonStyle::drawPrimitive(pe, opt, p, w); 00809 break; 00810 } 00811 }
Here is the call graph for this function:

| void QMotifStyle::drawControl | ( | ControlElement | element, | |
| const QStyleOption * | opt, | |||
| QPainter * | p, | |||
| const QWidget * | widget = 0 | |||
| ) | const [virtual] |
Reimplemented from QCommonStyle.
Definition at line 817 of file qmotifstyle.cpp.
References a, QIcon::Active, QPalette::Active, QRect::adjusted(), Qt::AlignCenter, Qt::AlignLeft, Qt::AlignVCenter, QStyleOptionButton::AutoDefaultButton, QPalette::Background, background, QPalette::background(), QRect::bottom(), QRect::bottomLeft(), QPalette::brush(), QPalette::Button, QStyle::CE_CheckBox, QStyle::CE_CheckBoxLabel, QStyle::CE_HeaderSection, QStyle::CE_MenuBarItem, QStyle::CE_MenuItem, QStyle::CE_MenuTearoff, 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_ScrollBarAddLine, QStyle::CE_ScrollBarAddPage, QStyle::CE_ScrollBarSlider, QStyle::CE_ScrollBarSubLine, QStyle::CE_ScrollBarSubPage, QStyle::CE_Splitter, QStyle::CE_TabBarTabShape, QRect::center(), QBrush::color(), d, QColor::dark(), Qt::DashLine, QStyleOptionButton::DefaultButton, Qt::Dense4Pattern, Qt::Dense5Pattern, QStyleOption::direction, QCommonStyle::drawControl(), QStyle::drawItemText(), drawPrimitive(), QPainter::drawRect(), QStyleOptionTab::End, QPainter::end(), QStyleOptionMenuItem::Exclusive, focus, QPixmap::fromImage(), h, QStyleOptionButton::HasMenu, QPixmap::height(), QRect::height(), QPalette::highlight(), QPalette::Highlight, QStyleOptionProgressBarV2::invertedAppearance, QRect::left(), left(), Qt::LeftToRight, QColor::light(), m, mask, QPalette::Mid, QPalette::Midlight, motifArrowHMargin, motifCheckMarkSpace, motifItemFrame, motifItemHMargin, motifItemVMargin, QRect::moveCenter(), Qt::NoBrush, Qt::NoPen, QIcon::Normal, QStyleOptionMenuItem::NotCheckable, QIcon::On, Qt::OpaqueMode, QStyleOptionProgressBarV2::orientation, p, QStyleOption::palette, QStyle::PE_FrameFocusRect, QStyle::PE_IndicatorArrowDown, QStyle::PE_IndicatorArrowLeft, QStyle::PE_IndicatorArrowRight, QStyle::PE_IndicatorArrowUp, QStyle::PE_IndicatorCheckBox, QStyle::PE_IndicatorDockWidgetResizeHandle, QStyle::PE_IndicatorRadioButton, QStyle::PE_PanelButtonBevel, QStyle::PE_PanelButtonCommand, pixelMetric(), QStyle::PM_ButtonDefaultIndicator, QStyle::PM_DefaultFrameWidth, QStyle::PM_MenuButtonIndicator, QStyle::PM_MenuPanelWidth, QStyle::PM_ProgressBarChunkWidth, QStyle::PM_SmallIconSize, qDrawShadePanel(), qMax(), QStyleOption::rect, reverse(), right(), QRect::right(), Qt::RightToLeft, QTabBar::RoundedEast, QTabBar::RoundedNorth, QTabBar::RoundedSouth, QTabBar::RoundedWest, s, QPixmap::save(), QStyle::SE_CheckBoxContents, QStyle::SE_CheckBoxFocusRect, QStyle::SE_CheckBoxIndicator, QStyle::SE_PushButtonContents, QStyle::SE_PushButtonFocusRect, QStyle::SE_RadioButtonContents, QStyle::SE_RadioButtonFocusRect, QStyle::SE_RadioButtonIndicator, QStyleOptionMenuItem::Separator, QPainter::setBackground(), QPainter::setBackgroundMode(), QPainter::setBrush(), QPalette::setColor(), QPainter::setPen(), QRect::setRect(), QStyle::SH_DitherDisabledText, QStyle::SH_RubberBand_Mask, QStyleOption::state, QStyle::State_Enabled, QStyle::State_HasFocus, QStyle::State_Horizontal, QStyle::State_None, QStyle::State_On, QStyle::State_Raised, QStyle::State_Selected, QStyle::State_Sunken, styleHint(), subElementRect(), QStyleOptionMenuItem::SubMenu, t, QPalette::Text, Qt::TextDontClip, Qt::TextShowMnemonic, Qt::TextSingleLine, QPixmap::toImage(), QRect::top(), QRect::topLeft(), u, Qt::Vertical, QStyle::visualRect(), w, QRect::width(), QPixmap::width(), QPalette::Window, QRect::x(), x, QRect::y(), and y.
Referenced by drawComplexControl(), QCDEStyle::drawControl(), and NorwegianWoodStyle::drawControl().
00819 { 00820 switch(element) { 00821 case CE_Splitter: { 00822 QStyleOption handleOpt = *opt; 00823 if (handleOpt.state & State_Horizontal) 00824 handleOpt.state &= ~State_Horizontal; 00825 else 00826 handleOpt.state |= State_Horizontal; 00827 drawPrimitive(PE_IndicatorDockWidgetResizeHandle, &handleOpt, p, widget); 00828 break; } 00829 00830 case CE_ScrollBarSubLine: 00831 case CE_ScrollBarAddLine:{ 00832 PrimitiveElement pe; 00833 if (element == CE_ScrollBarAddLine) 00834 pe = (opt->state & State_Horizontal) ? (opt->direction == Qt::LeftToRight ? PE_IndicatorArrowRight : PE_IndicatorArrowLeft) : PE_IndicatorArrowDown; 00835 else 00836 pe = (opt->state & State_Horizontal) ? (opt->direction == Qt::LeftToRight ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight) : PE_IndicatorArrowUp; 00837 QStyleOption arrowOpt = *opt; 00838 arrowOpt.state |= State_Enabled; 00839 drawPrimitive(pe, &arrowOpt, p, widget); 00840 if (!(opt->state & State_Enabled) && styleHint(SH_DitherDisabledText)) { 00841 int fw = pixelMetric(PM_DefaultFrameWidth); 00842 p->fillRect(opt->rect.adjusted(fw, fw, -fw, -fw), QBrush(p->background().color(), Qt::Dense5Pattern)); 00843 } 00844 }break; 00845 00846 case CE_ScrollBarSubPage: 00847 case CE_ScrollBarAddPage: 00848 p->fillRect(opt->rect, opt->palette.brush((opt->state & State_Enabled) ? QPalette::Mid : QPalette::Window)); 00849 break; 00850 00851 case CE_ScrollBarSlider: { 00852 QStyleOption bevelOpt = *opt; 00853 bevelOpt.state |= State_Raised; 00854 bevelOpt.state &= ~(State_Sunken | State_On); 00855 p->save(); 00856 p->setBrushOrigin(bevelOpt.rect.topLeft()); 00857 drawPrimitive(PE_PanelButtonBevel, &bevelOpt, p, widget); 00858 p->restore(); 00859 if (!(opt->state & State_Enabled) && styleHint(SH_DitherDisabledText)) 00860 p->fillRect(opt->rect, QBrush(p->background().color(), Qt::Dense5Pattern)); 00861 break; } 00862 00863 case CE_RadioButton: 00864 case CE_CheckBox: 00865 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { 00866 bool isRadio = (element == CE_RadioButton); 00867 QStyleOptionButton subopt = *btn; 00868 subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator 00869 : SE_CheckBoxIndicator, btn, widget); 00870 drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox, 00871 &subopt, p, widget); 00872 subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents 00873 : SE_CheckBoxContents, btn, widget); 00874 drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, p, widget); 00875 if ((btn->state & State_HasFocus) && (!focus || !focus->isVisible())) { 00876 QStyleOptionFocusRect fropt; 00877 fropt.QStyleOption::operator=(*btn); 00878 fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect 00879 : SE_CheckBoxFocusRect, btn, widget); 00880 drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); 00881 } 00882 } 00883 break; 00884 case CE_PushButton: 00885 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { 00886 drawControl(CE_PushButtonBevel, btn, p, widget); 00887 QStyleOptionButton subopt = *btn; 00888 subopt.rect = subElementRect(SE_PushButtonContents, btn, widget); 00889 drawControl(CE_PushButtonLabel, &subopt, p, widget); 00890 if ((btn->state & State_HasFocus) && (!focus || !focus->isVisible())) { 00891 QStyleOptionFocusRect fropt; 00892 fropt.QStyleOption::operator=(*btn); 00893 fropt.rect = subElementRect(SE_PushButtonFocusRect, btn, widget); 00894 drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); 00895 } 00896 } 00897 break; 00898 case CE_PushButtonBevel: 00899 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { 00900 int diw, x1, y1, x2, y2; 00901 p->setPen(opt->palette.foreground().color()); 00902 p->setBrush(QBrush(opt->palette.button().color(), Qt::NoBrush)); 00903 diw = pixelMetric(PM_ButtonDefaultIndicator); 00904 opt->rect.getCoords(&x1, &y1, &x2, &y2); 00905 if (btn->features & (QStyleOptionButton::AutoDefaultButton|QStyleOptionButton::DefaultButton)) { 00906 x1 += diw; 00907 y1 += diw; 00908 x2 -= diw; 00909 y2 -= diw; 00910 } 00911 if (btn->features & QStyleOptionButton::DefaultButton) { 00912 if (diw == 0) { 00913 QPolygon a; 00914 a.setPoints(9, 00915 x1, y1, x2, y1, x2, y2, x1, y2, x1, y1+1, 00916 x2-1, y1+1, x2-1, y2-1, x1+1, y2-1, x1+1, y1+1); 00917 p->setPen(opt->palette.shadow().color()); 00918 p->drawPolygon(a); 00919 x1 += 2; 00920 y1 += 2; 00921 x2 -= 2; 00922 y2 -= 2; 00923 } else { 00924 qDrawShadePanel(p, opt->rect.adjusted(1, 1, -1, -1), opt->palette, true); 00925 } 00926 } 00927 QStyleOptionButton newOpt = *btn; 00928 newOpt.rect = QRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1); 00929 p->setBrushOrigin(p->brushOrigin()); 00930 drawPrimitive(PE_PanelButtonCommand, &newOpt, p, widget); 00931 00932 if (btn->features & QStyleOptionButton::HasMenu) { 00933 int mbi = pixelMetric(PM_MenuButtonIndicator, btn, widget); 00934 QRect ir = btn->rect; 00935 QStyleOptionButton newBtn = *btn; 00936 newBtn.rect = QRect(ir.right() - mbi - 3, ir.y() + 4, mbi, ir.height() - 8); 00937 drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget); 00938 } 00939 break; 00940 } 00941 00942 #ifndef QT_NO_TABBAR 00943 case CE_TabBarTabShape: 00944 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) { 00945 const int default_frame = pixelMetric(PM_DefaultFrameWidth, tab, widget); 00946 const int frame_offset = (default_frame > 1) ? 1 : 0; 00947 00948 if (tab->shape == QTabBar::RoundedNorth || tab->shape == QTabBar::RoundedEast || 00949 tab->shape == QTabBar::RoundedSouth || tab->shape == QTabBar::RoundedWest) { 00950 p->save(); 00951 QRect tabRect = opt->rect; 00952 QColor tabLight = opt->palette.light().color(); 00953 QColor tabDark = opt->palette.dark().color(); 00954 00955 p->fillRect(opt->rect.adjusted(default_frame, default_frame, 00956 -default_frame, -default_frame), 00957 tab->palette.background()); 00958 00959 if(tab->shape == QTabBar::RoundedWest) { 00960 tabDark = opt->palette.light().color(); 00961 tabLight = opt->palette.dark().color(); 00962 tabRect = QRect(0, 0, tabRect.height(), tabRect.width()); 00963 p->translate(opt->rect.left(), opt->rect.bottom()); 00964 p->rotate(-90); 00965 } else if(tab->shape == QTabBar::RoundedSouth) { 00966 tabDark = opt->palette.light().color(); 00967 tabLight = opt->palette.dark().color(); 00968 tabRect = QRect(0, 0, tabRect.width(), tabRect.height()); 00969 p->translate(opt->rect.right(), opt->rect.bottom()); 00970 p->rotate(180); 00971 } else if(tab->shape == QTabBar::RoundedEast) { 00972 tabRect = QRect(0, 0, tabRect.height(), tabRect.width()); 00973 p->translate(opt->rect.right(), opt->rect.top()); 00974 p->rotate(90); 00975 } 00976 00977 if (default_frame > 1) { 00978 p->setPen(tabLight); 00979 p->drawLine(tabRect.left(), tabRect.bottom(), 00980 tabRect.right(), tabRect.bottom()); 00981 p->setPen(tabLight); 00982 p->drawLine(tabRect.left(), tabRect.bottom()-1, 00983 tabRect.right(), tabRect.bottom()-1); 00984 if (tabRect.left() == 0) 00985 p->drawPoint(tabRect.bottomLeft()); 00986 } else { 00987 p->setPen(tabLight); 00988 p->drawLine(tabRect.left(), tabRect.bottom(), 00989 tabRect.right(), tabRect.bottom()); 00990 } 00991 00992 if (opt->state & State_Selected) { 00993 p->fillRect(QRect(tabRect.left()+1, tabRect.bottom()-frame_offset, 00994 tabRect.width()-3, 2), 00995 tab->palette.brush(QPalette::Active, QPalette::Background)); 00996 p->setPen(tab->palette.background().color()); 00997 p->drawLine(tabRect.left()+1, tabRect.bottom(), 00998 tabRect.left()+1, tabRect.top()+2); 00999 p->setPen(tabLight); 01000 } else { 01001 p->setPen(tabLight); 01002 } 01003 p->drawLine(tabRect.left(), tabRect.bottom()-1, 01004 tabRect.left(), tabRect.top() + 2); 01005 p->drawPoint(tabRect.left()+1, tabRect.top() + 1); 01006 p->drawLine(tabRect.left()+2, tabRect.top(), 01007 tabRect.right() - 2, tabRect.top()); 01008 p->drawPoint(tabRect.left(), tabRect.bottom()); 01009 01010 if (default_frame > 1) { 01011 p->drawLine(tabRect.left()+1, tabRect.bottom(), 01012 tabRect.left()+1, tabRect.top() + 2); 01013 p->drawLine(tabRect.left()+2, tabRect.top()+1, 01014 tabRect.right() - 2, tabRect.top()+1); 01015 } 01016 01017 p->setPen(tabDark); 01018 p->drawLine(tabRect.right() - 1, tabRect.top() + 2, 01019 tabRect.right() - 1, tabRect.bottom() - 1 + 01020 ((opt->state & State_Selected) ? frame_offset : -frame_offset)); 01021 if (default_frame > 1) { 01022 p->drawPoint(tabRect.right() - 1, tabRect.top() + 1); 01023 p->drawLine(tabRect.right(), tabRect.top() + 2, tabRect.right(), 01024 tabRect.bottom() - 01025 ((opt->state & State_Selected) ? 01026 ((tab->position == QStyleOptionTab::End) ? 0:1):1+frame_offset)); 01027 p->drawPoint(tabRect.right() - 1, tabRect.top() + 1); 01028 } 01029 p->restore(); 01030 } else { 01031 QCommonStyle::drawControl(element, opt, p, widget); 01032 } 01033 break; } 01034 #endif // QT_NO_TABBAR 01035 case CE_ProgressBarGroove: 01036 qDrawShadePanel(p, opt->rect, opt->palette, true, 2); 01037 break; 01038 01039 case CE_ProgressBarLabel: 01040 if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) { 01041 QMatrix oldMatrix = p->matrix(); 01042 QRect rect = pb->rect; 01043 bool vertical = false; 01044 bool invert = false; 01045 bool bottomToTop = false; 01046 if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) { 01047 vertical = (pb2->orientation == Qt::Vertical); 01048 invert = pb2->invertedAppearance; 01049 bottomToTop = pb2->bottomToTop; 01050 } 01051 if (vertical) { 01052 QMatrix m; 01053 rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height 01054 if (bottomToTop) { 01055 m.translate(0.0, rect.width()); 01056 m.rotate(-90); 01057 } else { 01058 m.translate(rect.height(), 0.0); 01059 m.rotate(90); 01060 } 01061 p->setMatrix(m); 01062 } 01063 const int unit_width = pixelMetric(PM_ProgressBarChunkWidth, opt, widget); 01064 int u = rect.width() / unit_width; 01065 int p_v = pb->progress - pb->minimum; 01066 int t_s = qMax(0, pb->maximum - pb->minimum); 01067 if (u > 0 && pb->progress >= INT_MAX / u && t_s >= u) { 01068 // scale down to something usable. 01069 p_v /= u; 01070 t_s /= u; 01071 } 01072 if (pb->textVisible && t_s) { 01073 int nu = (u * p_v + t_s/2) / t_s; 01074 int x = unit_width * nu; 01075 QRect left(rect.x(), rect.y(), x, rect.height()); 01076 QRect right(rect.x() + x, rect.y(), rect.width() - x, rect.height()); 01077 Qt::LayoutDirection dir; 01078 dir = vertical ? (bottomToTop ? Qt::LeftToRight : Qt::RightToLeft) : pb->direction; 01079 if (invert) 01080 dir = (dir == Qt::LeftToRight) ? Qt::RightToLeft : Qt::LeftToRight; 01081 const QRect highlighted = visualRect(dir, rect, left); 01082 const QRect background = visualRect(dir, rect, right); 01083 p->setPen(opt->palette.highlightedText().color()); 01084 p->setClipRect(highlighted); 01085 p->drawText(rect, Qt::AlignCenter | Qt::TextSingleLine, pb->text); 01086 01087 if (pb->progress != pb->maximum) { 01088 p->setClipRect(background); 01089 p->setPen(opt->palette.highlight().color()); 01090 p->drawText(rect, Qt::AlignCenter | Qt::TextSingleLine, pb->text); 01091 } 01092 } 01093 p->setMatrix(oldMatrix); 01094 break; 01095 } 01096 01097 case CE_MenuTearoff: { 01098 if(opt->state & State_Selected) { 01099 if(pixelMetric(PM_MenuPanelWidth, opt, widget) > 1) 01100 qDrawShadePanel(p, opt->rect.x(), opt->rect.y(), opt->rect.width(), 01101 opt->rect.height(), opt->palette, false, motifItemFrame, 01102 &opt->palette.brush(QPalette::Button)); 01103 else 01104 qDrawShadePanel(p, opt->rect.x()+1, opt->rect.y()+1, opt->rect.width()-2, 01105 opt->rect.height()-2, opt->palette, true, 1, &opt->palette.brush(QPalette::Button)); 01106 } else { 01107 p->fillRect(opt->rect, opt->palette.brush(QPalette::Button)); 01108 } 01109 p->setPen(QPen(opt->palette.dark().color(), 1, Qt::DashLine)); 01110 p->drawLine(opt->rect.x()+2, opt->rect.y()+opt->rect.height()/2-1, opt->rect.x()+opt->rect.width()-4, 01111 opt->rect.y()+opt->rect.height()/2-1); 01112 p->setPen(QPen(opt->palette.light().color(), 1, Qt::DashLine)); 01113 p->drawLine(opt->rect.x()+2, opt->rect.y()+opt->rect.height()/2, opt->rect.x()+opt->rect.width()-4, 01114 opt->rect.y()+opt->rect.height()/2); 01115 break; } 01116 01117 case CE_MenuItem: 01118 if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) { 01119 int maxpmw = menuitem->maxIconWidth; 01120 if(menuitem->menuHasCheckableItems) 01121 maxpmw = qMax(maxpmw, motifCheckMarkSpace); 01122 01123 int x, y, w, h; 01124 opt->rect.getRect(&x, &y, &w, &h); 01125 01126 if (menuitem->menuItemType == QStyleOptionMenuItem::Separator) { // draw separator 01127 int textWidth = 0; 01128 if (!menuitem->text.isEmpty()) { 01129 QFont oldFont = p->font(); 01130 p->setFont(menuitem->font); 01131 p->fillRect(x, y, w, h, opt->palette.brush(QPalette::Button)); 01132 drawItemText(p, menuitem->rect.adjusted(10, 0, -5, 0), Qt::AlignLeft | Qt::AlignVCenter, 01133 menuitem->palette, menuitem->state & State_Enabled, menuitem->text, 01134 QPalette::Text); 01135 textWidth = menuitem->fontMetrics.width(menuitem->text) + 10; 01136 y += menuitem->fontMetrics.lineSpacing() / 2; 01137 p->setFont(oldFont); 01138 } 01139 p->setPen(opt->palette.dark().color()); 01140 p->drawLine(x, y, x + 5, y); 01141 p->drawLine(x + 5 + textWidth, y, x+w, y); 01142 p->setPen(opt->palette.light().color()); 01143 p->drawLine(x, y + 1, x + 5, y + 1); 01144 p->drawLine(x + 5 + textWidth, y + 1, x+w, y + 1); 01145 return; 01146 } 01147 01148 int pw = motifItemFrame; 01149 if((opt->state & State_Selected) && (opt->state & State_Enabled)) { // active item frame 01150 if(pixelMetric(PM_MenuPanelWidth, opt) > 1) 01151 qDrawShadePanel(p, x, y, w, h, opt->palette, false, pw, 01152 &opt->palette.brush(QPalette::Button)); 01153 else 01154 qDrawShadePanel(p, x+1, y+1, w-2, h-2, opt->palette, true, 1, 01155 &opt->palette.brush(QPalette::Button)); 01156 } else { // incognito frame 01157 p->fillRect(x, y, w, h, opt->palette.brush(QPalette::Button)); 01158 } 01159 01160 QRect vrect = visualRect(opt->direction, opt->rect, 01161 QRect(x+motifItemFrame, y+motifItemFrame, maxpmw, 01162 h-2*motifItemFrame)); 01163 int xvis = vrect.x(); 01164 if (menuitem->checked) { 01165 if(!menuitem->icon.isNull()) 01166 qDrawShadePanel(p, xvis, y+motifItemFrame, maxpmw, h-2*motifItemFrame, 01167 opt->palette, true, 1, &opt->palette.brush(QPalette::Midlight)); 01168 } else if (!(opt->state & State_Selected)) { 01169 p->fillRect(xvis, y+motifItemFrame, maxpmw, h-2*motifItemFrame, 01170 opt->palette.brush(QPalette::Button)); 01171 } 01172 01173 if(!menuitem->icon.isNull()) { // draw icon 01174 QIcon::Mode mode = QIcon::Normal; // no disabled icons in Motif 01175 if ((opt->state & State_Selected) && !!(opt->state & State_Enabled)) 01176 mode = QIcon::Active; 01177 QPixmap pixmap; 01178 if (menuitem->checkType != QStyleOptionMenuItem::NotCheckable && menuitem->checked) 01179 pixmap = menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize), mode, QIcon::On); 01180 else 01181 pixmap = menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize), mode); 01182 01183 int pixw = pixmap.width(); 01184 int pixh = pixmap.height(); 01185 QRect pmr(0, 0, pixw, pixh); 01186 pmr.moveCenter(vrect.center()); 01187 p->setPen(opt->palette.text().color()); 01188 p->drawPixmap(pmr.topLeft(), pixmap); 01189 01190 } else if (menuitem->checkType != QStyleOptionMenuItem::NotCheckable) { // just "checking"... 01191 int mh = h - 2*motifItemFrame; 01192 01193 QStyleOptionButton newMenuItem; 01194 newMenuItem.state = menuitem->checked ? State_On : State_None; 01195 if (opt->state & State_Enabled) { 01196 newMenuItem.state |= State_Enabled; 01197 if (menuitem->state & State_Sunken) 01198 newMenuItem.state |= State_Sunken; 01199 } 01200 if (menuitem->checkType & QStyleOptionMenuItem::Exclusive) { 01201 newMenuItem.rect.setRect(xvis + 2, y + motifItemFrame + mh / 4, 11, 11); 01202 drawPrimitive(PE_IndicatorRadioButton, &newMenuItem, p, widget); 01203 } else { 01204 newMenuItem.rect.setRect(xvis + 5, y + motifItemFrame + mh / 4, 9, 9); 01205 drawPrimitive(PE_IndicatorCheckBox, &newMenuItem, p, widget); 01206 } 01207 } 01208 01209 p->setPen(opt->palette.buttonText().color()); 01210 01211 QColor discol; 01212 if (!(opt->state & State_Enabled)) { 01213 discol = opt->palette.text().color(); 01214 p->setPen(discol); 01215 } 01216 01217 int xm = motifItemFrame + maxpmw + motifItemHMargin; 01218 01219 vrect = visualRect(opt->direction, opt->rect, 01220 QRect(x+xm, y+motifItemVMargin, w-xm-menuitem->tabWidth, 01221 h-2*motifItemVMargin)); 01222 xvis = vrect.x(); 01223 01224 QString s = menuitem->text; 01225 if (!s.isNull()) { // draw text 01226 int t = s.indexOf(QLatin1Char('\t')); 01227 int m = motifItemVMargin; 01228 int text_flags = Qt::AlignVCenter|Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; 01229 text_flags |= Qt::AlignLeft; 01230 QFont oldFont = p->font(); 01231 p->setFont(menuitem->font); 01232 if (t >= 0) { // draw tab text 01233 QRect vr = visualRect(opt->direction, opt->rect, 01234 QRect(x+w-menuitem->tabWidth-motifItemHMargin-motifItemFrame, 01235 y+motifItemVMargin, menuitem->tabWidth, 01236 h-2*motifItemVMargin)); 01237 int xv = vr.x(); 01238 QRect tr(xv, y+m, menuitem->tabWidth, h-2*m); 01239 p->drawText(tr, text_flags, s.mid(t+1)); 01240 if (!(opt->state & State_Enabled) && styleHint(SH_DitherDisabledText)) 01241 p->fillRect(tr, QBrush(p->background().color(), Qt::Dense5Pattern)); 01242 s = s.left(t); 01243 } 01244 QRect tr(xvis, y+m, w - xm - menuitem->tabWidth + 1, h-2*m); 01245 p->drawText(tr, text_flags, s.left(t)); 01246 p->setFont(oldFont); 01247 if (!(opt->state & State_Enabled) && styleHint(SH_DitherDisabledText)) 01248 p->fillRect(tr, QBrush(p->background().color(), Qt::Dense5Pattern)); 01249 } 01250 if (menuitem->menuItemType == QStyleOptionMenuItem::SubMenu) { // draw sub menu arrow 01251 int dim = (h-2*motifItemFrame) / 2; 01252 QStyle::PrimitiveElement arrow = (opt->direction == Qt::RightToLeft ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight); 01253 QStyleOption arrowOpt = *opt; 01254 arrowOpt.rect = visualRect(opt->direction, opt->rect, 01255 QRect(x+w - motifArrowHMargin - motifItemFrame - dim, 01256 y+h/2-dim/2, dim, dim)); 01257 if ((opt->state & State_Selected)) 01258 arrowOpt.state = (State_Sunken | ((opt->state & State_Enabled) ? State_Enabled : State_None)); 01259 else 01260 arrowOpt.state = ((opt->state & State_Enabled) ? State_Enabled : State_None); 01261 drawPrimitive(arrow, &arrowOpt, p, widget); 01262 } 01263 break; } 01264 01265 case CE_MenuBarItem: 01266 if (opt->state & State_Selected) // active item 01267 qDrawShadePanel(p, opt->rect, opt->palette, false, motifItemFrame, 01268 &opt->palette.brush(QPalette::Button)); 01269 else // other item 01270 p->fillRect(opt->rect, opt->palette.brush(QPalette::Button)); 01271 QCommonStyle::drawControl(element, opt, p, widget); 01272 break; 01273 01274 case CE_HeaderSection: 01275 p->save(); 01276 p->setBrushOrigin(opt->rect.topLeft()); 01277 qDrawShadePanel(p, opt->rect, opt->palette, bool(opt->state & (State_Sunken|State_On)), 01278 pixelMetric(PM_DefaultFrameWidth), 01279 &opt->palette.brush((opt->state & State_Sunken) ? QPalette::Mid : QPalette::Button)); 01280 p->restore(); 01281 break; 01282 case CE_RubberBand: { 01283 QPixmap tiledPixmap(16, 16); 01284 QPainter pixmapPainter(&tiledPixmap); 01285 pixmapPainter.setPen(Qt::NoPen); 01286 pixmapPainter.setBrush(Qt::Dense4Pattern); 01287 pixmapPainter.setBackground(QBrush(opt->palette.base())); 01288 pixmapPainter.setBackgroundMode(Qt::OpaqueMode); 01289 pixmapPainter.drawRect(0, 0, tiledPixmap.width(), tiledPixmap.height()); 01290 pixmapPainter.end(); 01291 // ### workaround for borked XRENDER 01292 tiledPixmap = QPixmap::fromImage(tiledPixmap.toImage()); 01293 01294 p->save(); 01295 QRect r = opt->rect; 01296 QStyleHintReturnMask mask; 01297 if (styleHint(QStyle::SH_RubberBand_Mask, opt, widget, &mask)) 01298 p->setClipRegion(mask.region); 01299 p->drawTiledPixmap(r.x(), r.y(), r.width(), r.height(), tiledPixmap); 01300 p->restore(); 01301 } 01302 break; 01303 #ifndef QT_NO_PROGRESSBAR 01304 case CE_ProgressBarContents: 01305 if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) { 01306 QRect rect = pb->rect; 01307 bool vertical = false; 01308 bool inverted = false; 01309 01310 // Get extra style options if version 2 01311 const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt); 01312 if (pb2) { 01313 vertical = (pb2->orientation == Qt::Vertical); 01314 inverted = pb2->invertedAppearance; 01315 } 01316 01317 QMatrix m; 01318 if (vertical) { 01319 rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height 01320 m.translate(rect.height(), 0.0); 01321 m.rotate(90); 01322 } 01323 01324 QPalette pal2 = pb->palette; 01325 // Correct the highlight color if it is the same as the background 01326 if (pal2.highlight() == pal2.background()) 01327 pal2.setColor(QPalette::Highlight, pb->palette.color(QPalette::Active, 01328 QPalette::Highlight)); 01329 bool reverse = ((!vertical && (pb->direction == Qt::RightToLeft)) || vertical); 01330 if (inverted) 01331 reverse = !reverse; 01332 int fw = 2; 01333 int w = rect.width() - 2 * fw; 01334 if (pb->minimum == 0 && pb->maximum == 0) { 01335 QRect progressBar; 01336 Q_D(const QMotifStyle); 01337 // draw busy indicator 01338 int x = (d->animateStep*8)% (w * 2); 01339 if (x > w) 01340 x = 2 * w - x; 01341 x = reverse ? rect.right() - x : x + rect.x(); 01342 p->setMatrix(m); 01343 p->setPen(QPen(pal2.highlight().color(), 4)); 01344 p->drawLine(x, rect.y() + 1, x, rect.height() - fw); 01345 01346 } else 01347 QCommonStyle::drawControl(element, opt, p, widget); 01348 } 01349 break; 01350 #endif // QT_NO_PROGRESSBAR 01351 default: 01352 QCommonStyle::drawControl(element, opt, p, widget); 01353 break; } 01354 }
Here is the call graph for this function:

| void QMotifStyle::drawComplexControl | ( | ComplexControl | cc, | |
| const QStyleOptionComplex * | opt, | |||
| QPainter * | p, | |||
| const QWidget * | widget = 0 | |||
| ) | const [virtual] |
Reimplemented from QCommonStyle.
Definition at line 1406 of file qmotifstyle.cpp.
References a, QRect::adjust(), QRect::adjusted(), QPalette::Base, QPalette::Button, c, QStyle::CC_ComboBox, QStyle::CC_Q3ListView, QStyle::CC_ScrollBar, QStyle::CC_Slider, QStyle::CC_SpinBox, QStyle::CC_ToolButton, QStyle::CE_ToolButtonLabel, QStyleOptionQ3ListViewItem::childCount, TokenEngine::copy(), Qt::Dense5Pattern, QPalette::Disabled, QCommonStyle::drawComplexControl(), drawControl(), drawPrimitive(), QStyleOptionQ3ListViewItem::Expandable, QStyleOptionQ3ListViewItem::features, focus, get_combo_parameters(), QApplication::globalStrut(), height, Qt::Horizontal, i, QRect::isValid(), QStyleOptionFrame::lineWidth, QPalette::Mid, QStyleOptionFrame::midLineWidth, QStyleOptionQ3ListViewItem::MultiLine, Qt::NoBrush, p, QStyleOption::palette, QStyle::PE_FrameFocusRect, QStyle::PE_FrameLineEdit, QStyle::PE_IndicatorArrowDown, QStyle::PE_IndicatorButtonDropDown, QStyle::PE_IndicatorSpinDown, QStyle::PE_IndicatorSpinMinus, QStyle::PE_IndicatorSpinPlus, QStyle::PE_IndicatorSpinUp, QStyle::PE_PanelButtonBevel, QStyle::PE_PanelButtonCommand, QStyle::PE_PanelButtonTool, pixelMetric(), QAbstractSpinBox::PlusMinus, QStyle::PM_ComboBoxFrameWidth, QStyle::PM_DefaultFrameWidth, QStyle::PM_SpinBoxFrameWidth, qDrawShadeLine(), qDrawShadePanel(), qMax(), QStyleOption::rect, QVector< T >::resize(), QStyle::SC_All, QStyle::SC_ComboBoxArrow, QStyle::SC_ComboBoxEditField, QStyle::SC_Q3ListView, QStyle::SC_Q3ListViewBranch, QStyle::SC_Q3ListViewExpand, QStyle::SC_ScrollBarGroove, QStyle::SC_SliderGroove, QStyle::SC_SliderHandle, QStyle::SC_SliderTickmarks, QStyle::SC_SpinBoxDown, QStyle::SC_SpinBoxEditField, QStyle::SC_SpinBoxFrame, QStyle::SC_SpinBoxUp, QStyle::SC_ToolButton, QStyle::SC_ToolButtonMenu, QStyle::SE_ComboBoxFocusRect, QStyle::SE_SliderFocusRect, QPalette::setCurrentColorGroup(), QStyle::SH_DitherDisabledText, QStyleOption::state, QStyle::State_AutoRaise, QStyle::State_Enabled, QStyle::State_HasFocus, QStyle::State_MouseOver, QStyle::State_On, QStyle::State_Open, QStyle::State_Raised, QStyle::State_Sunken, QAbstractSpinBox::StepDownEnabled, QAbstractSpinBox::StepUpEnabled, styleHint(), subControlRect(), QStyleOptionComplex::subControls, subElementRect(), QStyleOptionQ3ListViewItem::Visible, QStyle::visualRect(), QPalette::Window, QRect::x(), and y.
01408 { 01409 switch (cc) { 01410 case CC_ToolButton: 01411 if (const QStyleOptionToolButton *toolbutton 01412 = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) { 01413 QRect button, menuarea; 01414 button = subControlRect(cc, toolbutton, SC_ToolButton, widget); 01415 menuarea = subControlRect(cc, toolbutton, SC_ToolButtonMenu, widget); 01416 01417 State bflags = toolbutton->state; 01418 01419 if (bflags & State_AutoRaise) { 01420 if (!(bflags & State_MouseOver)) { 01421 bflags &= ~State_Raised; 01422 } 01423 } 01424 State mflags = bflags; 01425 01426 if (toolbutton->activeSubControls & SC_ToolButton) 01427 bflags |= State_Sunken; 01428 if (toolbutton->activeSubControls & SC_ToolButtonMenu) 01429 mflags |= State_Sunken; 01430 01431 QStyleOption tool(0); 01432 tool.palette = toolbutton->palette; 01433 if (toolbutton->subControls & SC_ToolButton) { 01434 if (bflags & (State_Sunken | State_On | State_Raised)) { 01435 tool.rect = button; 01436 tool.state = bflags; 01437 drawPrimitive(PE_PanelButtonTool, &tool, p, widget); 01438 } 01439 } 01440 01441 if (toolbutton->subControls & SC_ToolButtonMenu) { 01442 tool.rect = menuarea; 01443 tool.state = mflags; 01444 if (mflags & (State_Sunken | State_On | State_Raised)) 01445 drawPrimitive(PE_IndicatorButtonDropDown, &tool, p, widget); 01446 drawPrimitive(PE_IndicatorArrowDown, &tool, p, widget); 01447 } 01448 01449 if ((toolbutton->state & State_HasFocus) && (!focus || !focus->isVisible())) { 01450 QStyleOptionFocusRect fr; 01451 fr.QStyleOption::operator=(*toolbutton); 01452 fr.rect = toolbutton->rect.adjusted(3, 3, -3, -3); 01453 drawPrimitive(PE_FrameFocusRect, &fr, p, widget); 01454 } 01455 QStyleOptionToolButton label = *toolbutton; 01456 int fw = pixelMetric(PM_DefaultFrameWidth, opt, widget); 01457 label.rect = button.adjusted(fw, fw, -fw, -fw); 01458 drawControl(CE_ToolButtonLabel, &label, p, widget); 01459 } 01460 break; 01461 #ifndef QT_NO_SPINBOX 01462 case CC_SpinBox: 01463 if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) { 01464 QStyleOptionSpinBox copy = *spinbox; 01465 PrimitiveElement pe; 01466 01467 if (spinbox->frame && (spinbox->subControls & SC_SpinBoxFrame)) { 01468 QRect r = subControlRect(CC_SpinBox, spinbox, SC_SpinBoxFrame, widget); 01469 qDrawShadePanel(p, r, opt->palette, false, pixelMetric(PM_SpinBoxFrameWidth)); 01470 01471 int fw = pixelMetric(QStyle::PM_DefaultFrameWidth); 01472 r = subControlRect(CC_SpinBox, spinbox, SC_SpinBoxEditField, widget).adjusted(-fw,-fw,fw,fw); 01473 QStyleOptionFrame lineOpt; 01474 lineOpt.QStyleOption::operator=(*opt); 01475 lineOpt.rect = r; 01476 lineOpt.lineWidth = fw; 01477 lineOpt.midLineWidth = 0; 01478 lineOpt.state |= QStyle::State_Sunken; 01479 drawPrimitive(QStyle::PE_FrameLineEdit, &lineOpt, p, widget); 01480 } 01481 01482 if (spinbox->subControls & SC_SpinBoxUp) { 01483 copy.subControls = SC_SpinBoxUp; 01484 QPalette pal2 = spinbox->palette; 01485 if (!(spinbox->stepEnabled & QAbstractSpinBox::StepUpEnabled)) { 01486 pal2.setCurrentColorGroup(QPalette::Disabled); 01487 copy.state &= ~State_Enabled; 01488 } 01489 01490 copy.palette = pal2; 01491 01492 if (spinbox->activeSubControls == SC_SpinBoxUp && (spinbox->state & State_Sunken)) { 01493 copy.state |= State_On; 01494 copy.state |= State_Sunken; 01495 } else { 01496 copy.state |= State_Raised; 01497 copy.state &= ~State_Sunken; 01498 } 01499 pe = (spinbox->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus 01500 : PE_IndicatorSpinUp); 01501 01502 copy.rect = subControlRect(CC_SpinBox, spinbox, SC_SpinBoxUp, widget); 01503 drawPrimitive(pe, ©, p, widget); 01504 } 01505 01506 if (spinbox->subControls & SC_SpinBoxDown) { 01507 copy.subControls = SC_SpinBoxDown; 01508 copy.state = spinbox->state; 01509 QPalette pal2 = spinbox->palette; 01510 if (!(spinbox->stepEnabled & QAbstractSpinBox::StepDownEnabled)) { 01511 pal2.setCurrentColorGroup(QPalette::Disabled); 01512 copy.state &= ~State_Enabled; 01513 } 01514 copy.palette = pal2; 01515 01516 if (spinbox->activeSubControls == SC_SpinBoxDown && (spinbox->state & State_Sunken)) { 01517 copy.state |= State_On; 01518 copy.state |= State_Sunken; 01519 } else { 01520 copy.state |= State_Raised; 01521 copy.state &= ~State_Sunken; 01522 } 01523 pe = (spinbox->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus 01524 : PE_IndicatorSpinDown); 01525 01526 copy.rect = subControlRect(CC_SpinBox, spinbox, SC_SpinBoxDown, widget); 01527 drawPrimitive(pe, ©, p, widget); 01528 } 01529 } 01530 break; 01531 #endif // QT_NO_SPINBOX 01532 #ifndef QT_NO_SLIDER 01533 case CC_Slider: 01534 if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { 01535 QRect groove = subControlRect(CC_Slider, opt, SC_SliderGroove, widget), 01536 handle = subControlRect(CC_Slider, opt, SC_SliderHandle, widget); 01537 01538 if ((opt->subControls & SC_SliderGroove) && groove.isValid()) { 01539 qDrawShadePanel(p, groove, opt->palette, true, pixelMetric(PM_DefaultFrameWidth), 01540 &opt->palette.brush((opt->state & State_Enabled) ? QPalette::Mid : QPalette::Window)); 01541 if ((opt->state & State_HasFocus) && (!focus || !focus->isVisible())) { 01542 QStyleOption focusOpt = *opt; 01543 focusOpt.rect = subElementRect(SE_SliderFocusRect, opt, widget); 01544 drawPrimitive(PE_FrameFocusRect, &focusOpt, p, widget); 01545 } 01546 } 01547 01548 if ((opt->subControls & SC_SliderHandle) && handle.isValid()) { 01549 QStyleOption bevelOpt = *opt; 01550 bevelOpt.state = (opt->state | State_Raised) & ~State_Sunken; 01551 bevelOpt.rect = handle; 01552 p->save(); 01553 p->setBrushOrigin(bevelOpt.rect.topLeft()); 01554 drawPrimitive(PE_PanelButtonBevel, &bevelOpt, p, widget); 01555 p->restore(); 01556 01557 if (slider->orientation == Qt::Horizontal) { 01558 int mid = handle.x() + handle.width() / 2; 01559 qDrawShadeLine(p, mid, handle.y(), mid, handle.y() + handle.height() - 2, 01560 opt->palette, true, 1); 01561 } else { 01562 int mid = handle.y() + handle.height() / 2; 01563 qDrawShadeLine(p, handle.x(), mid, handle.x() + handle.width() - 2, mid, opt->palette, 01564 true, 1); 01565 } 01566 if (!(opt->state & State_Enabled) && styleHint(SH_DitherDisabledText)) 01567 p->fillRect(handle, QBrush(p->background().color(), Qt::Dense5Pattern)); 01568 } 01569 01570 if (slider->subControls & SC_SliderTickmarks) { 01571 QStyleOptionSlider tmpSlider = *slider; 01572 tmpSlider.subControls = SC_SliderTickmarks; 01573 QCommonStyle::drawComplexControl(cc, &tmpSlider, p, widget); 01574 } 01575 } 01576 break; 01577 #endif // QT_NO_SLIDER 01578 case CC_ComboBox: 01579 if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) { 01580 if (opt->subControls & SC_ComboBoxArrow) { 01581 int awh, ax, ay, sh, sy, dh, ew; 01582 int fw = cb->frame ? pixelMetric(PM_ComboBoxFrameWidth, opt, widget) : 0; 01583 01584 if (cb->frame) { 01585 QStyleOptionButton btn; 01586 btn.QStyleOption::operator=(*cb); 01587 btn.state |= QStyle::State_Raised; 01588 drawPrimitive(PE_PanelButtonCommand, &btn, p, widget); 01589 } else { 01590 p->fillRect(opt->rect, opt->palette.brush(QPalette::Button)); 01591 } 01592 01593 QRect tr = opt->rect; 01594 tr.adjust(fw, fw, -fw, -fw); 01595 get_combo_parameters(tr, ew, awh, ax, ay, sh, dh, sy); 01596 01597 QRect ar = QStyle::visualRect(opt->direction, opt->rect, QRect(ax,ay,awh,awh)); 01598 01599 QStyleOption arrowOpt = *opt; 01600 arrowOpt.rect = ar; 01601 arrowOpt.state |= State_Enabled; 01602 drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget); 01603 01604 01605 // draws the shaded line under the arrow 01606 p->setPen(opt->palette.light().color()); 01607 p->drawLine(ar.x(), sy, ar.x()+awh-1, sy); 01608 p->drawLine(ar.x(), sy, ar.x(), sy+sh-1); 01609 p->setPen(opt->palette.dark().color()); 01610 p->drawLine(ar.x()+1, sy+sh-1, ar.x()+awh-1, sy+sh-1); 01611 p->drawLine(ar.x()+awh-1, sy+1, ar.x()+awh-1, sy+sh-1); 01612 01613 if ((cb->state & State_HasFocus) && (!focus || !focus->isVisible())) { 01614 QStyleOptionFocusRect focus; 01615 focus.QStyleOption::operator=(*opt); 01616 focus.rect = subElementRect(SE_ComboBoxFocusRect, opt, widget); 01617 focus.backgroundColor = opt->palette.button().color(); 01618 drawPrimitive(PE_FrameFocusRect, &focus, p, widget); 01619 } 01620 } 01621 01622 if (opt->subControls & SC_ComboBoxEditField) { 01623 if (cb->editable) { 01624 QRect er = subControlRect(CC_ComboBox, opt, SC_ComboBoxEditField, widget); 01625 er.adjust(-1, -1, 1, 1); 01626 qDrawShadePanel(p, er, opt->palette, true, 1, 01627 &opt->palette.brush(QPalette::Base)); 01628 } 01629 } 01630 p->setPen(opt->palette.buttonText().color()); 01631 } 01632 break; 01633 01634 case CC_ScrollBar: { 01635 if (opt->subControls & SC_ScrollBarGroove) 01636 qDrawShadePanel(p, opt->rect, opt->palette, true, 01637 pixelMetric(PM_DefaultFrameWidth, opt, widget), 01638 &opt->palette.brush((opt->state & State_Enabled) ? QPalette::Mid : QPalette::Window)); 01639 01640 QCommonStyle::drawComplexControl(cc, opt, p, widget); 01641 break; } 01642 01643 01644 case CC_Q3ListView: 01645 if (opt->subControls & (SC_Q3ListViewBranch | SC_Q3ListViewExpand)) { 01646 int i; 01647 if (opt->subControls & SC_Q3ListView) 01648 QCommonStyle::drawComplexControl(cc, opt, p, widget); 01649 if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) { 01650 QStyleOptionQ3ListViewItem item = lv->items.at(0); 01651 int y = opt->rect.y(); 01652 int c; 01653 QPolygon dotlines; 01654 if ((opt->activeSubControls & SC_All) && (opt->subControls & SC_Q3ListViewExpand)) { 01655 c = 2; 01656 dotlines.resize(2); 01657 dotlines[0] = QPoint(opt->rect.right(), opt->rect.top()); 01658 dotlines[1] = QPoint(opt->rect.right(), opt->rect.bottom()); 01659 } else { 01660 int linetop = 0, linebot = 0; 01661 // each branch needs at most two lines, ie. four end points 01662 dotlines.resize(item.childCount * 4); 01663 c = 0; 01664 01665 // skip the stuff above the exposed rectangle 01666 for (i = 1; i < lv->items.size(); ++i) { 01667 QStyleOptionQ3ListViewItem child = lv->items.at(i); 01668 if (child.height + y > 0) 01669 break; 01670 y += child.totalHeight; 01671 } 01672 01673 int bx = opt->rect.width() / 2; 01674 01675 // paint stuff in the magical area 01676 while (i < lv->items.size() && y < lv->rect.height()) { 01677 QStyleOptionQ3ListViewItem child = lv->items.at(i); 01678 if (child.features & QStyleOptionQ3ListViewItem::Visible) { 01679 int lh; 01680 if (!(item.features & QStyleOptionQ3ListViewItem::MultiLine)) 01681 lh = child.height; 01682 else 01683 lh = p->fontMetrics().height() + 2 * lv->itemMargin; 01684 lh = qMax(lh, QApplication::globalStrut().height()); 01685 if (lh % 2 > 0) 01686 lh++; 01687 linebot = y + lh/2; 01688 if ((child.features & QStyleOptionQ3ListViewItem::Expandable || child.childCount > 0) && 01689 child.height > 0) { 01690 // needs a box 01691 p->setPen(opt->palette.text().color()); 01692 p->drawRect(bx-4, linebot-4, 9, 9); 01693 QPolygon a; 01694 if ((child.state & State_Open)) 01695 a.setPoints(3, bx-2, linebot-2, 01696 bx, linebot+2, 01697 bx+2, linebot-2); //Qt::RightArrow 01698 else 01699 a.setPoints(3, bx-2, linebot-2, 01700 bx+2, linebot, 01701 bx-2, linebot+2); //Qt::DownArrow 01702 p->setBrush(opt->palette.text()); 01703 p->drawPolygon(a); 01704 p->setBrush(Qt::NoBrush); 01705 // dotlinery 01706 dotlines[c++] = QPoint(bx, linetop); 01707 dotlines[c++] = QPoint(bx, linebot - 5); 01708 dotlines[c++] = QPoint(bx + 5, linebot); 01709 dotlines[c++] = QPoint(opt->rect.width(), linebot); 01710 linetop = linebot + 5; 01711 } else { 01712 // just dotlinery 01713 dotlines[c++] = QPoint(bx+1, linebot); 01714 dotlines[c++] = QPoint(opt->rect.width(), linebot); 01715 } 01716 y += child.totalHeight; 01717 } 01718 ++i; 01719 } 01720 01721 // Expand line height to edge of rectangle if there's any 01722 // visible child below 01723 while (i < lv->items.size() && lv->items.at(i).height <= 0) 01724 ++i; 01725 if (i < lv->items.size()) 01726 linebot = opt->rect.height(); 01727 01728 if (linetop < linebot) { 01729 dotlines[c++] = QPoint(bx, linetop); 01730 dotlines[c++] = QPoint(bx, linebot); 01731 } 01732 } 01733 01734 int line; // index into dotlines 01735 p->setPen(opt->palette.text().color()); 01736 if (opt->subControls & SC_Q3ListViewBranch) for(line = 0; line < c; line += 2) { 01737 p->drawLine(dotlines[line].x(), dotlines[line].y(), 01738 dotlines[line+1].x(), dotlines[line+1].y()); 01739 } 01740 } 01741 break; } 01742 01743 default: 01744 QCommonStyle::drawComplexControl(cc, opt, p, widget); 01745 break; 01746 } 01747 }
Here is the call graph for this function:

| QRect QMotifStyle::subControlRect | ( | ComplexControl | cc, | |
| const QStyleOptionComplex * | opt, | |||
| SubControl | sc, | |||
| const QWidget * | widget = 0 | |||
| ) | const [virtual] |
Reimplemented from QCommonStyle.
Definition at line 1858 of file qmotifstyle.cpp.
References QRect::adjust(), QRect::bottomRight(), QStyle::CC_ComboBox, QStyle::CC_ScrollBar, QStyle::CC_Slider, QStyle::CC_SpinBox, QSize::expandedTo(), get_combo_extra_width(), get_combo_parameters(), QApplication::globalStrut(), QRect::height(), QSize::height(), Qt::Horizontal, len, pixelMetric(), QStyle::PM_ComboBoxFrameWidth, QStyle::PM_DefaultFrameWidth, QStyle::PM_SliderControlThickness, QStyle::PM_SliderLength, QStyle::PM_SliderTickmarkOffset, QStyle::PM_SpinBoxFrameWidth, qMin(), QStyle::SC_ComboBoxArrow, QStyle::SC_ComboBoxEditField, QStyle::SC_ScrollBarGroove, QStyle::SC_ScrollBarSlider, QStyle::SC_SliderHandle, QStyle::SC_SpinBoxDown, QStyle::SC_SpinBoxEditField, QStyle::SC_SpinBoxFrame, QStyle::SC_SpinBoxUp, QSize::setHeight(), QSize::setWidth(), QStyle::sliderPositionFromValue(), QCommonStyle::subControlRect(), QStyle::visualRect(), QRect::width(), QSize::width(), x, and y.
Referenced by drawComplexControl().
01860 { 01861 switch (cc) { 01862 #ifndef QT_NO_SPINBOX 01863 case CC_SpinBox: 01864 if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) { 01865 int fw = spinbox->frame ? pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0; 01866 QSize bs; 01867 bs.setHeight(opt->rect.height()/2 - fw); 01868 bs.setWidth(qMin(bs.height() * 8 / 5, opt->rect.width() / 4)); // 1.6 -approximate golden mean 01869 bs = bs.expandedTo(QApplication::globalStrut()); 01870 int y = fw; 01871 int x, lx, rx; 01872 x = opt->rect.width() - y - bs.width(); 01873 lx = fw; 01874 rx = x - fw * 2; 01875 const int margin = spinbox->frame ? 4 : 0; 01876 switch (sc) { 01877 case SC_SpinBoxUp: 01878 return visualRect(spinbox->direction, spinbox->rect, 01879 QRect(x, y, bs.width(), bs.height() - 1)); 01880 case SC_SpinBoxDown: 01881 return visualRect(spinbox->direction, spinbox->rect, 01882 QRect(x, y + bs.height() + 1, bs.width(), bs.height() - 1)); 01883 case SC_SpinBoxEditField: 01884 return visualRect(spinbox->direction, spinbox->rect, 01885 QRect(lx + margin, fw + margin, rx - margin, 01886 spinbox->rect.height() - 2*fw - 2 * margin)); 01887 case SC_SpinBoxFrame: 01888 return visualRect(spinbox->direction, spinbox->rect, spinbox->rect); 01889 default: 01890 break; 01891 } 01892 break; } 01893 #endif // QT_NO_SPINBOX 01894 #ifndef QT_NO_SLIDER 01895 case CC_Slider: 01896 if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { 01897 if (sc == SC_SliderHandle) { 01898 int tickOffset = pixelMetric(PM_SliderTickmarkOffset, opt, widget); 01899 int thickness = pixelMetric(PM_SliderControlThickness, opt, widget); 01900 bool horizontal = slider->orientation == Qt::Horizontal; 01901 int len = pixelMetric(PM_SliderLength, opt, widget); 01902 int motifBorder = pixelMetric(PM_DefaultFrameWidth); 01903 int sliderPos = sliderPositionFromValue(slider->minimum, slider->maximum, slider->sliderPosition, 01904 horizontal ? slider->rect.width() - len - 2 * motifBorder 01905 : slider->rect.height() - len - 2 * motifBorder, 01906 slider->upsideDown); 01907 if (horizontal) 01908 return visualRect(slider->direction, slider->rect, 01909 QRect(sliderPos + motifBorder, tickOffset + motifBorder, len, 01910 thickness - 2 * motifBorder)); 01911 return visualRect(slider->direction, slider->rect, 01912 QRect(tickOffset + motifBorder, sliderPos + motifBorder, 01913 thickness - 2 * motifBorder, len)); 01914 } 01915 } 01916 break; 01917 #endif // QT_NO_SLIDER 01918 #ifndef QT_NO_SCROLLBAR 01919 case CC_ScrollBar: 01920 if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { 01921 int dfw = pixelMetric(PM_DefaultFrameWidth); 01922 QRect rect = visualRect(scrollbar->direction, scrollbar->rect, 01923 QCommonStyle::subControlRect(cc, scrollbar, sc, widget)); 01924 if (sc == SC_ScrollBarSlider) { 01925 if (scrollbar->orientation == Qt::Horizontal) 01926 rect.adjust(-dfw, dfw, dfw, -dfw); 01927 else 01928 rect.adjust(dfw, -dfw, -dfw, dfw); 01929 } else if (sc != SC_ScrollBarGroove) 01930 if (scrollbar->orientation == Qt::Horizontal) 01931 rect.adjust(0, dfw, 0, -dfw); 01932 else 01933 rect.adjust(dfw, 0, -dfw, 0); 01934 return visualRect(scrollbar->direction, scrollbar->rect, rect); 01935 } 01936 break; 01937 #endif // QT_NO_SCROLLBAR 01938 #ifndef QT_NO_COMBOBOX 01939 case CC_ComboBox: 01940 if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) { 01941 switch (sc) { 01942 case SC_ComboBoxArrow: { 01943 int ew, awh, sh, dh, ax, ay, sy; 01944 int fw = cb->frame ? pixelMetric(PM_ComboBoxFrameWidth, opt, widget) : 0; 01945 QRect cr = opt->rect; 01946 cr.adjust(fw, fw, -fw, -fw); 01947 get_combo_parameters(cr, ew, awh, ax, ay, sh, dh, sy); 01948 return visualRect(cb->direction, cb->rect, QRect(QPoint(ax, ay), cr.bottomRight())); 01949 } 01950 01951 case SC_ComboBoxEditField: { 01952 int fw = cb->frame ? pixelMetric(PM_ComboBoxFrameWidth, opt, widget) : 0; 01953 QRect rect = opt->rect; 01954 rect.adjust(fw, fw, -fw, -fw); 01955 int ew = get_combo_extra_width(rect.height(), rect.width()); 01956 rect.adjust(1, 1, -1-ew, -1); 01957 return visualRect(cb->direction, cb->rect, rect); 01958 } 01959 01960 default: 01961 break; 01962 } 01963 } 01964 break; 01965 #endif // QT_NO_SCROLLBAR 01966 default: 01967 break; 01968 } 01969 return QCommonStyle::subControlRect(cc, opt, sc, widget); 01970 }
Here is the call graph for this function:

| int QMotifStyle::pixelMetric | ( | PixelMetric | pm, | |
| const QStyleOption * | opt = 0, |
|||
| const QWidget * | widget = 0 | |||
| ) | const [virtual] |
Reimplemented from QCommonStyle.
Definition at line 1751 of file qmotifstyle.cpp.
References QApplication::globalStrut(), Qt::Horizontal, n, QCommonStyle::pixelMetric(), QStyle::PM_ButtonDefaultIndicator, QStyle::PM_ButtonShiftHorizontal, QStyle::PM_ButtonShiftVertical, QStyle::PM_DefaultFrameWidth, QStyle::PM_DockWidgetFrameWidth, QStyle::PM_DockWidgetHandleExtent, QStyle::PM_ExclusiveIndicatorHeight, QStyle::PM_ExclusiveIndicatorWidth, QStyle::PM_MenuBarHMargin, QStyle::PM_MenuButtonIndicator, QStyle::PM_ProgressBarChunkWidth, QStyle::PM_SliderControlThickness, QStyle::PM_SliderLength, QStyle::PM_SliderSpaceAvailable, QStyle::PM_SliderThickness, QStyle::PM_SplitterWidth, QStyle::PM_ToolBarFrameWidth, QStyle::PM_ToolBarItemMargin, qMax(), QSlider::TicksAbove, QSlider::TicksBelow, and width.
Referenced by drawComplexControl(), drawControl(), drawPrimitive(), QCDEStyle::pixelMetric(), NorwegianWoodStyle::pixelMetric(), subControlRect(), and subElementRect().
01753 { 01754 int ret = 0; 01755 01756 switch(pm) { 01757 case PM_ButtonDefaultIndicator: 01758 ret = 5; 01759 break; 01760 01761 case PM_ToolBarFrameWidth: 01762 ret = pixelMetric(PM_DefaultFrameWidth); 01763 break; 01764 01765 case PM_ToolBarItemMargin: 01766 ret = 1; 01767 break; 01768 01769 case PM_ButtonShiftHorizontal: 01770 case PM_ButtonShiftVertical: 01771 ret = 0; 01772 break; 01773 01774 case PM_SplitterWidth: 01775 ret = qMax(10, QApplication::globalStrut().width()); 01776 break; 01777 01778 case PM_SliderLength: 01779 ret = 30; 01780 break; 01781 01782 case PM_SliderThickness: 01783 ret = 16 + 4 * pixelMetric(PM_DefaultFrameWidth); 01784 break; 01785 #ifndef QT_NO_SLIDER 01786 case PM_SliderControlThickness: 01787 if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { 01788 int space = (sl->orientation == Qt::Horizontal) ? sl->rect.height() : sl->rect.width(); 01789 int ticks = sl->tickPosition; 01790 int n = 0; 01791 if (ticks & QSlider::TicksAbove) 01792 n++; 01793 if (ticks & QSlider::TicksBelow) 01794 n++; 01795 if (!n) { 01796 ret = space; 01797 break; 01798 } 01799 01800 int thick = 6; // Magic constant to get 5 + 16 + 5 01801 01802 space -= thick; 01803 //### the two sides may be unequal in size 01804 if (space > 0) 01805 thick += (space * 2) / (n + 2); 01806 ret = thick; 01807 } 01808 break; 01809 01810 case PM_SliderSpaceAvailable: 01811 if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { 01812 if (sl->orientation == Qt::Horizontal) 01813 ret = sl->rect.width() - pixelMetric(PM_SliderLength, opt, widget) - 2 * pixelMetric(PM_DefaultFrameWidth, opt, widget); 01814 else 01815 ret = sl->rect.height() - pixelMetric(PM_SliderLength, opt, widget) - 2 * pixelMetric(PM_DefaultFrameWidth, opt, widget); 01816 } 01817 break; 01818 #endif // QT_NO_SLIDER 01819 case PM_DockWidgetFrameWidth: 01820 ret = 2; 01821 break; 01822 01823 case PM_DockWidgetHandleExtent: 01824 ret = 9; 01825 break; 01826 01827 case PM_ProgressBarChunkWidth: 01828 ret = 1; 01829 break; 01830 01831 case PM_ExclusiveIndicatorWidth: 01832 case PM_ExclusiveIndicatorHeight: 01833 ret = 13; 01834 break; 01835 01836 case PM_MenuBarHMargin: 01837 ret = 2; // really ugly, but Motif 01838 break; 01839 01840 case PM_MenuButtonIndicator: 01841 if (!opt) 01842 ret = 12; 01843 else 01844 ret = qMax(12, (opt->rect.height() - 4) / 3); 01845 break; 01846 default: 01847 ret = QCommonStyle::pixelMetric(pm, opt, widget); 01848 break; 01849 } 01850 return ret; 01851 }
Here is the call graph for this function:

| QSize QMotifStyle::sizeFromContents | ( | ContentsType | ct, | |
| const QStyleOption * | opt, | |||
| const QSize & | contentsSize, | |||
| const QWidget * | widget = 0 | |||
| ) | const [virtual] |
Reimplemented from QCommonStyle.
Definition at line 1976 of file qmotifstyle.cpp.
References QStyleOptionButton::AutoDefaultButton, QStyle::CT_CheckBox, QStyle::CT_MenuBarItem, QStyle::CT_MenuItem, QStyle::CT_PushButton, QStyle::CT_RadioButton, QStyle::CT_Splitter, QStyleOptionButton::DefaultButton, h, QSize::height(), QSize::isEmpty(), motifArrowHMargin, motifCheckMarkHMargin, motifCheckMarkSpace, motifItemFrame, motifItemHMargin, motifItemVMargin, motifSepHeight, motifTabSpacing, qMax(), QSize::rwidth(), QStyleOptionMenuItem::Separator, QSize::setWidth(), QCommonStyle::sizeFromContents(), QStyleOptionMenuItem::SubMenu, w, and QSize::width().
01978 { 01979 QSize sz(contentsSize); 01980 01981 switch(ct) { 01982 case CT_Splitter: 01983 sz = QSize(10, 10); 01984 break; 01985 01986 case CT_RadioButton: 01987 case CT_CheckBox: 01988 sz = QCommonStyle::sizeFromContents(ct, opt, contentsSize, widget); 01989 sz.rwidth() += motifItemFrame; 01990 break; 01991 01992 case CT_PushButton: 01993 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { 01994 sz = QCommonStyle::sizeFromContents(ct, opt, contentsSize, widget); 01995 if (!btn->text.isEmpty() && (btn->features & (QStyleOptionButton::AutoDefaultButton|QStyleOptionButton::DefaultButton))) 01996 sz.setWidth(qMax(75, sz.width())); 01997 sz += QSize(0, 1); // magical extra pixel 01998 } 01999 break; 02000 02001 case CT_MenuBarItem: { 02002 if(!sz.isEmpty()) 02003 sz += QSize(5*motifItemHMargin+1, 2*motifItemVMargin + motifItemFrame); 02004 break; } 02005 02006 case CT_MenuItem: 02007 if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) { 02008 sz = QCommonStyle::sizeFromContents(ct, opt, sz, widget); 02009 int w = sz.width(), h = sz.height(); 02010 02011 if (mi->menuItemType == QStyleOptionMenuItem::Separator) { 02012 w = 10; 02013 h = (mi->text.isEmpty()) ? motifSepHeight : mi->fontMetrics.lineSpacing(); 02014 } 02015 02016 // a little bit of border can never harm 02017 w += 2*motifItemHMargin + 2*motifItemFrame; 02018 02019 if (!mi->text.isNull() && mi->text.indexOf(QLatin1Char('\t')) >= 0) 02020 // string contains tab 02021 w += motifTabSpacing; 02022 else if (mi->menuItemType == QStyleOptionMenuItem::SubMenu) 02023 // submenu indicator needs some room if we don't have a tab column 02024 w += motifArrowHMargin + 4*motifItemFrame; 02025 02026 int checkColumn = mi->maxIconWidth; 02027 if (mi->menuHasCheckableItems) 02028 checkColumn = qMax(checkColumn, motifCheckMarkSpace); 02029 if (checkColumn > 0) 02030 w += checkColumn + motifCheckMarkHMargin; 02031 02032 sz = QSize(w, h); 02033 } 02034 break; 02035 02036 02037 default: 02038 sz = QCommonStyle::sizeFromContents(ct, opt, contentsSize, widget); 02039 break; 02040 } 02041 02042 return sz; 02043 }
Here is the call graph for this function:

| QRect QMotifStyle::subElementRect | ( | SubElement | sr, | |
| const QStyleOption * | opt, | |||
| const QWidget * | widget = 0 | |||
| ) | const [virtual] |
Reimplemented from QCommonStyle.
Definition at line 2049 of file qmotifstyle.cpp.
References QRect::adjust(), Qt::AlignCenter, Qt::AlignLeft, QStyleOption::direction, get_combo_parameters(), motifItemFrame, pixelMetric(), QStyle::PM_DefaultFrameWidth, QStyleOption::rect, QRect::right(), QStyle::SE_CheckBoxClickRect, QStyle::SE_CheckBoxContents, QStyle::SE_CheckBoxIndicator, QStyle::SE_ComboBoxFocusRect, QStyle::SE_ProgressBarContents, QStyle::SE_ProgressBarGroove, QStyle::SE_ProgressBarLabel, QStyle::SE_Q3DockWindowHandleRect, QStyle::SE_RadioButtonClickRect, QStyle::SE_RadioButtonContents, QStyle::SE_RadioButtonIndicator, QStyle::SE_SliderFocusRect, QRect::setCoords(), QRect::setRect(), QStyle::State_Horizontal, QCommonStyle::subElementRect(), QStyle::visualRect(), and QRect::width().
Referenced by drawComplexControl(), and drawControl().
02050 { 02051 QRect rect; 02052 02053 switch (sr) { 02054 case SE_SliderFocusRect: 02055 rect = QCommonStyle::subElementRect(sr, opt, widget); 02056 rect.adjust(2, 2, -2, -2); 02057 break; 02058 02059 case SE_CheckBoxIndicator: 02060 case SE_RadioButtonIndicator: 02061 { 02062 rect = visualRect(opt->direction, opt->rect, 02063 QCommonStyle::subElementRect(sr, opt, widget)); 02064 rect.adjust(motifItemFrame,0, motifItemFrame,0); 02065 rect = visualRect(opt->direction, opt->rect, rect); 02066 } 02067 break; 02068 02069 case SE_ComboBoxFocusRect: 02070 { 02071 int awh, ax, ay, sh, sy, dh, ew; 02072 int fw = pixelMetric(PM_DefaultFrameWidth, opt, widget); 02073 QRect tr = opt->rect; 02074 02075 tr.adjust(fw, fw, -fw, -fw); 02076 get_combo_parameters(tr, ew, awh, ax, ay, sh, dh, sy); 02077 rect.setRect(ax-2, ay-2, awh+4, awh+sh+dh+4); 02078 break; 02079 } 02080 02081 case SE_Q3DockWindowHandleRect: 02082 if (const QStyleOptionQ3DockWindow *dw = qstyleoption_cast<const QStyleOptionQ3DockWindow *>(opt)) { 02083 if (!dw->docked || !dw->closeEnabled) 02084 rect.setRect(0, 0, opt->rect.width(), opt->rect.height()); 02085 else { 02086 if (dw->state == State_Horizontal) 02087 rect.setRect(2, 15, opt->rect.width()-2, opt->rect.height() - 15); 02088 else 02089 rect.setRect(0, 2, opt->rect.width() - 15, opt->rect.height() - 2); 02090 } 02091 rect = visualRect(dw->direction, dw->rect, rect); 02092 } 02093 break; 02094 02095 case SE_ProgressBarLabel: 02096 case SE_ProgressBarGroove: 02097 case SE_ProgressBarContents: 02098 if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) { 02099 int textw = 0; 02100 if (pb->textVisible) 02101 textw = pb->fontMetrics.width(QLatin1String("100%")) + 6; 02102 02103 if (pb->textAlignment == Qt::AlignLeft || pb->textAlignment == Qt::AlignCenter) { 02104 rect = opt->rect; 02105 } else { 02106 if(sr == SE_ProgressBarLabel) 02107 rect.setCoords(opt->rect.right() - textw, opt->rect.top(), 02108 opt->rect.right(), opt->rect.bottom()); 02109 else 02110 rect.setCoords(opt->rect.left(), opt->rect.top(), 02111 opt->rect.right() - textw, opt->rect.bottom()); 02112 } 02113 rect = visualRect(pb->direction, pb->rect, rect); 02114 } 02115 break; 02116 case SE_CheckBoxContents: 02117 case SE_RadioButtonContents: { 02118 QRect ir = visualRect(opt->direction, opt->rect, 02119 subElementRect(sr == SE_CheckBoxContents ? SE_CheckBoxIndicator 02120 : SE_RadioButtonIndicator, 02121 opt, widget)); 02122 rect.setRect(ir.right() + 10, opt->rect.y(), 02123 opt->rect.width() - ir.width() - 10, opt->rect.height()); 02124 rect = visualRect(opt->direction, opt->rect, rect); 02125 break; } 02126 case SE_CheckBoxClickRect: 02127 case SE_RadioButtonClickRect: 02128 rect = visualRect(opt->direction, opt->rect, opt->rect); 02129 break; 02130 02131 default: 02132 rect = QCommonStyle::subElementRect(sr, opt, widget); 02133 } 02134 return rect; 02135 }
Here is the call graph for this function:

| QPixmap QMotifStyle::standardPixmap | ( | StandardPixmap | standardPixmap, | |
| const QStyleOption * | opt, | |||
| const QWidget * | widget = 0 | |||
| ) | const [virtual] |
Reimplemented from QCommonStyle.
Definition at line 2474 of file qmotifstyle.cpp.
References QPalette::Active, QPalette::Base, QPalette::color(), QPalette::Dark, QPixmap::fromImage(), image, QApplication::palette(), QColor::rgb(), QStyle::SP_DockWidgetCloseButton, QStyle::SP_MessageBoxCritical, QStyle::SP_MessageBoxInformation, QStyle::SP_MessageBoxQuestion, QStyle::SP_MessageBoxWarning, QStyle::SP_TitleBarCloseButton, QStyle::SP_TitleBarMaxButton, QStyle::SP_TitleBarMenuButton, QStyle::SP_TitleBarMinButton, QStyle::SP_TitleBarNormalButton, QStyle::SP_TitleBarShadeButton, QStyle::SP_TitleBarUnshadeButton, QCommonStyle::standardPixmap(), and QPalette::Text.
02476 { 02477 #ifndef QT_NO_IMAGEFORMAT_XPM 02478 switch (standardPixmap) { 02479 case SP_TitleBarMenuButton: 02480 return QPixmap(qt_menu_xpm); 02481 case SP_TitleBarShadeButton: 02482 return QPixmap(qt_shade_xpm); 02483 case SP_TitleBarUnshadeButton: 02484 return QPixmap(qt_unshade_xpm); 02485 case SP_TitleBarNormalButton: 02486 return QPixmap(qt_normalizeup_xpm); 02487 case SP_TitleBarMinButton: 02488 return QPixmap(qt_minimize_xpm); 02489 case SP_TitleBarMaxButton: 02490 return QPixmap(qt_maximize_xpm); 02491 case SP_TitleBarCloseButton: 02492 return QPixmap(qt_close_xpm); 02493 case SP_DockWidgetCloseButton: 02494 return QPixmap(dock_window_close_xpm); 02495 02496 case SP_MessageBoxInformation: 02497 case SP_MessageBoxWarning: 02498 case SP_MessageBoxCritical: 02499 case SP_MessageBoxQuestion: 02500 { 02501 const char * const * xpm_data; 02502 switch (standardPixmap) { 02503 case SP_MessageBoxInformation: 02504 xpm_data = information_xpm; 02505 break; 02506 case SP_MessageBoxWarning: 02507 xpm_data = warning_xpm; 02508 break; 02509 case SP_MessageBoxCritical: 02510 xpm_data = critical_xpm; 02511 break; 02512 case SP_MessageBoxQuestion: 02513 xpm_data = question_xpm; 02514 break; 02515 default: 02516 xpm_data = 0; 02517 break; 02518 } 02519 QPixmap pm; 02520 if (xpm_data) { 02521 QImage image((const char **) xpm_data); 02522 // All that color looks ugly in Motif 02523 const QPalette &pal = QApplication::palette(); 02524 switch (standardPixmap) { 02525 case SP_MessageBoxInformation: 02526 case SP_MessageBoxQuestion: 02527 image.setColor(2, 0xff000000 | 02528 pal.color(QPalette::Active, QPalette::Dark).rgb()); 02529 image.setColor(3, 0xff000000 | 02530 pal.color(QPalette::Active, QPalette::Base).rgb()); 02531 image.setColor(4, 0xff000000 | 02532 pal.color(QPalette::Active, QPalette::Text).rgb()); 02533 break; 02534 case SP_MessageBoxWarning: 02535 image.setColor(1, 0xff000000 | 02536 pal.color(QPalette::Active, QPalette::Base).rgb()); 02537 image.setColor(2, 0xff000000 | 02538 pal.color(QPalette::Active, QPalette::Text).rgb()); 02539 image.setColor(3, 0xff000000 | 02540 pal.color(QPalette::Active, QPalette::Dark).rgb()); 02541 break; 02542 case SP_MessageBoxCritical: 02543 image.setColor(1, 0xff000000 | 02544 pal.color(QPalette::Active, QPalette::Dark).rgb()); 02545 image.setColor(2, 0xff000000 | 02546 pal.color(QPalette::Active, QPalette::Text).rgb()); 02547 image.setColor(3, 0xff000000 | 02548 pal.color(QPalette::Active, QPalette::Base).rgb()); 02549 break; 02550 default: 02551 break; 02552 } 02553 pm = QPixmap::fromImage(image); 02554 } 02555 return pm; 02556 } 02557 02558 default: 02559 break; 02560 } 02561 #endif 02562 02563 return QCommonStyle::standardPixmap(standardPixmap, opt, widget); 02564 }
Here is the call graph for this function:

| int QMotifStyle::styleHint | ( | StyleHint | hint, | |
| const QStyleOption * | opt = 0, |
|||
| const QWidget * | widget = 0, |
|||
| QStyleHintReturn * | returnData = 0 | |||
| ) | const [virtual] |
Reimplemented from QCommonStyle.
Definition at line 2588 of file qmotifstyle.cpp.
References Qt::AlignLeft, Qt::AlignVCenter, QDialogButtonBox::KdeLayout, QPalette::Mid, QStyle::SH_Dial_BackgroundRole, QStyle::SH_DialogButtonLayout, QStyle::SH_DitherDisabledText, QStyle::SH_DrawMenuBarSeparator, QStyle::SH_ItemView_ChangeHighlightOnFocus, QStyle::SH_Menu_SpaceActivatesItem, QStyle::SH_Menu_SubMenuPopupDelay, QStyle::SH_MenuBar_DismissOnSecondClick, QStyle::SH_MessageBox_UseBorderForButtonSpacing, QStyle::SH_ProgressDialog_CenterCancelButton, QStyle::SH_ProgressDialog_TextLabelAlignment, QStyle::SH_ScrollBar_MiddleClickAbsolutePosition, QStyle::SH_ScrollView_FrameOnlyAroundContents, QStyle::SH_Slider_SloppyKeyEvents, and QCommonStyle::styleHint().
Referenced by drawComplexControl(), drawControl(), drawPrimitive(), QCDEStyle::drawPrimitive(), and NorwegianWoodStyle::styleHint().
02590 { 02591 int ret; 02592 02593 switch (hint) { 02594 #ifdef QT3_SUPPORT 02595 case SH_GUIStyle: 02596 ret = Qt::MotifStyle; 02597 break; 02598 #endif 02599 case SH_DrawMenuBarSeparator: 02600 ret = true; 02601 break; 02602 02603 case SH_ScrollBar_MiddleClickAbsolutePosition: 02604 case SH_Slider_SloppyKeyEvents: 02605 case SH_ProgressDialog_CenterCancelButton: 02606 case SH_Menu_SpaceActivatesItem: 02607 case SH_ScrollView_FrameOnlyAroundContents: 02608 case SH_DitherDisabledText: 02609 ret = 1; 02610 break; 02611 02612 case SH_Menu_SubMenuPopupDelay: 02613 ret = 96; 02614 break; 02615 02616 case SH_ProgressDialog_TextLabelAlignment: 02617 ret = Qt::AlignLeft | Qt::AlignVCenter; 02618 break; 02619 02620 case SH_ItemView_ChangeHighlightOnFocus: 02621 ret = 0; 02622 break; 02623 02624 case SH_MenuBar_DismissOnSecondClick: 02625 ret = 0; 02626 break; 02627 02628 case SH_MessageBox_UseBorderForButtonSpacing: 02629 ret = 1; 02630 break; 02631 02632 case SH_Dial_BackgroundRole: 02633 ret = QPalette::Mid; 02634 break; 02635 02636 case SH_DialogButtonLayout: 02637 ret = QDialogButtonBox::KdeLayout; 02638 break; 02639 default: 02640 ret = QCommonStyle::styleHint(hint, opt, widget, returnData); 02641 break; 02642 } 02643 02644 return ret; 02645 }
Here is the call graph for this function:

| bool QMotifStyle::event | ( | QEvent * | e | ) | [virtual] |
Reimplemented from QObject.
Definition at line 2567 of file qmotifstyle.cpp.
References QObject::event(), focus, QEvent::FocusIn, QEvent::FocusOut, QApplication::focusWidget(), and QEvent::type().
Referenced by timerEvent().
02568 { 02569 if(e->type() == QEvent::FocusIn) { 02570 if (QWidget *focusWidget = QApplication::focusWidget()) { 02571 if(!focus) 02572 focus = new QFocusFrame(focusWidget); 02573 focus->setWidget(focusWidget); 02574 } else { 02575 if(focus) 02576 focus->setWidget(0); 02577 } 02578 } else if(e->type() == QEvent::FocusOut) { 02579 if(focus) 02580 focus->setWidget(0); 02581 } 02582 return QCommonStyle::event(e); 02583 }
Here is the call graph for this function:

| QPalette QMotifStyle::standardPalette | ( | ) | const [virtual] |
Reimplemented from QStyle.
Definition at line 2648 of file qmotifstyle.cpp.
References QX11Info::appDepth(), background, QPalette::Base, Qt::black, QPalette::ButtonText, QPalette::Disabled, palette, QPalette::Text, Qt::white, and QPalette::WindowText.
02649 { 02650 #ifdef Q_WS_X11 02651 QColor background(0xcf, 0xcf, 0xcf); 02652 if (QX11Info::appDepth() <= 8) 02653 background = QColor(0xc0, 0xc0, 0xc0); 02654 #else 02655 QColor background = QColor(0xcf, 0xcf, 0xcf); 02656 #endif 02657 02658 QColor light = background.light(); 02659 QColor mid = QColor(0xa6, 0xa6, 0xa6); 02660 QColor dark = QColor(0x79, 0x7d, 0x79); 02661 QPalette palette(Qt::black, background, light, dark, mid, Qt::black, Qt::white); 02662 palette.setBrush(QPalette::Disabled, QPalette::WindowText, dark); 02663 palette.setBrush(QPalette::Disabled, QPalette::Text, dark); 02664 palette.setBrush(QPalette::Disabled, QPalette::ButtonText, dark); 02665 palette.setBrush(QPalette::Disabled, QPalette::Base, background); 02666 return palette; 02667 }
Here is the call graph for this function:

| QIcon QMotifStyle::standardIconImplementation | ( | StandardPixmap | standardIcon, | |
| const QStyleOption * | opt = 0, |
|||
| const QWidget * | widget = 0 | |||
| ) | const [protected, slot] |
Reimplement this slot to provide your own icons in a QStyle subclass; because of binary compatibility constraints, the standardIcon() function (introduced in Qt 4.1) is not virtual. Instead, standardIcon() will dynamically detect and call this slot. The default implementation simply calls the standardPixmap() function with the given parameters.
The standardIcon is a standard pixmap which can follow some existing GUI style or guideline. The option argument can be used to pass extra information required when defining the appropriate icon. The widget argument is optional and can also be used to aid the determination of the icon.
Reimplemented from QCommonStyle.
Definition at line 166 of file qmotifstyle.cpp.
References QCommonStyle::standardIconImplementation().
Referenced by QCDEStyle::standardIconImplementation().
00168 { 00169 return QCommonStyle::standardIconImplementation(standardIcon, opt, widget); 00170 }
| void QMotifStyle::timerEvent | ( | QTimerEvent * | event | ) | [protected, virtual] |
Reimplemented from QObject.
Definition at line 175 of file qmotifstyle.cpp.
References d, event(), QProgressBar::maximum(), QProgressBar::minimum(), and QWidget::update().
00176 { 00177 #ifndef QT_NO_PROGRESSBAR 00178 Q_D(QMotifStyle); 00179 if (event->timerId() == d->animateTimer) { 00180 Q_ASSERT(d->animationFps > 0); 00181 d->animateStep = d->startTime.elapsed() / (1000 / d->animationFps); 00182 foreach (QProgressBar *bar, d->bars) { 00183 if ((bar->minimum() == 0 && bar->maximum() == 0)) 00184 bar->update(); 00185 } 00186 } 00187 #endif // QT_NO_PROGRESSBAR 00188 event->ignore(); 00189 }
Here is the call graph for this function:

Filters events if this object has been installed as an event filter for the watched object.
In your reimplementation of this function, if you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.
Example:
class MainWindow : public QMainWindow { public: MainWindow(); protected: bool eventFilter(QObject *obj, QEvent *ev); private: QTextEdit *textEdit; }; MainWindow::MainWindow() { textEdit = new QTextEdit; setCentralWidget(textEdit); textEdit->installEventFilter(this); } bool MainWindow::eventFilter(QObject *obj, QEvent *event) { if (obj == textEdit) { if (event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event); qDebug() << "Ate key press" << keyEvent->key(); return true; } else { return false; } } else { // pass the event on to the parent class return QMainWindow::eventFilter(obj, event); } }
Notice in the example above that unhandled events are passed to the base class's eventFilter() function, since the base class might have reimplemented eventFilter() for its own internal purposes.
Reimplemented from QObject.
Definition at line 130 of file qmotifstyle.cpp.
References d, QEvent::Destroy, QObject::eventFilter(), QEvent::Hide, QObject::killTimer(), o, QEvent::Show, QObject::startTimer(), QEvent::StyleChange, and QEvent::type().
00131 { 00132 #ifndef QT_NO_PROGRESSBAR 00133 Q_D(QMotifStyle); 00134 switch(e->type()) { 00135 case QEvent::StyleChange: 00136 case QEvent::Show: 00137 if (QProgressBar *bar = qobject_cast<QProgressBar *>(o)) { 00138 d->bars << bar; 00139 if (d->bars.size() == 1) { 00140 Q_ASSERT(d->animationFps> 0); 00141 d->animateTimer = startTimer(1000 / d->animationFps); 00142 } 00143 } 00144 break; 00145 case QEvent::Destroy: 00146 case QEvent::Hide: 00147 // reinterpret_cast because there is no type info when getting 00148 // the destroy event. We know that it is a QProgressBar. 00149 if (QProgressBar *bar = reinterpret_cast<QProgressBar *>(o)) { 00150 d->bars.removeAll(bar); 00151 if (d->bars.isEmpty() && d->animateTimer) { 00152 killTimer(d->animateTimer); 00153 d->animateTimer = 0; 00154 } 00155 } 00156 default: 00157 break; 00158 } 00159 #endif // QT_NO_PROGRESSBAR 00160 return QStyle::eventFilter(o, e); 00161 }
Here is the call graph for this function:

QPointer<QFocusFrame> QMotifStyle::focus [protected] |
Definition at line 90 of file qmotifstyle.h.
Referenced by drawComplexControl(), drawControl(), drawPrimitive(), event(), QMotifStyle(), and ~QMotifStyle().
bool QMotifStyle::highlightCols [private] |
Definition at line 99 of file qmotifstyle.h.
Referenced by polish(), QMotifStyle(), setUseHighlightColors(), and useHighlightColors().
1.5.1