26 #include <QPaintEvent>
27 #include <QResizeEvent>
28 #include <QMouseEvent>
39 setObjectName(
"panningWidget" );
40 setMinimumSize( 5, 5 );
41 setAttribute( Qt::WA_NoSystemBackground );
47 QRegion reg( 0, 0, s.width(), s.height() );
48 QRegion reg2( 2, 2, s.width() - 4, s.height() - 4 );
49 QRegion reg3 = reg.subtract( reg2 );
56 QRect r( QPoint( 0, 0 ), size() );
60 p.setBrush( Qt::red );
70 : QWidget( parent ), mMapCanvas( mapCanvas )
72 setObjectName(
"theOverviewCanvas" );
101 QPainter paint(
this );
102 paint.drawPixmap( pe->rect().topLeft(),
mPixmap, pe->rect() );
130 if ( ur.x() >= 0 && ur.x() < width() ) show =
true;
131 if ( ll.x() >= 0 && ll.x() < width() ) show =
true;
132 if ( ur.y() >= 0 && ur.y() < height() ) show =
true;
133 if ( ll.y() >= 0 && ll.y() < height() ) show =
true;
136 QgsDebugMsg(
"panning: extent out of overview area" );
143 int x1 =
static_cast<int>( ur.x() + 0.5 ), x2 = static_cast<int>( ll.x() + 0.5 );
144 int y1 =
static_cast<int>( ur.y() + 0.5 ), y2 = static_cast<int>( ll.y() + 0.5 );
156 if ( x1 == INT_MIN && x2 == INT_MAX ) x1 += 1;
157 if ( y1 == INT_MIN && y2 == INT_MAX ) y1 += 1;
160 QRect r( x1, y1, x2 - x1 + 1, y2 - y1 + 1 );
163 if ( r.width() < 5 && x1 > INT_MIN + 2 )
165 r.setX( r.x() - (( 5 - r.width() ) / 2 ) );
168 if ( r.height() < 5 && y1 > INT_MIN + 2 )
170 r.setY( r.y() - (( 5 - r.height() ) / 2 ) );
174 QgsDebugMsg( QString(
"panning: extent to widget: [%1,%2] [%3x%4]" ).arg( x1 ).arg( y1 ).arg( r.width() ).arg( r.height() ) );
207 if ( e->button() == Qt::LeftButton )
221 QgsDebugMsg( QString(
"panning: new position: [%1,%2] [%3x%4]" ).arg( rect.left() ).arg( rect.top() ).arg( rect.width() ).arg( rect.height() ) );
232 if (( e->buttons() & Qt::LeftButton ) == Qt::LeftButton )
259 painter.setRenderHint( QPainter::Antialiasing );
280 palette.setColor( backgroundRole(), color );
281 setPalette( palette );