QRect PrimerLineEdit::placeHolderRect() const { QStyleOptionFrame panel; initStyleOption(&panel); QRect r = style()->subElementRect(QStyle::SE_LineEditContents, &panel, this); r.setX(r.x() + textMargins().left()); r.setY(r.y() + textMargins().top()); r.setRight(r.right() - textMargins().right()); r.setBottom(r.bottom() - textMargins().bottom()); QFontMetrics fm = fontMetrics(); int minLB = qMax(0, -fm.minLeftBearing()); int minRB = qMax(0, -fm.minRightBearing()); int vscroll = r.y() + (r.height() - fm.height() + 1) / 2; static const int horizontalMargin = 2; // QLineEditPrivate::horizontalMargin QRect lineRect(r.x() + horizontalMargin, vscroll, r.width() - 2*horizontalMargin, fm.height()); return lineRect.adjusted(minLB, 0, -minRB, 0); }
void DisassemblyView::paintBackground(QPainter& p) { // Draw background medusa::UserConfiguration UserCfg; QColor AddrColor = QColor(QString::fromStdString(UserCfg.GetOption("color.background_address"))); QColor CodeColor = QColor(QString::fromStdString(UserCfg.GetOption("color.background_listing"))); QColor CursColor = QColor(Qt::black); QRect AddrRect = viewport()->rect(); QRect CodeRect = viewport()->rect(); AddrRect.setWidth((_addrLen - horizontalScrollBar()->value()) * _wChar); CodeRect.setX((_addrLen - horizontalScrollBar()->value()) * _wChar); p.fillRect(AddrRect, AddrColor); p.fillRect(CodeRect, CodeColor); }
void ReleaseDialog::calendar_start_clicked(bool checked) { QRect rect; // = calendarStart->geometry(); QPoint point = QCursor::pos(); rect.setX(point.x()); rect.setY(point.y()); // calendarStart->setGeometry(point.x() - 180, point.y() + 50, 180, 110); if(checked){ // calendarStart->setHidden(false); // calendarStart->setFocus(); }else{ // calendarStart->setHidden(true); } }
QRect ScreenGrabberChooserRectItem::chosenRect() const { QRect rect (x(), y(), rectWidth, rectHeight); if (rectWidth < 0) { rect.setX(rect.x() + rectWidth); rect.setWidth(-rectWidth); } if (rectHeight < 0) { rect.setY(rect.y() + rectHeight); rect.setHeight(-rectHeight); } return rect; }
void SongsQueryWideget::calendar_end_clicked(bool checked) { QRect rect = calendarStart->geometry(); QPoint point = QCursor::pos(); rect.setX(point.x()); rect.setY(point.y()); calendarEnd->setGeometry(point.x() - 230, point.y() + 50, 280, 180); if(checked){ calendarEnd->setHidden(false); calendarEnd->setFocus(); }else{ calendarEnd->setHidden(true); } }
void EtaKeyboard::animationFromBottom() { if (!tog) { tog=true; out->deleteWhole(); anime->setDuration(400); anime->setEasingCurve(QEasingCurve::OutBack); anime->setStartValue(QRect((screenWidth-m_width)/2,screenHeight,m_width,m_height)); QRect next; next.setY(screenHeight/2+m_height/2); next.setX((screenWidth-m_width)/2); next.setHeight(m_height); next.setWidth(m_width); anime->setEndValue(next); anime->start(); } }
void KviThemedComboBox::paintEvent ( QPaintEvent * event ) { #ifdef COMPILE_PSEUDO_TRANSPARENCY QPainter * p = new QPainter(this); QLineEdit *le = lineEdit(); if(le) { QRect r = rect(); QPalette pal = palette(); QStyleOptionFrameV2 option; option.initFrom(this); option.rect = contentsRect(); option.lineWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, &option, le); option.midLineWidth = 0; option.state |= QStyle::State_Sunken; if(le->isReadOnly()) option.state |= QStyle::State_ReadOnly; option.features = QStyleOptionFrameV2::None; r = style()->subElementRect(QStyle::SE_LineEditContents, &option, le); int left, right, top, bottom; le->getTextMargins(&left, &top, &right, &bottom); r.setX(r.x() + left); r.setY(r.y() + top); r.setRight(r.right() - right); r.setBottom(r.bottom() - bottom); p->setClipRect(r); } // else not editable if(KVI_OPTION_BOOL(KviOption_boolUseCompositingForTransparency) && g_pApp->supportsCompositing()) { p->setCompositionMode(QPainter::CompositionMode_Source); QColor col=KVI_OPTION_COLOR(KviOption_colorGlobalTransparencyFade); col.setAlphaF((float)((float)KVI_OPTION_UINT(KviOption_uintGlobalTransparencyChildFadeFactor) / (float)100)); p->fillRect(contentsRect(), col); } else if(g_pShadedChildGlobalDesktopBackground) { QPoint pnt = m_pKviWindow->mdiParent() ? mapTo(g_pMainWindow, contentsRect().topLeft() + g_pMainWindow->mdiManager()->scrollBarsOffset()) : mapTo(m_pKviWindow, contentsRect().topLeft()); p->drawTiledPixmap(contentsRect(),*(g_pShadedChildGlobalDesktopBackground), pnt); } delete p; #endif QComboBox::paintEvent(event); }
QRect MiamStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const { QRect r = QProxyStyle::subElementRect(element, option, widget); if (widget && widget->objectName() == "tabPlaylists") { const TabPlaylist *t = dynamic_cast<const TabPlaylist*>(widget); QRect minRect = QRect(0, 0, 0, 0); for (int i = 0; i < t->tabBar()->count(); i++) { minRect.setWidth(minRect.width() + t->tabBar()->tabRect(i).width()); } minRect.setHeight(t->tabBar()->tabRect(0).height()); switch (element) { case SE_TabWidgetRightCorner: r.setX(minRect.x() + minRect.width() + 1); r.setY(0); break; case SE_TabWidgetTabBar: { SettingsPrivate *settings = SettingsPrivate::instance(); if (!settings->isRectTabs()) { r = minRect.adjusted(0, 0, settings->tabsOverlappingLength(), 0); } else { r = minRect; } break; } default: break; } } else { if (widget && widget->objectName() == "tabBar") { const QStyleOptionTab *sot = qstyleoption_cast<const QStyleOptionTab*>(option); QStyleOptionTab tab = *sot; //qDebug() << Q_FUNC_INFO << element << r; if (element == SE_TabBarTabText) { //tab.rect.setX(tab.rect.x() + 20); //qDebug() << "SE_TabBarTabText" << sot->rect; return sot->rect; } else if (element == SE_CheckBoxContents) { //qDebug() << "SE_CheckBoxContents" << sot->rect; return sot->rect; } } } return r; }
void albumDelegate::drawDisplay(QPainter* painter, const QStyleOptionViewItem *option, QRect& rect,const QModelIndex &index) const { // painter->save(); const QStyleOptionViewItemV2 *opt=static_cast<const QStyleOptionViewItemV2 *>(option); if(!(opt->features & QStyleOptionViewItemV2::HasDisplay) ) return; painter->setFont(option->font); rect.setWidth(rect.width()-2); rect.setX(rect.x()+5); QString text=index.data(Qt::DisplayRole).toString(); // QString text=option->fontMetrics.elidedText(text, Qt::ElideRight, rect.width()); painter->drawText( rect,option->displayAlignment, text); }
void PopUpMessage::paintEvent(QPaintEvent *event) { Q_UNUSED(event) QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); QRect roundedRect; roundedRect.setX(rect().x() + 5); roundedRect.setY(rect().y() + 5); roundedRect.setWidth(rect().width() - 10); roundedRect.setHeight(rect().height() - 10); painter.setBrush(QBrush(QColor(0,0,0,180))); painter.setPen(Qt::NoPen); painter.drawRoundedRect(roundedRect, 10, 10); }
void ColorScaleButton::paintScale(QPainter *painter, const QRect &baseRect, const ColorScale &colorScale) { QRect rect = baseRect; rect.setX(rect.x() + 2); rect.setY(rect.y() + 2); rect.setWidth(rect.width() - 4); rect.setHeight(rect.height() - 4); QLinearGradient grad(QPointF(rect.x(), rect.y()), QPointF(rect.x() + rect.width(), rect.y())); std::map<float, Color> stops = colorScale.getColorMap(); for (std::map<float, Color>::iterator it = stops.begin(); it != stops.end(); ++it) grad.setColorAt(it->first, colorToQColor(it->second)); painter->setBrush(QBrush(grad)); painter->drawRect(rect); }
QRect BlockSplitter::getRootBlock(const QImage &image) { QImage img1 = image; QRect result = blockAllText(); RotationCropper rc(&img1, QColor("white").rgb(), generalBr); QRect r = rc.crop(); result.setWidth(result.width() + r.x()); result.setX(result.x() + r.x()); result.setHeight(result.height()+r.y()); result.setY(result.y() + r.y()); foreach (Rect rc, bars) { bars.removeOne(rc); rc.x1 += r.x(); rc.x2 += r.x(); rc.y1 += r.y(); rc.y2 += r.y(); bars.append(rc); }
bool BoxTool::beginCreating(const QPointF &pos_) { Body* b = scene()->activeBody(); QPointF pos = pos_; if (b) { pos = b->toLocal(pos_); } Tool::beginCreating(pos); QRect rect; rect.setX(pos.x()); rect.setY(pos.y()); rect.setWidth(10); rect.setHeight(10); if (m_primitive) delete m_primitive; m_primitive = 0; m_primitive = new BoxPrimitive( scene()->activeBody(),rect ); return true; }
void QgsWFSProgressDialog::resizeEvent( QResizeEvent *ev ) { QProgressDialog::resizeEvent( ev ); // Note: this relies heavily on the details of the layout done in QProgressDialogPrivate::layout() // Might be a bit fragile depending on QT versions. QRect rect = geometry(); QRect cancelRect = mCancel->geometry(); QRect hideRect = mHide->geometry(); int mtb = style()->pixelMetric( QStyle::PM_DefaultTopLevelMargin ); int mlr = std::min( width() / 10, mtb ); if ( rect.width() - cancelRect.x() - cancelRect.width() > mlr ) { // Force right alighnment of cancel button cancelRect.setX( rect.width() - cancelRect.width() - mlr ); mCancel->setGeometry( cancelRect ); } mHide->setGeometry( rect.width() - cancelRect.x() - cancelRect.width(), cancelRect.y(), hideRect.width(), cancelRect.height() ); }
void KisColorSelectorBase::showPopup(Move move) { // This slot may be called by some action, // so we need to be able to handle it lazyCreatePopup(); QPoint cursorPos = QCursor::pos(); if (move == MoveToMousePosition) { m_popup->move(cursorPos.x()-m_popup->width()/2, cursorPos.y()-m_popup->height()/2); QRect rc = m_popup->geometry(); if (rc.x() < 0) rc.setX(0); if (rc.y() < 0) rc.setY(0); m_popup->setGeometry(rc); } m_popup->show(); m_popup->m_colorPreviewPopup->show(); }
void RegionSelect::drawBackGround() { // create painter on pixelmap of desktop QPainter painter(&desktopPixmapBkg); // set painter brush on 85% transparency painter.setBrush(QBrush(QColor(0, 0, 0, 85), Qt::SolidPattern)); // draw rect of desktop size in poainter painter.drawRect(QApplication::desktop()->rect()); QRect txtRect = QApplication::desktop()->screenGeometry(QApplication::desktop()->primaryScreen()); QString txtTip = QApplication::tr("Use your mouse to draw a rectangle to screenshot or exit pressing\nany key or using the right or middle mouse buttons."); txtRect.setHeight(qRound(txtRect.height() / 10)); // rounded val of text rect height painter.setPen(QPen(Qt::red)); // ste message rect border color painter.setBrush(QBrush(QColor(255, 255, 255, 180), Qt::SolidPattern)); QRect txtBgRect = painter.boundingRect(txtRect, Qt::AlignCenter, txtTip); // set height & width of bkg rect txtBgRect.setX(txtBgRect.x() - 6); txtBgRect.setY(txtBgRect.y() - 4); txtBgRect.setWidth(txtBgRect.width() + 12); txtBgRect.setHeight(txtBgRect.height() + 8); painter.drawRect(txtBgRect); // Draw the text painter.setPen(QPen(Qt::black)); // black color pen painter.drawText(txtBgRect, Qt::AlignCenter, txtTip); palBackground = (qApp->desktop()->numScreens() > 1); // set bkg to pallette widget if (palBackground) { QPalette newPalette = palette(); newPalette.setBrush(QPalette::Window, QBrush(desktopPixmapBkg)); setPalette(newPalette); } }
QRect PersistentState::selectionRect() { if (!_persistentCursor.isNull() && _persistentCursor.hasSelection()) { QTextCursor startCursor(editor()->document()); QTextCursor endCursor(editor()->document()); startCursor.setPosition(_persistentCursor.selectionStart()); endCursor.setPosition(_persistentCursor.selectionEnd()); QRect rect = editor()->cursorRect(startCursor).unite(editor()->cursorRect(endCursor)); if (rect.height() > editor()->fontMetrics().height()) { rect.setX(0); rect.setWidth(editor()->width()); } return rect; } return QRect(); }
/*! Align the legend to the canvas \param canvasRect Geometry of the canvas \param legendRect Maximum geometry for the legend \return Geometry for the aligned legend */ QRect QwtPlotLayout::alignLegend(const QRect &canvasRect, const QRect &legendRect) const { QRect alignedRect = legendRect; if ( d_data->legendPos == QwtPlot::BottomLegend || d_data->legendPos == QwtPlot::TopLegend ) { if ( d_data->layoutData.legend.hint.width() < canvasRect.width() ) { alignedRect.setX(canvasRect.x()); alignedRect.setWidth(canvasRect.width()); } } else { if ( d_data->layoutData.legend.hint.height() < canvasRect.height() ) { alignedRect.setY(canvasRect.y()); alignedRect.setHeight(canvasRect.height()); } } return alignedRect; }
void TikzEditor::paintEvent(QPaintEvent *event) { QPainter painter(viewport()); if( m_highlightCurrentLine ) { // highlight current line QRect rect = cursorRect(); rect.setX(0); rect.setWidth(viewport()->width()); painter.fillRect(rect, QBrush(m_highlightCurrentLineColor)); } // show white spaces and tabulators if (m_showWhiteSpaces || m_showTabulators) printWhiteSpaces(painter); painter.end(); QPlainTextEdit::paintEvent(event); }
void KstViewBox::paintSelf(KstPainter& p, const QRegion& bounds) { p.save(); if (p.type() != KstPainter::P_PRINT && p.type() != KstPainter::P_EXPORT) { if (p.makingMask()) { p.setRasterOp(Qt::SetROP); } else { const QRegion clip(clipRegion()); KstViewObject::paintSelf(p, bounds - clip); p.setClipRegion(bounds & clip); } } // restrict the border width so we do not draw outside of the rectangle itself int bw(borderWidth() * p.lineWidthAdjustmentFactor()); if (bw > _geom.width() / 2) { bw = _geom.width() / 2; } if (bw > _geom.height()) { bw = _geom.height() / 2; } QPen pen(borderColor(), bw); pen.setJoinStyle(_cornerStyle); if (bw == 0) { pen.setStyle(Qt::NoPen); } p.setPen(pen); if (_transparentFill) { p.setBrush(Qt::NoBrush); } else { p.setBrush(_foregroundColor); } QRect r; r.setX(_geom.left() + bw / 2); r.setY(_geom.top() + bw / 2); r.setWidth(_geom.width() - bw); r.setHeight(_geom.height() - bw); p.drawRoundRect(r, _xRound, _yRound); p.restore(); }
void EditorSpashScreen::drawContents(QPainter *painter) { painter->setOpacity(1); painter->fillRect(rect(), QBrush(Qt::transparent)); painter->setOpacity(opacity); painter->drawPixmap(rect(), buffer, buffer.rect()); painter->setPen(Qt::black); painter->setBrush(Qt::white); painter->setRenderHint(QPainter::TextAntialiasing); painter->setRenderHint(QPainter::Antialiasing); for(int i=0; i<animations.size(); i++) { QPixmap &frame = animations[i].second->wholeImage(); QRect frameRect = animations[i].second->frameRect(); QRect x; x.setX(animations[i].first.x() RatioWidth); x.setY(animations[i].first.y() RatioHeight); x.setWidth(frameRect.width() RatioWidth); x.setHeight(frameRect.height() RatioHeight); painter->drawPixmap(x, frame, frameRect); } painter->setBrush(QBrush(Qt::black)); QPen progressLine_bar( QBrush(Qt::black), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); painter->setPen(progressLine_bar); painter->drawRect(0, rect().height()-5, rect().width(), 4); painter->setBrush(QBrush(Qt::green)); painter->setPen(Qt::transparent); painter->drawRect(0, rect().height()-4, Maths::iRound(double(rect().width()) *( (double)_percents/100.0)), 2); painter->setPen(Qt::white); painter->setFont(QFont("Lucida Grande", 8, -1, true)); QPainterPath path; path.addText(rect().x()+20, rect().bottom()-20, painter->font(), _label); painter->strokePath(path, QPen(QColor(Qt::black), 4)); painter->drawText(rect().x()+20, rect().bottom()-20, _label); }
void QwtLegendItem::drawItem(QPainter *painter, const QRect &rect) const { painter->save(); const QwtMetricsMap &map = QwtPainter::metricsMap(); const int margin = map.screenToLayoutX(Margin); const QRect identifierRect(rect.x() + margin, rect.y(), map.screenToLayoutX(IdentifierWidth), rect.height()); drawIdentifier(painter, identifierRect); // Label QRect titleRect = rect; titleRect.setX(identifierRect.right() + 2 * margin); text().draw(painter, titleRect); painter->restore(); }
void YocDialog::paintEvent(QPaintEvent *event) { QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing, true); QPen pen(QColor(Qt::black ),1,Qt::SolidLine,Qt::RoundCap,Qt::RoundJoin); QBrush brush(QColor(Qt::white),Qt::SolidPattern); painter.setPen(pen); painter.setBrush(brush); painter.drawRect(this->rect()); brush.setColor(QColor(Qt::lightGray)); painter.setBrush(brush); QRect textRect; textRect.setX(this->rect().x() + SIDEW); textRect.setY(this->rect().y() + SIDEW); textRect.setWidth(this->rect().width() - 2*SIDEW); textRect.setHeight(this->rect().height() - 2*SIDEW); painter.drawRect(textRect); QDialog::paintEvent(event); }
void GraphQtInteractiveRenderer::clipRegionAddRect(Rectangle *rect) { GraphQtRenderer *renderer = m_data->renderer; QRegion *clip = renderer->clipRegion(); QRect clipRect; clipRect.setX(rect->x()); clipRect.setY(rect->y()); clipRect.setWidth(rect->width()); clipRect.setHeight(rect->height()); *clip = clip->united(clipRect); QPainterPath path; path.addRegion(*clip); QPainter *painter = m_data->renderer->painter(); painter->setClipping(true); painter->setClipPath(path); }
void QStyleRangeSlider::paintFilling(QPainter& p, const QRect& bbox, const QPair<int, int>& range, const QPair<int, int>& cutoffRange) const { QRect paintBox; int x = getPosMin(bbox, range.first, cutoffRange); int width = getPosMax(bbox, range.second, cutoffRange) - x; paintBox.setX(x); paintBox.setY(getGrooveY(bbox)); paintBox.setWidth(width); paintBox.setHeight(getGrooveHeight(bbox)); QPolygon paintArea = QPolygon(paintBox, true); QRectF pbbox = paintArea.boundingRect(); QPointF p1 = pbbox.topLeft(); QPointF p2 = pbbox.bottomRight(); p2.setX(p1.x()); QLinearGradient grad(p1, p2); grad.setColorAt(0, Qt::black); grad.setColorAt(0.15, Qt::red); grad.setColorAt(0.85, Qt::red); grad.setColorAt(1.0, Qt::white); p.save(); //p.setRenderHint(QPainter::Antialiasing, true); p.setRenderHint(QPainter::HighQualityAntialiasing, true); p.setPen(Qt::NoPen); //p.drawPoints(paintArea); p.setBrush(QBrush(grad)); p.drawPolygon(paintArea); p.restore(); }
QList<QRect> FatherBlock::GetEnableBlockRects(int theStatusIndex,bool theRealBlocksFlag) { QList<QRect>theBlockRects; if(theStatusIndex == -1) { theStatusIndex = m_current_status_index; } if(theStatusIndex < m_status_list.count()) { QBitArray theStatus = m_status_list[theStatusIndex]; int count = theStatus.count()-1; while(count >= 0) { if(theStatus.testBit(count) == true) { QRect ChildBlockRect = QRect(m_blocks_list[count]->geometry()); ChildBlockRect.setX(ChildBlockRect.x() + this->x()); ChildBlockRect.setY(ChildBlockRect.y() + this->y()); ChildBlockRect.setWidth(m_blocks_list[count]->width()); ChildBlockRect.setHeight(m_blocks_list[count]->height()); if(!hasBottomBlock(count) && !theRealBlocksFlag) { QRect tempBlock(ChildBlockRect); tempBlock.setY(ChildBlockRect.y()+m_blocks_list[count]->height()); theBlockRects.append(tempBlock); } if(!hasRightBlock(count) && !theRealBlocksFlag) { QRect tempBlock(ChildBlockRect); tempBlock.setX(ChildBlockRect.x() + m_blocks_list[count]->width()); theBlockRects.append(tempBlock); } theBlockRects.append(ChildBlockRect); } count--; } } return theBlockRects; }
void BubbleManager::onCCDestRectChanged(const QRect &destRect) { // get the current rect of control-center m_ccGeometry = m_dbusControlCenter->rect(); // use the current rect of control-center to setup position of bubble // to avoid a move-anim bug m_bubble->setBasePosition(getX(), getY()); // use destination rect of control-center to setup move-anim if (destRect.width() == 0) { // closing the control-center if (m_dockPosition == DockPosition::Right) { const QRect &screenRect = screensInfo(QCursor::pos()).first; if ((screenRect.height() - m_dockGeometry.height()) / 2.0 < m_bubble->height()) { QRect mRect = destRect; mRect.setX((screenRect.right()) - m_dockGeometry.width()); m_bubble->resetMoveAnim(mRect); return; } } } m_bubble->resetMoveAnim(destRect); }
// Determine the free area behind the last action. QRect ToolBarEventFilter::freeArea(const QToolBar *tb) { QRect rc = QRect(QPoint(0, 0), tb->size()); const ActionList actionList = tb->actions(); QRect exclusionRectangle = actionList.empty() ? handleArea(tb) : tb->actionGeometry(actionList.back()); switch (tb->orientation()) { case Qt::Horizontal: switch (QApplication::layoutDirection()) { case Qt::LeftToRight: rc.setX(exclusionRectangle.right() + 1); break; case Qt::RightToLeft: rc.setRight(exclusionRectangle.x()); break; } break; case Qt::Vertical: rc.setY(exclusionRectangle.bottom() + 1); break; } return rc; }
void GfxCanvasClip::paint(GfxPainter &g) { QRect ucr = g.userClipRect(); QRect cr = clip(); if(!(_type & Height) && !g.clipRect().isEmpty()) { cr.setY(g.clipRect().y()); cr.setHeight(g.clipRect().height()); } if(!(_type & Width) && !g.clipRect().isEmpty()) { cr.setX(g.clipRect().x()); cr.setWidth(g.clipRect().width()); } if(!ucr.isEmpty()) cr &= ucr; if(!cr.isEmpty()) { g.setUserClipRect(cr); GfxCanvasItem::paint(g); g.setUserClipRect(ucr); } }
void NotifyUI::paintEvent(QPaintEvent *) { // paint word QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); QRect rect; rect.setX(0); rect.setY(0); rect.setWidth(width() - 1); rect.setHeight(height() - 1); painter.setPen(QColor(0, 0, 0, 0)); QPainterPath path; path.addRoundedRect(rect, 5, 5); painter.drawPath(path); QColor backColor = ConfigureData::getInstance()->getColorIni("color1"); painter.fillPath(path, QBrush(backColor)); painter.setPen(Qt::white); QFont font(cns("微软雅黑")); font.setPixelSize(fontsize); painter.setFont(font); painter.drawText(QRect(QPoint(0, 0), this->size()), Qt::AlignCenter, text); }