📄 qmotifplusstyle.cpp
字号:
} int indent = ((y + h) / 2) - 6; drawArrow(p, Qt::DownArrow, TRUE, x + w - indent - 13, indent, 13, 13, g, TRUE, fill);}/*! \reimp*/QRect QMotifPlusStyle::comboButtonRect(int x, int y, int w, int h){ QRect r(x + (defaultFrameWidth() * 2), y + (defaultFrameWidth() * 2), w - (defaultFrameWidth() * 4), h - (defaultFrameWidth() * 4)); int indent = ((y + h) / 2) - defaultFrameWidth(); r.setRight(r.right() - indent - 13); return r;}/*! \reimp*/QRect QMotifPlusStyle::comboButtonFocusRect(int x, int y, int w, int h){ return comboButtonRect(x, y, w, h);}/*! \reimp*/void QMotifPlusStyle::drawPanel(QPainter *p, int x, int y, int w, int h, const QColorGroup &g, bool sunken, int, const QBrush *){ QPen oldpen = p->pen(); QPointArray a(4); if (sunken) p->setPen(g.dark()); else p->setPen(g.light()); a.setPoint(0, x, y + h - 1); a.setPoint(1, x, y); a.setPoint(2, x, y); a.setPoint(3, x + w - 1, y); p->drawLineSegments(a); if (sunken) p->setPen(black); else p->setPen(g.button()); a.setPoint(0, x + 1, y + h - 2); a.setPoint(1, x + 1, y + 1); a.setPoint(2, x + 1, y + 1); a.setPoint(3, x + w - 2, y + 1); p->drawLineSegments(a); if (sunken) p->setPen(g.button()); else p->setPen(g.dark()); a.setPoint(0, x + 2, y + h - 2); a.setPoint(1, x + w - 2, y + h - 2); a.setPoint(2, x + w - 2, y + h - 2); a.setPoint(3, x + w - 2, y + 2); p->drawLineSegments(a); if (sunken) p->setPen(g.light()); else p->setPen(black); a.setPoint(0, x + 1, y + h - 1); a.setPoint(1, x + w - 1, y + h - 1); a.setPoint(2, x + w - 1, y + h - 1); a.setPoint(3, x + w - 1, y); p->drawLineSegments(a); p->setPen(oldpen);}/*! \reimp*/void QMotifPlusStyle::drawIndicator(QPainter *p, int x, int y ,int w, int h, const QColorGroup &g, int state, bool, bool){ QBrush fill; if (state != QButton::Off) fill = g.brush(QColorGroup::Mid); else fill = g.brush(QColorGroup::Button); if (state == QButton::NoChange) { qDrawPlainRect(p, x, y, w, h, g.text(), 1, &fill); p->drawLine(x + w - 1, y, x, y + h - 1); } else { drawButton(p, x, y, w, h, g, (state != QButton::Off), &fill); }}/*! \reimp*/QSize QMotifPlusStyle::indicatorSize() const{ return QSize(10, 10);}/*! \reimp*/void QMotifPlusStyle::drawExclusiveIndicator(QPainter *p, int x, int y, int w, int h, const QColorGroup &g, bool on, bool, bool){ QPen oldpen = p->pen(); p->fillRect(x, y, w, h, g.button()); QPointArray thick(8); QPointArray thin(4); if (on) { thick.setPoint(0, x, y + (h / 2)); thick.setPoint(1, x + (w / 2), y); thick.setPoint(2, x + 1, y + (h / 2)); thick.setPoint(3, x + (w / 2), y + 1); thick.setPoint(4, x + (w / 2), y); thick.setPoint(5, x + w - 1, y + (h / 2)); thick.setPoint(6, x + (w / 2), y + 1); thick.setPoint(7, x + w - 2, y + (h / 2)); p->setPen(g.dark()); p->drawLineSegments(thick); thick.setPoint(0, x + 1, y + (h / 2) + 1); thick.setPoint(1, x + (w / 2), y + h - 1); thick.setPoint(2, x + 2, y + (h / 2) + 1); thick.setPoint(3, x + (w / 2), y + h - 2); thick.setPoint(4, x + (w / 2), y + h - 1); thick.setPoint(5, x + w - 2, y + (h / 2) + 1); thick.setPoint(6, x + (w / 2), y + h - 2); thick.setPoint(7, x + w - 3, y + (h / 2) + 1); p->setPen(g.light()); p->drawLineSegments(thick); thin.setPoint(0, x + 2, y + (h / 2)); thin.setPoint(1, x + (w / 2), y + 2); thin.setPoint(2, x + (w / 2), y + 2); thin.setPoint(3, x + w - 3, y + (h / 2)); p->setPen(black); p->drawLineSegments(thin); thin.setPoint(0, x + 3, y + (h / 2) + 1); thin.setPoint(1, x + (w / 2), y + h - 3); thin.setPoint(2, x + (w / 2), y + h - 3); thin.setPoint(3, x + w - 4, y + (h / 2) + 1); p->setPen(g.mid()); p->drawLineSegments(thin); } else { thick.setPoint(0, x, y + (h / 2)); thick.setPoint(1, x + (w / 2), y); thick.setPoint(2, x + 1, y + (h / 2)); thick.setPoint(3, x + (w / 2), y + 1); thick.setPoint(4, x + (w / 2), y); thick.setPoint(5, x + w - 1, y + (h / 2)); thick.setPoint(6, x + (w / 2), y + 1); thick.setPoint(7, x + w - 2, y + (h / 2)); p->setPen(g.light()); p->drawLineSegments(thick); thick.setPoint(0, x + 2, y + (h / 2) + 1); thick.setPoint(1, x + (w / 2), y + h - 2); thick.setPoint(2, x + 3, y + (h / 2) + 1); thick.setPoint(3, x + (w / 2), y + h - 3); thick.setPoint(4, x + (w / 2), y + h - 2); thick.setPoint(5, x + w - 3, y + (h / 2) + 1); thick.setPoint(6, x + (w / 2), y + h - 3); thick.setPoint(7, x + w - 4, y + (h / 2) + 1); p->setPen(g.dark()); p->drawLineSegments(thick); thin.setPoint(0, x + 2, y + (h / 2)); thin.setPoint(1, x + (w / 2), y + 2); thin.setPoint(2, x + (w / 2), y + 2); thin.setPoint(3, x + w - 3, y + (h / 2)); p->setPen(g.button()); p->drawLineSegments(thin); thin.setPoint(0, x + 1, y + (h / 2) + 1); thin.setPoint(1, x + (w / 2), y + h - 1); thin.setPoint(2, x + (w / 2), y + h - 1); thin.setPoint(3, x + w - 2, y + (h / 2) + 1); p->setPen(black); p->drawLineSegments(thin); } p->setPen(oldpen);}/*! \reimp*/QSize QMotifPlusStyle::exclusiveIndicatorSize() const{ return QSize(11, 11);}/*! \reimp*/void QMotifPlusStyle::drawMenuBarItem(QPainter *p, int x, int y, int w, int h, QMenuItem *mi, QColorGroup &g, bool enabled, bool activated){ if (enabled && activated) drawButton(p, x, y, w, h, d->prelight_palette.active(), FALSE); drawItem(p, x, y, w, h, AlignCenter | ShowPrefix | DontClip | SingleLine, g, enabled, mi->pixmap(), mi->text(), -1, &g.buttonText());}/*! \reimp*/void QMotifPlusStyle::drawPopupMenuItem(QPainter *p, bool checkable, int maxpmw, int tab, QMenuItem *mi, const QPalette &pl, bool act, bool enabled, int x, int y, int w, int h){ QPalette pal = (act && enabled) ? d->prelight_palette : pl; const QColorGroup & g = pal.active(); QColorGroup itemg = (! enabled) ? pal.disabled() : pal.active(); if (checkable) maxpmw = QMAX(maxpmw, 15); int checkcol = maxpmw; if (mi && mi->isSeparator()) { p->setPen( g.dark() ); p->drawLine( x, y, x+w, y ); p->setPen( g.light() ); p->drawLine( x, y+1, x+w, y+1 ); return; } if ( act && enabled ) drawButton(p, x, y, w, h, g, FALSE, &g.brush(QColorGroup::Button)); else p->fillRect(x, y, w, h, g.brush( QColorGroup::Button )); if ( !mi ) return; if ( mi->isChecked() ) {#ifndef QT_NO_ICONSET if ( mi->iconSet() ) { qDrawShadePanel( p, x+2, y+2, checkcol, h-2*2, g, TRUE, 1, &g.brush( QColorGroup::Midlight ) ); }#endif } else if ( !act ) { p->fillRect(x+2, y+2, checkcol, h-2*2, g.brush( QColorGroup::Button )); }#ifndef QT_NO_ICONSET if ( mi->iconSet() ) { // draw iconset QIconSet::Mode mode = (enabled) ? QIconSet::Normal : QIconSet::Disabled; if (act && enabled) mode = QIconSet::Active; QPixmap pixmap = mi->iconSet()->pixmap(QIconSet::Small, mode); int pixw = pixmap.width(); int pixh = pixmap.height(); QRect cr( x + 2, y+2, checkcol, h-2*2 ); QRect pmr( 0, 0, pixw, pixh ); pmr.moveCenter(cr.center()); p->setPen( itemg.text() ); p->drawPixmap( pmr.topLeft(), pixmap ); } else#endif if (checkable) { int mw = checkcol; int mh = h - 4; if (mi->isChecked()) drawCheckMark(p, x+2, y+2, mw, mh, itemg, act, ! enabled); } p->setPen( g.buttonText() ); QColor discol; if (! enabled) { discol = itemg.text(); p->setPen( discol ); } if (mi->custom()) { p->save(); mi->custom()->paint(p, itemg, act, enabled, x + checkcol + 4, y + 2, w - checkcol - tab - 3, h - 4); p->restore(); } QString s = mi->text(); if ( !s.isNull() ) { // draw text int t = s.find( '\t' ); int m = 2; const int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine; if ( t >= 0 ) { // draw tab text p->drawText( x+w-tab-2-2, y+m, tab, h-2*m, text_flags, s.mid( t+1 ) ); } p->drawText(x + checkcol + 4, y + 2, w - checkcol -tab - 3, h - 4, text_flags, s, t); } else if (mi->pixmap()) { QPixmap *pixmap = mi->pixmap(); if (pixmap->depth() == 1) p->setBackgroundMode(OpaqueMode); p->drawPixmap(x + checkcol + 2, y + 2, *pixmap); if (pixmap->depth() == 1) p->setBackgroundMode(TransparentMode); } if (mi->popup()) { int hh = h / 2; drawArrow(p, RightArrow, (act) ? mi->isEnabled() : FALSE, x + w - hh - 6, y + (hh / 2), hh, hh, g, mi->isEnabled()); }}/*! \reimp*/int QMotifPlusStyle::defaultFrameWidth() const{ return 2;}/*! \reimp*/void QMotifPlusStyle::drawArrow(QPainter *p, ArrowType type, bool down, int x, int y, int w, int h, const QColorGroup &g, bool, const QBrush *){ QPen oldpen = p->pen(); QBrush oldbrush = p->brush(); p->save(); QPointArray poly(3); p->setBrush(g.button()); switch (type) { case UpArrow: { poly.setPoint(0, x + (w / 2), y ); poly.setPoint(1, x, y + h - 1); poly.setPoint(2, x + w - 1, y + h - 1); p->drawPolygon(poly); if (down) p->setPen(g.button()); else p->setPen(g.dark()); p->drawLine(x + 1, y + h - 2, x + w - 2, y + h - 2); if (down) p->setPen(g.light()); else p->setPen(black); p->drawLine(x, y + h - 1, 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 / 2), y); if (down) p->setPen(black); else p->setPen(g.button()); p->drawLine(x + (w / 2), y + 1, x + 1, y + h - 1); if (down) p->setPen(g.dark()); else p->setPen(g.light()); p->drawLine(x + (w / 2), y, x, y + h - 1); break; } case DownArrow: { poly.setPoint(0, x + w - 1, y); poly.setPoint(1, x, y); poly.setPoint(2, x + (w / 2), y + h - 1); p->drawPolygon(poly); if (down) p->setPen(black); else p->setPen(g.button()); p->drawLine(x + w - 2, y + 1, x + 1, y + 1); if (down) p->setPen(g.dark()); else p->setPen(g.light()); p->drawLine(x + w - 1, y, x, y); if (down) p->setPen(black); else p->setPen(g.button()); p->drawLine(x + 1, y, x + (w / 2), y + h - 2); if (down) p->setPen(g.dark()); else p->setPen(g.light()); p->drawLine(x, y, x + (w / 2), y + h - 1); if (down) p->setPen(g.button()); else p->setPen(g.dark()); p->drawLine(x + (w / 2), y + h - 2, x + w - 2, y); if (down) p->setPen(g.light()); else p->setPen(black); p->drawLine(x + (w / 2), y + h - 1, x + w - 1, y); break; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -