本文整理汇总了C++中contentsRect函数的典型用法代码示例。如果您正苦于以下问题:C++ contentsRect函数的具体用法?C++ contentsRect怎么用?C++ contentsRect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了contentsRect函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 );
}
开发者ID:TheSLinux-forks,项目名称:uim,代码行数:6,代码来源:standalone-qt.cpp
示例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 );
}
}
开发者ID:opieproject,项目名称:qte-opie,代码行数:66,代码来源:qlcdnumber.cpp
示例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)
{
}
开发者ID:schindleren,项目名称:qzues,代码行数:5,代码来源:qzueslabel.cpp
示例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()));
}
}
开发者ID:Flat,项目名称:imgbrd-grabber,代码行数:74,代码来源:QBouton.cpp
示例5: Q_UNUSED
void ExprCSwatchFrame::paintEvent(QPaintEvent* event)
{
Q_UNUSED(event);
QPainter p(this);
p.fillRect(contentsRect(),_color);
}
开发者ID:ezhangle,项目名称:SeExpr,代码行数:6,代码来源:ExprColorCurve.cpp
示例6: repaint
void KProgress::rangeChange()
{
repaint(contentsRect(), FALSE);
emit percentageChanged(recalcValue(100));
}
开发者ID:kthxbyte,项目名称:KDE1-Linaro,代码行数:5,代码来源:kprogress.cpp
示例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 );
}
开发者ID:TheLortex,项目名称:Robotique-MJC-2011,代码行数:8,代码来源:qwt_wheel.cpp
示例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;
}
开发者ID:01iv3r,项目名称:OpenPilot,代码行数:77,代码来源:qwt_thermo.cpp
示例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);
}
开发者ID:KDE,项目名称:wicd-kde,代码行数:77,代码来源:wicdapplet.cpp
示例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);
//.........这里部分代码省略.........
开发者ID:dulton,项目名称:53_hero,代码行数:101,代码来源:tTideGraph.cpp
示例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()) );
}
开发者ID:KDE,项目名称:koffice,代码行数:65,代码来源:KoColorSlider.cpp
示例12: ASSERT
bool CoordinatedGraphicsLayer::imageBackingVisible()
{
ASSERT(m_coordinatedImageBacking);
return tiledBackingStoreVisibleRect().intersects(IntRect(contentsRect()));
}
开发者ID:Wrichik1999,项目名称:webkit,代码行数:5,代码来源:CoordinatedGraphicsLayer.cpp
示例13: MiniSplitterHandle
MiniSplitterHandle(Qt::Orientation orientation, QSplitter *parent)
: QSplitterHandle(orientation, parent)
{
setMask(QRegion(contentsRect()));
setAttribute(Qt::WA_MouseNoMask, true);
}
开发者ID:halsten,项目名称:beaverdbg,代码行数:6,代码来源:minisplitter.cpp
示例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);
}
开发者ID:kthxbyte,项目名称:KDE1-Linaro,代码行数:74,代码来源:kprogress.cpp
示例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 );
}
开发者ID:fangzhuang2004,项目名称:OpenPilot,代码行数:80,代码来源:qwt_plot.cpp
示例16: spacing
void MosaicLayout::refreshLayout(const QRect& rect)
{
//item size
int itemHSize, itemVSize;
int totalSpacing = spacing() * itemsList.count();
// horizontal max number of items
int HMaxItems = contentsRect().width() / (minItemHSize + totalSpacing);
bool oneRow = false;
if (HMaxItems >= itemsList.count())
{
HMaxItems = itemsList.count();
if (HMaxItems == 0)
HMaxItems += 1; // one avoid division by 0
oneRow = true;
}
// horizontal dimension that could be added to each item
// since there is room
int HPlusSize = ( contentsRect().width() -
(minItemHSize * HMaxItems) ) / HMaxItems;
//TODO: check this, too many operations
if (oneRow)
{
if (minItemHSize + HPlusSize > maxItemHSize)
itemHSize = maxItemHSize;
else
itemHSize = minItemHSize + HPlusSize;
}
else {
if (HPlusSize + minItemHSize > maxItemHSize)
itemHSize = minItemHSize;
else
itemHSize = minItemHSize + HPlusSize;
}
//repeat same story for vertical size
int VMaxItems = contentsRect().height() / (minItemVSize + totalSpacing);
int VPlusSize = ( contentsRect().height() %
(minItemVSize * VMaxItems) ) / VMaxItems;
if (VPlusSize + minItemVSize > maxItemVSize)
itemVSize = minItemVSize;
else
itemVSize = minItemVSize + VPlusSize;
//next lines add widgets to layout
// absolute position to set
int x = 0;
int y = 0;
// count of horizontal added items,
// increment it for each added item and
// when it reachs HMaxItems set it and
// x to zero
int HCountItem = 0;
QLayoutItem *item;
foreach (item, itemsList) {
item->setGeometry(QRect(QPoint(x,y),QPoint(itemHSize+x,itemVSize+y)));
HCountItem++;
if (HCountItem >= HMaxItems) {
HCountItem = x = 0;
y += itemVSize + spacing();
}
else
x += itemHSize + spacing();
}
开发者ID:clynamen,项目名称:QtClasses,代码行数:63,代码来源:MosaicLayout.cpp
示例17: contentsRect
void
QvisAbstractOpacityBar::drawFilledCurveWithSelection(float *curve, bool *mask, int nc,
const QColor &curveOn, float curveOnOpacity,
const QColor &curveOff, float curveOffOpacity,
const QColor &binLines, bool drawBinLines,
float range[2], float minval, float maxval)
{
int w = contentsRect().width();
int h = contentsRect().height();
QRgb BL = binLines.rgb();
for (int x = 0; x < w; x++)
{
float tx = float(x) / float(w-1);
int cx = qMin((nc-1), int(tx * nc));
float yval = curve[cx];
//qDebug("tx=%g, cx=%d, yval=%g", tx, cx, yval);
// Determine whether we will need to draw the column
bool drawColumn = true;
if(mask != NULL)
drawColumn = mask[cx];
else
{
// Restrict the columns we draw to a range.
float xval = (1.f-tx)*range[0] + tx*range[1];
if(xval < minval || xval > maxval)
drawColumn = false;
}
// Determine the proper color and opacity to use for the column
// based on whether we're drawing it.
QRgb color;
float opacity;
if(drawColumn)
{
color = curveOn.rgb();
opacity = curveOnOpacity;
}
else
{
color = curveOff.rgb();
opacity = curveOffOpacity;
}
// Draw the column
if(opacity == 1.f)
{
// Draw full opacity.
for (int y = 0; y < h; y++)
{
float yval2 = 1 - float(y)/float(h-1);
if (yval2 <= yval)
image->setPixel(x, y, color);
}
}
else if(opacity > 0.f)
{
// Blend the column with the background.
for (int y = 0; y < h; y++)
{
float yval2 = 1 - float(y)/float(h-1);
if (yval2 <= yval)
{
QRgb p = image->pixel(x, y);
int r = int((1.f - opacity)*float(qRed(p)) + opacity*float(qRed(color)));
int g = int((1.f - opacity)*float(qGreen(p)) + opacity*float(qGreen(color)));
int b = int((1.f - opacity)*float(qBlue(p)) + opacity*float(qBlue(color)));
image->setPixel(x,y, qRgb(r,g,b));
}
}
}
if(drawBinLines)
{
int yv = int((1.-yval) * (h-1));
yv = qMin(yv, h-1);
image->setPixel(x, yv, BL);
}
}
// Draw the bin dividers
if(drawBinLines)
{
for(int i = 1; i < histTextureSize+1; ++i)
{
float t = float(i) / float(histTextureSize);
int x = int(t * w);
if(x < w)
{
for (int y = 0; y < h; y++)
image->setPixel(x,y, BL);
}
}
}
}
开发者ID:burlen,项目名称:visit_vtk_7_src,代码行数:96,代码来源:QvisAbstractOpacityBar.C
示例18: drawContents
void QIStateStatusBarIndicator::drawContents(QPainter *pPainter)
{
if (m_icons.contains(m_iState))
pPainter->drawPixmap(contentsRect().topLeft(), m_icons.value(m_iState).pixmap(m_size));
}
开发者ID:mcenirm,项目名称:vbox,代码行数:5,代码来源:QIStatusBarIndicator.cpp
示例19: p
void ItemButton::paintEvent(QPaintEvent *event) {
QStylePainter p(this);
QStyleOptionButton option;
QRect margins = contentsRect();
QFontMetrics fontMetrics(p.font());
int textHeight = 0;
int textWidth = 0;
int priceWidth = fontMetrics.boundingRect(price).width();
option.initFrom(this);
if (isDown())
option.state |= QStyle::State_Sunken;
else
option.state |= QStyle::State_Raised;
if (isChecked())
option.state |= QStyle::State_On;
//Draw button
p.drawControl(QStyle::CE_PushButtonBevel, option);
//int iconWidth = iconSize().height() > iconSize().width() ? iconSize().height() : iconSize().width();
int iconWidth = margins.right();
textWidth = fontMetrics.boundingRect(description).width();
if (margins.right() - iconWidth < textWidth) {
qDebug() << "Resizing";
iconWidth = margins.right() - textWidth;
}
int iconHeight = margins.bottom();
QSize size = icon().availableSizes().first();
if (iconWidth > iconHeight) {
iconWidth = iconHeight;
}
size.scale(iconWidth, iconHeight, Qt::KeepAspectRatio);
setIconSize(size);
qDebug() << size;
//Draw icon
if(isEnabled())
p.drawPixmap(margins.left() + (iconWidth - iconSize().width())/2, (margins.height() - iconSize().height())/2 + margins.top(), icon().pixmap(iconSize(), QIcon::Normal));
else
p.drawPixmap(margins.left() + (iconWidth - iconSize().width())/2, (margins.height() - iconSize().height())/2 + margins.top(), icon().pixmap(iconSize(), QIcon::Disabled));
//Draw title text
textHeight = fontMetrics.boundingRect(text()).height();
textWidth = fontMetrics.boundingRect(text()).width();
if (textWidth > margins.width() - iconWidth - margins.left()) {
QFont font = p.font();
font.setPixelSize((double)font.pixelSize() * (margins.width() - iconWidth - margins.left()) / textWidth);
p.setFont(font);
}
p.drawText(QRect(margins.left()*2 + iconWidth, margins.top(), margins.width() - iconWidth, textHeight), Qt::AlignLeft|Qt::TextSingleLine, text());
p.setFont(this->font());
//Draw price text
p.drawText(QRect(margins.right() - priceWidth, margins.top(), priceWidth, margins.height()), Qt::AlignRight|Qt::TextSingleLine|Qt::AlignVCenter, price);
//Resize font
QFont font = p.font();
font.setPixelSize((int)(font.pixelSize() * 0.75));
//font.setPointSizeF((font.pointSizeF() * 0.75));
p.setFont(font);
//Draw description text
fontMetrics = QFontMetrics(p.font());
textHeight = fontMetrics.boundingRect(description).height();
textWidth = fontMetrics.boundingRect(description).width();
p.drawText(QRect(margins.left()*2 + iconWidth, margins.bottom() - textHeight, margins.width() - iconWidth, textHeight), Qt::AlignLeft|Qt::TextSingleLine, description);
}
开发者ID:crawford,项目名称:DrinkTouchClient,代码行数:75,代码来源:itembutton.cpp
示例20: contentsRect
void CodeEditor::resizeEvent(QResizeEvent *e)
{
QPlainTextEdit::resizeEvent(e);
QRect cr = contentsRect();
lineNumberArea->setGeometry(QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height()));
}
开发者ID:mukolatte,项目名称:CSE20212-FinalProj-QT,代码行数:6,代码来源:codeeditor.cpp
注:本文中的contentsRect函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论