/*
	A basic extension of the java.awt.Dialog class
 */

import java.awt.*;

import cooscale;
import cootimer;
public class Dialog1 extends Dialog
{
    int percent = 0;
	public Dialog1(Frame parent, java.applet.Applet applet, boolean modal)
	{
		super(parent, modal);

		// This code is automatically generated by Visual Cafe when you add
		// components to the visual environment. It instantiates and initializes
		// the components. To modify the code, only use code syntax that matches
		// what Visual Cafe can generate, or Visual Cafe may be unable to back
		// parse your Java file into its visual environment.
		//{{INIT_CONTROLS
		setLayout(null);
		setVisible(false);
		setSize(insets().left + insets().right + 243,insets().top + insets().bottom + 89);
		setBackground(new Color(12632256));
		cootimer1 = new cootimer();
		cootimer1.setRunTimer(true);
		//$$ cootimer1.move(0,0);
		try {
		ClassLoader cl = Class.forName("cooscale").getClassLoader();
		cooscale1 = (cooscale) java.beans.Beans.instantiate(cl, "cooscale");
		cooscale1.setLayout(null);
		cooscale1.setBounds(insets().left + 12,insets().top + 12,216,60);
		cooscale1.setBackground(new Color(12632256));
		add(cooscale1);
		cooscale1.start();
		} catch (Exception e) { }
		setTitle("Dialog1");
		//}}

		cooscale1.setApplet(applet);

		//{{REGISTER_LISTENERS
		SymWindow aSymWindow = new SymWindow();
		this.addWindowListener(aSymWindow);
		SymAction lSymAction = new SymAction();
		cootimer1.addActionListener(lSymAction);
		cooscale1.addActionListener(lSymAction);
		//}}
	}


	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);
		}
		fComponentsAdjusted = true;
	}

    // Used for addNotify check.
	boolean fComponentsAdjusted = false;




	public synchronized void show()
	{

		this.move(200,200);

		super.show();
	}

	//{{DECLARE_CONTROLS
	cootimer cootimer1;
	cooscale cooscale1;
	//}}

	class SymWindow extends java.awt.event.WindowAdapter
	{
		public void windowClosing(java.awt.event.WindowEvent event)
		{
			Object object = event.getSource();
			if (object == Dialog1.this)
				Dialog1_WindowClosing(event);
		}
	}

	void Dialog1_WindowClosing(java.awt.event.WindowEvent event)
	{
	    cooscale1.cancelAll();
		dispose();
	}

	class SymAction implements java.awt.event.ActionListener
	{
		public void actionPerformed(java.awt.event.ActionEvent event)
		{
			Object object = event.getSource();
			if (object == cootimer1)
				cootimer1_actionPerformed(event);
			else if (object == cooscale1)
				cooscale1_actionPerformed(event);
	
		}
	}

	void cootimer1_actionPerformed(java.awt.event.ActionEvent event)
	{
		// to do: code goes here.
		// to do: code goes here.
		percent++;
		if (percent>100)
		  percent=0;

		if (percent==10)
		{
		  cooscale1.m_enableTipsText = true;
		  cooscale1.setTipsText("You can display descriptions, advertisements, or instructions according to different percents");
		  cooscale1.showTips();
		}
	    else if (percent==20)
		{
		  cooscale1.m_enableTipsText = true;
		  cooscale1.setTipsText("A key thing to do when you insert this bean to your applet is that to call setAppelt after you show or start Cooscale. Go http://www.coolshare.com/html/src/caller_cs.java to see the sample codes.");
		  cooscale1.showTips();
		}
		else if (percent==30)
		{
		  cooscale1.m_enableTipsText = true;
		  cooscale1.setTipsText("Current version of Cooscale can be only used in applets. If you use it in an application, you will lose its sound and animation icon.");
		  cooscale1.showTips();
		}
		else if (percent==40)
		{
		  cooscale1.m_enableTipsText = true;
		  cooscale1.setTipsText("Cooscale will automatically remove the space for animation icon if it could not load images. It will also replace the original url text of the first image file with 'can't load image file'.  This occurs if you use it in an appliction or view it in BeanBox.");
		  cooscale1.showTips();
		}
		else if (percent==50)
		{
		  cooscale1.m_enableTipsText = true;
		  cooscale1.setTipsText("Cooscale will replace the original url text of the first image file with 'can't load audio file'. This occurs if you use it in an appliction or view it in BeanBox.");
		  cooscale1.showTips();
		}
		else if (percent==60)
		{
		  cooscale1.m_enableTipsText = true;
		  cooscale1.setTipsText("Cooscale comes with two versions: registered shareware version and Adware version. Adware version is FREE but its tooltips will display author's information and it will switch current page to author's home page if you click at it.");
		  cooscale1.showTips();
		}
		else if (percent==70)
		{
		  cooscale1.m_enableTipsText = true;
		  cooscale1.setTipsText("There are a lot of Java stuff in Mark Qian's www.coolshare.com: FREE Java applets, Java beans, screen savers....");
		  cooscale1.showTips();
		}
		else if (percent==80)
		{
		  cooscale1.m_enableTipsText = true;
		  cooscale1.setTipsText("Details for installation and donwloading latest version of Cooscale are available at http://www.coolshare.com/html/bean_cs.htm");
		  cooscale1.showTips();
		}
		else if (percent==90)
		{
		  cooscale1.m_enableTipsText = true;
		  cooscale1.setTipsText("The Cooscale on this page is driven by a timer bean to simulate a real process. Cooscale works on both IE(4.x) and Netscape(4.x). To view Cooscale demo with IE(4.x) please go http://www.coolshare.com/html/bean_cs.htm . To view Cooscale with Netscape(4.x) go http://www.coolshare.com/html/test_cs.htm .");
		  cooscale1.showTips();
		}
		
		//{{CONNECTION
		// setPercent...
		{
			cooscale1.setPercent(percent);
		}
		//}}
			 
		
	}

	
	public void stop()                                     
    { 
       cooscale1.cancelAll();
    }

	void cooscale1_actionPerformed(java.awt.event.ActionEvent event)
	{
		// to do: code goes here.
		percent = 0;	
		cooscale1.cancelAll();
		cootimer1.setRunTimer(false);
		//{{CONNECTION
		// Hide the Dialog
		dispose();
		//}}
	}
}
