#include <qcleanlooksstyle.h>
Inheritance diagram for QCleanlooksStyle:


Definition at line 36 of file qcleanlooksstyle.h.
Public Member Functions | |
| QCleanlooksStyle () | |
| ~QCleanlooksStyle () | |
| QPalette | standardPalette () const |
| void | drawPrimitive (PrimitiveElement elem, const QStyleOption *option, QPainter *painter, const QWidget *widget=0) const |
| void | drawControl (ControlElement ce, const QStyleOption *option, QPainter *painter, const QWidget *widget) const |
| int | pixelMetric (PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const |
| void | drawComplexControl (ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const |
| QRect | subElementRect (SubElement r, const QStyleOption *opt, const QWidget *widget=0) const |
| QSize | sizeFromContents (ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const |
| SubControl | hitTestComplexControl (ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *w=0) const |
| QRect | subControlRect (ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const |
| QPixmap | generatedIconPixmap (QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const |
| int | styleHint (StyleHint hint, const QStyleOption *option=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const |
| QRect | itemPixmapRect (const QRect &r, int flags, const QPixmap &pixmap) const |
| QPixmap | standardPixmap (StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget=0) const |
| void | drawItemPixmap (QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const |
| void | drawItemText (QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole=QPalette::NoRole) const |
| void | polish (QWidget *widget) |
| void | polish (QApplication *app) |
| void | polish (QPalette &pal) |
| void | unpolish (QWidget *widget) |
| void | unpolish (QApplication *app) |
Protected Slots | |
| QIcon | standardIconImplementation (StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget=0) const |
| QCleanlooksStyle::QCleanlooksStyle | ( | ) |
Constructs a QCleanlooksStyle object.
Definition at line 595 of file qcleanlooksstyle.cpp.
References QObject::setObjectName().
00595 : QWindowsStyle(*new QCleanlooksStylePrivate) 00596 { 00597 setObjectName(QLatin1String("CleanLooks")); 00598 }
Here is the call graph for this function:

| QCleanlooksStyle::~QCleanlooksStyle | ( | ) |
| QPalette QCleanlooksStyle::standardPalette | ( | ) | const [virtual] |
Reimplemented from QStyle.
Definition at line 2236 of file qcleanlooksstyle.cpp.
References QPalette::Active, QPalette::All, QPalette::Base, base, QPalette::Button, QColor::dark(), QPalette::Dark, QPalette::Disabled, QPalette::Highlight, QPalette::HighlightedText, QPalette::Inactive, QPalette::Light, QColor::light(), QPalette::Mid, QPalette::Midlight, palette, QRgb, QPalette::Shadow, QStyle::standardPalette(), QPalette::Text, Qt::white, and QPalette::Window.
02237 { 02238 QPalette palette = QWindowsStyle::standardPalette(); 02239 palette.setBrush(QPalette::Active, QPalette::Highlight, QColor(98, 140, 178)); 02240 palette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(145, 141, 126)); 02241 palette.setBrush(QPalette::Disabled, QPalette::Highlight, QColor(145, 141, 126)); 02242 02243 QColor backGround(239, 235, 231); 02244 02245 QColor light = backGround.light(150); 02246 QColor base = Qt::white; 02247 QColor dark = QColor(170, 156, 143).dark(110); 02248 dark = backGround.dark(150); 02249 QColor darkDisabled = QColor(209, 200, 191).dark(110); 02250 02251 //### Find the correct disabled text color 02252 palette.setBrush(QPalette::Disabled, QPalette::Text, QColor(190, 190, 190)); 02253 02254 palette.setBrush(QPalette::Window, backGround); 02255 palette.setBrush(QPalette::Mid, backGround.dark(130)); 02256 palette.setBrush(QPalette::Light, light); 02257 02258 palette.setBrush(QPalette::Active, QPalette::Base, base); 02259 palette.setBrush(QPalette::Inactive, QPalette::Base, base); 02260 palette.setBrush(QPalette::Disabled, QPalette::Base, backGround); 02261 02262 palette.setBrush(QPalette::Midlight, palette.mid().color().light(110)); 02263 02264 palette.setBrush(QPalette::All, QPalette::Dark, dark); 02265 palette.setBrush(QPalette::Disabled, QPalette::Dark, darkDisabled); 02266 02267 QColor button = backGround; 02268 02269 palette.setBrush(QPalette::Button, button); 02270 02271 QColor shadow = dark.dark(135); 02272 palette.setBrush(QPalette::Shadow, shadow); 02273 palette.setBrush(QPalette::Disabled, QPalette::Shadow, shadow.light(150)); 02274 palette.setBrush(QPalette::HighlightedText, QColor(QRgb(0xffffffff))); 02275 return palette; 02276 }
Here is the call graph for this function:

| void QCleanlooksStyle::drawPrimitive | ( | PrimitiveElement | elem, | |
| const QStyleOption * | option, | |||
| QPainter * | painter, | |||
| const QWidget * | widget = 0 | |||
| ) | const [virtual] |
Reimplemented from QWindowsStyle.
Definition at line 657 of file qcleanlooksstyle.cpp.
References QRect::adjust(), QRect::adjusted(), QPainter::Antialiasing, QPalette::background(), Qt::black, QRect::bottom(), QRect::bottomLeft(), QRect::bottomRight(), QPalette::button(), QStyle::CE_Splitter, QBrush::color(), QColor::dark(), QStyleOptionButton::DefaultButton, Qt::Dense4Pattern, drawControl(), QPainter::drawEllipse(), QPainter::drawImage(), QPainter::drawLine(), QPainter::drawPoint(), QWindowsStyle::drawPrimitive(), QPainter::drawRect(), QPainter::fillRect(), QStyleOptionButton::Flat, header(), QRect::height(), QColor::hue, i, image, QObject::inherits(), QImage::isNull(), QRect::left(), QColor::light(), mergedColors(), QRect::moveCenter(), Qt::NoPen, QLine::p1(), QLine::p2(), QStyleOption::palette, QStyle::PE_Frame, QStyle::PE_FrameDefaultButton, QStyle::PE_FrameDockWidget, QStyle::PE_FrameFocusRect, QStyle::PE_FrameLineEdit, QStyle::PE_FrameMenu, QStyle::PE_FrameTabBarBase, QStyle::PE_FrameTabWidget, QStyle::PE_FrameWindow, QStyle::PE_IndicatorButtonDropDown, QStyle::PE_IndicatorCheckBox, QStyle::PE_IndicatorDockWidgetResizeHandle, QStyle::PE_IndicatorHeaderArrow, QStyle::PE_IndicatorRadioButton, QStyle::PE_IndicatorToolBarHandle, QStyle::PE_IndicatorToolBarSeparator, QStyle::PE_IndicatorViewItemCheck, QStyle::PE_PanelButtonCommand, QStyle::PE_PanelButtonTool, QStyle::PE_Q3Separator, QPainter::pen(), pixelMetric(), QStyle::PM_TabBarBaseOverlap, qMin(), qt_cleanlooks_arrow_down_xpm, qt_cleanlooks_arrow_up_xpm, qt_cleanlooks_checkbox_checked, qt_cleanlooks_draw_gradient(), qt_cleanlooks_radiobutton, qt_cleanlooks_radiobutton_checked, QStyleOption::rect, QPainter::restore(), reverse(), QRect::right(), Qt::RightToLeft, QTabBar::RoundedEast, QTabBar::RoundedNorth, QTabBar::RoundedSouth, QTabBar::RoundedWest, QColor::saturation, QPainter::save(), QColor::setAlpha(), QPainter::setBackgroundMode(), QPainter::setBrush(), QPainter::setBrushOrigin(), QPainter::setClipRegion(), QImage::setColor(), QRect::setHeight(), QColor::setHsv(), QPainter::setPen(), QPainter::setRenderHint(), QRect::setSize(), QRect::setWidth(), QRect::setX(), QRect::setY(), QImage::size(), QStyleOptionHeader::SortDown, QStyleOptionHeader::SortUp, QStyleOption::state, QStyle::State_AutoRaise, QStyle::State_Enabled, QStyle::State_HasFocus, QStyle::State_Horizontal, QStyle::State_KeyboardFocusChange, QStyle::State_MouseOver, QStyle::State_NoChange, QStyle::State_On, QStyle::State_Sunken, QRect::top(), TopDown, QRect::topLeft(), QRect::topRight(), Qt::TransparentMode, QTabBar::TriangularEast, QTabBar::TriangularNorth, QTabBar::TriangularSouth, QTabBar::TriangularWest, QColor::value, Qt::white, QRect::width(), QPoint::x(), x, QPoint::y(), and y.
Referenced by drawComplexControl(), and drawControl().
00660 { 00661 Q_ASSERT(option); 00662 QRect rect = option->rect; 00663 int state = option->state; 00664 QColor button = option->palette.button().color(); 00665 QColor buttonShadow = option->palette.button().color().dark(110); 00666 QColor buttonShadowAlpha = buttonShadow; 00667 buttonShadowAlpha.setAlpha(128); 00668 QColor darkOutline; 00669 QColor dark; 00670 darkOutline.setHsv(button.hue(), 00671 qMin(255, (int)(button.saturation()*3.0)), 00672 qMin(255, (int)(button.value()*0.6))); 00673 dark.setHsv(button.hue(), 00674 qMin(255, (int)(button.saturation()*1.9)), 00675 qMin(255, (int)(button.value()*0.7))); 00676 QColor tabFrameColor = mergedColors(option->palette.background().color(), 00677 dark.light(135), 60); 00678 00679 switch(elem) { 00680 #ifndef QT_NO_TABBAR 00681 case PE_FrameTabBarBase: 00682 if (const QStyleOptionTabBarBase *tbb 00683 = qstyleoption_cast<const QStyleOptionTabBarBase *>(option)) { 00684 QRegion region(tbb->rect); 00685 painter->save(); 00686 painter->setPen(QPen(darkOutline.light(110), 0)); 00687 switch (tbb->shape) { 00688 case QTabBar::RoundedNorth: 00689 region -= tbb->selectedTabRect; 00690 painter->setClipRegion(region); 00691 painter->drawLine(tbb->rect.topLeft(), tbb->rect.topRight()); 00692 break; 00693 case QTabBar::RoundedWest: 00694 region -= tbb->selectedTabRect; 00695 painter->setClipRegion(region); 00696 painter->drawLine(tbb->rect.left(), tbb->rect.top(), tbb->rect.left(), tbb->rect.bottom()); 00697 break; 00698 case QTabBar::RoundedSouth: 00699 region -= tbb->selectedTabRect; 00700 painter->setClipRegion(region); 00701 painter->drawLine(tbb->rect.left(), tbb->rect.bottom(), 00702 tbb->rect.right(), tbb->rect.bottom()); 00703 break; 00704 case QTabBar::RoundedEast: 00705 region -= tbb->selectedTabRect; 00706 painter->setClipRegion(region); 00707 painter->drawLine(tbb->rect.topRight(), tbb->rect.bottomRight()); 00708 break; 00709 case QTabBar::TriangularNorth: 00710 case QTabBar::TriangularEast: 00711 case QTabBar::TriangularWest: 00712 case QTabBar::TriangularSouth: 00713 painter->restore(); 00714 QWindowsStyle::drawPrimitive(elem, option, painter, widget); 00715 return; 00716 } 00717 painter->restore(); 00718 } 00719 return; 00720 #endif // QT_NO_TABBAR 00721 case PE_IndicatorViewItemCheck: 00722 { 00723 QStyleOptionButton button; 00724 button.QStyleOption::operator=(*option); 00725 button.state &= ~State_MouseOver; 00726 drawPrimitive(PE_IndicatorCheckBox, &button, painter, widget); 00727 } 00728 return; 00729 case PE_IndicatorHeaderArrow: 00730 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { 00731 QRect r = header->rect; 00732 QImage arrow; 00733 if (header->sortIndicator & QStyleOptionHeader::SortUp) 00734 arrow = QImage(qt_cleanlooks_arrow_up_xpm); 00735 else if (header->sortIndicator & QStyleOptionHeader::SortDown) 00736 arrow = QImage(qt_cleanlooks_arrow_down_xpm); 00737 if (!arrow.isNull()) { 00738 r.setSize(arrow.size()); 00739 r.moveCenter(header->rect.center()); 00740 arrow.setColor(1, header->palette.foreground().color().rgba()); 00741 painter->drawImage(r, arrow); 00742 } 00743 } 00744 break; 00745 case PE_IndicatorButtonDropDown: 00746 drawPrimitive(PE_PanelButtonCommand, option, painter, widget); 00747 break; 00748 case PE_IndicatorToolBarSeparator: 00749 { 00750 QRect rect = option->rect; 00751 const int margin = 6; 00752 if (option->state & State_Horizontal) { 00753 const int offset = rect.width()/2; 00754 painter->setPen(QPen(option->palette.background().color().dark(110))); 00755 painter->drawLine(rect.bottomLeft().x() + offset, 00756 rect.bottomLeft().y() - margin, 00757 rect.topLeft().x() + offset, 00758 rect.topLeft().y() + margin); 00759 painter->setPen(QPen(option->palette.background().color().light(110))); 00760 painter->drawLine(rect.bottomLeft().x() + offset + 1, 00761 rect.bottomLeft().y() - margin, 00762 rect.topLeft().x() + offset + 1, 00763 rect.topLeft().y() + margin); 00764 } else { //Draw vertical separator 00765 const int offset = rect.height()/2; 00766 painter->setPen(QPen(option->palette.background().color().dark(110))); 00767 painter->drawLine(rect.topLeft().x() + margin , 00768 rect.topLeft().y() + offset, 00769 rect.topRight().x() - margin, 00770 rect.topRight().y() + offset); 00771 painter->setPen(QPen(option->palette.background().color().light(110))); 00772 painter->drawLine(rect.topLeft().x() + margin , 00773 rect.topLeft().y() + offset + 1, 00774 rect.topRight().x() - margin, 00775 rect.topRight().y() + offset + 1); 00776 } 00777 } 00778 break; 00779 case PE_Frame: 00780 painter->save(); 00781 painter->setPen(dark.light(108)); 00782 painter->drawRect(option->rect.adjusted(0, 0, -1, -1)); 00783 painter->restore(); 00784 break; 00785 case PE_FrameMenu: 00786 painter->save(); 00787 { 00788 painter->setPen(QPen(darkOutline, 1)); 00789 painter->drawRect(option->rect.adjusted(0, 0, -1, -1)); 00790 QColor frameLight = option->palette.background().color().light(160); 00791 QColor frameShadow = option->palette.background().color().dark(110); 00792 00793 //paint beveleffect 00794 QRect frame = option->rect.adjusted(1, 1, -1, -1); 00795 painter->setPen(frameLight); 00796 painter->drawLine(frame.topLeft(), frame.bottomLeft()); 00797 painter->drawLine(frame.topLeft(), frame.topRight()); 00798 00799 painter->setPen(frameShadow); 00800 painter->drawLine(frame.topRight(), frame.bottomRight()); 00801 painter->drawLine(frame.bottomLeft(), frame.bottomRight()); 00802 } 00803 painter->restore(); 00804 break; 00805 case PE_FrameDockWidget: 00806 00807 painter->save(); 00808 { 00809 QColor softshadow = option->palette.background().color().dark(120); 00810 00811 QRect rect= option->rect; 00812 painter->setPen(softshadow); 00813 painter->drawRect(option->rect.adjusted(0, 0, -1, -1)); 00814 painter->setPen(QPen(option->palette.light(), 0)); 00815 painter->drawLine(QPoint(rect.left() + 1, rect.top() + 1), QPoint(rect.left() + 1, rect.bottom() - 1)); 00816 painter->setPen(QPen(option->palette.background().color().dark(120), 0)); 00817 painter->drawLine(QPoint(rect.left() + 1, rect.bottom() - 1), QPoint(rect.right() - 2, rect.bottom() - 1)); 00818 painter->drawLine(QPoint(rect.right() - 1, rect.top() + 1), QPoint(rect.right() - 1, rect.bottom() - 1)); 00819 00820 } 00821 painter->restore(); 00822 break; 00823 case PE_PanelButtonTool: 00824 painter->save(); 00825 if ((option->state & State_Enabled) || !(option->state & State_AutoRaise)) { 00826 QRect rect = option->rect; 00827 QPen oldPen = painter->pen(); 00828 00829 if (widget && widget->inherits("QDockWidgetTitleButton")) { 00830 if (option->state & State_MouseOver) 00831 drawPrimitive(PE_PanelButtonCommand, option, painter, widget); 00832 } else { 00833 drawPrimitive(PE_PanelButtonCommand, option, painter, widget); 00834 } 00835 } 00836 painter->restore(); 00837 break; 00838 case PE_IndicatorDockWidgetResizeHandle: 00839 { 00840 QStyleOption dockWidgetHandle = *option; 00841 bool horizontal = option->state & State_Horizontal; 00842 if (horizontal) 00843 dockWidgetHandle.state &= ~State_Horizontal; 00844 else 00845 dockWidgetHandle.state |= State_Horizontal; 00846 drawControl(CE_Splitter, &dockWidgetHandle, painter, widget); 00847 } 00848 break; 00849 case PE_FrameWindow: 00850 painter->save(); 00851 { 00852 QRect rect= option->rect; 00853 painter->setPen(QPen(dark.dark(150), 0)); 00854 painter->drawRect(option->rect.adjusted(0, 0, -1, -1)); 00855 painter->setPen(QPen(option->palette.light(), 0)); 00856 painter->drawLine(QPoint(rect.left() + 1, rect.top() + 1), 00857 QPoint(rect.left() + 1, rect.bottom() - 1)); 00858 painter->setPen(QPen(option->palette.background().color().dark(120), 0)); 00859 painter->drawLine(QPoint(rect.left() + 1, rect.bottom() - 1), 00860 QPoint(rect.right() - 2, rect.bottom() - 1)); 00861 painter->drawLine(QPoint(rect.right() - 1, rect.top() + 1), 00862 QPoint(rect.right() - 1, rect.bottom() - 1)); 00863 } 00864 painter->restore(); 00865 break; 00866 #ifndef QT_NO_LINEDIT 00867 case PE_FrameLineEdit: 00868 // fall through 00869 #endif // QT_NO_LINEEDIT 00870 #ifdef QT3_SUPPORT 00871 if (widget && widget->inherits("Q3ToolBar")) { 00872 drawPrimitive(PE_Q3Separator, option, painter, widget); 00873 break; 00874 } 00875 #endif 00876 { 00877 QPen oldPen = painter->pen(); 00878 if (option->state & State_Enabled) { 00879 painter->setPen(QPen(option->palette.background(), 0)); 00880 painter->drawRect(rect.adjusted(0, 0, 0, 0)); 00881 painter->drawRect(rect.adjusted(1, 1, -1, -1)); 00882 } else { 00883 painter->fillRect(rect, option->palette.background()); 00884 } 00885 QRect r = rect.adjusted(0, 1, 0, -1); 00886 painter->setPen(buttonShadowAlpha); 00887 painter->drawLine(QPoint(r.left() + 2, r.top() - 1), QPoint(r.right() - 2, r.top() - 1)); 00888 painter->drawPoint(r.right() - 1, r.top()); 00889 painter->drawPoint(r.right(), r.top() + 1); 00890 painter->drawPoint(r.right() - 1, r.bottom()); 00891 painter->drawPoint(r.right(), r.bottom() - 1); 00892 painter->drawPoint(r.left() + 1, r.top() ); 00893 painter->drawPoint(r.left(), r.top() + 1); 00894 painter->drawPoint(r.left() + 1, r.bottom() ); 00895 painter->drawPoint(r.left(), r.bottom() - 1); 00896 painter->setPen(QPen(option->palette.background().color(), 1)); 00897 painter->drawLine(QPoint(r.left() + 2, r.top() + 1), QPoint(r.right() - 2, r.top() + 1)); 00898 00899 if (option->state & State_HasFocus) { 00900 QColor darkoutline = option->palette.highlight().color().dark(150); 00901 QColor innerline = mergedColors(option->palette.highlight().color(), Qt::white); 00902 painter->setPen(QPen(innerline, 0)); 00903 painter->drawRect(rect.adjusted(1, 2, -2, -3)); 00904 painter->setPen(QPen(darkoutline, 0)); 00905 } 00906 else { 00907 QColor highlight = Qt::white; 00908 highlight.setAlpha(130); 00909 painter->setPen(option->palette.base().color().dark(120)); 00910 painter->drawLine(QPoint(r.left() + 1, r.top() + 1), 00911 QPoint(r.right() - 1, r.top() + 1)); 00912 painter->drawLine(QPoint(r.left() + 1, r.top() + 1), 00913 QPoint(r.left() + 1, r.bottom() - 1)); 00914 painter->setPen(option->palette.base().color()); 00915 painter->drawLine(QPoint(r.right() - 1, r.top() + 1), 00916 QPoint(r.right() - 1, r.bottom() - 1)); 00917 painter->setPen(highlight); 00918 painter->drawLine(QPoint(r.left() + 1, r.bottom() + 1), 00919 QPoint(r.right() - 1, r.bottom() + 1)); 00920 painter->drawPoint(QPoint(r.left(), r.bottom())); 00921 painter->drawPoint(QPoint(r.right(), r.bottom() )); 00922 painter->setPen(QPen(darkOutline.light(115), 1)); 00923 } 00924 painter->drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2)); 00925 painter->drawLine(QPoint(r.right(), r.top() + 2), QPoint(r.right(), r.bottom() - 2)); 00926 painter->drawLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right() - 2, r.bottom())); 00927 painter->drawPoint(QPoint(r.right() - 1, r.bottom() - 1)); 00928 painter->drawPoint(QPoint(r.right() - 1, r.top() + 1)); 00929 painter->drawPoint(QPoint(r.left() + 1, r.bottom() - 1)); 00930 painter->drawPoint(QPoint(r.left() + 1, r.top() + 1)); 00931 painter->drawLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - 2, r.top())); 00932 painter->setPen(oldPen); 00933 } 00934 break; 00935 case PE_IndicatorCheckBox: 00936 painter->save(); 00937 if (const QStyleOptionButton *checkbox = qstyleoption_cast<const QStyleOptionButton*>(option)) { 00938 QRect checkRect; 00939 checkRect.setX(rect.left() ); 00940 checkRect.setY(rect.top() ); 00941 checkRect.setWidth(rect.width() - 1); 00942 checkRect.setHeight(rect.height() - 1); 00943 if (state & State_Sunken) 00944 painter->setBrush(dark.light(130)); 00945 else 00946 painter->setBrush(option->palette.base()); 00947 painter->setPen(QPen(dark.light(110), 0)); 00948 painter->drawRect(checkRect); 00949 if (checkbox->state & (State_On | State_Sunken | State_NoChange)) { 00950 QImage image(qt_cleanlooks_checkbox_checked); 00951 painter->drawImage(rect, image); 00952 if (checkbox->state & State_NoChange) { 00953 QColor bgc = option->palette.background().color(); 00954 bgc.setAlpha(127); 00955 painter->fillRect(checkRect.adjusted(1, 1, -1, -1), bgc); 00956 } 00957 } 00958 } 00959 painter->restore(); 00960 break; 00961 case PE_IndicatorRadioButton: 00962 painter->save(); 00963 { 00964 QRect checkRect = rect.adjusted(0, 0, 0, 0); 00965 if (state & (State_On )) { 00966 painter->drawImage(rect, QImage(qt_cleanlooks_radiobutton)); 00967 painter->drawImage(checkRect, QImage(qt_cleanlooks_radiobutton_checked)); 00968 } 00969 else if (state & State_Sunken) { 00970 painter->drawImage(rect, QImage(qt_cleanlooks_radiobutton)); 00971 QColor bgc = buttonShadow; 00972 painter->setRenderHint(QPainter::Antialiasing); 00973 painter->setBrush(bgc); 00974 painter->setPen(Qt::NoPen); 00975 painter->drawEllipse(rect.adjusted(1, 1, -1, -1)); } 00976 else { 00977 painter->drawImage(rect, QImage(qt_cleanlooks_radiobutton)); 00978 } 00979 } 00980 painter->restore(); 00981 break; 00982 case PE_IndicatorToolBarHandle: 00983 painter->save(); 00984 if (option->state & State_Horizontal) { 00985 for (int i = rect.height()/5; i <= 4*(rect.height()/5) ; ++i) { 00986 int y = rect.topLeft().y() + i + 1; 00987 int x1 = rect.topLeft().x() + 3; 00988 int x2 = rect.topRight().x() - 2; 00989 00990 if (i % 2 == 0) 00991 painter->setPen(QPen(option->palette.light(), 0)); 00992 else 00993 painter->setPen(QPen(dark.light(110), 0)); 00994 painter->drawLine(x1, y, x2, y); 00995 } 00996 } 00997 else { //vertical toolbar 00998 for (int i = rect.width()/5; i <= 4*(rect.width()/5) ; ++i) { 00999 int x = rect.topLeft().x() + i + 1; 01000 int y1 = rect.topLeft().y() + 3; 01001 int y2 = rect.topLeft().y() + 5; 01002 01003 if (i % 2 == 0) 01004 painter->setPen(QPen(option->palette.light(), 0)); 01005 else 01006 painter->setPen(QPen(dark.light(110), 0)); 01007 painter->drawLine(x, y1, x, y2); 01008 } 01009 } 01010 painter->restore(); 01011 break; 01012 case PE_FrameDefaultButton: 01013 case PE_FrameFocusRect: 01014 if (const QStyleOptionFocusRect *focusFrame = qstyleoption_cast<const QStyleOptionFocusRect *>(option)) { 01015 if (!(focusFrame->state & State_KeyboardFocusChange)) 01016 return; 01017 QRect rect = focusFrame->rect; 01018 painter->save(); 01019 painter->setBackgroundMode(Qt::TransparentMode); 01020 painter->setBrush(QBrush(dark.dark(120), Qt::Dense4Pattern)); 01021 painter->setBrushOrigin(rect.topLeft()); 01022 painter->setPen(Qt::NoPen); 01023 painter->drawRect(rect.left(), rect.top(), rect.width(), 1); // Top 01024 painter->drawRect(rect.left(), rect.bottom(), rect.width(), 1); // Bottom 01025 painter->drawRect(rect.left(), rect.top(), 1, rect.height()); // Left 01026 painter->drawRect(rect.right(), rect.top(), 1, rect.height()); // Right 01027 painter->restore(); 01028 } 01029 break; 01030 case PE_PanelButtonCommand: 01031 painter->save(); 01032 { 01033 bool down = (option->state & State_Sunken) || (option->state & State_On); 01034 01035 bool isDefault = false; 01036 QRect r = option->rect; 01037 r.adjust(0, 1, 0, -1); 01038 if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton*>(option)) { 01039 isDefault = (button->features & QStyleOptionButton::DefaultButton) &&(button->state & State_Enabled); 01040 if ((button->features & QStyleOptionButton::Flat) && !down) { 01041 if (isDefault) { 01042 painter->setPen(QPen(Qt::black, 0)); 01043 painter->drawLine(QPoint(r.left() + 2, r.top()), 01044 QPoint(r.right() - 2, r.top())); 01045 painter->drawLine(QPoint(r.left(), r.top() + 2), 01046 QPoint(r.left(), r.bottom() - 2)); 01047 painter->drawLine(QPoint(r.right(), r.top() + 2), 01048 QPoint(r.right(), r.bottom() - 2)); 01049 painter->drawLine(QPoint(r.left() + 2, r.bottom()), 01050 QPoint(r.right() - 2, r.bottom())); 01051 painter->drawPoint(QPoint(r.right() - 1, r.bottom() - 1)); 01052 painter->drawPoint(QPoint(r.right() - 1, r.top() + 1)); 01053 painter->drawPoint(QPoint(r.left() + 1, r.bottom() - 1)); 01054 painter->drawPoint(QPoint(r.left() + 1, r.top() + 1)); 01055 } 01056 painter->restore(); 01057 break; 01058 } 01059 } 01060 bool isEnabled = (option->state & State_Enabled); 01061 01062 QColor highlightedGradientStartColor = option->palette.button().color().light(107); 01063 QColor highlightedGradientStopColor = buttonShadow.light(107); 01064 QColor gradientStartColor = option->palette.button().color().light(108); 01065 01066 QColor buttonColor = option->palette.button().color(); 01067 QColor gradientStopColor; 01068 gradientStopColor.setHsv(buttonColor.hue(), 01069 qMin(255, (int)(buttonColor.saturation()*1.9)), 01070 qMin(255, (int)(buttonColor.value()*0.94))); 01071 01072 QRect gradRect = rect.adjusted(1, 1, -1, -1); 01073 if (isEnabled) { 01074 // gradient fill 01075 QRect innerBorder = r.adjusted(1, 1, -1, 0); 01076 01077 if (down) { 01078 painter->fillRect(gradRect, gradientStopColor.dark(110)); 01079 painter->setPen(gradientStopColor.dark(125)); 01080 painter->drawLine(innerBorder.topLeft(), innerBorder.topRight()); 01081 painter->drawLine(innerBorder.topLeft(), innerBorder.bottomLeft()); 01082 } else { 01083 if (option->state & State_Enabled && option->state & State_MouseOver ) { 01084 qt_cleanlooks_draw_gradient(painter, gradRect, 01085 highlightedGradientStartColor, 01086 highlightedGradientStopColor, TopDown, option->palette.button()); 01087 } else { 01088 qt_cleanlooks_draw_gradient(painter, gradRect, 01089 gradientStartColor, 01090 gradientStopColor, TopDown, option->palette.button()); 01091 } 01092 } 01093 } else { 01094 qt_cleanlooks_draw_gradient(painter, gradRect, 01095 gradientStartColor, 01096 gradientStopColor, TopDown, option->palette.button()); 01097 } 01098 01099 bool hasFocus = option->state & State_HasFocus; 01100 01101 if (!isEnabled) 01102 painter->setPen(QPen(dark.light(115))); 01103 else if (isDefault) 01104 painter->setPen(QPen(Qt::black, 1)); 01105 else 01106 painter->setPen(QPen(darkOutline, 1)); 01107 01108 painter->drawLine(QPoint(r.left(), r.top() + 2), 01109 QPoint(r.left(), r.bottom() - 2)); 01110 painter->drawLine(QPoint(r.right(), r.top() + 2), 01111 QPoint(r.right(), r.bottom() - 2)); 01112 painter->drawLine(QPoint(r.left() + 2, r.bottom()), 01113 QPoint(r.right() - 2, r.bottom())); 01114 painter->drawPoint(QPoint(r.right() - 1, r.bottom() - 1)); 01115 painter->drawPoint(QPoint(r.right() - 1, r.top() + 1)); 01116 painter->drawPoint(QPoint(r.left() + 1, r.bottom() - 1)); 01117 painter->drawPoint(QPoint(r.left() + 1, r.top() + 1)); 01118 01119 if (!isDefault && !hasFocus && isEnabled) 01120 painter->setPen(QPen(darkOutline.dark(110), 0)); 01121 01122 painter->drawLine(QPoint(r.left() + 2, r.top()), 01123 QPoint(r.right() - 2, r.top())); 01124 01125 QColor highlight = Qt::white; 01126 highlight.setAlpha(130); 01127 painter->setPen(highlight); 01128 painter->drawLine(QPoint(r.left() + 1, r.bottom() + 1), 01129 QPoint(r.right() - 1, r.bottom() + 1)); 01130 painter->drawLine(QPoint(r.left() + 1, r.top() + 2), 01131 QPoint(r.left() + 1, r.bottom() - 2)); 01132 painter->drawPoint(QPoint(r.left(), r.bottom())); 01133 painter->drawPoint(QPoint(r.right(), r.bottom() )); 01134 01135 painter->setPen(buttonShadowAlpha.dark(130)); 01136 painter->drawPoint(QPoint(r.right(), r.top() + 1)); 01137 painter->drawPoint(QPoint(r.right() - 1, r.top() )); 01138 painter->drawPoint(QPoint(r.right(), r.bottom() - 1)); 01139 painter->drawPoint(QPoint(r.right() - 1, r.bottom() )); 01140 painter->drawPoint(QPoint(r.left() + 1, r.bottom())); 01141 painter->drawPoint(QPoint(r.left(), r.bottom() - 1)); 01142 painter->drawPoint(QPoint(r.left() + 1, r.top())); 01143 painter->drawPoint(QPoint(r.left(), r.top() + 1)); 01144 painter->setPen(buttonShadowAlpha); 01145 painter->drawLine(QPoint(r.right() - 1, r.top() + 2), 01146 QPoint(r.right() - 1, r.bottom() - 2)); 01147 painter->drawLine(QPoint(r.left() + 2, r.top() - 1), 01148 QPoint(r.right() - 2, r.top() - 1)); 01149 01150 if (isDefault) { 01151 r.adjust(-1, -1, 1, 1); 01152 painter->setPen(buttonShadowAlpha.dark(120)); 01153 painter->drawLine(r.topLeft() + QPoint(3, 0), r.topRight() - QPoint(3, 0)); 01154 painter->drawLine(r.bottomLeft() + QPoint(3, 0), r.bottomRight() - QPoint(3, 0)); 01155 painter->drawLine(r.topLeft() + QPoint(0, 3), r.bottomLeft() - QPoint(0, 3)); 01156 painter->drawLine(r.topRight() + QPoint(0, 3), r.bottomRight() - QPoint(0, 3)); 01157 painter->drawPoint(r.topRight() + QPoint(-2, 1)); 01158 painter->drawPoint(r.topRight() + QPoint(-1, 2)); 01159 painter->drawPoint(r.bottomRight() + QPoint(-1, -2)); 01160 painter->drawPoint(r.bottomRight() + QPoint(-2, -1)); 01161 painter->drawPoint(r.topLeft() + QPoint(1, 2)); 01162 painter->drawPoint(r.topLeft() + QPoint(2, 1)); 01163 painter->drawPoint(r.bottomLeft() + QPoint(1, -2)); 01164 painter->drawPoint(r.bottomLeft() + QPoint(2, -1)); 01165 } 01166 } 01167 painter->restore(); 01168 break; 01169 #ifndef QT_NO_TABBAR 01170 case PE_FrameTabWidget: 01171 painter->save(); 01172 { 01173 painter->fillRect(option->rect, tabFrameColor); 01174 } 01175 #ifndef QT_NO_TABWIDGET 01176 if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(option)) { 01177 QColor borderColor = darkOutline.light(110); 01178 QColor alphaCornerColor = mergedColors(borderColor, option->palette.background().color()); 01179 QColor innerShadow = mergedColors(borderColor, option->palette.base().color()); 01180 01181 int borderThickness = pixelMetric(PM_TabBarBaseOverlap, twf, widget); 01182 bool reverse = (twf->direction == Qt::RightToLeft); 01183 QRect tabBarRect; 01184 01185 switch (twf->shape) { 01186 case QTabBar::RoundedNorth: 01187 if (reverse) { 01188 tabBarRect = QRect(twf->rect.right() - twf->leftCornerWidgetSize.width() 01189 - twf->tabBarSize.width() + 1, 01190 twf->rect.top(), 01191 twf->tabBarSize.width(), borderThickness); 01192 } else { 01193 tabBarRect = QRect(twf->rect.left() + twf->leftCornerWidgetSize.width(), 01194 twf->rect.top(), 01195 twf->tabBarSize.width(), borderThickness); 01196 } 01197 break ; 01198 case QTabBar::RoundedWest: 01199 tabBarRect = QRect(twf->rect.left(), 01200 twf->rect.top() + twf->leftCornerWidgetSize.height(), 01201 borderThickness, 01202 twf->tabBarSize.height()); 01203 tabBarRect = tabBarRect; //adjust 01204 break ; 01205 case QTabBar::RoundedEast: 01206 tabBarRect = QRect(twf->rect.right() - borderThickness + 1, 01207 twf->rect.top() + twf->leftCornerWidgetSize.height(), 01208 0, 01209 twf->tabBarSize.height()); 01210 break ; 01211 case QTabBar::RoundedSouth: 01212 if (reverse) { 01213 tabBarRect = QRect(twf->rect.right() - twf->leftCornerWidgetSize.width() - twf->tabBarSize.width() + 1, 01214 twf->rect.bottom() + 1, 01215 twf->tabBarSize.width(), 01216 borderThickness); 01217 } else { 01218 tabBarRect = QRect(twf->rect.left() + twf->leftCornerWidgetSize.width(), 01219 twf->rect.bottom() + 1, 01220 twf->tabBarSize.width(), 01221 borderThickness); 01222 } 01223 break; 01224 default: 01225 break; 01226 } 01227 01228 QRegion region(twf->rect); 01229 region -= tabBarRect; 01230 painter->setClipRegion(region); 01231 01232 // Outer border 01233 QLine leftLine = QLine(twf->rect.topLeft() + QPoint(0, 2), twf->rect.bottomLeft() - QPoint(0, 2)); 01234 QLine rightLine = QLine(twf->rect.topRight(), twf->rect.bottomRight() - QPoint(0, 2)); 01235 QLine bottomLine = QLine(twf->rect.bottomLeft() + QPoint(2, 0), twf->rect.bottomRight() - QPoint(2, 0)); 01236 QLine topLine = QLine(twf->rect.topLeft(), twf->rect.topRight()); 01237 01238 painter->setPen(borderColor); 01239 painter->drawLine(topLine); 01240 01241 // Inner border 01242 QLine innerLeftLine = QLine(leftLine.p1() + QPoint(1, 0), leftLine.p2() + QPoint(1, 0)); 01243 QLine innerRightLine = QLine(rightLine.p1() - QPoint(1, -1), rightLine.p2() - QPoint(1, 0)); 01244 QLine innerBottomLine = QLine(bottomLine.p1() - QPoint(0, 1), bottomLine.p2() - QPoint(0, 1)); 01245 QLine innerTopLine = QLine(topLine.p1() + QPoint(0, 1), topLine.p2() + QPoint(-1, 1)); 01246 01247 // Rounded Corner 01248 QPoint leftBottomOuterCorner = QPoint(innerLeftLine.p2() + QPoint(0, 1)); 01249 QPoint leftBottomInnerCorner1 = QPoint(leftLine.p2() + QPoint(0, 1)); 01250 QPoint leftBottomInnerCorner2 = QPoint(bottomLine.p1() - QPoint(1, 0)); 01251 QPoint rightBottomOuterCorner = QPoint(innerRightLine.p2() + QPoint(0, 1)); 01252 QPoint rightBottomInnerCorner1 = QPoint(rightLine.p2() + QPoint(0, 1)); 01253 QPoint rightBottomInnerCorner2 = QPoint(bottomLine.p2() + QPoint(1, 0)); 01254 QPoint leftTopOuterCorner = QPoint(innerLeftLine.p1() - QPoint(0, 1)); 01255 QPoint leftTopInnerCorner1 = QPoint(leftLine.p1() - QPoint(0, 1)); 01256 QPoint leftTopInnerCorner2 = QPoint(topLine.p1() - QPoint(1, 0)); 01257 01258 painter->setPen(borderColor); 01259 painter->drawLine(leftLine); 01260 painter->drawLine(rightLine); 01261 painter->drawLine(bottomLine); 01262 painter->drawPoint(leftBottomOuterCorner); 01263 painter->drawPoint(rightBottomOuterCorner); 01264 painter->drawPoint(leftTopOuterCorner); 01265 01266 painter->setPen(option->palette.light().color()); 01267 painter->drawLine(innerLeftLine); 01268 painter->drawLine(innerTopLine); 01269 01270 painter->setPen(buttonShadowAlpha); 01271 painter->drawLine(innerRightLine); 01272 painter->drawLine(innerBottomLine); 01273 01274 painter->setPen(alphaCornerColor); 01275 painter->drawPoint(leftBottomInnerCorner1); 01276 painter->drawPoint(leftBottomInnerCorner2); 01277 painter->drawPoint(rightBottomInnerCorner1); 01278 painter->drawPoint(rightBottomInnerCorner2); 01279 painter->drawPoint(leftTopInnerCorner1); 01280 painter->drawPoint(leftTopInnerCorner2); 01281 } 01282 #endif // QT_NO_TABWIDGET 01283 painter->restore(); 01284 break ; 01285 #endif // QT_NO_TABBAR 01286 default: 01287 QWindowsStyle::drawPrimitive(elem, option, painter, widget); 01288 break; 01289 } 01290 }
Here is the call graph for this function:

| void QCleanlooksStyle::drawControl | ( | ControlElement | element, | |
| const QStyleOption * | option, | |||
| QPainter * | painter, | |||
| const QWidget * | widget | |||
| ) | const [virtual] |
Reimplemented from QWindowsStyle.
Definition at line 1295 of file qcleanlooksstyle.cpp.
References QIcon::Active, QRect::adjusted(), Qt::AlignCenter, Qt::AlignHCenter, Qt::AlignLeft, Qt::AlignRight, Qt::AlignVCenter, QPainter::Antialiasing, background, QPalette::background(), QWidget::backgroundRole(), QStyleOptionTab::Beginning, QStyleOptionToolBar::Beginning, QRect::bottom(), QRect::bottomLeft(), QRect::bottomRight(), Qt::BottomToolBarArea, QPalette::button(), QPalette::ButtonText, QStyle::CE_CheckBox, QStyle::CE_DockWidgetTitle, QStyle::CE_HeaderSection, QStyle::CE_MenuBarEmptyArea, QStyle::CE_MenuBarItem, QStyle::CE_MenuEmptyArea, QStyle::CE_MenuHMargin, QStyle::CE_MenuItem, QStyle::CE_MenuVMargin, QStyle::CE_ProgressBarContents, QStyle::CE_ProgressBarGroove, QStyle::CE_PushButtonLabel, QStyle::CE_RadioButton, QStyle::CE_SizeGrip, QStyle::CE_Splitter, QStyle::CE_TabBarTabShape, QStyle::CE_ToolBar, QRect::center(), QBrush::color(), TokenEngine::copy(), QColor::dark(), QStyleOptionMenuItem::DefaultItem, QFontMetrics::descent(), QStyleOption::direction, QIcon::Disabled, QWindowsStyle::drawControl(), QCommonStyle::drawControl(), QPainter::drawEllipse(), QPainter::drawImage(), drawItemText(), QPainter::drawLine(), QPainter::drawPixmap(), QPainter::drawPoint(), drawPrimitive(), QPainter::drawRect(), QStyleOptionToolBar::End, QStyleOptionTab::End, QStyleOptionHeader::End, QStyleOptionMenuItem::Exclusive, QPixmap::fill(), QPainter::fillRect(), QPixmapCache::find(), QStyleOptionMenuItem::font, QPainter::fontMetrics(), QRect::getRect(), h, header(), QPixmap::height(), QRect::height(), QPalette::highlight(), QPalette::Highlight, QPalette::highlightedText(), QPalette::HighlightedText, QColor::hue, i, image, QPixmapCache::insert(), QApplication::isRightToLeft(), QApplication::layoutDirection(), QRect::left(), QStyleOptionTab::LeftCornerWidget, Qt::LeftToolBarArea, QColor::light(), QPalette::light(), m, QStyleOptionMenuItem::menuItemType, mergedColors(), QRect::moveCenter(), QStyleOptionTab::NextIsSelected, Qt::NoPen, QPalette::Normal, QIcon::Normal, QStyleOptionMenuItem::NotCheckable, QString::number(), QIcon::Off, QIcon::On, QStyleOptionToolBar::OnlyOne, QStyleOptionTab::OnlyOneTab, p, palette, QStyleOption::palette, QWidget::parentWidget(), QStyle::PE_IndicatorArrowLeft, QStyle::PE_IndicatorArrowRight, QPainter::pen(), pixelMetric(), QStyle::PM_SmallIconSize, QStyle::PM_TabBarBaseOverlap, QStyleOptionTab::PreviousIsSelected, qMax(), qMin(), qt_cleanlooks_draw_gradient(), qt_cleanlooks_menuitem_checkbox_checked, QStyleOption::rect, QPainter::restore(), reverse(), QRect::right(), Qt::RightToLeft, Qt::RightToolBarArea, QMatrix::rotate(), QTabBar::RoundedEast, QTabBar::RoundedNorth, QTabBar::RoundedSouth, QTabBar::RoundedWest, s, QColor::saturation, QPainter::save(), QMatrix::scale(), QStyleOptionMenuItem::Separator, QFont::setBold(), QPainter::setBrush(), QPainter::setClipRect(), QPalette::setColor(), QGradient::setColorAt(), QPainter::setFont(), QColor::setHsv(), QPainter::setMatrix(), QPainter::setPen(), QRect::setRect(), QPainter::setRenderHint(), QGradient::setStops(), QStyle::SH_TabBar_Alignment, QStyle::SH_UnderlineShortcut, QRect::size(), QStyleOption::state, QStyle::State_Enabled, QStyle::State_HasFocus, QStyle::State_Horizontal, QStyle::State_MouseOver, QStyle::State_None, QStyle::State_On, QStyle::State_Selected, QStyle::State_Sunken, styleHint(), QStyleOptionMenuItem::SubMenu, t, QStyleOptionMenuItem::tabWidth, QPalette::text(), QStyleOptionMenuItem::text, QPalette::Text, Qt::TextDontClip, Qt::TextHideMnemonic, Qt::TextShowMnemonic, Qt::TextSingleLine, QRect::top(), TopDown, QRect::topLeft(), QRect::topRight(), Qt::TopToolBarArea, QRect::translate(), QMatrix::translate(), QPainter::translate(), Qt::transparent, uniqueName(), UsePixmapCache, QColor::value, Qt::Vertical, QStyle::visualPos(), QStyle::visualRect(), w, QRect::width(), QPixmap::width(), width, windowsItemFrame, windowsItemHMargin, windowsItemVMargin, windowsRightBorder, QPalette::WindowText, QRect::x(), QPoint::x(), x, QRect::y(), QPoint::y(), and y.
Referenced by drawPrimitive().
01297 { 01298 QColor button = option->palette.button().color(); 01299 QColor dark; 01300 dark.setHsv(button.hue(), 01301 qMin(255, (int)(button.saturation()*1.9)), 01302 qMin(255, (int)(button.value()*0.7))); 01303 QColor darkOutline; 01304 darkOutline.setHsv(button.hue(), 01305 qMin(255, (int)(button.saturation()*2.0)), 01306 qMin(255, (int)(button.value()*0.6))); 01307 QRect rect = option->rect; 01308 QColor shadow = mergedColors(option->palette.background().color().dark(120), 01309 dark.light(130), 60); 01310 QColor tabFrameColor = mergedColors(option->palette.background().color(), 01311 dark.light(135), 60); 01312 01313 QColor highlight = option->palette.highlight().color(); 01314 QColor highlightText = option->palette.highlightedText().color(); 01315 01316 switch(element) { 01317 case CE_RadioButton: //fall through 01318 case CE_CheckBox: 01319 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) { 01320 bool hover = (btn->state & State_MouseOver && btn->state & State_Enabled); 01321 if (hover) 01322 painter->fillRect(rect, btn->palette.background().color().light(104)); 01323 QStyleOptionButton copy = *btn; 01324 copy.rect.adjust(2, 0, -2, 0); 01325 QWindowsStyle::drawControl(element, ©, painter, widget); 01326 } 01327 break; 01328 case CE_Splitter: 01329 painter->save(); 01330 { 01331 // hover appearance 01332 QBrush fillColor = option->palette.background().color(); 01333 if (option->state & State_MouseOver && option->state & State_Enabled) 01334 fillColor = fillColor.color().light(106); 01335 01336 painter->fillRect(option->rect, fillColor); 01337 01338 QColor grooveColor = mergedColors(dark.light(110), option->palette.button().color(),40); 01339 QColor gripShadow = grooveColor.dark(110); 01340 QPalette palette = option->palette; 01341 bool vertical = !(option->state & State_Horizontal); 01342 QRect scrollBarSlider = option->rect; 01343 int gripMargin = 4; 01344 //draw grips 01345 if (vertical) { 01346 for( int i = -20; i< 20 ; i += 2) { 01347 painter->setPen(QPen(gripShadow, 1)); 01348 painter->drawLine( 01349 QPoint(scrollBarSlider.center().x() + i , 01350 scrollBarSlider.top() + gripMargin), 01351 QPoint(scrollBarSlider.center().x() + i, 01352 scrollBarSlider.bottom() - gripMargin)); 01353 painter->setPen(QPen(palette.light(), 1)); 01354 painter->drawLine( 01355 QPoint(scrollBarSlider.center().x() + i + 1, 01356 scrollBarSlider.top() + gripMargin ), 01357 QPoint(scrollBarSlider.center().x() + i + 1, 01358 scrollBarSlider.bottom() - gripMargin)); 01359 } 01360 } else { 01361 for (int i = -20; i < 20 ; i += 2) { 01362 painter->setPen(QPen(gripShadow, 1)); 01363 painter->drawLine( 01364 QPoint(scrollBarSlider.left() + gripMargin , 01365 scrollBarSlider.center().y()+ i), 01366 QPoint(scrollBarSlider.right() - gripMargin, 01367 scrollBarSlider.center().y()+ i)); 01368 painter->setPen(QPen(palette.light(), 1)); 01369 painter->drawLine( 01370 QPoint(scrollBarSlider.left() + gripMargin, 01371 scrollBarSlider.center().y() + 1 + i), 01372 QPoint(scrollBarSlider.right() - gripMargin, 01373 scrollBarSlider.center().y() + 1 + i)); 01374 01375 } 01376 } 01377 } 01378 painter->restore(); 01379 break; 01380 #ifndef QT_NO_SIZEGRIP 01381 case CE_SizeGrip: 01382 painter->save(); 01383 { 01384 int x, y, w, h; 01385 option->rect.getRect(&x, &y, &w, &h); 01386 int sw = qMin(h, w); 01387 if (h > w) 01388 painter->translate(0, h - w); 01389 else 01390 painter->translate(w - h, 0); 01391 01392 int sx = x; 01393 int sy = y; 01394 int s = 4; 01395 if (option->direction == Qt::RightToLeft) { 01396 sx = x + sw; 01397 for (int i = 0; i < 4; ++i) { 01398 painter->setPen(QPen(option->palette.light().color(), 1)); 01399 painter->drawLine(x, sy - 1 , sx + 1, sw); 01400 painter->setPen(QPen(dark.light(120), 1)); 01401 painter->drawLine(x, sy, sx, sw); 01402 sx -= s; 01403 sy += s; 01404 } 01405 } else { 01406 for (int i = 0; i < 4; ++i) { 01407 painter->setPen(QPen(option->palette.light().color(), 1)); 01408 painter->drawLine(sx - 1, sw, sw, sy - 1); 01409 painter->setPen(QPen(dark.light(120), 1)); 01410 painter->drawLine(sx, sw, sw, sy); 01411 sx += s; 01412 sy += s; 01413 } 01414 } 01415 } 01416 painter->restore(); 01417 break; 01418 #endif // QT_NO_SIZEGRIP 01419 #ifndef QT_NO_TOOLBAR 01420 case CE_ToolBar: 01421 painter->save(); 01422 if (const QStyleOptionToolBar *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(option)) { 01423 QRect rect = option->rect; 01424 01425 bool paintLeftBorder = true; 01426 bool paintRightBorder = true; 01427 bool paintBottomBorder = true; 01428 01429 switch (toolbar->toolBarArea) { 01430 case Qt::BottomToolBarArea: 01431 switch(toolbar->positionOfLine) { 01432 case QStyleOptionToolBar::Beginning: 01433 case QStyleOptionToolBar::OnlyOne: 01434 paintBottomBorder = false; 01435 default: 01436 break; 01437 } 01438 case Qt::TopToolBarArea: 01439 switch (toolbar->positionWithinLine) { 01440 case QStyleOptionToolBar::Beginning: 01441 paintLeftBorder = false; 01442 break; 01443 case QStyleOptionToolBar::End: 01444 paintRightBorder = false; 01445 break; 01446 case QStyleOptionToolBar::OnlyOne: 01447 paintRightBorder = false; 01448 paintLeftBorder = false; 01449 default: 01450 break; 01451 } 01452 if (QApplication::layoutDirection() == Qt::RightToLeft) { //reverse layout changes the order of Beginning/end 01453 bool tmp = paintLeftBorder; 01454 paintRightBorder=paintLeftBorder; 01455 paintLeftBorder=tmp; 01456 } 01457 break; 01458 case Qt::RightToolBarArea: 01459 switch (toolbar->positionOfLine) { 01460 case QStyleOptionToolBar::Beginning: 01461 case QStyleOptionToolBar::OnlyOne: 01462 paintRightBorder = false; 01463 break; 01464 default: 01465 break; 01466 } 01467 break; 01468 case Qt::LeftToolBarArea: 01469 switch (toolbar->positionOfLine) { 01470 case QStyleOptionToolBar::Beginning: 01471 case QStyleOptionToolBar::OnlyOne: 01472 paintLeftBorder = false; 01473 break; 01474 default: 01475 break; 01476 } 01477 break; 01478 default: 01479 break; 01480 } 01481 01482 QColor light = option->palette.background().color().light(110); 01483 01484 //draw top border 01485 painter->setPen(QPen(light)); 01486 painter->drawLine(rect.topLeft().x(), 01487 rect.topLeft().y(), 01488 rect.topRight().x(), 01489 rect.topRight().y()); 01490 01491 if (paintLeftBorder) { 01492 painter->setPen(QPen(light)); 01493 painter->drawLine(rect.topLeft().x(), 01494 rect.topLeft().y(), 01495 rect.bottomLeft().x(), 01496 rect.bottomLeft().y()); 01497 } 01498 01499 if (paintRightBorder) { 01500 painter->setPen(QPen(shadow)); 01501 painter->drawLine(rect.topRight().x(), 01502 rect.topRight().y(), 01503 rect.bottomRight().x(), 01504 rect.bottomRight().y()); 01505 } 01506 01507 if (paintBottomBorder) { 01508 painter->setPen(QPen(shadow)); 01509 painter->drawLine(rect.bottomLeft().x(), 01510 rect.bottomLeft().y(), 01511 rect.bottomRight().x(), 01512 rect.bottomRight().y()); 01513 } 01514 } 01515 painter->restore(); 01516 break; 01517 #endif // QT_NO_TOOLBAR 01518 #ifndef QT_NO_DOCKWIDGET 01519 case CE_DockWidgetTitle: 01520 painter->save(); 01521 if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(option)) { 01522 QRect r = dwOpt->rect.adjusted(0, 0, -1, 0); 01523 painter->setPen(option->palette.light().color()); 01524 painter->drawRect(r.adjusted(1, 1, 1, 1)); 01525 painter->setPen(shadow); 01526 painter->drawRect(r); 01527 01528 if (!dwOpt->title.isEmpty()) { 01529 const int indent = painter->fontMetrics().descent() + 2; 01530 drawItemText(painter, r.adjusted(indent + 1, 0, - indent - 1, -1), 01531 Qt::AlignLeft | Qt::AlignVCenter, dwOpt->palette, 01532 dwOpt->state & State_Enabled, dwOpt->title, 01533 QPalette::WindowText); 01534 } 01535 } 01536 painter->restore(); 01537 break; 01538 #endif // QT_NO_DOCKWIDGET 01539 case CE_HeaderSection: 01540 painter->save(); 01541 // Draws the header in tables. 01542 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { 01543 QPixmap cache; 01544 QString pixmapName = uniqueName(QLatin1String("headersection"), option, option->rect.size()); 01545 pixmapName += QLatin1String("-") + QString::number(int(header->position)); 01546 pixmapName += QLatin1String("-") + QString::number(int(header->orientation)); 01547 QRect r = option->rect; 01548 QColor gradientStopColor; 01549 QColor gradientStartColor = option->palette.button().color(); 01550 gradientStopColor.setHsv(gradientStartColor.hue(), 01551 qMin(255, (int)(gradientStartColor.saturation()*2)), 01552 qMin(255, (int)(gradientStartColor.value()*0.96))); 01553 QLinearGradient gradient(rect.topLeft(), rect.bottomLeft()); 01554 if (option->palette.background().gradient()) { 01555 gradient.setStops(option->palette.background().gradient()->stops()); 01556 } else { 01557 gradient.setColorAt(0, gradientStartColor); 01558 gradient.setColorAt(0.8, gradientStartColor); 01559 gradient.setColorAt(1, gradientStopColor); 01560 } 01561 painter->fillRect(r, gradient); 01562 01563 if (!UsePixmapCache || !QPixmapCache::find(pixmapName, cache)) { 01564 cache = QPixmap(r.size()); 01565 cache.fill(Qt::transparent); 01566 QRect pixmapRect(0, 0, r.width(), r.height()); 01567 QPainter cachePainter(&cache); 01568 if (header->orientation == Qt::Vertical) { 01569 cachePainter.setPen(QPen(dark)); 01570 cachePainter.drawLine(pixmapRect.topRight(), pixmapRect.bottomRight()); 01571 if (header->position != QStyleOptionHeader::End) { 01572 cachePainter.setPen(QPen(shadow)); 01573 cachePainter.drawLine(pixmapRect.bottomLeft() + QPoint(3, -1), pixmapRect.bottomRight() + QPoint(-3, -1)); cachePainter.setPen(QPen(option->palette.light().color())); 01574 cachePainter.drawLine(pixmapRect.bottomLeft() + QPoint(3, 0), pixmapRect.bottomRight() + QPoint(-3, 0)); } 01575 } else { 01576 cachePainter.setPen(QPen(dark)); 01577 cachePainter.drawLine(pixmapRect.bottomLeft(), pixmapRect.bottomRight()); 01578 cachePainter.setPen(QPen(shadow)); 01579 cachePainter.drawLine(pixmapRect.topRight() + QPoint(-1, 3), pixmapRect.bottomRight() + QPoint(-1, -3)); cachePainter.setPen(QPen(option->palette.light().color())); 01580 cachePainter.drawLine(pixmapRect.topRight() + QPoint(0, 3), pixmapRect.bottomRight() + QPoint(0, -3)); } 01581 cachePainter.end(); 01582 if (UsePixmapCache) 01583 QPixmapCache::insert(pixmapName, cache); 01584 } 01585 painter->drawPixmap(r.topLeft(), cache); 01586 } 01587 painter->restore(); 01588 break; 01589 case CE_ProgressBarGroove: 01590 painter->save(); 01591 { 01592 painter->fillRect(rect, option->palette.base()); 01593 QColor borderColor = dark.light(110); 01594 painter->setPen(QPen(borderColor, 0)); 01595 painter->drawLine(QPoint(rect.left() + 1, rect.top()), QPoint(rect.right() - 1, rect.top())); 01596 painter->drawLine(QPoint(rect.left() + 1, rect.bottom()), QPoint(rect.right() - 1, rect.bottom())); 01597 painter->drawLine(QPoint(rect.left(), rect.top() + 1), QPoint(rect.left(), rect.bottom() - 1)); 01598 painter->drawLine(QPoint(rect.right(), rect.top() + 1), QPoint(rect.right(), rect.bottom() - 1)); 01599 QColor alphaCorner = mergedColors(borderColor, option->palette.background().color()); 01600 QColor innerShadow = mergedColors(borderColor, option->palette.base().color()); 01601 01602 //corner smoothing 01603 painter->setPen(alphaCorner); 01604 painter->drawPoint(rect.topRight()); 01605 painter->drawPoint(rect.topLeft()); 01606 painter->drawPoint(rect.bottomRight()); 01607 painter->drawPoint(rect.bottomLeft()); 01608 01609 //inner shadow 01610 painter->setPen(innerShadow); 01611 painter->drawLine(QPoint(rect.left() + 1, rect.top() + 1), 01612 QPoint(rect.right() - 1, rect.top() + 1)); 01613 painter->drawLine(QPoint(rect.left() + 1, rect.top() + 1), 01614 QPoint(rect.left() + 1, rect.bottom() + 1)); 01615 01616 } 01617 painter->restore(); 01618 break; 01619 case CE_ProgressBarContents: 01620 painter->save(); 01621 if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) { 01622 QRect rect = bar->rect; 01623 bool vertical = false; 01624 bool inverted = false; 01625 bool indeterminate = (bar->minimum == 0 && bar->maximum == 0); 01626 01627 // Get extra style options if version 2 01628 if (const QStyleOptionProgressBarV2 *bar2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) { 01629 vertical = (bar2->orientation == Qt::Vertical); 01630 inverted = bar2->invertedAppearance; 01631 } 01632 01633 // If the orientation is vertical, we use a transform to rotate 01634 // the progress bar 90 degrees clockwise. This way we can use the 01635 // same rendering code for both orientations. 01636 if (vertical) { 01637 rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height 01638 QMatrix m; 01639 m.translate(rect.height()-1, -1.0); 01640 m.rotate(90.0); 01641 painter->setMatrix(m); 01642 } 01643 01644 int maxWidth = rect.width() - 4; 01645 int minWidth = 4; 01646 int progress = qMax(bar->progress, bar->minimum); // workaround for bug in QProgressBar 01647 int width = indeterminate ? maxWidth : qMax(int((((progress - bar->minimum)) 01648 / double(bar->maximum - bar->minimum)) * maxWidth), minWidth); 01649 01650 bool reverse = (!vertical && (bar->direction == Qt::RightToLeft)) || vertical; 01651 if (inverted) 01652 reverse = !reverse; 01653 01654 QRect progressBar; 01655 if (!indeterminate) { 01656 if (!reverse) { 01657 progressBar.setRect(rect.left() + 1, rect.top() + 1, width + 1, rect.height() - 3); 01658 } else { 01659 progressBar.setRect(rect.right() - 1 - width, rect.top() + 1, width + 1, rect.height() - 3); 01660 } 01661 } else { 01662 int step = 0; 01663 int slideWidth = rect.width() / 2; 01664 progressBar.setRect(rect.left() + 1 + step, rect.top() + 1, 01665 slideWidth / 2, rect.height() - 3); 01666 01667 } 01668 QColor highlight = option->palette.color(QPalette::Normal, QPalette::Highlight); 01669 painter->setPen(QPen(highlight.dark(140), 0)); 01670 01671 QColor highlightedGradientStartColor = highlight.light(100); 01672 QColor highlightedGradientStopColor = highlight.light(130); 01673 01674 QLinearGradient gradient(rect.topLeft(), QPoint(rect.bottomLeft().x(), 01675 rect.bottomLeft().y()*2)); 01676 01677 gradient.setColorAt(0, highlightedGradientStartColor); 01678 gradient.setColorAt(1, highlightedGradientStopColor); 01679 01680 painter->setBrush(gradient); 01681 painter->drawRect(progressBar); 01682 01683 painter->setPen(QPen(highlight.light(120), 0)); 01684 painter->drawLine(QPoint(progressBar.left() + 1, progressBar.top() + 1), 01685 QPoint(progressBar.right(), progressBar.top() + 1)); 01686 painter->drawLine(QPoint(progressBar.left() + 1, progressBar.top() + 1), 01687 QPoint(progressBar.left() + 1, progressBar.bottom() - 1)); 01688 01689 painter->setPen(QPen(highlightedGradientStartColor, 7.0));//QPen(option->palette.highlight(), 3)); 01690 01691 painter->save(); 01692 painter->setClipRect(progressBar.adjusted(2, 2, -1, -1)); 01693 for (int x = rect.left() - 32; x< rect.right() ; x+=18) { 01694 painter->drawLine(x, progressBar.bottom() + 1, x + 23, progressBar.top() - 2); 01695 } 01696 painter->restore(); 01697 01698 } 01699 painter->restore(); 01700 break; 01701 case CE_MenuBarItem: 01702 painter->save(); 01703 if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) 01704 { 01705 QStyleOptionMenuItem item = *mbi; 01706 item.rect = mbi->rect.adjusted(0, 3, 0, -1); 01707 QColor highlightOutline = highlight.dark(125); 01708 QLinearGradient gradient(rect.topLeft(), QPoint(rect.bottomLeft().x(), rect.bottomLeft().y()*2)); 01709 01710 if (option->palette.button().gradient()) { 01711 gradient.setStops(option->palette.button().gradient()->stops()); 01712 } else { 01713 gradient.setColorAt(0, option->palette.button().color()); 01714 gradient.setColorAt(1, option->palette.button().color().dark(110)); 01715 } 01716 painter->fillRect(rect, gradient); 01717 01718 QCommonStyle::drawControl(element, &item, painter, widget); 01719 01720 bool act = mbi->state & State_Selected && mbi->state & State_Sunken; 01721 bool dis = !(mbi->state & State_Enabled); 01722 01723 QRect r = option->rect; 01724 if (act) { 01725 qt_cleanlooks_draw_gradient(painter, r.adjusted(1, 1, -1, -1), 01726 highlight, 01727 highlightOutline, TopDown, 01728 option->palette.highlight()); 01729 01730 painter->setPen(QPen(highlightOutline, 0)); 01731 painter->drawLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom())); 01732 painter->drawLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom())); 01733 painter->drawLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom())); 01734 painter->drawLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top())); 01735 01736 //draw text 01737 QPalette::ColorRole textRole = dis ? QPalette::Text : QPalette::HighlightedText; 01738 uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; 01739 if (!styleHint(SH_UnderlineShortcut, mbi, widget)) 01740 alignment |= Qt::TextHideMnemonic; 01741 drawItemText(painter, item.rect, alignment, mbi->palette, mbi->state & State_Enabled, mbi->text, textRole); 01742 } 01743 01744 } 01745 painter->restore(); 01746 break; 01747 case CE_MenuItem: 01748 painter->save(); 01749 // Draws one item in a popup menu. 01750 if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { 01751 QColor highlightOutline = highlight.dark(125); 01752 QColor menuBackground = option->palette.background().color().light(104); 01753 QColor borderColor = option->palette.background().color().dark(160); 01754 QColor alphaCornerColor; 01755 01756 if (widget) { 01757 // ### backgroundrole/foregroundrole should be part of the style option 01758 alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), borderColor); 01759 } else { 01760 alphaCornerColor = mergedColors(option->palette.background().color(), borderColor); 01761 } 01762 QColor alphaTextColor = mergedColors(option->palette.background().color(), option->palette.text().color()); 01763 if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { 01764 painter->fillRect(menuItem->rect, menuBackground); 01765 int w = 0; 01766 if (!menuItem->text.isEmpty()) { 01767 painter->setFont(menuItem->font); 01768 drawItemText(painter, menuItem->rect.adjusted(5, 0, -5, 0), Qt::AlignLeft | Qt::AlignVCenter, 01769 menuItem->palette, menuItem->state & State_Enabled, menuItem->text, 01770 QPalette::Text); 01771 w = menuItem->fontMetrics.width(menuItem->text) + 5; 01772 } 01773 painter->setPen(shadow.light(106)); 01774 bool reverse = menuItem->direction == Qt::RightToLeft; 01775 painter->drawLine(menuItem->rect.left() + 5 + (reverse ? 0 : w), menuItem->rect.center().y(), 01776 menuItem->rect.right() - 5 - (reverse ? w : 0), menuItem->rect.center().y()); 01777 painter->restore(); 01778 break; 01779 } 01780 bool selected = menuItem->state & State_Selected && menuItem->state & State_Enabled; 01781 if (selected) { 01782 QRect r = option->rect.adjusted(1, 0, -2, -1); 01783 qt_cleanlooks_draw_gradient(painter, r, highlight, 01784 highlightOutline, TopDown, 01785 highlight); 01786 r = r.adjusted(-1, 0, 1, 0); 01787 painter->setPen(QPen(highlightOutline, 0)); 01788 painter->drawLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom() - 1)); 01789 painter->drawLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom() - 1)); 01790 painter->drawLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom())); 01791 painter->drawLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top())); 01792 } else { 01793 painter->fillRect(option->rect, menuBackground); 01794 } 01795 01796 bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable; 01797 bool checked = menuItem->checked; 01798 bool sunken = menuItem->state & State_Sunken; 01799 bool enabled = menuItem->state & State_Enabled; 01800 01801 bool ignoreCheckMark = false; 01802 int checkcol = qMax(menuItem->maxIconWidth, 20); 01803 01804 #ifndef QT_NO_COMBOBOX 01805 if (qobject_cast<const QComboBox*>(widget)) 01806 ignoreCheckMark = true; //ignore the checkmarks provided by the QComboMenuDelegate 01807 #endif 01808 01809 if (!ignoreCheckMark) { 01810 // Check 01811 QRect checkRect(option->rect.left() + 7, option->rect.center().y() - 6, 13, 13); 01812 checkRect = visualRect(menuItem->direction, menuItem->rect, checkRect); 01813 if (checkable) { 01814 if (menuItem->checkType & QStyleOptionMenuItem::Exclusive) { 01815 // Radio button 01816 if (checked || sunken) { 01817 painter->setRenderHint(QPainter::Antialiasing); 01818 painter->setPen(Qt::NoPen); 01819 01820 QPalette::ColorRole textRole = !enabled ? QPalette::Text: 01821 selected ? QPalette::HighlightedText : QPalette::ButtonText; 01822 painter->setBrush(option->palette.brush( option->palette.currentColorGroup(), textRole)); 01823 painter->drawEllipse(checkRect.adjusted(4, 4, -4, -4)); 01824 } 01825 } else { 01826 // Check box 01827 if (menuItem->icon.isNull()) { 01828 if (checked || sunken) { 01829 QImage image(qt_cleanlooks_menuitem_checkbox_checked); 01830 if (menuItem->state & State_Selected) { 01831 image.setColor(1, 0x55ffffff); 01832 image.setColor(2, 0xAAffffff); 01833 image.setColor(3, 0xBBffffff); 01834 image.setColor(4, 0xFFffffff); 01835 image.setColor(5, 0x33ffffff); 01836 } else { 01837 image.setColor(1, 0x55000000); 01838 image.setColor(2, 0xAA000000); 01839 image.setColor(3, 0xBB000000); 01840 image.setColor(4, 0xFF000000); 01841 image.setColor(5, 0x33000000); 01842 } 01843 painter->drawImage(QPoint(checkRect.center().x() - image.width() / 2, 01844 checkRect.center().y() - image.height() / 2), image); 01845 } 01846 } else if (checked) { 01847 int iconSize = qMax(menuItem->maxIconWidth, 20); 01848 QRect sunkenRect(option->rect.left() + 2, 01849 option->rect.top() + (option->rect.height() - iconSize) / 2, 01850 iconSize, iconSize); 01851 sunkenRect = visualRect(menuItem->direction, menuItem->rect, sunkenRect); 01852 01853 QStyleOption opt = *option; 01854 opt.state |= State_Sunken; 01855 opt.rect = sunkenRect; 01856 } 01857 } 01858 } 01859 } else { //ignore checkmark 01860 if (menuItem->icon.isNull()) 01861 checkcol = 0; 01862 else 01863 checkcol = menuItem->maxIconWidth; 01864 } 01865 01866 // Text and icon, ripped from windows style 01867 bool dis = !(menuItem->state & State_Enabled); 01868 bool act = menuItem->state & State_Selected; 01869 const QStyleOption *opt = option; 01870 const QStyleOptionMenuItem *menuitem = menuItem; 01871 01872 QPainter *p = painter; 01873 QRect vCheckRect = visualRect(opt->direction, menuitem->rect, 01874 QRect(menuitem->rect.x(), menuitem->rect.y(), 01875 checkcol, menuitem->rect.height())); 01876 if (!menuItem->icon.isNull()) { 01877 QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal; 01878 if (act && !dis) 01879 mode = QIcon::Active; 01880 QPixmap pixmap; 01881 if (checked) 01882 pixmap = menuItem->icon.pixmap(pixelMetric(PM_SmallIconSize), mode, QIcon::On); 01883 else 01884 pixmap = menuItem->icon.pixmap(pixelMetric(PM_SmallIconSize), mode); 01885 int pixw = pixmap.width(); 01886 int pixh = pixmap.height(); 01887 01888 QRect pmr(0, 0, pixw, pixh); 01889 pmr.moveCenter(vCheckRect.center()); 01890 painter->setPen(menuItem->palette.text().color()); 01891 if (checkable && checked) 01892 painter->drawPixmap(QPoint(pmr.left() + 1, pmr.top() + 1), pixmap); 01893 else 01894 painter->drawPixmap(pmr.topLeft(), pixmap); 01895 } 01896 if (selected) { 01897 painter->setPen(menuItem->palette.highlightedText().color()); 01898 } else { 01899 painter->setPen(menuItem->palette.text().color()); 01900 } 01901 int x, y, w, h; 01902 menuitem->rect.getRect(&x, &y, &w, &h); 01903 int tab = menuitem->tabWidth; 01904 QColor discol; 01905 if (dis) { 01906 discol = menuitem->palette.text().color(); 01907 p->setPen(discol); 01908 } 01909 int xm = windowsItemFrame + checkcol + windowsItemHMargin; 01910 int xpos = menuitem->rect.x() + xm; 01911 01912 QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin); 01913 QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect); 01914 QString s = menuitem->text; 01915 if (!s.isEmpty()) { // draw text 01916 p->save(); 01917 int t = s.indexOf(QLatin1Char('\t')); 01918 int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; 01919 if (!styleHint(SH_UnderlineShortcut, menuitem, widget)) 01920 text_flags |= Qt::TextHideMnemonic; 01921 text_flags |= Qt::AlignLeft; 01922 if (t >= 0) { 01923 QRect vShortcutRect = visualRect(opt->direction, menuitem->rect, 01924 QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom()))); 01925 if (dis && !act) { 01926 p->setPen(menuitem->palette.light().color()); 01927 p->drawText(vShortcutRect.adjusted(1, 1, 1, 1), text_flags, s.mid(t + 1)); 01928 p->setPen(discol); 01929 } 01930 p->drawText(vShortcutRect, text_flags, s.mid(t + 1)); 01931 s = s.left(t); 01932 } 01933 QFont font = menuitem->font; 01934 01935 if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem) 01936 font.setBold(true); 01937 01938 p->setFont(font); 01939 if (dis && !act) { 01940 p->setPen(menuitem->palette.light().color()); 01941 p->drawText(vTextRect.adjusted(1, 1, 1, 1), text_flags, s.left(t)); 01942 p->setPen(discol); 01943 } 01944 p->drawText(vTextRect, text_flags, s.left(t)); 01945 p->restore(); 01946 } 01947 01948 // Arrow 01949 if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow 01950 int dim = (menuItem->rect.height() - 4) / 2; 01951 PrimitiveElement arrow; 01952 arrow = QApplication::isRightToLeft() ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight; 01953 int xpos = menuItem->rect.left() + menuItem->rect.width() - 1 - dim; 01954 QRect vSubMenuRect = visualRect(option->direction, menuItem->rect, 01955 QRect(xpos, menuItem->rect.top() + menuItem->rect.height() / 2 - dim / 2, dim, dim)); 01956 QStyleOptionMenuItem newMI = *menuItem; 01957 newMI.rect = vSubMenuRect; 01958 newMI.state = !enabled ? State_None : State_Enabled; 01959 if (selected) 01960 newMI.palette.setColor(QPalette::ButtonText, 01961 newMI.palette.highlightedText().color()); 01962 drawPrimitive(arrow, &newMI, painter, widget); 01963 } 01964 } 01965 painter->restore(); 01966 break; 01967 case CE_MenuHMargin: 01968 case CE_MenuVMargin: 01969 break; 01970 case CE_MenuEmptyArea: 01971 break; 01972 case CE_PushButtonLabel: 01973 if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) { 01974 QRect ir = button->rect; 01975 uint tf = Qt::AlignVCenter | Qt::TextShowMnemonic; 01976 if (!styleHint(SH_UnderlineShortcut, button, widget)) 01977 tf |= Qt::TextHideMnemonic; 01978 01979 if (!button->icon.isNull()) { 01980 //Center both icon and text 01981 QPoint point; 01982 01983 QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal 01984 : QIcon::Disabled; 01985 if (mode == QIcon::Normal && button->state & State_HasFocus) 01986 mode = QIcon::Active; 01987 QIcon::State state = QIcon::Off; 01988 if (button->state & State_On) 01989 state = QIcon::On; 01990 01991 QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state); 01992 int w = pixmap.width(); 01993 int h = pixmap.height(); 01994 01995 if (!button->text.isEmpty()) 01996 w += button->fontMetrics.width(button->text) + 2; 01997 01998 point = QPoint(ir.x() + ir.width() / 2 - w / 2, 01999 ir.y() + ir.height() / 2 - h / 2); 02000 02001 if (button->direction == Qt::RightToLeft) 02002 point.rx() += pixmap.width(); 02003 02004 painter->drawPixmap(visualPos(button->direction, button->rect, point), pixmap); 02005 02006 if (button->direction == Qt::RightToLeft) 02007 ir.translate(-point.x() - 2, 0); 02008 else 02009 ir.translate(point.x() + pixmap.width(), 0); 02010 02011 // left-align text if there is 02012 if (!button->text.isEmpty()) 02013 tf |= Qt::AlignLeft; 02014 02015 } else { 02016 tf |= Qt::AlignHCenter; 02017 } 02018 02019 //this tweak ensures the font is perfectly centered on small sizes 02020 //but slightly downward to make it more gnomeish if not 02021 if (button->fontMetrics.height() > 14) 02022 ir.translate(0, 1); 02023 02024 drawItemText(painter, ir, tf, button->palette, (button->state & State_Enabled), 02025 button->text, QPalette::ButtonText); 02026 } 02027 break; 02028 case CE_MenuBarEmptyArea: 02029 painter->save(); 02030 { 02031 QColor shadow = mergedColors(option->palette.background().color().dark(120), 02032 dark.light(140), 60); 02033 02034 QLinearGradient gradient(rect.topLeft(), QPoint(rect.bottomLeft().x(), rect.bottomLeft().y()*2)); 02035 gradient.setColorAt(0, option->palette.button().color()); 02036 gradient.setColorAt(1, option->palette.button().color().dark(110)); 02037 painter->fillRect(rect, gradient); 02038 02039 #ifndef QT_NO_MAINWINDOW 02040 if (widget && qobject_cast<const QMainWindow *>(widget->parentWidget())) { 02041 QPen oldPen = painter->pen(); 02042 painter->setPen(QPen(shadow)); 02043 painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight()); 02044 } 02045 #endif // QT_NO_MAINWINDOW 02046 } 02047 painter->restore(); 02048 break; 02049 #ifndef QT_NO_TABBAR 02050 case CE_TabBarTabShape: 02051 painter->save(); 02052 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) { 02053 02054 bool rtlHorTabs = (tab->direction == Qt::RightToLeft 02055 && (tab->shape == QTabBar::RoundedNorth 02056 || tab->shape == QTabBar::RoundedSouth)); 02057 bool selected = tab->state & State_Selected; 02058 bool lastTab = ((!rtlHorTabs && tab->position == QStyleOptionTab::End) 02059 || (rtlHorTabs 02060 && tab->position == QStyleOptionTab::Beginning)); 02061 bool onlyTab = tab->position == QStyleOptionTab::OnlyOneTab; 02062 bool leftCornerWidget = (tab->cornerWidgets & QStyleOptionTab::LeftCornerWidget); 02063 bool atBeginning = ((tab->position == QStyleOptionTab::Beginning) || onlyTab); 02064 02065 bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab; 02066 bool previousSelected = 02067 ((!rtlHorTabs 02068 && tab->selectedPosition == QStyleOptionTab::PreviousIsSelected) 02069 || (rtlHorTabs 02070 && tab->selectedPosition == QStyleOptionTab::NextIsSelected)); 02071 bool nextSelected = 02072 ((!rtlHorTabs 02073 && tab->selectedPosition == QStyleOptionTab::NextIsSelected) 02074 || (rtlHorTabs 02075 && tab->selectedPosition 02076 == QStyleOptionTab::PreviousIsSelected)); 02077 int tabBarAlignment = styleHint(SH_TabBar_Alignment, tab, widget); 02078 bool leftAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignLeft) 02079 || (rtlHorTabs 02080 && tabBarAlignment == Qt::AlignRight); 02081 02082 bool rightAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignRight) 02083 || (rtlHorTabs 02084 && tabBarAlignment == Qt::AlignLeft); 02085 02086 QColor light = tab->palette.light().color(); 02087 QColor midlight = tab->palette.midlight().color(); 02088 02089 QColor background = tab->palette.background().color(); 02090 int borderThinkness = pixelMetric(PM_TabBarBaseOverlap, tab, widget); 02091 if (selected) 02092 borderThinkness /= 2; 02093 QRect r2(option->rect); 02094 int x1 = r2.left(); 02095 int x2 = r2.right(); 02096 int y1 = r2.top(); 02097 int y2 = r2.bottom(); 02098 02099 QMatrix rotMatrix; 02100 bool flip = false; 02101 painter->setPen(shadow); 02102 QColor activeHighlight = option->palette.color(QPalette::Normal, QPalette::Highlight); 02103 switch (tab->shape) { 02104 case QTabBar::RoundedNorth: 02105 break; 02106 case QTabBar::RoundedSouth: 02107 rotMatrix.rotate(180); 02108 rotMatrix.translate(0, -rect.height() + 1); 02109 rotMatrix.scale(-1, 1); 02110 painter->setMatrix(rotMatrix); 02111 break; 02112 case QTabBar::RoundedWest: 02113 rotMatrix.rotate(180 + 90); 02114 rotMatrix.scale(-1, 1); 02115 flip = true; 02116 painter->setMatrix(rotMatrix); 02117 break; 02118 case QTabBar::RoundedEast: 02119 rotMatrix.rotate(90); 02120 rotMatrix.translate(0, - rect.width() + 1); 02121 flip = true; 02122 painter->setMatrix(rotMatrix); 02123 break; 02124 default: 02125 painter->restore(); 02126 QWindowsStyle::drawControl(element, tab, painter, widget); 02127 return; 02128 } 02129 02130 if (flip) { 02131 QRect tmp = rect; 02132 rect = QRect(tmp.y(), tmp.x(), tmp.height(), tmp.width()); 02133 int temp = x1; 02134 x1 = y1; 02135 y1 = temp; 02136 temp = x2; 02137 x2 = y2; 02138 y2 = temp; 02139 } 02140 02141 QLinearGradient gradient(rect.topLeft(), rect.bottomLeft()); 02142 if (option->palette.button().gradient()) { 02143 if (selected) 02144 gradient.setStops(option->palette.background().gradient()->stops()); 02145 else 02146 gradient.setStops(option->palette.background().gradient()->stops()); 02147 } 02148 else if (selected) { 02149 gradient.setColorAt(0, option->palette.background().color().light(104)); 02150 gradient.setColorAt(1, tabFrameColor); 02151 painter->fillRect(rect.adjusted(0, 2, 0, -1), gradient); 02152 } else { 02153 y1 += 2; 02154 gradient.setColorAt(0, option->palette.background().color()); 02155 gradient.setColorAt(1, dark.light(120)); 02156 painter->fillRect(rect.adjusted(0, 2, 0, -2), gradient); 02157 } 02158 02159 // Delete border 02160 if (selected) { 02161 painter->setPen(QPen(activeHighlight, 0)); 02162 painter->drawLine(x1 + 1, y1 + 1, x2 - 1, y1 + 1); 02163 painter->drawLine(x1 , y1 + 2, x2 , y1 + 2); 02164 } else { 02165 painter->setPen(dark); 02166 painter->drawLine(x1, y2 - 1, x2 + 2, y2 - 1 ); 02167 if (tab->shape == QTabBar::RoundedNorth || tab->shape == QTabBar::RoundedWest) { 02168 painter->setPen(light); 02169 painter->drawLine(x1, y2 , x2, y2 ); 02170 } 02171 } 02172 // Left 02173 if (atBeginning || selected ) { 02174 painter->setPen(light); 02175 painter->drawLine(x1 + 1, y1 + 2 + 1, x1 + 1, y2 - ((onlyOne || atBeginning) && selected && leftAligned ? 0 : borderThinkness) - (atBeginning && leftCornerWidget ? 1 : 0)); 02176 painter->drawPoint(x1 + 1, y1 + 1); 02177 painter->setPen(dark); 02178 painter->drawLine(x1, y1 + 2, x1, y2 - ((onlyOne || atBeginning) && leftAligned ? 0 : borderThinkness) - (atBeginning && leftCornerWidget ? 1 : 0)); 02179 } 02180 // Top 02181 { 02182 int beg = x1 + (previousSelected ? 0 : 2); 02183 int end = x2 - (nextSelected ? 0 : 2); 02184 painter->setPen(light); 02185 02186 if (!selected)painter->drawLine(beg - 2, y1 + 1, end, y1 + 1); 02187 02188 if (selected) 02189 painter->setPen(QPen(activeHighlight.dark(150), 0)); 02190 else 02191 painter->setPen(darkOutline); 02192 painter->drawLine(beg, y1 , end, y1); 02193 02194 if (atBeginning|| selected) { 02195 painter->drawPoint(beg - 1, y1 + 1); 02196 } else if (!atBeginning) { 02197 painter->drawPoint(beg - 1, y1); 02198 painter->drawPoint(beg - 2, y1); 02199 if (!lastTab) { 02200 painter->setPen(dark.light(130)); 02201 painter->drawPoint(end + 1, y1); 02202 painter->drawPoint(end + 2 , y1); 02203 painter->drawPoint(end + 2, y1 + 1); 02204 } 02205 } 02206 } 02207 // Right 02208 if (lastTab || selected || onlyOne || !nextSelected) { 02209 painter->setPen(darkOutline); 02210 painter->drawLine(x2, y1 + 2, x2, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness)); 02211 if (selected) 02212 painter->setPen(QPen(activeHighlight.dark(150), 0)); 02213 else 02214 painter->setPen(darkOutline); 02215 painter->drawPoint(x2 - 1, y1 + 1); 02216 02217 if (selected) { 02218 painter->setPen(background.dark(110)); 02219 painter->drawLine(x2 - 1, y1 + 3, x2 - 1, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness)); 02220 } 02221 } 02222 } 02223 painter->restore(); 02224 break; 02225 02226 #endif // QT_NO_TABBAR 02227 default: 02228 QWindowsStyle::drawControl(element,option,painter,widget); 02229 break; 02230 } 02231 }
Here is the call graph for this function:

| int QCleanlooksStyle::pixelMetric | ( | PixelMetric | metric, | |
| const QStyleOption * | option = 0, |
|||
| const QWidget * | widget = 0 | |||
| ) | const [virtual] |
Reimplemented from QWindowsStyle.
Definition at line 3474 of file qcleanlooksstyle.cpp.
References QWindowsStyle::pixelMetric(), QStyle::PM_ButtonDefaultIndicator, QStyle::PM_ButtonIconSize, QStyle::PM_ButtonShiftHorizontal, QStyle::PM_ButtonShiftVertical, QStyle::PM_DefaultFrameWidth, QStyle::PM_DialogButtonsSeparator, QStyle::PM_DockWidgetTitleMargin, QStyle::PM_ListViewIconSize, QStyle::PM_MenuBarHMargin, QStyle::PM_MenuBarItemSpacing, QStyle::PM_MenuBarVMargin, QStyle::PM_MenuPanelWidth, QStyle::PM_MessageBoxIconSize, QStyle::PM_ScrollBarExtent, QStyle::PM_ScrollBarSliderMin, QStyle::PM_SliderLength, QStyle::PM_SliderThickness, QStyle::PM_SmallIconSize, QStyle::PM_SpinBoxFrameWidth, QStyle::PM_SplitterWidth, QStyle::PM_TitleBarHeight, QStyle::PM_ToolBarFrameWidth, QStyle::PM_ToolBarHandleExtent, QStyle::PM_ToolBarItemMargin, and QStyle::PM_ToolBarItemSpacing.
Referenced by drawComplexControl(), drawControl(), drawPrimitive(), and subControlRect().
03475 { 03476 int ret = -1; 03477 switch (metric) { 03478 case PM_ButtonDefaultIndicator: 03479 ret = 0; 03480 break; 03481 case PM_ButtonShiftHorizontal: 03482 case PM_ButtonShiftVertical: 03483 ret = 0; 03484 break; 03485 case PM_MessageBoxIconSize: 03486 ret = 48; 03487 break; 03488 case PM_ListViewIconSize: 03489 ret = 24; 03490 break; 03491 case PM_DialogButtonsSeparator: 03492 case PM_SplitterWidth: 03493 ret = 6; 03494 break; 03495 case PM_ScrollBarSliderMin: 03496 ret = 26; 03497 break; 03498 case PM_MenuPanelWidth: //menu framewidth 03499 ret = 2; 03500 break; 03501 case PM_TitleBarHeight: 03502 ret = 24; 03503 break; 03504 case PM_ScrollBarExtent: 03505 ret = 15; 03506 break; 03507 case PM_SliderThickness: 03508 ret = 16; 03509 break; 03510 case PM_SliderLength: 03511 ret = 32; 03512 break; 03513 case PM_DockWidgetTitleMargin: 03514 ret = 2; 03515 break; 03516 case PM_MenuBarVMargin: 03517 ret = 1; 03518 break; 03519 case PM_DefaultFrameWidth: 03520 ret = 2; 03521 break; 03522 case PM_SpinBoxFrameWidth: 03523 ret = 3; 03524 break; 03525 case PM_MenuBarItemSpacing: 03526 ret = 6; 03527 case PM_MenuBarHMargin: 03528 ret = 0; 03529 break; 03530 case PM_ToolBarHandleExtent: 03531 ret = 9; 03532 break; 03533 case PM_ToolBarItemSpacing: 03534 ret = 2; 03535 break; 03536 case PM_ToolBarFrameWidth: 03537 ret = 0; 03538 break; 03539 case PM_ToolBarItemMargin: 03540 ret = 1; 03541 break; 03542 case PM_SmallIconSize: 03543 ret = 16; 03544 break; 03545 case PM_ButtonIconSize: 03546 ret = 24; 03547 break; 03548 default: 03549 break; 03550 } 03551 03552 return ret != -1 ? ret : QWindowsStyle::pixelMetric(metric, option, widget); 03553 }
Here is the call graph for this function:

| void QCleanlooksStyle::drawComplexControl | ( | ComplexControl | control, | |
| const QStyleOptionComplex * | option, | |||
| QPainter * | painter, | |||
| const QWidget * | widget | |||
| ) | const [virtual] |
Reimplemented from QWindowsStyle.
Definition at line 2281 of file qcleanlooksstyle.cpp.
References QRect::adjust(), QRect::adjusted(), Qt::AlignCenter, Qt::AlignHCenter, Qt::AlignLeft, Qt::AlignVCenter, QPalette::background(), QWidget::backgroundRole(), QRect::bottom(), QRect::bottomLeft(), QRect::bottomRight(), QPalette::button(), QStyle::CC_ComboBox, QStyle::CC_GroupBox, QStyle::CC_ScrollBar, QStyle::CC_Slider, QStyle::CC_SpinBox, QStyle::CC_TitleBar, QRect::center(), QBrush::color(), QPalette::color(), QColor::dark(), QPalette::Dark, QWindowsStyle::drawComplexControl(), QPainter::drawImage(), drawItemPixmap(), QPainter::drawLine(), QPainter::drawPixmap(), QPainter::drawPoint(), drawPrimitive(), QPainter::drawRect(), QPainter::drawText(), QPainter::end(), QStyleOptionFrameV2::features, QPixmap::fill(), QPainter::fillRect(), fillRect(), QLinearGradient::finalStop(), QPixmapCache::find(), QStyleOptionFrameV2::Flat, QPainter::font(), QStyleOptionSpinBox::frame, FromLeft, QImage::height(), QRect::height(), QPalette::highlight(), QPalette::Highlight, Qt::Horizontal, QColor::hue, i, image, QPixmapCache::insert(), int, QRect::isValid(), QRect::left(), Qt::LeftToRight, len, QColor::light(), QStyleOptionFrame::lineWidth, mergedColors(), QStyleOptionFrame::midLineWidth, Qt::NoPen, QPalette::Normal, palette, QStyleOption::palette, QStyle::PE_FrameFocusRect, QStyle::PE_FrameGroupBox, QStyle::PE_IndicatorCheckBox, QStyle::PE_PanelButtonCommand, QPainter::pen(), pixelMetric(), QAbstractSpinBox::PlusMinus, QStyle::PM_SliderLength, QStyle::PM_SliderSpaceAvailable, QStyle::PM_SliderTickmarkOffset, QStyle::PM_SpinBoxFrameWidth, qMax(), qMin(), qt_cleanlooks_arrow_down_xpm, qt_cleanlooks_draw_gradient(), qt_cleanlooks_draw_mdibutton(), qt_scrollbar_button_arrow_down, qt_scrollbar_button_arrow_left, qt_scrollbar_button_arrow_right, qt_scrollbar_button_arrow_up, qt_scrollbar_button_down, qt_scrollbar_button_left, qt_scrollbar_button_right, qt_scrollbar_button_up, qt_spinbox_button_arrow_down, qt_spinbox_button_arrow_up, qt_titlebar_context_help, QStyleOption::rect, QPainter::restore(), reverse(), QColor::rgba(), QRect::right(), Qt::RightToLeft, QColor::saturation, QPainter::save(), QStyle::SC_ComboBoxArrow, QStyle::SC_ComboBoxEditField, QStyle::SC_GroupBoxCheckBox, QStyle::SC_GroupBoxFrame, QStyle::SC_GroupBoxLabel, QStyle::SC_ScrollBarAddLine, QStyle::SC_ScrollBarGroove, QStyle::SC_ScrollBarSlider, QStyle::SC_ScrollBarSubLine, QStyle::SC_SliderGroove, QStyle::SC_SliderHandle, QStyle::SC_SliderTickmarks, QStyle::SC_SpinBoxDown, QStyle::SC_SpinBoxUp, QStyle::SC_TitleBarCloseButton, QStyle::SC_TitleBarContextHelpButton, QStyle::SC_TitleBarLabel, QStyle::SC_TitleBarMaxButton, QStyle::SC_TitleBarMinButton, QStyle::SC_TitleBarNormalButton, QStyle::SC_TitleBarShadeButton, QStyle::SC_TitleBarSysMenu, QStyle::SC_TitleBarUnshadeButton, QColor::setAlpha(), QFont::setBold(), QPainter::setBrush(), QPalette::setBrush(), QPainter::setClipRegion(), QImage::setColor(), QGradient::setColorAt(), QLinearGradient::setFinalStop(), QPainter::setFont(), QColor::setHsv(), QPainter::setPen(), QLinearGradient::setStart(), QStyle::SH_UnderlineShortcut, QStyle::sliderPositionFromValue(), QStyle::SP_TitleBarMenuButton, standardPixmap(), QLinearGradient::start(), QStyleOption::state, QStyle::State_Active, QStyle::State_Enabled, QStyle::State_HasFocus, QStyle::State_Horizontal, QStyle::State_KeyboardFocusChange, QStyle::State_MouseOver, QStyle::State_On, QStyle::State_Sunken, QAbstractSpinBox::StepDownEnabled, QAbstractSpinBox::StepUpEnabled, styleHint(), subControlRect(), Qt::TextHideMnemonic, Qt::TextShowMnemonic, QSlider::TicksAbove, QSlider::TicksBelow, QRect::top(), TopDown, QRect::topLeft(), QRect::topRight(), Qt::transparent, uniqueName(), QRect::united(), UsePixmapCache, QColor::value, Qt::white, QRect::width(), QImage::width(), Qt::WindowMaximizeButtonHint, Qt::WindowMaximized, Qt::WindowMinimizeButtonHint, Qt::WindowMinimized, Qt::WindowSystemMenuHint, QPoint::x(), and QPoint::y().
02283 { 02284 QColor button = option->palette.button().color(); 02285 QColor dark; 02286 QColor grooveColor; 02287 QColor darkOutline; 02288 dark.setHsv(button.hue(), 02289 qMin(255, (int)(button.saturation()*1.9)), 02290 qMin(255, (int)(button.value()*0.7))); 02291 grooveColor.setHsv(button.hue(), 02292 qMin(255, (int)(button.saturation()*2.6)), 02293 qMin(255, (int)(button.value()*0.9))); 02294 darkOutline.setHsv(button.hue(), 02295 qMin(255, (int)(button.saturation()*3.0)), 02296 qMin(255, (int)(button.value()*0.6))); 02297 02298 QColor alphaCornerColor; 02299 if (widget) { 02300 // ### backgroundrole/foregroundrole should be part of the style option 02301 alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), darkOutline); 02302 } else { 02303 alphaCornerColor = mergedColors(option->palette.background().color(), darkOutline); 02304 } 02305 QColor gripShadow = grooveColor.dark(110); 02306 QColor buttonShadow = option->palette.button().color().dark(110); 02307 02308 QColor gradientStartColor = option->palette.button().color().light(108); 02309 QColor gradientStopColor = mergedColors(option->palette.button().color().dark(108), dark.light(150), 70); 02310 02311 QColor highlightedGradientStartColor = option->palette.button().color(); 02312 QColor highlightedGradientStopColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 85); 02313 02314 QColor highlightedDarkInnerBorderColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 35); 02315 QColor highlightedLightInnerBorderColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 58); 02316 02317 QColor buttonShadowAlpha = option->palette.background().color().dark(105); 02318 02319 QPalette palette = option->palette; 02320 02321 switch (control) { 02322 #ifndef QT_NO_SPINBOX 02323 case CC_SpinBox: 02324 if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { 02325 QPixmap cache; 02326 QString pixmapName = uniqueName(QLatin1String("spinbox"), spinBox, spinBox->rect.size()); 02327 if (!UsePixmapCache || !QPixmapCache::find(pixmapName, cache)) { 02328 cache = QPixmap(spinBox->rect.size()); 02329 cache.fill(Qt::transparent); 02330 QRect pixmapRect(0, 0, spinBox->rect.width(), spinBox->rect.height()); 02331 QPainter cachePainter(&cache); 02332 02333 bool isEnabled = (spinBox->state & State_Enabled); 02334 //bool focus = isEnabled && (spinBox->state & State_HasFocus); 02335 bool hover = isEnabled && (spinBox->state & State_MouseOver); 02336 bool sunken = (spinBox->state & State_Sunken); 02337 bool upIsActive = (spinBox->activeSubControls == SC_SpinBoxUp); 02338 bool downIsActive = (spinBox->activeSubControls == SC_SpinBoxDown); 02339 02340 QRect rect = pixmapRect; 02341 QStyleOptionSpinBox spinBoxCopy = *spinBox; 02342 spinBoxCopy.rect = pixmapRect; 02343 QRect upRect = subControlRect(CC_SpinBox, &spinBoxCopy, SC_SpinBoxUp, widget); 02344 QRect downRect = subControlRect(CC_SpinBox, &spinBoxCopy, SC_SpinBoxDown, widget); 02345 02346 int fw = spinBoxCopy.frame ? pixelMetric(PM_SpinBoxFrameWidth, &spinBoxCopy, widget) : 0; 02347 cachePainter.fillRect(rect.adjusted(1, qMax(fw - 1, 0), -1, -fw), 02348 option->palette.base()); 02349 02350 QRect r = rect.adjusted(0, 1, 0, -1); 02351 if (spinBox->frame) { 02352 // draw frame 02353 cachePainter.setPen(buttonShadowAlpha); 02354 cachePainter.drawLine(QPoint(r.left() + 2, r.top() - 1), QPoint(r.right() - 2, r.top() - 1)); 02355 02356 cachePainter.setPen(QPen(option->palette.background().color(), 1)); 02357 cachePainter.drawLine(QPoint(r.left() + 2, r.top() + 1), QPoint(r.right() - 2, r.top() + 1)); 02358 QColor highlight = Qt::white; 02359 highlight.setAlpha(130); 02360 cachePainter.setPen(option->palette.base().color().dark(120)); 02361 cachePainter.drawLine(QPoint(r.left() + 1, r.top() + 1), 02362 QPoint(r.right() - 1, r.top() + 1)); 02363 cachePainter.drawLine(QPoint(r.left() + 1, r.top() + 1), 02364 QPoint(r.left() + 1, r.bottom() - 1)); 02365 cachePainter.setPen(option->palette.base().color()); 02366 cachePainter.drawLine(QPoint(r.right() - 1, r.top() + 1), 02367 QPoint(r.right() - 1, r.bottom() - 1)); 02368 cachePainter.drawLine(QPoint(r.left() + 1, r.bottom() - 1), 02369 QPoint(r.right() - 1, r.bottom() - 1)); 02370 cachePainter.setPen(highlight); 02371 cachePainter.drawLine(QPoint(r.left() + 2, r.bottom() + 1), 02372 QPoint(r.right() - 2, r.bottom() + 1)); 02373 cachePainter.drawPoint(QPoint(r.left() + 1, r.bottom())); 02374 cachePainter.drawPoint(QPoint(r.right() - 1, r.bottom() )); 02375 cachePainter.setPen(QPen(darkOutline.light(115), 1)); 02376 02377 // top and bottom lines 02378 cachePainter.drawLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right()- 2, r.bottom())); 02379 cachePainter.drawLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - 2, r.top())); 02380 cachePainter.drawLine(QPoint(r.right(), r.top() + 2), QPoint(r.right(), r.bottom() - 2)); 02381 cachePainter.drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2)); 02382 cachePainter.drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2)); 02383 } 02384 02385 // gradients 02386 qt_cleanlooks_draw_gradient(&cachePainter, upRect, 02387 gradientStartColor.dark(106), 02388 gradientStopColor, TopDown, option->palette.button()); 02389 qt_cleanlooks_draw_gradient(&cachePainter, downRect.adjusted(0, 0, 0, 1), 02390 gradientStartColor.dark(106), 02391 gradientStopColor, TopDown, option->palette.button()); 02392 if (isEnabled) { 02393 if(upIsActive) { 02394 if (sunken) { 02395 cachePainter.fillRect(upRect.adjusted(1, 0, 0, 0), gradientStopColor.dark(110)); 02396 } else if (hover) { 02397 qt_cleanlooks_draw_gradient(&cachePainter, upRect.adjusted(1, 0, 0, 0), 02398 gradientStartColor.light(110), 02399 gradientStopColor.light(110), TopDown, option->palette.button()); 02400 } 02401 } 02402 if(downIsActive) { 02403 if (sunken) { 02404 cachePainter.fillRect(downRect.adjusted(1, 0, 0, 1), gradientStopColor.dark(110)); 02405 02406 } else if (hover) { 02407 qt_cleanlooks_draw_gradient(&cachePainter, downRect.adjusted(1, 0, 0, 1), 02408 gradientStartColor.light(110), 02409 gradientStopColor.light(110), TopDown, option->palette.button()); 02410 } 02411 } 02412 } 02413 02414 if (spinBox->frame) { 02415 // rounded corners 02416 cachePainter.drawPoint(QPoint(r.left() + 1, r.bottom() - 1)); 02417 cachePainter.drawPoint(QPoint(r.left() + 1, r.top() + 1)); 02418 cachePainter.drawPoint(QPoint(r.right() - 1, r.bottom() - 1)); 02419 cachePainter.drawPoint(QPoint(r.right() - 1, r.top() + 1)); 02420 02421 if (option->state & State_HasFocus) { 02422 QColor darkoutline = option->palette.highlight().color().dark(150); 02423 QColor innerline = mergedColors(option->palette.highlight().color(), Qt::white); 02424 cachePainter.setPen(QPen(innerline, 0)); 02425 if (spinBox->direction == Qt::LeftToRight) { 02426 cachePainter.drawRect(rect.adjusted(1, 2, -3 -downRect.width(), -3)); 02427 cachePainter.setPen(QPen(darkoutline, 0)); 02428 cachePainter.drawLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right()- downRect.width() - 1, r.bottom())); 02429 cachePainter.drawLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - downRect.width() - 1, r.top())); 02430 cachePainter.drawLine(QPoint(r.right() - downRect.width() - 1, r.top() + 1), QPoint(r.right()- downRect.width() - 1, r.bottom() - 1)); 02431 cachePainter.drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2)); 02432 cachePainter.drawPoint(QPoint(r.left() + 1, r.bottom() - 1)); 02433 cachePainter.drawPoint(QPoint(r.left() + 1, r.top() + 1)); 02434 cachePainter.drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2)); 02435 } else { 02436 cachePainter.drawRect(rect.adjusted(downRect.width() + 2, 2, -2, -3)); 02437 cachePainter.setPen(QPen(darkoutline, 0)); 02438 cachePainter.drawLine(QPoint(r.left() + downRect.width(), r.bottom()), QPoint(r.right()- 2 - 1, r.bottom())); 02439 cachePainter.drawLine(QPoint(r.left() + downRect.width(), r.top()), QPoint(r.right() - 2 - 1, r.top())); 02440 02441 cachePainter.drawLine(QPoint(r.right(), r.top() + 2), QPoint(r.right(), r.bottom() - 2)); 02442 cachePainter.drawPoint(QPoint(r.right() - 1, r.bottom() - 1)); 02443 cachePainter.drawPoint(QPoint(r.right() - 1, r.top() + 1)); 02444 cachePainter.drawLine(QPoint(r.left() + downRect.width() + 1, r.top()), 02445 QPoint(r.left() + downRect.width() + 1, r.bottom())); 02446 } 02447 } 02448 } 02449 02450 // outline the up/down buttons 02451 cachePainter.setPen(darkOutline); 02452 QColor light = option->palette.light().color().light(); 02453 02454 if (spinBox->direction == Qt::RightToLeft) { 02455 cachePainter.drawLine(upRect.right(), upRect.top() - 1, upRect.right(), downRect.bottom() + 1); 02456 cachePainter.setPen(light); 02457 cachePainter.drawLine(upRect.right() - 1, upRect.top() + 3, upRect.right() - 1, downRect.bottom() ); 02458 } else { 02459 cachePainter.drawLine(upRect.left(), upRect.top() - 1, upRect.left(), downRect.bottom() + 1); 02460 cachePainter.setPen(light); 02461 cachePainter.drawLine(upRect.left() + 1, upRect.top() , upRect.left() + 1, downRect.bottom() ); 02462 } 02463 if (upIsActive && sunken) { 02464 cachePainter.setPen(gradientStopColor.dark(130)); 02465 cachePainter.drawLine(upRect.left() + 1, upRect.top(), upRect.left() + 1, upRect.bottom()); 02466 cachePainter.drawLine(upRect.left(), upRect.top() - 1, upRect.right(), upRect.top() - 1); 02467 } else { 02468 cachePainter.setPen(light); 02469 cachePainter.drawLine(upRect.topLeft() + QPoint(1, -1), upRect.topRight() + QPoint(-1, -1)); 02470 cachePainter.setPen(darkOutline); 02471 cachePainter.drawLine(upRect.bottomLeft(), upRect.bottomRight()); 02472 } 02473 if (downIsActive && sunken) { 02474 cachePainter.setPen(gradientStopColor.dark(130)); 02475 cachePainter.drawLine(downRect.left() + 1, downRect.top(), downRect.left() + 1, downRect.bottom() + 1); 02476 cachePainter.drawLine(downRect.left(), downRect.top(), downRect.right(), downRect.top()); 02477 cachePainter.setPen(gradientStopColor.dark(110)); 02478 cachePainter.drawLine(downRect.left(), downRect.bottom() + 1, downRect.right(), downRect.bottom() + 1); 02479 } else { 02480 cachePainter.setPen(light); 02481 cachePainter.drawLine(downRect.topLeft() + QPoint(2,0), downRect.topRight()); 02482 } 02483 02484 if (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus) { 02485 int centerX = upRect.center().x(); 02486 int centerY = upRect.center().y(); 02487 cachePainter.setPen(spinBox->palette.foreground().color()); 02488 02489 // plus/minus 02490 if (spinBox->activeSubControls == SC_SpinBoxUp && sunken) { 02491 cachePainter.drawLine(1 + centerX - 2, 1 + centerY, 1 + centerX + 2, 1 + centerY); 02492 cachePainter.drawLine(1 + centerX, 1 + centerY - 2, 1 + centerX, 1 + centerY + 2); 02493 } else { 02494 cachePainter.drawLine(centerX - 2, centerY, centerX + 2, centerY); 02495 cachePainter.drawLine(centerX, centerY - 2, centerX, centerY + 2); 02496 } 02497 02498 centerX = downRect.center().x(); 02499 centerY = downRect.center().y(); 02500 if (spinBox->activeSubControls == SC_SpinBoxDown && sunken) { 02501 cachePainter.drawLine(1 + centerX - 2, 1 + centerY, 1 + centerX + 2, 1 + centerY); 02502 } else { 02503 cachePainter.drawLine(centerX - 2, centerY, centerX + 2, centerY); 02504 } 02505 } else { 02506 // arrows 02507 QImage upArrow(qt_spinbox_button_arrow_up); 02508 upArrow.setColor(1, spinBox->palette.foreground().color().rgba()); 02509 02510 cachePainter.drawImage(upRect.center().x() - upArrow.width() / 2, 02511 upRect.center().y() - upArrow.height() / 2, 02512 upArrow); 02513 02514 QImage downArrow(qt_spinbox_button_arrow_down); 02515 downArrow.setColor(1, spinBox->palette.foreground().color().rgba()); 02516 02517 cachePainter.drawImage(downRect.center().x() - downArrow.width() / 2, 02518 downRect.center().y() - downArrow.height() / 2 + 1, 02519 downArrow); 02520 } 02521 02522 QColor disabledColor = option->palette.background().color(); 02523 disabledColor.setAlpha(150); 02524 if (!(spinBox->stepEnabled & QAbstractSpinBox::StepUpEnabled)) 02525 cachePainter.fillRect(upRect, disabledColor); 02526 if (!(spinBox->stepEnabled & QAbstractSpinBox::StepDownEnabled)) 02527 cachePainter.fillRect(downRect.adjusted(0, 0, 0, 1), disabledColor); 02528 02529 cachePainter.end(); 02530 if (UsePixmapCache) 02531 QPixmapCache::insert(pixmapName, cache); 02532 } 02533 painter->drawPixmap(spinBox->rect.topLeft(), cache); 02534 } 02535 break; 02536 #endif // QT_NO_SPINBOX 02537 case CC_TitleBar: 02538 painter->save(); 02539 if (const QStyleOptionTitleBar *titleBar = qstyleoption_cast<const QStyleOptionTitleBar *>(option)) { 02540 bool active = (titleBar->titleBarState & State_Active); 02541 QRect fullRect = titleBar->rect; 02542 QPalette palette = option->palette; 02543 QColor highlight = option->palette.highlight().color(); 02544 02545 QColor titleBarGradientStart(active ? highlight: palette.background().color()); 02546 QColor titleBarGradientStop(active ? highlight.dark(150): palette.background().color().dark(120)); 02547 QColor titleBarFrameBorder(active ? highlight.dark(180): dark.dark(110)); 02548 QColor titleBarHighlight(active ? highlight.light(120): palette.background().color().light(120)); 02549 QColor textColor(active ? 0xffffff : 0xff000000); 02550 QColor textAlphaColor(active ? 0xffffff : 0xff000000 ); 02551 02552 // Fill titlebar gradient 02553 qt_cleanlooks_draw_gradient(painter, option->rect.adjusted(1, 1, -1, 0), 02554 titleBarGradientStart, 02555 titleBarGradientStop, TopDown, active ? highlight : palette.background().color()); 02556 02557 // Frame and rounded corners 02558 painter->setPen(titleBarFrameBorder); 02559 02560 // top outline 02561 painter->drawLine(fullRect.left() + 5, fullRect.top(), fullRect.right() - 5, fullRect.top()); 02562 painter->drawLine(fullRect.left(), fullRect.top() + 4, fullRect.left(), fullRect.bottom()); 02563 painter->drawPoint(fullRect.left() + 4, fullRect.top() + 1); 02564 painter->drawPoint(fullRect.left() + 3, fullRect.top() + 1); 02565 painter->drawPoint(fullRect.left() + 2, fullRect.top() + 2); 02566 painter->drawPoint(fullRect.left() + 1, fullRect.top() + 3); 02567 painter->drawPoint(fullRect.left() + 1, fullRect.top() + 4); 02568 02569 painter->drawLine(fullRect.right(), fullRect.top() + 4, fullRect.right(), fullRect.bottom()); 02570 painter->drawPoint(fullRect.right() - 3, fullRect.top() + 1); 02571 painter->drawPoint(fullRect.right() - 4, fullRect.top() + 1); 02572 painter->drawPoint(fullRect.right() - 2, fullRect.top() + 2); 02573 painter->drawPoint(fullRect.right() - 1, fullRect.top() + 3); 02574 painter->drawPoint(fullRect.right() - 1, fullRect.top() + 4); 02575 02576 // draw bottomline 02577 painter->drawLine(fullRect.right(), fullRect.bottom(), fullRect.left(), fullRect.bottom()); 02578 02579 // top highlight 02580 painter->setPen(titleBarHighlight); 02581 painter->drawLine(fullRect.left() + 6, fullRect.top() + 1, fullRect.right() - 6, fullRect.top() + 1); 02582 02583 // draw title 02584 QRect textRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarLabel, widget); 02585 QFont font = painter->font(); 02586 font.setBold(true); 02587 painter->setFont(font); 02588 painter->setPen(active? (titleBar->palette.text().color().light(120)) : 02589 titleBar->palette.text().color() ); 02590 painter->drawText(textRect.adjusted(1, 1, 1, 1), titleBar->text, QTextOption(Qt::AlignHCenter | Qt::AlignVCenter)); 02591 painter->setPen(Qt::white); 02592 if (active) 02593 painter->drawText(textRect, titleBar->text, QTextOption(Qt::AlignHCenter | Qt::AlignVCenter)); 02594 02595 // min button 02596 if ((titleBar->subControls & SC_TitleBarMinButton) && (titleBar->titleBarFlags & Qt::WindowMinimizeButtonHint)) { 02597 bool hover = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_MouseOver); 02598 bool sunken = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_Sunken); 02599 QRect minButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarMinButton, widget); 02600 qt_cleanlooks_draw_mdibutton(painter, titleBar, minButtonRect, hover, sunken); 02601 02602 int xoffset = 5; 02603 int yoffset = 5; 02604 02605 QRect minButtonIconRect(minButtonRect.left() + xoffset, minButtonRect.top() + yoffset, 02606 minButtonRect.width() - xoffset * 2, minButtonRect.height() - yoffset * 2); 02607 02608 painter->setPen(textColor); 02609 painter->drawLine(minButtonIconRect.center().x() - 2, minButtonIconRect.center().y() + 3, 02610 minButtonIconRect.center().x() + 3, minButtonIconRect.center().y() + 3); 02611 painter->drawLine(minButtonIconRect.center().x() - 2, minButtonIconRect.center().y() + 4, 02612 minButtonIconRect.center().x() + 3, minButtonIconRect.center().y() + 4); 02613 painter->setPen(textAlphaColor); 02614 painter->drawLine(minButtonIconRect.center().x() - 3, minButtonIconRect.center().y() + 3, 02615 minButtonIconRect.center().x() - 3, minButtonIconRect.center().y() + 4); 02616 painter->drawLine(minButtonIconRect.center().x() + 4, minButtonIconRect.center().y() + 3, 02617 minButtonIconRect.center().x() + 4, minButtonIconRect.center().y() + 4); 02618 } 02619 02620 // max button 02621 if ((titleBar->subControls & SC_TitleBarMaxButton) && (titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint)) { 02622 bool hover = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_MouseOver); 02623 bool sunken = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_Sunken); 02624 QRect maxButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarMaxButton, widget); 02625 qt_cleanlooks_draw_mdibutton(painter, titleBar, maxButtonRect, hover, sunken); 02626 02627 int xoffset = maxButtonRect.width() / 3; 02628 int yoffset = maxButtonRect.height() / 3; 02629 02630 QRect maxButtonIconRect(maxButtonRect.left() + xoffset, maxButtonRect.top() + yoffset, 02631 maxButtonRect.width() - xoffset * 2, maxButtonRect.height() - yoffset * 2); 02632 02633 painter->setPen(textColor); 02634 painter->drawRect(maxButtonIconRect.adjusted(0, 0, -1, -1)); 02635 painter->drawLine(maxButtonIconRect.left() + 1, maxButtonIconRect.top() + 1, 02636 maxButtonIconRect.right() - 1, maxButtonIconRect.top() + 1); 02637 painter->setPen(textAlphaColor); 02638 painter->drawPoint(maxButtonIconRect.topLeft()); 02639 painter->drawPoint(maxButtonIconRect.topRight()); 02640 painter->drawPoint(maxButtonIconRect.bottomLeft()); 02641 painter->drawPoint(maxButtonIconRect.bottomRight()); 02642 } 02643 02644 // close button 02645 if (titleBar->subControls & SC_TitleBarCloseButton) { 02646 bool hover = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_MouseOver); 02647 bool sunken = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_Sunken); 02648 QRect closeButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarCloseButton, widget); 02649 qt_cleanlooks_draw_mdibutton(painter, titleBar, closeButtonRect, hover, sunken); 02650 02651 int xoffset = 5; 02652 int yoffset = 5; 02653 02654 QRect closeIconRect(closeButtonRect.left() + xoffset, closeButtonRect.top() + yoffset, 02655 closeButtonRect.width() - xoffset * 2, closeButtonRect.height() - yoffset * 2); 02656 02657 painter->setPen(textAlphaColor); 02658 painter->drawLine(closeIconRect.left() + 1, closeIconRect.top(), 02659 closeIconRect.right(), closeIconRect.bottom() - 1); 02660 painter->drawLine(closeIconRect.left(), closeIconRect.top() + 1, 02661 closeIconRect.right() - 1, closeIconRect.bottom()); 02662 painter->drawLine(closeIconRect.right() - 1, closeIconRect.top(), 02663