Newer
Older
\param painter Painter
*/
void QwtPlotCanvas::drawFocusIndicator( QPainter *painter )
{
const int margin = 1;
QRect focusRect = contentsRect();
focusRect.setRect( focusRect.x() + margin, focusRect.y() + margin,
focusRect.width() - 2 * margin, focusRect.height() - 2 * margin );
QwtPainter::drawFocusRect( painter, this, focusRect );
}
/*!
Invalidate the paint cache and repaint the canvas
\sa invalidatePaintCache()
*/
void QwtPlotCanvas::replot()
{
invalidateBackingStore();
if ( testPaintAttribute( QwtPlotCanvas::ImmediatePaint ) )
repaint( contentsRect() );
else
update( contentsRect() );
}
//! Update the cached information about the current style sheet
void QwtPlotCanvas::updateStyleSheetInfo()
{
if ( !testAttribute(Qt::WA_StyledBackground ) )
return;
QwtStyleSheetRecorder recorder( size() );
QPainter painter( &recorder );
QStyleOption opt;
opt.initFrom(this);
style()->drawPrimitive( QStyle::PE_Widget, &opt, &painter, this);
painter.end();
d_data->styleSheet.hasBorder = !recorder.border.rectList.isEmpty();
d_data->styleSheet.cornerRects = recorder.clipRects;
if ( recorder.background.path.isEmpty() )
{
if ( !recorder.border.rectList.isEmpty() )
{
d_data->styleSheet.borderPath =
qwtCombinePathList( rect(), recorder.border.pathList );
}
else
{
d_data->styleSheet.borderPath = recorder.background.path;
d_data->styleSheet.background.brush = recorder.background.brush;
d_data->styleSheet.background.origin = recorder.background.origin;
/*!
Calculate the painter path for a styled or rounded border
When the canvas has no styled background or rounded borders
the painter path is empty.
\param rect Bounding rectangle of the canvas
\return Painter path, that can be used for clipping
*/
QPainterPath QwtPlotCanvas::borderPath( const QRect &rect ) const
if ( testAttribute(Qt::WA_StyledBackground ) )
{
QwtStyleSheetRecorder recorder( rect.size() );
QStyleOption opt;
opt.initFrom(this);
opt.rect = rect;
style()->drawPrimitive( QStyle::PE_Widget, &opt, &painter, this);
painter.end();
if ( !recorder.background.path.isEmpty() )
return recorder.background.path;
if ( !recorder.border.rectList.isEmpty() )
return qwtCombinePathList( rect, recorder.border.pathList );
else if ( d_data->borderRadius > 0.0 )
{
double fw2 = frameWidth() * 0.5;
QRectF r = QRectF(rect).adjusted( fw2, fw2, -fw2, -fw2 );
QPainterPath path;
path.addRoundedRect( r, d_data->borderRadius, d_data->borderRadius );
return path;
}
return QPainterPath();