added methods to render buttons directly in helper

wilder-pre-rebase
Hugo Pereira Da Costa 12 years ago
parent 8b951d0131
commit f744611c02
  1. 9
      kstyle/breeze.h
  2. 102
      kstyle/breezehelper.cpp
  3. 3
      kstyle/breezehelper.h

@ -187,6 +187,15 @@ namespace Breeze
ArrowRight
};
//! button type
enum ButtonType
{
ButtonClose,
ButtonMaximize,
ButtonMinimize,
ButtonRestore
};
//! shadow area
enum ShadowArea
{

@ -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
{

@ -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

Loading…
Cancel
Save