package gve.calc.formula;

import java.awt.*;

public class UneditableView extends Container implements View,HasCursorPos,HasBaseline {
	private Uneditable model;

	public UneditableView(Uneditable model,FormulaView view) {
		this.model = model;
		add(view.getView(model.child));
	}

	public Object getModel() { return model; }

	public void updateView(Object with) {}

	public void setCursorPos(int pos) {
//		FormulaView.get(this).setCursorComp(null);
		return;
	}

	public void activate() {}

	public void deactivate() {}

	public int getCursorPos() { return Somewhere_NOWHERE; }

	public int getBaseline() {
		Component child = getComponent(0);
		if (child instanceof HasBaseline)
			return ((HasBaseline)child).getBaseline();
		return child.getPreferredSize().height / 2;
	}

	public Dimension getPreferredSize() {
		return getComponent(0).getPreferredSize();
	}

	public Dimension getMinimumSize() {
		return getComponent(0).getMinimumSize();
	}

	public void doLayout() {
		Component child = getComponent(0);
		child.validate();
		Dimension siz = child.getPreferredSize();
		child.setBounds(0,0,siz.width,siz.height);
	}
}