Beispiel #1
0
void Border::allocateBody( Glyph* body, Twips thickness, Allocation& interior ) 
{
	// Dies funktioniert minimal, d.h. wenn Request nicht vorhanden.
    Allotment& x = interior.getAllotment( DimensionX );
	x.setSpan( x.getSpan() - 2 * thickness );
	x.setOrigin( x.getOrigin() + thickness );
    Allotment& y = interior.getAllotment( DimensionY );
	y.setSpan( y.getSpan() - 2 * thickness );
	y.setOrigin( y.getOrigin() + thickness );
	return;

	// Stammt aus BevelFrame: wozu das ganze? Scheint zu funktionieren.
    Requisition reqest;
    body->request( reqest );
    Allotment& ax = interior.getAllotment( DimensionX );
    Twips x_span = ax.getSpan() - 2 * thickness;
    Twips x_offset = thickness;
    Twips x_align = ax.getAlignment();


    const Requirement& rx = reqest.getRequirement( DimensionX );
    if( rx.isDefined() ) 
	{
		Twips x_usable = rx.getNatural() + rx.getStretch();
		if( x_span > x_usable ) 
		{
			x_offset += 0 * ( x_span - x_usable );	// d_alignX
			x_span = x_usable;
		}
    }
    ax.setSpan( x_span );
    ax.move( x_offset * ( AlignmentMax - 2 * x_align ) );

    Allotment& ay = interior.getAllotment( DimensionY );
    Twips y_span = ay.getSpan() - 2 * thickness;
    Twips y_offset = thickness;
    Twips y_align = ay.getAlignment();


    const Requirement& ry = reqest.getRequirement( DimensionY );
    if( ry.isDefined() ) 
	{
		Twips y_usable = ry.getNatural() + ry.getStretch();
		if( y_span > y_usable ) 
		{
			y_offset += 0 * ( y_span - y_usable );	// d_alignY
			y_span = y_usable;
		}
    }
    ay.setSpan( y_span );
    ay.move( y_offset * ( AlignmentMax - 2 * y_align ) );
}
Beispiel #2
0
void Border::request( Requisition& requisition ) 
{
    Glyph* g = getBody();
    if( g != nil ) 
	{
		g->request( requisition );
	    Requirement& rx = requisition.getRequirement( DimensionX );
	    if( rx.isDefined() ) 
			rx.setNatural( rx.getNatural() + 2 * d_thickness );
	    Requirement& ry = requisition.getRequirement( DimensionY );
	    if( ry.isDefined() ) 
			ry.setNatural( ry.getNatural() + 2 * d_thickness );
    }
}
Beispiel #3
0
void SpecRuler2D::request( Requisition& requisition ) 
{
	calcSize();
    Glyph* g = getBody();
    if( g != nil ) 
	{
		g->request( requisition );
	    Requirement& rx = requisition.getRequirement( DimensionX );
	    if( rx.isDefined() ) 
			rx.setNatural( rx.getNatural() + d_width );
	    Requirement& ry = requisition.getRequirement( DimensionY );
	    if( ry.isDefined() ) 
			ry.setNatural( ry.getNatural() + d_height );
    }
}
Beispiel #4
0
void FontBoundingBox::request(Requisition & requisition)
{
	// Requisition umschliesst den gesamten Zeichenbereich, der Pixel enthält.
	// Normalerweise ist alignment horizontal negativ, da Ursprung links
	// des gemalten Bereichs liegt.
	Requirement& rx = requisition.getRequirement( DimX );
	Requirement& ry = requisition.getRequirement( DimY );

	ry.setNatural( getHeight() );
	//ry.setAlignment( ( getAscent() + TwipsPerPoint ) / float( getHeight() ) );
	//. 20 wegen Basislinie in Twips. Ev. weglassen.

	Coord lb = getLeftBearing();
	Coord rb = getRightBearing();
	Coord w = getWidth();
	if( rb < 0 )
		w += -rb;	// zähle den w überragenden Teil dazu.
		// den leeren Rand (rb > 0) könnte man eigentlich entfernen.
	if( lb < 0 )
	{
		lb = -lb;	// logischer Ursprung wird links von gemalten Pixeln überragt.
		w += lb;
		//rx.setAlignment( lb / float( w ) );
	}else
	{
		w -= lb;	// logischer Ursprung ist links des gemalten Bereichs.
		//rx.setAlignment( -lb / float( w ) );
	}
	rx.setNatural( w );
}
Beispiel #5
0
void StripRuler2D::request( Requisition& requisition ) 
{
	calcSize();
    Glyph* g = getBody();
    if( g != nil ) 
	{
		g->request( requisition );
	    Requirement& ry = requisition.getRequirement( DimensionY );
	    if( ry.isDefined() ) 
			ry.setNatural( ry.getNatural() + d_hUpper + d_hLower );
    }
}
Beispiel #6
0
void Layer::request(Requisition & r)
{
    // TODO: ev. ein Align verwenden statt Handbetrieb.
    Requisition sub;
    // Nullen nicht ntig, da r als Default -CoordMax, was immer kleiner ist als sub.Natural.
    Requirement& rx = r.getRequirement( DimensionX );
    Requirement& ry = r.getRequirement( DimensionY );
    if( getCount() == 0)
    {
        // NOTE: Nullen dennoch ntig, da undefiniert, wenn Layer leer. Tile wird sonst
        // Null-Allocation zuweisen. RISK
        rx = Requirement( 0, MaxTwips, 0 );
        ry = Requirement( 0, MaxTwips, 0 );
    }
    for( GlyphIndex i = 0; i < getCount(); i++ )
    {
        Glyph* g = getComponent( i );
        if( g )
        {
            g->request( sub );
            Requirement& sx = sub.getRequirement( DimensionX );
            Requirement& sy = sub.getRequirement( DimensionY );
            if( sx.isDefined() )
            {
                rx.setNatural( Math::_max( rx.getNatural(), sx.getNatural() ) );
                rx.setStretch( Math::_max( rx.getStretch(), sx.getStretch() ) );
                rx.setShrink( Math::_max( rx.getShrink(), sx.getShrink() ) );
            }
            if( sy.isDefined() )
            {
                ry.setNatural( Math::_max( ry.getNatural(), sy.getNatural() ) );
                ry.setStretch( Math::_max( ry.getStretch(), sy.getStretch() ) );
                ry.setShrink( Math::_max( ry.getShrink(), sy.getShrink() ) );
            }
        }
    }
    d_changed = false;
}