home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 139 / dpcs0999.iso / Web / CFserver / data1.cab / Java / netscape / application / RootView.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-04-12  |  30.5 KB  |  1,786 lines

  1. package netscape.application;
  2.  
  3. import java.awt.Component;
  4. import netscape.util.InconsistencyException;
  5. import netscape.util.Vector;
  6.  
  7. public class RootView extends View implements EventProcessor, ExtendedTarget {
  8.    Color _backgroundColor;
  9.    Image _image;
  10.    FoundationPanel panel;
  11.    Application application;
  12.    Timer _autoscrollTimer;
  13.    ColorChooser colorChooser;
  14.    FontChooser fontChooser;
  15.    InternalWindow _mainWindow;
  16.    View _mouseView;
  17.    View _moveView;
  18.    View _focusedView;
  19.    View _windowClipView;
  20.    View _mouseClickView;
  21.    View _rootViewFocusedView;
  22.    View _selectedView;
  23.    View _defaultSelectedView;
  24.    Vector windows;
  25.    long _lastClickTime;
  26.    int _clickCount;
  27.    int _mouseX;
  28.    int _mouseY;
  29.    int _currentCursor;
  30.    int _viewCursor;
  31.    int _overrideCursor;
  32.    int mouseDownCount;
  33.    int _imageDisplayStyle;
  34.    Vector dirtyViews;
  35.    boolean _redrawTransWindows;
  36.    boolean recomputeCursor;
  37.    boolean recomputeMoveView;
  38.    boolean isVisible;
  39.    boolean redrawAll;
  40.    Vector componentViews;
  41.    MouseFilter mouseFilter;
  42.    static Vector _commands = new Vector();
  43.    static final String VALIDATE_SELECTED_VIEW = "validateSelectedView";
  44.  
  45.    public RootView() {
  46.       this(0, 0, 0, 0);
  47.    }
  48.  
  49.    public RootView(Rect var1) {
  50.       this(var1.x, var1.y, var1.width, var1.height);
  51.    }
  52.  
  53.    public RootView(int var1, int var2, int var3, int var4) {
  54.       super(var1, var2, var3, var4);
  55.       this.windows = new Vector();
  56.       this._overrideCursor = -1;
  57.       this.dirtyViews = new Vector();
  58.       this._redrawTransWindows = true;
  59.       this.redrawAll = true;
  60.       this.mouseFilter = new MouseFilter();
  61.       this._backgroundColor = Color.gray;
  62.       this.application = Application.application();
  63.       this._defaultSelectedView = this;
  64.    }
  65.  
  66.    void addWindowRelativeTo(InternalWindow var1, int var2, InternalWindow var3) {
  67.       if (var1 != null) {
  68.          if (this._windowClipView != null && var1.layer() < 500) {
  69.             this._windowClipView.addSubview(var1);
  70.          } else {
  71.             ((View)this).addSubview(var1);
  72.          }
  73.  
  74.          this.makeWindowVisible(var1, var2, var3);
  75.       }
  76.    }
  77.  
  78.    void removeWindow(InternalWindow var1) {
  79.       if (var1 != null) {
  80.          Rect var4 = this.absoluteWindowBounds(var1);
  81.          ((View)var1).removeFromSuperview();
  82.          int var3 = this.windows.indexOf(var1) - 1;
  83.          if (var3 < 0) {
  84.             this.windows.indexOf(var1);
  85.          }
  86.  
  87.          this.windows.removeElement(var1);
  88.          if (var1 == this._mainWindow) {
  89.             InternalWindow var2 = null;
  90.  
  91.             for(int var5 = this.windows.count() - 1; var5 >= 0; --var5) {
  92.                if (((InternalWindow)this.windows.elementAt(var5)).canBecomeMain()) {
  93.                   var2 = (InternalWindow)this.windows.elementAt(var5);
  94.                   break;
  95.                }
  96.             }
  97.  
  98.             this._setMainWindow(var2);
  99.          }
  100.  
  101.          this.redraw(var4);
  102.          this.redrawTransparentWindows(var4, (InternalWindow)null);
  103.          if (!(var1 instanceof KeyboardArrow)) {
  104.             this.validateSelectedView();
  105.          }
  106.  
  107.          this.createMouseEnterLater();
  108.       }
  109.    }
  110.  
  111.    public Vector internalWindows() {
  112.       return this.windows;
  113.    }
  114.  
  115.    public InternalWindow mainWindow() {
  116.       return this._mainWindow;
  117.    }
  118.  
  119.    void _setMainWindow(InternalWindow var1) {
  120.       if (this._mainWindow != var1 && (var1 == null || var1.canBecomeMain())) {
  121.          InternalWindow var2 = this._mainWindow;
  122.          this._mainWindow = var1;
  123.          if (var2 != null) {
  124.             var2.didResignMain();
  125.          } else if (this._focusedView != null && !this.isInWindow(this._focusedView)) {
  126.             this._rootViewFocusedView = this._focusedView;
  127.             this.setFocusedView((View)null, false);
  128.          }
  129.  
  130.          if (this._mainWindow != null) {
  131.             this._mainWindow.didBecomeMain();
  132.          } else if (this.rootViewFocusedView() != null) {
  133.             this.setFocusedView(this.rootViewFocusedView(), false);
  134.             this._rootViewFocusedView = null;
  135.          }
  136.  
  137.          this.validateSelectedView();
  138.          this.createMouseEnterLater();
  139.       }
  140.    }
  141.  
  142.    InternalWindow frontWindowWithLayer(int var1) {
  143.       for(int var2 = this.windows.count() - 1; var2 >= 0; --var2) {
  144.          InternalWindow var3 = (InternalWindow)this.windows.elementAt(var2);
  145.          if (var3.layer() == var1) {
  146.             return var3;
  147.          }
  148.       }
  149.  
  150.       return null;
  151.    }
  152.  
  153.    InternalWindow backWindowWithLayer(int var1) {
  154.       int var3 = this.windows.count();
  155.  
  156.       for(int var2 = 0; var2 < var3; ++var2) {
  157.          InternalWindow var4 = (InternalWindow)this.windows.elementAt(var2);
  158.          if (var4.layer() == var1) {
  159.             return var4;
  160.          }
  161.       }
  162.  
  163.       return null;
  164.    }
  165.  
  166.    void makeWindowVisible(InternalWindow var1, int var2, InternalWindow var3) {
  167.       InternalWindow var4 = null;
  168.       if (var1 != null) {
  169.          if (((View)var1).descendsFrom(this)) {
  170.             int var5 = this.windows.indexOf(var1);
  171.             int var6 = var1.layer();
  172.             if (var3 != null) {
  173.                if (var3.layer() > var6) {
  174.                   var3 = null;
  175.                   var2 = 0;
  176.                } else if (var3.layer() < var6) {
  177.                   var3 = null;
  178.                   var2 = 1;
  179.                }
  180.             }
  181.  
  182.             this.windows.removeElement(var1);
  183.             if (var3 != null) {
  184.                boolean var8;
  185.                if (var2 == 0) {
  186.                   var8 = this.windows.insertElementAfter(var1, var3);
  187.                } else {
  188.                   var8 = this.windows.insertElementBefore(var1, var3);
  189.                }
  190.  
  191.                if (var8) {
  192.                   this._setMainWindow(var1);
  193.                   if (var5 != this.windows.indexOf(var1)) {
  194.                      ((View)var1).draw();
  195.                      this.updateTransWindows(var1);
  196.                      if (var2 == 1) {
  197.                         this.updateWindowsAbove(var1);
  198.                      }
  199.                   }
  200.  
  201.                   return;
  202.                }
  203.  
  204.                Object var10 = null;
  205.             }
  206.  
  207.             int var7 = this.windows.count();
  208.  
  209.             while(var7-- > 0) {
  210.                var4 = (InternalWindow)this.windows.elementAt(var7);
  211.                if (var4.layer() <= var6 && var4.layer() <= var6) {
  212.                   break;
  213.                }
  214.             }
  215.  
  216.             boolean var9;
  217.             if (var4 == null) {
  218.                this.windows.insertElementAt(var1, 0);
  219.                var9 = true;
  220.             } else if (var4.layer() > var6) {
  221.                var9 = this.windows.insertElementBefore(var1, var4);
  222.             } else {
  223.                var9 = this.windows.insertElementAfter(var1, var4);
  224.             }
  225.  
  226.             if (!var9) {
  227.                this.windows.insertElementAt(var1, 0);
  228.             }
  229.  
  230.             this._setMainWindow(var1);
  231.             if (var5 != this.windows.indexOf(var1)) {
  232.                ((View)var1).draw();
  233.                this.updateTransWindows(var1);
  234.             }
  235.  
  236.          }
  237.       }
  238.    }
  239.  
  240.    void updateWindowsAbove(InternalWindow var1) {
  241.       Rect var6 = this.absoluteWindowBounds(var1);
  242.       int var5 = this.windows.indexOf(var1);
  243.       Rect var8 = new Rect();
  244.       int var3 = var5 + 1;
  245.  
  246.       for(int var4 = this.windows.count(); var3 < var4; ++var3) {
  247.          InternalWindow var2 = (InternalWindow)this.windows.elementAt(var3);
  248.          Rect var7 = this.absoluteWindowBounds(var2);
  249.          if (var6.intersects(var7)) {
  250.             var8.setBounds(var6);
  251.             var8.intersectWith(var7);
  252.             ((View)this).convertRectToView(var2, var8, var8);
  253.             ((View)var2).addDirtyRect(var8);
  254.          }
  255.       }
  256.  
  257.    }
  258.  
  259.    void updateTransWindows(InternalWindow var1) {
  260.       if (var1 != null) {
  261.          int var5 = this.windows.indexOf(var1);
  262.          Rect var3 = ((View)var1).superview().convertRectToView(this, var1.bounds);
  263.  
  264.          for(int var4 = 0; var4 < var5; ++var4) {
  265.             InternalWindow var2 = (InternalWindow)this.windows.elementAt(var4);
  266.             if (var2.isTransparent()) {
  267.                Rect var6 = this.absoluteWindowBounds(var2);
  268.                if (var6.intersects(var3) || var3.intersects(var6)) {
  269.                   var2.updateDrawingBuffer();
  270.                }
  271.             }
  272.          }
  273.  
  274.       }
  275.    }
  276.  
  277.    void disableWindowsAbove(InternalWindow var1, boolean var2) {
  278.       if (var1 != null) {
  279.          int var4 = this.windows.indexOf(var1);
  280.          if (var4 != -1) {
  281.             for(int var5 = this.windows.count(); var4 < var5; ++var4) {
  282.                InternalWindow var3 = (InternalWindow)this.windows.elementAt(var4);
  283.                if (var2) {
  284.                   ((View)var3).disableDrawing();
  285.                } else {
  286.                   ((View)var3).reenableDrawing();
  287.                }
  288.             }
  289.  
  290.          }
  291.       }
  292.    }
  293.  
  294.    Vector windowRects(Rect var1, InternalWindow var2) {
  295.       Vector var4 = null;
  296.       int var6 = this.windows.count();
  297.       int var5;
  298.       if (var2 != null) {
  299.          var5 = this.windows.indexOf(var2) + 1;
  300.       } else {
  301.          var5 = 0;
  302.       }
  303.  
  304.       for(; var5 < var6; ++var5) {
  305.          InternalWindow var3 = (InternalWindow)this.windows.elementAt(var5);
  306.          Rect var7 = this.absoluteWindowBounds(var3);
  307.          if (var7.intersects(var1) || var1.intersects(var7)) {
  308.             if (var4 == null) {
  309.                var4 = VectorCache.newVector();
  310.             }
  311.  
  312.             var4.addElement(new Rect(var7));
  313.          }
  314.       }
  315.  
  316.       return var4;
  317.    }
  318.  
  319.    void setRedrawTransparentWindows(boolean var1) {
  320.       this._redrawTransWindows = var1;
  321.    }
  322.  
  323.    public void redrawTransparentWindows(Rect var1, InternalWindow var2) {
  324.       this.redrawTransparentWindows((Graphics)null, var1, var2);
  325.    }
  326.  
  327.    public void redrawTransparentWindows(Graphics var1, Rect var2, InternalWindow var3) {
  328.       Rect var7 = null;
  329.       if (this._redrawTransWindows) {
  330.          int var6 = this.windows.count();
  331.          int var5;
  332.          if (var3 != null) {
  333.             var5 = this.windows.indexOf(var3) + 1;
  334.          } else {
  335.             var5 = 0;
  336.          }
  337.  
  338.          for(; var5 < var6; ++var5) {
  339.             InternalWindow var4 = (InternalWindow)this.windows.elementAt(var5);
  340.             if (var4.isTransparent()) {
  341.                Rect var8 = this.absoluteWindowBounds(var4);
  342.                if (var8.intersects(var2)) {
  343.                   if (var7 == null) {
  344.                      var7 = Rect.newRect();
  345.                   }
  346.  
  347.                   ((View)this).convertRectToView(var4, var2, var7);
  348.                   var4.draw(var1, var7);
  349.                }
  350.             }
  351.          }
  352.  
  353.          if (var7 != null) {
  354.             Rect.returnRect(var7);
  355.          }
  356.  
  357.       }
  358.    }
  359.  
  360.    void paint(ApplicationEvent var1) {
  361.       UpdateFilter var2 = new UpdateFilter(var1.rect());
  362.       var2.rootView = this;
  363.  
  364.       try {
  365.          Thread.sleep(100L);
  366.       } catch (InterruptedException var4) {
  367.       }
  368.  
  369.       this.application.eventLoop().filterEvents(var2);
  370.       if (this.redrawAll) {
  371.          Rect var3 = Rect.newRect(0, 0, super.bounds.width, super.bounds.height);
  372.          this.redraw(var3);
  373.          this.redrawTransparentWindows(var3, (InternalWindow)null);
  374.          Rect.returnRect(var3);
  375.       } else {
  376.          this.redraw(var2._rect);
  377.          this.redrawTransparentWindows(var2._rect, (InternalWindow)null);
  378.       }
  379.  
  380.       AWTCompatibility.awtToolkit().sync();
  381.    }
  382.  
  383.    void print(ApplicationEvent var1) {
  384.       Rect var2 = new Rect(0, 0, ((View)this).width(), ((View)this).height());
  385.       Graphics var3 = new Graphics(var2, var1.graphics());
  386.       this.redraw(var3, var2);
  387.       this.redrawTransparentWindows(var3, var2, (InternalWindow)null);
  388.    }
  389.  
  390.    void resize(ApplicationEvent var1) {
  391.       ResizeFilter var2 = new ResizeFilter();
  392.  
  393.       try {
  394.          Thread.sleep(50L);
  395.       } catch (InterruptedException var3) {
  396.       }
  397.  
  398.       var2.lastEvent = var1;
  399.       this.application.eventLoop().filterEvents(var2);
  400.       ((View)this).sizeTo(var2.lastEvent.rect().width, var2.lastEvent.rect().height);
  401.    }
  402.  
  403.    public void setMouseView(View var1) {
  404.       this._mouseView = var1;
  405.    }
  406.  
  407.    public View mouseView() {
  408.       return this._mouseView;
  409.    }
  410.  
  411.    public View viewForMouse(int var1, int var2) {
  412.       View var4 = null;
  413.  
  414.       InternalWindow var3;
  415.       Rect var6;
  416.       for(int var5 = this.windows.count(); var5-- > 0 && var4 == null; var4 = var3.viewForMouse(var1 - var6.x, var2 - var6.y)) {
  417.          var3 = (InternalWindow)this.windows.elementAt(var5);
  418.          var6 = this.absoluteWindowBounds(var3);
  419.       }
  420.  
  421.       return var4 != null ? var4 : super.viewForMouse(var1, var2);
  422.    }
  423.  
  424.    void _mouseDown(MouseEvent var1) {
  425.       ++this.mouseDownCount;
  426.       if (this.mouseDownCount <= 1) {
  427.          View var3 = this.viewForMouse(var1.x, var1.y);
  428.          if (var3 == null) {
  429.             this._mouseView = null;
  430.          } else {
  431.             long var5 = var1.timeStamp;
  432.             if (this._mouseClickView == var3 && var5 - this._lastClickTime < 250L) {
  433.                ++this._clickCount;
  434.             } else {
  435.                this._clickCount = 1;
  436.             }
  437.  
  438.             this._lastClickTime = var5;
  439.             var1.setClickCount(this._clickCount);
  440.             this._mouseView = this._mouseClickView = var3;
  441.             if (!this.viewExcludedFromModalSession(var3)) {
  442.                if (!(this._mouseView instanceof InternalWindow)) {
  443.                   InternalWindow var2 = this._mouseView.window();
  444.                   if (!(this._mouseView instanceof MenuView) || var2 != null) {
  445.                      this._setMainWindow(var2);
  446.                   }
  447.                }
  448.  
  449.                var1.x -= this._mouseView.absoluteX();
  450.                var1.y -= this._mouseView.absoluteY();
  451.                View var4 = this._mouseView;
  452.                if (!this._mouseView.mouseDown(var1) && var4 == this._mouseView) {
  453.                   this._mouseView = null;
  454.                }
  455.  
  456.             }
  457.          }
  458.       }
  459.    }
  460.  
  461.    public boolean isVisible() {
  462.       return this.isVisible;
  463.    }
  464.  
  465.    void setVisible(boolean var1) {
  466.       if (this.isVisible != var1) {
  467.          this.isVisible = var1;
  468.          if (this.isVisible) {
  469.             ((View)this).ancestorWasAddedToViewHierarchy(this);
  470.             if (this._focusedView != null) {
  471.                this._focusedView._startFocus();
  472.                Application.application().focusChanged(this._focusedView);
  473.                return;
  474.             }
  475.          } else {
  476.             ((View)this).ancestorWillRemoveFromViewHierarchy(this);
  477.             if (this._focusedView != null) {
  478.                this._focusedView._pauseFocus();
  479.             }
  480.          }
  481.       }
  482.  
  483.    }
  484.  
  485.    void _mouseDrag(MouseEvent var1) {
  486.       if (!this.viewExcludedFromModalSession(this._mouseView)) {
  487.          if (this._mouseView != null) {
  488.             boolean var3 = this._mouseView.containsPointInVisibleRect(var1.x, var1.y);
  489.             if (this._mouseView.wantsAutoscrollEvents() && !var3) {
  490.                if (this._autoscrollTimer == null) {
  491.                   Autoscroller var4 = new Autoscroller();
  492.                   this._autoscrollTimer = new Timer(var4, "autoscroll", 100);
  493.                   this._autoscrollTimer.start();
  494.                   this._autoscrollTimer.setData(this._mouseView);
  495.                   var4.setEvent(this._mouseView.convertEventToView((View)null, var1));
  496.                } else {
  497.                   Autoscroller var2 = (Autoscroller)this._autoscrollTimer.target();
  498.                   var2.setEvent(this._mouseView.convertEventToView((View)null, var1));
  499.                }
  500.             } else {
  501.                if (this._autoscrollTimer != null) {
  502.                   this._autoscrollTimer.stop();
  503.                   this._autoscrollTimer = null;
  504.                }
  505.  
  506.                var1.setClickCount(this._clickCount);
  507.                this._mouseView.mouseDragged(var1);
  508.             }
  509.          } else {
  510.             if (this._autoscrollTimer != null) {
  511.                this._autoscrollTimer.stop();
  512.                this._autoscrollTimer = null;
  513.             }
  514.  
  515.          }
  516.       }
  517.    }
  518.  
  519.    void _mouseUp(MouseEvent var1) {
  520.       --this.mouseDownCount;
  521.       if (this.mouseDownCount <= 0) {
  522.          if (!this.viewExcludedFromModalSession(this._mouseView)) {
  523.             if (this._mouseView != null) {
  524.                var1.setClickCount(this._clickCount);
  525.                this._mouseView.mouseUp(var1);
  526.                if (this._autoscrollTimer != null) {
  527.                   this._autoscrollTimer.stop();
  528.                   this._autoscrollTimer = null;
  529.                }
  530.             }
  531.  
  532.             View var2 = this.viewForMouse(this._mouseX, this._mouseY);
  533.             if (var2 != this._moveView) {
  534.                this.createMouseEnter();
  535.             }
  536.  
  537.             this._mouseClickView = this._mouseView;
  538.             this._mouseView = null;
  539.          }
  540.       }
  541.    }
  542.  
  543.    void createMouseEnter() {
  544.       MouseEvent var1 = new MouseEvent(System.currentTimeMillis(), -4, this._mouseX, this._mouseY, 0);
  545.       this._mouseEnter(var1);
  546.    }
  547.  
  548.    void createMouseEnterLater() {
  549.       if (this._mouseView == null) {
  550.          this.recomputeMoveView = true;
  551.       }
  552.  
  553.    }
  554.  
  555.    void _mouseEnter(MouseEvent var1) {
  556.       this._mouseMove(var1);
  557.    }
  558.  
  559.    void _mouseMove(MouseEvent var1) {
  560.       View var2 = this.viewForMouse(var1.x, var1.y);
  561.       if (!this.viewExcludedFromModalSession(var2)) {
  562.          if (var2 == this._moveView) {
  563.             if (this._moveView == null) {
  564.                return;
  565.             }
  566.  
  567.             MouseEvent var4 = ((View)this).convertEventToView(this._moveView, var1);
  568.             this._moveView.mouseMoved(var4);
  569.          } else {
  570.             View var3 = this._moveView;
  571.             this._moveView = var2;
  572.             if (var3 != null) {
  573.                MouseEvent var5 = ((View)this).convertEventToView(var3, var1);
  574.                ((Event)var5).setType(-6);
  575.                var3.mouseExited(var5);
  576.             }
  577.  
  578.             if (this._moveView != null) {
  579.                MouseEvent var6 = ((View)this).convertEventToView(this._moveView, var1);
  580.                ((Event)var6).setType(-4);
  581.                this._moveView.mouseEntered(var6);
  582.             }
  583.          }
  584.  
  585.          this.updateCursorLater();
  586.       }
  587.    }
  588.  
  589.    void _mouseExit(MouseEvent var1) {
  590.       if (this._moveView != null) {
  591.          this._moveView.mouseExited(((View)this).convertEventToView(this._moveView, var1));
  592.          this._moveView = null;
  593.          this.updateCursorLater();
  594.       }
  595.  
  596.    }
  597.  
  598.    void flushCursor() {
  599.       int var1;
  600.       if (this._overrideCursor != -1) {
  601.          var1 = this._overrideCursor;
  602.       } else {
  603.          var1 = this._viewCursor;
  604.       }
  605.  
  606.       if (var1 != this._currentCursor) {
  607.          this.panel.setCursor(var1);
  608.          this._currentCursor = var1;
  609.       }
  610.  
  611.    }
  612.  
  613.    void computeCursor() {
  614.       View var1 = this.viewForMouse(this._mouseX, this._mouseY);
  615.       if (var1 != null) {
  616.          Point var2 = Point.newPoint();
  617.          ((View)this).convertToView(var1, this._mouseX, this._mouseY, var2);
  618.          this._viewCursor = var1.cursorForPoint(var2.x, var2.y);
  619.          Point.returnPoint(var2);
  620.       } else {
  621.          this._viewCursor = 0;
  622.       }
  623.  
  624.       this.flushCursor();
  625.    }
  626.  
  627.    public int cursor() {
  628.       return this._currentCursor;
  629.    }
  630.  
  631.    public void setOverrideCursor(int var1) {
  632.       if (var1 >= -1 && var1 <= 13) {
  633.          if (this._overrideCursor != var1) {
  634.             this._overrideCursor = var1;
  635.             this.flushCursor();
  636.          }
  637.  
  638.       } else {
  639.          throw new InconsistencyException("Unknown cursor type: " + var1);
  640.       }
  641.    }
  642.  
  643.    public void removeOverrideCursor() {
  644.       this.setOverrideCursor(-1);
  645.    }
  646.  
  647.    public void updateCursor() {
  648.       this.computeCursor();
  649.    }
  650.  
  651.    public void updateCursorLater() {
  652.       this.recomputeCursor = true;
  653.    }
  654.  
  655.    void _updateCursorAndMoveView() {
  656.       if (this.recomputeMoveView) {
  657.          this.createMouseEnter();
  658.          this.recomputeMoveView = false;
  659.          this.recomputeCursor = false;
  660.       } else {
  661.          if (this.recomputeCursor) {
  662.             this.computeCursor();
  663.             this.recomputeCursor = false;
  664.          }
  665.  
  666.       }
  667.    }
  668.  
  669.    void _keyDown(KeyEvent var1) {
  670.       boolean var4 = false;
  671.       Object var5 = null;
  672.       View var2 = this._focusedView;
  673.       ExternalWindow var3 = this.externalWindow();
  674.       if (var3 != null && var3.menu() != null) {
  675.          if (JDK11AirLock.menuShortcutExists()) {
  676.             MenuItem var6 = var3.menu().itemForKeyEvent(var1);
  677.             if (var6 != null) {
  678.                var4 = true;
  679.             }
  680.          } else {
  681.             var4 = var3.menu().handleCommandKeyEvent(var1);
  682.          }
  683.       }
  684.  
  685.       if (!var4) {
  686.          if (this.processKeyboardEvent(var1, true)) {
  687.             return;
  688.          }
  689.  
  690.          if (var2 != null && !this.viewExcludedFromModalSession(var2)) {
  691.             var2.keyDown(var1);
  692.             return;
  693.          }
  694.  
  695.          this.application().keyDown(var1);
  696.       }
  697.  
  698.    }
  699.  
  700.    void _keyUp(KeyEvent var1) {
  701.       View var2 = this._focusedView;
  702.       if (var2 != null && !this.viewExcludedFromModalSession(var2)) {
  703.          var2.keyUp(var1);
  704.       } else {
  705.          this.application().keyUp(var1);
  706.       }
  707.    }
  708.  
  709.    public void showColorChooser() {
  710.       this.colorChooser().show();
  711.    }
  712.  
  713.    public ColorChooser colorChooser() {
  714.       if (this.colorChooser == null) {
  715.          InternalWindow var1 = new InternalWindow(0, 0, 10, 10);
  716.          var1.setRootView(this);
  717.          this.colorChooser = new ColorChooser();
  718.          this.colorChooser.setWindow(var1);
  719.          var1.center();
  720.       }
  721.  
  722.       return this.colorChooser;
  723.    }
  724.  
  725.    public void showFontChooser() {
  726.       this.fontChooser().show();
  727.    }
  728.  
  729.    public FontChooser fontChooser() {
  730.       if (this.fontChooser == null) {
  731.          InternalWindow var1 = new InternalWindow(0, 0, 1, 1);
  732.          var1.setRootView(this);
  733.          this.fontChooser = new FontChooser();
  734.          this.fontChooser.setWindow(var1);
  735.          var1.center();
  736.       }
  737.  
  738.       return this.fontChooser;
  739.    }
  740.  
  741.    public ExternalWindow externalWindow() {
  742.       for(Object var1 = this.panel; var1 != null; var1 = ((Component)var1).getParent()) {
  743.          if (var1 instanceof FoundationFrame) {
  744.             return ((FoundationFrame)var1).externalWindow;
  745.          }
  746.  
  747.          if (var1 instanceof FoundationDialog) {
  748.             return ((FoundationDialog)var1).externalWindow;
  749.          }
  750.  
  751.          if (var1 instanceof FoundationWindow) {
  752.             return ((FoundationWindow)var1).externalWindow;
  753.          }
  754.       }
  755.  
  756.       return null;
  757.    }
  758.  
  759.    MouseEvent removeMouseEvents(MouseEvent var1) {
  760.       MouseEvent var2 = (MouseEvent)this.application.eventLoop().filterEvents(this.mouseFilter);
  761.       return var2 != null ? var2 : var1;
  762.    }
  763.  
  764.    void _convertMouseEventToMouseView(MouseEvent var1) {
  765.       if (this._mouseView != null && var1 != null) {
  766.          Point var2 = Point.newPoint();
  767.          ((View)this).convertToView(this._mouseView, var1.x, var1.y, var2);
  768.          var1.x = var2.x;
  769.          var1.y = var2.y;
  770.          Point.returnPoint(var2);
  771.       }
  772.    }
  773.  
  774.    public void processEvent(Event var1) {
  775.       if (this.application != null) {
  776.          if (var1 instanceof MouseEvent) {
  777.             MouseEvent var2 = (MouseEvent)var1;
  778.             int var3 = var2.type;
  779.             if (var3 == -5 && this.mouseDownCount > 0 && this._mouseView != null) {
  780.                MouseEvent var4 = ((View)this).convertEventToView(this._mouseView, var2);
  781.                ((Event)var4).setType(-3);
  782.                this._mouseUp(var4);
  783.             }
  784.  
  785.             if (var3 == -2 && this._mouseView != null && this._mouseView.wantsMouseEventCoalescing()) {
  786.                var2 = this.removeMouseEvents(var2);
  787.                var3 = ((Event)var2).type();
  788.             } else if (var3 == -5 && this._moveView != null && this._moveView.wantsMouseEventCoalescing()) {
  789.                var2 = this.removeMouseEvents(var2);
  790.                var3 = ((Event)var2).type();
  791.             }
  792.  
  793.             this._mouseX = var2.x;
  794.             this._mouseY = var2.y;
  795.             switch (var3) {
  796.                case -6:
  797.                   if (this._mouseView == null) {
  798.                      this._mouseExit(var2);
  799.                      return;
  800.                   }
  801.                   break;
  802.                case -5:
  803.                   this._mouseMove(var2);
  804.                   return;
  805.                case -4:
  806.                   if (this._mouseView == null) {
  807.                      this._mouseEnter(var2);
  808.                      return;
  809.                   }
  810.                   break;
  811.                case -3:
  812.                   this._convertMouseEventToMouseView(var2);
  813.                   this._mouseUp(var2);
  814.                   return;
  815.                case -2:
  816.                   this._convertMouseEventToMouseView(var2);
  817.                   this._mouseDrag(var2);
  818.                   return;
  819.                case -1:
  820.                   if (this.application.firstRootView() != this) {
  821.                      this.application.makeFirstRootView(this);
  822.                   }
  823.  
  824.                   this._mouseDown(var2);
  825.                   return;
  826.             }
  827.          } else {
  828.             if (var1 instanceof KeyEvent) {
  829.                KeyEvent var9 = (KeyEvent)var1;
  830.                if (this.application.firstRootView() != this) {
  831.                   this.application.makeFirstRootView(this);
  832.                }
  833.  
  834.                if (var9.type == -11) {
  835.                   this._keyDown(var9);
  836.                   return;
  837.                }
  838.  
  839.                this._keyUp(var9);
  840.                return;
  841.             }
  842.  
  843.             if (var1 instanceof ApplicationEvent) {
  844.                ExternalWindow var6 = null;
  845.                switch (var1.type) {
  846.                   case -28:
  847.                      this.print((ApplicationEvent)var1);
  848.                      return;
  849.                   case -27:
  850.                   case -26:
  851.                   case -25:
  852.                   default:
  853.                      break;
  854.                   case -24:
  855.                      if (!((View)this).bounds().equals(((ApplicationEvent)var1).rect()) && ((View)this).bounds().contains(((ApplicationEvent)var1).rect())) {
  856.                         ApplicationEvent var5 = new ApplicationEvent();
  857.                         var5.data = ((ApplicationEvent)var1).rect();
  858.                         var5.type = -23;
  859.                         ((Event)var5).setProcessor(this);
  860.                         if (this.application() != null && this.application().eventLoop() != null) {
  861.                            this.application().eventLoop().addEvent(var5);
  862.                         }
  863.                      }
  864.  
  865.                      this.resize((ApplicationEvent)var1);
  866.                      var6 = this.externalWindow();
  867.                      if (var6 != null) {
  868.                         var6.validateBounds();
  869.                         return;
  870.                      }
  871.                      break;
  872.                   case -23:
  873.                      if (this.isVisible) {
  874.                         this.paint((ApplicationEvent)var1);
  875.                         return;
  876.                      }
  877.                      break;
  878.                   case -22:
  879.                      var6 = this.externalWindow();
  880.                      if (var6 != null) {
  881.                         var6.didResignMain();
  882.                      }
  883.  
  884.                      if (this._mainWindow != null) {
  885.                         this._setMainWindow((InternalWindow)null);
  886.                      }
  887.  
  888.                      if (this._focusedView != null) {
  889.                         this._focusedView._pauseFocus();
  890.                         return;
  891.                      }
  892.                      break;
  893.                   case -21:
  894.                      this.application.makeFirstRootView(this);
  895.                      if (var6 != null) {
  896.                         var6.didBecomeMain();
  897.                      }
  898.  
  899.                      if (this._focusedView != null) {
  900.                         this._focusedView.resumeFocus();
  901.                         return;
  902.                      }
  903.                }
  904.             }
  905.          }
  906.  
  907.       }
  908.    }
  909.  
  910.    void setFocusedView(View var1, boolean var2) {
  911.       if (var1 != this._focusedView) {
  912.          if (this._focusedView != null) {
  913.             View var3 = this._focusedView;
  914.             this._focusedView = null;
  915.             if (var2) {
  916.                var3._stopFocus();
  917.             } else {
  918.                var3._pauseFocus();
  919.             }
  920.          } else {
  921.             this._focusedView = null;
  922.          }
  923.  
  924.          if (this._focusedView == null) {
  925.             this._focusedView = var1;
  926.             if (this._focusedView != null) {
  927.                this._focusedView._startFocus();
  928.             }
  929.          }
  930.  
  931.          Application.application().focusChanged(this._focusedView);
  932.          Application.application().performCommandLater(this, "validateSelectedView", (Object)null, true);
  933.       }
  934.  
  935.    }
  936.  
  937.    public void setFocusedView(View var1) {
  938.       this.setFocusedView(var1, true);
  939.    }
  940.  
  941.    public View focusedView() {
  942.       return this._focusedView;
  943.    }
  944.  
  945.    public void performCommand(String var1, Object var2) {
  946.       if ("showFontChooser".equals(var1)) {
  947.          this.showFontChooser();
  948.       } else if ("showColorChooser".equals(var1)) {
  949.          this.showColorChooser();
  950.       } else if ("newFontSelection".equals(var1)) {
  951.          if (this.fontChooser != null) {
  952.             this.fontChooser.setFont((Font)var2);
  953.          }
  954.       } else if ("validateSelectedView".equals(var1)) {
  955.          this.validateSelectedView();
  956.       } else {
  957.          throw new NoSuchMethodError("unknown command: " + var1);
  958.       }
  959.    }
  960.  
  961.    public boolean canPerformCommand(String var1) {
  962.       return _commands.contains(var1);
  963.    }
  964.  
  965.    public void setColor(Color var1) {
  966.       this._backgroundColor = var1;
  967.    }
  968.  
  969.    public Color color() {
  970.       return this._backgroundColor;
  971.    }
  972.  
  973.    public void setImage(Image var1) {
  974.       this._image = var1;
  975.    }
  976.  
  977.    public Image image() {
  978.       return this._image;
  979.    }
  980.  
  981.    public void setImageDisplayStyle(int var1) {
  982.       if (var1 != 0 && var1 != 2 && var1 != 1) {
  983.          throw new InconsistencyException("Unknown image display style: " + var1);
  984.       } else {
  985.          this._imageDisplayStyle = var1;
  986.       }
  987.    }
  988.  
  989.    public int imageDisplayStyle() {
  990.       return this._imageDisplayStyle;
  991.    }
  992.  
  993.    public boolean isTransparent() {
  994.       return false;
  995.    }
  996.  
  997.    public void drawView(Graphics var1) {
  998.       if ((this._image == null || this._imageDisplayStyle == 0 && (this._image.width() < super.bounds.width || this._image.height() < super.bounds.height)) && this._backgroundColor != null) {
  999.          var1.setColor(this._backgroundColor);
  1000.          var1.fillRect(var1.clipRect());
  1001.       }
  1002.  
  1003.       if (this._image != null) {
  1004.          this._image.drawWithStyle(var1, 0, 0, super.bounds.width, super.bounds.height, this._imageDisplayStyle);
  1005.       }
  1006.  
  1007.    }
  1008.  
  1009.    public void draw(Graphics var1, Rect var2) {
  1010.       Vector var4 = new Vector();
  1011.       int var5 = this.windows.count();
  1012.  
  1013.       while(var5-- > 0) {
  1014.          InternalWindow var3 = (InternalWindow)this.windows.elementAt(var5);
  1015.          if (((View)var3).isDrawingEnabled()) {
  1016.             ((View)var3).disableDrawing();
  1017.             var4.addElement(var3);
  1018.          }
  1019.       }
  1020.  
  1021.       super.draw(var1, var2);
  1022.       var5 = var4.count();
  1023.  
  1024.       while(var5-- > 0) {
  1025.          InternalWindow var6 = (InternalWindow)var4.elementAt(var5);
  1026.          ((View)var6).reenableDrawing();
  1027.       }
  1028.  
  1029.    }
  1030.  
  1031.    View viewWithBuffer(View var1, Rect var2) {
  1032.       Object var5 = null;
  1033.       int var6 = var1.subviewCount();
  1034.       if (var6 == 0) {
  1035.          return null;
  1036.       } else {
  1037.          Vector var8 = var1.subviews();
  1038.          Rect var7 = Rect.newRect(0, 0, var2.width, var2.height);
  1039.  
  1040.          while(var6-- > 0) {
  1041.             View var3 = (View)var8.elementAt(var6);
  1042.             if (!(var3 instanceof InternalWindow) && var3.bounds.contains(var2)) {
  1043.                if (var3.isBuffered()) {
  1044.                   Rect.returnRect(var7);
  1045.                   return var3;
  1046.                }
  1047.  
  1048.                var3.isTransparent();
  1049.                var7.x = var2.x - var3.bounds.x;
  1050.                var7.y = var2.y - var3.bounds.y;
  1051.                View var4 = this.viewWithBuffer(var3, var7);
  1052.                if (var4 != null) {
  1053.                   Rect.returnRect(var7);
  1054.                   return var4;
  1055.                }
  1056.  
  1057.                if (var5 != null) {
  1058.                   Rect.returnRect(var7);
  1059.                   return (View)var5;
  1060.                }
  1061.             }
  1062.          }
  1063.  
  1064.          Rect.returnRect(var7);
  1065.          return null;
  1066.       }
  1067.    }
  1068.  
  1069.    void redraw(Graphics var1, Rect var2) {
  1070.       Rect var9 = Rect.newRect(0, 0, var2.width, var2.height);
  1071.       if (var2 == null) {
  1072.          var2 = new Rect(0, 0, super.bounds.width, super.bounds.height);
  1073.       }
  1074.  
  1075.       Vector var5 = VectorCache.newVector();
  1076.       this.setRedrawTransparentWindows(false);
  1077.       int var7 = this.windows.count();
  1078.       boolean var8 = false;
  1079.       int var6 = var7;
  1080.  
  1081.       while(var6-- > 0 && !var8) {
  1082.          InternalWindow var3 = (InternalWindow)this.windows.elementAt(var6);
  1083.          Rect var10 = this.absoluteWindowBounds(var3);
  1084.          if (var10.intersects(var2)) {
  1085.             var5.addElement(var3);
  1086.             if (!var3.isTransparent() && var10.contains(var2)) {
  1087.                var8 = true;
  1088.             }
  1089.          }
  1090.       }
  1091.  
  1092.       if (!var8) {
  1093.          View var4 = ((View)this)._viewForRect(var2, (View)null);
  1094.          if (var4 != null) {
  1095.             ((View)this).convertRectToView(var4, var2, var9);
  1096.             var1.pushState();
  1097.             var1.translate(var2.x - var9.x, var2.y - var9.y);
  1098.             var4.draw(var1, var9);
  1099.             var1.popState();
  1100.          } else {
  1101.             this.draw(var1, var2);
  1102.          }
  1103.       }
  1104.  
  1105.       var7 = var5.count();
  1106.  
  1107.       for(int var13 = 0; var13 < var7; ++var13) {
  1108.          InternalWindow var11 = (InternalWindow)var5.elementAt(var13);
  1109.          View var15 = ((View)var11).superview();
  1110.          ((View)this).convertRectToView(var15, var2, var9);
  1111.          Object var12 = ((View)var11)._viewForRect(var9, var15);
  1112.          if (var12 == null) {
  1113.             var12 = var11;
  1114.          }
  1115.  
  1116.          ((View)this).convertRectToView((View)var12, var2, var9);
  1117.          var1.pushState();
  1118.          var1.translate(var2.x - var9.x, var2.y - var9.y);
  1119.          ((View)var12).draw(var1, var9);
  1120.          var1.popState();
  1121.       }
  1122.  
  1123.       this.setRedrawTransparentWindows(true);
  1124.       Rect.returnRect(var9);
  1125.       VectorCache.returnVector(var5);
  1126.    }
  1127.  
  1128.    public void redraw(Rect var1) {
  1129.       Graphics var2 = ((View)this).createGraphics();
  1130.       this.redraw(var2, var1);
  1131.       var2.dispose();
  1132.    }
  1133.  
  1134.    void redraw() {
  1135.       Graphics var1 = ((View)this).createGraphics();
  1136.       Rect var2 = Rect.newRect(0, 0, super.bounds.width, super.bounds.height);
  1137.       this.redraw(var1, var2);
  1138.       Rect.returnRect(var2);
  1139.       var1.dispose();
  1140.    }
  1141.  
  1142.    synchronized void markDirty(View var1) {
  1143.       if (this.dirtyViews != null) {
  1144.          this.dirtyViews.addElement(var1);
  1145.       } else {
  1146.          throw new InconsistencyException("Don't dirty a View while the list of dirty views is being drawn!");
  1147.       }
  1148.    }
  1149.  
  1150.    synchronized void markClean(View var1) {
  1151.       if (this.dirtyViews != null) {
  1152.          this.dirtyViews.removeElement(var1);
  1153.       }
  1154.  
  1155.    }
  1156.  
  1157.    public synchronized void resetDirtyViews() {
  1158.       Vector var4 = this.dirtyViews;
  1159.       this.dirtyViews = null;
  1160.       int var2 = var4.count();
  1161.  
  1162.       for(int var1 = 0; var1 < var2; ++var1) {
  1163.          View var3 = (View)var4.elementAt(var1);
  1164.          var3.setDirty(false);
  1165.       }
  1166.  
  1167.       var4.removeAllElements();
  1168.       this.dirtyViews = var4;
  1169.    }
  1170.  
  1171.    public synchronized void drawDirtyViews() {
  1172.       int var2 = this.dirtyViews.count();
  1173.       if (var2 != 0) {
  1174.          Vector var5 = this.dirtyViews;
  1175.  
  1176.          try {
  1177.             this.dirtyViews = null;
  1178.             Vector var4 = new Vector(var2);
  1179.             Rect var3 = new Rect();
  1180.  
  1181.             for(int var1 = 0; var1 < var2; ++var1) {
  1182.                View var6 = (View)var5.elementAt(var1);
  1183.                this.collectDirtyViews(var6, var4, var3);
  1184.             }
  1185.  
  1186.             var2 = var4.count();
  1187.  
  1188.             for(int var11 = 0; var11 < var2; ++var11) {
  1189.                View var13 = (View)var4.elementAt(var11);
  1190.                var13.draw(var13.dirtyRect);
  1191.             }
  1192.          } finally {
  1193.             this.dirtyViews = var5;
  1194.             this.resetDirtyViews();
  1195.          }
  1196.  
  1197.       }
  1198.    }
  1199.  
  1200.    void collectDirtyViews(View var1, Vector var2, Rect var3) {
  1201.       View var9 = var1;
  1202.       View var8 = var1;
  1203.       int var6 = 0;
  1204.       int var4 = 0;
  1205.       int var7 = 0;
  1206.       int var5 = 0;
  1207.       var3.setBounds(0, 0, var1.width(), var1.height());
  1208.       if (var1.dirtyRect != null) {
  1209.          var3.intersectWith(var1.dirtyRect);
  1210.       }
  1211.  
  1212.       if (!var3.isEmpty()) {
  1213.          do {
  1214.             var4 += var8.bounds.x;
  1215.             var5 += var8.bounds.y;
  1216.             var3.moveBy(var8.bounds.x, var8.bounds.y);
  1217.             var8 = var8.superview();
  1218.             if (var8 != null) {
  1219.                var3.intersectWith(0, 0, var8.width(), var8.height());
  1220.                if (var3.isEmpty()) {
  1221.                   return;
  1222.                }
  1223.  
  1224.                if (var8.isDirty()) {
  1225.                   var9 = var8;
  1226.                   var6 = var4;
  1227.                   var7 = var5;
  1228.                }
  1229.             }
  1230.          } while(var8 != null && !(var8 instanceof InternalWindow));
  1231.  
  1232.          if (var1 != var9) {
  1233.             var3.moveBy(var6 - var4, var7 - var5);
  1234.             var9.addDirtyRect(var3);
  1235.          }
  1236.  
  1237.          if (!var2.containsIdentical(var9)) {
  1238.             var2.addElement(var9);
  1239.          }
  1240.  
  1241.       }
  1242.    }
  1243.  
  1244.    public boolean mouseDown(MouseEvent var1) {
  1245.       return false;
  1246.    }
  1247.  
  1248.    public RootView rootView() {
  1249.       return this.panel == null ? super.rootView() : this;
  1250.    }
  1251.  
  1252.    void setPanel(FoundationPanel var1) {
  1253.       this.panel = var1;
  1254.    }
  1255.  
  1256.    public FoundationPanel panel() {
  1257.       return this.panel;
  1258.    }
  1259.  
  1260.    Application application() {
  1261.       return this.application;
  1262.    }
  1263.  
  1264.    void setApplication(Application var1) {
  1265.       this.application = var1;
  1266.    }
  1267.  
  1268.    public void setWindowClipView(View var1) {
  1269.       this._windowClipView = var1;
  1270.    }
  1271.  
  1272.    public View windowClipView() {
  1273.       return this._windowClipView;
  1274.    }
  1275.  
  1276.    void addComponentView(AWTComponentView var1) {
  1277.       if (this.componentViews == null) {
  1278.          this.componentViews = new Vector();
  1279.       }
  1280.  
  1281.       this.componentViews.addElement(var1);
  1282.       var1.setComponentBounds();
  1283.       this.panel.add(var1.component);
  1284.    }
  1285.  
  1286.    void removeComponentView(AWTComponentView var1) {
  1287.       if (this.componentViews == null) {
  1288.          this.componentViews = new Vector();
  1289.       }
  1290.  
  1291.       this.componentViews.removeElement(var1);
  1292.       this.panel.remove(var1.component);
  1293.    }
  1294.  
  1295.    private final void subviewDidResizeOrMove(View var1) {
  1296.       if (this.componentViews != null) {
  1297.          int var3 = this.componentViews.count();
  1298.  
  1299.          for(int var4 = 0; var4 < var3; ++var4) {
  1300.             AWTComponentView var2 = (AWTComponentView)this.componentViews.elementAt(var4);
  1301.             if (((View)var2).descendsFrom(var1)) {
  1302.                var2.setComponentBounds();
  1303.             }
  1304.          }
  1305.       }
  1306.  
  1307.       this.createMouseEnterLater();
  1308.       if (this.application != null) {
  1309.          KeyboardArrow var5 = this.application.keyboardArrow();
  1310.          View var6 = var5.view();
  1311.          if (var6 != null && var6.rootView() == this) {
  1312.             this.updateArrowLocation(var5);
  1313.          }
  1314.       }
  1315.  
  1316.    }
  1317.  
  1318.    public void subviewDidResize(View var1) {
  1319.       this.subviewDidResizeOrMove(var1);
  1320.    }
  1321.  
  1322.    public void subviewDidMove(View var1) {
  1323.       this.subviewDidResizeOrMove(var1);
  1324.    }
  1325.  
  1326.    public boolean canDraw() {
  1327.       return this.panel.getParent() == null ? false : this.isVisible;
  1328.    }
  1329.  
  1330.    public Point mousePoint() {
  1331.       return new Point(this._mouseX, this._mouseY);
  1332.    }
  1333.  
  1334.    public boolean viewExcludedFromModalSession(View var1) {
  1335.       if (var1 == null) {
  1336.          return true;
  1337.       } else {
  1338.          View var2 = Application.application().modalView();
  1339.          if (var2 != null && !var1.descendsFrom(var2)) {
  1340.             return !(var1 instanceof DragView) && !(var1 instanceof InternalWindow);
  1341.          } else {
  1342.             return false;
  1343.          }
  1344.       }
  1345.    }
  1346.  
  1347.    public void setRedrawAll(boolean var1) {
  1348.       this.redrawAll = var1;
  1349.    }
  1350.  
  1351.    public boolean redrawAll() {
  1352.       return this.redrawAll;
  1353.    }
  1354.  
  1355.    Rect absoluteWindowBounds(InternalWindow var1) {
  1356.       return ((View)var1).superview() != this ? ((View)var1).superview().convertRectToView(this, var1.bounds) : var1.bounds;
  1357.    }
  1358.  
  1359.    void viewHierarchyChanged() {
  1360.       if (this._focusedView != null && !this._focusedView.descendsFrom(this)) {
  1361.          this.setFocusedView((View)null);
  1362.       }
  1363.  
  1364.       Application.application().performCommandLater(this, "validateSelectedView", (Object)null, true);
  1365.    }
  1366.  
  1367.    private boolean isInWindow(View var1) {
  1368.       if (var1 == null) {
  1369.          return false;
  1370.       } else if (var1 instanceof InternalWindow) {
  1371.          return true;
  1372.       } else {
  1373.          View var2 = var1.superview();
  1374.  
  1375.          while(var2 != this) {
  1376.             if (var2 instanceof InternalWindow) {
  1377.                return true;
  1378.             }
  1379.  
  1380.             var2 = var2.superview();
  1381.             if (var2 == null) {
  1382.                return false;
  1383.             }
  1384.          }
  1385.  
  1386.          return false;
  1387.       }
  1388.    }
  1389.  
  1390.    public boolean mouseStillDown() {
  1391.       return this.mouseDownCount > 0;
  1392.    }
  1393.  
  1394.    View rootViewFocusedView() {
  1395.       if (this._rootViewFocusedView != null) {
  1396.          if (this._rootViewFocusedView.descendsFrom(this)) {
  1397.             return this._rootViewFocusedView;
  1398.          }
  1399.  
  1400.          this._rootViewFocusedView = null;
  1401.       }
  1402.  
  1403.       return null;
  1404.    }
  1405.  
  1406.    public void setDefaultSelectedView(View var1) {
  1407.       this._defaultSelectedView = var1;
  1408.    }
  1409.  
  1410.    public View defaultSelectedView() {
  1411.       return this._defaultSelectedView;
  1412.    }
  1413.  
  1414.    public void selectView(View var1, boolean var2) {
  1415.       View var3 = this.keyboardRootView();
  1416.       if ((this.application == null || this.application.isKeyboardUIEnabled()) && this._selectedView != var3 && this._selectedView != null) {
  1417.          if (var2) {
  1418.             this.setFocusedView((View)null);
  1419.          }
  1420.  
  1421.          if (this._focusedView == null && var1.canBecomeSelectedView() && var1.descendsFrom(var3)) {
  1422.             View var4 = var1.superview();
  1423.             if (var4 != var3) {
  1424.                do {
  1425.                   if (var4.hidesSubviewsFromKeyboard()) {
  1426.                      var1 = var4;
  1427.                   }
  1428.  
  1429.                   var4 = var4.superview();
  1430.                } while(var4 != var3);
  1431.             }
  1432.  
  1433.             this.makeSelectedView(var1);
  1434.          } else if (var3 instanceof RootView) {
  1435.             ((RootView)var3).setDefaultSelectedView(var1);
  1436.          } else {
  1437.             if (var3 instanceof InternalWindow) {
  1438.                ((InternalWindow)var3).setDefaultSelectedView(var1);
  1439.             }
  1440.  
  1441.          }
  1442.       }
  1443.    }
  1444.  
  1445.    public void selectViewAfter(View var1) {
  1446.       Object var2 = null;
  1447.       View var3 = this.findNextView(var1, this.keyboardRootView(), true);
  1448.       this.makeSelectedView(var3);
  1449.    }
  1450.  
  1451.    public void selectViewBefore(View var1) {
  1452.       Object var2 = null;
  1453.       View var3 = this.findNextView(var1, this.keyboardRootView(), false);
  1454.       this.makeSelectedView(var3);
  1455.    }
  1456.  
  1457.    void didBecomeFirstRootView() {
  1458.       ExternalWindow var1 = this.externalWindow();
  1459.       if (var1 != null) {
  1460.          var1.didBecomeMain();
  1461.       }
  1462.  
  1463.       if (this._focusedView != null) {
  1464.          this._focusedView._startFocus();
  1465.          Application.application().focusChanged(this._focusedView);
  1466.       }
  1467.  
  1468.       this.application.performCommandLater(this, "validateSelectedView", (Object)null, true);
  1469.    }
  1470.  
  1471.    void didResignFirstRootView() {
  1472.       ExternalWindow var1 = this.externalWindow();
  1473.       if (var1 != null) {
  1474.          var1.didResignMain();
  1475.       }
  1476.  
  1477.       if (this._mainWindow != null) {
  1478.          this._setMainWindow((InternalWindow)null);
  1479.       }
  1480.  
  1481.       if (this._focusedView != null) {
  1482.          this._focusedView._pauseFocus();
  1483.       }
  1484.  
  1485.       this.application.performCommandLater(this, "validateSelectedView", (Object)null, true);
  1486.    }
  1487.  
  1488.    void makeSelectedView(View var1) {
  1489.       if (this.application != null && this.application.isKeyboardUIEnabled()) {
  1490.          View var2 = this.keyboardRootView();
  1491.          if (var1 != this._selectedView) {
  1492.             if (this._selectedView != null) {
  1493.                this._selectedView.willBecomeUnselected();
  1494.                this._selectedView = null;
  1495.             }
  1496.  
  1497.             this._selectedView = var1;
  1498.             if (this._selectedView != null) {
  1499.                if (var2 instanceof RootView) {
  1500.                   ((RootView)var2).setDefaultSelectedView(this._selectedView);
  1501.                } else if (var2 instanceof InternalWindow) {
  1502.                   ((InternalWindow)var2).setDefaultSelectedView(this._selectedView);
  1503.                }
  1504.  
  1505.                this._selectedView.scrollRectToVisible(new Rect(0, 0, this._selectedView.width(), this._selectedView.height()));
  1506.                this._selectedView.willBecomeSelected();
  1507.             }
  1508.  
  1509.             this.validateKeyboardArrow();
  1510.          }
  1511.       }
  1512.  
  1513.    }
  1514.  
  1515.    void validateKeyboardArrow() {
  1516.       if (this.application != null && this.application.isKeyboardUIEnabled()) {
  1517.          Object var1 = null;
  1518.          View var2;
  1519.          if (this._selectedView != null && this._selectedView.wantsKeyboardArrow()) {
  1520.             var2 = this._selectedView;
  1521.          } else if (this._focusedView != null && this._focusedView.canBecomeSelectedView() && this._focusedView.wantsKeyboardArrow()) {
  1522.             var2 = this._focusedView;
  1523.          } else {
  1524.             var2 = null;
  1525.          }
  1526.  
  1527.          if (var2 != null) {
  1528.             this.showKeyboardArrowForView(var2);
  1529.             return;
  1530.          }
  1531.  
  1532.          this.hideKeyboardArrow();
  1533.       }
  1534.  
  1535.    }
  1536.  
  1537.    void validateSelectedView() {
  1538.       if (this.application == null || this.application.isKeyboardUIEnabled()) {
  1539.          if (this._focusedView == null && (this.application == null || this.application.firstRootView() == this)) {
  1540.             View var1 = this.keyboardRootView();
  1541.             if (this._selectedView != null && this._selectedView.descendsFrom(var1)) {
  1542.                boolean var3 = false;
  1543.                if (!(this._selectedView instanceof InternalWindow) && !(this._selectedView instanceof RootView) || this._selectedView == var1) {
  1544.                   if (this._selectedView != var1) {
  1545.                      for(View var4 = this._selectedView.superview(); var4 != null && var4 != var1; var4 = var4.superview()) {
  1546.                         if (var4.hidesSubviewsFromKeyboard()) {
  1547.                            var3 = true;
  1548.                            break;
  1549.                         }
  1550.                      }
  1551.                   }
  1552.  
  1553.                   if (!var3) {
  1554.                      return;
  1555.                   }
  1556.  
  1557.                   this.makeSelectedView((View)null);
  1558.                }
  1559.             }
  1560.  
  1561.             View var2;
  1562.             if (var1 instanceof RootView) {
  1563.                var2 = ((RootView)var1).defaultSelectedView();
  1564.             } else if (var1 instanceof InternalWindow) {
  1565.                var2 = ((InternalWindow)var1).defaultSelectedView();
  1566.             } else {
  1567.                var2 = null;
  1568.             }
  1569.  
  1570.             if (var2 != null && var2.descendsFrom(var1)) {
  1571.                this.makeSelectedView(var2);
  1572.             } else {
  1573.                this.selectNextSelectableView();
  1574.             }
  1575.          } else if (this._selectedView != null) {
  1576.             this.makeSelectedView((View)null);
  1577.          }
  1578.  
  1579.          this.validateKeyboardArrow();
  1580.       }
  1581.    }
  1582.  
  1583.    void selectNextSelectableView() {
  1584.       View var1 = this.keyboardRootView();
  1585.       Object var2 = null;
  1586.       View var3;
  1587.       if (this._selectedView != null && this._selectedView.descendsFrom(var1)) {
  1588.          var3 = this.findNextView(this._selectedView, var1, true);
  1589.       } else {
  1590.          var3 = this.findNextView((View)null, var1, true);
  1591.       }
  1592.  
  1593.       this.makeSelectedView(var3);
  1594.    }
  1595.  
  1596.    void selectPreviousSelectableView() {
  1597.       View var1 = this.keyboardRootView();
  1598.       Object var2 = null;
  1599.       View var3;
  1600.       if (this._selectedView != null && this._selectedView.descendsFrom(var1)) {
  1601.          var3 = this.findNextView(this._selectedView, var1, false);
  1602.       } else {
  1603.          var3 = this.findNextView((View)null, var1, false);
  1604.       }
  1605.  
  1606.       this.makeSelectedView(var3);
  1607.    }
  1608.  
  1609.    boolean processKeyboardEvent(KeyEvent var1, boolean var2) {
  1610.       if ((this.application == null || this.application.isKeyboardUIEnabled()) && ((View)this).subviews().count() != 0) {
  1611.          if (var2 && !var1.isControlKeyDown()) {
  1612.             return false;
  1613.          } else if (!var2 && var1.isControlKeyDown()) {
  1614.             return false;
  1615.          } else {
  1616.             View var4 = this.keyboardRootView();
  1617.             this.validateSelectedView();
  1618.             if (var2 || !var1.isTabKey() && !var1.isBackTabKey()) {
  1619.                KeyStroke var5 = new KeyStroke(var1);
  1620.                if (this._selectedView != null) {
  1621.                   if (this._selectedView.performCommandForKeyStroke(var5, 0)) {
  1622.                      return true;
  1623.                   }
  1624.  
  1625.                   if (this._selectedView != var4) {
  1626.                      for(View var3 = this._selectedView.superview(); var3 != var4; var3 = var3.superview()) {
  1627.                         if (var3.performCommandForKeyStroke(var5, 1)) {
  1628.                            return true;
  1629.                         }
  1630.                      }
  1631.                   }
  1632.                }
  1633.  
  1634.                View var6 = var4;
  1635.  
  1636.                do {
  1637.                   var6 = this.nextView(var6, var4, true, true, false);
  1638.                   if (var6.performCommandForKeyStroke(var5, 1)) {
  1639.                      return true;
  1640.                   }
  1641.                } while(var6 != var4);
  1642.  
  1643.                Object var7 = this;
  1644.  
  1645.                do {
  1646.                   var7 = this.nextView((View)var7, this, true, true, true);
  1647.                   if (((View)var7).performCommandForKeyStroke(var5, 2)) {
  1648.                      return true;
  1649.                   }
  1650.                } while(var7 != this);
  1651.  
  1652.                return false;
  1653.             } else {
  1654.                if (var1.isBackTabKey()) {
  1655.                   this.selectPreviousSelectableView();
  1656.                } else {
  1657.                   this.selectNextSelectableView();
  1658.                }
  1659.  
  1660.                return true;
  1661.             }
  1662.          }
  1663.       } else {
  1664.          return false;
  1665.       }
  1666.    }
  1667.  
  1668.    private View nextView(View var1, View var2, boolean var3, boolean var4, boolean var5) {
  1669.       Object var6 = null;
  1670.       if (var1 == var2 && var3) {
  1671.          Vector var10 = var2.subviews();
  1672.          if (var10.count() > 0) {
  1673.             return var4 ? var2.firstSubview() : var2.lastSubview();
  1674.          } else {
  1675.             return null;
  1676.          }
  1677.       } else if (var3 && (!var1.hidesSubviewsFromKeyboard() || var5 && var1 instanceof InternalWindow) && var1.subviews().count() > 0) {
  1678.          return var4 ? var1.firstSubview() : var1.lastSubview();
  1679.       } else {
  1680.          View var7 = var1.superview();
  1681.          if (var4) {
  1682.             View var8 = var7.viewAfter(var1);
  1683.             if (var8 != null) {
  1684.                return var8;
  1685.             }
  1686.          } else {
  1687.             View var9 = var7.viewBefore(var1);
  1688.             if (var9 != null) {
  1689.                return var9;
  1690.             }
  1691.          }
  1692.  
  1693.          return var7 == var2 ? var2 : this.nextView(var7, var2, false, var4, var5);
  1694.       }
  1695.    }
  1696.  
  1697.    private View findNextView(View var1, View var2, boolean var3) {
  1698.       if (var2 == null) {
  1699.          return null;
  1700.       } else if (var1 == null) {
  1701.          return var2;
  1702.       } else {
  1703.          View var5 = var1;
  1704.          View var4 = var1;
  1705.  
  1706.          do {
  1707.             var4 = this.nextView(var4, var2, true, var3, false);
  1708.          } while(var4 != null && var4 != var5 && !var4.canBecomeSelectedView());
  1709.  
  1710.          return var4;
  1711.       }
  1712.    }
  1713.  
  1714.    private View keyboardRootView() {
  1715.       View var1 = Application.application().modalView();
  1716.       if (var1 != null && var1.isInViewHierarchy()) {
  1717.          return var1;
  1718.       } else {
  1719.          InternalWindow var2 = this.mainWindow();
  1720.          if (var2 != null) {
  1721.             return (View)var2;
  1722.          } else {
  1723.             return this.application != null && this.application.firstRootView() != null ? this.application.firstRootView() : this;
  1724.          }
  1725.       }
  1726.    }
  1727.  
  1728.    void showKeyboardArrowForView(View var1) {
  1729.       if (this.application != null) {
  1730.          KeyboardArrow var2 = this.application.keyboardArrow();
  1731.          if (var2.view() == var1) {
  1732.             return;
  1733.          }
  1734.  
  1735.          ((InternalWindow)var2).setRootView(this);
  1736.          var2.setView(var1);
  1737.          this.updateArrowLocation(var2);
  1738.          ((InternalWindow)var2).show();
  1739.       }
  1740.  
  1741.    }
  1742.  
  1743.    void updateArrowLocation(KeyboardArrow var1) {
  1744.       View var2 = var1.view();
  1745.       int var3 = this.application.keyboardArrowPosition(var2);
  1746.       Image var4 = this.application.keyboardArrowImage(var3);
  1747.       Point var5 = this.application.keyboardArrowHotSpot(var3);
  1748.       Point var6 = this.application.keyboardArrowLocation(var2, var3);
  1749.       var6.x -= var5.x;
  1750.       var6.y -= var5.y;
  1751.       if (this.windowClipView() != null) {
  1752.          ((View)this).convertPointToView(this.windowClipView(), var6, var6);
  1753.       }
  1754.  
  1755.       var1.setImage(var4);
  1756.       ((View)var1).moveTo(var6.x, var6.y);
  1757.    }
  1758.  
  1759.    void hideKeyboardArrow() {
  1760.       if (this.application != null) {
  1761.          KeyboardArrow var1 = this.application.keyboardArrow();
  1762.          if (((View)var1).rootView() == this) {
  1763.             ((InternalWindow)var1).hide();
  1764.             ((InternalWindow)var1).setRootView((RootView)null);
  1765.             var1.setView((View)null);
  1766.          }
  1767.       }
  1768.  
  1769.    }
  1770.  
  1771.    public boolean canBecomeSelectedView() {
  1772.       return true;
  1773.    }
  1774.  
  1775.    boolean wantsKeyboardArrow() {
  1776.       return false;
  1777.    }
  1778.  
  1779.    static {
  1780.       _commands.addElement("showFontChooser");
  1781.       _commands.addElement("showColorChooser");
  1782.       _commands.addElement("newFontSelection");
  1783.       _commands.addElement("validateSelectedView");
  1784.    }
  1785. }
  1786.