Beispiel #1
0
void BevelFrame::allocate_body(Glyph* g, Coord t, Allocation& a) const {
    Requisition req;
    g->request(req);
    Coord h = hmargin_ ? t : 0, v = vmargin_ ? t : 0;
    Allotment& ax = a.x_allotment();
    Coord x_span = ax.span() - h - h;
    Coord x_offset = h;
    Coord x_align = ax.alignment();
    const Requirement& rx = req.x_requirement();
    if (rx.defined()) {
	Coord x_usable = rx.natural() + rx.stretch();
	if (x_span > x_usable) {
	    x_offset += xalign_ * (x_span - x_usable);
	    x_span = x_usable;
	}
    }
    ax.span(x_span);
    ax.offset(x_offset * (1 - x_align - x_align));

    Allotment& ay = a.y_allotment();
    Coord y_span = ay.span() - v - v;
    Coord y_offset = v;
    Coord y_align = ay.alignment();
    const Requirement& ry = req.y_requirement();
    if (ry.defined()) {
	Coord y_usable = ry.natural() + ry.stretch();
	if (y_span > y_usable) {
	    y_offset += yalign_ * (y_span - y_usable);
	    y_span = y_usable;
	}
    }
    ay.span(y_span);
    ay.offset(y_offset * (1 - y_align - y_align));
}
void TransformSetter::request(Requisition& req) const {
    TransformSetter* t = (TransformSetter*)this;
    MonoGlyph::request(req);
    Allocation& a = t->natural_allocation_;

    Requirement& rx = req.x_requirement();
    Allotment& ax = a.x_allotment();
    ax.origin(0.0);
    ax.span(rx.natural());
    ax.alignment(rx.alignment());

    Requirement& ry = req.y_requirement();
    Allotment& ay = a.y_allotment();
    ay.origin(0.0);
    ay.span(ry.natural());
    ay.alignment(ry.alignment());

    const Transformer& tx = transformer_;
    Coord left = ax.begin(), bottom = ay.begin();
    Coord right = ax.end(), top = ay.end();
    Coord x1, y1, x2, y2, x3, y3, x4, y4;
    tx.transform(left, bottom, x1, y1);
    tx.transform(left, top, x2, y2);
    tx.transform(right, top, x3, y3);
    tx.transform(right, bottom, x4, y4);
    left = Math::min(x1, x2, x3, x4);
    bottom = Math::min(y1, y2, y3, y4);
    right = Math::max(x1, x2, x3, x4);
    top = Math::max(y1, y2, y3, y4);

    compute_req(rx, left, right);
    compute_req(ry, bottom, top);
}
Beispiel #3
0
void TBScrollBox::request(Requisition& req) const {
    GlyphIndex n = count();
    TBScrollBoxImpl& sb = *impl_;
    if (sb.changed_) {
	Requisition r;
	const Requirement& rx = r.x_requirement();
	const Requirement& ry = r.y_requirement();
	Coord natural_width = 0.0;
	Coord natural_height = 0.0;
	for (GlyphIndex i = 0; i < n; i++) {
	    Glyph* g = component(i);
	    if (g != nil) {
		g->request(r);
		Coord r_width = rx.natural();
		if (r_width > natural_width) {
		    natural_width = r_width;
		}
		natural_height += ry.natural();
	    }
	}
	Requirement& box_x = sb.requisition_.x_requirement();
	box_x.natural(natural_width);
	box_x.stretch(fil);
	box_x.shrink(natural_width);
	box_x.alignment(0.0);

	Requirement& box_y = sb.requisition_.y_requirement();
	box_y.natural(natural_height);
	box_y.stretch(fil);
	box_y.shrink(natural_height);
	box_y.alignment(1.0);
	sb.changed_ = false;
    }
    req = sb.requisition_;
}
Beispiel #4
0
void Text31::request (Requisition& req) const { 
    _body->request(req);
    Requirement& rx = req.x_requirement();
    Requirement& ry = req.y_requirement();

    Coord left, bottom, right, top;
    left = -rx.natural()*rx.alignment();
    right = left + rx.natural();
    bottom = -ry.natural()*ry.alignment();
    top = bottom + ry.natural();

    Text31* text = (Text31*) this;
    text->_ctrlpts = 4;
    text->_x[0] = left;
    text->_y[0] = bottom;
    text->_x[1] = left;
    text->_y[1] = top;
    text->_x[2] = right;
    text->_y[2] = top;
    text->_x[3] = right;
    text->_y[3] = bottom;

    if (_t != nil) {
        corners(left, bottom, right, top, *_t);
    }
    rx.natural(right - left);
    rx.stretch(0.0);
    rx.shrink(0.0);
    rx.alignment(-left / rx.natural());

    ry.natural(top - bottom);
    ry.stretch(0.0);
    ry.shrink(0.0);
    ry.alignment(-bottom / ry.natural());
}
Beispiel #5
0
void XYView::request(Requisition& req) const {
    TransformSetter::request(req);
    Requirement rx(xsize_orig_);
    Requirement ry(ysize_orig_);
    req.require_x(rx);
    req.require_y(ry);
}
Beispiel #6
0
void GraphicMaster::request(Requisition& req) const {
    PolyGraphic::request(req);
    Requirement& rx = req.x_requirement();
    rx.alignment(0.0);
    
    Requirement& ry = req.y_requirement();
    ry.alignment(0.0);
}
Beispiel #7
0
void DebugGlyph::request(Requisition& r) const {
    MonoGlyph::request(r);
    if ((flags_ & trace_request) != 0) {
	heading("request ");
	print_requirement(r.requirement(Dimension_X));
	printf(", ");
	print_requirement(r.requirement(Dimension_Y));
	printf("\n");
    }
}
Beispiel #8
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 #9
0
void GlyphViewer::request(Requisition& req) const {
    Requirement& rx = req.x_requirement();
    rx.natural(_width);
    rx.stretch(fil);
    rx.shrink(_width);
    rx.alignment(0.0);
    
    Requirement& ry = req.y_requirement();
    ry.natural(_height);
    ry.stretch(fil);
    ry.shrink(0.0);
    ry.alignment(0.0);
}
Beispiel #10
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 #11
0
void ShapeOf::request(Requisition& requisition) const {
    if (x_ == y_) {
	x_->request(requisition);
    } else {
	Requisition req;
	if (x_ != nil) {
	    x_->request(req);
	    requisition.require_x(req.x_requirement());
	}
	if (y_ != nil) {
	    y_->request(req);
	    requisition.require_y(req.y_requirement());
	}
    }
}
Beispiel #12
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 #13
0
void Scrollable::request(Requisition& req) const {
    Scrollable* s = (Scrollable*) this;
    Patch::request(s->requisition_);
    Requirement& box_x = req.x_requirement();
    box_x.natural(width_);
    box_x.stretch(fil);
    box_x.shrink(width_);
    box_x.alignment(0.0);

    Requirement& box_y = req.y_requirement();
    box_y.natural(height_);
    box_y.stretch(fil);
    box_y.shrink(height_);
    box_y.alignment(0.0);
}
Beispiel #14
0
void VStrut::request(Requisition& requisition) const {
    Coord height = ascent_ + descent_;
    Requirement rx(natural_, stretch_, shrink_, 0);
    Requirement ry(height, 0, 0, (height == 0) ? 0 : descent_ / height);
    requisition.require(Dimension_X, rx);
    requisition.require(Dimension_Y, ry);
}
Beispiel #15
0
void HStrut::request(Requisition& requisition) const {
    Coord width = left_bearing_ + right_bearing_;
    Requirement rx(width, 0, 0, (width == 0) ? 0 : left_bearing_ / width);
    Requirement ry(natural_, stretch_, shrink_, 0);
    requisition.require(Dimension_X, rx);
    requisition.require(Dimension_Y, ry);
}
Beispiel #16
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 #17
0
void BevelFrame::request(Requisition& req) const {
    Glyph* g = body();
    if (g != nil) {
	g->request(req);
	if (hmargin_ || vmargin_) {
	    Coord t = thickness_ + thickness_;
	    Requirement& rx = req.x_requirement();
	    if (hmargin_ && rx.defined()) {
		rx.natural(rx.natural() + t);
	    }
	    Requirement& ry = req.y_requirement();
	    if (vmargin_ && ry.defined()) {
		ry.natural(ry.natural() + t);
	    }
	}
    }
}
Beispiel #18
0
void TextLine::request(Requisition& requisition) const 
{
	FontBoundingBox fbb;
	font_->font_bbox(fbb);
	Text::request(requisition);
	Requirement ry(fbb.ascent() + fbb.descent(), 0, 0, 0);
	requisition.require(Dimension_Y, ry);
}
Beispiel #19
0
void Page::allocate(Canvas* c, const Allocation& allocation, Extension& ext) {
    canvas_ = c;
    allocation_ = allocation;
    if (background_ != nil) {
        background_->allocate(c, allocation, ext);
    }
    GlyphIndex count = info_->count();
    for (GlyphIndex index = 0; index < count; ++index) {
        PageInfo& info = info_->item_ref(index);
        if (info.glyph_ != nil) {
            Allocation& a = info.allocation_;
            Extension& b = info.extension_;
            Requisition s;
            info.glyph_->request(s);
            Allotment ax = Allotment(
                allocation.x() + info.x_,
                s.requirement(Dimension_X).natural(),
                s.requirement(Dimension_X).alignment()
            );
            Allotment ay = Allotment(
                allocation.y() + info.y_,
                s.requirement(Dimension_Y).natural(),
                s.requirement(Dimension_Y).alignment()
            );
            if (
                !(info.status_ & PageInfoAllocated)
                || !ax.equals(a.allotment(Dimension_X), epsilon)
                || !ay.equals(a.allotment(Dimension_Y), epsilon)
            ) {
                if (c != nil && (info.status_ & PageInfoExtended)) {
                    c->damage(b);
                }
                a.allot(Dimension_X, ax);
                a.allot(Dimension_Y, ay);
		b.clear();
                info.glyph_->allocate(c, a, b);
                if (c != nil) {
                    c->damage(b);
                }
            }
            info.status_ |= PageInfoAllocated|PageInfoExtended;
            ext.merge(b);
        }
    }
}
Beispiel #20
0
void TBScrollBoxImpl::reallocate() {
    if (canvas_ == nil) {
	return;
    }
    ScrollBox* s = scrollbox_;
    GlyphIndex n = s->count();
    end_ = n;
    TBScrollBoxList& list = visible_;
    list.remove_all();
    Requisition req;
    TBScrollBoxInfo info;
    Extension e_i;
    const Requirement& r = req.y_requirement();
    Coord p = allocation_.top();
    Coord bottom = allocation_.bottom();
    bool found_start = false;
    for (GlyphIndex i = start_; i < n; i++) {
	Glyph* g = s->component(i);
	if (g != nil) {
	    g->request(req);
	    Coord span = r.natural();
	    if (!Math::equal(span, Coord(0), float(1e-2))) {
		if (!found_start) {
		    start_ = i;
		    found_start = true;
		}
		Coord alignment = r.alignment();
		p -= span;
		if (p < bottom) {
		    end_ = i;
		    break;
		}
		info.glyph_ = g;
		Allotment& ax = info.allocation_.x_allotment();
		ax = allocation_.x_allotment();
		Allotment& ay = info.allocation_.y_allotment();
		ay.span(span);
		ay.origin(p + Coord(alignment * span));
		ay.alignment(alignment);
		list.append(info);
		g->allocate(canvas_, info.allocation_, e_i);
	    }
	}
    }
}
Beispiel #21
0
void Text::request(Requisition& requisition) const 
{
	FontBoundingBox fbb;
	font_->font_bbox(fbb);
	Requirement rx(width(' ') * initialColumns_, fil,
		width(' ') * (initialColumns_ - 1), 0);
	Requirement ry((fbb.ascent() + fbb.descent()) * initialLines_, fil,
		(fbb.ascent() + fbb.descent()) * (initialLines_ - 1), 0);
	requisition.require(Dimension_X, rx);
	requisition.require(Dimension_Y, ry);
}
Beispiel #22
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 #23
0
XtGeometryResult WidgetWindow::xt_query_geometry(
    XtWidgetGeometry* intended, XtWidgetGeometry* preferred
) {
    WindowRep& wr = *((Window*)this)->rep();
    Display& d = *wr.display_;
    Glyph* g = glyph();

    if (!g) {
	*preferred = *intended;
	return XtGeometryYes;
    }

    Requisition req;
//    GlyphImpl::default_requisition(req);

    g->request(req);

    Coord w = req.requirement(Dimension_X).natural();
    Coord h = req.requirement(Dimension_Y).natural();

    // ### look into how the following works 
    XtGeometryMask mode = CWWidth | CWHeight;
    preferred->request_mode = mode;
    preferred->width = XCoord(d.to_pixels(w));
    preferred->height = XCoord(d.to_pixels(h));

    if ((intended->request_mode & mode) == mode &&
	intended->width == preferred->width &&
	intended->height == preferred->height
    ) {
	return XtGeometryYes;
    } 
    else if (preferred->width == widget_->core.width &&
	preferred->height == widget_->core.height
    ) {
	return XtGeometryNo;
    }

    return XtGeometryAlmost;
}
Beispiel #24
0
void Graphic31::request(Requisition& req) const {
    if (_ctrlpts > 0) {
        Coord left = _xmin, bottom = _ymin;
        Coord right = _xmax, top = _ymax;
        Requirement& rx = req.x_requirement();
        Requirement& ry = req.y_requirement();

        if (_t != nil) {
            corners(left, bottom, right, top, *_t);
        } 
        
        rx.natural(right - left + 1);
        rx.stretch(0.0);
        rx.shrink(0.0);
        rx.alignment(-left / rx.natural());
        
        ry.natural(top - bottom + 1);
        ry.stretch(0.0);
        ry.shrink(0.0);
        ry.alignment(-bottom / ry.natural());
    }
}
Beispiel #25
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;
}
Beispiel #26
0
void PolyGraphic::request (Requisition& req) const { 
   _body->request(req);
    Requirement& rx = req.x_requirement();
    Requirement& ry = req.y_requirement();

    Coord left, bottom, right, top;
    left = -rx.natural()*rx.alignment();
    right = left + rx.natural();
    bottom = -ry.natural()*ry.alignment();
    top = bottom + ry.natural();

    if (_t != nil) {
        corners(left, bottom, right, top, *_t);
    }
    rx.natural(right - left);
    rx.stretch(0.0);
    rx.shrink(0.0);
    rx.alignment(-left / rx.natural());

    ry.natural(top - bottom);
    ry.stretch(0.0);
    ry.shrink(0.0);
    ry.alignment(-bottom / ry.natural());
}
Beispiel #27
0
void Character::request(Requisition& requisition) const {
    Requirement rx(width_, 0, 0, 0);
    Requirement ry(height_, 0, 0, alignment_);
    requisition.require(Dimension_X, rx);
    requisition.require(Dimension_Y, ry);
}
Beispiel #28
0
void Rule::request(Requisition& req) const {
    Requirement r(thickness_, 0, 0, 0);
    req.require(dimension_, r);
}
Beispiel #29
0
void XYView_helper::request(Requisition& req) const {
    Requirement rx(v_->width(), 0, 0, -v_->left()/v_->width());
    Requirement ry(v_->height(), 0, 0, -v_->bottom()/v_->height());
    req.require_x(rx);
    req.require_y(ry);
}
Beispiel #30
0
void Slider::request(Requisition& req) const {
    Requirement default_size(22.0, fil, 22.0, 0.0);
    req.require(Dimension_X, default_size);
    req.require(Dimension_Y, default_size);
}