本文整理汇总了C++中QColorGroup::light方法的典型用法代码示例。如果您正苦于以下问题:C++ QColorGroup::light方法的具体用法?C++ QColorGroup::light怎么用?C++ QColorGroup::light使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QColorGroup
的用法示例。
在下文中一共展示了QColorGroup::light方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawScrollBarControls
/*!\reimp
*/
void QWindowsStyle::drawScrollBarControls( QPainter* p, const QScrollBar* sb, int sliderStart, uint controls, uint activeControl )
{
#ifndef QT_NO_SCROLLBAR
#define ADD_LINE_ACTIVE ( activeControl == AddLine )
#define SUB_LINE_ACTIVE ( activeControl == SubLine )
QColorGroup g = sb->colorGroup();
int sliderMin, sliderMax, sliderLength, buttonDim;
scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
if (sliderStart > sliderMax) { // sanity check
sliderStart = sliderMax;
}
int b = 0;
int dimB = buttonDim;
QRect addB;
QRect subB;
QRect addPageR;
QRect subPageR;
QRect sliderR;
int addX, addY, subX, subY;
int length = HORIZONTAL ? sb->width() : sb->height();
int extent = HORIZONTAL ? sb->height() : sb->width();
if ( HORIZONTAL ) {
subY = addY = ( extent - dimB ) / 2;
subX = b;
addX = length - dimB - b;
} else {
subX = addX = ( extent - dimB ) / 2;
subY = b;
addY = length - dimB - b;
}
subB.setRect( subX,subY,dimB,dimB );
addB.setRect( addX,addY,dimB,dimB );
int sliderEnd = sliderStart + sliderLength;
int sliderW = extent - b*2;
if ( HORIZONTAL ) {
subPageR.setRect( subB.right() + 1, b,
sliderStart - subB.right() - 1 , sliderW );
addPageR.setRect( sliderEnd, b, addX - sliderEnd, sliderW );
sliderR .setRect( sliderStart, b, sliderLength, sliderW );
} else {
subPageR.setRect( b, subB.bottom() + 1, sliderW,
sliderStart - subB.bottom() - 1 );
addPageR.setRect( b, sliderEnd, sliderW, addY - sliderEnd );
sliderR .setRect( b, sliderStart, sliderW, sliderLength );
}
bool maxedOut = (sb->maxValue() == sb->minValue());
if ( controls & AddLine ) {
qDrawWinPanel( p, addB.x(), addB.y(),
addB.width(), addB.height(), g,
ADD_LINE_ACTIVE, &g.brush( QColorGroup::Button ) );
drawArrow( p, VERTICAL ? DownArrow : RightArrow,
ADD_LINE_ACTIVE, addB.x()+2, addB.y()+2,
addB.width()-4, addB.height()-4, g, !maxedOut );
}
if ( controls & SubLine ) {
qDrawWinPanel( p, subB.x(), subB.y(),
subB.width(), subB.height(), g,
SUB_LINE_ACTIVE, &g.brush( QColorGroup::Button ) );
drawArrow( p, VERTICAL ? UpArrow : LeftArrow,
SUB_LINE_ACTIVE, subB.x()+2, subB.y()+2,
subB.width()-4, subB.height()-4, g, !maxedOut );
}
QBrush br =
g.brush( QColorGroup::Light ).pixmap() ?
g.brush( QColorGroup::Light ) :
QBrush(g.light(), Dense4Pattern);
p->setBrush( br );
p->setPen( NoPen );
p->setBackgroundMode( OpaqueMode );
if ( maxedOut ) {
p->drawRect( sliderR );
} else {
if ( (controls & SubPage && SubPage == activeControl) ||
(controls & AddPage && AddPage == activeControl) ) {
QBrush b = p->brush();
QColor c = p->backgroundColor();
// p->fillRect( AddPage == activeControl? addPageR : subPageR, g.fillDark() );
p->setBackgroundColor( g.dark() );
p->setBrush( QBrush(g.shadow(), Dense4Pattern) );
p->drawRect( AddPage == activeControl? addPageR : subPageR );
p->setBackgroundColor( c );
p->setBrush( b );
}
if ( controls & SubPage && SubPage != activeControl)
p->drawRect( subPageR );
if ( controls & AddPage && AddPage != activeControl)
p->drawRect( addPageR );
if ( controls & Slider ) {
if ( !maxedOut ) {
QPoint bo = p->brushOrigin();
if ( !sb->testWState(WState_GlobalBrushOrigin) )
//.........这里部分代码省略.........
示例2: drawComplexControl
/*!\reimp
*/
void QPlatinumStyle::drawComplexControl( ComplexControl control,
QPainter *p,
const QWidget *widget,
const QRect &r,
const QColorGroup &cg,
SFlags how,
SCFlags sub,
SCFlags subActive,
const QStyleOption& opt ) const
{
switch ( control ) {
case CC_ComboBox:
{
int x,
y,
w,
h;
r.rect( &x, &y, &w, &h );
p->fillRect( x + 2, y + 2, w - 4,
h - 4, cg.brush(QColorGroup::Button) );
// the bright side
p->setPen(cg.shadow());
p->drawLine( x, y, x + w - 1, y );
p->drawLine( x, y, x, y + h - 1 );
p->setPen( cg.light() );
p->drawLine( x + 1, y + 1,
x + w - 2, y + 1 );
p->drawLine( x + 1, y + 1,
x + 1, y + h - 2 );
// the dark side!
p->setPen( cg.mid() );
p->drawLine( x + 2, y + h - 2,
x + w - 2, y + h - 2 );
p->drawLine( x + w - 2, y + 2,
x + w - 2, y + h - 2 );
p->setPen (cg.shadow() );
p->drawLine( x + 1, y + h - 1,
x + w - 1, y + h - 1 );
p->drawLine( x + w - 1, y,
x + w - 1, y + h - 1 );
// top left corner:
p->setPen( cg.background() );
p->drawPoint( x, y );
p->drawPoint( x + 1, y );
p->drawPoint( x, y + 1 );
p->setPen( cg.shadow() );
p->drawPoint( x + 1, y + 1 );
p->setPen( white );
p->drawPoint( x + 3, y + 3 );
// bottom left corner:
p->setPen( cg.background() );
p->drawPoint( x, y + h - 1 );
p->drawPoint( x + 1, y + h - 1 );
p->drawPoint( x, y + h - 2 );
p->setPen( cg.shadow() );
p->drawPoint( x + 1, y + h - 2 );
// top right corner:
p->setPen( cg.background() );
p->drawPoint( x + w - 1, y );
p->drawPoint( x + w - 2, y );
p->drawPoint( x + w - 1, y + 1 );
p->setPen( cg.shadow() );
p->drawPoint( x + w - 2, y + 1 );
// bottom right corner:
p->setPen( cg.background() );
p->drawPoint( x + w - 1, y + h - 1 );
p->drawPoint( x + w - 2, y + h - 1 );
p->drawPoint( x + w - 1, y + h - 2 );
p->setPen( cg.shadow() );
p->drawPoint( x + w - 2, y + h - 2 );
p->setPen( cg.dark() );
p->drawPoint( x + w - 3, y + h - 3 );
if ( sub & SC_ComboBoxArrow ) {
QRect rTmp = querySubControlMetrics( CC_ComboBox, widget,
SC_ComboBoxArrow, opt );
int xx = rTmp.x(),
yy = rTmp.y(),
ww = rTmp.width(),
hh = rTmp.height();
// the bright side
p->setPen( cg.mid() );
p->drawLine( xx, yy+2, xx, yy+hh-3 );
p->setPen( cg.button() );
p->drawLine( xx+1, yy+1, xx+ww-2, yy+1 );
p->drawLine( xx+1, yy+1, xx+1, yy+hh-2 );
p->setPen( cg.light() );
p->drawLine( xx+2, yy+2, xx+2, yy+hh-2 );
p->drawLine( xx+2, yy+2, xx+ww-2, yy+2 );
//.........这里部分代码省略.........
示例3: drawPrimitive
/*!\reimp
*/
void QPlatinumStyle::drawPrimitive( PrimitiveElement pe,
QPainter *p,
const QRect &r,
const QColorGroup &cg,
SFlags flags,
const QStyleOption& opt ) const
{
switch (pe) {
case PE_HeaderSection:
{
// adjust the sunken flag, otherwise headers are drawn
// sunken...
if ( flags & Style_Sunken )
flags ^= Style_Sunken;
drawPrimitive( PE_ButtonBevel, p, r, cg, flags, opt );
break;
}
case PE_ButtonTool:
{
// tool buttons don't change color when pushed in platinum,
// so we need to make the mid and button color the same
QColorGroup myCG = cg;
QBrush fill;
// quick trick to make sure toolbuttons drawn sunken
// when they are activated...
if ( flags & Style_On )
flags |= Style_Sunken;
fill = myCG.brush( QColorGroup::Button );
myCG.setBrush( QColorGroup::Mid, fill );
drawPrimitive( PE_ButtonBevel, p, r, myCG, flags, opt );
break;
}
case PE_ButtonBevel:
{
int x,
y,
w,
h;
r.rect( &x, &y, &w, &h );
QPen oldPen = p->pen();
if ( w * h < 1600 ||
QABS(w - h) > 10 ) {
// small buttons
if ( !(flags & (Style_Sunken | Style_Down)) ) {
p->fillRect( x + 2, y + 2, w - 4, h - 4,
cg.brush(QColorGroup::Button) );
// the bright side
p->setPen( cg.dark() );
// the bright side
p->setPen( cg.dark() );
p->drawLine( x, y, x + w - 1, y );
p->drawLine( x, y, x, y + h - 1 );
p->setPen( cg.light() );
p->drawLine( x + 1, y + 1, x + w - 2, y + 1 );
p->drawLine( x + 1, y + 1, x + 1, y + h - 2 );
// the dark side
p->setPen( cg.mid() );
p->drawLine( x + 2, y + h - 2, x + w - 2, y + h - 2 );
p->drawLine( x + w - 2, y + 2, x + w - 2, y + h - 3 );
p->setPen( cg.dark().dark() );
p->drawLine( x + 1, y + h - 1, x + w - 1,
y + h - 1 );
p->drawLine( x + w - 1, y + 1,
x + w - 1,
y + h - 2 );
} else {
p->fillRect(x + 2, y + 2,
w - 4, h - 4,
cg.brush( QColorGroup::Mid ));
// the dark side
p->setPen( cg.dark().dark() );
p->drawLine( x, y, x + w - 1, y );
p->drawLine( x, y, x, y + h - 1 );
p->setPen( cg.mid().dark());
p->drawLine( x + 1, y + 1,
x + w-2, y + 1);
p->drawLine( x + 1, y + 1,
x + 1, y + h - 2 );
// the bright side!
p->setPen(cg.button());
p->drawLine( x + 1, y + h - 2,
x + w - 2,
y + h - 2 );
p->drawLine( x + w - 2, y + 1,
x + w - 2,
y + h - 2 );
//.........这里部分代码省略.........
示例4: drawControl
//.........这里部分代码省略.........
x1 += diw;
y1 += diw;
x2 -= diw;
y2 -= diw;
}
if ( !btn->isFlat() || btn->isOn() || btn->isDown() ) {
if ( useBevelButton ) {
// fix for toggle buttons...
if ( flags & (Style_Down | Style_On) )
flags |= Style_Sunken;
drawPrimitive( PE_ButtonBevel, p, QRect( x1, y1,
x2 - x1 + 1,
y2 - y1 + 1 ),
myCg, flags, opt );
} else {
drawPrimitive( PE_ButtonCommand, p, QRect( x1, y1,
x2 - x1 + 1,
y2 - y1 + 1 ),
myCg, flags, opt );
}
}
if ( p->brush().style() != NoBrush )
p->setBrush( NoBrush );
break;
#endif
}
case CE_PushButtonLabel:
{
#ifndef QT_NO_PUSHBUTTON
const QPushButton *btn;
bool on;
int x, y, w, h;
SFlags flags;
flags = Style_Default;
btn = (const QPushButton*)widget;
on = btn->isDown() || btn->isOn();
r.rect( &x, &y, &w, &h );
if ( btn->isMenuButton() ) {
int dx = pixelMetric( PM_MenuButtonIndicator, widget );
QColorGroup g = cg;
int xx = x + w - dx - 4;
int yy = y - 3;
int hh = h + 6;
if ( !on ) {
p->setPen( g.mid() );
p->drawLine( xx, yy + 2, xx, yy + hh - 3 );
p->setPen( g.button() );
p->drawLine( xx + 1, yy + 1, xx + 1, yy + hh - 2 );
p->setPen( g.light() );
p->drawLine( xx + 2, yy + 2, xx + 2, yy + hh - 2 );
}
if ( btn->isEnabled() )
flags |= Style_Enabled;
drawPrimitive( PE_ArrowDown, p, QRect(x + w - dx - 1, y + 2,
dx, h - 4),
g, flags, opt );
w -= dx;
}
#ifndef QT_NO_ICONSET
if ( btn->iconSet() && !btn->iconSet()->isNull() ) {
QIconSet::Mode mode = btn->isEnabled()
? QIconSet::Normal : QIconSet::Disabled;
if ( mode == QIconSet::Normal && btn->hasFocus() )
mode = QIconSet::Active;
QIconSet::State state = QIconSet::Off;
if ( btn->isToggleButton() && btn->isOn() )
state = QIconSet::On;
QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small,
mode, state );
int pixw = pixmap.width();
int pixh = pixmap.height();
p->drawPixmap( x + 2, y + h / 2 - pixh / 2, pixmap );
x += pixw + 4;
w -= pixw + 4;
}
#endif
drawItem( p, QRect( x, y, w, h ),
AlignCenter | ShowPrefix,
btn->colorGroup(), btn->isEnabled(),
btn->pixmap(), btn->text(), -1,
on ? &btn->colorGroup().brightText()
: &btn->colorGroup().buttonText() );
if ( btn->hasFocus() )
drawPrimitive( PE_FocusRect, p,
subRect(SR_PushButtonFocusRect, widget),
cg, flags );
break;
#endif
}
default:
QWindowsStyle::drawControl( element, p, widget, r, cg, how, opt );
break;
}
}
示例5: drawSegment
void BW_LED_Number::drawSegment( const QPoint &pos, char seg_number, QPainter &p,
int Segment_Length, bool erase){
QPoint pt = pos;
QColorGroup g = colorGroup();
QColor lightColor,darkColor;
if ( erase ){
lightColor = offcolor;
darkColor = offcolor;
} else {
lightColor = g.light();
darkColor = g.dark();
}
// int Width = (int) Segment_Length/5 ; // original
int Width = (int) Segment_Length/4;
QBrush brush(g.light());
QPointArray pts;
pt.ry() += (QCOORD)Width/2;
if (erase){
p.setBrush(offcolor);
brush.setColor(offcolor);
}
else
p.setBrush(g.light());
if(!smallLED){
switch ( seg_number ) {
case 0 :
if (erase)
p.setPen(offcolor);
pts.setPoints(3,pt.x(), pt.y() ,
pt.x(), pt.y()-Width +1,
pt.x() + Width-1, pt.y());
p.drawPolygon(pts);
pts.setPoints(3,pt.x(), pt.y() + Segment_Length -Width - Width/2 -1 ,
pt.x() + Width -1 , pt.y() -Width +Segment_Length - Width/2 -1,
pt.x() , pt.y() + Segment_Length - 3*Width/4 -1);
p.drawPolygon(pts);
if (erase)
p.setPen(g.light());
p.fillRect(pt.x(),pt.y()+ Width/2 -1, Width ,
Segment_Length - Width -Width +1 ,brush);
break;
case 1 :
p.fillRect(pt.x()+Width,pt.y()- Width , Segment_Length -2* Width, Width ,brush);
if (erase)
p.setPen(offcolor);
pts.setPoints(3,pt.x()+1, pt.y()-Width ,
pt.x()+Width, pt.y()-Width ,
pt.x() + Width, pt.y() -1 );
p.drawPolygon(pts);
pts.setPoints(3,pt.x()+ Segment_Length - Width , pt.y() - Width,
pt.x()+ Segment_Length -1, pt.y() - Width,
pt.x() + Segment_Length - Width , pt.y() -1 );
p.drawPolygon(pts);
if (erase)
p.setPen(g.light());
break;
case 2 :
pt.rx() += (QCOORD)(Segment_Length);
if (erase)
p.setPen(offcolor);
pts.setPoints(3,pt.x() , pt.y() ,
pt.x() , pt.y() - Width + 1, // changes from 1 to 2
pt.x() - Width +1, pt.y() );
p.drawPolygon(pts);
pts.setPoints(3,pt.x() , pt.y() + Segment_Length - Width - Width/2 -1,
pt.x() , pt.y() + Segment_Length - 3*Width/4 - 1,
pt.x() - Width +1, pt.y() + Segment_Length - Width - Width/2 -1);
p.drawPolygon(pts);
//.........这里部分代码省略.........