/*
 * $Log: FramedPanel.java,v $
# Revision 1.2  1996/04/19  01:55:01  inder
# Initial Revision.
#
 */
/////////////////////////////////////////////////
package gui;			    // Part of gui package.

import java.awt.Panel;
import java.awt.Insets;
import java.awt.Graphics;
import java.awt.Dimension;
//////////////////////////////////////////////////
public class FramedPanel extends Panel {

private int inset_gap = 10;	    // Gap from the borders (insets).

public static final int NO_BORDER = 0;
public static final int SINGLE_BORDER = 1;
public static final int DOUBLE_BORDER = 2;
private int border = NO_BORDER;		    // Type of border of this frame.
//************************************************
public FramedPanel() {
// REQUIRES: nothing.
// RETURNS: nothing.
// PROMISES: creates a panel with 0 inset (gap from the borders).

  super();
  inset_gap = 0;
}
//************************************************
public FramedPanel(int bordertype) {
// REQUIRES: nothing.
// RETURNS: nothing.
// PROMISES: creates a frame with border bordertype and a default inset of 10. 

  super();
  border = bordertype;
}
//************************************************
public FramedPanel(int bordertype, int gaps_from_borders) {
// REQUIRES: nothing.
// RETURNS: nothing.
// PROMISES: creates a frame with defined bordertype and a inset of
// gaps_from_borders. 

  this(bordertype);
  inset_gap = gaps_from_borders;
}
//************************************************
public void paint(Graphics g) {
// REQUIRES: nothing.
// RETURNS: nothing.
// PROMISES: paint the component and its border.
  super.paint(g);
  PaintBorder(g);
}
//************************************************
private void PaintBorder(Graphics g) {
// REQUIRES: nothing.
// RETURNS: nothing.
// PROMISES: Paints border of this panel.

  Dimension d;
  switch(border) {
  case NO_BORDER:
    break;
  case SINGLE_BORDER:
    d = size();
    g.drawRect(0, 0, d.width-1, d.height-1);
    break;
  case DOUBLE_BORDER:
    d = size();
    g.drawRect(0, 0, d.width-1, d.height-1);
    g.drawRect(2, 2, d.width-5, d.height-5);
    break;
  default:			    // Don't draw any border.
    break;
  }
}
//************************************************
public Insets insets() {
// REQUIRES: nothing.
// RETURNS: nothing.
// PROMISES: returns the desired insets of this panel.

  return new Insets(inset_gap, inset_gap, inset_gap, inset_gap);
}
//************************************************
} // End of class FramedPanel
//////////////////////////////////////////////////
