import java.awt.*;

//------------------------------------------------------------------------------
// PanelFormat.java:
//		Contains several field, label, button, choice formats
//		for use on panels.
//------------------------------------------------------------------------------

public class PanelFormat
{
	//private OurFrame parent;
	public GridBagConstraints gbc;
	public GridBagLayout gbl;
	
	// Constructor
	//--------------------------------------------------------------------------
	public PanelFormat() //OurFrame f)
	{
		//parent = f;
	}
	
	public void initializePanel(Panel panel)
	{
		gbl = new GridBagLayout();
		gbc = new GridBagConstraints();
		panel.setLayout(gbl);
		gbc.anchor = GridBagConstraints.WEST;
		gbc.insets = new Insets(0,0,0,10);
	}
	
	public boolean LabelFieldChoice(Panel panel,Label label,TextField field, Choice choice)
	{
		// Error check
		if(gbc == null || gbl == null || panel == null)
			return false;

		// Initialize
		gbc.anchor = GridBagConstraints.WEST;
		gbc.gridwidth = 1;
		gbc.fill = GridBagConstraints.NONE;

		// Build and add
		gbc.insets = new Insets(0,11,0,10);	// set for sdaLabel
		gbl.setConstraints(label,gbc);
		gbc.insets = new Insets(0,0,0,10);  // reset to original value
		panel.add(label);

		gbc.fill = GridBagConstraints.HORIZONTAL;
		gbl.setConstraints(field,gbc);
		panel.add(field);

		gbc.gridwidth = GridBagConstraints.REMAINDER;
		gbl.setConstraints(choice,gbc);
		panel.add(choice);

		return true;
	}  
	
	public boolean LabelFieldField(Panel panel,Label label,TextField field1, TextField field2)
	{
		// Error check
		if(gbc == null || gbl == null || panel == null)
			return false;

		// Initialize
		gbc.anchor = GridBagConstraints.WEST;
		gbc.gridwidth = 1;
		gbc.fill = GridBagConstraints.NONE;

		// Build and add
		gbc.insets = new Insets(0,11,0,10);	// set for sdaLabel
		gbl.setConstraints(label,gbc);
		gbc.insets = new Insets(0,0,0,10);  // reset to original value
		panel.add(label);

		gbc.fill = GridBagConstraints.HORIZONTAL;
		gbl.setConstraints(field1,gbc);
		panel.add(field1);

		gbc.gridwidth = GridBagConstraints.REMAINDER;
		gbl.setConstraints(field2,gbc);
		panel.add(field2);

		return true;
	}  
	
	public boolean LabelLabelLabel(Panel panel,Label label1,Label label2,Label label3)
	{
		// Error check
		if(gbc == null || gbl == null || panel == null)
			return false;

		// Initialize
		gbc.anchor = GridBagConstraints.WEST;
		gbc.gridwidth = 1;
		gbc.fill = GridBagConstraints.NONE;

		// Build and add
		gbc.insets = new Insets(0,11,0,10);	// set for sdaLabel
		gbl.setConstraints(label1,gbc);
		gbc.insets = new Insets(0,0,0,10);  // reset to original value
		panel.add(label1);

		gbc.fill = GridBagConstraints.HORIZONTAL;
		gbl.setConstraints(label2,gbc);
		panel.add(label2);

		gbc.gridwidth = GridBagConstraints.REMAINDER;
		gbl.setConstraints(label3,gbc);
		panel.add(label3);

		return true;
	}  

		
	public boolean LabelFieldChoiceButton(Panel panel,Label label,TextField field, Choice choice,Button but)
	{
		// Error check
		if(gbc == null || gbl == null || panel == null)
			return false;

		// Initialize
		gbc.anchor = GridBagConstraints.WEST;
		gbc.gridwidth = 1;
		gbc.fill = GridBagConstraints.NONE;

		// Build and add
		gbc.insets = new Insets(0,11,0,10);	// set for sdaLabel
		gbl.setConstraints(label,gbc);
		gbc.insets = new Insets(0,0,0,10);  // reset to original value
		panel.add(label);

		gbc.fill = GridBagConstraints.HORIZONTAL;
		gbl.setConstraints(field,gbc);
		panel.add(field);
		
		gbc.fill = GridBagConstraints.HORIZONTAL;
		gbl.setConstraints(choice,gbc);
		panel.add(choice);

		gbc.gridwidth = GridBagConstraints.REMAINDER;
		gbl.setConstraints(but,gbc);
		panel.add(but);

		return true;
	}  
	
	
	public boolean LabelChoice(Panel panel,Label label,Choice choice)
	{
		// Error check
		if(gbc == null || gbl == null || panel == null)
			return false;

		// Initialize
		gbc.anchor = GridBagConstraints.WEST;
		gbc.gridwidth = 1;
		gbc.fill = GridBagConstraints.NONE;

		// Build and add
		gbc.insets = new Insets(0,11,0,10);	// set for sdaLabel
		gbl.setConstraints(label,gbc);
		gbc.insets = new Insets(0,0,0,10);  // reset to original value
		panel.add(label);
		
		gbc.gridwidth = GridBagConstraints.REMAINDER;
		gbl.setConstraints(choice,gbc);
		panel.add(choice);

		return true;
	}  
	
	// Add a lable-choice combination to a panel.
	// Return true if successful, false if unsuccessful.
	//--------------------------------------------------------------------------
	public boolean LabelField(Panel panel,Label label,TextField field)
	{
		// Error check
		if(gbc == null || gbl == null || panel == null)
			return false;

		// Initialize
		gbc.anchor = GridBagConstraints.WEST;
		gbc.gridwidth = 1;
		gbc.fill = GridBagConstraints.NONE;

		// Build and add
		gbc.insets = new Insets(0,11,0,10);	// set for sdaLabel
		
		gbl.setConstraints(label,gbc);
		gbc.insets = new Insets(0,0,0,10);  // reset to original value
		panel.add(label);

		gbc.gridwidth = GridBagConstraints.REMAINDER;
		gbc.fill = GridBagConstraints.NONE;
		gbl.setConstraints(field,gbc);
		panel.add(field);

		return true;
	}
	
	// Add a lable-choice combination to a panel.
	// Return true if successful, false if unsuccessful.
	//--------------------------------------------------------------------------
	public boolean LabelSlide(Panel panel,Label label,SlideBar field)
	{
		// Error check
		if(gbc == null || gbl == null || panel == null)
			return false;

		// Initialize
		gbc.anchor = GridBagConstraints.WEST;
		gbc.gridwidth = 1;
		gbc.fill = GridBagConstraints.NONE;

		// Build and add
		gbc.insets = new Insets(0,11,0,10);	// set for sdaLabel
		
		gbl.setConstraints(label,gbc);
		gbc.insets = new Insets(0,0,0,10);  // reset to original value
		panel.add(label);

		gbc.gridwidth = GridBagConstraints.REMAINDER;
		gbc.fill = GridBagConstraints.NONE;
		gbl.setConstraints(field,gbc);
		panel.add(field);

		return true;
	}


	// Add a section subtitle to a panel.
	// Return true if successful, false if unsuccessful.
	//--------------------------------------------------------------------------
	public boolean Subtitle(Panel panel, String title)
	{
		// Error check
		if(gbc == null || gbl == null || panel == null)
			return false;

		// Build and add
		Label field_name = new Label(title);
		field_name.setFont(new Font("Helvetica",Font.BOLD,18));
		if(System.getProperty("java.vendor").compareTo("Netscape Communications Corporation") == 0)
			gbc.insets = new Insets(0,11,0,10);
		gbc.gridwidth = GridBagConstraints.REMAINDER;
		gbc.fill = GridBagConstraints.NONE;
		gbl.setConstraints(field_name,gbc);
		panel.add(field_name);

		return true;
	}

	// Add verbage to a panel.
	// Return true if successful, false if unsuccessful.
	//--------------------------------------------------------------------------
	public boolean Words(Panel panel, int j, String s, String title)
	{
		// Error check
		if(gbc == null || gbl == null || panel == null)
			return false;

		// Build and add
		gbc.gridwidth = GridBagConstraints.REMAINDER;
		gbc.fill = GridBagConstraints.NONE;
		Label field_name = new Label(title);
		if(s.compareTo("BOLD") == 0)
		    field_name.setFont(new Font("Helvetica",Font.BOLD,j));
		else
		    field_name.setFont(new Font("Helvetica",Font.PLAIN,j));
		if(System.getProperty("java.vendor").compareTo("Netscape Communications Corporation") == 0)
			gbc.insets = new Insets(0,11,0,10);
		gbl.setConstraints(field_name,gbc);
		panel.add(field_name);

		return true;
	}

	// Add a vertical space to a panel.
	// Return true if successful, false if unsuccessful.
	//--------------------------------------------------------------------------
	public boolean Space(Panel panel)
	{
		// Error check
		if(gbc == null || gbl == null || panel == null)
			return false;

		// Build and add
		gbc.gridwidth = GridBagConstraints.REMAINDER;
		gbc.fill = GridBagConstraints.NONE;
		Label field_name = new Label("");
		gbl.setConstraints(field_name,gbc);
		panel.add(field_name);

		return true;
	}
	
	// Used in SetupDialog.java
    public boolean LabelCheck(Panel panel,Label s,Checkbox cb1,Checkbox cb2)
	{
		// Error check
		if(gbc == null || gbl == null || panel == null)
			return false;

		// Initialize
		gbc.anchor = GridBagConstraints.WEST;
		gbc.gridwidth = 1;
		gbc.fill = GridBagConstraints.NONE;

		// Build and add
		gbc.insets = new Insets(0,11,0,10);	// set for Label
		gbl.setConstraints(s,gbc);
		gbc.insets = new Insets(0,0,0,10);  // reset to original value
		panel.add(s);

		gbc.gridwidth = GridBagConstraints.HORIZONTAL;
		gbc.fill = GridBagConstraints.NONE;
		gbl.setConstraints(cb1,gbc);
		panel.add(cb1);

		gbc.gridwidth = GridBagConstraints.REMAINDER;
		gbc.fill = GridBagConstraints.NONE;
		gbl.setConstraints(cb2,gbc);
		panel.add(cb2);

		return true;
	}

/*	// Add a lable-choice combination to a panel.
	// Return true if successful, false if unsuccessful.
	//--------------------------------------------------------------------------
	public boolean LabelChoice(Panel panel, fieldWrapper wrap)
	{
		// Error check
		if(gbc == null || gbl == null || panel == null)
			return false;

		// Initialize
		gbc.anchor = GridBagConstraints.WEST;
		gbc.gridwidth = 1;
		gbc.fill = GridBagConstraints.NONE;

		// Build and add
		gbc.insets = new Insets(0,11,0,10);	// set for sdaLabel
		gbl.setConstraints(wrap.label,gbc);
		gbc.insets = new Insets(0,0,0,10);  // reset to original value
		panel.add(wrap.label);

		gbc.gridwidth = GridBagConstraints.REMAINDER;
		gbc.fill = GridBagConstraints.NONE;
		gbl.setConstraints(wrap.choice,gbc);
		panel.add(wrap.choice);

		return true;
	}  */
	
}