void ReleaseDialog::paintEvent(QPaintEvent *event) { QStyleOption opt; opt.init(this); QPainter p(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); // QPixmap pixmap("./login/images/login_bg.png"); // QWidget::setMask(pixmap.mask()); // QPainter painter(this->parentWidget()); // painter.setPen(Qt::NoPen); // painter.setBrush(Qt::red); // painter.drawRect(QRect(10, 10, 50, 80)); }
void PushButtonDone::paintEvent(QPaintEvent *) { QStyleOption opt; opt.init(this); QPainter p(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); if("Cancel" == text_) { QFont font = p.font(); font.setPointSize(24); p.setFont(font); } p.drawText(QPoint(9, 65), text_); }
void ComboTabBar::paintEvent(QPaintEvent* ev) { Q_UNUSED(ev); // This is needed to apply style sheets QStyleOption option; option.init(this); QPainter p(this); style()->drawPrimitive(QStyle::PE_Widget, &option, &p, this); #ifndef Q_OS_MAC // Draw tabbar base even on parts of ComboTabBar that are not directly QTabBar QStyleOptionTabBarBaseV2 opt; TabBarHelper::initStyleBaseOption(&opt, m_mainTabBar, size()); // Left container opt.rect.setX(m_leftContainer->x()); opt.rect.setWidth(m_leftContainer->width()); style()->drawPrimitive(QStyle::PE_FrameTabBarBase, &opt, &p); // Right container opt.rect.setX(m_rightContainer->x()); opt.rect.setWidth(m_rightContainer->width()); style()->drawPrimitive(QStyle::PE_FrameTabBarBase, &opt, &p); if (m_mainBarOverFlowed) { const int scrollButtonWidth = m_mainTabBarWidget->scrollButtonsWidth(); // Left scroll button opt.rect.setX(m_mainTabBarWidget->x()); opt.rect.setWidth(scrollButtonWidth); style()->drawPrimitive(QStyle::PE_FrameTabBarBase, &opt, &p); // Right scroll button opt.rect.setX(m_mainTabBarWidget->x() + m_mainTabBarWidget->width() - scrollButtonWidth); opt.rect.setWidth(scrollButtonWidth); style()->drawPrimitive(QStyle::PE_FrameTabBarBase, &opt, &p); } // Draw base even when main tabbar is empty if (normalTabsCount() == 0) { opt.rect.setX(m_mainTabBarWidget->x()); opt.rect.setWidth(m_mainTabBarWidget->width()); style()->drawPrimitive(QStyle::PE_FrameTabBarBase, &opt, &p); } #endif }
void LaunchyWidget::paintEvent(QPaintEvent* event) { // Do the default draw first to render any background specified in the stylesheet QStyleOption styleOption; styleOption.init(this); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); style()->drawPrimitive(QStyle::PE_Widget, &styleOption, &painter, this); // Now draw the standard frame.png graphic if there is one if (frameGraphic) { painter.drawPixmap(0,0, *frameGraphic); } QWidget::paintEvent(event); }
void view::visualizer::callGraph::paintEvent(QPaintEvent *) { QString filename = QString(((binspector *)thisParent)->getActiveAnalysisPath() + "/graphs/callGraph.png"); QFile file(filename); if (file.exists()) { QStyleOption opt; opt.init(this); QPainter p(this); QPixmap graph(filename); p.drawPixmap(0, 0, graph.scaled(size())); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); } }
static QSize buttonShift(const QwtLegendItem *w) { #if QT_VERSION < 0x040000 const int ph = w->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal, w); const int pv = w->style().pixelMetric( QStyle::PM_ButtonShiftVertical, w); #else QStyleOption option; option.init(w); const int ph = w->style()->pixelMetric( QStyle::PM_ButtonShiftHorizontal, &option, w); const int pv = w->style()->pixelMetric( QStyle::PM_ButtonShiftVertical, &option, w); #endif return QSize(ph, pv); }
/*! \brief Qt Paint Event \param event Paint event */ void QwtWheel::paintEvent( QPaintEvent *event ) { QPainter painter( this ); painter.setClipRegion( event->region() ); QStyleOption opt; opt.init(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); qDrawShadePanel( &painter, contentsRect(), palette(), true, d_data->borderWidth ); drawWheelBackground( &painter, wheelRect() ); drawTicks( &painter, wheelRect() ); if ( hasFocus() ) QwtPainter::drawFocusRect( &painter, this ); }
//----------------------------------------------------------------------------- void ctkExpandButton::setOrientation(Qt::Orientation newOrientation) { Q_D(ctkExpandButton); QStyleOption opt; opt.init(this); if(newOrientation == Qt::Horizontal) { d->defaultPixmap = this->style()->standardPixmap( QStyle::SP_ToolBarHorizontalExtensionButton, &opt); d->orientation = Qt::Horizontal; } else { d->defaultPixmap = this->style()->standardPixmap( QStyle::SP_ToolBarVerticalExtensionButton, &opt); d->orientation = Qt::Vertical; } this->updateIcon(d->direction); }
/*! Qt paint event handler \param event Paint event */ void QwtSlider::paintEvent( QPaintEvent *event ) { QPainter painter( this ); painter.setClipRegion( event->region() ); QStyleOption opt; opt.init(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); if ( d_data->scalePosition != QwtSlider::NoScale ) { if ( !d_data->sliderRect.contains( event->rect() ) ) scaleDraw()->draw( &painter, palette() ); } drawSlider( &painter, d_data->sliderRect ); if ( hasFocus() ) QwtPainter::drawFocusRect( &painter, this, d_data->sliderRect ); }
/*! \brief Return a minimum size hint */ QSize QwtArrowButton::minimumSizeHint() const { const QSize asz = arrowSize( Qt::RightArrow, QSize() ); QSize sz( 2 * Margin + ( MaxNum - 1 ) * Spacing + MaxNum * asz.width(), 2 * Margin + asz.height() ); if ( d_data->arrowType == Qt::UpArrow || d_data->arrowType == Qt::DownArrow ) sz.transpose(); QStyleOption styleOption; styleOption.init( this ); sz = style()->sizeFromContents( QStyle::CT_PushButton, &styleOption, sz, this ); return sz; }
void GroupButton::paintEvent(QPaintEvent *) { QStyleOption opt; opt.init(this); QPainter painter(this); QPen pen(Qt::white, 5); painter.setPen(pen); QPainterPath path; path.addRect(this->rect()); if (mButtonState == EGroupButtonState::clearAll) { painter.fillPath(path, QBrush(computeHighlightColor(mCheckedCount, mReachableCount))); } else { painter.fillPath(path, QBrush(QColor(32, 31, 31, 255))); } if (mIsSelected) { painter.drawPath(path); } }
void CUiWidget_win::paintEvent(QPaintEvent *event) { QStyleOption opt; QPainter p(this); QRect r; //QPainterPath path; //QRegion region; //int xroundness = 1, yroundness = 2; r = rect(); opt.init(this); /* // isMaximized doesn't work here, because we change // the maximize logic, we can use the new 'widgetState' method if (isFullScreen() || widgetState() == Qt::WindowMaximized ) { setMask(region); } else { path.addRoundRect(0, 0, r.width(), r.height(), xroundness, yroundness); p.setClipPath(path); region = p.clipRegion(); setMask(region); } */ QPalette defaultPalette = QApplication::palette(this); /* QColor c; QPixmap pixmap(":/res/icons/woodbackground.png"); for (int i = 0; i < QPalette::NColorGroups; ++i) { c = defaultPalette.brush(QPalette::ColorGroup(i), QPalette::Window).color(); defaultPalette.setBrush(QPalette::ColorGroup(i), QPalette::Window, pixmap); } */ setPalette(defaultPalette); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); }
void MasterSlider::paintEvent(QPaintEvent *event) { QPainter p(this); p.setPen(Qt::black); p.rotate(180); p.setRenderHint(QPainter::Antialiasing); QStyleOption opt; opt.init(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); QColor myPenColor = QColor(0,0,0,255); QBrush *brush = new QBrush(myPenColor,Qt::SolidPattern); p.setPen(myPenColor); p.setBrush(*brush); unsigned short * levels = controllerm->getLevels(1); y = -300; int g = 0; for(int i = 0;i < numOuts;i++) { if(i == 4) { g = 0; y = -600; } x = -40 * (g + 1); unsigned short lax = levels[i]; volRect = new QRect(x,y,30,lax/200); p.drawRect(*volRect); p.rotate(180); QString text = ""; QString text2 = QString::number(i + 1); p.drawText(-x - 25,-y + 100, text.append(text2)); p.rotate(180); g++; } p.rotate(180); }
void LiveChatMembersControl::paintEvent(QPaintEvent* _e) { QStyleOption opt; opt.init(this); QPainter painter(this); painter.setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform|QPainter::TextAntialiasing); style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); int maxCount = (geometry().width() - sv(avatarWithFrameHeight)) / (sv(avatarWithFrameHeight) - sv(avatarIntersection) - sv(frameWidth)) + 1; int xOffset = 0; for (const auto& chat : members_) { if (maxCount <= 0) break; painter.setBrush(Qt::white); painter.setPen(Qt::white); painter.drawEllipse(xOffset, 0, sv(avatarWithFrameHeight), sv(avatarWithFrameHeight)); bool isDefault = false; const auto &avatar = Logic::GetAvatarStorage()->GetRounded(chat.first, chat.second, Utils::scale_bitmap(sv(avatarHeight)), QString(), true, isDefault); if (!avatar->isNull()) { painter.drawPixmap(xOffset + sv(frameWidth), sv(frameWidth), sv(avatarHeight), sv(avatarHeight), *avatar); } xOffset += sv(avatarWithFrameHeight) - sv(avatarIntersection) - sv(frameWidth); --maxCount; } return QWidget::paintEvent(_e); }
void ListMoodPreviewWidget::paintEvent(QPaintEvent *) { QStyleOption opt; opt.init(this); QPainter painter(this); QPen pen(Qt::white, 5); painter.setPen(pen); QPainterPath path; path.addRect(this->rect()); painter.setRenderHint(QPainter::Antialiasing); if (mIsChecked) { painter.fillRect(this->rect(), QBrush(QColor(61, 142, 201))); } else { painter.fillRect(this->rect(), QBrush(QColor(32, 31, 31))); } if (mIsSelected) { painter.drawPath(path); } }
void TabCloseButton::paintEvent(QPaintEvent *event) { Q_UNUSED(event) // get the tab this close button belongs to KateTabButton *tabButton = qobject_cast<KateTabButton*>(parent()); const bool isActive = underMouse() || (tabButton && tabButton->isChecked()); // set style options depending on current state QStyleOption opt; opt.init(this); if (isActive && !isChecked()) { opt.state |= QStyle::State_Raised; } if (isChecked()) { opt.state |= QStyle::State_Sunken; } QPainter p(this); style()->drawPrimitive(QStyle::PE_IndicatorTabClose, &opt, &p, this); }
void CloseButton::paintEvent(QPaintEvent * /*event*/) { QPainter p(this); QStyleOption opt; opt.init(this); opt.state |= QStyle::State_AutoRaise; if (isEnabled() && underMouse() && !isChecked() && !isDown()) opt.state |= QStyle::State_Raised; if (isChecked()) opt.state |= QStyle::State_On; if (isDown()) opt.state |= QStyle::State_Sunken; if (const QTabBar *tb = qobject_cast<const QTabBar *>(parent())) { int index = tb->currentIndex(); QTabBar::ButtonPosition position = (QTabBar::ButtonPosition) style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, tb); if (tb->tabButton(index, position) == this) opt.state |= QStyle::State_Selected; } style()->drawPrimitive(QStyle::PE_IndicatorTabClose, &opt, &p, this); }
/*! Paint the dial \param event Paint event */ void QwtDial::paintEvent( QPaintEvent *event ) { QPainter painter( this ); painter.setClipRegion( event->region() ); QStyleOption opt; opt.init(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); painter.setRenderHint( QPainter::Antialiasing, true ); painter.save(); drawContents( &painter ); painter.restore(); painter.save(); drawFrame( &painter ); painter.restore(); if ( hasFocus() ) drawFocusIndicator( &painter ); }
/*! Repaint the knob \param event Paint event */ void QwtKnob::paintEvent( QPaintEvent *event ) { QPainter painter( this ); painter.setClipRegion( event->region() ); QStyleOption opt; opt.init(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); painter.setRenderHint( QPainter::Antialiasing, true ); if ( !d_data->knobRect.contains( event->region().boundingRect() ) ) scaleDraw()->draw( &painter, palette() ); drawKnob( &painter, d_data->knobRect ); drawMarker( &painter, d_data->knobRect, d_data->angle ); painter.setRenderHint( QPainter::Antialiasing, false ); if ( hasFocus() ) QwtPainter::drawFocusRect( &painter, this ); }
void SkRasterWidget::paintEvent(QPaintEvent* event) { if (!this->isHidden()) { fDebugger->draw(fCanvas); QPainter painter(this); QStyleOption opt; opt.init(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); QPoint origin(0,0); QImage image((uchar *)fBitmap.getPixels(), fBitmap.width(), fBitmap.height(), QImage::Format_ARGB32_Premultiplied); #if SK_R32_SHIFT == 0 painter.drawImage(origin, image.rgbSwapped()); #else painter.drawImage(origin, image); #endif painter.end(); emit drawComplete(); } }
void CloseButton::paintEvent(QPaintEvent *AEvent) { Q_UNUSED(AEvent); if (icon().isNull()) { QStyleOption opt; opt.init(this); opt.state |= QStyle::State_AutoRaise; if (isEnabled() && underMouse() && !isChecked() && !isDown()) opt.state |= QStyle::State_Raised; if (isChecked()) opt.state |= QStyle::State_On; if (isDown()) opt.state |= QStyle::State_Sunken; QPainter p(this); style()->drawPrimitive(QStyle::PE_IndicatorTabClose, &opt, &p, this); } else { QIcon::Mode mode = QIcon::Normal; if (!isEnabled()) mode = QIcon::Disabled; else if (underMouse()) mode = QIcon::Active; QIcon::State state = QIcon::Off; if (isChecked()) state = QIcon::On; QPixmap pixmap = icon().pixmap(iconSize(),mode,state); QRect pixmapRect = QRect(0, 0, pixmap.width(), pixmap.height()); pixmapRect.moveCenter(rect().center()); QPainter p(this); p.drawPixmap(pixmapRect, pixmap); } }
void ViewTaskResult::paintEvent(QPaintEvent *paintEvent) { QStyleOption option; option.init(this); QPainter painter(this); this->style()->drawPrimitive(QStyle::PE_Widget, &option, &painter, this); QRect upperRect(0, 0, this->rect().width(), this->rect().height() / 2); QRect lowerRect(0, this->rect().height() / 2, this->rect().width(), this->rect().height() / 2); this->style()->drawItemText(&painter, upperRect, Qt::AlignVCenter | Qt::AlignHCenter, QPalette(), true, this->task->getName()); QString resultString = "??"; if(this->result != nullptr) resultString = QString::number(this->result->getResult()); int maxPoints = 0; const Tests *tests = this->task->getTests(); if(tests != nullptr) maxPoints = tests->getMaxPoints(); this->style()->drawItemText(&painter, lowerRect, Qt::AlignVCenter | Qt::AlignHCenter, QPalette(), true, resultString + "/" + QString::number(maxPoints)); }
static PyObject *meth_QStyleOption_init(PyObject *sipSelf, PyObject *sipArgs) { PyObject *sipParseErr = NULL; { const QWidget* a0; QStyleOption *sipCpp; if (sipParseArgs(&sipParseErr, sipArgs, "BJ8", &sipSelf, sipType_QStyleOption, &sipCpp, sipType_QWidget, &a0)) { Py_BEGIN_ALLOW_THREADS sipCpp->init(a0); Py_END_ALLOW_THREADS Py_INCREF(Py_None); return Py_None; } } /* Raise an exception if the arguments couldn't be parsed. */ sipNoMethod(sipParseErr, sipName_QStyleOption, sipName_init, doc_QStyleOption_init); return NULL; }
void FramelessWin2::paintEvent(QPaintEvent *evt) { /* 添加阴影效果 :param args: :param kwargs: :return: */ QStyleOption opt; opt.init(this); QPainter painter(this); QStyle *style = this->style(); style->drawPrimitive(QStyle::PE_Widget,&opt,&painter,this); QPainterPath path; path.setFillRule(Qt::WindingFill); path.addRect(10,10,width()-20,height()-20); painter.setRenderHint(QPainter::Antialiasing,true); painter.fillPath(path,QBrush(Qt::white)); QColor color(0,0,0,50); int i = 0; //for i in xrange(10): for (i = 0 ; i < 10; i++) { QPainterPath path2; path2.setFillRule(Qt::WindingFill); path2.addRect(10-i,10-i,width()-(10-i)*2,height()-(10-i)*2); color.setAlpha(150 - sqrt((float)i)*50); painter.setPen(color); painter.drawPath(path2); } QPixmap back("./UI/skin.png"); i = 0; painter.drawPixmap(10-i,10-i,width()-(10-i)*2,height()-(10-i)*2,back); }
void SettingsTechnicalInfo::paintEvent (QPaintEvent *){ QStyleOption opt; opt.init(this); QPainter p(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); }
void ScaleSliderQWidget::paintEvent(QPaintEvent* /*e*/) { if (_imp->mustInitializeSliderPosition) { centerOn(_imp->minimum, _imp->maximum); _imp->mustInitializeSliderPosition = false; seekScalePosition(_imp->value); _imp->initialized = true; } ///fill the background with the appropriate style color QStyleOption opt; opt.init(this); QPainter p(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); double txtR,txtG,txtB; appPTR->getCurrentSettings()->getTextColor(&txtR, &txtG, &txtB); QColor textColor; textColor.setRgbF(Natron::clamp(txtR), Natron::clamp(txtG), Natron::clamp(txtB)); QColor scaleColor; scaleColor.setRgbF(textColor.redF() / 2., textColor.greenF() / 2., textColor.blueF() / 2.); QFontMetrics fontM(*_imp->font); p.setPen(scaleColor); QPointF btmLeft = _imp->zoomCtx.toZoomCoordinates(0,height() - 1); QPointF topRight = _imp->zoomCtx.toZoomCoordinates(width() - 1, 0); if ( btmLeft.x() == topRight.x() ) { return; } /*drawing X axis*/ double lineYpos = height() - 1 - fontM.height() - TICK_HEIGHT / 2; p.drawLine(0, lineYpos, width() - 1, lineYpos); double tickBottom = _imp->zoomCtx.toZoomCoordinates( 0,height() - 1 - fontM.height() ).y(); double tickTop = _imp->zoomCtx.toZoomCoordinates(0,height() - 1 - fontM.height() - TICK_HEIGHT).y(); const double smallestTickSizePixel = 5.; // tick size (in pixels) for alpha = 0. const double largestTickSizePixel = 1000.; // tick size (in pixels) for alpha = 1. std::vector<double> acceptedDistances; acceptedDistances.push_back(1.); acceptedDistances.push_back(5.); acceptedDistances.push_back(10.); acceptedDistances.push_back(50.); const double rangePixel = width(); const double range_min = btmLeft.x(); const double range_max = topRight.x(); const double range = range_max - range_min; double smallTickSize; bool half_tick; ticks_size(range_min, range_max, rangePixel, smallestTickSizePixel, &smallTickSize, &half_tick); int m1, m2; const int ticks_max = 1000; double offset; ticks_bounds(range_min, range_max, smallTickSize, half_tick, ticks_max, &offset, &m1, &m2); std::vector<int> ticks; ticks_fill(half_tick, ticks_max, m1, m2, &ticks); const double smallestTickSize = range * smallestTickSizePixel / rangePixel; const double largestTickSize = range * largestTickSizePixel / rangePixel; const double minTickSizeTextPixel = fontM.width( QString("00") ); // AXIS-SPECIFIC const double minTickSizeText = range * minTickSizeTextPixel / rangePixel; for (int i = m1; i <= m2; ++i) { double value = i * smallTickSize + offset; const double tickSize = ticks[i - m1] * smallTickSize; const double alpha = ticks_alpha(smallestTickSize, largestTickSize, tickSize); QColor color(textColor); color.setAlphaF(alpha); QPen pen(color); pen.setWidthF(1.9); p.setPen(pen); QPointF tickBottomPos = _imp->zoomCtx.toWidgetCoordinates(value, tickBottom); QPointF tickTopPos = _imp->zoomCtx.toWidgetCoordinates(value, tickTop); p.drawLine(tickBottomPos,tickTopPos); bool renderText = _imp->dataType == eDataTypeDouble || std::abs(std::floor(0.5 + value) - value) == 0.; if (renderText && tickSize > minTickSizeText) { const int tickSizePixel = rangePixel * tickSize / range; const QString s = QString::number(value); const int sSizePixel = fontM.width(s); if (tickSizePixel > sSizePixel) { const int sSizeFullPixel = sSizePixel + minTickSizeTextPixel; double alphaText = 1.0; //alpha; if (tickSizePixel < sSizeFullPixel) { // when the text size is between sSizePixel and sSizeFullPixel, // draw it with a lower alpha alphaText *= (tickSizePixel - sSizePixel) / (double)minTickSizeTextPixel; } QColor c = _imp->readOnly || !isEnabled() ? Qt::black : textColor; c.setAlphaF(alphaText); p.setFont(*_imp->font); p.setPen(c); QPointF textPos = _imp->zoomCtx.toWidgetCoordinates( value, btmLeft.y() ); p.drawText(textPos, s); } } } double positionValue = _imp->zoomCtx.toWidgetCoordinates(_imp->value,0).x(); QPointF sliderBottomLeft(positionValue - SLIDER_WIDTH / 2,height() - 1 - fontM.height() / 2); QPointF sliderTopRight(positionValue + SLIDER_WIDTH / 2,height() - 1 - fontM.height() / 2 - SLIDER_HEIGHT); /*draw the slider*/ p.setPen(_imp->sliderColor); p.fillRect(sliderBottomLeft.x(), sliderBottomLeft.y(), sliderTopRight.x() - sliderBottomLeft.x(), sliderTopRight.y() - sliderBottomLeft.y(),_imp->sliderColor); /*draw a black rect around the slider for contrast*/ p.setPen(Qt::black); p.drawLine( sliderBottomLeft.x(),sliderBottomLeft.y(),sliderBottomLeft.x(),sliderTopRight.y() ); p.drawLine( sliderBottomLeft.x(),sliderTopRight.y(),sliderTopRight.x(),sliderTopRight.y() ); p.drawLine( sliderTopRight.x(),sliderTopRight.y(),sliderTopRight.x(),sliderBottomLeft.y() ); p.drawLine( sliderTopRight.x(),sliderBottomLeft.y(),sliderBottomLeft.x(),sliderBottomLeft.y() ); } // paintEvent
void SendCoinsEntry::paintEvent(QPaintEvent* evt) { QStyleOption opt; opt.init(this); QPainter p(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); }
void RDHeaderView::paintEvent(QPaintEvent *e) { if(!m_customSizing) return QHeaderView::paintEvent(e); if(count() == 0) return; QPainter painter(viewport()); int start = qMax(visualIndexAt(e->rect().left()), 0); int end = visualIndexAt(e->rect().right()); if(end == -1) end = count() - 1; // make sure we always paint the whole header for any merged headers while(start > 0 && !hasGroupTitle(start - 1)) start--; while(end < m_sections.count() && !hasGroupTitle(end)) end++; QRect accumRect; for(int i = start; i <= end; ++i) { int pos = sectionViewportPosition(i); int size = sectionSize(i); if(!hasGroupGap(i) && pos < 0) { size += pos; pos = 0; } // either set or accumulate this section's rect if(accumRect.isEmpty()) accumRect.setRect(pos, 0, size, viewport()->height()); else accumRect.setWidth(accumRect.width() + size); if(hasGroupTitle(i)) { painter.save(); accumRect.setWidth(accumRect.width() - 1); if(accumRect.left() < m_pinnedWidth && i >= m_pinnedColumns) accumRect.setLeft(m_pinnedWidth); paintSection(&painter, accumRect, i); painter.restore(); // if we have more sections to go, reset so we can accumulate the next group if(i < end) accumRect = QRect(); } } // clear the remainder of the header if there's a gap if(accumRect.right() < e->rect().right()) { QStyleOption opt; opt.init(this); opt.state |= QStyle::State_Horizontal; opt.rect = QRect(accumRect.right() + 1, 0, e->rect().right() - accumRect.right(), viewport()->height()); style()->drawControl(QStyle::CE_HeaderEmptyArea, &opt, &painter, this); } }
QRect LineEditTaskMenuInlineEditor::editRectangle() const { QStyleOption opt; opt.init(widget()); return opt.rect; }
void ScaleSliderQWidget::paintEvent(QPaintEvent* /*e*/) { if (_imp->mustInitializeSliderPosition) { if (_imp->minimum < _imp->maximum) { centerOn(_imp->minimum, _imp->maximum); } _imp->mustInitializeSliderPosition = false; seekScalePosition(_imp->value); _imp->initialized = true; } ///fill the background with the appropriate style color QStyleOption opt; opt.init(this); QPainter p(this); p.setOpacity(1); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); double txtR, txtG, txtB; if (_imp->altered) { appPTR->getCurrentSettings()->getAltTextColor(&txtR, &txtG, &txtB); } else { appPTR->getCurrentSettings()->getTextColor(&txtR, &txtG, &txtB); } QColor textColor; textColor.setRgbF( Image::clamp<qreal>(txtR, 0., 1.), Image::clamp<qreal>(txtG, 0., 1.), Image::clamp<qreal>(txtB, 0., 1.) ); QColor scaleColor; scaleColor.setRgbF(textColor.redF() / 2., textColor.greenF() / 2., textColor.blueF() / 2.); QFontMetrics fontM(_imp->font, 0); if (!_imp->useLineColor) { p.setPen(scaleColor); } else { p.setPen(_imp->lineColor); } QPointF btmLeft = _imp->zoomCtx.toZoomCoordinates(0, height() - 1); QPointF topRight = _imp->zoomCtx.toZoomCoordinates(width() - 1, 0); if ( btmLeft.x() == topRight.x() ) { return; } /*drawing X axis*/ double lineYpos = height() - 1 - fontM.height() - TO_DPIY(TICK_HEIGHT) / 2; p.drawLine(0, lineYpos, width() - 1, lineYpos); double tickBottom = _imp->zoomCtx.toZoomCoordinates( 0, height() - 1 - fontM.height() ).y(); double tickTop = _imp->zoomCtx.toZoomCoordinates( 0, height() - 1 - fontM.height() - TO_DPIY(TICK_HEIGHT) ).y(); const double smallestTickSizePixel = 10.; // tick size (in pixels) for alpha = 0. const double largestTickSizePixel = 1000.; // tick size (in pixels) for alpha = 1. const double rangePixel = width(); const double range_min = btmLeft.x(); const double range_max = topRight.x(); const double range = range_max - range_min; double smallTickSize; bool half_tick; ticks_size(range_min, range_max, rangePixel, smallestTickSizePixel, &smallTickSize, &half_tick); if ( (_imp->dataType == eDataTypeInt) && (smallTickSize < 1.) ) { smallTickSize = 1.; half_tick = false; } int m1, m2; const int ticks_max = 1000; double offset; ticks_bounds(range_min, range_max, smallTickSize, half_tick, ticks_max, &offset, &m1, &m2); std::vector<int> ticks; ticks_fill(half_tick, ticks_max, m1, m2, &ticks); const double smallestTickSize = range * smallestTickSizePixel / rangePixel; const double largestTickSize = range * largestTickSizePixel / rangePixel; const double minTickSizeTextPixel = fontM.width( QLatin1String("00") ); // AXIS-SPECIFIC const double minTickSizeText = range * minTickSizeTextPixel / rangePixel; for (int i = m1; i <= m2; ++i) { double value = i * smallTickSize + offset; const double tickSize = ticks[i - m1] * smallTickSize; const double alpha = ticks_alpha(smallestTickSize, largestTickSize, tickSize); QColor color(textColor); color.setAlphaF(alpha); QPen pen(color); pen.setWidthF(1.9); p.setPen(pen); // for Int slider, because smallTickSize is at least 1, isFloating can never be true bool isFloating = std::abs(std::floor(0.5 + value) - value) != 0.; assert( !(_imp->dataType == eDataTypeInt && isFloating) ); bool renderFloating = _imp->dataType == eDataTypeDouble || !isFloating; if (renderFloating) { QPointF tickBottomPos = _imp->zoomCtx.toWidgetCoordinates(value, tickBottom); QPointF tickTopPos = _imp->zoomCtx.toWidgetCoordinates(value, tickTop); p.drawLine(tickBottomPos, tickTopPos); } if ( renderFloating && (tickSize > minTickSizeText) ) { const int tickSizePixel = rangePixel * tickSize / range; const QString s = QString::number(value); const int sSizePixel = fontM.width(s); if (tickSizePixel > sSizePixel) { const int sSizeFullPixel = sSizePixel + minTickSizeTextPixel; double alphaText = 1.0; //alpha; if (tickSizePixel < sSizeFullPixel) { // when the text size is between sSizePixel and sSizeFullPixel, // draw it with a lower alpha alphaText *= (tickSizePixel - sSizePixel) / (double)minTickSizeTextPixel; } QColor c = _imp->readOnly || !isEnabled() ? Qt::black : textColor; c.setAlphaF(alphaText); p.setFont(_imp->font); p.setPen(c); QPointF textPos = _imp->zoomCtx.toWidgetCoordinates( value, btmLeft.y() ); p.drawText(textPos, s); } } } double positionValue = _imp->zoomCtx.toWidgetCoordinates(_imp->value, 0).x(); QPointF sliderBottomLeft(positionValue - TO_DPIX(SLIDER_WIDTH) / 2, height() - 1 - fontM.height() / 2); QPointF sliderTopRight( positionValue + TO_DPIX(SLIDER_WIDTH) / 2, height() - 1 - fontM.height() / 2 - TO_DPIY(SLIDER_HEIGHT) ); /*draw the slider*/ p.setPen(_imp->sliderColor); p.fillRect(sliderBottomLeft.x(), sliderBottomLeft.y(), sliderTopRight.x() - sliderBottomLeft.x(), sliderTopRight.y() - sliderBottomLeft.y(), _imp->sliderColor); /*draw a black rect around the slider for contrast or orange when focused*/ if ( !hasFocus() ) { p.setPen(Qt::black); } else { QPen pen = p.pen(); pen.setColor( QColor(243, 137, 0) ); QVector<qreal> dashStyle; qreal space = 2; dashStyle << 1 << space; pen.setDashPattern(dashStyle); p.setOpacity(0.8); p.setPen(pen); } p.drawLine( sliderBottomLeft.x(), sliderBottomLeft.y(), sliderBottomLeft.x(), sliderTopRight.y() ); p.drawLine( sliderBottomLeft.x(), sliderTopRight.y(), sliderTopRight.x(), sliderTopRight.y() ); p.drawLine( sliderTopRight.x(), sliderTopRight.y(), sliderTopRight.x(), sliderBottomLeft.y() ); p.drawLine( sliderTopRight.x(), sliderBottomLeft.y(), sliderBottomLeft.x(), sliderBottomLeft.y() ); } // paintEvent