18 #include <qstyleoption.h>
20 #include <qpainterpath.h>
24 #if QT_VERSION >= 0x050000
28 const QRect r( 0, 0,
size.width(),
size.height() );
30 QPainterPath borderPath;
32 (
void )QMetaObject::invokeMethod(
33 const_cast< QWidget*
>( canvas ),
"borderPath", Qt::DirectConnection,
34 Q_RETURN_ARG( QPainterPath, borderPath ), Q_ARG( QRect, r ) );
36 if ( borderPath.isEmpty() )
38 if ( canvas->contentsRect() == canvas->rect() )
41 #if QT_VERSION >= 0x050000
42 QBitmap mask(
size* pixelRatio );
43 mask.setDevicePixelRatio( pixelRatio );
47 mask.fill( Qt::color0 );
49 QPainter painter( &mask );
50 painter.fillRect( canvas->contentsRect(), Qt::color1 );
55 #if QT_VERSION >= 0x050000
56 QImage image(
size* pixelRatio, QImage::Format_ARGB32_Premultiplied );
57 image.setDevicePixelRatio( pixelRatio );
59 QImage image(
size, QImage::Format_ARGB32_Premultiplied );
61 image.fill( Qt::color0 );
63 QPainter painter( &image );
64 painter.setClipPath( borderPath );
65 painter.fillRect( r, Qt::color1 );
69 painter.setCompositionMode( QPainter::CompositionMode_DestinationOut );
71 if ( canvas->testAttribute(Qt::WA_StyledBackground ) )
73 QStyleOptionFrame opt;
76 canvas->style()->drawPrimitive( QStyle::PE_Frame, &opt, &painter, canvas );
80 const QVariant borderRadius = canvas->property(
"borderRadius" );
81 const QVariant frameWidth = canvas->property(
"frameWidth" );
83 if ( borderRadius.canConvert<
double >() && frameWidth.canConvert<
int >() )
85 const double br = borderRadius.value<
double >();
86 const int fw = frameWidth.value<
int >();
88 if ( br > 0.0 && fw > 0 )
90 painter.setPen( QPen( Qt::color1, fw ) );
91 painter.setBrush( Qt::NoBrush );
92 painter.setRenderHint( QPainter::Antialiasing,
true );
94 painter.drawPath( borderPath );
101 const QImage mask = image.createMaskFromColor(
102 QColor( Qt::color1 ).rgb(), Qt::MaskOutColor );
104 return QBitmap::fromImage( mask );
133 connect(
this, SIGNAL(
panned(
int,
int)),
179 return parentWidget();
185 return parentWidget();
193 w = w->parentWidget();
195 return qobject_cast< QwtPlot* >( w );
201 const QWidget* w =
canvas();
203 w = w->parentWidget();
205 return qobject_cast< const QwtPlot* >( w );
218 if ( dx == 0 && dy == 0 )
244 d1 =
map.invTransform( p1 - dx );
245 d2 =
map.invTransform( p2 - dx );
249 d1 =
map.invTransform( p1 - dy );
250 d2 =
map.invTransform( p2 - dy );
280 const QWidget* cv =
canvas();
281 if ( cv && cv->inherits(
"QGLWidget" ) )
285 QPixmap pm( cv->size() );
288 QPainter painter( &pm );
289 const_cast< QwtPlot*
>(
plot() )->drawCanvas( &painter );
298 #include "moc_qwt_plot_panner.cpp"