?? qcommonstyle.cpp
字號:
/*!\reimp */voidQCommonStyle::drawSliderGrooveMask( QPainter *p, int x, int y, int w, int h, QCOORD c, Orientation orient ){ QColorGroup g(color1, color1, color1, color1, color1, color1, color1, color1, color0); drawSliderGroove( p, x, y, w, h, g, c, orient );// if ( orient == Horizontal )// p->fillRect(x, y, w, h, color1);// else// p->fillRect(x, y, w, h, color1);}/*!\reimp */int QCommonStyle::maximumSliderDragDistance() const{ return -1;}static const int motifArrowHMargin = 6; // arrow horizontal margin/*! \reimp */int QCommonStyle::popupSubmenuIndicatorWidth( const QFontMetrics& fm ){ return fm.ascent() + motifArrowHMargin;}void QCommonStyle::drawMenuBarItem( QPainter* p, int x, int y, int w, int h, QMenuItem* mi, QColorGroup& g, bool enabled, bool ){#ifndef QT_NO_MENUBAR drawItem( p, x, y, w, h, AlignCenter|ShowPrefix|DontClip|SingleLine, g, enabled, mi->pixmap(), mi->text(), -1, &g.buttonText() );#endif}// doesn't really belong here... fix 3.0QRect QStyle::pushButtonContentsRect( QPushButton* btn ){#ifndef QT_NO_PUSHBUTTON int fw = 0; if ( btn->isDefault() || btn->autoDefault() ) fw = buttonDefaultIndicatorWidth(); return buttonRect( fw, fw, btn->width()-2*fw, btn->height()-2*fw );#else return QRect(0,0,0,0);#endif}void QStyle::drawToolBarHandle( QPainter *p, const QRect &r, Qt::Orientation orientation, bool highlight, const QColorGroup &cg, bool drawBorder ){ p->save(); p->translate( r.x(), r.y() ); if ( guiStyle() == Qt::MotifStyle ) {#ifndef QT_NO_STYLE_MOTIFPLUS if (inherits("QMotifPlusStyle")) { QMotifPlusStyle *mp = (QMotifPlusStyle *) this; unsigned int i; if (orientation == Qt::Vertical) { mp->drawButton(p, 0, 0, r.width(), toolBarHandleExtent(), cg, FALSE, &cg.brush(((highlight) ? QColorGroup::Highlight : QColorGroup::Button))); if (r.width() > 8) { QPointArray a( 2 * ((r.width()-8)/3) ); int x = 3 + (r.width()%3)/2; p->setPen( cg.dark() ); for( i=0; 2*i < a.size(); i ++ ) { a.setPoint( 2*i, x+1+3*i, 6 ); a.setPoint( 2*i+1, x+2+3*i, 3 ); } p->drawPoints( a ); p->setPen( cg.light() ); for( i=0; 2*i < a.size(); i++ ) { a.setPoint( 2*i, x+3*i, 5 ); a.setPoint( 2*i+1, x+1+3*i, 2 ); } p->drawPoints( a ); } } else { mp->drawButton(p, 0, 0, toolBarHandleExtent(), r.height(), cg, FALSE, &cg.brush(((highlight) ? QColorGroup::Highlight : QColorGroup::Button))); if ( r.height() > 8 ) { QPointArray a( 2 * ((r.height()-8)/3) ); int y = 3 + (r.height()%3)/2; p->setPen( cg.dark() ); for( i=0; 2*i < a.size(); i ++ ) { a.setPoint( 2*i, 5, y+1+3*i ); a.setPoint( 2*i+1, 2, y+2+3*i ); } p->drawPoints( a ); p->setPen( cg.light() ); for( i=0; 2*i < a.size(); i++ ) { a.setPoint( 2*i, 4, y+3*i ); a.setPoint( 2*i+1, 1, y+1+3*i ); } p->drawPoints( a ); } } } else#endif // QT_NO_STYLE_MOTIFPLUS { QColor dark( cg.dark() ); QColor light( cg.light() ); unsigned int i; if ( orientation == Qt::Vertical ) { int w = r.width(); if ( w > 6 ) { if ( highlight ) p->fillRect( 1, 1, w - 2, 9, cg.highlight() ); QPointArray a( 2 * ((w-6)/3) ); int x = 3 + (w%3)/2; p->setPen( dark ); p->drawLine( 1, 8, w-2, 8 ); for( i=0; 2*i < a.size(); i ++ ) { a.setPoint( 2*i, x+1+3*i, 6 ); a.setPoint( 2*i+1, x+2+3*i, 3 ); } p->drawPoints( a ); p->setPen( light ); p->drawLine( 1, 9, w-2, 9 ); for( i=0; 2*i < a.size(); i++ ) { a.setPoint( 2*i, x+3*i, 5 ); a.setPoint( 2*i+1, x+1+3*i, 2 ); } p->drawPoints( a ); if ( drawBorder ) { p->setPen( QPen( Qt::darkGray ) ); p->drawLine( r.width() - 1, 0, r.width() - 1, toolBarHandleExtent() ); } } } else { int h = r.height(); if ( h > 6 ) { if ( highlight ) p->fillRect( 1, 1, 8, h - 2, cg.highlight() ); QPointArray a( 2 * ((h-6)/3) ); int y = 3 + (h%3)/2; p->setPen( dark ); p->drawLine( 8, 1, 8, h-2 ); for( i=0; 2*i < a.size(); i ++ ) { a.setPoint( 2*i, 5, y+1+3*i ); a.setPoint( 2*i+1, 2, y+2+3*i ); } p->drawPoints( a ); p->setPen( light ); p->drawLine( 9, 1, 9, h-2 ); for( i=0; 2*i < a.size(); i++ ) { a.setPoint( 2*i, 4, y+3*i ); a.setPoint( 2*i+1, 1, y+1+3*i ); } p->drawPoints( a ); if ( drawBorder ) { p->setPen( QPen( Qt::darkGray ) ); p->drawLine( 0, r.height() - 1, toolBarHandleExtent(), r.height() - 1 ); } } } } } else { if ( orientation == Qt::Vertical ) { if ( r.width() > 4 ) { qDrawShadePanel( p, 2, 4, r.width() - 4, 3, cg, highlight, 1, 0 ); qDrawShadePanel( p, 2, 7, r.width() - 4, 3, cg, highlight, 1, 0 ); } } else { if ( r.height() > 4 ) { qDrawShadePanel( p, 4, 2, 3, r.height() - 4, cg, highlight, 1, 0 ); qDrawShadePanel( p, 7, 2, 3, r.height() - 4, cg, highlight, 1, 0 ); } } } p->restore();}void QStyle::drawToolButton( QToolButton* btn, QPainter *p){#ifndef QT_NO_TOOLBUTTON if ( !btn ) return; int x = 0; int y = 0; int w = btn->width(); int h = btn->height(); const QColorGroup &g = btn->colorGroup(); bool sunken = ( btn->isOn() && !btn->son ) || btn->isDown(); QBrush fill = btn->colorGroup().brush( btn->backgroundMode() == QToolButton::PaletteBackground ? QColorGroup::Background : QColorGroup::Button ); if ( guiStyle() == WindowsStyle && btn->isOn() ) fill = QBrush( g.light(), Dense4Pattern );#if defined(_WS_WIN_) if ( btn->uses3D() || btn->isDown() || ( btn->isOn() && !btn->son ) ) { // WIN2000 is really tricky here! bool drawRect = btn->isOn(); if ( guiStyle() == WindowsStyle && btn->isOn() && ( QApplication::winVersion() == Qt::WV_2000 || QApplication::winVersion() == Qt::WV_98 ) && btn->uses3D() ) { fill = btn->colorGroup().brush( QColorGroup::Button ); drawRect = FALSE; } if ( guiStyle() == WindowsStyle && ( QApplication::winVersion() == Qt::WV_2000 || QApplication::winVersion() == Qt::WV_98 ) && btn->autoRaise() ) { drawPanel( p, x, y, w, h, g, sunken, 1, &fill ); if ( drawRect ) { p->setPen( QPen( g.color( QColorGroup::Button ) ) ); p->drawRect( x + 1, y + 1, w - 2, h - 2 ); } } else { drawToolButton( p, x, y, w, h, g, sunken, &fill ); } } else if ( btn->parentWidget() && btn->parentWidget()->backgroundPixmap() && !btn->parentWidget()->backgroundPixmap()->isNull() ) { p->drawTiledPixmap( 0, 0, btn->width(), btn->height(), *btn->parentWidget()->backgroundPixmap(), btn->x(), btn->y() ); }#else if ( btn->uses3D() || btn->isDown() || ( btn->isOn() && !btn->son ) ) { drawToolButton( p, x, y, w, h, g, sunken, &fill ); } else if ( btn->parentWidget() && btn->parentWidget()->backgroundPixmap() && !btn->parentWidget()->backgroundPixmap()->isNull() ) { if ( btn->testWState(WState_GlobalBrushOrigin) && btn->parentWidget()->backgroundMode() != QWidget::FixedPixmap ) { // paletted brush background, we need to use the brush origin p->fillRect( 0, 0, btn->width(), btn->height(), QBrush(QColor(),*btn->parentWidget()->backgroundPixmap()) ); } else { p->drawTiledPixmap( 0, 0, btn->width(), btn->height(), *btn->parentWidget()->backgroundPixmap(), btn->x(), btn->y() ); } } else { if ( btn->parentWidget() ) fill = QBrush( btn->parentWidget()->backgroundColor() ); drawToolButton( p, x - 10, y - 10, w + 20, h + 20, g, sunken, &fill ); }#endif#endif}//### remove in Version 3.0void QStyle::drawMenuBarItem( QPainter* p, int x, int y, int w, int h, QMenuItem* mi, QColorGroup& g, bool enabled, bool active ){#ifndef QT_NO_MENUBAR#ifndef QT_NO_STYLE_SGI if (draw_menu_bar_impl != 0) { QDrawMenuBarItemImpl impl = draw_menu_bar_impl; (this->*impl)(p, x, y, w, h, mi, g, enabled, active); // } else if ( inherits("QSGIStyle" ) ) { // QSGIStyle* sg = (QSGIStyle*) this; // sg->drawMenuBarItem( p, x, y, w, h, mi, g, enabled, active ); } else { drawItem( p, x, y, w, h, AlignCenter|ShowPrefix|DontClip|SingleLine, g, enabled, mi->pixmap(), mi->text(), -1, &g.buttonText() ); }#else Q_UNUSED(active); drawItem( p, x, y, w, h, AlignCenter|ShowPrefix|DontClip|SingleLine, g, enabled, mi->pixmap(), mi->text(), -1, &g.buttonText() );#endif // QT_NO_STYLE_SGI#endif}#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -