本文整理汇总了C++中QColorGroup::brush方法的典型用法代码示例。如果您正苦于以下问题:C++ QColorGroup::brush方法的具体用法?C++ QColorGroup::brush怎么用?C++ QColorGroup::brush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QColorGroup
的用法示例。
在下文中一共展示了QColorGroup::brush方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawExclusiveIndicator
/*!\reimp
*/
void QCDEStyle::drawExclusiveIndicator( QPainter* p,
int x, int y, int w, int h, const QColorGroup &g,
bool on, bool down, bool /* enabled */ )
{
static const QCOORD pts1[] = { // up left lines
1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 };
static const QCOORD pts4[] = { // bottom right lines
2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7,
11,4, 10,3, 10,2 };
static const QCOORD pts5[] = { // inner fill
4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 };
p->eraseRect( x, y, w, h );
QPointArray a( QCOORDARRLEN(pts1), pts1 );
a.translate( x, y );
p->setPen( (down||on) ? g.dark() : g.light() );
p->drawPolyline( a );
a.setPoints( QCOORDARRLEN(pts4), pts4 );
a.translate( x, y );
p->setPen( (down||on) ? g.light() : g.dark() );
p->drawPolyline( a );
a.setPoints( QCOORDARRLEN(pts5), pts5 );
a.translate( x, y );
QColor fillColor = on ? g.dark() : g.background();
p->setPen( fillColor );
p->setBrush( on ? g.brush( QColorGroup::Dark ) :
g.brush( QColorGroup::Background ) );
p->drawPolygon( a );
}
示例2: drawComboButton
/*!\reimp
*/
void QWindowsStyle::drawComboButton( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken ,
bool /* editable */,
bool enabled,
const QBrush *fill )
{
qDrawWinPanel(p, x, y, w, h, g, TRUE,
fill?fill:(enabled?&g.brush( QColorGroup::Base ):
&g.brush( QColorGroup::Background )));
// the special reversed left shadow panel ( slightly different from drawPanel() )
//qDrawWinPanel(p, w-2-16,2,16,h-4, g, sunken);
// #### DO SUNKEN!
if ( sunken )
drawWinShades( p, x+w-2-16, y+2, 16, h-4,
g.dark(), g.dark(), g.button(), g.button(),
fill ? fill : &g.brush( QColorGroup::Button ) );
else
drawWinShades( p, x+w-2-16, y+2, 16, h-4,
g.midlight(), g.shadow(), g.light(), g.dark(),
fill ? fill : &g.brush( QColorGroup::Button ) );
drawArrow( p, QStyle::DownArrow, sunken,
x+w-2-16+ 2, y+2+ 2, 16- 4, h-4- 4, g, enabled,
fill ? fill : &g.brush( QColorGroup::Button ) );
}
示例3: drawIndicator
/*!\reimp
*/
void QCDEStyle::drawIndicator( QPainter* p,
int x, int y, int w, int h, const QColorGroup &g,
int s, bool down, bool /* enabled */ )
{
bool showUp = !down && s == QButton::Off;
QBrush fill = down ? g.brush( QColorGroup::Mid ) :
g.brush( QColorGroup::Button );
qDrawShadePanel( p, x, y, w, h, g, !showUp, defaultFrameWidth(), &fill );
if (s != QButton::Off) {
QPointArray a( 7*2 );
int i, xx, yy;
xx = x+3;
yy = y+5;
for ( i=0; i<3; i++ ) {
a.setPoint( 2*i, xx, yy );
a.setPoint( 2*i+1, xx, yy+2 );
xx++; yy++;
}
yy -= 2;
for ( i=3; i<7; i++ ) {
a.setPoint( 2*i, xx, yy );
a.setPoint( 2*i+1, xx, yy+2 );
xx++; yy--;
}
if ( s == QButton::NoChange )
p->setPen( g.dark() );
else
p->setPen( g.foreground() );
p->drawLineSegments( a );
}
}
示例4: arrowCenter
/*!
Draw a compass needle
*/
void QwtCompassWindArrow::drawStyle2Needle(
QPainter *painter, const QColorGroup &cg,
const QPoint ¢er, int length, double direction)
{
painter->save();
painter->setPen(Qt::NoPen);
const double angle = 12.0;
const double ratio = 0.7;
const QPoint arrowCenter(center.x() + 1, center.y() + 1);
QPointArray pa(3);
pa.setPoint(0, center);
pa.setPoint(2, qwtDegree2Pos(arrowCenter, ratio * length, direction));
pa.setPoint(1, qwtDegree2Pos(arrowCenter, length, direction + angle));
painter->setBrush(cg.brush(QColorGroup::Dark));
painter->drawPolygon(pa);
pa.setPoint(1, qwtDegree2Pos(arrowCenter, length, direction - angle));
painter->setBrush(cg.brush(QColorGroup::Light));
painter->drawPolygon(pa);
painter->restore();
}
示例5: fill
/*!\reimp
*/
void
QWindowsStyle::drawPushButton( QPushButton* btn, QPainter *p)
{
#ifndef QT_NO_PUSHBUTTON
QColorGroup g = btn->colorGroup();
int x1, y1, x2, y2;
btn->rect().coords( &x1, &y1, &x2, &y2 ); // get coordinates
p->setPen( g.foreground() );
p->setBrush( QBrush(g.button(),NoBrush) );
int diw = buttonDefaultIndicatorWidth();
if ( btn->isDefault() || btn->autoDefault() ) {
if ( btn->isDefault() ) {
p->setPen( g.shadow() );
p->drawRect( x1, y1, x2-x1+1, y2-y1+1 );
}
x1 += diw;
y1 += diw;
x2 -= diw;
y2 -= diw;
}
bool clearButton = TRUE;
if ( btn->isDown() ) {
if ( btn->isDefault() ) {
p->setPen( g.dark() );
p->drawRect( x1, y1, x2-x1+1, y2-y1+1 );
} else {
drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, TRUE,
&g.brush( QColorGroup::Button ) );
}
} else {
if ( btn->isToggleButton() && btn->isOn() && btn->isEnabled() ) {
QBrush fill(g.light(), Dense4Pattern );
drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, TRUE, &fill );
clearButton = FALSE;
} else {
if ( !btn->isFlat() )
drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, btn->isOn(),
&g.brush( QColorGroup::Button ) );
}
}
if ( clearButton ) {
if (btn->isDown())
p->setBrushOrigin(p->brushOrigin() + QPoint(1,1));
p->fillRect( x1+2, y1+2, x2-x1-3, y2-y1-3,
g.brush( QColorGroup::Button ) );
if (btn->isDown())
p->setBrushOrigin(p->brushOrigin() - QPoint(1,1));
}
if ( p->brush().style() != NoBrush )
p->setBrush( NoBrush );
#endif
}
示例6: drawArrowNeedle
/*!
Draw a needle looking like an arrow
*/
void QwtDialSimpleNeedle::drawArrowNeedle(
QPainter *painter, const QColorGroup &cg,
const QPoint ¢er, int length, int width,
double direction, bool hasKnob)
{
direction *= M_PI / 180.0;
painter->save();
if ( width <= 0 )
{
width = (int)QMAX(length * 0.06, 9);
if ( width % 2 == 0 )
width++;
}
const int peak = 3;
const QPoint p1(center.x() + 1, center.y() + 1);
const QPoint p2 = qwtPolar2Pos(p1, length - peak, direction);
const QPoint p3 = qwtPolar2Pos(p1, length, direction);
QPointArray pa(5);
pa.setPoint(0, qwtPolar2Pos(p1, width / 2, direction - M_PI_2));
pa.setPoint(1, qwtPolar2Pos(p2, 1, direction - M_PI_2));
pa.setPoint(2, p3);
pa.setPoint(3, qwtPolar2Pos(p2, 1, direction + M_PI_2));
pa.setPoint(4, qwtPolar2Pos(p1, width / 2, direction + M_PI_2));
painter->setPen(Qt::NoPen);
painter->setBrush(cg.brush(QColorGroup::Mid));
painter->drawPolygon(pa);
QPointArray shadowPa(3);
const int colorOffset = 10;
int i;
for ( i = 0; i < 3; i++ )
shadowPa.setPoint(i, pa[i]);
painter->setPen(cg.mid().dark(100 + colorOffset));
painter->drawPolyline(shadowPa);
for ( i = 0; i < 3; i++ )
shadowPa.setPoint(i, pa[i + 2]);
painter->setPen(cg.mid().dark(100 - colorOffset));
painter->drawPolyline(shadowPa);
if ( hasKnob )
{
drawKnob(painter, center, qRound(width * 1.3),
cg.brush(QColorGroup::Base), FALSE);
}
painter->restore();
}
示例7: paintCell
void RosterBoxItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int align)
{
if(!v_rt){
QListViewItem::paintCell(p, cg, column, width, align);
return;
}
p->save();
QListView* lv = listView();
if ( isSelected() != v_selected || lv->isActiveWindow() != v_active)
setup();
int r = lv->itemMargin();
const QBrush *paper;
// setup (colors, sizes, ...)
if ( isSelected() ) {
paper = &cg.brush( QColorGroup::Highlight );
}
else{
const QColorGroup::ColorRole crole = QPalette::backgroundRoleFromMode( lv->viewport()->backgroundMode() );
paper = &cg.brush( crole );
}
const QPixmap * px = pixmap( column );
QRect pxrect;
int pxw = 0;
int pxh = 0;
if(px) {
pxw = px->width();
pxh = px->height();
pxrect = QRect(r, (height() - pxh)/2, pxw, pxh);
r += pxw + lv->itemMargin();
}
if(px)
pxrect.moveTop( (height() - pxh)/2 );
// start drawing
QRect rtrect(r, (height() - v_rt->height())/2, v_widthUsed, v_rt->height());
v_rt->draw(p, rtrect.left(), rtrect.top(), rtrect, cg, paper);
QRegion clip(0, 0, width, height());
clip -= rtrect;
p->setClipRegion(clip, QPainter::CoordPainter);
p->fillRect( 0, 0, width, height(), *paper );
if(px)
p->drawPixmap(pxrect, *px);
p->restore();
}
示例8: drawTriangleNeedle
/*!
Draw a compass needle
*/
void QwtCompassMagnetNeedle::drawTriangleNeedle(
QPainter *painter, const QColorGroup &cg,
const QPoint ¢er, int length, double direction)
{
QBrush brush;
const int width = qRound(length / 3.0);
const int colorOffset = 10;
painter->save();
painter->setPen(Qt::NoPen);
const QPoint arrowCenter(center.x() + 1, center.y() + 1);
QPointArray pa(3);
pa.setPoint(0, arrowCenter);
pa.setPoint(1, qwtDegree2Pos(arrowCenter, length, direction));
pa.setPoint(2, qwtDegree2Pos(arrowCenter, width / 2, direction + 90.0));
brush = cg.brush(QColorGroup::Dark);
brush.setColor(brush.color().dark(100 + colorOffset));
painter->setBrush(brush);
painter->drawPolygon(pa);
pa.setPoint(2, qwtDegree2Pos(arrowCenter, width / 2, direction - 90.0));
brush = cg.brush(QColorGroup::Dark);
brush.setColor(brush.color().dark(100 - colorOffset));
painter->setBrush(brush);
painter->drawPolygon(pa);
// --
pa.setPoint(1, qwtDegree2Pos(arrowCenter, length, direction + 180.0));
pa.setPoint(2, qwtDegree2Pos(arrowCenter, width / 2, direction + 90.0));
brush = cg.brush(QColorGroup::Light);
brush.setColor(brush.color().dark(100 + colorOffset));
painter->setBrush(brush);
painter->drawPolygon(pa);
pa.setPoint(2, qwtDegree2Pos(arrowCenter, width / 2, direction - 90.0));
brush = cg.brush(QColorGroup::Light);
brush.setColor(brush.color().dark(100 - colorOffset));
painter->setBrush(brush);
painter->drawPolygon(pa);
painter->restore();
}
示例9: drawButton
/*!
Draws a press-sensitive shape.
*/
void QWindowsStyle::drawButton( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken, const QBrush* fill)
{
if (sunken)
drawWinShades( p, x, y, w, h,
g.shadow(), g.light(), g.dark(), g.button(),
fill?fill: &g.brush( QColorGroup::Button ) );
else
drawWinShades( p, x, y, w, h,
g.light(), g.shadow(), g.button(), g.dark(),
fill?fill:&g.brush( QColorGroup::Button ) );
}
示例10: drawComplexControl
void MetalStyle::drawComplexControl( ComplexControl cc,
QPainter *p,
const QWidget *widget,
const QRect &r,
const QColorGroup &cg,
SFlags how,
SCFlags sub,
SCFlags subActive,
const QStyleOption& opt ) const
{
switch ( cc ) {
case CC_Slider:
{
const QSlider *slider = ( const QSlider* ) widget;
QRect handle = querySubControlMetrics( CC_Slider, widget,
SC_SliderHandle, opt);
if ( sub & SC_SliderGroove )
QWindowsStyle::drawComplexControl( cc, p, widget, r, cg, how,
SC_SliderGroove, subActive, opt );
if ( (sub & SC_SliderHandle) && handle.isValid() )
drawMetalButton( p, handle.x(), handle.y(), handle.width(),
handle.height(), FALSE,
slider->orientation() == QSlider::Horizontal);
break;
}
case CC_ComboBox:
{
// not exactly correct...
const QComboBox *cmb = ( const QComboBox* ) widget;
qDrawWinPanel( p, r.x(), r.y(), r.width(), r.height(), cg, TRUE,
cmb->isEnabled() ? &cg.brush( QColorGroup::Base ) :
&cg.brush( QColorGroup::Background ) );
drawMetalButton( p, r.x() + r.width() - 2 - 16, r.y() + 2, 16, r.height() - 4,
how & Style_Sunken, TRUE );
drawPrimitive( PE_ArrowDown, p,
QRect( r.x() + r.width() - 2 - 16 + 2,
r.y() + 2 + 2, 16 - 4, r.height() - 4 -4 ),
cg,
cmb->isEnabled() ? Style_Enabled : Style_Default,
opt );
break;
}
default:
QWindowsStyle::drawComplexControl( cc, p, widget, r, cg, how, sub, subActive,
opt );
break;
}
}
示例11: drawSlider
void FreshStyle::drawSlider( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, Orientation o, bool tickAbove, bool tickBelow )
{
int a = tickAbove ? 3 : 0;
int b = tickBelow ? 3 : 0;
if ( o == Horizontal ) {
drawBevelButton( p, x, y+a, w, h-a-b, g, FALSE, &g.brush( QColorGroup::Button ) );
int xp = x + w/2;
qDrawShadeLine( p, xp, y+a+2, xp, y+h-b-3, g );
} else {
drawBevelButton( p, x+a, y, w-a-b, h, g, FALSE, &g.brush( QColorGroup::Button ) );
int yp = y + h/2;
qDrawShadeLine( p, x+a+2, yp, x+w-b-3, yp, g );
}
}
示例12: paint
/**
* @internal
* This paints the item
*/
void OCheckItem::paint( QPainter *p, const QColorGroup &cg, const QRect &cr,
bool )
{
p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) );
int marg = ( cr.width() - BoxSize ) / 2;
int x = 0;
int y = ( cr.height() - BoxSize ) / 2;
p->setPen( QPen( cg.text() ) );
p->drawRect( x + marg, y, BoxSize, BoxSize );
p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 );
p->setPen( darkGreen );
x += 1;
y += 1;
if ( m_checked ) {
QPointArray a( 7*2 );
int i, xx, yy;
xx = x+1+marg;
yy = y+2;
for ( i=0; i<3; i++ ) {
a.setPoint( 2*i, xx, yy );
a.setPoint( 2*i+1, xx, yy+2 );
xx++; yy++;
}
yy -= 2;
for ( i=3; i<7; i++ ) {
a.setPoint( 2*i, xx, yy );
a.setPoint( 2*i+1, xx, yy+2 );
xx++; yy--;
}
p->drawLineSegments( a );
}
}
示例13: drawRayNeedle
/*!
Draw a needle looking like a ray
*/
void QwtDialSimpleNeedle::drawRayNeedle(
QPainter *painter, const QColorGroup &cg,
const QPoint ¢er, int length, int width, double direction,
bool hasKnob)
{
if ( width <= 0 )
width = 5;
direction *= M_PI / 180.0;
painter->save();
const QPoint p1(center.x() + 1, center.y() + 2);
const QPoint p2 = qwtPolar2Pos(p1, length, direction);
if ( width == 1 )
{
painter->setPen(QPen(cg.mid(), 1));
painter->drawLine(p1, p2);
}
else
{
QPointArray pa(4);
pa.setPoint(0, qwtPolar2Pos(p1, width / 2, direction + M_PI_2));
pa.setPoint(1, qwtPolar2Pos(p2, width / 2, direction + M_PI_2));
pa.setPoint(2, qwtPolar2Pos(p2, width / 2, direction - M_PI_2));
pa.setPoint(3, qwtPolar2Pos(p1, width / 2, direction - M_PI_2));
painter->setPen(Qt::NoPen);
painter->setBrush(cg.brush(QColorGroup::Mid));
painter->drawPolygon(pa);
}
if ( hasKnob )
{
int knobWidth = QMAX(qRound(width * 0.7), 5);
if ( knobWidth % 2 == 0 )
knobWidth++;
drawKnob(painter, center, knobWidth,
cg.brush(QColorGroup::Base), FALSE);
}
painter->restore();
}
示例14: drawIndicator
void QWindowsStyle::drawIndicator( QPainter* p,
int x, int y, int w, int h, const QColorGroup &g,
int s, bool down, bool enabled )
{
#ifndef QT_NO_BUTTON
QBrush fill;
if ( s == QButton::NoChange ) {
QBrush b = p->brush();
QColor c = p->backgroundColor();
p->setBackgroundMode( TransparentMode );
p->setBackgroundColor( green );
fill = QBrush(g.base(), Dense4Pattern);
p->setBackgroundColor( c );
p->setBrush( b );
} else if ( down )
fill = g.brush( QColorGroup::Button );
else
fill = g.brush( enabled ? QColorGroup::Base : QColorGroup::Background );
qDrawWinPanel( p, x, y, w, h, g, TRUE, &fill );
if ( s != QButton::Off ) {
QPointArray a( 7*2 );
int i, xx, yy;
xx = x+3;
yy = y+5;
for ( i=0; i<3; i++ ) {
a.setPoint( 2*i, xx, yy );
a.setPoint( 2*i+1, xx, yy+2 );
xx++; yy++;
}
yy -= 2;
for ( i=3; i<7; i++ ) {
a.setPoint( 2*i, xx, yy );
a.setPoint( 2*i+1, xx, yy+2 );
xx++; yy--;
}
if ( s == QButton::NoChange ) {
p->setPen( g.dark() );
} else {
p->setPen( g.text() );
}
p->drawLineSegments( a );
}
#endif
}
示例15: drawThinNeedle
/*!
Draw a compass needle
*/
void QwtCompassMagnetNeedle::drawThinNeedle(
QPainter *painter, const QColorGroup &cg,
const QPoint ¢er, int length, double direction)
{
const int colorOffset = 10;
const int width = QMAX(qRound(length / 6.0), 3);
painter->save();
const QPoint arrowCenter(center.x() + 1, center.y() + 1);
drawPointer(painter, cg.brush(QColorGroup::Dark), colorOffset,
arrowCenter, length, width, direction);
drawPointer(painter, cg.brush(QColorGroup::Light), -colorOffset,
arrowCenter, length, width, direction + 180.0);
drawKnob(painter, arrowCenter, width,
cg.brush(QColorGroup::Base), TRUE);
painter->restore();
}