void Style::drawComboBox(const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const { ASSURE_OPTION(cmb, ComboBox); B_STATES if ( widget && widget->inherits("WebView") ) { if (!(config.btn.backLightHover || cmb->editable)) { // paints hardcoded black text bypassing the style?! grrr... QStyleOptionComboBox *_cmb = const_cast<QStyleOptionComboBox*>(cmb); _cmb->palette.setColor(config.btn.std_role[Bg], QColor(230,230,230,255)); _cmb->palette.setColor(config.btn.active_role[Bg], QColor(255,255,255,255)); } widget = 0; } const int f1 = F(1), f2 = F(2); QRect ar; const QComboBox *combo = widget ? qobject_cast<const QComboBox*>(widget) : 0; QColor c = CONF_COLOR(btn.std, Bg); const bool listShown = combo && combo->view() && ((QWidget*)(combo->view()))->isVisible(); if (listShown) // this messes up hover hover = hover || QRect(widget->mapToGlobal(RECT.topLeft()), RECT.size()).contains(QCursor::pos()); if (isEnabled && (cmb->subControls & SC_ComboBoxArrow) && (!combo || combo->count() > 0)) { // do we have an arrow? ar = subControlRect(CC_ComboBox, cmb, SC_ComboBoxArrow, widget); ar.setBottom(ar.bottom()-f2); } // the frame if ((cmb->subControls & SC_ComboBoxFrame) && cmb->frame) { if (cmb->editable) drawLineEdit(option, painter, widget, false); else { if (!ar.isNull()) { animStep = (appType == GTK || !widget) ? 6*hover : Animator::Hover::step(widget); if (listShown) animStep = 6; int btn_layer = config.btn.layer; Gradients::Type btn_grd = config.btn.gradient; config.btn.round = !config.btn.round; const bool comboNotSmallerThanTool = config.chooser.layer == Raised || config.chooser.layer == Inlay || config.btn.tool.frame == Sunken || config.btn.tool.frame == Relief; if (comboNotSmallerThanTool && widget && qobject_cast<QToolBar*>(widget->parentWidget())) { GRAD(btn) = GRAD(btn.tool); config.btn.layer = config.btn.tool.frame; } else { GRAD(btn) = GRAD(chooser); config.btn.layer = config.chooser.layer; } drawButtonFrame(option, painter, widget, animStep); config.btn.round = !config.btn.round; config.btn.layer = btn_layer; config.btn.gradient = btn_grd; } else shadows.sunken[!config.btn.round][isEnabled].render(RECT, painter); } } // the arrow if (!ar.isNull()) { if (!(ar.width()%2) ) ar.setWidth(ar.width()-1); const int dy = ar.height()/4; QRect rect = ar.adjusted(0, dy, 0, -dy); Navi::Direction dir = Navi::S; bool upDown = false; if (listShown) dir = (config.leftHanded) ? Navi::E : Navi::W; else if (combo) { if (combo->currentIndex() == 0) dir = Navi::S; else if (combo->currentIndex() == combo->count()-1) dir = Navi::N; else upDown = true; } painter->save(); painter->setPen(Qt::NoPen); if (cmb->editable) { if (upDown || dir == Navi::N) dir = Navi::S; upDown = false; // shall never look like spinbox! hover = hover && (cmb->activeSubControls == SC_ComboBoxArrow); if (!sunken) { painter->setBrush(FCOLOR(Base).dark(105)); rect.translate(0, f2); drawArrow(dir, rect, painter); rect.translate(0, -f2); } if (hover || listShown) painter->setBrush(FCOLOR(Highlight)); else painter->setBrush( Colors::mid(FCOLOR(Base), FCOLOR(Text)) ); } else if (config.btn.backLightHover) painter->setBrush(Colors::mid(c, CONF_COLOR(btn.std, Fg), 6-animStep, 3+animStep)); else { c = Colors::mid(c, CONF_COLOR(btn.active, Bg)); c = Colors::mid(c, CONF_COLOR(btn.active, Bg), 6-animStep, animStep); masks.rect[!config.btn.round].render(ar, painter, GRAD(chooser), ori[1], c, RECT.height()-f2, QPoint(0, ar.y() - RECT.y()) ); painter->setBrush(Colors::mid(c, CONF_COLOR(btn.active, Fg), 1,2)); } if (upDown) { rect.setBottom(rect.y() + rect.height()/2); rect.translate(0, -1); drawArrow(Navi::N, rect, painter); rect.translate(0, rect.height()); drawArrow(Navi::S, rect, painter); } else { if (dir == Navi::N) // loooks unbalanced otherwise rect.translate(0, -f1); drawArrow(dir, rect, painter); } painter->restore(); } }
void WindowsModernStyle::drawComplexControl( ComplexControl control, const QStyleOptionComplex* option, QPainter* painter, const QWidget* widget ) const { switch ( control ) { case CC_ToolButton: { QToolBar* toolBar; if ( widget && ( toolBar = qobject_cast<QToolBar*>( widget->parentWidget() ) ) ) { if ( const QStyleOptionToolButton* optionToolButton = qstyleoption_cast<const QStyleOptionToolButton*>( option ) ) { QRect buttonRect = subControlRect( control, option, SC_ToolButton, widget ); QStyle::State buttonState = option->state & ~State_Sunken; if ( option->state & State_Sunken ) { if ( optionToolButton->activeSubControls & SC_ToolButton ) buttonState |= State_Sunken; else if ( optionToolButton->activeSubControls & SC_ToolButtonMenu ) buttonState |= State_MouseOver; } bool selected = buttonState & State_MouseOver && option->state & State_Enabled; bool checked = buttonState & State_On; bool sunken = buttonState & State_Sunken; if ( selected || checked || sunken ) { QRect rect = buttonRect.adjusted( 0, 0, -1, -1 ); painter->setPen( m_colorItemBorder ); QLinearGradient gradient; if ( toolBar->orientation() == Qt::Vertical ) gradient = QLinearGradient( rect.topLeft(), rect.topRight() ); else gradient = QLinearGradient( rect.topLeft(), rect.bottomLeft() ); if ( sunken || (selected && checked) ) { gradient.setColorAt( 0.0, m_colorItemSunkenBegin ); gradient.setColorAt( 0.5, m_colorItemSunkenMiddle ); gradient.setColorAt( 1.0, m_colorItemSunkenEnd ); } else if ( checked ) { gradient.setColorAt( 0.0, m_colorItemCheckedBegin ); gradient.setColorAt( 0.5, m_colorItemCheckedMiddle ); gradient.setColorAt( 1.0, m_colorItemCheckedEnd ); } else { gradient.setColorAt( 0.0, m_colorItemBackgroundBegin ); gradient.setColorAt( 0.5, m_colorItemBackgroundMiddle ); gradient.setColorAt( 1.0, m_colorItemBackgroundEnd ); } painter->setBrush( gradient ); painter->drawRect( rect ); } QStyleOptionToolButton optionLabel = *optionToolButton; int fw = pixelMetric( PM_DefaultFrameWidth, option, widget ); optionLabel.rect = buttonRect.adjusted( fw, fw, -fw, -fw ); drawControl( CE_ToolButtonLabel, &optionLabel, painter, widget ); if ( optionToolButton->subControls & SC_ToolButtonMenu ) { QStyleOption optionMenu = *optionToolButton; optionMenu.rect = subControlRect( control, option, SC_ToolButtonMenu, widget ); optionMenu.state = optionToolButton->state & ~State_Sunken; if ( optionToolButton->state & State_Sunken ) { if ( optionToolButton->activeSubControls & SC_ToolButton ) optionMenu.state |= State_MouseOver | State_Sunken; else if ( optionToolButton->activeSubControls & SC_ToolButtonMenu ) optionMenu.state |= State_Sunken; } drawPrimitive( PE_IndicatorButtonDropDown, &optionMenu, painter, widget ); } else if ( optionToolButton->features & QStyleOptionToolButton::HasMenu ) { int size = pixelMetric( PM_MenuButtonIndicator, option, widget ); QRect rect = optionToolButton->rect; QStyleOptionToolButton optionArrow = *optionToolButton; optionArrow.rect = QRect( rect.right() + 4 - size, rect.height() - size + 4, size - 5, size - 5 ); drawPrimitive( PE_IndicatorArrowDown, &optionArrow, painter, widget ); } return; } } break; } default: break; } if ( useVista() ) QWindowsVistaStyle::drawComplexControl( control, option, painter, widget ); else QWindowsXPStyle::drawComplexControl( control, option, painter, widget ); }
void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const { if (!panelWidget(widget)) return QProxyStyle::drawComplexControl(control, option, painter, widget); QRect rect = option->rect; switch (control) { case CC_ToolButton: if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { bool reverse = option->direction == Qt::RightToLeft; bool drawborder = (widget && widget->property("showborder").toBool()); if (drawborder) drawButtonSeparator(painter, rect, reverse); QRect button, menuarea; button = subControlRect(control, toolbutton, SC_ToolButton, widget); menuarea = subControlRect(control, toolbutton, SC_ToolButtonMenu, widget); State bflags = toolbutton->state; if (bflags & State_AutoRaise) { if (!(bflags & State_MouseOver)) bflags &= ~State_Raised; } State mflags = bflags; if (toolbutton->state & State_Sunken) { if (toolbutton->activeSubControls & SC_ToolButton) bflags |= State_Sunken; if (toolbutton->activeSubControls & SC_ToolButtonMenu) mflags |= State_Sunken; } QStyleOption tool(0); tool.palette = toolbutton->palette; if (toolbutton->subControls & SC_ToolButton) { tool.rect = button; tool.state = bflags; drawPrimitive(PE_PanelButtonTool, &tool, painter, widget); } QStyleOptionToolButton label = *toolbutton; label.palette = panelPalette(option->palette, lightColored(widget)); int fw = pixelMetric(PM_DefaultFrameWidth, option, widget); label.rect = button.adjusted(fw, fw, -fw, -fw); drawControl(CE_ToolButtonLabel, &label, painter, widget); if (toolbutton->subControls & SC_ToolButtonMenu) { tool.state = mflags; tool.rect = menuarea.adjusted(1, 1, -1, -1); if (mflags & (State_Sunken | State_On | State_Raised)) { painter->setPen(Qt::gray); painter->drawLine(tool.rect.topLeft(), tool.rect.bottomLeft()); if (mflags & (State_Sunken)) { QColor shade(0, 0, 0, 50); painter->fillRect(tool.rect.adjusted(0, -1, 1, 1), shade); } else if (!Utils::HostOsInfo::isMacHost() && (mflags & State_MouseOver)) { QColor shade(255, 255, 255, 50); painter->fillRect(tool.rect.adjusted(0, -1, 1, 1), shade); } } tool.rect = tool.rect.adjusted(2, 2, -2, -2); drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget); } else if (toolbutton->features & QStyleOptionToolButton::HasMenu && !widget->property("noArrow").toBool()) { int arrowSize = 6; QRect ir = toolbutton->rect.adjusted(1, 1, -1, -1); QStyleOptionToolButton newBtn = *toolbutton; newBtn.palette = panelPalette(option->palette); newBtn.rect = QRect(ir.right() - arrowSize - 1, ir.height() - arrowSize - 2, arrowSize, arrowSize); drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget); } } break; case CC_ComboBox: if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { painter->save(); bool isEmpty = cb->currentText.isEmpty() && cb->currentIcon.isNull(); bool reverse = option->direction == Qt::RightToLeft; bool drawborder = !(widget && widget->property("hideborder").toBool()); bool alignarrow = !(widget && widget->property("alignarrow").toBool()); if (drawborder) drawButtonSeparator(painter, rect, reverse); QStyleOption toolbutton = *option; if (isEmpty) toolbutton.state &= ~(State_Enabled | State_Sunken); painter->save(); if (drawborder) painter->setClipRect(toolbutton.rect.adjusted(0, 0, -2, 0)); drawPrimitive(PE_PanelButtonTool, &toolbutton, painter, widget); painter->restore(); // Draw arrow int menuButtonWidth = 12; int left = !reverse ? rect.right() - menuButtonWidth : rect.left(); int right = !reverse ? rect.right() : rect.left() + menuButtonWidth; QRect arrowRect((left + right) / 2 + (reverse ? 6 : -6), rect.center().y() - 3, 9, 9); if (!alignarrow) { int labelwidth = option->fontMetrics.width(cb->currentText); if (reverse) arrowRect.moveLeft(qMax(rect.width() - labelwidth - menuButtonWidth - 2, 4)); else arrowRect.moveLeft(qMin(labelwidth + menuButtonWidth - 2, rect.width() - menuButtonWidth - 4)); } if (option->state & State_On) arrowRect.translate(QProxyStyle::pixelMetric(PM_ButtonShiftHorizontal, option, widget), QProxyStyle::pixelMetric(PM_ButtonShiftVertical, option, widget)); QStyleOption arrowOpt = *option; arrowOpt.rect = arrowRect; if (isEmpty) arrowOpt.state &= ~(State_Enabled | State_Sunken); if (styleHint(SH_ComboBox_Popup, option, widget)) { arrowOpt.rect.translate(0, -3); drawPrimitive(PE_IndicatorArrowUp, &arrowOpt, painter, widget); arrowOpt.rect.translate(0, 6); drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, painter, widget); } else { drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, painter, widget); } painter->restore(); } break; default: QProxyStyle::drawComplexControl(control, option, painter, widget); break; } }
void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { if (!panelWidget(widget)) return QProxyStyle::drawControl(element, option, painter, widget); switch (element) { case CE_Splitter: painter->fillRect(option->rect, Utils::StyleHelper::borderColor()); break; case CE_TabBarTabShape: // Most styles draw a single dark outline. This looks rather ugly when combined with our // single pixel dark separator so we adjust the first tab to compensate for this if (const QStyleOptionTabV3 *tab = qstyleoption_cast<const QStyleOptionTabV3 *>(option)) { QStyleOptionTabV3 adjustedTab = *tab; if (tab->cornerWidgets == QStyleOptionTab::NoCornerWidgets && ( tab->position == QStyleOptionTab::Beginning || tab->position == QStyleOptionTab::OnlyOneTab)) { if (option->direction == Qt::LeftToRight) adjustedTab.rect = adjustedTab.rect.adjusted(-1, 0, 0, 0); else adjustedTab.rect = adjustedTab.rect.adjusted(0, 0, 1 ,0); } QProxyStyle::drawControl(element, &adjustedTab, painter, widget); return; } break; case CE_MenuBarItem: painter->save(); if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { QColor highlightOutline = Utils::StyleHelper::borderColor().lighter(120); bool act = mbi->state & State_Sunken; bool dis = !(mbi->state & State_Enabled); Utils::StyleHelper::menuGradient(painter, option->rect, option->rect); QStyleOptionMenuItem item = *mbi; item.rect = mbi->rect; QPalette pal = mbi->palette; pal.setBrush(QPalette::ButtonText, dis ? Qt::gray : Qt::black); item.palette = pal; QCommonStyle::drawControl(element, &item, painter, widget); QRect r = option->rect; if (act) { // Fill| QColor baseColor = Utils::StyleHelper::baseColor(); QLinearGradient grad(option->rect.topLeft(), option->rect.bottomLeft()); grad.setColorAt(0, baseColor.lighter(120)); grad.setColorAt(1, baseColor.lighter(130)); painter->fillRect(option->rect.adjusted(1, 1, -1, 0), grad); // Outline painter->setPen(QPen(highlightOutline, 0)); painter->drawLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom())); painter->drawLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom())); painter->drawLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top())); highlightOutline.setAlpha(60); painter->setPen(QPen(highlightOutline, 0)); painter->drawPoint(r.topLeft()); painter->drawPoint(r.topRight()); QPalette pal = mbi->palette; uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; if (!styleHint(SH_UnderlineShortcut, mbi, widget)) alignment |= Qt::TextHideMnemonic; pal.setBrush(QPalette::Text, dis ? Qt::gray : QColor(0, 0, 0, 60)); drawItemText(painter, item.rect.translated(0, 1), alignment, pal, mbi->state & State_Enabled, mbi->text, QPalette::Text); pal.setBrush(QPalette::Text, dis ? Qt::gray : Qt::white); drawItemText(painter, item.rect, alignment, pal, mbi->state & State_Enabled, mbi->text, QPalette::Text); } } painter->restore(); break; case CE_ComboBoxLabel: if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { if (panelWidget(widget)) { painter->save(); QRect editRect = subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget); QPalette customPal = cb->palette; bool drawIcon = !(widget && widget->property("hideicon").toBool()); if (!cb->currentIcon.isNull() && drawIcon) { QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal : QIcon::Disabled; QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode); QRect iconRect(editRect); iconRect.setWidth(cb->iconSize.width() + 4); iconRect = alignedRect(cb->direction, Qt::AlignLeft | Qt::AlignVCenter, iconRect.size(), editRect); if (cb->editable) painter->fillRect(iconRect, customPal.brush(QPalette::Base)); drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap); if (cb->direction == Qt::RightToLeft) editRect.translate(-4 - cb->iconSize.width(), 0); else editRect.translate(cb->iconSize.width() + 4, 0); // Reserve some space for the down-arrow editRect.adjust(0, 0, -13, 0); } QLatin1Char asterisk('*'); int elideWidth = editRect.width(); bool notElideAsterisk = widget && widget->property("notelideasterisk").toBool() && cb->currentText.endsWith(asterisk) && option->fontMetrics.width(cb->currentText) > elideWidth; QString text; if (notElideAsterisk) { elideWidth -= option->fontMetrics.width(asterisk); text = asterisk; } text.prepend(option->fontMetrics.elidedText(cb->currentText, Qt::ElideRight, elideWidth)); if ((option->state & State_Enabled)) { painter->setPen(QColor(0, 0, 0, 70)); painter->drawText(editRect.adjusted(1, 0, -1, 0), Qt::AlignLeft | Qt::AlignVCenter, text); } else { painter->setOpacity(0.8); } painter->setPen(Utils::StyleHelper::panelTextColor()); painter->drawText(editRect.adjusted(1, 0, -1, 0), Qt::AlignLeft | Qt::AlignVCenter, text); painter->restore(); } else { QProxyStyle::drawControl(element, option, painter, widget); } } break; case CE_SizeGrip: { painter->save(); QColor dark = Qt::white; dark.setAlphaF(0.1); int x, y, w, h; option->rect.getRect(&x, &y, &w, &h); int sw = qMin(h, w); if (h > w) painter->translate(0, h - w); else painter->translate(w - h, 0); int sx = x; int sy = y; int s = 4; painter->setPen(dark); if (option->direction == Qt::RightToLeft) { sx = x + sw; for (int i = 0; i < 4; ++i) { painter->drawLine(x, sy, sx, sw); sx -= s; sy += s; } } else { for (int i = 0; i < 4; ++i) { painter->drawLine(sx, sw, sw, sy); sx += s; sy += s; } } painter->restore(); } break; case CE_MenuBarEmptyArea: { Utils::StyleHelper::menuGradient(painter, option->rect, option->rect); painter->save(); painter->setPen(Utils::StyleHelper::borderColor()); painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight()); painter->restore(); } break; case CE_ToolBar: { QRect rect = option->rect; bool horizontal = option->state & State_Horizontal; rect = option->rect; // Map offset for global window gradient QPoint offset = widget->window()->mapToGlobal(option->rect.topLeft()) - widget->mapToGlobal(option->rect.topLeft()); QRect gradientSpan; if (widget) gradientSpan = QRect(offset, widget->window()->size()); bool drawLightColored = lightColored(widget); if (horizontal) Utils::StyleHelper::horizontalGradient(painter, gradientSpan, rect, drawLightColored); else Utils::StyleHelper::verticalGradient(painter, gradientSpan, rect, drawLightColored); if (!drawLightColored) painter->setPen(Utils::StyleHelper::borderColor()); else painter->setPen(QColor(0x888888)); if (horizontal) { // Note: This is a hack to determine if the // toolbar should draw the top or bottom outline // (needed for the find toolbar for instance) QColor lighter(Utils::StyleHelper::sidebarHighlight()); if (drawLightColored) lighter = QColor(255, 255, 255, 180); if (widget && widget->property("topBorder").toBool()) { painter->drawLine(rect.topLeft(), rect.topRight()); painter->setPen(lighter); painter->drawLine(rect.topLeft() + QPoint(0, 1), rect.topRight() + QPoint(0, 1)); } else { painter->drawLine(rect.bottomLeft(), rect.bottomRight()); painter->setPen(lighter); painter->drawLine(rect.topLeft(), rect.topRight()); } } else { painter->drawLine(rect.topLeft(), rect.bottomLeft()); painter->drawLine(rect.topRight(), rect.bottomRight()); } } break; default: QProxyStyle::drawControl(element, option, painter, widget); break; } }
void Style::drawComboBox(const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const { ASSURE_OPTION(cmb, ComboBox); OPT_ENABLED OPT_HOVER OPT_FOCUS SAVE_PAINTER(Pen|Brush|Alias); if ( widget && widget->inherits("WebView") ) { // paints hardcoded black text bypassing the style?! grrr... const_cast<QStyleOptionComboBox*>(cmb)->palette.setColor(QPalette::Window, QColor(230,230,230,255)); widget = 0; } animStep = !widget ? MAX_STEPS*hover : Animator::Hover::step(widget); QRect ar; const QComboBox *combo = widget ? qobject_cast<const QComboBox*>(widget) : NULL; if ((cmb->subControls & SC_ComboBoxArrow) && (!combo || combo->count() > 0)) { // do we have an arrow? ar = subControlRect(CC_ComboBox, cmb, SC_ComboBoxArrow, widget); const int dx = (F(2) & ~1) / 2; ar.translate(cmb->direction == Qt::LeftToRight ? -dx : dx, 0); } const bool listShown = combo && combo->view() && ((QWidget*)(combo->view()))->isVisible(); if (listShown) { // this messes up hover hover = hover || QRect(widget->mapToGlobal(RECT.topLeft()), RECT.size()).contains(QCursor::pos()); // TODO Qt5, avoid asking for the cursor pos animStep = MAX_STEPS; } QColor c = hasFocus ? FCOLOR(Highlight) : (cmb->editable ? FCOLOR(Text) : FCOLOR(WindowText)); if (cmb->editable) { drawLineEditFrame(option, painter, widget); c = FX::blend(FCOLOR(Base), c, MAX_STEPS, 1 + 2*animStep); } else { const int icon = cmb->currentIcon.isNull() ? 0 : cmb->iconSize.width() + F(4); QFont fnt(painter->font()); fnt.setBold(true); int text = QFontMetrics(fnt).width(cmb->currentText); if (text) text += F(4); if (!(text+icon)) // webkit etc. text = ar.left() - (F(16) + RECT.x()); painter->setRenderHint(QPainter::Antialiasing, true); painter->setPen(QPen(hasFocus ? FCOLOR(Highlight) : FX::blend(FCOLOR(Window), c, 4, 1), FRAME_STROKE)); painter->setBrush(Qt::NoBrush); const int y = ar.y() + ar.height()/2; const int da = animStep * 168 / MAX_STEPS; if (option->direction == Qt::LeftToRight) { DRAW_SEGMENT(ar, 16*(120 - da/2), 16*(192+da)); painter->drawLine(RECT.x() + icon + text + F(6), y, ar.left()-F(2), y); } else { DRAW_SEGMENT(ar, 16*(30 + da/2), -16*(192+da)); painter->drawLine(RECT.right() - (icon + text + F(6)), y, ar.right()+F(2), y); } c = FX::blend(FCOLOR(Window), FCOLOR(WindowText), MAX_STEPS - animStep, 1 + animStep); } if (!isEnabled) { RESTORE_PAINTER return; }
void KWaitStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const { switch (control) { case CC_Slider: { if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { QRect groove = subControlRect(CC_Slider, option, SC_SliderGroove, widget); QRect handle = subControlRect(CC_Slider, option, SC_SliderHandle, widget); painter->save(); bool hover = (slider->state & State_Enabled) && (slider->state & State_MouseOver); if (hover) { QRect moderated = widget->rect().adjusted(0, 4, 0, -4); drawHoverRect(painter, moderated, option->palette.background()); } if ((option->subControls & SC_SliderGroove) && groove.isValid()) { QPixmap grv = cached(":dwaitstyle/images/slider_bar.png", option->palette.color(QPalette::Background)); painter->drawPixmap(QRect(groove.x() + 5, groove.y(), groove.width() - 10, grv.height()), grv); } if ((option->subControls & SC_SliderHandle) && handle.isValid()) { QPixmap hndl = cached(":dwaitstyle/images/slider_thumb_on.png", option->palette.color(QPalette::Background)); painter->drawPixmap(handle.topLeft(), hndl); } painter->restore(); } else { QPlastiqueStyle::drawComplexControl(control, option, painter, widget); } break; } case CC_GroupBox: { const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option); if (groupBox) { QStyleOptionGroupBox groupBoxCopy(*groupBox); groupBoxCopy.subControls &= ~SC_GroupBoxLabel; QPlastiqueStyle::drawComplexControl(control, &groupBoxCopy, painter, widget); if (groupBox->subControls & SC_GroupBoxLabel) { const QRect &r = groupBox->rect; QPixmap titleLeft = cached(":dwaitstyle/images/title_cap_left.png", option->palette.color(QPalette::Background)); QPixmap titleRight = cached(":dwaitstyle/images/title_cap_right.png", option->palette.color(QPalette::Background)); QPixmap titleStretch = cached(":dwaitstyle/images/title_stretch.png", option->palette.color(QPalette::Background)); int txt_width = groupBox->fontMetrics.width(groupBox->text) + 20; painter->drawPixmap(r.center().x() - txt_width/2, 0, titleLeft); QRect tileRect = subControlRect(control, groupBox, SC_GroupBoxLabel, widget); painter->drawTiledPixmap(tileRect, titleStretch); painter->drawPixmap(tileRect.x() + tileRect.width(), 0, titleRight); int opacity = 31; painter->setPen(QColor(0, 0, 0, opacity)); painter->drawText(tileRect.translated(0, 1), Qt::AlignVCenter | Qt::AlignHCenter, groupBox->text); painter->drawText(tileRect.translated(2, 1), Qt::AlignVCenter | Qt::AlignHCenter, groupBox->text); painter->setPen(QColor(0, 0, 0, opacity * 2)); painter->drawText(tileRect.translated(1, 1), Qt::AlignVCenter | Qt::AlignHCenter, groupBox->text); painter->setPen(Qt::white); painter->drawText(tileRect, Qt::AlignVCenter | Qt::AlignHCenter, groupBox->text); } } else { QPlastiqueStyle::drawComplexControl(control, option, painter, widget); } break; } default: QPlastiqueStyle::drawComplexControl(control, option, painter, widget); break; } return; }