示例#1
0
/*!
    \reimp
*/
void QProgressBar::drawContents( QPainter *p )
{
    const QRect bar = contentsRect();

    QSharedDoubleBuffer buffer( p, bar.x(), bar.y(), bar.width(), bar.height() );

    QPoint pn = backgroundOffset();
    buffer.painter()->setBrushOrigin( -pn.x(), -pn.y() );

    const QPixmap *bpm = paletteBackgroundPixmap();
    if ( bpm )
	buffer.painter()->fillRect( bar, QBrush( paletteBackgroundColor(), *bpm ) );
    else
	buffer.painter()->fillRect( bar, paletteBackgroundColor() );
    buffer.painter()->setFont( p->font() );

    QStyle::SFlags flags = QStyle::Style_Default;
    if (isEnabled())
	flags |= QStyle::Style_Enabled;
    if (hasFocus())
	flags |= QStyle::Style_HasFocus;

    style().drawControl(QStyle::CE_ProgressBarGroove, buffer.painter(), this,
			QStyle::visualRect(style().subRect(QStyle::SR_ProgressBarGroove, this), this ),
			colorGroup(), flags);

    style().drawControl(QStyle::CE_ProgressBarContents, buffer.painter(), this,
			QStyle::visualRect(style().subRect(QStyle::SR_ProgressBarContents, this), this ),
			colorGroup(), flags);

    if (percentageVisible())
	style().drawControl(QStyle::CE_ProgressBarLabel, buffer.painter(), this,
			    QStyle::visualRect(style().subRect(QStyle::SR_ProgressBarLabel, this), this ),
			    colorGroup(), flags);
}
示例#2
0
/*!
    \reimp
*/
void Q3ProgressBar::paintEvent(QPaintEvent *)
{
    QPainter paint(this);
    QPainter *p = &paint;
    drawFrame(p);

    QStyleOptionProgressBar opt = getStyleOption(this);
    opt.rect = style()->subElementRect(QStyle::SE_ProgressBarGroove, &opt, this);

    style()->drawControl(QStyle::CE_ProgressBarGroove, &opt, p, this);
    opt.rect = contentsRect();
    opt.rect = style()->subElementRect(QStyle::SE_ProgressBarContents, &opt, this);
    style()->drawControl(QStyle::CE_ProgressBarContents, &opt, p, this);

    if (percentageVisible()) {
        opt.rect = contentsRect();
        opt.rect = style()->subElementRect(QStyle::SE_ProgressBarLabel, &opt, this);
        style()->drawControl(QStyle::CE_ProgressBarLabel, &opt, p, this);
    }
}
示例#3
0
bool KProgress::textEnabled() const
{
    return percentageVisible();
}