Esempio n. 1
0
void ScrollCtrl::pageView(KeyEvent & e, const Allocation& a )
{
	PPM delta = 0;
	Dimension dim = 0;
	if( e.isPageUp() && e.isPlainKey() )
	{
		dim = DimY;
		delta = -PPM( a.getHeight() ) * g_page / d_area->getTwipPerPpm( dim );
	}else if( e.isPageDown() && e.isPlainKey() )
	{
		dim = DimY;
		delta = PPM( a.getHeight() ) * g_page / d_area->getTwipPerPpm( dim );
	}else if( e.isPageUp() && e.isCtrl() )
	{
		dim = DimX;
		delta = -PPM( a.getWidth() ) * g_page / d_area->getTwipPerPpm( dim );
	}else if( e.isPageDown() && e.isCtrl() )
	{
		dim = DimX;
		delta = PPM( a.getWidth() ) * g_page / d_area->getTwipPerPpm( dim );
	}
	if( d_do[ dim ] && d_area->inUse( dim ) )
	{
		PpmRange r = d_area->getRange( dim );
		r.move( delta * r.getSign() );
		d_area->setRange( dim, r );
		getViewport()->damageAll();
	}
}
Esempio n. 2
0
	void draw(Canvas & c, const Allocation & a)
	{
		Lexi::Twips x = a.getLeft() + a.getWidth() / 10;
		c.drawLine( x, a.getTop(), x, a.getBottom(), g_color );	
		Lexi::Twips y = a.getTop() + a.getHeight() / 10;
		c.drawLine( x, y, a.getRight(), y, g_color );	
	}
Esempio n. 3
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. 4
0
	void update( const Allocation& a, Lexi::Twips w, Lexi::Twips h, bool all, bool shift )
	{
		if( d_dim == DimX || d_dim == DimUndefined )
			d_phi = double( w ) * 360.0 * ( (shift)?3.0:1.0 ) / 
				double( a.getWidth() ) + d_phi;
		if( d_dim == DimY || d_dim == DimUndefined )
			d_psi = double( h ) * 360.0 * ( (shift)?3.0:1.0 ) / 
				double( a.getHeight() ) + d_psi;
		d_agent->setPhiPsi( d_phi, d_psi, all );
	}
Esempio n. 5
0
void Border::invalidate(Viewport & v, const Allocation & a)
{
    Twips t = a.getTop();
    Twips l = a.getLeft();
    Twips h = a.getHeight();
    Twips w = a.getWidth();
    Twips d = d_thickness;

	// Zeichne einen Rahmen um a herum nach innen ausdehnend um thickness.
    v.damage( Allocation( l, t, w, d ) ); // oben
    v.damage( Allocation( l, t, d, h ) ); // links
    v.damage( Allocation( l + w - d, t, d, h ) ); // rechts
    v.damage( Allocation( l, t + h - d, w, d ) ); // unten
}
Esempio n. 6
0
void SpecViewer::draw(Canvas & c, const Allocation & a)
{
	d_area->allocate( a );
	c.clip( a );	// RISK: clip
	Layer::draw( c, a );
	c.popClip();

	// Zeichne nun bei Bedarf das Fokusrechteck
    if( d_focus ) 
	{
		// NOTE: mit dieser Variante verschwindet right/bottom meist
		//		 Irgendwer macht Rundungsfehler, ev. Tile.
		c.drawRect( a.getLeft(), a.getTop(), a.getWidth() - s_off, 
			a.getHeight() - s_off, g_color ); 
    }
}
Esempio n. 7
0
	void execute()
	{
		Allocation rect;
		getAllocation( rect );
		if( rect.getWidth() != 0 && rect.getHeight() != 0 )
		{
			Allocation a = d_model->getAllocation();
			Viewport* p = getController()->getViewport();
			assert( p );
			p->pushCursor( Viewport::CurWait );
			p->captureDamage();
			if( d_do[ DimY ] && d_model->inUse( DimY ) && 
				d_do[ DimX ] && d_model->inUse( DimX )  )
			{
				PpmRange rx;
				rx.first = d_model->toPpm( rect.getLeft(), a.getLeft(), DimX );
				rx.second = d_model->toPpm( rect.getRight(), a.getLeft(), DimX );
				
				PpmRange ry;
				ry.first = d_model->toPpm( rect.getTop(), a.getTop(), DimY );
				ry.second = d_model->toPpm( rect.getBottom(), a.getTop(), DimY );

				d_model->setRange( rx, ry );

			}else if( d_do[ DimX ] && d_model->inUse( DimX ) )
			{
				PpmRange rx;
				rx.first = d_model->toPpm( rect.getLeft(), a.getLeft(), DimX );
				rx.second = d_model->toPpm( rect.getRight(), a.getLeft(), DimX );

				d_model->setRange( DimX, rx );

			}else if( d_do[ DimY ] && d_model->inUse( DimY ) )
			{
				PpmRange ry;
				ry.first = d_model->toPpm( rect.getTop(), a.getTop(), DimY );
				ry.second = d_model->toPpm( rect.getBottom(), a.getTop(), DimY );

				d_model->setRange( DimY, ry );

			}
			p->commitDamage();
			p->popCursor();
			d_model->redraw(p);
		}
		Command::execute();
	}
Esempio n. 8
0
	bool handleMousePress( Viewport& v, const Allocation& a, const MouseEvent& e )
	{
		if( e.isLeft() && d_agent->getCurDim() != -1 )
		{
			d_phi = d_agent->getPhi();
			d_psi = d_agent->getPsi();
			if( e.getX() < ( a.getLeft() + a.getWidth() / 10 ) )
				d_dim = DimY;
			else if( e.getY() < ( a.getTop() + a.getHeight() / 10 ) )
				d_dim = DimX;
			else
				d_dim = DimUndefined;
			v.grab( this );
			return true;
		}else
			return false;
	}
Esempio n. 9
0
void Border::draw( Canvas& v, const Allocation& a)  
{
	Canvas& c = v;
    Twips t = a.getTop();
    Twips l = a.getLeft();
    Twips h = a.getHeight();
    Twips w = a.getWidth();
    Twips d = d_thickness;

	// Zeichne einen Rahmen um a herum nach innen ausdehnend um thickness.
    c.fillRect( l, t, w, d, d_color ); // oben
    c.fillRect( l, t, d, h, d_color ); // links
    c.fillRect( l + w - d, t, d, h, d_color ); // rechts
    c.fillRect( l, t + h - d, w, d, d_color ); // unten

    Glyph* g = getBody();
    if( g != nil ) 
	{
	    Allocation interior( a );
	    allocateBody( g, d_thickness, interior );
	    g->draw( v, interior);
    }
}
Esempio n. 10
0
void SpecRuler2D::draw( Canvas& v, const Allocation& a)  
{
	if( d_model == 0 )
		return;
	assert( d_model->getDimCount() == 2 );
	Canvas& c = v;
    Twips t = a.getTop();
    Twips l = a.getLeft();
    Twips h = a.getHeight();
    Twips w = a.getWidth();

    Glyph* g = getBody();
    if( g != nil ) 
	{
	    Allocation interior( a );
	    allocateBody( g, interior );
	    g->draw( v, interior);
    }

	// Zeichne die horizontale Legende
	ViewAreaMdl* area = d_model->getViewArea();
	char buf[ 32 ];
	char format[ 8 ];
	Font::BoundingBox box;
	double delta;
	int stellen;
	double start;
	double p;
	Twips x;
	Twips y;

	// Wir zeichnen immer von links nach rechts und oben nach unten.
	if( d_show[ DimX ] )
	{
		const PpmRange& rh = d_model->getBuffer().getScale( DimX ).getRange();
        //const Allotment& ax = a.getAllotment( DimX );
		delta = ::fabs( area->toPpmDiff( 0, d_space[ DimX ], DimX ) );
		start = calc( rh, delta, stellen );

		// Zeichne die horizontale Legende
		::sprintf( format, "%%0.%df", stellen );
		y = t + h - d_height;
		p = start;
		while( rh.contains( p ) )
		{
			x = area->toTwip( p, DimX );
			c.drawLine( x, y, x, y + d_large, d_color, d_thick );
			::sprintf( buf, format, p );
			box.stringBox( d_font, buf, c.getViewport() );
			c.drawText( x - box.getWidth() / 2, y + d_large + box.getAscent(), buf, &d_font, d_color );
			if( rh.isParallel() )
				p += delta;
			else
				p -= delta;
		}
		double count = d_count[ DimX ];
		if( delta > 1.0 )
			count = delta;
		if( rh.isParallel() )
		{
			p = start - delta;
			delta = delta / count;
			while( p < rh.second )
			{
				x = area->toTwip( p, DimX );
				if( p >= rh.first )
					c.drawLine( x, y, x, y + d_small, d_color, d_thick );
				p += delta;
			}
		}else
		{
			p = start + delta;
			delta = delta / count;
			while( p > rh.second )
			{
				x = area->toTwip( p, DimX );
				if( p <= rh.first )
					c.drawLine( x, y, x, y + d_small, d_color, d_thick );
				p -= delta;
			}
		}
	}

	if( d_show[ DimY ] )
	{
		const PpmRange& rv = d_model->getBuffer().getScale( DimY ).getRange();
        //const Allotment& ay = a.getAllotment( DimY );
		delta = ::fabs( area->toPpmDiff( 0, d_space[ DimY ], DimY ) );
		start = calc( rv, delta, stellen );

		// Zeichne die vertikale Legende
		::sprintf( format, "%%0.%df", stellen );

		x = l + w - d_width;
		p = start;
		while( rv.contains( p ) )
		{
			y = area->toTwip( p, DimY );
			c.drawLine( x, y, x + d_large, y, d_color, d_thick );
			::sprintf( buf, format, p );
			box.stringBox( d_font, buf, c.getViewport() );
			c.drawText( x + d_large + 20, y + 
				( box.getAscent() - box.getDescent() ) / 2, 
				buf, &d_font, d_color );
			// c.drawText( x + d_large + 20, y + box.getAscent() / 2, buf, d_font, d_color );
			if( rv.isParallel() )
				p += delta;
			else
				p -= delta;
		}
		double count = d_count[ DimY ];
		if( delta > 1.0 )
			count = delta;
		if( rv.isParallel() )
		{
			p = start - delta;
			delta = delta / count;
			while( p < rv.second )
			{
				y = area->toTwip( p, DimY );
				if( p >= rv.first )
					c.drawLine( x, y, x + d_small, y, d_color, d_thick );
				p += delta;
			}
		}else
		{
			p = start + delta;
			delta = delta / count;
			while( p > rv.second )
			{
				y = area->toTwip( p, DimY );
				if( p <= rv.first )
					c.drawLine( x, y, x + d_small, y, d_color, d_thick );
				p -= delta;
			}
		}
	}
}