/**
	AUTHOR & Copyright Holder: Anthony Hand (anthony@handaweb.com)

	COURSE: University of Michigan SI 544

	DATE: 11/3/98

	URL
		http://www.handaweb.com/anthony/coursework/

	SUMMARY:
 		This class was designed to keep the look and feel of the JBDemo applet
 		beans consistent, even tho' 8 people were involved in coding it. As a 
 		result, all of the access methods are read only.

   CREDITS
		o The concept for this object came from both Anders and Anthony.

   INPUT (this class)
		o N/A -- but every class should instantiate this object when its created.

   BAD DATA CHECKING
		o N/A

   OUTPUT
		o Each class should instantiate this object and use it to get its
		  GUI appropriately. The programmers should carefully look over this
		  object's access methods.

   CLASS HIERARCHY:
        Object
        |
        +---ReadBean
        |
        +---WriteBean
        |
        +---Component
            |
            +---Container
                |
                +---Panel
                |   |
                |   +---Applet
                |       |
                |       +---JBDemo
                |
                +---Window
                    |
                    +---Frame
                        |
                        +---BrowseWin
                        |
                        +---RespondWin
                        |
                        +---CheckWin
                        |
                        +---PostWin
                        |
                        +---ErrorWin
                        |
                        +---StyleBean

   ASSUMPTIONS
		o Programmers will use the StyleBean as much as is relevant for their
		  windows.
		o The programmers and users will like the look and feel we developed.
		o There is a need to maintain this kind of consistency.
		o This is also just an exercise in using Beans.

   STYLE GUIDE
		o Please use SansSerif font.
		o Use left alignment for most text (except buttons).
		o Bold and italics are to be used sparingly.
		o In general, the pop up windows should be as wide and high as necessary,
		  but no more than 550 pixels wide. Please implement window scrollbars
		  if necessary. 
		o Programmers should use the setBounds() as much as possible to place
		  components in the windows.
		o Please make the event handling classes INNER CLASSES. They'll be easier
		  for us to keep track of that way.
		o Please use the following labeling conventions for variables:
		  - labels must end in "Lbl"; example: bannerLbl
		  - panels must end in "Pnl"; example: topPnl
		  - text areas must end in "TA"; example: msgTA
		  - text fields must end in "TF"; example: userNameTF
		  - strings must end in "Str"; example: newStr
		  - radio buttons should end in "Radio"; example: browseRadio
		  - choice boxes should end in "Choice"; example: browseCatChoice
		o Pay attention to setEditable()s in the text areas.
		o Note: all button specs are based on the browseBtn in this class.
		
	BONUS POINTS
		o Pay attention to the order in which the components are listed in a
		  window, and the which one gets the default focus when the window 
		  appears.
	    o Making the window attractive overall, and including scrollbars.
	    o 

	NOTES
		o We tried to make this applet as helpful as possible for keeping the 
		  GUI consistent across the many different windows. However, not every
		  type of component's look and feel could be anticipated. What the 
		  programmer does not find here, he or she is welcome to set on her own,
		  with the understanding that it will be consistent with the rest of the
		  look and feel.
		o SUGGESTION: do the rough GUI in Symantec Visual Cafe FIRST. Then, when
		  everything is pretty much finished, that's when the programmer should
		  implement the style bean get()s to make sure the GUI is consistent. Along
		  the way, however, the programmer should reference the specs in the 
		  StyleBean. 

*/

import java.awt.*;
import java.beans.*;

public class StyleBean extends java.awt.Frame
{
	
	//{{DECLARE_CONTROLS
	private java.awt.Panel browseWinPnl;
	private java.awt.Button browseBtn;
	private java.awt.Label browseLbl;
	private java.awt.Panel respondWinPnl;
	private java.awt.Button respondBtn;
	private java.awt.Label respondLbl;
	private java.awt.Panel postWinPnl;
	private java.awt.Button postBtn;
	private java.awt.Label postLbl;
	private java.awt.Panel checkWinPnl;
	private java.awt.Button checkBtn;
	private java.awt.Label checkLbl;
	private java.awt.Label bannerLbl;
	private java.awt.Label headerLbl;
	private java.awt.Label adSampleLbl;
	private java.awt.Label firstLineLbl;
	private java.awt.Label catLbl;
	private java.awt.TextArea regularTA;
	private java.awt.Label regularLbl;
	private java.awt.TextField regularTF;
	//}}
	
	public StyleBean()
	{
		//{{INIT_CONTROLS
		//basic window GUI 
		setLayout(null);
		setVisible(false);
		setSize(667,433);
		setFont(new Font("SansSerif", Font.PLAIN, 12));
		browseWinPnl = new java.awt.Panel();
		browseWinPnl.setLayout(null);
		browseWinPnl.setBounds(468,264,180,60);
		browseWinPnl.setBackground(new Color(-3355495));
		add(browseWinPnl);
		
		//GUI colors for BrowseWin
		browseBtn = new java.awt.Button();
		browseBtn.setLabel("browseBtn");
		browseBtn.setBounds(12,24,156,24);
		browseBtn.setFont(new Font("SansSerif", Font.PLAIN, 12));
		browseBtn.setForeground(new Color(16777215));
		browseBtn.setBackground(new Color(-6724096));
		browseWinPnl.add(browseBtn);
		browseLbl = new java.awt.Label("BrowseWin Colors");
		browseLbl.setBounds(0,0,132,24);
		browseWinPnl.add(browseLbl);
		
		//GUI colors for RespondWin
		respondWinPnl = new java.awt.Panel();
		respondWinPnl.setLayout(null);
		respondWinPnl.setBounds(468,120,180,60);
		respondWinPnl.setBackground(new Color(-6697831));
		add(respondWinPnl);
		respondBtn = new java.awt.Button();
		respondBtn.setLabel("respondBtn");
		respondBtn.setBounds(12,24,getBtnWidth(),getBtnHeight());
		respondBtn.setFont(getBtnFont());
		respondBtn.setForeground(new Color(16777215));
		respondBtn.setBackground(new Color(-16764058));
		respondWinPnl.add(respondBtn);
		respondLbl = new java.awt.Label("RespondWin Colors");
		respondLbl.setBounds(0,0,156,24);
		respondWinPnl.add(respondLbl);
		
		//GUI colors for PostWin
		postWinPnl = new java.awt.Panel();
		postWinPnl.setLayout(null);
		postWinPnl.setBounds(468,336,180,60);
		postWinPnl.setBackground(new Color(-103));
		add(postWinPnl);
		postBtn = new java.awt.Button();
		postBtn.setLabel("postBtn");
		postBtn.setBounds(12,24,getBtnWidth(),getBtnHeight());
		postBtn.setFont(getBtnFont());
		postBtn.setForeground(new Color(16777215));
		postBtn.setBackground(new Color(-10066330));
		postWinPnl.add(postBtn);
		postLbl = new java.awt.Label("PostWin Colors");
		postLbl.setBounds(0,0,120,24);
		postWinPnl.add(postLbl);
		
		//GUI colors for CheckWin
		checkWinPnl = new java.awt.Panel();
		checkWinPnl.setLayout(null);
		checkWinPnl.setBounds(468,192,180,60);
		checkWinPnl.setBackground(new Color(-3368602));
		add(checkWinPnl);
		checkBtn = new java.awt.Button();
		checkBtn.setLabel("checkBtn");
		checkBtn.setBounds(12,24,getBtnWidth(),getBtnHeight());
		checkBtn.setFont(getBtnFont());
		checkBtn.setForeground(new Color(16777215));
		checkBtn.setBackground(new Color(-16764160));
		checkWinPnl.add(checkBtn);
		checkLbl = new java.awt.Label("CheckWin Colors");
		checkLbl.setBounds(0,0,132,24);
		checkWinPnl.add(checkLbl);
		
		//these are common GUI elements
		//found in all 4 windows
		bannerLbl = new java.awt.Label("bannerLbl");
		bannerLbl.setBounds(12,12,432,42);
		bannerLbl.setFont(new Font("SansSerif", Font.PLAIN, 32));
		add(bannerLbl);
		headerLbl = new java.awt.Label("headerLbl");
		headerLbl.setBounds(12,96,300,24);
		headerLbl.setFont(new Font("SansSerif", Font.BOLD, 14));
		add(headerLbl);
		
		//found in Check & Respond windows
		adSampleLbl = new java.awt.Label("adSampleLbl");
		adSampleLbl.setBounds(48,216,384,18);
		adSampleLbl.setFont(new Font("SansSerif", Font.ITALIC, 12));
		add(adSampleLbl);
		firstLineLbl = new java.awt.Label("firstLineLbl");
		firstLineLbl.setBounds(12,180,252,20);
		firstLineLbl.setFont(new Font("SansSerif", Font.PLAIN, 14));
		add(firstLineLbl);
		
		//found in Browse, Post, and Check windows
		catLbl = new java.awt.Label("catLbl");
		catLbl.setBounds(12,132,420,28);
		catLbl.setFont(new Font("SansSerif", Font.BOLD, 18));
		add(catLbl);
		
		//found in all 4 windows
		regularTA = new java.awt.TextArea();
		regularTA.setEditable(false);
		regularTA.setText("regularTA");
		regularTA.setBounds(12,324,418,73);
		regularTA.setFont(new Font("SansSerif", Font.PLAIN, 12));
		add(regularTA);

		//found in all 4 windows
		regularLbl = new java.awt.Label("regularLbl");
		regularLbl.setBounds(12,252,260,18);
		regularLbl.setFont(new Font("SansSerif", Font.PLAIN, 12));
		add(regularLbl);
		
		//found in the Browse, Respond, and Post windows
		regularTF = new java.awt.TextField();
		regularTF.setText("regularTF");
		regularTF.setBounds(120,288,158,20);
		regularTF.setFont(new Font("MonoSpaced", Font.PLAIN, 12));
		regularTF.setBackground(new Color(16777215));
		add(regularTF);
		
		setTitle("StyleBean - Samples");
		//}}

		//{{REGISTER_LISTENERS
		StyleBeanWinAdapter winAdapter = new StyleBeanWinAdapter();
		this.addWindowListener(winAdapter);
		//}}

		//{{INIT_MENUS
		//}}

	} //0 arg constructor

	public StyleBean(String title)
	{
		this();
		setTitle(title);
	} //1 arg constructor
	
	

	//**************************************************
    //*             BrowseWin info                     *
	//**************************************************
	public Color getBrowseWinColor ()
	{
	    return browseWinPnl.getBackground();
	} //getBrowseWinPnl
	
	public Color getBrowseBtnBGColor ()
	{
	    return browseBtn.getBackground();
	} //getBrowseBtnBGColor
	
	public Color getBrowseBtnFGColor ()
	{
	    return browseBtn.getForeground();
	} //getBrowseBtnFGColor

	//**************************************************
    //*            RespondWin colors                   *
	//**************************************************
	public Color getRespondWinColor()
	{
	    return respondWinPnl.getBackground();
	} //getRespondWinPnl

	public Color getRespondBtnBGColor ()
	{
	    return respondBtn.getBackground();
	} //getRespondBtnBGColor
	
	public Color getRespondBtnFGColor ()
	{
	    return respondBtn.getForeground();
	} //getRespondBtnFGColor
	

	//**************************************************
    //*              PostWin colors                    *
	//**************************************************
	public Color getPostWinColor ()
	{
	    return postWinPnl.getBackground();
	} //getPostWinPnl

	public Color getPostBtnBGColor ()
	{
	    return postBtn.getBackground();
	} //getPostBtnBGColor
	
	public Color getPostBtnFGColor ()
	{
	    return postBtn.getForeground();
	} //getPostBtnFGColor
	
	
	//**************************************************
    //*              CheckWin colors                    *
	//**************************************************
	public Color getCheckWinColor ()
	{
	    return checkWinPnl.getBackground();
	} //getCheckWinPnl
	
	public Color getCheckBtnBGColor ()
	{
	    return checkBtn.getBackground();
	} //getCheckBtnBGColor
	
	public Color getCheckBtnFGColor ()
	{
	    return checkBtn.getForeground();
	} //getCheckBtnFGColor
	
	//**************************************************
    //*                 Button Info                    *
	//**************************************************
    public int getBtnHeight()
    {
        return browseBtn.getSize().height;
    } //getBtnHeight
	
    public int getBtnWidth()
    {
        return browseBtn.getSize().width;
    } //getBtnWidth
    
    public Font getBtnFont()
    {
        return browseBtn.getFont();
    } //getBannerFont
    
	
	//**************************************************
    //*              bannerLbl Info                    *
	//**************************************************
	public int getBannerLblHeight ()
	{
	    return bannerLbl.getSize().height;
	} //getBannerLblHeight
	
	public int getBannerLblWidth ()
	{
	    return bannerLbl.getSize().width;
	} //getBannerLblWidth
	
    public Font getBannerLblFont()
    {
        return bannerLbl.getFont();
    } //getBannerFont
	
	
	//**************************************************
    //*              headerLbl Info                    *
	//**************************************************
	public int getHeaderLblHeight ()
	{
	    return headerLbl.getSize().height;
	} //getHeaderLblHeight
	
	public int getHeaderLblWidth ()
	{
	    return headerLbl.getSize().width;
	} //getHeaderLblWidth

    public Font getHeaderLblFont()
    {
        return headerLbl.getFont();
    } //getHeaderFont
    
    
	//**************************************************
    //*                 catLbl Info                    *
	//**************************************************
	public int getCatLblHeight()
	{
	    return catLbl.getSize().height;
	} //getCatLblHeight
	
	public int getCatLblWidth()
	{
	    return catLbl.getSize().width;
	} //getCatLblWidth

    public Font getCatLblFont()
    {
        return catLbl.getFont();
    } //getHeaderFont

	//**************************************************
    //*              firstLineLbl Info                 *
	//**************************************************
	public int getFirstLineLblHeight()
	{
	    return firstLineLbl.getSize().height;
	} //getFirstLineLblHeight
	
    public Font getFirstLineLblFont()
    {
        return firstLineLbl.getFont();
    } //getFirstLineLblFont

	//**************************************************
    //*              adSampleLbl Info                 *
	//**************************************************
	public int getAdSampleLblHeight()
	{
	    return adSampleLbl.getSize().height;
	} //getFirstLineLblHeight
	
    public Font getAdSampleLblFont()
    {
        return adSampleLbl.getFont();
    } //getFirstLineLblFont
	
	//**************************************************
    //*                 regularLbl Info                *
	//**************************************************
	public int getRegularLblHeight()
	{
	    return regularLbl.getSize().height;
	} //getRegularLblHeight
	
    public Font getRegularLblFont()
    {
        return regularLbl.getFont();
    } //getRegularLblHeight
	
	//**************************************************
    //*                 regularTF Info                *
	//**************************************************
	public int getRegularTFHeight()
	{
	    return regularTF.getSize().height;
	} //getRegularTFHeight
	
    public Font getRegularTFFont()
    {
        return regularTF.getFont();
    } //getRegularTFFont

	//**************************************************
    //*                 regularTA Info                *
	//**************************************************	
    public Font getRegularTAFont()
    {
        return regularTA.getFont();
    } //getRegularTFFont
	
	
	
	//**************************************************
    //*    Symantec Bean Stuff -- ignore this          *
	//**************************************************
	public synchronized void show()
	{
		move(50, 50);
		super.show();
	} //show
	
	public void addNotify()
	{
		// Record the size of the window prior to calling parents addNotify.
		Dimension d = getSize();

		super.addNotify();

		if (fComponentsAdjusted)
			return;

		// Adjust components according to the insets
		setSize(insets().left + insets().right + d.width, insets().top + insets().bottom + d.height);
		Component components[] = getComponents();
		for (int i = 0; i < components.length; i++)
			{
			Point p = components[i].getLocation();
			p.translate(insets().left, insets().top);
			components[i].setLocation(p);
		} //for
		fComponentsAdjusted = true;
	}

	// Used for addNotify check.
	boolean fComponentsAdjusted = false;

	
	//**************************************************
    //*          internal event class -- Window        *
	//**************************************************	
	class StyleBeanWinAdapter extends java.awt.event.WindowAdapter
	{
		public void windowClosing(java.awt.event.WindowEvent event)
		{
		    Object object = event.getSource();
		    if (object == StyleBean.this)
			    StyleBean_WindowClosing(event);
		} //windowClosing
	} //StyleBeanWinAdapter

	void StyleBean_WindowClosing(java.awt.event.WindowEvent event)
	{
		dispose();		 // dispose of the Frame.
	} //StyleBean_WindowClosing

} //StyleBean