?? qmotifplusstyle.cpp
字號:
case LeftArrow: { poly.setPoint(0, x, y + (h / 2)); poly.setPoint(1, x + w - 1, y + h - 1); poly.setPoint(2, x + w - 1, y); p->drawPolygon(poly); if (down) p->setPen(g.button()); else p->setPen(g.dark()); p->drawLine(x + 1, y + (h / 2), x + w - 1, y + h - 1); if (down) p->setPen(g.light()); else p->setPen(black); p->drawLine(x, y + (h / 2), x + w - 1, y + h - 1); if (down) p->setPen(g.button()); else p->setPen(g.dark()); p->drawLine(x + w - 2, y + h - 1, x + w - 2, y + 1); if (down) p->setPen(g.light()); else p->setPen(black); p->drawLine(x + w - 1, y + h - 1, x + w - 1, y); if (down) p->setPen(black); else p->setPen(g.button()); p->drawLine(x + w - 1, y + 1, x + 1, y + (h / 2)); if (down) p->setPen(g.dark()); else p->setPen(g.light()); p->drawLine(x + w - 1, y, x, y + (h / 2)); break; } case RightArrow: { poly.setPoint(0, x + w - 1, y + (h / 2)); poly.setPoint(1, x, y); poly.setPoint(2, x, y + h - 1); p->drawPolygon(poly); if (down) p->setPen(black); else p->setPen(g.button()); p->drawLine( x + w - 1, y + (h / 2), x + 1, y + 1); if (down) p->setPen(g.dark()); else p->setPen(g.light()); p->drawLine(x + w - 1, y + (h / 2), x, y); if (down) p->setPen(black); else p->setPen(g.button()); p->drawLine(x + 1, y + 1, x + 1, y + h - 2); if (down) p->setPen(g.dark()); else p->setPen(g.light()); p->drawLine(x, y, x, y + h - 1); if (down) p->setPen(g.button()); else p->setPen(g.dark()); p->drawLine(x + 1, y + h - 2, x + w - 1, y + (h / 2)); if (down) p->setPen(g.light()); else p->setPen(black); p->drawLine(x, y + h - 1, x + w - 1, y + (h / 2)); break; } } p->restore(); p->setBrush(oldbrush); p->setPen(oldpen);}/*! \reimp*/void QMotifPlusStyle::scrollBarMetrics(const QScrollBar *scrollbar, int &sliderMin, int &sliderMax, int &sliderLength, int &buttonDim){ QMotifStyle::scrollBarMetrics(scrollbar, sliderMin, sliderMax, sliderLength, buttonDim); sliderMin += 1; sliderMax -= 1; return;}#define HORIZONTAL (sb->orientation() == QScrollBar::Horizontal)#define VERTICAL !HORIZONTAL#define MOTIF_BORDER defaultFrameWidth()#define SLIDER_MIN buttonDim/*! \reimp*/void QMotifPlusStyle::drawScrollBarControls( QPainter* p, const QScrollBar* sb, int sliderStart, uint controls, uint activeControl ){#define ADD_LINE_ACTIVE ( activeControl == AddLine )#define SUB_LINE_ACTIVE ( activeControl == SubLine ) QColorGroup g = sb->colorGroup(); QColorGroup pg = d->prelight_palette.active(); int sliderMin, sliderMax, sliderLength, buttonDim; scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); if (sliderStart > sliderMax) { // sanity check sliderStart = sliderMax; } int b = MOTIF_BORDER; 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 scrollbarUpdate = FALSE; if (d->hovering) { if (addB.contains(d->mousePos)) { scrollbarUpdate = (d->scrollbarElement == AddLine); d->scrollbarElement = AddLine; } else if (subB.contains(d->mousePos)) { scrollbarUpdate = (d->scrollbarElement == SubLine); d->scrollbarElement = SubLine; } else if (sliderR.contains(d->mousePos)) { scrollbarUpdate = (d->scrollbarElement == Slider); d->scrollbarElement = Slider; } else d->scrollbarElement = 0; } else d->scrollbarElement = 0; if (scrollbarUpdate) return; if ( controls == (AddLine | SubLine | AddPage | SubPage | Slider | First | Last ) ) drawButton(p, sb->rect().x(), sb->rect().y(), sb->rect().width(), sb->rect().height(), g, TRUE, &g.brush(QColorGroup::Mid)); if ( controls & AddLine ) drawArrow( p, VERTICAL ? DownArrow : RightArrow, ADD_LINE_ACTIVE, addB.x(), addB.y(), addB.width(), addB.height(), (ADD_LINE_ACTIVE || d->scrollbarElement == AddLine) ? pg : g, TRUE ); if ( controls & SubLine ) drawArrow( p, VERTICAL ? UpArrow : LeftArrow, SUB_LINE_ACTIVE, subB.x(), subB.y(), subB.width(), subB.height(), (SUB_LINE_ACTIVE || d->scrollbarElement == SubLine) ? pg : g, TRUE ); QBrush fill = g.brush( QColorGroup::Mid ); if (sb->backgroundPixmap() ){ fill = QBrush( g.mid(), *sb->backgroundPixmap() ); } if ( controls & SubPage ) p->fillRect( subPageR, fill ); if ( controls & AddPage ) p->fillRect( addPageR, fill ); if ( controls & Slider ) { QPoint bo = p->brushOrigin(); p->setBrushOrigin(sliderR.topLeft()); if ( sliderR.isValid() ) { drawBevelButton( p, sliderR.x(), sliderR.y(), sliderR.width(), sliderR.height(), (activeControl & Slider || d->scrollbarElement == Slider) ? pg : g, FALSE, (activeControl & Slider || d->scrollbarElement == Slider) ? &pg.brush( QColorGroup::Button ) : &g.brush( QColorGroup::Button ) ); } p->setBrushOrigin(bo); }}/*! \reimp*/void QMotifPlusStyle::drawTab(QPainter *p, const QTabBar *tabbar, QTab *tab, bool selected){ QColorGroup g = tabbar->colorGroup(); QPen oldpen = p->pen(); QRect fr(tab->r); if (! selected) { if (tabbar->shape() == QTabBar::RoundedAbove || tabbar->shape() == QTabBar::TriangularAbove) { fr.setTop(fr.top() + 2); } else { fr.setBottom(fr.bottom() - 2); } } fr.setWidth(fr.width() - 3); p->fillRect(fr.left() + 1, fr.top() + 1, fr.width() - 2, fr.height() - 2, (selected) ? g.brush(QColorGroup::Button) : g.brush(QColorGroup::Mid)); if (tabbar->shape() == QTabBar::RoundedAbove) { // "rounded" tabs on top fr.setBottom(fr.bottom() - 1); p->setPen(g.light()); p->drawLine(fr.left(), fr.top() + 1, fr.left(), fr.bottom() - 1); p->drawLine(fr.left() + 1, fr.top(), fr.right() - 1, fr.top()); if (! selected) p->drawLine(fr.left(), fr.bottom(), fr.right() + 3, fr.bottom()); if (fr.left() == 0) p->drawLine(fr.left(), fr.bottom(), fr.left(), fr.bottom() + 1); p->setPen(g.dark()); p->drawLine(fr.right() - 1, fr.top() + 2, fr.right() - 1, fr.bottom() - 1); p->setPen(black); p->drawLine(fr.right(), fr.top() + 1, fr.right(), fr.bottom() - 1); } else if (tabbar->shape() == QTabBar::RoundedBelow) { // "rounded" tabs on bottom fr.setTop(fr.top() + 1); p->setPen(g.dark()); p->drawLine(fr.right() + 3, fr.top() - 1, fr.right() - 1, fr.top() - 1); p->drawLine(fr.right() - 1, fr.top(), fr.right() - 1, fr.bottom() - 2); p->drawLine(fr.right() - 1, fr.bottom() - 2, fr.left() + 2, fr.bottom() - 2); if (! selected) { p->drawLine(fr.right(), fr.top() - 1, fr.left() + 1, fr.top() - 1); if (fr.left() != 0) p->drawPoint(fr.left(), fr.top() - 1); } p->setPen(black); p->drawLine(fr.right(), fr.top(), fr.right(), fr.bottom() - 2); p->drawLine(fr.right() - 1, fr.bottom() - 1, fr.left(), fr.bottom() - 1); if (! selected) p->drawLine(fr.right() + 3, fr.top(), fr.left(), fr.top()); else p->drawLine(fr.right() + 3, fr.top(), fr.right(), fr.top()); p->setPen(g.light()); p->drawLine(fr.left(), fr.top() + 1, fr.left(), fr.bottom() - 2); if (selected) { p->drawPoint(fr.left(), fr.top()); if (fr.left() == 0) p->drawPoint(fr.left(), fr.top() - 1); p->setPen(g.button()); p->drawLine(fr.left() + 2, fr.top() - 1, fr.left() + 1, fr.top() - 1); } } else { // triangular drawing code QCommonStyle::drawTab(p, tabbar, tab, selected); } p->setPen(oldpen);}/*! \reimp*/void QMotifPlusStyle::drawSlider(QPainter *p, int x, int y, int w, int h, const QColorGroup &g, Orientation orientation, bool, bool){ QRect sliderR(x, y, w, h); QColorGroup cg; cg = ((d->hovering && sliderR.contains(d->mousePos)) || d->sliderActive) ? d->prelight_palette.active() : g; if (orientation == Horizontal) { drawButton(p, x, y, w / 2, h, cg, FALSE, &cg.brush(QColorGroup::Button)); drawButton(p, x + (w / 2), y, w / 2, h, cg, FALSE, &cg.brush(QColorGroup::Button)); } else { drawButton(p, x, y, w, h / 2, cg, FALSE, &cg.brush(QColorGroup::Button)); drawButton(p, x, y + (h / 2), w, h / 2, cg, FALSE, &cg.brush(QColorGroup::Button)); }}/*! \reimp*/void QMotifPlusStyle::drawSliderGroove(QPainter *p, int x, int y, int w, int h, const QColorGroup& g, QCOORD, Orientation ){ drawButton(p, x, y, w, h, g, TRUE, &g.brush(QColorGroup::Mid));}/*! \reimp*/bool QMotifPlusStyle::eventFilter(QObject *object, QEvent *event){ switch(event->type()) { case QEvent::MouseButtonPress: { if (object->inherits("QSlider")) d->sliderActive = TRUE; break; } case QEvent::MouseButtonRelease: { if (object->inherits("QSlider")) { d->sliderActive = FALSE; ((QWidget *) object)->repaint(FALSE); } break; } case QEvent::Enter: { if (object->isWidgetType()) { d->hoverWidget = (QWidget *) object; if (d->hoverWidget->isEnabled()) { if (object->inherits("QScrollBar") || object->inherits("QSlider")) { d->hoverWidget->repaint(FALSE); } else if (object->inherits("QPushButton")) { QPalette pal = d->hoverWidget->palette(); if (d->hoverWidget->ownPalette()) d->hoverPalette = new QPalette(pal); pal.setColor(QPalette::Active, QColorGroup::Button, d->prelight_palette.color(QPalette::Active, QColorGroup::Button)); d->hoverWidget->setPalette(pal); } else d->hoverWidget->setPalette(d->prelight_palette); } else d->hoverWidget = 0; } break; } case QEvent::Leave: { if (object == d->hoverWidget) { if (d->hoverPalette) { d->hoverWidget->setPalette(*(d->hoverPalette)); delete d->hoverPalette; d->hoverPalette = 0; } else { d->hoverWidget->unsetPalette(); } d->hoverWidget = 0; } break; } case QEvent::MouseMove: { if (object->isWidgetType() && object == d->hoverWidget) { if (object->inherits("QScrollBar") || object->inherits("QSlider")) { d->mousePos = ((QMouseEvent *) event)->pos(); d->hovering = (((QMouseEvent *) event)->button() == NoButton); d->hoverWidget->repaint(FALSE); d->hovering = FALSE; } } break; } default: { ; } } return QMotifStyle::eventFilter(object, event);}#endif // QT_NO_STYLE_MOTIFPLUS
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -