本文整理汇总了C++中contentsRect函数的典型用法代码示例。如果您正苦于以下问题:C++ contentsRect函数的具体用法?C++ contentsRect怎么用?C++ contentsRect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了contentsRect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: style
void UimToolbarDraggingHandler::drawContents( QPainter* p )
{
const QStyle::SFlags flags = QStyle::Style_Default | QStyle::Style_Horizontal;
style().drawPrimitive( QStyle::PE_DockWindowSeparator, p,
contentsRect(), colorGroup(), flags );
}
示例2: newPoints
void QLCDNumber::internalSetString( const QString& s )
{
QString buffer;
int i;
int len = s.length();
QBitArray newPoints(ndigits);
if ( !smallPoint ) {
if ( len == ndigits )
buffer = s;
else
buffer = s.right( ndigits ).rightJustify( ndigits, ' ' );
} else {
int index = -1;
bool lastWasPoint = TRUE;
newPoints.clearBit(0);
for ( i=0; i<len; i++ ) {
if ( s[i] == '.' ) {
if ( lastWasPoint ) { // point already set for digit?
if ( index == ndigits - 1 ) // no more digits
break;
index++;
buffer[index] = ' '; // 2 points in a row, add space
}
newPoints.setBit(index); // set decimal point
lastWasPoint = TRUE;
} else {
if ( index == ndigits - 1 )
break;
index++;
buffer[index] = s[i];
newPoints.clearBit(index); // decimal point default off
lastWasPoint = FALSE;
}
}
if ( index < ((int) ndigits) - 1 ) {
for( i=index; i>=0; i-- ) {
buffer[ndigits - 1 - index + i] = buffer[i];
newPoints.setBit( ndigits - 1 - index + i,
newPoints.testBit(i) );
}
for( i=0; i<ndigits-index-1; i++ ) {
buffer[i] = ' ';
newPoints.clearBit(i);
}
}
}
if ( buffer == digitStr )
return;
if ( backgroundMode() == FixedPixmap
|| colorGroup().brush( QColorGroup::Background ).pixmap() ) {
digitStr = buffer;
if ( smallPoint )
points = newPoints;
repaint( contentsRect() );
}
else {
QPainter p( this );
if ( !smallPoint )
drawString( buffer, p );
else
drawString( buffer, p, &newPoints );
}
}
示例3: QLabel
QZuesLabel::QZuesLabel(QWidget *parent)
: QLabel(parent), m_placeholdText("..."), m_type(LABEL_TYPE_NORMAL), m_maqueeTimerId(-1), m_maqueeSpeed(100), m_contentsRect(contentsRect()), m_stepLength(5)
{
}
示例4: painter
void QBouton::paintEvent(QPaintEvent *event)
{
// Used for normal buttons
if (!m_resizeInsteadOfCropping && m_border == 0 && m_progressMax == 0)
{
QPushButton::paintEvent(event);
return;
}
QPainter painter(this);
QRect region = m_smartSizeHint ? contentsRect() : event->rect();
QSize iconSize = getIconSize(region.width(), region.height());
int p = m_border;
int x = region.x();
int y = region.y();
int w = iconSize.width() + 2*p;
int h = iconSize.height() + 2*p;
// Ignore invalid images
if (w == 0 || h == 0)
return;
// Center the image
bool center = true;
if (center)
{
x += (region.width() - w) / 2;
y += (region.height() - h) / 2;
}
// Draw image
QIcon::Mode mode = this->isChecked() ? QIcon::Selected : QIcon::Normal;
if (w > h)
{
icon().paint(&painter, x+p, y+p, w-2*p, w-2*p, Qt::AlignLeft | Qt::AlignTop, mode);
h = h-((h*2*p)/w)+2*p-1;
}
else
{
icon().paint(&painter, x+p, y+p, h-2*p, h-2*p, Qt::AlignLeft | Qt::AlignTop, mode);
w = w-((w*2*p)/h)+2*p-1;
}
// Clip borders overflows
painter.setClipRect(x, y, w, h);
// Draw progress
if (m_progressMax > 0 && m_progress > 0 && m_progress != m_progressMax)
{
int lineHeight = 6;
int a = p + lineHeight/2;
float ratio = (float)m_progress / m_progressMax;
QPoint p1(qMax(x, 0) + a, qMax(y, 0) + a);
QPoint p2(p1.x() + (iconSize.width() - a) * ratio, p1.y());
if (p2.x() > p1.x())
{
QPen pen(QColor(0, 200, 0));
pen.setWidth(lineHeight);
painter.setPen(pen);
painter.drawLine(p1, p2);
}
}
// Draw borders
if (p > 0 && m_penColor.isValid())
{
QPen pen(m_penColor);
pen.setWidth(p*2);
painter.setPen(pen);
painter.drawRect(qMax(x,0), qMax(y,0), qMin(w,size().width()), qMin(h,size().height()));
}
}
示例5: Q_UNUSED
void ExprCSwatchFrame::paintEvent(QPaintEvent* event)
{
Q_UNUSED(event);
QPainter p(this);
p.fillRect(contentsRect(),_color);
}
示例6: repaint
void KProgress::rangeChange()
{
repaint(contentsRect(), FALSE);
emit percentageChanged(recalcValue(100));
}
示例7: contentsRect
/*!
\return Rectangle of the wheel without the outer border
*/
QRect QwtWheel::wheelRect() const
{
const int bw = d_data->borderWidth;
return contentsRect().adjusted( bw, bw, -bw, -bw );
}
示例8: pipe
/*!
\return Bounding rectangle of the pipe ( without borders )
in widget coordinates
*/
QRect QwtThermo::pipeRect() const
{
const QRect cr = contentsRect();
int mbd = 0;
if ( d_data->scalePos != NoScale )
{
int d1, d2;
scaleDraw()->getBorderDistHint( font(), d1, d2 );
mbd = qMax( d1, d2 );
}
int bw = d_data->borderWidth;
QRect tRect;
if ( d_data->orientation == Qt::Horizontal )
{
switch ( d_data->scalePos )
{
case TopScale:
{
tRect.setRect(
cr.x() + mbd + bw,
cr.y() + cr.height() - d_data->pipeWidth - 2 * bw,
cr.width() - 2 * ( bw + mbd ),
d_data->pipeWidth
);
break;
}
case BottomScale:
case NoScale:
default:
{
tRect.setRect(
cr.x() + mbd + bw,
cr.y() + d_data->borderWidth,
cr.width() - 2 * ( bw + mbd ),
d_data->pipeWidth
);
break;
}
}
}
else // Qt::Vertical
{
switch ( d_data->scalePos )
{
case RightScale:
{
tRect.setRect(
cr.x() + bw,
cr.y() + mbd + bw,
d_data->pipeWidth,
cr.height() - 2 * ( bw + mbd )
);
break;
}
case LeftScale:
case NoScale:
default:
{
tRect.setRect(
cr.x() + cr.width() - 2 * bw - d_data->pipeWidth,
cr.y() + mbd + bw,
d_data->pipeWidth,
cr.height() - 2 * ( bw + mbd ) );
break;
}
}
}
return tRect;
}
示例9: init
void WicdApplet::init()
{
m_theme->resize(contentsRect().size());
Plasma::ToolTipManager::self()->registerWidget(this);
//load dataengine
Plasma::DataEngine *engine = dataEngine("wicd");
if (!engine->isValid()) {
setFailedToLaunch(true, i18n("Unable to load the Wicd data engine."));
return;
}
setupActions();
//build the popup dialog
QGraphicsWidget *appletDialog = new QGraphicsWidget(this);
m_dialoglayout = new QGraphicsLinearLayout(Qt::Vertical);
//Network list
m_scrollWidget = new Plasma::ScrollWidget(appletDialog);
m_scrollWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_scrollWidget->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
m_scrollWidget->setMaximumHeight(400);
m_networkView = new NetworkView(m_scrollWidget);
m_scrollWidget->setWidget(m_networkView);
m_busyWidget = new Plasma::BusyWidget(m_scrollWidget);
m_busyWidget->hide();
m_dialoglayout->addItem(m_scrollWidget);
//Separator
m_dialoglayout->addItem(new Plasma::Separator(appletDialog));
//Bottom bar
QGraphicsLinearLayout* bottombarLayout = new QGraphicsLinearLayout(Qt::Horizontal);
m_messageBox = new Plasma::Label(appletDialog);
m_messageBox->setWordWrap(false);
bottombarLayout->addItem(m_messageBox);
bottombarLayout->addStretch();
m_abortButton = new Plasma::ToolButton(appletDialog);
m_abortButton->setIcon(KIcon("dialog-cancel"));
m_abortButton->nativeWidget()->setToolTip(i18n("Abort"));
connect(m_abortButton, SIGNAL(clicked()), this, SLOT(cancelConnect()));
bottombarLayout->addItem(m_abortButton);
Plasma::ToolButton *reloadButton = new Plasma::ToolButton(appletDialog);
reloadButton->nativeWidget()->setToolTip(i18n("Reload"));
reloadButton->setAction(action("reload"));
bottombarLayout->addItem(reloadButton);
m_dialoglayout->addItem(bottombarLayout);
appletDialog->setLayout(m_dialoglayout);
setGraphicsWidget(appletDialog);
setHasConfigurationInterface(true);
// read config
configChanged();
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), SLOT(updateColors()));
//prevent notification on startup
m_status.State = 10;
m_isScanning = false;
//connect dataengine
m_wicdService = engine->serviceForSource("");
engine->connectSource("status", this);
engine->connectSource("daemon", this);
}
示例10: contentsRect
//-----------------------------------------------------------------------------
//!
//-----------------------------------------------------------------------------
void tTideGraph::paintEvent( QPaintEvent* pEvent )
{
tTideCurrentGraphBase::paintEvent( pEvent );
int w = contentsRect().width();
int h = contentsRect().height();
QPainter p( this );
p.setRenderHint( QPainter::Antialiasing, true );
p.setClipRect( contentsRect() );
QRect r( QPoint(0,0), contentsRect().size() );
// lets translate the painter so we can work with a 0,0 origin
p.save();
p.translate( contentsRect().topLeft() );
//###### 1) Paint background and the daylight area
if(m_SunRiseX <= m_SunSetX)
{
// left night
p.fillRect( 0, 0, m_SunRiseX, h, palette().dark() );
// day
p.fillRect( m_SunRiseX, 0, m_SunSetX - m_SunRiseX, h, palette().light() );
// right night
p.fillRect( m_SunSetX, 0, w - m_SunSetX, h, palette().dark() );
}
else if(m_SunRiseX > m_SunSetX)
{
// left day
p.fillRect( 0, 0, m_SunSetX, h, palette().light() );
// night
p.fillRect( m_SunSetX, 0, m_SunRiseX - m_SunSetX, h, palette().dark() );
// right day
p.fillRect( m_SunRiseX, 0, w - m_SunRiseX, h, palette().light() );
}
//###### 2) Add legend backgrounds
QColor c = palette().text().color();
c.setAlpha( 127 );
p.fillRect( 0, h - BOTTOM_MARGIN_HEIGHT, w, BOTTOM_MARGIN_HEIGHT, QBrush( c ) );
p.fillRect( 0, 0, LEFT_MARGIN_WIDTH, h, palette().base() );
// we have finished doing work with a 0,0 origin
p.restore();
//###### 3) Left depth legend and grid lines
p.rotate(-90);
p.setRenderHint( QPainter::Antialiasing, false );
c.setAlpha( 63 );
QPen pen( QBrush( c ), 0 );
qreal rangeDiv = GetRangeDivision( tConvert::Instance()->ToUser(UNITS_DEPTH, m_HeightUnits, static_cast<float>(m_GraphConfig.m_DeltaY)) );
float stepSize = tConvert::Instance()->UserToBase( UNITS_DEPTH, static_cast<float>(rangeDiv) );
stepSize = tConvert::Instance()->BaseToSpecifiedUnits(UNITS_DEPTH, m_HeightUnits, stepSize);
for( qreal pxY = 0, strY = 0; pxY <= m_GraphConfig.m_MaxY; pxY += stepSize, strY += rangeDiv )
{
p.setPen( palette().text().color() );
p.drawText(RotatedTextELeftMargin(0, pxY, 40), Qt::AlignCenter, QString("%1").arg(strY) );
p.setPen( pen );
p.drawLine(RotatedGraphToPixel(0, pxY), RotatedGraphToPixel(1, pxY));
}
for( qreal pxY = 0, strY = 0; pxY >= m_GraphConfig.m_MinY; pxY -= stepSize, strY += rangeDiv )
{
p.setPen( palette().text().color() );
p.drawText(RotatedTextELeftMargin(0, pxY, 40), Qt::AlignCenter, QString("%1").arg(strY) );
p.setPen( pen );
p.drawLine(RotatedGraphToPixel(0, pxY), RotatedGraphToPixel(1, pxY));
}
p.rotate(90);
p.drawLine( QPointF( GraphToPixel(0.25, 0).x(), 0 ), QPointF( GraphToPixel(0.25, 0).x(), h ) );
p.drawLine( QPointF( GraphToPixel(0.5, 0).x(), 0 ), QPointF( GraphToPixel(0.5, 0).x(), h ) );
p.drawLine( QPointF( GraphToPixel(0.75, 0).x(), 0 ), QPointF( GraphToPixel(0.75, 0).x(), h ) );
p.setRenderHint( QPainter::Antialiasing, true );
//###### 4) Graph and fill the tides spline
QPainterPath path;
path.moveTo( GraphToPixel(0, 0) );
for( int i = 0; i < m_TideHeights.size(); ++i )
{
// source data is in 10 minute intervals => 1/144 of a day
path.lineTo( GraphToPixel( m_TideHeights.at(i).x(), m_TideHeights.at(i).y() ) );
}
// Close the path
path.lineTo( GraphToPixel(1, 0) );
path.lineTo( GraphToPixel(0, 0) );
//###### 5) Fill graph path
QLinearGradient gradient(0,0,0,h);
QColor endColor = palette().highlight().color();
endColor.setAlpha( 191 );
QColor midColor = palette().highlight().color().lighter( 130 );
midColor.setAlpha( 191 );
gradient.setColorAt(0.0, endColor);
gradient.setColorAt(0.1, endColor);
gradient.setColorAt(0.5, midColor);
//.........这里部分代码省略.........
示例11: checker
void KoColorSlider::drawContents( QPainter *painter )
{
QPixmap checker(8, 8);
QPainter p(&checker);
p.fillRect(0, 0, 4, 4, Qt::lightGray);
p.fillRect(4, 0, 4, 4, Qt::darkGray);
p.fillRect(0, 4, 4, 4, Qt::darkGray);
p.fillRect(4, 4, 4, 4, Qt::lightGray);
p.end();
QRect contentsRect_(contentsRect());
painter->fillRect(contentsRect_, QBrush(checker));
if( !d->upToDate || d->pixmap.isNull() || d->pixmap.width() != contentsRect_.width()
|| d->pixmap.height() != contentsRect_.height() )
{
KoColor c = d->minColor; // smart way to fetch colorspace
QColor color;
const quint8 *colors[2];
colors[0] = d->minColor.data();
colors[1] = d->maxColor.data();
KoMixColorsOp * mixOp = c.colorSpace()->mixColorsOp();
QImage image(contentsRect_.width(), contentsRect_.height(), QImage::Format_ARGB32 );
if( orientation() == Qt::Horizontal ) {
for (int x = 0; x < contentsRect_.width(); x++) {
qreal t = static_cast<qreal>(x) / (contentsRect_.width() - 1);
qint16 colorWeights[2];
colorWeights[0] = static_cast<quint8>((1.0 - t) * 255 + 0.5);
colorWeights[1] = 255 - colorWeights[0];
mixOp->mixColors(colors, colorWeights, 2, c.data());
c.toQColor(&color);
for (int y = 0; y < contentsRect_.height(); y++)
image.setPixel(x, y, color.rgba());
}
}
else {
for (int y = 0; y < contentsRect_.height(); y++) {
qreal t = static_cast<qreal>(y) / (contentsRect_.height() - 1);
qint16 colorWeights[2];
colorWeights[0] = static_cast<quint8>((t) * 255 + 0.5);
colorWeights[1] = 255 - colorWeights[0];
mixOp->mixColors(colors, colorWeights, 2, c.data());
c.toQColor(&color);
for (int x = 0; x < contentsRect_.width(); x++)
image.setPixel(x, y, color.rgba());
}
}
d->pixmap = QPixmap::fromImage(image);
d->upToDate = true;
}
painter->drawPixmap( contentsRect_, d->pixmap, QRect( 0, 0, d->pixmap.width(), d->pixmap.height()) );
}
示例12: ASSERT
bool CoordinatedGraphicsLayer::imageBackingVisible()
{
ASSERT(m_coordinatedImageBacking);
return tiledBackingStoreVisibleRect().intersects(IntRect(contentsRect()));
}
示例13: MiniSplitterHandle
MiniSplitterHandle(Qt::Orientation orientation, QSplitter *parent)
: QSplitterHandle(orientation, parent)
{
setMask(QRegion(contentsRect()));
setAttribute(Qt::WA_MouseNoMask, true);
}
示例14: contentsRect
void KProgress::drawContents(QPainter *p)
{
QRect cr = contentsRect(), er = cr;
fr = cr;
QBrush fb(bar_color), eb(backgroundColor());
if (bar_pixmap)
fb.setPixmap(*bar_pixmap);
if (backgroundPixmap())
eb.setPixmap(*backgroundPixmap());
switch (bar_style) {
case Solid:
if (orient == Horizontal) {
fr.setWidth(recalcValue(cr.width()));
er.setLeft(fr.right() + 1);
} else {
fr.setTop(cr.bottom() - recalcValue(cr.height()));
er.setBottom(fr.top() - 1);
}
p->setBrushOrigin(cr.topLeft());
p->fillRect(fr, fb);
p->fillRect(er, eb);
break;
case Blocked:
const int margin = 2;
int max, num, dx, dy;
if (orient == Horizontal) {
fr.setHeight(cr.height() - 2 * margin);
fr.setWidth((int)(0.67 * fr.height()));
fr.moveTopLeft(QPoint(cr.left() + margin, cr.top() + margin));
dx = fr.width() + margin;
dy = 0;
max = (cr.width() - margin) / (fr.width() + margin) + 1;
num = recalcValue(max);
} else {
fr.setWidth(cr.width() - 2 * margin);
fr.setHeight((int)(0.67 * fr.width()));
fr.moveBottomLeft(QPoint(cr.left() + margin, cr.bottom() - margin));
dx = 0;
dy = - (fr.height() + margin);
max = (cr.height() - margin) / (fr.height() + margin) + 1;
num = recalcValue(max);
}
p->setClipRect(cr.x() + margin, cr.y() + margin,
cr.width() - margin, cr.height() - margin);
for (int i = 0; i < num; i++) {
p->setBrushOrigin(fr.topLeft());
p->fillRect(fr, fb);
fr.moveBy(dx, dy);
}
if (num != max) {
if (orient == Horizontal)
er.setLeft(fr.right() + 1);
else
er.setBottom(fr.bottom() + 1);
if (!er.isNull()) {
p->setBrushOrigin(cr.topLeft());
p->fillRect(er, eb);
}
}
break;
}
if (text_enabled && bar_style != Blocked)
drawText(p);
}
示例15: resizeEvent
/*!
\brief Adjust plot content to its current size.
\sa resizeEvent()
*/
void QwtPlot::updateLayout()
{
d_data->layout->activate( this, contentsRect() );
QRect titleRect = d_data->layout->titleRect().toRect();
QRect footerRect = d_data->layout->footerRect().toRect();
QRect scaleRect[QwtPlot::axisCnt];
for ( int axisId = 0; axisId < axisCnt; axisId++ )
scaleRect[axisId] = d_data->layout->scaleRect( axisId ).toRect();
QRect legendRect = d_data->layout->legendRect().toRect();
QRect canvasRect = d_data->layout->canvasRect().toRect();
// resize and show the visible widgets
if ( !d_data->titleLabel->text().isEmpty() )
{
d_data->titleLabel->setGeometry( titleRect );
if ( !d_data->titleLabel->isVisibleTo( this ) )
d_data->titleLabel->show();
}
else
d_data->titleLabel->hide();
if ( !d_data->footerLabel->text().isEmpty() )
{
d_data->footerLabel->setGeometry( footerRect );
if ( !d_data->footerLabel->isVisibleTo( this ) )
d_data->footerLabel->show();
}
else
d_data->footerLabel->hide();
for ( int axisId = 0; axisId < axisCnt; axisId++ )
{
if ( axisEnabled( axisId ) )
{
axisWidget( axisId )->setGeometry( scaleRect[axisId] );
#if 1
if ( axisId == xBottom || axisId == xTop )
{
// do we need this code any longer ???
QRegion r( scaleRect[axisId] );
if ( axisEnabled( yLeft ) )
r = r.subtracted( QRegion( scaleRect[yLeft] ) );
if ( axisEnabled( yRight ) )
r = r.subtracted( QRegion( scaleRect[yRight] ) );
r.translate( -scaleRect[ axisId ].x(),
-scaleRect[axisId].y() );
axisWidget( axisId )->setMask( r );
}
#endif
if ( !axisWidget( axisId )->isVisibleTo( this ) )
axisWidget( axisId )->show();
}
else
axisWidget( axisId )->hide();
}
if ( d_data->legend )
{
if ( d_data->legend->isEmpty() )
{
d_data->legend->hide();
}
else
{
d_data->legend->setGeometry( legendRect );
d_data->legend->show();
}
}
d_data->canvas->setGeometry( canvasRect );
}