本文整理汇总了C++中QPointArray::translate方法的典型用法代码示例。如果您正苦于以下问题:C++ QPointArray::translate方法的具体用法?C++ QPointArray::translate怎么用?C++ QPointArray::translate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPointArray
的用法示例。
在下文中一共展示了QPointArray::translate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void
QWindowsStyle::drawArrow( QPainter *p, ArrowType type, bool down,
int x, int y, int w, int h,
const QColorGroup &g, bool enabled, const QBrush *fill )
{
QPointArray a; // arrow polygon
switch ( type ) {
case UpArrow:
a.setPoints( 7, -4,1, 2,1, -3,0, 1,0, -2,-1, 0,-1, -1,-2 );
break;
case DownArrow:
a.setPoints( 7, -4,-2, 2,-2, -3,-1, 1,-1, -2,0, 0,0, -1,1 );
break;
case LeftArrow:
a.setPoints( 7, 1,-3, 1,3, 0,-2, 0,2, -1,-1, -1,1, -2,0 );
break;
case RightArrow:
a.setPoints( 7, -1,-3, -1,3, 0,-2, 0,2, 1,-1, 1,1, 2,0 );
break;
}
if ( a.isNull() )
return;
if ( down ) {
x++;
y++;
}
QPen savePen = p->pen(); // save current pen
if (down)
p->setBrushOrigin(p->brushOrigin() + QPoint(1,1));
if ( fill )
p->fillRect( x, y, w, h, *fill );
if (down)
p->setBrushOrigin(p->brushOrigin() - QPoint(1,1));
if ( enabled ) {
a.translate( x+w/2, y+h/2 );
p->setPen( g.buttonText() );
p->drawLineSegments( a, 0, 3 ); // draw arrow
p->drawPoint( a[6] );
} else {
a.translate( x+w/2+1, y+h/2+1 );
p->setPen( g.light() );
p->drawLineSegments( a, 0, 3 ); // draw arrow
p->drawPoint( a[6] );
a.translate( -1, -1 );
p->setPen( g.mid() );
p->drawLineSegments( a, 0, 3 ); // draw arrow
p->drawPoint( a[6] );
}
p->setPen( savePen ); // restore pen
}
示例2: qDrawWinArrow
static void qDrawWinArrow( QPainter *p, Qt::ArrowType type, bool down,
int x, int y, int w, int h,
const QColorGroup &g, bool enabled )
{
QPointArray a; // arrow polygon
switch ( type ) {
case Qt::UpArrow:
a.setPoints( 7, -3,1, 3,1, -2,0, 2,0, -1,-1, 1,-1, 0,-2 );
break;
case Qt::DownArrow:
a.setPoints( 7, -3,-1, 3,-1, -2,0, 2,0, -1,1, 1,1, 0,2 );
break;
case Qt::LeftArrow:
a.setPoints( 7, 1,-3, 1,3, 0,-2, 0,2, -1,-1, -1,1, -2,0 );
break;
case Qt::RightArrow:
a.setPoints( 7, -1,-3, -1,3, 0,-2, 0,2, 1,-1, 1,1, 2,0 );
break;
}
if ( a.isNull() )
return;
if ( down ) {
x++;
y++;
}
QPen savePen = p->pen(); // save current pen
if (down)
p->setBrushOrigin(p->brushOrigin() + QPoint(1,1));
p->fillRect( x, y, w, h, g.brush( QColorGroup::Button ) );
if (down)
p->setBrushOrigin(p->brushOrigin() - QPoint(1,1));
if ( enabled ) {
a.translate( x+w/2, y+h/2 );
p->setPen( g.foreground() );
p->drawLineSegments( a, 0, 3 ); // draw arrow
p->drawPoint( a[6] );
} else {
a.translate( x+w/2+1, y+h/2+1 );
p->setPen( g.light() );
p->drawLineSegments( a, 0, 3 ); // draw arrow
p->drawPoint( a[6] );
a.translate( -1, -1 );
p->setPen( g.mid() );
p->drawLineSegments( a, 0, 3 ); // draw arrow
p->drawPoint( a[6] );
}
p->setPen( savePen ); // restore pen
}
示例3: drawShape
void OutputFlowNode::drawShape ( QPainter &p )
{
const int _x = ( int ) x();
const int _y = ( int ) y();
if ( m_dir == 0 ) p.drawLine ( _x, _y, _x-8, _y );
else if ( m_dir == 90 ) p.drawLine ( _x, _y, _x, _y-8 );
else if ( m_dir == 180 ) p.drawLine ( _x, _y, _x+8, _y );
else if ( m_dir == 270 ) p.drawLine ( _x, _y, _x, _y+8 );
QPointArray pa ( 3 );
switch ( m_dir )
{
case 0: // right
pa = arrowPoints ( 0 );
break;
case 180: // left
pa = arrowPoints ( 180 );
break;
case 90: // down
pa = arrowPoints ( 90 );
break;
case 270: // up
pa = arrowPoints ( 270 );
break;
default:
kdError() << k_funcinfo << "BUG: m_dir = " << m_dir << endl;
}
// Note: I have not tested the positioning of the arrows for all combinations.
// In fact, most almost definitely do not work. So feel free to change the code
// as you see fit if necessary.
if ( m_dir == 0 ) pa.translate ( -5, 0 );
else if ( m_dir == 90 ) pa.translate ( 0, -5 );
else if ( m_dir == 180 ) pa.translate ( 5, 0 );
else if ( m_dir == 270 ) pa.translate ( 0, 5 );
pa.translate ( _x, _y );
p.drawPolygon ( pa );
}
示例4: drawComplexControl
//.........这里部分代码省略.........
p->drawLine( xx+ww-3, yy+3, xx+ww-3, yy+hh-3 );
p->setPen( cg.dark() );
p->drawLine( xx+2, yy+hh-2 ,xx+ww-2, yy+hh-2 );
p->drawLine( xx+ww-2, yy+2, xx+ww-2, yy+hh-2 );
p->setPen( cg.shadow() );
p->drawLine( xx+1, yy+hh-1,xx+ww-1, yy+hh-1 );
p->drawLine( xx+ww-1, yy, xx+ww-1, yy+hh-1 );
// top right corner:
p->setPen( cg.background() );
p->drawPoint( xx + ww - 1, yy );
p->drawPoint( xx + ww - 2, yy );
p->drawPoint( xx + ww - 1, yy + 1 );
p->setPen( cg.shadow() );
p->drawPoint( xx + ww - 2, yy + 1 );
// bottom right corner:
p->setPen( cg.background() );
p->drawPoint( xx + ww - 1, yy + hh - 1 );
p->drawPoint( xx + ww - 2, yy + hh - 1 );
p->drawPoint( xx + ww - 1, yy + hh - 2 );
p->setPen( cg.shadow() );
p->drawPoint( xx + ww - 2, yy + hh - 2 );
p->setPen( cg.dark() );
p->drawPoint( xx + ww - 3, yy + hh - 3 );
p->setPen( cg.mid() );
p->drawPoint( xx + ww - 4, yy + hh - 4 );
// and the arrows
p->setPen( cg.foreground() );
QPointArray a ;
a.setPoints( 7, -3,1, 3,1, -2,0, 2,0, -1,-1, 1,-1, 0,-2 );
a.translate( xx + ww / 2, yy + hh / 2 - 3 );
p->drawLineSegments( a, 0, 3 ); // draw arrow
p->drawPoint( a[6] );
a.setPoints( 7, -3,-1, 3,-1, -2,0, 2,0, -1,1, 1,1, 0,2 );
a.translate( xx + ww / 2, yy + hh / 2 + 2 );
p->drawLineSegments( a, 0, 3 ); // draw arrow
p->drawPoint( a[6] );
}
#ifndef QT_NO_COMBOBOX
if ( sub & SC_ComboBoxEditField ) {
const QComboBox *cmb;
cmb = (const QComboBox*)widget;
// sadly this is pretty much the windows code, except
// for the first fillRect call...
QRect re =
QStyle::visualRect( querySubControlMetrics( CC_ComboBox,
widget,
SC_ComboBoxEditField ),
widget );
if ( cmb->hasFocus() && !cmb->editable() )
p->fillRect( re.x() + 1, re.y() + 1,
re.width() - 2, re.height() - 2,
cg.brush( QColorGroup::Highlight ) );
if ( cmb->hasFocus() ) {
p->setPen( cg.highlightedText() );
p->setBackgroundColor( cg.highlight() );
} else {
p->setPen( cg.text() );
p->setBackgroundColor( cg.background() );
}
示例5: drawPrimitive
//.........这里部分代码省略.........
cg, flags );
p->fillRect( r.x() + r.width() - 2, r.y(), 2, r.height(),
cg.brush( QColorGroup::Background ) );
p->setPen( cg.shadow() );
p->drawRect( r.x(), r.y(), r.width() - 2, r.height() );
static const QCOORD nochange_mark[] = { 3,5, 9,5, 3,6, 9,6 };
static const QCOORD check_mark[] = {
3,5, 5,5, 4,6, 5,6, 5,7, 6,7, 5,8, 6,8, 6,9, 9,9,
6,10, 8,10, 7,11, 8,11, 7,12, 7,12, 8,8, 9,8, 8,7, 10,7,
9,6, 10,6, 9,5, 11,5, 10,4, 11,4, 10,3, 12,3,
11,2, 12,2, 11,1, 13,1, 12,0, 13,0 };
if ( !(flags & Style_Off) ) {
QPen oldPen = p->pen();
int x1 = r.x();
int y1 = r.y();
if ( flags & Style_Down ) {
x1++;
y1++;
}
QPointArray amark;
if ( flags & Style_On ) {
amark = QPointArray( sizeof(check_mark)/(sizeof(QCOORD)*2),
check_mark );
// ### KLUDGE!!
flags ^= Style_On;
flags ^= Style_Down;
} else if ( flags & Style_NoChange ) {
amark = QPointArray( sizeof(nochange_mark)
/ (sizeof(QCOORD) * 2),
nochange_mark );
}
amark.translate( x1 + 1, y1 + 1 );
p->setPen( cg.dark() );
p->drawLineSegments( amark );
amark.translate( -1, -1 );
p->setPen( cg.foreground() );
p->drawLineSegments( amark );
p->setPen( oldPen );
}
break;
}
case PE_IndicatorMask:
{
int x,
y,
w,
h;
r.rect( &x, &y, &w, &h );
p->fillRect( x, y, w - 2, h, color1);
if ( flags & Style_Off ) {
QPen oldPen = p->pen();
p->setPen ( QPen(color1, 2));
p->drawLine( x + 2, y + h / 2 - 1,
x + w / 2 - 1, y + h - 4 );
p->drawLine( x + w / 2 - 1, y + h - 4,
x + w, 0);
p->setPen( oldPen );
}
break;
}
case PE_ExclusiveIndicator:
{
#define QCOORDARRLEN(x) sizeof(x) / (sizeof(QCOORD) * 2 )
bool down = flags & Style_Down;