本文整理汇总了C++中QColorGroup::button方法的典型用法代码示例。如果您正苦于以下问题:C++ QColorGroup::button方法的具体用法?C++ QColorGroup::button怎么用?C++ QColorGroup::button使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QColorGroup
的用法示例。
在下文中一共展示了QColorGroup::button方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 ) );
}
示例2: HTMLColors
HTMLColors()
{
map["black"] = "#000000";
map["green"] = "#008000";
map["silver"] = "#c0c0c0";
map["lime"] = "#00ff00";
map["gray"] = "#808080";
map["olive"] = "#808000";
map["white"] = "#ffffff";
map["yellow"] = "#ffff00";
map["maroon"] = "#800000";
map["navy"] = "#000080";
map["red"] = "#ff0000";
map["blue"] = "#0000ff";
map["purple"] = "#800080";
map["teal"] = "#008080";
map["fuchsia"] = "#ff00ff";
map["aqua"] = "#00ffff";
map["crimson"] = "#dc143c";
map["indigo"] = "#4b0082";
#ifdef __BEOS__
printf( "Warning: HTMLColors::HTMLColors() not initiating all colors\n" );
#else
// ### react to style changes
// see http://www.richinstyle.com for details
QColorGroup cg = kapp->palette().active();
map["activeborder"] = cg.light(); // bordercolor of an active window
map["activecaption"] = cg.text(); // caption color of an active window
map["appworkspace"] = cg.background(); // background color of an MDI interface
map["highlight"] = cg.highlight();
map["highlighttext"] = cg.highlightedText();
cg = kapp->palette().inactive();
map["background"] = cg.background(); // desktop background color
map["buttonface"] = cg.button(); // Button background color
map["buttonhighlight"] = cg.light();
map["buttonshadow"] = cg.shadow();
map["buttontext"] = cg.buttonText();
map["captiontext"] = cg.text();
map["infobackground"] = QToolTip::palette().inactive().background();
map["menu"] = cg.background();
map["menutext"] = cg.foreground();
map["scrollbar"] = cg.background();
map["threeddarkshadow"] = cg.dark();
map["threedface"] = cg.button();
map["threedhighlight"] = cg.light();
map["threedlightshadow"] = cg.midlight();
map["window"] = cg.background();
map["windowframe"] = cg.background();
map["text"] = cg.text();
cg = kapp->palette().disabled();
map["inactiveborder"] = cg.background();
map["inactivecaption"] = cg.background();
map["inactivecaptiontext"] = cg.text();
map["graytext"] = cg.text();
#endif
};
示例3: qDrawWinButton
void qDrawWinButton( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken,
const QBrush *fill )
{
if ( sunken )
qDrawWinShades( p, x, y, w, h,
g.shadow(), g.light(), g.dark(), g.button(), fill );
else
qDrawWinShades( p, x, y, w, h,
g.light(), g.shadow(), g.button(), g.dark(), fill );
}
示例4: 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 ) );
}
示例5: drawExclusiveIndicator
void FreshStyle::drawExclusiveIndicator ( QPainter * p, int x, int y, int w,
int h, const QColorGroup &cg, bool on, bool down, bool enabled )
{
static const QCOORD pts1[] = { // dark 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[] = { // white 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), pts4 );
a.translate( x, y );
p->setPen( cg.dark() );
p->drawPolyline( a );
a.setPoints( QCOORDARRLEN(pts4), pts1 );
a.translate( x, y );
p->setPen( cg.light() );
p->drawPolyline( a );
a.setPoints( QCOORDARRLEN(pts5), pts5 );
a.translate( x, y );
QColor fillColor = ( down || !enabled ) ? cg.button() : cg.base();
p->setPen( fillColor );
p->setBrush( fillColor ) ;
p->drawPolygon( a );
if ( on ) {
p->setPen( NoPen );
p->setBrush( cg.text() );
p->drawRect( x+5, y+4, 2, 4 );
p->drawRect( x+4, y+5, 4, 2 );
}
}
示例6: 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
}
示例7: qDrawMotifArrow
// motif arrows look the same whether they are used or not
// is this correct?
static void qDrawMotifArrow( QPainter *p, Qt::ArrowType type, bool down,
int x, int y, int w, int h,
const QColorGroup &g, bool )
{
QPointArray bFill; // fill polygon
QPointArray bTop; // top shadow.
QPointArray bBot; // bottom shadow.
QPointArray bLeft; // left shadow.
#ifndef QT_NO_TRANSFORMATIONS
QWMatrix matrix; // xform matrix
#endif
bool vertical = type == Qt::UpArrow || type == Qt::DownArrow;
bool horizontal = !vertical;
int dim = w < h ? w : h;
int colspec = 0x0000; // color specification array
if ( dim < 2 ) // too small arrow
return;
if ( dim > 3 ) {
if ( dim > 6 )
bFill.resize( dim & 1 ? 3 : 4 );
bTop.resize( (dim/2)*2 );
bBot.resize( dim & 1 ? dim + 1 : dim );
bLeft.resize( dim > 4 ? 4 : 2 );
bLeft.putPoints( 0, 2, 0,0, 0,dim-1 );
if ( dim > 4 )
bLeft.putPoints( 2, 2, 1,2, 1,dim-3 );
bTop.putPoints( 0, 4, 1,0, 1,1, 2,1, 3,1 );
bBot.putPoints( 0, 4, 1,dim-1, 1,dim-2, 2,dim-2, 3,dim-2 );
for( int i=0; i<dim/2-2 ; i++ ) {
bTop.putPoints( i*2+4, 2, 2+i*2,2+i, 5+i*2, 2+i );
bBot.putPoints( i*2+4, 2, 2+i*2,dim-3-i, 5+i*2,dim-3-i );
}
if ( dim & 1 ) // odd number size: extra line
bBot.putPoints( dim-1, 2, dim-3,dim/2, dim-1,dim/2 );
if ( dim > 6 ) { // dim>6: must fill interior
bFill.putPoints( 0, 2, 1,dim-3, 1,2 );
if ( dim & 1 ) // if size is an odd number
bFill.setPoint( 2, dim - 3, dim / 2 );
else
bFill.putPoints( 2, 2, dim-4,dim/2-1, dim-4,dim/2 );
}
}
else {
if ( dim == 3 ) { // 3x3 arrow pattern
bLeft.setPoints( 4, 0,0, 0,2, 1,1, 1,1 );
bTop .setPoints( 2, 1,0, 1,0 );
bBot .setPoints( 2, 1,2, 2,1 );
}
else { // 2x2 arrow pattern
bLeft.setPoints( 2, 0,0, 0,1 );
bTop .setPoints( 2, 1,0, 1,0 );
bBot .setPoints( 2, 1,1, 1,1 );
}
}
if ( type == Qt::UpArrow || type == Qt::LeftArrow ) {
#ifndef QT_NO_TRANSFORMATIONS // #### fix me!
matrix.translate( x, y );
if ( vertical ) {
matrix.translate( 0, h - 1 );
matrix.rotate( -90 );
} else {
matrix.translate( w - 1, h - 1 );
matrix.rotate( 180 );
}
#endif
if ( down )
colspec = horizontal ? 0x2334 : 0x2343;
else
colspec = horizontal ? 0x1443 : 0x1434;
}
else if ( type == Qt::DownArrow || type == Qt::RightArrow ) {
#ifndef QT_NO_TRANSFORMATIONS // #### fix me!
matrix.translate( x, y );
if ( vertical ) {
matrix.translate( w-1, 0 );
matrix.rotate( 90 );
}
#endif
if ( down )
colspec = horizontal ? 0x2443 : 0x2434;
else
colspec = horizontal ? 0x1334 : 0x1343;
}
QColor *cols[5];
cols[0] = 0;
cols[1] = (QColor *)&g.button();
cols[2] = (QColor *)&g.mid();
cols[3] = (QColor *)&g.light();
cols[4] = (QColor *)&g.dark();
#define CMID *cols[ (colspec>>12) & 0xf ]
#define CLEFT *cols[ (colspec>>8) & 0xf ]
#define CTOP *cols[ (colspec>>4) & 0xf ]
#define CBOT *cols[ colspec & 0xf ]
//.........这里部分代码省略.........
示例8: paint
void Mine::paint( QPainter* p, const QColorGroup &cg, const QRect& cr )
{
int x = cr.x();
int y = cr.y();
if ( !knownField || knownField->width() != cr.width() ||
knownField->height() != cr.height() ) {
delete knownField;
knownField = new QPixmap( cr.width(), cr.height() );
QPainter pp( knownField );
QBrush br( cg.button().dark(115) );
qDrawWinButton( &pp, QRect( 0, 0, cr.width(), cr.height() ), cg, TRUE, &br );
}
const int pmmarg=cr.width()/5;
if ( !unknownField || unknownField->width() != cr.width() ||
unknownField->height() != cr.height() ) {
delete unknownField;
unknownField = new QPixmap( cr.width(), cr.height() );
QPainter pp( unknownField );
QBrush br( cg.button() );
qDrawWinButton( &pp, QRect( 0, 0, cr.width(), cr.height() ), cg, FALSE, &br );
}
if ( !flag_pix || flag_pix->width() != cr.width()-pmmarg*2 ||
flag_pix->height() != cr.height()-pmmarg*2 ) {
delete flag_pix;
flag_pix = new QPixmap( cr.width()-pmmarg*2, cr.height()-pmmarg*2 );
flag_pix->convertFromImage( QImage(pix_flag).smoothScale(cr.width()-pmmarg*2, cr.height()-pmmarg*2) );
}
if ( !mine_pix || mine_pix->width() != cr.width()-pmmarg*2 ||
mine_pix->height() != cr.height()-pmmarg*2 ) {
delete mine_pix;
mine_pix = new QPixmap( cr.width()-pmmarg*2, cr.height()-pmmarg*2 );
mine_pix->convertFromImage( QImage(pix_mine).smoothScale(cr.width()-pmmarg*2, cr.height()-pmmarg*2) );
}
p->save();
switch(st) {
case Hidden:
p->drawPixmap( x, y, *unknownField );
break;
case Empty:
p->drawPixmap( x, y, *knownField );
if ( hint > 0 ) {
switch( hint ) {
case 1:
p->setPen( blue );
break;
case 2:
p->setPen( green.dark() );
break;
case 3:
p->setPen( red );
break;
case 4:
p->setPen( darkYellow.dark() );
break;
case 5:
p->setPen( darkMagenta );
break;
case 6:
p->setPen( darkRed );
break;
default:
p->setPen( black );
break;
}
p->drawText( cr, AlignHCenter | AlignVCenter, QString::number( hint ) );
}
break;
case Mined:
p->drawPixmap( x, y, *knownField );
p->drawPixmap( x+pmmarg, y+pmmarg, *mine_pix );
break;
case Exploded:
p->drawPixmap( x, y, *knownField );
p->drawPixmap( x+pmmarg, y+pmmarg, *mine_pix );
p->setPen( red );
p->drawText( cr, AlignHCenter | AlignVCenter, "X" );
break;
case Flagged:
p->drawPixmap( x, y, *unknownField );
p->drawPixmap( x+pmmarg, y+pmmarg, *flag_pix );
break;
#ifdef MARK_UNSURE
case Unsure:
p->drawPixmap( x, y, *unknownField );
p->drawText( cr, AlignHCenter | AlignVCenter, "?" );
break;
#endif
case Wrong:
p->drawPixmap( x, y, *unknownField );
p->drawPixmap( x+pmmarg, y+pmmarg, *flag_pix );
p->setPen( red );
p->drawText( cr, AlignHCenter | AlignVCenter, "X" );
break;
}
//.........这里部分代码省略.........
示例9: drawControl
void MetalStyle::drawControl( ControlElement element,
QPainter *p,
const QWidget *widget,
const QRect &r,
const QColorGroup &cg,
SFlags how,
const QStyleOption& opt ) const
{
switch( element ) {
case CE_PushButton:
{
const QPushButton *btn;
btn = (const QPushButton*)widget;
int x1, y1, x2, y2;
r.coords( &x1, &y1, &x2, &y2 );
p->setPen( cg.foreground() );
p->setBrush( QBrush(cg.button(), NoBrush) );
QBrush fill;
if ( btn->isDown() )
fill = cg.brush( QColorGroup::Mid );
else if ( btn->isOn() )
fill = QBrush( cg.mid(), Dense4Pattern );
else
fill = cg.brush( QColorGroup::Button );
if ( btn->isDefault() ) {
QPointArray a;
a.setPoints( 9,
x1, y1, x2, y1, x2, y2, x1, y2, x1, y1+1,
x2-1, y1+1, x2-1, y2-1, x1+1, y2-1, x1+1, y1+1 );
p->setPen( Qt::black );
p->drawPolyline( a );
x1 += 2;
y1 += 2;
x2 -= 2;
y2 -= 2;
}
SFlags flags = Style_Default;
if ( btn->isOn() )
flags |= Style_On;
if ( btn->isDown() )
flags |= Style_Down;
if ( !btn->isFlat() && !btn->isDown() )
flags |= Style_Raised;
drawPrimitive( PE_ButtonCommand, p,
QRect( x1, y1, x2 - x1 + 1, y2 - y1 + 1),
cg, flags, opt );
if ( btn->isMenuButton() ) {
flags = Style_Default;
if ( btn->isEnabled() )
flags |= Style_Enabled;
int dx = ( y1 - y2 - 4 ) / 3;
drawPrimitive( PE_ArrowDown, p,
QRect(x2 - dx, dx, y1, y2 - y1),
cg, flags, opt );
}
if ( p->brush().style() != NoBrush )
p->setBrush( NoBrush );
break;
}
case CE_PushButtonLabel:
{
const QPushButton *btn;
btn = (const QPushButton*)widget;
int x, y, w, h;
r.rect( &x, &y, &w, &h );
int x1, y1, x2, y2;
r.coords( &x1, &y1, &x2, &y2 );
int dx = 0;
int dy = 0;
if ( btn->isMenuButton() )
dx = ( y2 - y1 ) / 3;
if ( btn->isOn() || btn->isDown() ) {
dx--;
dy--;
}
if ( dx || dy )
p->translate( dx, dy );
x += 2;
y += 2;
w -= 4;
h -= 4;
drawItem( p, QRect( x, y, w, h ),
AlignCenter|ShowPrefix,
cg, btn->isEnabled(),
btn->pixmap(), btn->text(), -1,
(btn->isDown() || btn->isOn())? &cg.brightText() : &cg.buttonText() );
if ( dx || dy )
p->translate( -dx, -dy );
break;
}
default:
QWindowsStyle::drawControl( element, p, widget, r, cg, how, opt );
//.........这里部分代码省略.........
示例10: drawArrow
void QCDEStyle::drawArrow( QPainter *p, ArrowType type, bool down,
int x, int y, int w, int h,
const QColorGroup &g, bool enabled, const QBrush * /* fill */ )
{
QPointArray bFill; // fill polygon
QPointArray bTop; // top shadow.
QPointArray bBot; // bottom shadow.
QPointArray bLeft; // left shadow.
QWMatrix matrix; // xform matrix
bool vertical = type == UpArrow || type == DownArrow;
bool horizontal = !vertical;
int dim = w < h ? w : h;
int colspec = 0x0000; // color specification array
if ( dim < 2 ) // too small arrow
return;
// adjust size and center (to fix rotation below)
if ( w > dim ) {
x += (w-dim)/2;
w = dim;
}
if ( h > dim ) {
y += (h-dim)/2;
h = dim;
}
if ( dim > 3 ) {
bFill.resize( dim & 1 ? 3 : 4 );
bTop.resize( 2 );
bBot.resize( 2 );
bLeft.resize( 2 );
bLeft.putPoints( 0, 2, 0,0, 0,dim-1 );
bTop.putPoints( 0, 2, 1,0, dim-1, dim/2);
bBot.putPoints( 0, 2, 1,dim-1, dim-1, dim/2);
if ( dim > 6 ) { // dim>6: must fill interior
bFill.putPoints( 0, 2, 1,dim-1, 1,1 );
if ( dim & 1 ) // if size is an odd number
bFill.setPoint( 2, dim - 2, dim / 2 );
else
bFill.putPoints( 2, 2, dim-2,dim/2-1, dim-2,dim/2 );
}
}
else {
if ( dim == 3 ) { // 3x3 arrow pattern
bLeft.setPoints( 4, 0,0, 0,2, 1,1, 1,1 );
bTop .setPoints( 2, 1,0, 1,0 );
bBot .setPoints( 2, 1,2, 2,1 );
}
else { // 2x2 arrow pattern
bLeft.setPoints( 2, 0,0, 0,1 );
bTop .setPoints( 2, 1,0, 1,0 );
bBot .setPoints( 2, 1,1, 1,1 );
}
}
if ( type == UpArrow || type == LeftArrow ) {
matrix.translate( x, y );
if ( vertical ) {
matrix.translate( 0, h - 1 );
matrix.rotate( -90 );
} else {
matrix.translate( w - 1, h - 1 );
matrix.rotate( 180 );
}
if ( down )
colspec = horizontal ? 0x2334 : 0x2343;
else
colspec = horizontal ? 0x1443 : 0x1434;
}
else if ( type == DownArrow || type == RightArrow ) {
matrix.translate( x, y );
if ( vertical ) {
matrix.translate( w-1, 0 );
matrix.rotate( 90 );
}
if ( down )
colspec = horizontal ? 0x2443 : 0x2434;
else
colspec = horizontal ? 0x1334 : 0x1343;
}
QColor *cols[5];
if ( enabled ) {
cols[0] = 0;
cols[1] = (QColor *)&g.button();
cols[2] = (QColor *)&g.mid();
cols[3] = (QColor *)&g.light();
cols[4] = (QColor *)&g.dark();
} else {
cols[0] = 0;
cols[1] = (QColor *)&g.button();
cols[2] = (QColor *)&g.button();
cols[3] = (QColor *)&g.button();
cols[4] = (QColor *)&g.button();
}
#define CMID *cols[ (colspec>>12) & 0xf ]
#define CLEFT *cols[ (colspec>>8) & 0xf ]
#define CTOP *cols[ (colspec>>4) & 0xf ]
//.........这里部分代码省略.........
示例11: 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 );
//.........这里部分代码省略.........
示例12: 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 );
//.........这里部分代码省略.........
示例13: drawControl
/*!\reimp
*/
void QPlatinumStyle::drawControl( ControlElement element,
QPainter *p,
const QWidget *widget,
const QRect &r,
const QColorGroup &cg,
SFlags how,
const QStyleOption& opt ) const
{
switch( element ) {
case CE_PushButton:
{
#ifndef QT_NO_PUSHBUTTON
QColorGroup myCg( cg );
const QPushButton *btn;
int x1, y1, x2, y2;
bool useBevelButton;
SFlags flags;
flags = Style_Default;
btn = (const QPushButton*)widget;
p->setBrushOrigin( -widget->backgroundOffset().x(),
-widget->backgroundOffset().y() );
// take care of the flags based on what we know...
if ( btn->isDown() )
flags |= Style_Down;
if ( btn->isOn() )
flags |= Style_On;
if ( btn->isEnabled() )
flags |= Style_Enabled;
if ( btn->isDefault() )
flags |= Style_Default;
if (! btn->isFlat() && !(flags & Style_Down))
flags |= Style_Raised;
r.coords( &x1, &y1, &x2, &y2 );
p->setPen( cg.foreground() );
p->setBrush( QBrush(cg.button(), NoBrush) );
QBrush fill;
if ( btn->isDown() ) {
fill = cg.brush( QColorGroup::Dark );
// this could be done differently, but this
// makes a down Bezel drawn correctly...
myCg.setBrush( QColorGroup::Mid, fill );
} else if ( btn->isOn() ) {
fill = QBrush( cg.mid(), Dense4Pattern );
myCg.setBrush( QColorGroup::Mid, fill );
}
// to quote the old QPlatinumStlye drawPushButton...
// small or square image buttons as well as toggle buttons are
// bevel buttons (what a heuristic....)
if ( btn->isToggleButton()
|| ( btn->pixmap() &&
(btn->width() * btn->height() < 1600 ||
QABS( btn->width() - btn->height()) < 10 )) )
useBevelButton = TRUE;
else
useBevelButton = FALSE;
int diw = pixelMetric( PM_ButtonDefaultIndicator, widget );
if ( btn->isDefault() ) {
x1 += 1;
y1 += 1;
x2 -= 1;
y2 -= 1;
QColorGroup cg2( myCg );
SFlags myFlags = flags;
// don't draw the default button sunken, unless it's necessary.
if ( myFlags & Style_Down )
myFlags ^= Style_Down;
if ( myFlags & Style_Sunken )
myFlags ^= Style_Sunken;
cg2.setColor( QColorGroup::Button, cg.mid() );
if ( useBevelButton ) {
drawPrimitive( PE_ButtonBevel, p, QRect( x1, y1,
x2 - x1 + 1,
y2 - y1 + 1 ),
myCg, myFlags, opt );
} else {
drawPrimitive( PE_ButtonCommand, p, QRect( x1, y1,
x2 - x1 + 1,
y2 - y1 + 1 ),
cg2, myFlags, opt );
}
}
if ( btn->isDefault() || btn->autoDefault() ) {
x1 += diw;
y1 += diw;
x2 -= diw;
y2 -= diw;
}
if ( !btn->isFlat() || btn->isOn() || btn->isDown() ) {
if ( useBevelButton ) {
// fix for toggle buttons...
//.........这里部分代码省略.........