/* Spiro by Jimmc
 * Copyright 1996 Jim McBeath
 *
 * Permission to use, copy, and distribute Spiro, in source or binary form,
 * for personal non-commercial use is hereby granted without fee, provided
 * that this copyright notice appears in all copies, and that no charge is
 * associated with such copies.
 *
 * Permission to modify Spiro and make derivative works for personal
 * non-commercial use, and to distribute such modified versions, is hereby
 * granted without fee, provided that the users of such a modified version
 * are clearly notified that the work is a modified version of Spiro and
 * not the original Spiro.  As with unmodified distributions, this copyight
 * notice must appear in all modified copies, and no charge may be associated
 * with such copies.
 *
 * The author makes no representations about the suitability of this software
 * for any purpose.  It is provided "as-is", without any express or implied
 * warranty.  In no event will the author be held liable for any damages
 * arising from the use of this software.
 */
/* GridBuilder - make it simpler to layout a GridBagLayout
 *
 * Jim McBeath, June 15, 1996
 */

import java.awt.*;

class GridBuilder extends GridBagLayout {
	Container container;
	GridBagConstraints constraints;

	public GridBuilder(Container c) {
		container = c;
		constraints = new GridBagConstraints();
		container.setLayout(this);
		constraints.insets = new Insets(5,5,5,5);
		constraints.gridx = 0;
		constraints.gridy = 0;
	}
	public void nextRow() {
		constraints.gridx = 0;
		constraints.gridy++;
	}
	public Button addButton(String label) {
		Button button = new Button(label);
		this.setConstraints(button,constraints);
		container.add(button);
		constraints.gridx = GridBagConstraints.RELATIVE;
		return button;
	}
	public Label addLabel(String label) {
		Label lw = new Label(label);
		this.setConstraints(lw,constraints);
		container.add(lw);
		constraints.gridx = GridBagConstraints.RELATIVE;
		return lw;
	}
	public TextField addTextField(String dflt,int size) {
		TextField tf = new TextField(dflt,size);
		this.setConstraints(tf,constraints);
		container.add(tf);
		constraints.gridx = GridBagConstraints.RELATIVE;
		return tf;
	}
	public Choice addChoice() {
		Choice c = new Choice();
		this.setConstraints(c,constraints);
		container.add(c);
		constraints.gridx = GridBagConstraints.RELATIVE;
		return c;
	}
	public Checkbox addCheckbox(String labeltext) {
		Checkbox cbox = new Checkbox(labeltext);
		this.setConstraints(cbox,constraints);
		container.add(cbox);
		constraints.gridx = GridBagConstraints.RELATIVE;
		return cbox;
	}
}

/* end */
