void QSlider::drawWinGroove( QPainter *p, QCOORD c ) { if ( orient == Horizontal ) { qDrawWinPanel( p, 0, c - 2, width(), 4, colorGroup(), TRUE ); p->setPen( colorGroup().foreground() ); p->drawLine( 1, c - 1, width() - 3, c - 1 ); } else { qDrawWinPanel( p, c - 2, 0, 4, height(), colorGroup(), TRUE ); p->setPen( colorGroup().foreground() ); p->drawLine( c - 1, 1, c - 1, height() - 3 ); } }
/*! \reimp */ void QWindowsStyle::drawPopupPanel( QPainter *p, int x, int y, int w, int h, const QColorGroup &g, int /* lineWidth */, const QBrush *fill ) { qDrawWinPanel( p, x, y, w, h, g, FALSE, fill ); }
/*! \fn void QDecorationDefault::paintButton(QPainter *painter, const QWidget *widget, int buttonRegion, DecorationState state, const QPalette &palette) Paints a region of the top-level \a widget. The region is painted in the specified decoration \a state using the \a painter and \a palette provided. The region to be painted is specified by \a buttonRegion, which is a combination of the bitmask values of DecorationRegion. If the value of \a buttonRegion is one of \e Help, \e Menu, \e Close, \e Minimize, \e Maximize, and \e Normalize, the button pixmap for that region is painted. \sa pixmapFor() */ void QDecorationDefault::paintButton(QPainter *painter, const QWidget *widget, int buttonRegion, DecorationState state, const QPalette &pal) { int xoff = 2; int yoff = 2; const QPixmap pm = pixmapFor(widget, buttonRegion, xoff, yoff); QRect brect(QDecoration::region(widget, buttonRegion).boundingRect()); bool porterDuff = painter->paintEngine()->hasFeature(QPaintEngine::PorterDuff); if (state & QDecoration::Pressed) { if (porterDuff) painter->setCompositionMode(QPainter::CompositionMode_Source); qDrawWinPanel(painter, brect, pal, true, &pal.brush(QPalette::Window)); if (porterDuff) painter->setCompositionMode(QPainter::CompositionMode_SourceOver); ++xoff; ++yoff; } else { painter->fillRect(brect, pal.brush(QPalette::Window)); } if (!pm.isNull()) painter->drawPixmap(brect.x() + xoff, brect.y() + yoff, pm); }
/*!\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 ) ); }
/*! Virtual function that draws the mask of the frame's frame. If you reimplemented drawFrame(QPainter*) and your widget should support transparency you probably have to re-implement this function as well. \sa drawFrame(), updateMask(), QWidget::setAutoMask(), QPainter::setClipRect() */ void QFrame::drawFrameMask( QPainter* p ) { QPoint p1, p2; QRect r = frameRect(); int type = fstyle & MShape; int style = fstyle & MShadow; #ifdef QT_NO_DRAWUTIL p->setPen( color1 ); p->drawRect( r ); //### a bit too simple #else QColorGroup g(color1, color1, color1, color1, color1, color1, color1, color1, color0); switch ( type ) { case Box: if ( style == Plain ) qDrawPlainRect( p, r, g.foreground(), lwidth ); else qDrawShadeRect( p, r, g, style == Sunken, lwidth, midLineWidth() ); break; case Panel: if ( style == Plain ) qDrawPlainRect( p, r, g.foreground(), lwidth ); else qDrawShadePanel( p, r, g, style == Sunken, lwidth ); break; case WinPanel: if ( style == Plain ) qDrawPlainRect( p, r, g.foreground(), wpwidth ); else qDrawWinPanel( p, r, g, style == Sunken ); break; case HLine: case VLine: if ( type == HLine ) { p1 = QPoint( r.x(), r.height()/2 ); p2 = QPoint( r.x()+r.width(), p1.y() ); } else { p1 = QPoint( r.x()+r.width()/2, 0 ); p2 = QPoint( p1.x(), r.height() ); } if ( style == Plain ) { QPen oldPen = p->pen(); p->setPen( QPen(g.foreground(),lwidth) ); p->drawLine( p1, p2 ); p->setPen( oldPen ); } else qDrawShadeLine( p, p1, p2, g, style == Sunken, lwidth, midLineWidth() ); break; } #endif // QT_NO_DRAWUTIL }
/*!\reimp */ void QWindowsStyle::drawSliderGroove( QPainter *p, int x, int y, int w, int h, const QColorGroup& g, QCOORD c, Orientation orient ) { if ( orient == Horizontal ) { qDrawWinPanel( p, x, y + c - 2, w, 4, g, TRUE ); p->setPen( g.shadow() ); p->drawLine( x+1, y + c - 1, x + w - 3, y + c - 1 ); } else { qDrawWinPanel( p, x + c - 2, y, 4, h, g, TRUE ); p->setPen( g.shadow() ); p->drawLine( x + c - 1, y + 1, x + c - 1, y + h - 3 ); } }
void QvisOpacitySlider::drawSliderGroove(QPainter *p, int x, int y, int w, int, int c) { qDrawWinPanel(p, x, y + c - 2, w, 4, palette(), TRUE); p->setPen(palette().color(QPalette::Shadow)); p->drawLine(x+1, y + c - 1, x + w - 3, y + c - 1); }
void QDecorationWindows::paintButton(QPainter *painter, const QWidget *widget, int buttonRegion, DecorationState state, const QPalette &pal) { QBrush fromBrush, toBrush; QPen titlePen; if (widget == qApp->activeWindow() || qApp->activeWindow() == qApp->activePopupWidget()) { fromBrush = pal.brush(QPalette::Highlight); titlePen = pal.color(QPalette::HighlightedText); } else { fromBrush = pal.brush(QPalette::Window); titlePen = pal.color(QPalette::Text); } toBrush = fromBrush.color().lighter(300); QRect brect(QDecoration::region(widget, buttonRegion).boundingRect()); if (buttonRegion != Close && buttonRegion != Menu) painter->fillRect(brect, toBrush); else painter->fillRect(brect.x() - 2, brect.y(), brect.width() + 4, brect.height(), buttonRegion == Menu ? fromBrush : toBrush); int xoff = 1; int yoff = 2; const QPixmap pm = pixmapFor(widget, buttonRegion, xoff, yoff); if (buttonRegion != Menu) { if (state & Normal) { qDrawWinPanel(painter, brect.x(), brect.y() + 2, brect.width(), brect.height() - 4, pal, false, &pal.brush(QPalette::Window)); } else if (state & Pressed) { qDrawWinPanel(painter, brect.x(), brect.y() + 2, brect.width(), brect.height() - 4, pal, true, &pal.brush(QPalette::Window)); ++xoff; ++yoff; } } else { xoff = 0; yoff = 2; } if (!pm.isNull()) painter->drawPixmap(brect.x() + xoff, brect.y() + yoff, pm); }
void MetalStyle::drawComplexControl( ComplexControl cc, QPainter *p, const QWidget *widget, const QRect &r, const QColorGroup &cg, SFlags how, SCFlags sub, SCFlags subActive, const QStyleOption& opt ) const { switch ( cc ) { case CC_Slider: { const QSlider *slider = ( const QSlider* ) widget; QRect handle = querySubControlMetrics( CC_Slider, widget, SC_SliderHandle, opt); if ( sub & SC_SliderGroove ) QWindowsStyle::drawComplexControl( cc, p, widget, r, cg, how, SC_SliderGroove, subActive, opt ); if ( (sub & SC_SliderHandle) && handle.isValid() ) drawMetalButton( p, handle.x(), handle.y(), handle.width(), handle.height(), FALSE, slider->orientation() == QSlider::Horizontal); break; } case CC_ComboBox: { // not exactly correct... const QComboBox *cmb = ( const QComboBox* ) widget; qDrawWinPanel( p, r.x(), r.y(), r.width(), r.height(), cg, TRUE, cmb->isEnabled() ? &cg.brush( QColorGroup::Base ) : &cg.brush( QColorGroup::Background ) ); drawMetalButton( p, r.x() + r.width() - 2 - 16, r.y() + 2, 16, r.height() - 4, how & Style_Sunken, TRUE ); drawPrimitive( PE_ArrowDown, p, QRect( r.x() + r.width() - 2 - 16 + 2, r.y() + 2 + 2, 16 - 4, r.height() - 4 -4 ), cg, cmb->isEnabled() ? Style_Enabled : Style_Default, opt ); break; } default: QWindowsStyle::drawComplexControl( cc, p, widget, r, cg, how, sub, subActive, opt ); break; } }
void QWindowsStyle::drawIndicator( QPainter* p, int x, int y, int w, int h, const QColorGroup &g, int s, bool down, bool enabled ) { #ifndef QT_NO_BUTTON QBrush fill; if ( s == QButton::NoChange ) { QBrush b = p->brush(); QColor c = p->backgroundColor(); p->setBackgroundMode( TransparentMode ); p->setBackgroundColor( green ); fill = QBrush(g.base(), Dense4Pattern); p->setBackgroundColor( c ); p->setBrush( b ); } else if ( down ) fill = g.brush( QColorGroup::Button ); else fill = g.brush( enabled ? QColorGroup::Base : QColorGroup::Background ); qDrawWinPanel( p, x, y, w, h, g, TRUE, &fill ); if ( s != QButton::Off ) { QPointArray a( 7*2 ); int i, xx, yy; xx = x+3; yy = y+5; for ( i=0; i<3; i++ ) { a.setPoint( 2*i, xx, yy ); a.setPoint( 2*i+1, xx, yy+2 ); xx++; yy++; } yy -= 2; for ( i=3; i<7; i++ ) { a.setPoint( 2*i, xx, yy ); a.setPoint( 2*i+1, xx, yy+2 ); xx++; yy--; } if ( s == QButton::NoChange ) { p->setPen( g.dark() ); } else { p->setPen( g.text() ); } p->drawLineSegments( a ); } #endif }
KDEFX_EXPORT void kDrawRoundButton(QPainter *p, const QRect &r, const QColorGroup &g, bool sunken) { int x, y, x2, y2; r.coords(&x, &y, &x2, &y2); if(r.width() > 16 && r.height() > 16){ QPen oldPen = p->pen(); QPointArray hPntArray, lPntArray; hPntArray.putPoints(0, 12, x+4,y+1, x+5,y+1, // top left x+3,y+2, x+2,y+3, x+1,y+4, x+1,y+5, x+1,y2-5, x+1,y2-4, x+2,y2-3, // half corners x2-5,y+1, x2-4,y+1, x2-3,y+2); lPntArray.putPoints(0, 17, x2-5,y2-1, x2-4,y2-1, // btm right x2-3,y2-2, x2-2,y2-3, x2-1,y2-5, x2-1,y2-4, x+3,y2-2, x+4,y2-1, x+5,y2-1, //half corners x2-2,y+3, x2-1,y+4, x2-1,y+5, x2-5,y2-2, x2-4,y2-2, // testing x2-3,y2-3, x2-2,y2-5, x2-2,y2-4); p->setPen(sunken ? g.dark() : g.light()); p->drawLine(x+6, y, x2-6, y); p->drawLine(0, y+6, 0, y2-6); p->drawPoints(hPntArray); p->setPen(sunken ? g.light() : g.dark()); p->drawLine(x+6, y2, x2-6, y2); p->drawLine(x+6, y2-1, x2-6, y2-1); p->drawLine(x2, y+6, x2, y2-6); p->drawLine(x2-1, y+6, x2-1, y2-6); p->drawPoints(lPntArray); p->setPen(oldPen); } else qDrawWinPanel(p, x, y, r.width(), r.height(), g, sunken); }
void QWSDefaultDecoration::paintButton(QPainter *painter, const QWidget *w, QWSDecoration::Region type, int state) { #ifndef QT_NO_PALETTE #ifndef QT_NO_STYLE QStyle &style = QApplication::style(); #endif const QColorGroup &cg = w->palette().active(); QRect brect(region(w, w->rect(), type).boundingRect()); int xoff=2; int yoff=2; const QPixmap *pm=pixmapFor(w,type,state & QWSButton::On, xoff, yoff); { if ((state & QWSButton::MouseOver) && (state & QWSButton::Clicked)) { #if !defined(QT_NO_STYLE) style.drawToolButton(painter, brect.x(), brect.y(), brect.width()-1, brect.height()-1, cg, TRUE, &cg.brush(QColorGroup::Background)); #elif !defined(QT_NO_DRAWUTIL) qDrawWinPanel(painter, brect.x(), brect.y(), brect.width()-1, brect.height()-1, cg, TRUE, &cg.brush(QColorGroup::Background)); #endif if (pm) painter->drawPixmap(brect.x()+xoff+1, brect.y()+yoff+1, *pm); } else { painter->fillRect(brect.x(), brect.y(), brect.width()-1, brect.height()-1, cg.brush(QColorGroup::Background)); if (pm) painter->drawPixmap(brect.x()+xoff, brect.y()+yoff, *pm); } } #endif }
void Frame::drawFrame(QPainter *p) { QPoint p1, p2; QStyleOptionFrame opt; opt.init(this); if ( hasFocus() ) { opt.state |= QStyle::State_HasFocus; } int frameShape = frameStyle() & QFrame::Shape_Mask; int frameShadow = frameStyle() & QFrame::Shadow_Mask; int lw = 0; int mlw = 0; opt.rect = frameRect(); switch (frameShape) { case QFrame::Box: case QFrame::HLine: case QFrame::VLine: case QFrame::StyledPanel: lw = lineWidth(); mlw = midLineWidth(); break; default: // most frame styles do not handle customized line and midline widths // (see updateFrameWidth()). lw = frameWidth(); break; } opt.lineWidth = lw; opt.midLineWidth = mlw; if (frameShadow == Sunken) opt.state |= QStyle::State_Sunken; else if (frameShadow == Raised) opt.state |= QStyle::State_Raised; switch (frameShape) { case Box: if (frameShadow == Plain) qDrawPlainRect(p, opt.rect, opt.palette.foreground().color(), lw); else qDrawShadeRect(p, opt.rect, opt.palette, frameShadow == Sunken, lw, mlw); break; case StyledPanel: style()->drawPrimitive(QStyle::PE_Frame, &opt, p, this); break; case Panel: if (frameShadow == Plain) qDrawPlainRect(p, opt.rect, opt.palette.foreground().color(), lw); else qDrawShadePanel(p, opt.rect, opt.palette, frameShadow == Sunken, lw); break; case WinPanel: if (frameShadow == Plain) qDrawPlainRect(p, opt.rect, opt.palette.foreground().color(), lw); else qDrawWinPanel(p, opt.rect, opt.palette, frameShadow == Sunken); break; case HLine: case VLine: if (frameShape == HLine) { p1 = QPoint(opt.rect.x(), opt.rect.height() / 2); p2 = QPoint(opt.rect.x() + opt.rect.width(), p1.y()); } else { p1 = QPoint(opt.rect.x()+opt.rect.width() / 2, 0); p2 = QPoint(p1.x(), opt.rect.height()); } if (frameShadow == Plain) { QPen oldPen = p->pen(); p->setPen(QPen(opt.palette.foreground().color(), lw)); p->drawLine(p1, p2); p->setPen(oldPen); } else { qDrawShadeLine(p, p1, p2, opt.palette, frameShadow == Sunken, lw, mlw); } break; } }
void QLineEdit::paintEvent( QPaintEvent *e ) { if ( !d->pm || d->pmDirty ) { if ( !d->pm ) d->pm = new QPixmap( size() ); QPainter p( d->pm, this ); QColorGroup g = colorGroup(); QColor bg = isEnabled() ? g.base() : g.background(); QFontMetrics fm = fontMetrics(); int markBegin = minMark(); int markEnd = maxMark(); int margin = frame() ? 2 : 0; if ( frame() ) { QBrush fill( bg ); qDrawWinPanel( &p, 0, 0, width(), height(), g, TRUE, &fill ); } else { p.fillRect( 0, 0, width(), height(), bg ); } QString displayText; switch( echoMode() ) { case Normal: displayText = tbuf.mid( offset, tbuf.length() ); break; case NoEcho: displayText = ""; break; case Password: displayText.fill( '*', tbuf.length() - offset ); break; } int ypos = height() - margin - fm.descent() - 1 - (height() - 2*margin - fm.height())/2; if ( !displayText.isEmpty() ) { int charsVisible = lastCharVisible() - offset; if ( displayText[ charsVisible ] != '\0' ) charsVisible++; int mark1,mark2; if ( markBegin > offset ) { if ( markBegin < offset + charsVisible ) mark1 = markBegin - offset; else mark1 = charsVisible; } else { mark1 = 0; } if ( markEnd > offset ) { if ( markEnd < offset + charsVisible ) mark2 = markEnd - offset; else mark2 = charsVisible; } else { mark2 = 0; } // display code comes here - a bit yucky but it works if ( mark1 != mark2 ) { QString marked( displayText.mid( mark1, mark2 - mark1 ) ); int xpos1 = margin + 2 + fm.width( displayText, mark1 ); int xpos2 = xpos1 + fm.width( marked ) - 1; p.fillRect( xpos1, ypos - fm.ascent(), xpos2 - xpos1, fm.height(), style() == WindowsStyle ? QApplication::winStyleHighlightColor() : g.text() ); p.setPen( style() == WindowsStyle ? white : g.base() ); p.drawText( xpos1, ypos, marked ); } p.setPen( g.text() ); if ( mark1 != 0 ) p.drawText( margin + 2, ypos, displayText, mark1 ); if ( mark2 != charsVisible ) { QString rest( displayText.mid( mark2, charsVisible - mark2 ) ); p.drawText( margin + 2 + fm.width( displayText.left( mark2) ), ypos, rest ); } } p.setPen( g.foreground() ); int curXPos = margin + 2; if ( echoMode() != NoEcho ) curXPos += offset > cursorPos ? -1 : // ?: for scrolling case fm.width( displayText, cursorPos - offset ) - 1; int curYPos = ypos - fm.ascent(); d->cursorRepaintRect.setRect( curXPos-2, curYPos, 5, fm.height() ); d->pmDirty = FALSE; } bitBlt( this, e->rect().topLeft(), d->pm, e->rect() ); if ( hasFocus() ) { if ( cursorOn && d->cursorRepaintRect.intersects( e->rect() ) ) { QPainter p( this ); int curYTop = d->cursorRepaintRect.y(); int curYBot = d->cursorRepaintRect.bottom(); int curXPos = d->cursorRepaintRect.x() + 2; p.drawLine( curXPos, curYTop, curXPos, curYBot ); if ( style() != WindowsStyle ) { p.drawLine( curXPos - 2, curYTop, curXPos + 2, curYTop ); p.drawLine( curXPos - 2, curYBot, curXPos + 2, curYBot ); } } } else { delete d->pm; d->pm = 0; } }
void QFrame::drawFrame(QPainter *p) { QPoint p1, p2; QRect r = frameRect(); int type = fstyle & MShape; int cstyle = fstyle & MShadow; #ifdef QT_NO_DRAWUTIL p->setPen(black); // #### p->drawRect(r); //### a bit too simple #else const QColorGroup & g = colorGroup(); #ifndef QT_NO_STYLE QStyleOption opt(lineWidth(), midLineWidth()); QStyle::SFlags flags = QStyle::Style_Default; if (isEnabled()) flags |= QStyle::Style_Enabled; if (cstyle == Sunken) flags |= QStyle::Style_Sunken; else if (cstyle == Raised) flags |= QStyle::Style_Raised; if (hasFocus()) flags |= QStyle::Style_HasFocus; if (hasMouse()) flags |= QStyle::Style_MouseOver; #endif // QT_NO_STYLE switch (type) { case Box: if (cstyle == Plain) qDrawPlainRect(p, r, g.foreground(), lwidth); else qDrawShadeRect(p, r, g, cstyle == Sunken, lwidth, midLineWidth()); break; case LineEditPanel: style().drawPrimitive(QStyle::PE_PanelLineEdit, p, r, g, flags, opt); break; case GroupBoxPanel: style().drawPrimitive(QStyle::PE_PanelGroupBox, p, r, g, flags, opt); break; case TabWidgetPanel: style().drawPrimitive(QStyle::PE_PanelTabWidget, p, r, g, flags, opt); break; case MenuBarPanel: #ifndef QT_NO_STYLE style().drawPrimitive(QStyle::PE_PanelMenuBar, p, r, g, flags, opt); break; #endif // fall through to Panel if QT_NO_STYLE case ToolBarPanel: #ifndef QT_NO_STYLE style().drawPrimitive(QStyle::PE_PanelDockWindow, p, rect(), g, flags, opt); break; #endif // fall through to Panel if QT_NO_STYLE case StyledPanel: #ifndef QT_NO_STYLE if (cstyle == Plain) qDrawPlainRect(p, r, g.foreground(), lwidth); else style().drawPrimitive(QStyle::PE_Panel, p, r, g, flags, opt); break; #endif // fall through to Panel if QT_NO_STYLE case PopupPanel: #ifndef QT_NO_STYLE { int vextra = style().pixelMetric(QStyle::PM_PopupMenuFrameVerticalExtra, this), hextra = style().pixelMetric(QStyle::PM_PopupMenuFrameHorizontalExtra, this); if (vextra > 0 || hextra > 0) { QRect fr = frameRect(); int fw = frameWidth(); if (vextra > 0) { style().drawControl(QStyle::CE_PopupMenuVerticalExtra, p, this, QRect(fr.x() + fw, fr.y() + fw, fr.width() - (fw*2), vextra), g, flags, opt); style().drawControl(QStyle::CE_PopupMenuVerticalExtra, p, this, QRect(fr.x() + fw, fr.bottom() - fw - vextra, fr.width() - (fw*2), vextra), g, flags, opt); } if (hextra > 0) { style().drawControl(QStyle::CE_PopupMenuHorizontalExtra, p, this, QRect(fr.x() + fw, fr.y() + fw + vextra, hextra, fr.height() - (fw*2) - vextra), g, flags, opt); style().drawControl(QStyle::CE_PopupMenuHorizontalExtra, p, this, QRect(fr.right() - fw - hextra, fr.y() + fw + vextra, hextra, fr.height() - (fw*2) - vextra), g, flags, opt); } } if (cstyle == Plain) qDrawPlainRect(p, r, g.foreground(), lwidth); else style().drawPrimitive(QStyle::PE_PanelPopup, p, r, g, flags, opt); break; } #endif // fall through to Panel if QT_NO_STYLE case Panel: if (cstyle == Plain) qDrawPlainRect(p, r, g.foreground(), lwidth); else qDrawShadePanel(p, r, g, cstyle == Sunken, lwidth); break; case WinPanel: if (cstyle == Plain) qDrawPlainRect(p, r, g.foreground(), wpwidth); else qDrawWinPanel(p, r, g, cstyle == Sunken); break; case HLine: case VLine: if (type == HLine) { p1 = QPoint(r.x(), r.height() / 2); p2 = QPoint(r.x() + r.width(), p1.y()); } else { p1 = QPoint(r.x() + r.width() / 2, 0); p2 = QPoint(p1.x(), r.height()); } if (cstyle == Plain) { QPen oldPen = p->pen(); p->setPen(QPen(g.foreground(), lwidth)); p->drawLine(p1, p2); p->setPen(oldPen); } else qDrawShadeLine(p, p1, p2, g, cstyle == Sunken, lwidth, midLineWidth()); break; }
// draw custom slider + handle for timeslide widget void MpcTimeSlideStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget) const { if( cc == CC_Slider ) { if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { QRect groove = subControlRect(CC_Slider, slider, SC_SliderGroove, widget); QRect handle = subControlRect(CC_Slider, slider, SC_SliderHandle, widget); if ((slider->subControls & SC_SliderGroove) && groove.isValid()) { if (slider->orientation == Qt::Horizontal) { int x = groove.x() + 2; int y = slider->rect.height() / 2 - 4; int w = groove.width() - 4; int h = 7; qDrawShadeRect (p,x,y,w,h, slider->palette, true,1,0, &slider->palette.brush(QPalette::Light)); } } if (slider->subControls & SC_SliderTickmarks) { QStyleOptionSlider tmpSlider = *slider; tmpSlider.subControls = SC_SliderTickmarks; QCommonStyle::drawComplexControl(cc, &tmpSlider, p, widget); } if (slider->subControls & SC_SliderHandle) { QBrush handleBrush; if (slider->state & State_Enabled) { handleBrush = slider->palette.color(QPalette::Button); } else { handleBrush = QBrush(slider->palette.color(QPalette::Button), Qt::Dense4Pattern); } int x = handle.x() , y = handle.y() + 1, wi = 13, he = 14; if (slider->state & State_HasFocus) { QStyleOptionFocusRect fropt; fropt.QStyleOption::operator=(*slider); fropt.rect = subElementRect(SE_SliderFocusRect, slider, widget); drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); } Qt::BGMode oldMode = p->backgroundMode(); p->setBackgroundMode(Qt::OpaqueMode); qDrawWinPanel(p, QRect(x, y, wi, he), slider->palette, false, &handleBrush); qDrawShadeRect (p, QRect(x+2,y+3, wi-4, he-6), slider->palette, true,1,0, &slider->palette.brush(QPalette::Light)); p->setBackgroundMode(oldMode); } } } else { QWindowsStyle::drawComplexControl(cc,opt,p,widget); } }
void Q3GroupBox::drawFrame(QPainter *p) { QPoint p1, p2; QStyleOptionFrame opt; opt.init(this); int frameShape = d->frameStyle & QFrame::Shape_Mask; int frameShadow = d->frameStyle & QFrame::Shadow_Mask; int lw = 0; int mlw = 0; opt.rect = frameRect(); switch (frameShape) { case QFrame::Box: case QFrame::HLine: case QFrame::VLine: case QFrame::StyledPanel: lw = d->lineWidth; mlw = d->midLineWidth; break; default: // most frame styles do not handle customized line and midline widths // (see updateFrameWidth()). lw = d->frameWidth; break; } opt.lineWidth = lw; opt.midLineWidth = mlw; if (frameShadow == Sunken) opt.state |= QStyle::State_Sunken; else if (frameShadow == Raised) opt.state |= QStyle::State_Raised; switch (frameShape) { case Box: if (frameShadow == Plain) qDrawPlainRect(p, opt.rect, opt.palette.foreground().color(), lw); else qDrawShadeRect(p, opt.rect, opt.palette, frameShadow == Sunken, lw, mlw); break; case StyledPanel: style()->drawPrimitive(QStyle::PE_Frame, &opt, p, this); break; case Panel: if (frameShadow == Plain) qDrawPlainRect(p, opt.rect, opt.palette.foreground().color(), lw); else qDrawShadePanel(p, opt.rect, opt.palette, frameShadow == Sunken, lw); break; case WinPanel: if (frameShadow == Plain) qDrawPlainRect(p, opt.rect, opt.palette.foreground().color(), lw); else qDrawWinPanel(p, opt.rect, opt.palette, frameShadow == Sunken); break; case HLine: case VLine: if (frameShape == HLine) { p1 = QPoint(opt.rect.x(), opt.rect.height() / 2); p2 = QPoint(opt.rect.x() + opt.rect.width(), p1.y()); } else { p1 = QPoint(opt.rect.x()+opt.rect.width() / 2, 0); p2 = QPoint(p1.x(), opt.rect.height()); } if (frameShadow == Plain) { QPen oldPen = p->pen(); p->setPen(QPen(opt.palette.foreground().color(), lw)); p->drawLine(p1, p2); p->setPen(oldPen); } else { qDrawShadeLine(p, p1, p2, opt.palette, frameShadow == Sunken, lw, mlw); } break; } #ifdef QT_KEYPAD_NAVIGATION if (QApplication::keypadNavigationEnabled() && hasFocus()) { QStyleOptionFocusRect fopt; fopt.init(this); fopt.state |= QStyle::State_KeyboardFocusChange; fopt.rect = frameRect(); style()->drawPrimitive(QStyle::PE_FrameFocusRect, &fopt, p, this); } #endif }
void QWindowsStyle::drawSplitter( QPainter *p, int x, int y, int w, int h, const QColorGroup &g, Orientation) { qDrawWinPanel( p, x, y, w, h, g ); }
void QWSDefaultDecoration::paint(QPainter *painter, const QWidget *widget) { #ifndef QT_NO_STYLE QStyle &style = QApplication::style(); #endif int titleWidth = getTitleWidth(widget); int titleHeight = getTitleHeight(widget); QRect rect(widget->rect()); // Border rect QRect br( rect.left() - BORDER_WIDTH, rect.top() - BORDER_WIDTH - titleHeight, rect.width() + 2 * BORDER_WIDTH, rect.height() + BORDER_WIDTH + BOTTOM_BORDER_WIDTH + titleHeight ); // title bar rect QRect tr; { tr = QRect( titleHeight, -titleHeight, titleWidth, titleHeight - 1); } QRegion oldClip = painter->clipRegion(); painter->setClipRegion( oldClip - QRegion( tr ) ); // reduce flicker #ifndef QT_NO_PALETTE // const QColorGroup &cg = QApplication::palette().active(); const QColorGroup &cg = widget->palette().active(); #if !defined(QT_NO_STYLE) style.drawPanel(painter, br.x(), br.y(), br.width(), br.height() - 4, cg, FALSE, 2, &cg.brush(QColorGroup::Background)); #elif !defined(QT_NO_DRAWUTIL) qDrawWinPanel(painter, br.x(), br.y(), br.width(), br.height() - 4, cg, FALSE, &cg.brush(QColorGroup::Background)); #endif painter->setClipRegion( oldClip ); if (titleWidth > 0) { QBrush titleBrush; QPen titlePen; int titleLeft = titleHeight + 4; if (widget == qApp->activeWindow()) { titleBrush = cg.brush(QColorGroup::Highlight); titlePen = cg.color(QColorGroup::HighlightedText); } else { titleBrush = cg.brush(QColorGroup::Background); titlePen = cg.color(QColorGroup::Text); } #define CLAMP(x, y) ( ((x) > (y)) ? (y) : (x) ) { #if !defined(QT_NO_STYLE) style.drawPanel(painter, tr.x(), tr.y(), tr.width(), tr.height(), cg, TRUE, 1, &titleBrush); #elif !defined(QT_NO_DRAWUTIL) qDrawWinPanel(painter, tr.x(), tr.y(), tr.width(), tr.height(), cg, TRUE, &titleBrush); #endif painter->setPen(titlePen); painter->setFont(widget->font()); painter->drawText( titleLeft, -titleHeight, titleWidth-5, titleHeight - 1, QPainter::AlignVCenter, widget->caption()); return; } painter->setPen(titlePen); painter->setFont(widget->font()); painter->drawText( titleLeft, -titleHeight, rect.width() - titleHeight - 10, titleHeight-1, QPainter::AlignVCenter, widget->caption()); } #endif //QT_NO_PALETTE }
void qDrawWinPanel( QPainter *p, const QRect &r, const QColorGroup &g, bool sunken, const QBrush *fill ) { qDrawWinPanel( p, r.x(), r.y(), r.width(), r.height(), g, sunken, fill ); }
/*! Paints the border and title decoration for the top-level \a widget using the \a painter provided and the decoration \a state. The value of \a decorationRegion is a combination of the bitmask values of enum DecorationRegion. Note that Qt for Embedded Linux expects this function to return true if any of the widget's decorations are repainted; otherwise it returns false. */ bool QDecorationDefault::paint(QPainter *painter, const QWidget *widget, int decorationRegion, DecorationState state) { if (decorationRegion == None) return false; const QRect titleRect = QDecoration::region(widget, Title).boundingRect(); const QPalette pal = QApplication::palette(); int titleHeight = titleRect.height(); int titleWidth = titleRect.width(); QRegion oldClipRegion = painter->clipRegion(); Qt::WindowFlags flags = widget->windowFlags(); bool hasBorder = !widget->isMaximized(); bool hasTitle = flags & Qt::WindowTitleHint; bool hasSysMenu = flags & Qt::WindowSystemMenuHint; bool hasContextHelp = flags & Qt::WindowContextHelpButtonHint; bool hasMinimize = flags & Qt::WindowMinimizeButtonHint; bool hasMaximize = flags & Qt::WindowMaximizeButtonHint; bool paintAll = (decorationRegion == int(All)); bool handled = false; bool porterDuff = painter->paintEngine()->hasFeature(QPaintEngine::PorterDuff); if ((paintAll || decorationRegion & Borders) && state == Normal && hasBorder) { if (hasTitle) { // reduce flicker QRect rect(widget->rect()); QRect r(rect.left(), rect.top() - titleHeight, rect.width(), titleHeight); painter->setClipRegion(oldClipRegion - r); } QRect br = QDecoration::region(widget).boundingRect(); if (porterDuff) painter->setCompositionMode(QPainter::CompositionMode_Source); qDrawWinPanel(painter, br.x(), br.y(), br.width(), br.height(), pal, false, &pal.brush(QPalette::Window)); if (porterDuff) painter->setCompositionMode(QPainter::CompositionMode_SourceOver); handled |= true; } if ((paintAll || decorationRegion & Title && titleWidth > 0) && state == Normal && hasTitle) { painter->setClipRegion(oldClipRegion); QBrush titleBrush; QPen titlePen; if (widget == qApp->activeWindow()) { titleBrush = pal.brush(QPalette::Highlight); titlePen = pal.color(QPalette::HighlightedText); } else { titleBrush = pal.brush(QPalette::Window); titlePen = pal.color(QPalette::Text); } if (porterDuff) painter->setCompositionMode(QPainter::CompositionMode_Source); qDrawShadePanel(painter, titleRect.x(), titleRect.y(), titleRect.width(), titleRect.height(), pal, true, 1, &titleBrush); if (porterDuff) painter->setCompositionMode(QPainter::CompositionMode_SourceOver); painter->setPen(titlePen); painter->drawText(titleRect.x() + 4, titleRect.y(), titleRect.width() - 8, titleRect.height(), Qt::AlignVCenter, windowTitleFor(widget)); handled |= true; } if (state != Hover) { painter->setClipRegion(oldClipRegion); if ((paintAll || decorationRegion & Menu) && hasSysMenu) { paintButton(painter, widget, Menu, state, pal); handled |= true; } if ((paintAll || decorationRegion & Help) && hasContextHelp) { paintButton(painter, widget, Help, state, pal); handled |= true; } if ((paintAll || decorationRegion & Minimize) && hasMinimize) { paintButton(painter, widget, Minimize, state, pal); handled |= true; } if ((paintAll || decorationRegion & Maximize) && hasMaximize) { paintButton(painter, widget, ((widget->windowState() & Qt::WindowMaximized)? Normalize : Maximize), state, pal); handled |= true; } if (paintAll || decorationRegion & Close) { paintButton(painter, widget, Close, state, pal); handled |= true; } } return handled; }
/*!\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 }
void qDrawWinPanel(QPainter *p, const QRect &r, const QPalette &pal, bool sunken, const QBrush *fill) { qDrawWinPanel(p, r.x(), r.y(), r.width(), r.height(), pal, sunken, fill); }
void QFrame::drawFrame( QPainter *p ) { QPoint p1, p2; QRect r = frameRect(); int type = fstyle & MShape; int cstyle = fstyle & MShadow; #ifdef QT_NO_DRAWUTIL p->setPen( black ); // #### p->drawRect( r ); //### a bit too simple #else const QColorGroup & g = colorGroup(); switch ( type ) { case Box: if ( cstyle == Plain ) qDrawPlainRect( p, r, g.foreground(), lwidth ); else qDrawShadeRect( p, r, g, cstyle == Sunken, lwidth, midLineWidth() ); break; case StyledPanel: #ifndef QT_NO_STYLE if ( cstyle == Plain ) qDrawPlainRect( p, r, g.foreground(), lwidth ); else style().drawPanel( p, r.x(), r.y(), r.width(), r.height(), g, cstyle == Sunken, lwidth ); break; #endif // fall through to Panel if QT_NO_STYLE case PopupPanel: #ifndef QT_NO_STYLE if ( cstyle == Plain ) qDrawPlainRect( p, r, g.foreground(), lwidth ); else style().drawPopupPanel( p, r.x(), r.y(), r.width(), r.height(), g, lwidth ); break; #endif // fall through to Panel if QT_NO_STYLE case Panel: if ( cstyle == Plain ) qDrawPlainRect( p, r, g.foreground(), lwidth ); else qDrawShadePanel( p, r, g, cstyle == Sunken, lwidth ); break; case WinPanel: if ( cstyle == Plain ) qDrawPlainRect( p, r, g.foreground(), wpwidth ); else qDrawWinPanel( p, r, g, cstyle == Sunken ); break; case HLine: case VLine: if ( type == HLine ) { p1 = QPoint( r.x(), r.height()/2 ); p2 = QPoint( r.x()+r.width(), p1.y() ); } else { p1 = QPoint( r.x()+r.width()/2, 0 ); p2 = QPoint( p1.x(), r.height() ); } if ( cstyle == Plain ) { QPen oldPen = p->pen(); p->setPen( QPen(g.foreground(),lwidth) ); p->drawLine( p1, p2 ); p->setPen( oldPen ); } else qDrawShadeLine( p, p1, p2, g, cstyle == Sunken, lwidth, midLineWidth() ); break; } #endif // QT_NO_DRAWUTIL }
/*! Draw a rectangular frame \param painter Painter \param rect Frame rectangle \param palette Palette \param foregroundRole Foreground role used for QFrame::Plain \param frameWidth Frame width \param midLineWidth Used for QFrame::Box \param frameStyle bitwise OR´ed value of QFrame::Shape and QFrame::Shadow */ void QwtPainter::drawFrame( QPainter *painter, const QRectF &rect, const QPalette &palette, QPalette::ColorRole foregroundRole, int frameWidth, int midLineWidth, int frameStyle ) { if ( frameWidth <= 0 || rect.isEmpty() ) return; const int shadow = frameStyle & QFrame::Shadow_Mask; painter->save(); if ( shadow == QFrame::Plain ) { const QRectF outerRect = rect.adjusted( 0.0, 0.0, -1.0, -1.0 ); const QRectF innerRect = outerRect.adjusted( frameWidth, frameWidth, -frameWidth, -frameWidth ); QPainterPath path; path.addRect( outerRect ); path.addRect( innerRect ); painter->setPen( Qt::NoPen ); painter->setBrush( palette.color( foregroundRole ) ); painter->drawPath( path ); } else { const int shape = frameStyle & QFrame::Shape_Mask; if ( shape == QFrame::Box ) { const QRectF outerRect = rect.adjusted( 0.0, 0.0, -1.0, -1.0 ); const QRectF midRect1 = outerRect.adjusted( frameWidth, frameWidth, -frameWidth, -frameWidth ); const QRectF midRect2 = midRect1.adjusted( midLineWidth, midLineWidth, -midLineWidth, -midLineWidth ); const QRectF innerRect = midRect2.adjusted( frameWidth, frameWidth, -frameWidth, -frameWidth ); QPainterPath path1; path1.moveTo( outerRect.bottomLeft() ); path1.lineTo( outerRect.topLeft() ); path1.lineTo( outerRect.topRight() ); path1.lineTo( midRect1.topRight() ); path1.lineTo( midRect1.topLeft() ); path1.lineTo( midRect1.bottomLeft() ); QPainterPath path2; path2.moveTo( outerRect.bottomLeft() ); path2.lineTo( outerRect.bottomRight() ); path2.lineTo( outerRect.topRight() ); path2.lineTo( midRect1.topRight() ); path2.lineTo( midRect1.bottomRight() ); path2.lineTo( midRect1.bottomLeft() ); QPainterPath path3; path3.moveTo( midRect2.bottomLeft() ); path3.lineTo( midRect2.topLeft() ); path3.lineTo( midRect2.topRight() ); path3.lineTo( innerRect.topRight() ); path3.lineTo( innerRect.topLeft() ); path3.lineTo( innerRect.bottomLeft() ); QPainterPath path4; path4.moveTo( midRect2.bottomLeft() ); path4.lineTo( midRect2.bottomRight() ); path4.lineTo( midRect2.topRight() ); path4.lineTo( innerRect.topRight() ); path4.lineTo( innerRect.bottomRight() ); path4.lineTo( innerRect.bottomLeft() ); QPainterPath path5; path5.addRect( midRect1 ); path5.addRect( midRect2 ); painter->setPen( Qt::NoPen ); QBrush brush1 = palette.dark().color(); QBrush brush2 = palette.light().color(); if ( shadow == QFrame::Raised ) qSwap( brush1, brush2 ); painter->setBrush( brush1 ); painter->drawPath( path1 ); painter->drawPath( path4 ); painter->setBrush( brush2 ); painter->drawPath( path2 ); painter->drawPath( path3 ); painter->setBrush( palette.mid() ); painter->drawPath( path5 ); } #if 0 // qDrawWinPanel doesn't result in something nice // on a scalable document like PDF. Better draw a // Panel. else if ( shape == QFrame::WinPanel ) { painter->setRenderHint( QPainter::NonCosmeticDefaultPen, true ); qDrawWinPanel ( painter, rect.toRect(), palette, frameStyle & QFrame::Sunken ); } else if ( shape == QFrame::StyledPanel ) { } #endif else { const QRectF outerRect = rect.adjusted( 0.0, 0.0, -1.0, -1.0 ); const QRectF innerRect = outerRect.adjusted( frameWidth - 1.0, frameWidth - 1.0, -( frameWidth - 1.0 ), -( frameWidth - 1.0 ) ); QPainterPath path1; path1.moveTo( outerRect.bottomLeft() ); path1.lineTo( outerRect.topLeft() ); path1.lineTo( outerRect.topRight() ); path1.lineTo( innerRect.topRight() ); path1.lineTo( innerRect.topLeft() ); path1.lineTo( innerRect.bottomLeft() ); QPainterPath path2; path2.moveTo( outerRect.bottomLeft() ); path2.lineTo( outerRect.bottomRight() ); path2.lineTo( outerRect.topRight() ); path2.lineTo( innerRect.topRight() ); path2.lineTo( innerRect.bottomRight() ); path2.lineTo( innerRect.bottomLeft() ); painter->setPen( Qt::NoPen ); QBrush brush1 = palette.dark().color(); QBrush brush2 = palette.light().color(); if ( shadow == QFrame::Raised ) qSwap( brush1, brush2 ); painter->setBrush( brush1 ); painter->drawPath( path1 ); painter->setBrush( brush2 ); painter->drawPath( path2 ); } } painter->restore(); }
void QWSWindowsDecoration::paint(QPainter *painter, const QWidget *widget) { int titleWidth = getTitleWidth(widget); int titleHeight = getTitleHeight(widget); QRect rect(widget->rect()); // Border rect QRect br( rect.left() - BORDER_WIDTH, rect.top() - BORDER_WIDTH - titleHeight, rect.width() + 2 * BORDER_WIDTH, rect.height() + BORDER_WIDTH + BOTTOM_BORDER_WIDTH + titleHeight ); // title bar rect QRect tr( 0, -titleHeight, titleWidth - 1, titleHeight - 1); QRegion oldClip = painter->clipRegion(); painter->setClipRegion( oldClip - QRegion( tr ) ); // reduce flicker #ifndef QT_NO_PALETTE const QColorGroup &cg = QApplication::palette().active(); // const QColorGroup &cg = widget->palette().active(); #if !defined(QT_NO_DRAWUTIL) qDrawWinPanel(painter, br.x(), br.y(), br.width(), br.height() - 4, cg, FALSE, &cg.brush(QColorGroup::Background)); #endif painter->setClipRegion( oldClip ); if (titleWidth > 0) { QBrush titleBrush; QPen titlePen; int titleLeft = titleHeight + 4; if (widget == qApp->activeWindow()) { titleBrush = cg.brush(QColorGroup::Highlight); titlePen = cg.color(QColorGroup::HighlightedText); } else { titleBrush = cg.brush(QColorGroup::Background); titlePen = cg.color(QColorGroup::Text); } #define CLAMP(x, y) ( ((x) > (y)) ? (y) : (x) ) int x = tr.x(); QColor c1 = titleBrush.color(); QColor c2 = titleBrush.color(); if (widget == qApp->activeWindow()) { c1 = QColor( 0x10, 0x20, 0x90 ); // '98 Blue // c2 = QColor( 0x50, 0x60, 0xD0 ); c2 = QColor( 0x70, 0x70, 0x70 ); // c1 = QColor( 0xBA, 0xC4, 0x05 ); // Trolltech Green // c1 = QColor( 0xAA, 0xB4, 0x00 ); // Trolltech Green // c2 = QColor( 0x20, 0x20, 0x20 ); } else { c1 = QColor( 0x20, 0x30, 0x50 ); // c2 = QColor( 0x60, 0x70, 0x90 ); // c2 = QColor( 0x40, 0x40, 0x40 ); c2 = QColor( 0x70, 0x70, 0x70 ); titlePen = QPen( QColor( 0x90, 0x90, 0x90 ) ); } int r = c1.red(); int g = c1.green(); int b = c1.blue(); for (int i = 0; i < 100; i++) { int dr = r + (c2.red() * i) / 100; int dg = g + (c2.green() * i) / 100; int db = b + (c2.blue() * i) / 100; x = tr.x() + (tr.width() * i) / 100; int x2 = tr.x() + (tr.width() * (i + 1)) / 100; QBrush tbr = QBrush( QColor( CLAMP(dr,255), CLAMP(dg,255), CLAMP(db,255) ) ); painter->fillRect( x, tr.y(), x2 - x, tr.height(), tbr); } #ifndef QT_NO_WIDGET_TOPEXTRA painter->setPen(titlePen); painter->setFont(widget->font()); painter->drawText( titleLeft, -titleHeight, rect.width() - titleHeight - 10, titleHeight-1, QPainter::AlignVCenter, widget->caption()); #endif } #endif //QT_NO_PALETTE }