/*
The code is available only to persons
currently affiliated with any of the following,
      o Universities and schools
      o Non-commercial research organizations
      o Registered not-for-profit organizations
      o Registered charities
For these people, the license is of the form of
the GNU Public License version 2.  The restrictions
must remain attached to this and any subsequently derived code.
All other people have no implicit right to use, read, or copy
this software unless granted by Mr. Deck
THIS SOFTWARE IS PROVIDED "AS IS" AND MR. DECK
MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
IMPLIED.  BY WAY OF EXAMPLE, BUT NOT LIMITATION, HE
MAKES NO REPRESENTATIONS OR WARRANTIES OF MERCHANT-
ABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE
OF THE LICENSED SOFTWARE AND DOCUMENTATION WILL NOT
INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR
*/

import java.awt.*;
import java.net.URL;


public class langPicker extends Canvas{
icontext it;

	public langPicker(icontext i){
	   this.it = i;
	   setWords(1);
	}


public void paint(Graphics g){
	g.setColor(Color.white);
	g.fillRect(0,0,size().width,size().height);
	g.setColor(Color.white);
	for(int i =0;i<5;i++){
	   g.fillRect(i*20,0,15,10);
	}
	g.setColor(Color.red);
	g.fillRect(0,0,5,10);
	g.setColor(Color.blue);
	g.fillRect(10,0,5,10);

	g.setColor(Color.red);
	g.fillRect(20,0,15,1);
	g.fillRect(20,2,15,1);
	g.fillRect(20,4,15,1);
	g.fillRect(20,6,15,1);
	g.fillRect(20,8,15,1);
	g.setColor(Color.blue);
	g.fillRect(20,0,6,5);

	g.setColor(Color.black);
	g.fillRect(40,0,15,4);
	g.setColor(Color.red);
	g.fillRect(40,4,15,4);
	g.setColor(Color.yellow);
	g.fillRect(40,7,15,3);

	g.setColor(Color.red);
	g.fillRect(60,0,15,3);
	g.setColor(Color.yellow);
	g.fillRect(60,3,15,4);
	g.setColor(Color.red);
	g.fillRect(60,7,15,4);

	g.fillOval(86,3,4,4);
	g.drawOval(86,3,4,4);
	g.setColor(Color.lightGray);
	g.drawRect(80,0,15,10);
	
}

public boolean mouseDown(Event e, int x, int y){
	setWords(x/20);
	String s = it.usrLab.getText();
	if(s.charAt(0)>='0' && s.charAt(0)<='9'){
		if(s.charAt(0)=='1')
		 it.usrLab.setText(s.substring(0,2)+env.user);
		else
		 it.usrLab.setText(s.substring(0,2)+env.users);
		 it.usrLab.repaint();
	}
	return true;
}

public void setWords(int i){
	switch (i){
	   case 0:	
		env.user = "utilisateur";
		env.users = "utilisateurs";
		env.serverdown = "Serveur plante";
		env.disconnected = "Débranché"; 
		env.reconnecting = "Se relier "; 
		env.tryreload = "Tappez 'Recharger'";
		env.overmax = "Trop de monde";
		env.welcome="Bienvenue";
		env.kcol = "/* Touche/Couleur  corrélations */";
		env.save= "/* Enregistration archival */";
		env.open= "/* Ouvrir icontexts */";
		env.nav= "/*   Aide-navigation   */";
		env.type= "/*  Changer sens du text  */";
		env.cpick= "Choisir couleurs";
		env.saveLbl= "Choisez le nom du icontext:";
		env.deriveLbl= "Ajoutez icontext a la série:";
		break;
	   case 1:
		env.user = "user";
		env.users = "users";
		env.serverdown = "Server down (?)";
		env.disconnected = "Disconnected"; 
		env.reconnecting = "Reconnecting"; 
		env.tryreload = "Try 'Reload'";
		env.overmax = "Over user max";
		env.welcome="Welcome";
		env.kcol = "/* Key  Color    relationships   */";
		env.save= "/*  Add icontext to archive  */";
		env.open= "/* Open icontexts */";
		env.nav= "/*   Navigation tool   */";
		env.type= "/*  Change typing direction */";
		env.cpick= "Color picker";
		env.saveLbl= "Please name your icontext:";
		env.deriveLbl= "Add icontext to series:";
		break;
           case 2:	
		env.user = "Benutzer";
		env.users = "Benuetzer";
		env.serverdown = "Server down";
		env.tryreload = "Neu laden klicken";
		env.reconnecting = "Neuanschluß"; 
		env.disconnected = "Getrennt"; 
		env.overmax = "über Benutzermax";
		env.welcome="Willkommen";
		env.kcol = "/*    Farberelationen    */";
		env.save= "/*   Icontext archivieren   */";
		env.open= "/*  Icontext öffnen  */";
		env.nav= "/*   Navigatïonshilfe   */";
		env.type= "/*  Schreibrichtung verändern */";
		env.cpick= "Farbwähler";
		env.saveLbl= "Wählen Sie bitte ein Namens:";
		env.deriveLbl= "Fügen Sie Bild Serien hinzu:";
		break;
           case 3:	
                env.user = "usuario";
                env.users = "usuarios";
		env.serverdown = "El Servidor no responde";
		env.tryreload = "Intente actualizar";
		env.reconnecting = "Restaurando la conexión"; 
		env.disconnected = "Desconectado"; 
		env.overmax = "Demasiados usuarios";
		env.welcome = "Bienvenido";
		env.kcol = "/* Tecla Color   correlaciónes   */";
		env.save= "/*  Añadir icontexto al archivo  */";
		env.open= "/* Abrir icontexts */";
		env.nav= "/*  Beneficio de navigación  */";
		env.type= "/*  Cambiar dirección del texto */";
		env.cpick= "Destacar colores";
		env.saveLbl= "Escoge el nombre del icontexto:";
		env.deriveLbl= "Añadir el icontexto a la serie:";
		break;
	   case 4:
		URL u=null;
  		try{
          	  u=new URL("http://"+env.host+"/icontext/html/helpJap.html");
                }catch(Exception ee){ee.printStackTrace();}
                    it.getAppletContext().showDocument(u);
		break;
	}
	it.usrLab.setText("/*  "+env.welcome+"  */");
  }

}
