25 #include <QPaintEvent>
26 #include <QResizeEvent>
27 #include <QMouseEvent>
38 setObjectName(
"panningWidget" );
39 setMinimumSize( 5, 5 );
40 setAttribute( Qt::WA_NoSystemBackground );
46 QRegion reg( 0, 0, s.width(), s.height() );
47 QRegion reg2( 2, 2, s.width() - 4, s.height() - 4 );
48 QRegion reg3 = reg.subtract( reg2 );
57 QRect r( QPoint( 0, 0 ),
size() );
61 p.setBrush( Qt::red );
71 : QWidget( parent ), mMapCanvas( mapCanvas )
73 setObjectName(
"theOverviewCanvas" );
103 QPainter paint(
this );
104 paint.drawPixmap( pe->rect().topLeft(),
mPixmap, pe->rect() );
134 if ( ur.x() >= 0 && ur.x() < width() )
136 if ( ll.x() >= 0 && ll.x() < width() )
138 if ( ur.y() >= 0 && ur.y() < height() )
140 if ( ll.y() >= 0 && ll.y() < height() )
144 QgsDebugMsg(
"panning: extent out of overview area" );
151 int x1 =
static_cast<int>( ur.x() + 0.5 ), x2 = static_cast<int>( ll.x() + 0.5 );
152 int y1 =
static_cast<int>( ur.y() + 0.5 ), y2 = static_cast<int>( ll.y() + 0.5 );
164 if ( x1 == INT_MIN && x2 == INT_MAX )
166 if ( y1 == INT_MIN && y2 == INT_MAX )
170 QRect r( x1, y1, x2 - x1 + 1, y2 - y1 + 1 );
173 if ( r.width() < 5 && x1 > INT_MIN + 2 )
175 r.setX( r.x() - (( 5 - r.width() ) / 2 ) );
178 if ( r.height() < 5 && y1 > INT_MIN + 2 )
180 r.setY( r.y() - (( 5 - r.height() ) / 2 ) );
184 QgsDebugMsg( QString(
"panning: extent to widget: [%1,%2] [%3x%4]" ).arg( x1 ).arg( y1 ).arg( r.width() ).arg( r.height() ) );
217 if ( e->button() == Qt::LeftButton )
231 QgsDebugMsg( QString(
"panning: new position: [%1,%2] [%3x%4]" ).arg( rect.left() ).arg( rect.top() ).arg( rect.width() ).arg( rect.height() ) );
242 if (( e->buttons() & Qt::LeftButton ) == Qt::LeftButton )
269 painter.setRenderHint( QPainter::Antialiasing );
290 palette.setColor( backgroundRole(), color );
291 setPalette( palette );
296 QgsDebugMsg(
"layerSet: " + layerSet.join(
", " ) );