package typo;

import java.awt.Graphics;

public class Vbox extends Group {

	double lineSkip;
	
	public Vbox(double lineSkip) {
		this.lineSkip = lineSkip;
	}
	
	public void doDraw(Graphics g, double x, double y, double w) {
		for (Box b : contents) {
			b.draw(g, x, y, w);
			y += lineSkip + b.getDescent() + b.getAscent();
		}
	}

	public void add(Box b) {
		if (!contents.isEmpty()) ascent += lineSkip;
		super.add(b);
		ascent += descent + b.getAscent();
		descent = b.getDescent();
		minimalWidth = Math.max(minimalWidth, b.getMinimalWidth()); 
		stretchingCapacity = Math.max(stretchingCapacity, b.getStretchingCapacity());
	}
	
	public String toString() {
		return "Vbox" + super.toString();
	}

}

