home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / unuy2wen / cybcerone / control / controlpanel.java < prev    next >
Encoding:
Java Source  |  1996-08-14  |  3.0 KB  |  130 lines

  1. // ControlPanel.java
  2. // 19.03.96
  3. // 
  4. // the bar at the bottom
  5.  
  6. package cybcerone.control;
  7.  
  8. import java.awt.Rectangle;
  9. import java.awt.Event;
  10. import java.awt.Graphics;
  11. import java.util.Vector;
  12.  
  13. import cybcerone.utils.Appletlike;
  14. import cybcerone.utils.IdPanel;
  15. import cybcerone.utils.Mapable;
  16.  
  17. import cybcerone.main.MainPanel;
  18. import cybcerone.init.InitPanel;
  19.  
  20. /**
  21.  * The bar at the bottom of the screen that controls movement and a
  22.  * few other features.
  23.  */
  24. public class ControlPanel extends IdPanel {
  25.   private static final Rectangle placement = new Rectangle (0, 668, 1024, 100);
  26.   
  27.   private static final String id = "ControlPanel";
  28.   private static final String statusText = "";
  29.  
  30.   public static final String imagePath = "control/";
  31.   private static final String bgFile = imagePath + "barre_grise_ok.gif";
  32.  
  33.   private boolean buttonPressed;
  34.  
  35.   private UnilButton unil;
  36.   private ForwardButton forward;
  37.   private BackButton back;
  38.   private UrgencesButton urgences;
  39.  
  40.   private Rectangle help = scale (741, 5, 87, 95);
  41.   private Rectangle language = scale (897, 5, 87, 95);
  42.  
  43.   private Object current;
  44.  
  45.   public ControlPanel (Appletlike app) {
  46.     super (id, statusText, app);
  47.     reshape (placement);
  48.  
  49.     setBackground (bgFile, 0);
  50.  
  51.     add (new Clock (app));
  52.     add (unil = new UnilButton (app));
  53.     add (forward = new ForwardButton (this, app));
  54.     add (back = new BackButton (this, app));
  55.     add (urgences = new UrgencesButton (back, app));
  56.  
  57.     unil.setNext (MainPanel.id);
  58.     urgences.setNext (UrgencesPanel.id);
  59.     buttonPressed = false;
  60.   }
  61.  
  62.   /**
  63.    * This panel has been activated, take appropriate action.
  64.    */
  65.   public void update (String newPanelId) {
  66.     if (!newPanelId.equals (InitPanel.id)) {
  67.       unil.update (newPanelId);
  68.       urgences.update (newPanelId);
  69.       if (newPanelId.equals (MainPanel.id)) {
  70.     back.clear ();
  71.     current = null;
  72.       }
  73.       if (!buttonPressed) {
  74.     if (current != null)
  75.       back.update (current);
  76.     forward.clear ();
  77.       }
  78.       buttonPressed = false;
  79.       current = newPanelId;
  80.     }
  81.   }
  82.  
  83.   /**
  84.    * This Mapable object has been selected.
  85.    */
  86.   public void update (Mapable newMap) {
  87.     unil.enable ();
  88.     urgences.enable ();
  89.     if (!buttonPressed) {
  90.       if (current != null)
  91.     back.update (current);
  92.       forward.clear ();
  93.     }
  94.     buttonPressed = false;
  95.     current = newMap;
  96.   }
  97.  
  98.   /**
  99.    * Go forward 1 screen (must have gone back first).
  100.    */
  101.   void goForward (Object panelId) {
  102.     buttonPressed = true;
  103.     back.update (current);
  104.     app.update (panelId);
  105.   }
  106.  
  107.   /**
  108.    * Go back 1 screen.
  109.    */
  110.   void goBack (Object panelId) {
  111.     buttonPressed = true;
  112.     forward.update (current);
  113.     app.update (panelId);
  114.   }
  115.  
  116.   /**
  117.    * Keep the user informed of coming features.
  118.    */
  119.   public boolean mouseMove (Event evt, int x, int y) {
  120.     if (help.inside (x, y))
  121.       app.showStatus ("Help system pending");
  122.     else if (language.inside (x, y))
  123.       app.showStatus ("Multiple language support pending");
  124.     else if (locate (x, y) == null)
  125.       app.showStatus (statusText);
  126.     return true;
  127.   }
  128.   
  129. }
  130.