diff --git a/kstyle/breeze.h b/kstyle/breeze.h index 1d1ff960..caea7b96 100644 --- a/kstyle/breeze.h +++ b/kstyle/breeze.h @@ -187,6 +187,15 @@ namespace Breeze ArrowRight }; + //! button type + enum ButtonType + { + ButtonClose, + ButtonMaximize, + ButtonMinimize, + ButtonRestore + }; + //! shadow area enum ShadowArea { diff --git a/kstyle/breezehelper.cpp b/kstyle/breezehelper.cpp index 747bf5e8..54891812 100644 --- a/kstyle/breezehelper.cpp +++ b/kstyle/breezehelper.cpp @@ -1037,7 +1037,6 @@ namespace Breeze } - //______________________________________________________________________________ void Helper::renderArrow( QPainter* painter, const QRect& rect, const QColor& color, ArrowOrientation orientation ) const { @@ -1064,6 +1063,107 @@ namespace Breeze return; } + //______________________________________________________________________________ + void Helper::renderButton( QPainter* painter, const QRect& rect, const QColor& color, ButtonType buttonType, bool inverted ) const + { + + painter->save(); + painter->setViewport( rect ); + painter->setWindow( 0, 0, 18, 18 ); + painter->setRenderHints( QPainter::Antialiasing ); + + // initialize pen + QPen pen; + pen.setCapStyle( Qt::RoundCap ); + pen.setJoinStyle( Qt::MiterJoin ); + + if( inverted ) + { + // render circle + painter->setPen( Qt::NoPen ); + painter->setBrush( color ); + painter->drawEllipse( QRectF( 0, 0, 18, 18 ) ); + + // take out the inner part + painter->setCompositionMode( QPainter::CompositionMode_SourceOut ); + pen.setColor( Qt::black ); + + } else { + + painter->setBrush( Qt::NoBrush ); + pen.setColor( color ); + + } + + switch( buttonType ) + { + case ButtonClose: + { + + // adjust pen and assign + const qreal penWidth( 1.8/2 ); + pen.setWidth( 2*penWidth ); + painter->setPen( pen ); + + // render + painter->drawLine( 5 + penWidth, 5 + penWidth, 13 - penWidth, 13 - penWidth ); + painter->drawLine( 13 - penWidth, 5 + penWidth, 5 + penWidth, 13 - penWidth ); + break; + + } + + case ButtonMaximize: + { + const qreal penWidth( 2.5/2 ); + pen.setWidth( 2*penWidth ); + painter->setPen( pen ); + + painter->drawPolyline( QPolygonF() + << QPointF( 3.5 + penWidth, 13.8 - penWidth ) + << QPointF( 9, 6 + penWidth ) + << QPointF( 14.5 - penWidth, 13.8 - penWidth ) ); + + break; + } + + case ButtonMinimize: + { + const qreal penWidth( 2.5/2 ); + pen.setWidth( 2*penWidth ); + painter->setPen( pen ); + + painter->drawPolyline( QPolygonF() + << QPointF( 3.5 + penWidth, 6 + penWidth ) + << QPointF( 9, 13.8 - penWidth ) + << QPointF( 14.5 - penWidth, 6 + penWidth ) ); + + break; + } + + case ButtonRestore: + { + + const qreal penWidth( 2.5/2 ); + pen.setWidth( 2*penWidth ); + pen.setJoinStyle( Qt::RoundJoin ); + painter->setPen( pen ); + + painter->drawPolygon( QPolygonF() + << QPointF( 3.25 + penWidth, 9 ) + << QPointF( 9, 3.25 + penWidth ) + << QPointF( 14.75 - penWidth, 9 ) + << QPointF( 9, 14.75 - penWidth ) ); + + break; + } + + default: break; + } + + painter->restore(); + + } + //______________________________________________________________________________ QPainterPath Helper::roundedPath( const QRectF& rect, qreal radius, Corners corners ) const { diff --git a/kstyle/breezehelper.h b/kstyle/breezehelper.h index db57e975..de2405ba 100644 --- a/kstyle/breezehelper.h +++ b/kstyle/breezehelper.h @@ -191,6 +191,9 @@ namespace Breeze //! generic arrow void renderArrow( QPainter*, const QRect&, const QColor&, ArrowOrientation ) const; + //! generic button (for mdi decorations, tabs and dock widgets) + void renderButton( QPainter*, const QRect&, const QColor&, ButtonType, bool inverted ) const; + //@} //!@name compositing utilities