Esempio n. 1
0
	void execute()
	{
		Allocation rect;
		getAllocation( rect );
		try
		{
			Allocation a = d_model->getAllocation();
			Viewport* v = getHandler()->getViewport();
			assert( v );
			Viewport::pushCursor( Viewport::CurWait );
			if( rect.getWidth() != 0 && rect.getHeight() != 0 )
			{
				v->captureDamage();

				PpmRange rx, ry;
				rx.first = d_model->toPpm( rect.getLeft(), a.getLeft(), DimX );
				rx.second = d_model->toPpm( rect.getRight(), a.getLeft(), DimX );
				ry.first = d_model->toPpm( rect.getTop(), a.getTop(), DimY );
				ry.second = d_model->toPpm( rect.getBottom(), a.getTop(), DimY );
				d_target->setRange( rx, ry );
				v->commitDamage();
			}else
			{
				d_target->centerPoint( d_model->toPpm( rect.getLeft(), a.getLeft(), DimX ),
					d_model->toPpm( rect.getTop(), a.getTop(), DimY ) );
			}
			v->damageAll();
			Viewport::popCursor();
		}catch( ... )
		{
			qDebug( "Exception in _OverviewCmd" );
		}
		Command::execute();
	}
Esempio n. 2
0
bool ScrollCtrl::handleMouseRelease( MouseEvent& e) 
{
	Viewport* v = getViewport();
	if( v->isGrabbing( this ) && d_immediate )
	{
		v->ungrab();
		Viewport::popCursor();
		return true;
	}else if( v->isGrabbing( this ) && !d_immediate )
	{
		v->ungrab();
		Viewport::popCursor();
		Viewport::pushCursor( Viewport::CurWait );
		if( d_do[ DimY ] && d_area->inUse( DimY ) && d_do[ DimX ] && d_area->inUse( DimX ) )
		{
			PpmRange rx = d_area->getRange( DimX );
			PpmRange ry = d_area->getRange( DimY );

			rx.move( rx.getSign() * -PPM( e.getX() - d_lastX ) / 
				d_area->getTwipPerPpm( DimX ) );
			ry.move( ry.getSign() * -PPM( e.getY() - d_lastY ) / 
				d_area->getTwipPerPpm( DimY ) );

			d_area->setRange( rx, ry );
		}else if( d_do[ DimY ] && d_area->inUse( DimY ) )
		{
			PpmRange r = d_area->getRange( DimY );
			r.move( -PPM( e.getY() - d_lastY ) / 
				d_area->getTwipPerPpm( DimY ) * r.getSign() );
			d_area->setRange( DimY, r );
		}else if( d_do[ DimX ] && d_area->inUse( DimX ) )
		{
			PpmRange r = d_area->getRange( DimX );
			r.move( -PPM( e.getX() - d_lastX ) / 
				d_area->getTwipPerPpm( DimX ) * r.getSign() );
			d_area->setRange( DimX, r );
		}
		v->damageAll();
		Viewport::popCursor();
		return true;
	}else
		return false;
}
Esempio n. 3
0
bool ScrollCtrl::handleMouseDrag( DragEvent& e ) 
{ 
	Viewport* v = getViewport();
	if( v->isGrabbing( this ) && d_immediate )
	{
		if( d_do[ DimY ] && d_area->inUse( DimY ) )
		{
			PpmRange r = d_area->getRange( DimY );
			r.move( -PPM( e.getDeltaY() ) / d_area->getTwipPerPpm( DimY ) * r.getSign() );
			d_area->setRange( DimY, r );
		}
		if( d_do[ DimX ] && d_area->inUse( DimX ) )
		{
			PpmRange r = d_area->getRange( DimX );
			r.move( -PPM( e.getDeltaX() ) / d_area->getTwipPerPpm( DimX ) * r.getSign() );
			d_area->setRange( DimX, r );
		}
		v->damageAll();
		return true;
	}else if( v->isGrabbing( this ) && !d_immediate )
		return true;
	else
		return false;
}