void LegendWidget::print(QPainter *painter, const QwtScaleMap map[QwtPlot::axisCnt]) { int x = map[QwtPlot::xBottom].transform(calculateXValue()); int y = map[QwtPlot::yLeft].transform(calculateYValue()); const int symbolLineLength = line_length + symbolsMaxWidth(); int width, height, textWidth, textHeight; QwtArray<long> heights = itemsHeight(symbolLineLength, width, height, textWidth, textHeight); drawFrame(painter, QRect(x, y, width, height)); drawText(painter, QRect(x, y, textWidth, textHeight), heights, symbolLineLength); }
void LegendWidget::paintEvent(QPaintEvent *e) { const int symbolLineLength = line_length + symbolsMaxWidth(); int width, height, textWidth, textHeight; QwtArray<long> heights = itemsHeight(symbolLineLength, width, height, textWidth, textHeight); resize(width, height); QPainter p(this); drawFrame(&p, rect()); drawText(&p, QRect(0, 0, textWidth, textHeight), heights, symbolLineLength); e->accept(); }
QRect LegendMarker::rect() const { const QwtScaleMap &xMap = d_plot->canvasMap(xAxis()); const QwtScaleMap &yMap = d_plot->canvasMap(yAxis()); const int x = xMap.transform(xValue()); const int y = yMap.transform(yValue()); int width, height; itemsHeight(y, symbolsMaxLineLength(), width, height); return QRect(QPoint(x, y), QSize(width - 1, height - 1)); }
void LegendWidget::print(QPainter *painter, const QwtScaleMap map[QwtPlot::axisCnt]) { int x = map[QwtPlot::xBottom].transform(xValue()); int y = map[QwtPlot::yLeft].transform(yValue()); const int symbolLineLength = line_length + symbolsMaxWidth(); int width, height; QwtArray<int> heights = itemsHeight(y, symbolLineLength, width, height); QRect rect = QRect(x, y, width, height); drawFrame(painter, rect); drawText(painter, rect, heights, symbolLineLength); }
void LegendMarker::draw(QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &) const { const int x = xMap.transform(xValue()); const int y = yMap.transform(yValue()); const int symbolLineLength = symbolsMaxLineLength(); int width, height; QwtArray<long> heights = itemsHeight(y, symbolLineLength, width, height); QRect rs = QRect(QPoint(x, y), QSize(width, height)); drawFrame(p, d_frame, rs); drawSymbols(p, rs, heights, symbolLineLength); drawLegends(p, rs, heights, symbolLineLength); }
void LegendWidget::paintEvent(QPaintEvent *e) { if (d_fixed_coordinates){ setOriginCoord(d_x, d_y); d_fixed_coordinates = false; } const int symbolLineLength = line_length + symbolsMaxWidth(); int width, height; QwtArray<int> heights = itemsHeight(0, symbolLineLength, width, height); if (d_frame == Shadow) resize(width + 5, height + 5); else resize(width, height); QRect rect = QRect(0, 0, width - 1, height - 1); QPainter p(this); drawFrame(&p, rect); drawText(&p, rect, heights, symbolLineLength); e->accept(); }
void KListWidgetPrivate::resetAreas() { Q_Q(KListWidget); QSizeF winSize = q->size(); if(winSize.height() < itemsHeight()) { //需要滚动条 if(m_scrollbar == NULL) { m_scrollbar = new KScrollBar(q); QObject::connect(m_scrollbar, SIGNAL(valueChanged(qreal)), q, SLOT(on_scroll_valueChanged(qreal))); } qreal thickness = m_scrollbar->frameThickness(); m_vscrollArea = QRectF(winSize.width() - thickness, 0, thickness, winSize.height()); m_contentArea = QRectF(0, 0, winSize.width() - m_thinknessScrollbar, winSize.height()); m_scrollbar->setGeometry(m_vscrollArea); m_scrollbar->setFixSize(m_vscrollArea.size()); qreal maxval = maxScrollValue(); m_scrollbar->setRange(0, maxval); m_valueCurrentScroll = qBound<int>(0, m_valueCurrentScroll, maxval); m_scrollbar->setSingleStep(m_heightUnselect); m_scrollbar->setPageStep(m_contentArea.height() - m_heightUnselect); m_scrollbar->show(); } else { //不需要滚动条 m_valueCurrentScroll = 0; m_contentArea = QRectF(0, 0, winSize.width(), winSize.height()); if(m_scrollbar) { m_scrollbar->hide(); } } /*重新调整所有项的尺寸*/ doLayout(); }
qreal KListWidgetPrivate::maxScrollValue() { Q_Q(KListWidget); return itemsHeight() - m_contentArea.height() + m_heightContentBottomHidden; }