home *** CD-ROM | disk | FTP | other *** search
/ Print Shop Ensemble 3 / the-print-shop-ensemble-iii.iso / worldnet / disk2 / java.z / MOZ2_01.ZIP / netscape / applet / MozillaFrame.class (.txt) < prev    next >
Encoding:
Java Class File  |  1996-03-08  |  2.7 KB  |  80 lines

  1. package netscape.applet;
  2.  
  3. import java.io.PrintStream;
  4. import java.util.Enumeration;
  5. import java.util.Vector;
  6.  
  7. class MozillaFrame {
  8.    int MWContext;
  9.    int oldMWContext;
  10.    MozillaWindow window;
  11.    Vector history;
  12.    HistoryElement current;
  13.  
  14.    MozillaFrame(MozillaWindow window, int MWContext) {
  15.       if (MozillaAppletContext.debug > 0) {
  16.          System.err.println("# New frame " + MWContext);
  17.       }
  18.  
  19.       this.MWContext = MWContext;
  20.       this.window = window;
  21.       window.add(this);
  22.       this.history = new Vector();
  23.    }
  24.  
  25.    void setCurrent(HistoryElement h) {
  26.       this.current = h;
  27.    }
  28.  
  29.    void add(HistoryElement h) {
  30.       this.history.addElement(h);
  31.    }
  32.  
  33.    void remove(HistoryElement h) {
  34.       this.history.removeElement(h);
  35.       if (h == this.current) {
  36.          this.current = null;
  37.       }
  38.  
  39.       if (this.history.size() == 0) {
  40.          if (MozillaAppletContext.debug > 0) {
  41.             System.err.println("# Destroy frame " + this.MWContext + " (old=" + this.oldMWContext + ")");
  42.          }
  43.  
  44.          this.MWContext = this.oldMWContext;
  45.          this.window.remove(this);
  46.       }
  47.  
  48.    }
  49.  
  50.    void setMWContext(int newFrameMWContext) {
  51.       if (newFrameMWContext != this.MWContext) {
  52.          if (newFrameMWContext == 0) {
  53.             this.oldMWContext = this.MWContext;
  54.             this.MWContext = 0;
  55.             return;
  56.          }
  57.  
  58.          if (this.oldMWContext != newFrameMWContext) {
  59.             this.window.change(this, this.oldMWContext, newFrameMWContext);
  60.          }
  61.  
  62.          this.MWContext = newFrameMWContext;
  63.          this.oldMWContext = 0;
  64.       }
  65.  
  66.    }
  67.  
  68.    void dumpState(PrintStream out, int i) {
  69.       MozillaWindow.indent(out, i);
  70.       out.println("MozillaFrame MWContext=" + this.MWContext + " oldMWContext=" + this.oldMWContext + " (" + this.history.size() + " history elements) current=" + (this.current != null ? this.current.id : -1));
  71.       Enumeration e = this.history.elements();
  72.  
  73.       while(e.hasMoreElements()) {
  74.          HistoryElement h = (HistoryElement)e.nextElement();
  75.          h.dumpState(out, i + 1);
  76.       }
  77.  
  78.    }
  79. }
  80.