⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qwindowsstyle.cpp

📁 qtopia-phone-2.2.0下公共的控件实现源代码。
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	    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}/*!\reimp */void QWindowsStyle::getButtonShift( int &x, int &y){    x = 1;    y = 1;}/*!\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 ) );}/*!\reimp */QRect QWindowsStyle::comboButtonRect( int x, int y, int w, int h){    return QRect(x+2, y+2, w-4-16, h-4);}/*!\reimp */QRect QWindowsStyle::comboButtonFocusRect( int x, int y, int w, int h){    return QRect(x+3, y+3, w-6-16, h-6);}/*! \reimp */void QWindowsStyle::tabbarMetrics( const QTabBar* t, int& hframe, int& vframe, int& overlap){    QCommonStyle::tabbarMetrics( t, hframe, vframe, overlap );}/*! \reimp */void QWindowsStyle::drawTab( QPainter* p,  const QTabBar* tb, QTab* t , bool selected ){#ifndef QT_NO_TABBAR    QRect r( t->r );    if ( tb->shape()  == QTabBar::RoundedAbove ) {	p->setPen( tb->colorGroup().midlight() );	p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() );	p->setPen( tb->colorGroup().light() );	p->drawLine( r.left(), r.bottom()-1, r.right(), r.bottom()-1 );	if ( r.left() == 0 )	    p->drawPoint( tb->rect().bottomLeft() );	else {	    p->setPen( tb->colorGroup().midlight() );	    p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() );	}	if ( selected ) {	    p->fillRect( QRect( r.left()+1, r.bottom()-1, r.width()-3, 2),			 tb->colorGroup().brush( QColorGroup::Background ));	    p->setPen( tb->colorGroup().background() );	    p->drawLine( r.left()+1, r.bottom(), r.left()+1, r.top()+2 );	    p->setPen( tb->colorGroup().light() );	} else {	    p->setPen( tb->colorGroup().light() );	    r.setRect( r.left() + 2, r.top() + 2,		       r.width() - 4, r.height() - 2 );	}	p->drawLine( r.left(), r.bottom()-1, r.left(), r.top() + 2 );	p->drawPoint( r.left()+1, r.top() + 1 );	p->drawLine( r.left()+2, r.top(),		     r.right() - 2, r.top() );	if ( r.left() > 0 ) {	    p->setPen( tb->colorGroup().midlight() );	}	p->drawPoint( r.left(), r.bottom());	p->setPen( tb->colorGroup().midlight() );	p->drawLine( r.left()+1, r.bottom(), r.left()+1, r.top() + 2 );	p->drawLine( r.left()+2, r.top()+1,		     r.right() - 2, r.top()+1 );	p->setPen( tb->colorGroup().dark() );	p->drawLine( r.right() - 1, r.top() + 2,		     r.right() - 1, r.bottom() - 1 + (selected?1:-1));	p->setPen( tb->colorGroup().shadow() );	p->drawPoint( r.right() - 1, r.top() + 1 );	p->drawLine( r.right(), r.top() + 2, r.right(), r.bottom() - (selected?1:2));	p->drawPoint( r.right() - 1, r.top() + 1 );    } else if ( tb->shape() == QTabBar::RoundedBelow ) {	if ( selected ) {	    p->fillRect( QRect( r.left()+1, r.top(), r.width()-3, 1),			 tb->palette().normal().brush( QColorGroup::Background ));	    p->setPen( tb->colorGroup().background() );// 	    p->drawLine( r.left()+1, r.top(), r.right()-2, r.top() );	    p->drawLine( r.left()+1, r.top(), r.left()+1, r.bottom()-2 );	    p->setPen( tb->colorGroup().dark() );	} else {	    p->setPen( tb->colorGroup().dark() );	    p->drawLine( r.left(), r.top(), r.right(), r.top() );	    r.setRect( r.left() + 2, r.top(),		       r.width() - 4, r.height() - 2 );	}	p->drawLine( r.right() - 1, r.top(),		     r.right() - 1, r.bottom() - 2 );	p->drawPoint( r.right() - 2, r.bottom() - 2 );	p->drawLine( r.right() - 2, r.bottom() - 1,		     r.left() + 1, r.bottom() - 1 );	p->drawPoint( r.left() + 1, r.bottom() - 2 );	p->setPen( tb->colorGroup().shadow() );	p->drawLine( r.right(), r.top(),		     r.right(), r.bottom() - 1 );	p->drawPoint( r.right() - 1, r.bottom() - 1 );	p->drawLine( r.right() - 1, r.bottom(),		     r.left() + 2, r.bottom() );	p->setPen( tb->colorGroup().light() );	p->drawLine( r.left(), r.top(),		     r.left(), r.bottom() - 2 );    } else {	QCommonStyle::drawTab( p, tb, t, selected );    }#endif}/*! \reimp */void QWindowsStyle::drawTabMask( QPainter* p,  const QTabBar* tb, QTab* t, bool selected ){    QCommonStyle::drawTabMask(p, tb, t, selected );}#define HORIZONTAL	(sb->orientation() == QScrollBar::Horizontal)#define VERTICAL	!HORIZONTAL#define MOTIF_BORDER	2#define SLIDER_MIN	9 // ### wtf does this have to do with motif?/*!\reimp */void QWindowsStyle::scrollBarMetrics( const QScrollBar* sb, int &sliderMin, int &sliderMax, int &sliderLength, int&buttonDim ){#ifndef QT_NO_SCROLLBAR    int maxLength;    int b = 0;    int length = HORIZONTAL ? sb->width()  : sb->height();    int extent = HORIZONTAL ? sb->height() : sb->width();    if ( length > ( extent - b*2 - 1 )*2 + b*2  )	buttonDim = extent - b*2;    else	buttonDim = ( length - b*2 )/2 - 1;    sliderMin = b + buttonDim;    maxLength  = length - b*2 - buttonDim*2;    if ( sb->maxValue() == sb->minValue() ) {	sliderLength = maxLength;    } else {	sliderLength = (sb->pageStep()*maxLength)/			(sb->maxValue()-sb->minValue()+sb->pageStep());	uint range = sb->maxValue()-sb->minValue();	if ( sliderLength < SLIDER_MIN || range > INT_MAX/2 )	    sliderLength = SLIDER_MIN;	if ( sliderLength > maxLength )	    sliderLength = maxLength;    }    sliderMax = sliderMin + maxLength - sliderLength;#endif}/*!\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) )		    p->setBrushOrigin(sliderR.topLeft());		qDrawWinPanel( p, sliderR.x(), sliderR.y(),				 sliderR.width(), sliderR.height(), g,				 FALSE, &g.brush( QColorGroup::Button ) );		p->setBrushOrigin(bo);	    }	}    }    // ### perhaps this should not be able to accept focus if maxedOut?    if ( sb->hasFocus() && (controls & Slider) )	drawFocusRect(p, QRect(sliderR.x()+2, sliderR.y()+2,			       sliderR.width()-5, sliderR.height()-5), g,		      &sb->backgroundColor());#endif}/*!\reimp */int QWindowsStyle::sliderLength() const{    return 11;}/*!\reimp */void QWindowsStyle::drawSlider( QPainter *p,			     int x, int y, int w, int h,			     const QColorGroup &g,			     Orientation orient, bool tickAbove, bool tickBelow ){#ifndef QT_NO_SLIDER        // 4444440    // 4333310    // 4322210    // 4322210    // 4322210    // 4322210    // *43210*    // **410**    // ***0***    const QColor c0 = g.shadow();    const QColor c1 = g.dark();    //    const QColor c2 = g.button();    const QColor c3 = g.midlight();    const QColor c4 = g.light();    int x1 = x;    int x2 = x+w-1;    int y1 = y;    int y2 = y+h-1;    p->fillRect( x, y, w, h, g.brush( QColorGroup::Background ) );    if ( tickAbove && tickBelow || !tickAbove && !tickBelow ) {	qDrawWinButton( p, QRect(x,y,w,h), g, FALSE,			&g.brush( QColorGroup::Button ) );	return;    }    enum  { SlUp, SlDown, SlLeft, SlRight } dir;    if ( orient == Horizontal )	if ( tickAbove )	    dir = SlUp;	else	    dir = SlDown;    else	if ( tickAbove )	    dir = SlLeft;	else	    dir = SlRight;    QPointArray a;    int d = 0;    switch ( dir ) {    case SlUp:	y1 = y1 + w/2;	d =  (w + 1) / 2 - 1;	a.setPoints(5, x1,y1, x1,y2, x2,y2, x2,y1, x1+d,y1-d );	break;    case SlDown:	y2 = y2 - w/2;	d =  (w + 1) / 2 - 1;	a.setPoints(5, x1,y1, x1,y2, x1+d,y2+d, x2,y2, x2,y1 );	break;    case SlLeft:	d =  (h + 1) / 2 - 1;	x1 = x1 + h/2;	a.setPoints(5, x1,y1, x1-d,y1+d, x1,y2, x2,y2, x2,y1);	break;    case SlRight:	d =  (h + 1) / 2 - 1;	x2 = x2 - h/2;	a.setPoints(5, x1,y1, x1,y2, x2,y2, x2+d,y1+d, x2,y1 );	break;    }    QBrush oldBrush = p->brush();    p->setBrush( g.brush( QColorGroup::Button ) );    p->setPen( NoPen );    p->drawRect( x1, y1, x2-x1+1, y2-y1+1 );    p->drawPolygon( a );    p->setBrush( oldBrush );    if ( dir != SlUp ) {	p->setPen( c4 );	p->drawLine( x1, y1, x2, y1 );	p->setPen( c3 );	p->drawLine( x1, y1+1, x2, y1+1 );    }    if ( dir != SlLeft ) {	p->setPen( c3 );	p->drawLine( x1+1, y1+1, x1+1, y2 );	p->setPen( c4 );	p->drawLine( x1, y1, x1, y2 );    }    if ( dir != SlRight ) {	p->setPen( c0 );	p->drawLine( x2, y1, x2, y2 );	p->setPen( c1 );	p->drawLine( x2-1, y1+1, x2-1, y2-1 );    }    if ( dir != SlDown ) {	p->setPen( c0 );	p->drawLine( x1, y2, x2, y2 );	p->setPen( c1 );	p->drawLine( x1+1, y2-1, x2-1, y2-1 );    }    switch ( dir ) {	case SlUp:	    p->setPen( c4 );	    p->drawLine( x1, y1, x1+d, y1-d);	    p->setPen( c0 );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -