void statusAvatarWidget::paintEvent(QPaintEvent* event) { Q_UNUSED(event); QPainter painter(this); QRect r = rect(); QPixmap pixmap = icon().pixmap(sizeHint(), QIcon::Normal, QIcon::On); if(pixmap.isNull()) pixmap = QPixmap(":/icons/resource/avatar.png"); QRect pixRect(0, 0, 32, 32); pixRect.moveCenter(r.center()); painter.drawPixmap(pixRect, pixmap); if(underMouse() && !isDown()) { painter.drawRect(pixRect.adjusted(0, 0, -1, -1)); QColor col(Qt::white); col.setAlpha(80); painter.fillRect(pixRect.adjusted(0, 0, -1, -1), col); } if(isDown()) { QColor col(Qt::white); col.setAlpha(50); painter.drawRect(pixRect.adjusted(1, 1, -2, -2)); } }
QStyleOptionButton TCircleButton::styleOption() const { QStyleOptionButton opt; opt.init(this); if (isEnabled()) opt.state |= QStyle::State_Enabled; if (hasFocus()) opt.state |= QStyle::State_HasFocus; if (isDown()) opt.state |= QStyle::State_Sunken; if (! isFlat() && ! isDown()) opt.state |= QStyle::State_Raised; opt.features = isDefault() ? QStyleOptionButton::DefaultButton : QStyleOptionButton::None; opt.text = text(); opt.icon = icon(); opt.iconSize = QSize(m_diameter,m_diameter); QRect r = rect(); opt.rect = QRect(r.x(),r.y(), m_diameter, m_diameter); return opt; }
void QDockWidgetTitleButton::paintEvent(QPaintEvent *) { QPainter p(this); QRect r = rect(); QStyleOption opt; opt.init(this); opt.state |= QStyle::State_AutoRaise; #ifdef Q_WS_MAC if (!qobject_cast<QMacStyle *>(style())) #endif { if (isEnabled() && underMouse() && !isChecked() && !isDown()) opt.state |= QStyle::State_Raised; if (isChecked()) opt.state |= QStyle::State_On; if (isDown()) opt.state |= QStyle::State_Sunken; style()->drawPrimitive(QStyle::PE_PanelButtonTool, &opt, &p, this); } int shiftHorizontal = opt.state & QStyle::State_Sunken ? style()->pixelMetric(QStyle::PM_ButtonShiftHorizontal, &opt, this) : 0; int shiftVertical = opt.state & QStyle::State_Sunken ? style()->pixelMetric(QStyle::PM_ButtonShiftVertical, &opt, this) : 0; r.adjust(2, 2, -2, -2); r.translate(shiftHorizontal, shiftVertical); QPixmap pm = icon().pixmap(style()->pixelMetric(QStyle::PM_SmallIconSize), isEnabled() ? underMouse() ? QIcon::Active : QIcon::Normal : QIcon::Disabled, isDown() ? QIcon::On : QIcon::Off); style()->drawItemPixmap(&p, r, Qt::AlignCenter, pm); }
void K3bMiniButton::drawButton( QPainter* p ) { p->fillRect( 0,0, width(), height(), QBrush(colorGroup().brush(QColorGroup::Background)) ); p->drawPixmap( (width() - pixmap()->width()) / 2, (height() - pixmap()->height()) / 2, *pixmap() ); if( m_mouseOver && !isDown() ){ p->setPen( white ); p->moveTo( 0, height() - 1 ); p->lineTo( 0, 0 ); p->lineTo( width() - 1, 0 ); p->setPen( colorGroup().dark() ); p->lineTo( width() - 1, height() - 1 ); p->lineTo( 0, height() - 1 ); } if( isOn() || isDown() ){ p->setPen( colorGroup().dark() ); p->moveTo( 0, height() - 1 ); p->lineTo( 0, 0 ); p->lineTo( width() - 1, 0 ); p->setPen( white ); p->lineTo( width() - 1, height() - 1 ); p->lineTo( 0, height() - 1 ); } }
QStyleOptionButton OrientationButton::getStyleOption() const { QStyleOptionButton opt; opt.initFrom(this); if (orientation_ == Qt::Vertical) { QSize size = opt.rect.size(); size.transpose(); opt.rect.setSize(size); } opt.features = QStyleOptionButton::None; if (isFlat()) opt.features |= QStyleOptionButton::Flat; if (menu()) opt.features |= QStyleOptionButton::HasMenu; if (autoDefault() || isDefault()) opt.features |= QStyleOptionButton::AutoDefaultButton; if (isDefault()) opt.features |= QStyleOptionButton::DefaultButton; if (isDown() || (menu() && menu()->isVisible())) opt.state |= QStyle::State_Sunken; if (isChecked()) opt.state |= QStyle::State_On; if (!isFlat() && !isDown()) opt.state |= QStyle::State_Raised; opt.text = text(); opt.icon = icon(); opt.iconSize = iconSize(); return opt; }
void QDockWidgetTitleButton::paintEvent(QPaintEvent *) { QPainter p(this); QStyleOptionToolButton opt; opt.init(this); opt.state |= QStyle::State_AutoRaise; if (style()->styleHint(QStyle::SH_DockWidget_ButtonsHaveFrame, 0, this)) { if (isEnabled() && underMouse() && !isChecked() && !isDown()) opt.state |= QStyle::State_Raised; if (isChecked()) opt.state |= QStyle::State_On; if (isDown()) opt.state |= QStyle::State_Sunken; style()->drawPrimitive(QStyle::PE_PanelButtonTool, &opt, &p, this); } opt.icon = icon(); opt.subControls = 0; opt.activeSubControls = 0; opt.features = QStyleOptionToolButton::None; opt.arrowType = Qt::NoArrow; int size = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this); opt.iconSize = QSize(size, size); style()->drawComplexControl(QStyle::CC_ToolButton, &opt, &p, this); }
void K3DockButton_Private::drawButton( QPainter* p ) { p->fillRect( 0,0, width(), height(), QBrush(QColorGroup(palette()).brush(QPalette::Background)) ); #if 1 // ### TODO: is the centering done automatically or do we need some codelike for KDE3 (see below the #else part) icon().paint( p, rect() ); #else p->drawPixmap( (width() - pixmap()->width()) / 2, (height() - pixmap()->height()) / 2, *pixmap() ); #endif if ( moveMouse && !isDown() ){ p->setPen( Qt::white ); p->drawLine( 0, height() - 1, 0, 0 ); p->drawLine( 0, 0, width() -1 , 0 ); p->setPen( QColorGroup(palette()).dark() ); p->drawLine( width() -1, 0, width() - 1, height() - 1 ); p->drawLine( width() - 1, height() - 1, 0, height() - 1 ); } if ( isChecked() || isDown() ){ p->setPen( QColorGroup(palette()).dark() ); p->drawLine(0 , height() - 1, 0, 0); p->drawLine(0, 0, width() -1 , 0); p->setPen( Qt::white ); p->drawLine(width() - 1, height() - 1, 0, height() - 1); } }
void KDockButton_Private::drawButton( TQPainter* p ) { p->fillRect( 0,0, width(), height(), TQBrush(colorGroup().brush(TQColorGroup::Background)) ); p->drawPixmap( (width() - pixmap()->width()) / 2, (height() - pixmap()->height()) / 2, *pixmap() ); if ( moveMouse && !isDown() ){ p->setPen( white ); p->moveTo( 0, height() - 1 ); p->lineTo( 0, 0 ); p->lineTo( width() - 1, 0 ); p->setPen( colorGroup().dark() ); p->lineTo( width() - 1, height() - 1 ); p->lineTo( 0, height() - 1 ); } if ( isOn() || isDown() ){ p->setPen( colorGroup().dark() ); p->moveTo( 0, height() - 1 ); p->lineTo( 0, 0 ); p->lineTo( width() - 1, 0 ); p->setPen( white ); p->lineTo( width() - 1, height() - 1 ); p->lineTo( 0, height() - 1 ); } }
void ToolButton::drawButtonLabel( QPainter * p ) { if ( m_angleDegrees % 180 == 0 || text().isEmpty() ) { //QToolButton::drawButtonLabel(p); QToolButton::render(p); return; } double dx = size().width()/2; double dy = size().height()/2; p->translate( dx, dy ); p->rotate( m_angleDegrees ); p->translate( -dx, -dy ); p->translate( -dy+dx, 0 ); int m = width() > height() ? width() : height(); p->setPen( Qt::black ); p->drawText( isDown()?1:0, isDown()?1:0, m, m, Qt::AlignVCenter | Qt::AlignHCenter, text() ); p->translate( dy-dx, 0 ); p->translate( dx, dy ); p->rotate( -m_angleDegrees ); p->translate( -dx, -dy ); }
void QuartzButton::drawButton(QPainter *p) { // Never paint if the pixmaps have not been created if (!quartz_initialized) return; QColor c; if (isLeft() ) c = KDecoration::options()->color(KDecoration::ColorTitleBar, decoration()->isActive()).light(130); else c = KDecoration::options()->color(KDecoration::ColorTitleBlend, decoration()->isActive()); // Fill the button background with an appropriate color p->fillRect(0, 0, width(), height(), c ); // If we have a decoration bitmap, then draw that // otherwise we paint a menu button (with mini icon), or a onAllDesktops button. if( deco ) { int xOff = (width()-10)/2; int yOff = (height()-10)/2; p->setPen( Qt::black ); p->drawPixmap(isDown() ? xOff+2: xOff+1, isDown() ? yOff+2 : yOff+1, *deco); p->setPen( KDecoration::options()->color(KDecoration::ColorButtonBg, decoration()->isActive()).light(150) ); p->drawPixmap(isDown() ? xOff+1: xOff, isDown() ? yOff+1 : yOff, *deco); } else { QPixmap btnpix; int Offset = 0; if (type() == OnAllDesktopsButton) { if (isDown()) Offset = 1; // Select the right onAllDesktops button to paint if (decoration()->isActive()) btnpix = isOn() ? *pinDownPix : *pinUpPix; else btnpix = isOn() ? *ipinDownPix : *ipinUpPix; } else btnpix = decoration()->icon().pixmap( QIconSet::Small, QIconSet::Normal); // Shrink the miniIcon for tiny titlebars. if ( height() < 16) { QPixmap tmpPix; // Smooth scale the image tmpPix.convertFromImage( btnpix.convertToImage().smoothScale(height(), height())); p->drawPixmap( 0, 0, tmpPix ); } else { Offset += (height() - 16)/2; p->drawPixmap( Offset, Offset, btnpix ); } } }
void QSanSkillButton::onMouseClick() { if (_m_skill == NULL) return; if ((_m_style == S_STYLE_TOGGLE && isDown() && _m_emitActivateSignal) || _m_style == S_STYLE_PUSH) { emit skill_activated(); emit skill_activated(_m_skill); } else if (!isDown() && _m_emitDeactivateSignal) { emit skill_deactivated(); emit skill_deactivated(_m_skill); } }
void CImgButton::paintEvent( QPaintEvent * e ) { QPainter p( this ); if ( !underMouse() ) { if ( isDown() || isChecked() ) { const QPixmap & pm = image( m_cName, m_cKey ); p.drawPixmap( QPoint( 0, 0 ), pm ); } else { const QPixmap & pm = image( m_uName, m_uKey ); p.drawPixmap( QPoint( 0, 0 ), pm ); } } else { if ( m_hovered ) { if ( isDown() || isChecked() ) { const QPixmap & pm = image( m_chName, m_chKey ); p.drawPixmap( QPoint( 0, 0 ), pm ); } else { const QPixmap & pm = image( m_uhName, m_uhKey ); p.drawPixmap( QPoint( 0, 0 ), pm ); } } else { if ( isDown() || isChecked() ) { const QPixmap & pm = image( m_cName, m_cKey ); p.drawPixmap( QPoint( 0, 0 ), pm ); } else { const QPixmap & pm = image( m_uName, m_uKey ); p.drawPixmap( QPoint( 0, 0 ), pm ); } // А поверх рисуем прямоугольник. QPen pen = QPen( QColor( 170, 170, 210, 150 ) ); QBrush brush = QBrush( QColor( 170, 170, 210, 150 ) ); p.setPen( pen ); p.setBrush( brush ); p.drawRect( QRect( 0, 0, size().width(), size().height() ) ); } } }
/*! \reimp */ void QCommandLinkButton::paintEvent(QPaintEvent *) { Q_D(QCommandLinkButton); QStylePainter p(this); p.save(); QStyleOptionButton option; initStyleOption(&option); //Enable command link appearence on Vista option.features |= QStyleOptionButton::CommandLinkButton; option.text = QString(); option.icon = QIcon(); //we draw this ourselves QSize pixmapSize = icon().actualSize(iconSize()); int vOffset = isDown() ? style()->pixelMetric(QStyle::PM_ButtonShiftVertical) : 0; int hOffset = isDown() ? style()->pixelMetric(QStyle::PM_ButtonShiftHorizontal) : 0; //Draw icon p.drawControl(QStyle::CE_PushButton, option); if (!icon().isNull()) p.drawPixmap(d->leftMargin() + hOffset, d->topMargin() + vOffset, icon().pixmap(pixmapSize, isEnabled() ? QIcon::Normal : QIcon::Disabled, isChecked() ? QIcon::On : QIcon::Off)); //Draw title QColor textColor = palette().buttonText().color(); if (isEnabled() && d->usingVistaStyle()) { textColor = QColor(21, 28, 85); if (underMouse() && !isDown()) textColor = QColor(7, 64, 229); //A simple text color transition d->currentColor = d->mergedColors(textColor, d->currentColor, 60); option.palette.setColor(QPalette::ButtonText, d->currentColor); } int textflags = Qt::TextShowMnemonic; if (!style()->styleHint(QStyle::SH_UnderlineShortcut, &option, this)) textflags |= Qt::TextHideMnemonic; p.setFont(d->titleFont()); p.drawItemText(d->titleRect().translated(hOffset, vOffset), textflags, option.palette, isEnabled(), text(), QPalette::ButtonText); //Draw description textflags |= Qt::TextWordWrap | Qt::ElideRight; p.setFont(d->descriptionFont()); p.drawItemText(d->descriptionRect().translated(hOffset, vOffset), textflags, option.palette, isEnabled(), description(), QPalette::ButtonText); p.restore(); }
void setDisplay(){ if (modechanged){ gotoXY(0,0); sprintf(cha, " Ustaw. wysw.");LcdString(cha, true); gotoXY(0,1); sprintf(cha, EMPTY_LINE);LcdString(cha, false); } gotoXY(0,1); sprintf(cha, "kontrast:");LcdString(cha,false); gotoXY(60,1); sprintf(cha, "%02i", contrast_val);LcdString(cha, (pos_setDisp==0)); gotoXY(0,2); sprintf(cha, "jasnosc:");LcdString(cha,false); gotoXY(60,2); sprintf(cha, "%02i", jasnosc_val);LcdString(cha, (pos_setDisp==1)); gotoXY(0,3); sprintf(cha, "OK");LcdString(cha,(pos_setDisp==2)); if (modechanged){ gotoXY(0,4); sprintf(cha, "<> poprz/nast");LcdString(cha); gotoXY(0,5); sprintf(cha, "^v wart +/-");LcdString(cha); modechanged=false; } if (pos_setDisp==0){ if (isUp()) { contrast_val=obetnij(contrast_val+1, 10, true); LcdInitialise(); } if (isDown()) { contrast_val=obetnij(contrast_val-1, 10, true); LcdInitialise(); } } else if (pos_setDisp==1){ if (isUp()) { jasnosc_val=obetnij(jasnosc_val+1, 50); analogWrite(11, jasnosc_val); } if (isDown()) { jasnosc_val=obetnij(jasnosc_val-1, 50); analogWrite(11, jasnosc_val); } } if (pos_setDisp==2){ if (isPressed()) { mode=1; modechanged=true; LcdClear(); return; } } if (isRight()) pos_setDisp++; if (isLeft()) pos_setDisp--; if (pos_setDisp>2) pos_setDisp=0; if (pos_setDisp<0) pos_setDisp=2; }
void QVistaBackButton::paintEvent(QPaintEvent *) { QPainter p(this); QRect r = rect(); HANDLE theme = pOpenThemeData(0, L"Navigation"); //RECT rect; RECT clipRect; int xoffset = QWidget::mapToParent(r.topLeft()).x() - 1; int yoffset = QWidget::mapToParent(r.topLeft()).y() - 1; clipRect.top = r.top() + yoffset; clipRect.bottom = r.bottom() + yoffset; clipRect.left = r.left() + xoffset; clipRect.right = r.right() + xoffset; int state = WIZ_NAV_BB_NORMAL; if (!isEnabled()) state = WIZ_NAV_BB_DISABLED; else if (isDown()) state = WIZ_NAV_BB_PRESSED; else if (underMouse()) state = WIZ_NAV_BB_HOT; pDrawThemeBackground(theme, p.paintEngine()->getDC(), WIZ_NAV_BACKBUTTON, state, &clipRect, &clipRect); }
void ColorButton::paintEvent ( QPaintEvent * event ) { QColor paintcolor; if(isEnabled()) paintcolor = m_Color; else { if(isDown()) paintcolor = m_Color.lighter(150); else paintcolor = Qt::lightGray; } QPainter painter(this); painter.setBackgroundMode(Qt::TransparentMode); QRect r = rect(); QPen GreyPen(QColor(70,70,70), 1, Qt::DotLine); QBrush colorbrush(paintcolor); painter.setBrush(colorbrush); r.adjust(3,3,-3,-3); painter.setPen(Qt::NoPen); // painter.drawRoundedRect(r, 10, 50, Qt::RelativeSize); painter.drawRect(r); painter.setPen(GreyPen); painter.setBrush(Qt::NoBrush); r.adjust(-1,-1,0,0); // painter.drawRoundedRect(r, 10, 50, Qt::RelativeSize); painter.drawRect(r); }
void SxButton::paintEvent(QPaintEvent *event) { QPoint mousePos = mapFromGlobal(QCursor::pos()); bool selected = rect().contains(mousePos); QPainter painter(this); QRect drawRect = event->rect(); if (drawRect.width() > m_width) { int margin = (drawRect.width() - m_width) / 2; int left = drawRect.left() + margin; drawRect.setLeft(left); drawRect.setWidth(m_width); } if (drawRect.height() > m_height) { int margin = (drawRect.height() - m_height) / 2; int top = drawRect.top() + margin; drawRect.setTop(top); drawRect.setHeight(m_height); } if (isEnabled()) { if (isDown()) painter.drawPixmap(drawRect, m_pixmapDown); else if (selected) painter.drawPixmap(drawRect, m_pixmapSelected); else painter.drawPixmap(drawRect, m_pixmap); } else painter.drawPixmap(drawRect, m_pixmap); }
bool Console::keyDown(keypress key, keymod mod) { if (!isDown()) return false; // If we intercept a toggleConsole() command, then execute it. keypress convertedKey = Input::convertKeycode(key); std::string commandString = bindings.getCommandString(convertedKey); if (commandString == "toggleConsole()") { toggle(); return true; } _textInput.keyDown(key, mod); TextInput::text_input_status status = _textInput.getStatus(); if (status == TextInput::text_input_complete) { // Add the completed string to the history. // Front = top = oldest, // Back = bottom = newest std::string finishedText = _textInput.getText(); write(finishedText); if (_history.size() > _historySize) _history.pop_front(); executeString(finishedText); _textInput.clear(); } else if (status == TextInput::text_input_cancelled) _textInput.clear(); return true; }
void ColorButton::drawButton(QPainter *p) { QStyleOptionButton buttonOptions; buttonOptions.init(this); buttonOptions.features = QStyleOptionButton::None; buttonOptions.rect = rect(); buttonOptions.palette = palette(); buttonOptions.state = (isDown() ? QStyle::State_Sunken : QStyle::State_Raised); if (!mIsFlat) { style()->drawPrimitive(QStyle::PE_PanelButtonBevel, &buttonOptions, p, this); } else { style()->drawPrimitive(QStyle::PE_FrameDefaultButton, &buttonOptions, p, this); } p->save(); drawButtonLabel(p); p->restore(); QStyleOptionFocusRect frectOptions; frectOptions.init(this); frectOptions.rect = style()->subElementRect(QStyle::SE_PushButtonFocusRect, &buttonOptions, this); if (hasFocus()) { style()->drawPrimitive(QStyle::PE_FrameFocusRect, &frectOptions, p, this); } }
void QColorButton::drawButtonLabel( QPainter *painter ) { #if COMPAT_QT_VERSION < 0x030000 QRect r = style().pushButtonContentsRect(this); #else QRect r = style().subRect( QStyle::SR_PushButtonContents, this ); #endif int l = r.x(); int t = r.y(); int w = r.width(); int h = r.height(); int b = 5; QColor lnCol = colorGroup().text(); QColor fillCol = isEnabled() ? col : backgroundColor(); if ( isDown() ) { qDrawPlainRect( painter, l+b+1, t+b+1, w-b*2, h-b*2, lnCol, 1, 0 ); b++; if ( fillCol.isValid() ) painter->fillRect( l+b+1, t+b+1, w-b*2, h-b*2, fillCol ); } else { qDrawPlainRect( painter, l+b, t+b, w-b*2, h-b*2, lnCol, 1, 0 ); b++; if ( fillCol.isValid() ) painter->fillRect( l+b, t+b, w-b*2, h-b*2, fillCol ); } }
void paintEvent(QPaintEvent *e) { if (isChecked()) { QPainter p(this); QColor col(Qt::black); QRect r(rect()); if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_9) { col.setAlphaF(0.1); p.setClipRect(r); p.setRenderHint(QPainter::Antialiasing, true); p.fillPath(Utils::buildPath(r.adjusted(0, 0, 0, 32), 4), col); } else { QLinearGradient bgndGrad(r.topLeft(), r.bottomLeft()); col.setAlphaF(0.01); bgndGrad.setColorAt(0, col); bgndGrad.setColorAt(1, col); col.setAlphaF(0.1); bgndGrad.setColorAt(0.25, col); bgndGrad.setColorAt(0.75, col); p.fillRect(r, bgndGrad); p.setRenderHint(QPainter::Antialiasing, true); col.setAlphaF(0.25); drawFadedLine(&p, QRect(r.x(), r.y(), r.x(), r.y()+r.height()-1), col, false, 0.25); drawFadedLine(&p, QRect(r.x()+r.width()-1, r.y(), r.x()+1, r.y()+r.height()-1), col, false, 0.25); } } QStylePainter p(this); QStyleOptionToolButton opt; initStyleOption(&opt); if (isDown()) { opt.state&=QStyle::State_Sunken; } p.drawComplexControl(QStyle::CC_ToolButton, opt); }
void KColorButton::drawButtonLabel(QPainter *painter) { int x, y, w, h; QRect r = style().subRect(QStyle::SR_PushButtonContents, this); r.rect(&x, &y, &w, &h); int margin = style().pixelMetric(QStyle::PM_ButtonMargin, this); x += margin; y += margin; w -= 2 * margin; h -= 2 * margin; if(isOn() || isDown()) { x += style().pixelMetric(QStyle::PM_ButtonShiftHorizontal, this); y += style().pixelMetric(QStyle::PM_ButtonShiftVertical, this); } QColor fillCol = isEnabled() ? col : backgroundColor(); qDrawShadePanel(painter, x, y, w, h, colorGroup(), true, 1, NULL); if(fillCol.isValid()) painter->fillRect(x + 1, y + 1, w - 2, h - 2, fillCol); if(hasFocus()) { QRect focusRect = style().subRect(QStyle::SR_PushButtonFocusRect, this); style().drawPrimitive(QStyle::PE_FocusRect, painter, focusRect, colorGroup()); } }
void SimpleButton::drawButtonLabel( QPainter *p ) { if (!pixmap()) { return; } QPixmap pix = m_highlight? m_activeIcon : m_normalIcon; if (isOn() || isDown()) { pix = pix.convertToImage().smoothScale(pix.width() - 2, pix.height() - 2); } int h = height(); int w = width(); int ph = pix.height(); int pw = pix.width(); int margin = KDialog::spacingHint(); QPoint origin(margin / 2, margin / 2); if (ph < (h - margin)) { origin.setY((h - ph) / 2); } if (pw < (w - margin)) { origin.setX((w - pw) / 2); } p->drawPixmap(origin, pix); }
void HideButton::drawButtonLabel(QPainter *p) { QPixmap pix = m_highlight ? m_activeIcon : m_normalIcon; if (isChecked() || isDown()) { p->translate(2, 2); } QPoint origin(2, 2); int w = width(); int h = height(); int pw = pix.width(); int ph = pix.height(); if (ph < (h - 4)) { origin.setY(origin.y() + ((h - ph) / 2)); } if (pw < (w - 4)) { origin.setX(origin.x() + ((w - pw) / 2)); } p->drawPixmap(origin, pix); }
void QVistaBackButton::paintEvent(QPaintEvent *) { QPainter p(this); QRect r = rect(); HANDLE theme = pOpenThemeData(0, L"Navigation"); //RECT rect; QPoint origin; const HDC hdc = QVistaHelper::backingStoreDC(parentWidget(), &origin); RECT clipRect; int xoffset = origin.x() + QWidget::mapToParent(r.topLeft()).x() - 1; int yoffset = origin.y() + QWidget::mapToParent(r.topLeft()).y() - 1; const int dpr = devicePixelRatio(); const QRect rDp = QRect(r.topLeft() * dpr, r.size() * dpr); const int xoffsetDp = xoffset * dpr; const int yoffsetDp = yoffset * dpr; clipRect.top = rDp.top() + yoffsetDp; clipRect.bottom = rDp.bottom() + yoffsetDp; clipRect.left = rDp.left() + xoffsetDp; clipRect.right = rDp.right() + xoffsetDp; int state = WIZ_NAV_BB_NORMAL; if (!isEnabled()) state = WIZ_NAV_BB_DISABLED; else if (isDown()) state = WIZ_NAV_BB_PRESSED; else if (underMouse()) state = WIZ_NAV_BB_HOT; WIZ_NAVIGATIONPARTS buttonType = (layoutDirection() == Qt::LeftToRight ? WIZ_NAV_BACKBUTTON : WIZ_NAV_FORWARDBUTTON); pDrawThemeBackground(theme, hdc, buttonType, state, &clipRect, &clipRect); }
void QColorButton::paintEvent (QPaintEvent *p) { QPushButton::paintEvent (p); QStyleOptionButton option; option.initFrom (this); int x, y, w, h; QRect r = style()->subElementRect (QStyle::SE_PushButtonContents, &option, this); r.getRect (&x, &y, &w, &h); int margin = style()->pixelMetric (QStyle::PM_ButtonMargin, &option, this); x += margin; y += margin; w -= 2*margin; h -= 2*margin; if (isChecked() || isDown()) { x += style()->pixelMetric (QStyle::PM_ButtonShiftHorizontal, &option, this ); y += style()->pixelMetric (QStyle::PM_ButtonShiftVertical, &option, this ); } QPainter painter (this); QColor fillCol = isEnabled() ? col : palette().brush(QPalette::Window).color(); qDrawShadePanel (&painter, x, y, w, h, palette(), true, 1, NULL); if (fillCol.isValid()) painter.fillRect (x+1, y+1, w-2, h-2, fillCol); if (hasFocus()) { style()->subElementRect (QStyle::SE_PushButtonFocusRect, &option, this); style()->drawPrimitive (QStyle::PE_FrameFocusRect, &option, &painter, this); } }
//============================================================================== Drawable* DrawableButton::getCurrentImage() const noexcept { if (isDown()) return getDownImage(); if (isOver()) return getOverImage(); return getNormalImage(); }
void HideButton::drawButtonLabel(QPainter *p) { if(pixmap()) { QPixmap pix = m_highlight ? m_activeIcon : m_normalIcon; if(isOn() || isDown()) { p->translate(2, 2); } QPoint origin(2, 2); if(pix.height() < (height() - 4)) { origin.setY(origin.y() + ((height() - pix.height()) / 2)); } if(pix.width() < (width() - 4)) { origin.setX(origin.x() + ((width() - pix.width()) / 2)); } p->drawPixmap(origin, pix); } }
/*! \return the bounding rect for the label */ QRect QwtArrowButton::labelRect() const { const int m = Margin; QRect r = rect(); r.setRect(r.x() + m, r.y() + m, r.width() - 2 * m, r.height() - 2 * m); if ( isDown() ) { int ph, pv; #if QT_VERSION < 0x040000 ph = style().pixelMetric( QStyle::PM_ButtonShiftHorizontal, this); pv = style().pixelMetric( QStyle::PM_ButtonShiftVertical, this); r.moveBy(ph, pv); #else QStyleOptionButton option = styleOpt(this); ph = style()->pixelMetric( QStyle::PM_ButtonShiftHorizontal, &option, this); pv = style()->pixelMetric( QStyle::PM_ButtonShiftVertical, &option, this); r.translate(ph, pv); #endif } return r; }
void ToolButton::paintEvent(QPaintEvent* e) { if (!m_usingMultiIcon) { QToolButton::paintEvent(e); return; } QPainter p(this); QStyleOptionToolButton opt; opt.init(this); if (!isEnabled()) { p.drawPixmap(0, 0, m_disabledIcon); return; } if (isDown()) { p.drawPixmap(0, 0, m_activeIcon); return; } if (opt.state & QStyle::State_MouseOver) { p.drawPixmap(0, 0, m_hoverIcon); return; } p.drawPixmap(0, 0, m_normalIcon); }