home *** CD-ROM | disk | FTP | other *** search
- package netscape.application;
-
- import netscape.util.ClassInfo;
- import netscape.util.Codable;
- import netscape.util.CodingException;
- import netscape.util.Decoder;
- import netscape.util.Encoder;
- import netscape.util.Enumeration;
- import netscape.util.Hashtable;
- import netscape.util.InconsistencyException;
- import netscape.util.Vector;
-
- public class View implements Codable {
- View _superview;
- Size _minSize;
- Bitmap drawingBuffer;
- private Vector subviews;
- private Vector kbdOrder;
- LayoutManager layoutManager;
- Hashtable _keyboardBindings;
- public Rect bounds;
- Rect dirtyRect;
- byte resizeInstr;
- int drawingDisabled;
- boolean autoResizeSubviews;
- boolean buffered;
- boolean drawingBufferValid;
- boolean drawingBufferIsBitCache;
- boolean isDirty;
- boolean needFocus;
- boolean focusPaused;
- boolean wantsKeyboardArrow;
- public static final int RIGHT_MARGIN_CAN_CHANGE = 0;
- public static final int LEFT_MARGIN_CAN_CHANGE = 1;
- public static final int WIDTH_CAN_CHANGE = 2;
- public static final int CENTER_HORIZ = 32;
- public static final int BOTTOM_MARGIN_CAN_CHANGE = 4;
- public static final int TOP_MARGIN_CAN_CHANGE = 8;
- public static final int HEIGHT_CAN_CHANGE = 16;
- public static final int CENTER_VERT = 64;
- private static final int DEFAULT_RESIZE_INSTR = 4;
- private static final int VERT_MASK = 92;
- private static final int HORZ_MASK = 35;
- static final String MINSIZE_KEY = "minSize";
- static final String BOUNDS_KEY = "bounds";
- static final String SUBVIEWS_KEY = "subviews";
- static final String RESIZE_KEY = "resizeInstr";
- static final String DRAWINGDISABLED_KEY = "drawingDisabled";
- static final String AUTORESIZE_KEY = "autoResizeSubviews";
- static final String BUFFERED_KEY = "buffered";
- static final String LAYOUTMANAGER_KEY = "layoutManager";
- static final String KEYBOARD_BINDINGS_KEY = "keyboardBindings";
- private static final String KBD_COMMAND_KEY = "kbdCmd";
- private static final String KBD_WHEN = "when";
- private static final String KBD_DATA_KEY = "kbdData";
- static final int DEFAULT_CURSOR = -1;
- public static final int ARROW_CURSOR = 0;
- public static final int CROSSHAIR_CURSOR = 1;
- public static final int TEXT_CURSOR = 2;
- public static final int WAIT_CURSOR = 3;
- public static final int SW_RESIZE_CURSOR = 4;
- public static final int SE_RESIZE_CURSOR = 5;
- public static final int NW_RESIZE_CURSOR = 6;
- public static final int NE_RESIZE_CURSOR = 7;
- public static final int N_RESIZE_CURSOR = 8;
- public static final int S_RESIZE_CURSOR = 9;
- public static final int W_RESIZE_CURSOR = 10;
- public static final int E_RESIZE_CURSOR = 11;
- public static final int HAND_CURSOR = 12;
- public static final int MOVE_CURSOR = 13;
- public static final int WHEN_SELECTED = 0;
- public static final int WHEN_IN_MAIN_WINDOW = 1;
- public static final int ALWAYS = 2;
-
- public View() {
- this(0, 0, 0, 0);
- }
-
- public View(Rect var1) {
- this(var1.x, var1.y, var1.width, var1.height);
- }
-
- public View(int var1, int var2, int var3, int var4) {
- this.bounds = new Rect();
- this.resizeInstr = 4;
- this.autoResizeSubviews = true;
- this._setBounds(var1, var2, var3, var4);
- }
-
- void _setBounds(int var1, int var2, int var3, int var4) {
- this.bounds.setBounds(var1, var2, var3, var4);
- }
-
- int subviewCount() {
- return this.subviews == null ? 0 : this.subviews.count();
- }
-
- public Vector subviews() {
- if (this.subviews == null) {
- this.subviews = new Vector();
- }
-
- return this.subviews;
- }
-
- public Vector peersForSubview(View var1) {
- if (this.subviewCount() != 0 && this.subviews().contains(var1)) {
- Vector var2 = new Vector();
- var2.addElementsIfAbsent(this.subviews);
- return var2;
- } else {
- return new Vector();
- }
- }
-
- public boolean descendsFrom(View var1) {
- if (var1 == this) {
- return true;
- } else if (this._superview != null && var1 != null) {
- return this._superview == var1 ? true : this._superview.descendsFrom(var1);
- } else {
- return false;
- }
- }
-
- public InternalWindow window() {
- return this._superview == null ? null : this._superview.window();
- }
-
- public Rect bounds() {
- return new Rect(this.bounds);
- }
-
- // $FF: renamed from: x () int
- public int method_0() {
- return this.bounds.x;
- }
-
- // $FF: renamed from: y () int
- public int method_1() {
- return this.bounds.y;
- }
-
- public int width() {
- return this.bounds.width;
- }
-
- public int height() {
- return this.bounds.height;
- }
-
- public View superview() {
- return this._superview;
- }
-
- public void setHorizResizeInstruction(int var1) {
- if (var1 != 0 && var1 != 1 && var1 != 2 && var1 != 32) {
- throw new IllegalArgumentException("invalid horz resize instruction " + var1);
- } else {
- this.resizeInstr = (byte)(this.resizeInstr & 92);
- this.resizeInstr = (byte)(this.resizeInstr | var1);
- }
- }
-
- public int horizResizeInstruction() {
- return this.resizeInstr & 35;
- }
-
- public void setVertResizeInstruction(int var1) {
- if (var1 != 4 && var1 != 8 && var1 != 16 && var1 != 64) {
- throw new IllegalArgumentException("invalid vert resize instruction " + var1);
- } else {
- this.resizeInstr = (byte)(this.resizeInstr & 35);
- this.resizeInstr = (byte)(this.resizeInstr | var1);
- }
- }
-
- public int vertResizeInstruction() {
- return this.resizeInstr & 92;
- }
-
- public boolean wantsAutoscrollEvents() {
- return false;
- }
-
- public DragDestination acceptsDrag(DragSession var1, int var2, int var3) {
- return null;
- }
-
- public void setAutoResizeSubviews(boolean var1) {
- this.autoResizeSubviews = var1;
- }
-
- public boolean doesAutoResizeSubviews() {
- return this.autoResizeSubviews;
- }
-
- public void didMoveBy(int var1, int var2) {
- }
-
- public void didSizeBy(int var1, int var2) {
- if (this.autoResizeSubviews) {
- this.layoutView(var1, var2);
- }
- }
-
- public void setBounds(Rect var1) {
- this.setBounds(var1.x, var1.y, var1.width, var1.height);
- }
-
- public void setBounds(int var1, int var2, int var3, int var4) {
- int var5 = var1 - this.bounds.x;
- int var6 = var2 - this.bounds.y;
- int var7 = var3 - this.bounds.width;
- int var8 = var4 - this.bounds.height;
- boolean var9 = var5 != 0 || var6 != 0;
- boolean var10 = var7 != 0 || var8 != 0;
- if (var9 || var10) {
- this._setBounds(var1, var2, var3, var4);
- if (this.buffered && var10) {
- if (this.drawingBuffer != null) {
- this.drawingBuffer.flush();
- }
-
- if (var3 > 0 && var4 > 0) {
- this.drawingBuffer = this.createBuffer();
- } else {
- this.drawingBuffer = null;
- }
-
- this.drawingBufferValid = false;
- }
-
- if (var9) {
- if (this._superview != null) {
- this._superview.subviewDidMove(this);
- }
-
- this.didMoveBy(var5, var6);
- }
-
- if (var10) {
- if (this._superview != null) {
- this._superview.subviewDidResize(this);
- }
-
- this.didSizeBy(var7, var8);
- }
-
- }
- }
-
- public void moveBy(int var1, int var2) {
- this.setBounds(this.bounds.x + var1, this.bounds.y + var2, this.bounds.width, this.bounds.height);
- }
-
- public void moveTo(int var1, int var2) {
- this.setBounds(var1, var2, this.bounds.width, this.bounds.height);
- }
-
- public void sizeBy(int var1, int var2) {
- this.setBounds(this.bounds.x, this.bounds.y, this.bounds.width + var1, this.bounds.height + var2);
- }
-
- public void sizeTo(int var1, int var2) {
- this.setBounds(this.bounds.x, this.bounds.y, var1, var2);
- }
-
- public void setMinSize(int var1, int var2) {
- if (var1 != -1 && var2 != -1) {
- this._minSize = new Size(var1, var2);
- } else {
- this._minSize = null;
- }
- }
-
- public Size minSize() {
- return this._minSize != null ? new Size(this._minSize) : new Size();
- }
-
- public void sizeToMinSize() {
- Size var1 = this.minSize();
- this.sizeTo(var1.width, var1.height);
- }
-
- public void subviewDidResize(View var1) {
- if (this._superview != null) {
- this._superview.subviewDidResize(var1);
- }
-
- }
-
- public void subviewDidMove(View var1) {
- if (this._superview != null) {
- this._superview.subviewDidMove(var1);
- }
-
- }
-
- private void setSuperview(View var1) {
- this._superview = var1;
- this.ancestorWasAddedToViewHierarchy(var1);
- RootView var2 = this.rootView();
- if (var2 != null) {
- var2.updateCursorLater();
- var2.viewHierarchyChanged();
- }
-
- }
-
- public void addSubview(View var1) {
- if (var1 != null) {
- this.invalidateKeyboardSelectionOrder();
- if (this.subviews == null) {
- this.subviews = new Vector();
- } else if (this.subviews.contains(var1)) {
- return;
- }
-
- this.subviews.addElement(var1);
- var1.setSuperview(this);
- if (this.layoutManager != null) {
- this.layoutManager.addSubview(var1);
- }
-
- }
- }
-
- protected void ancestorWasAddedToViewHierarchy(View var1) {
- if (this.buffered) {
- this.setBuffered(true);
- }
-
- if (this.needFocus) {
- this.setFocusedView();
- }
-
- int var3 = this.subviewCount();
-
- while(var3-- > 0) {
- View var2 = (View)this.subviews.elementAt(var3);
- var2.ancestorWasAddedToViewHierarchy(var1);
- }
-
- }
-
- protected void removeSubview(View var1) {
- this.invalidateKeyboardSelectionOrder();
- if (this.subviews != null) {
- this.subviews.removeElement(var1);
- }
-
- if (this.layoutManager != null) {
- this.layoutManager.removeSubview(var1);
- }
-
- }
-
- public void removeFromSuperview() {
- if (this._superview != null) {
- RootView var1 = this.rootView();
- if (var1 != null) {
- var1.updateCursorLater();
- }
-
- this.ancestorWillRemoveFromViewHierarchy(this);
- this._superview.removeSubview(this);
- this._superview = null;
- if (var1 != null) {
- var1.viewHierarchyChanged();
- }
- }
-
- }
-
- protected void ancestorWillRemoveFromViewHierarchy(View var1) {
- if (this.drawingBuffer != null) {
- this.drawingBuffer.flush();
- this.drawingBuffer = null;
- }
-
- RootView var2 = this.rootView();
- if (var2 != null) {
- if (var2.mouseView() == this) {
- var2.setMouseView((View)null);
- }
-
- if (var2._moveView == this) {
- var2._moveView = null;
- }
- }
-
- if (this.isDirty) {
- this.setDirty(false);
- }
-
- int var4 = this.subviewCount();
-
- while(var4-- > 0) {
- View var3 = (View)this.subviews.elementAt(var4);
- var3.ancestorWillRemoveFromViewHierarchy(var1);
- }
-
- }
-
- public boolean containsPoint(int var1, int var2) {
- return Rect.contains(0, 0, this.width(), this.height(), var1, var2);
- }
-
- public boolean containsPointInVisibleRect(int var1, int var2) {
- Rect var3 = Rect.newRect();
- this.computeVisibleRect(var3);
- boolean var4 = var3.contains(var1, var2);
- Rect.returnRect(var3);
- return var4;
- }
-
- View _viewForRect(Rect var1, View var2) {
- View var4 = null;
- if (var1 == null) {
- return null;
- } else {
- Rect var5;
- if (var2 != null) {
- if (!this.bounds.contains(var1)) {
- return null;
- }
-
- var5 = Rect.newRect();
- var2.convertRectToView(this, var1, var5);
- } else {
- var5 = Rect.newRect(var1);
- }
-
- int var6 = this.subviewCount();
-
- while(var6-- > 0) {
- View var3 = (View)this.subviews.elementAt(var6);
- var4 = var3._viewForRect(var5, this);
- if (var4 != null) {
- break;
- }
- }
-
- Rect.returnRect(var5);
- if (var4 != null) {
- return var4;
- } else {
- return this.isTransparent() && var2 != null ? null : this;
- }
- }
- }
-
- public View viewForMouse(int var1, int var2) {
- if (!this.containsPoint(var1, var2)) {
- return null;
- } else {
- int var4 = this.subviewCount();
-
- while(var4-- > 0) {
- View var5 = (View)this.subviews.elementAt(var4);
- if (!(var5 instanceof InternalWindow)) {
- View var3 = var5.viewForMouse(var1 - var5.bounds.x, var2 - var5.bounds.y);
- if (var3 != null) {
- return var3;
- }
- }
- }
-
- return this;
- }
- }
-
- public int cursorForPoint(int var1, int var2) {
- return 0;
- }
-
- public boolean mouseDown(MouseEvent var1) {
- return false;
- }
-
- public void mouseDragged(MouseEvent var1) {
- }
-
- public void mouseUp(MouseEvent var1) {
- }
-
- public void mouseEntered(MouseEvent var1) {
- }
-
- public void mouseMoved(MouseEvent var1) {
- }
-
- public void mouseExited(MouseEvent var1) {
- }
-
- public void keyDown(KeyEvent var1) {
- if (this._superview != null) {
- this._superview.keyDown(var1);
- }
-
- }
-
- public void keyUp(KeyEvent var1) {
- if (this._superview != null) {
- this._superview.keyUp(var1);
- }
-
- }
-
- View scrollingView() {
- return this._superview != null ? this._superview.scrollingView() : null;
- }
-
- public void scrollRectToVisible(Rect var1) {
- if (this._superview != null) {
- this._superview.scrollRectToVisible(this.convertRectToView(this._superview, var1));
- }
-
- }
-
- public void disableDrawing() {
- ++this.drawingDisabled;
- }
-
- public void reenableDrawing() {
- --this.drawingDisabled;
- if (this.drawingDisabled < 0) {
- this.drawingDisabled = 0;
- }
-
- }
-
- public boolean isDrawingEnabled() {
- return this.drawingDisabled == 0;
- }
-
- public boolean isInViewHierarchy() {
- RootView var1 = this.rootView();
- return var1 != null && var1.isVisible();
- }
-
- public RootView rootView() {
- return this._superview == null ? null : this._superview.rootView();
- }
-
- public boolean canDraw() {
- return this.drawingDisabled <= 0 && this._superview != null ? this._superview.canDraw() : false;
- }
-
- public void computeVisibleRect(Rect var1) {
- if (this._superview == null) {
- var1.setBounds(0, 0, this.width(), this.height());
- } else {
- this._superview.computeVisibleRect(var1);
- this._superview.convertRectToView(this, var1, var1);
- var1.intersectWith(0, 0, this.width(), this.height());
- }
- }
-
- public boolean isTransparent() {
- return true;
- }
-
- public boolean wantsMouseEventCoalescing() {
- return true;
- }
-
- View opaqueAncestor() {
- return this.isTransparent() && this._superview != null ? this._superview.opaqueAncestor() : this;
- }
-
- public void addDirtyRect(Rect var1) {
- if (var1 == null) {
- this.setDirty(true);
- } else {
- if (this.isDirty) {
- if (this.dirtyRect != null) {
- this.dirtyRect.unionWith(var1);
- return;
- }
- } else {
- RootView var2 = this.rootView();
- if (var2 != null) {
- this.dirtyRect = new Rect(var1);
- var2.markDirty(this);
- this.isDirty = true;
- }
- }
-
- }
- }
-
- public void setDirty(boolean var1) {
- if (var1) {
- if (!this.isDirty) {
- RootView var2 = this.rootView();
- if (var2 != null) {
- var2.markDirty(this);
- this.isDirty = true;
- }
- }
- } else if (this.isDirty) {
- RootView var3 = this.rootView();
- if (var3 != null) {
- var3.markClean(this);
- this.isDirty = false;
- }
- }
-
- this.dirtyRect = null;
- }
-
- public boolean isDirty() {
- return this.isDirty;
- }
-
- public void drawView(Graphics var1) {
- }
-
- public void drawSubviews(Graphics var1) {
- Rect var4 = null;
- if (this.drawingDisabled <= 0) {
- Rect var3 = var1.clipRect();
- int var5 = this.subviewCount();
-
- for(int var6 = 0; var6 < var5; ++var6) {
- View var2 = (View)this.subviews.elementAt(var6);
- boolean var7 = var2.isDrawingEnabled();
- if (var4 == null) {
- var4 = Rect.newRect();
- }
-
- this.convertRectToView(var2, var3, var4);
- var4.intersectWith(0, 0, var2.bounds.width, var2.bounds.height);
- if (var7 && !var4.isEmpty()) {
- var2._drawView(var1, var4, false);
- }
- }
-
- if (var4 != null) {
- Rect.returnRect(var4);
- }
-
- }
- }
-
- void _drawView(Graphics var1, Rect var2, boolean var3) {
- if (this.drawingDisabled <= 0) {
- var1.pushState();
- var1.setDebug(this);
- if (!var3) {
- var1.translate(this.bounds.x, this.bounds.y);
- }
-
- if (var2 == null) {
- Rect var4 = Rect.newRect(0, 0, this.width(), this.height());
- var1.setClipRect(var4);
- Rect.returnRect(var4);
- } else {
- var1.setClipRect(var2);
- }
-
- if (this.drawingBuffer != null && var3 && !var1.isDrawingBuffer()) {
- this.drawingBuffer.drawAt(var1, 0, 0);
- } else {
- this.drawView(var1);
- this.drawSubviews(var1);
- }
-
- var1.popState();
- }
- }
-
- void clipAndDrawView(Graphics var1, Rect var2) {
- Rect var12;
- if (var1.isDrawingBuffer()) {
- var12 = Rect.newRect(0, 0, this.width(), this.height());
- } else {
- var12 = Rect.newRect();
- this.computeVisibleRect(var12);
- }
-
- var12.intersectWith(var2);
- Vector var3;
- if ((this != this.rootView() || var12.x != 0 || var12.y != 0 || var12.width != this.width() || var12.height != this.height()) && !var1.isDrawingBuffer()) {
- var3 = this.rootView().windowRects(this.convertRectToView((View)null, var12), this.window());
- } else {
- var3 = null;
- }
-
- if (var3 != null && !var3.isEmpty()) {
- Vector var5 = VectorCache.newVector();
- Vector var4 = VectorCache.newVector();
- var12.x += this.absoluteX();
- var12.y += this.absoluteY();
- var4.addElement(var12);
- Vector var6 = VectorCache.newVector();
- int var13 = var3.count();
-
- while(var13-- > 0) {
- Rect var10 = (Rect)var3.elementAt(var13);
- int var14 = var4.count();
-
- while(var14-- > 0) {
- Rect var9 = (Rect)var4.elementAt(var14);
- var9.computeDisunionRects(var10, var5);
- if (!var5.isEmpty()) {
- var6.addElementsIfAbsent(var5);
- var5.removeAllElements();
- } else if (!var10.contains(var9)) {
- var6.addElement(var9);
- var4.removeElement(var9);
- }
- }
-
- Vector var7 = var4;
- var4 = var6;
- var6 = var7;
- Rect.returnRects(var7);
- }
-
- VectorCache.returnVector(var5);
- VectorCache.returnVector(var6);
- int var15 = var4.count();
-
- for(int var17 = 0; var17 < var15; ++var17) {
- Rect var8 = (Rect)var4.elementAt(var17);
- int var19 = var15;
-
- while(var19-- > 0) {
- Rect var11 = (Rect)var4.elementAt(var19);
- if (var11 != var8 && var8.contains(var11)) {
- Rect.returnRect((Rect)var4.removeElementAt(var19));
- --var15;
- var17 = -1;
- break;
- }
- }
- }
-
- var13 = var4.count();
-
- while(var13-- > 0) {
- var2 = (Rect)var4.elementAt(var13);
- if (!var2.isEmpty()) {
- var2.x -= this.absoluteX();
- var2.y -= this.absoluteY();
- this._drawView(var1, var2, true);
- }
- }
-
- Rect.returnRects(var4);
- VectorCache.returnVector(var4);
- } else {
- this._drawView(var1, var12, true);
- Rect.returnRect(var12);
- }
-
- Rect.returnRects(var3);
- VectorCache.returnVector(var3);
- }
-
- void _draw(Graphics var1, Rect var2) {
- boolean var3 = this.drawingBuffer != null && !var1.isDrawingBuffer() ? false : this.isTransparent();
- if (var3 && !(this instanceof InternalWindow)) {
- Rect var4 = Rect.newRect();
- View var5 = this.opaqueAncestor();
- this.convertRectToView(var5, var2, var4);
- var1.pushState();
- var1.translate(var2.x - var4.x, var2.y - var4.y);
- var5.draw(var1, var4);
- Rect.returnRect(var4);
- var1.popState();
- } else {
- this.updateInvalidDrawingBuffers(var2);
- this.clipAndDrawView(var1, var2);
- }
- }
-
- public void draw(Graphics var1, Rect var2) {
- if (var2 != null) {
- var2 = Rect.newRect(var2);
- var2.intersectWith(0, 0, this.width(), this.height());
- if (var2.isEmpty()) {
- Rect.returnRect(var2);
- return;
- }
- } else {
- var2 = Rect.newRect(0, 0, this.width(), this.height());
- }
-
- boolean var7 = this.canDraw();
- if (var1 == null || !var1.isDrawingBuffer()) {
- if (this.drawingBuffer == null) {
- if (!var7) {
- Rect.returnRect(var2);
- return;
- }
-
- View var3 = this.ancestorWithDrawingBuffer();
- if (var3 != null && var3 != this) {
- Rect var4 = Rect.newRect();
- this.computeVisibleRect(var4);
- var4.intersectWith(var2);
- this.convertRectToView(var3, var4, var4);
- var3.drawingBufferValid = false;
- if (var1 == null) {
- var1 = var3.createGraphics();
- var3.draw(var1, var4);
- var1.dispose();
- Object var13 = null;
- } else {
- Point var6 = new Point(0, 0);
- this.convertPointToView(var3, var6, var6);
- var1.pushState();
-
- try {
- var1.translate(-var6.x, -var6.y);
- var3.draw(var1, var4);
- } finally {
- var1.popState();
- }
- }
-
- Rect.returnRect(var4);
- Rect.returnRect(var2);
- return;
- }
- } else if (!this.drawingBufferIsBitCache) {
- this.updateDrawingBuffer(var2);
- }
-
- Rect var5 = this.convertRectToView(this.rootView(), var2);
- this.rootView().redrawTransparentWindows(var5, this.window());
- }
-
- if (var1 != null && var1.isDrawingBuffer() || var7) {
- if (var1 == null) {
- var1 = this.createGraphics();
- this._draw(var1, var2);
- var1.dispose();
- Object var15 = null;
- } else {
- this._draw(var1, var2);
- }
- }
-
- Rect.returnRect(var2);
- }
-
- public void draw(Rect var1) {
- if (this.isInViewHierarchy()) {
- this.draw((Graphics)null, var1);
- }
-
- }
-
- public void draw() {
- if (this.isInViewHierarchy()) {
- this.draw((Graphics)null, (Rect)null);
- }
-
- }
-
- public void setBuffered(boolean var1) {
- this.buffered = var1;
- if (var1 && this.drawingBuffer == null) {
- if (this.bounds.width != 0 && this.bounds.height != 0) {
- this.drawingBuffer = this.createBuffer();
- }
-
- this.drawingBufferValid = false;
- } else {
- if (!var1 && this.drawingBuffer != null) {
- this.drawingBuffer.flush();
- this.drawingBuffer = null;
- }
-
- }
- }
-
- public boolean isBuffered() {
- return this.buffered;
- }
-
- public Bitmap drawingBuffer() {
- return this.drawingBuffer;
- }
-
- void updateDrawingBuffer(Rect var1) {
- if (var1.intersects(0, 0, this.width(), this.height())) {
- if (this.drawingBuffer != null) {
- Bitmap var3 = this.drawingBuffer;
- synchronized(var3){}
-
- try {
- Graphics var2 = Graphics.newGraphics(this.drawingBuffer);
- this.drawingBufferValid = true;
- var2.setDebugOptions(this.shouldDebugGraphics());
- this.draw(var2, var1);
- if (!this.canDraw()) {
- this.drawingBufferValid = false;
- }
-
- var2.dispose();
- Object var6 = null;
- } catch (Throwable var5) {
- throw var5;
- }
-
- }
- }
- }
-
- void updateInvalidDrawingBuffers(Rect var1) {
- Rect var3 = null;
- int var4 = this.subviewCount();
-
- while(var4-- > 0) {
- View var2 = (View)this.subviews.elementAt(var4);
- if (var3 == null) {
- var3 = Rect.newRect();
- }
-
- this.convertRectToView(var2, var1, var3);
- if (var3.intersects(0, 0, var2.width(), var2.height())) {
- if (var2.drawingBuffer != null && !var2.drawingBufferValid) {
- var2.updateDrawingBuffer(var3);
- }
-
- var2.updateInvalidDrawingBuffers(var3);
- }
- }
-
- if (var3 != null) {
- Rect.returnRect(var3);
- }
-
- }
-
- View ancestorWithDrawingBuffer() {
- if (this.drawingBuffer != null) {
- return this;
- } else {
- return this._superview == null ? null : this._superview.ancestorWithDrawingBuffer();
- }
- }
-
- void _startFocus() {
- if (this.focusPaused) {
- this.focusPaused = false;
- this.resumeFocus();
- } else {
- this.startFocus();
- }
- }
-
- void _stopFocus() {
- this.focusPaused = false;
- this.stopFocus();
- }
-
- void _pauseFocus() {
- this.focusPaused = true;
- this.pauseFocus();
- }
-
- public void startFocus() {
- }
-
- public void stopFocus() {
- }
-
- public void pauseFocus() {
- }
-
- public void resumeFocus() {
- }
-
- void setFocusedView(View var1) {
- if (this._superview != null) {
- this._superview.setFocusedView(var1);
- }
-
- }
-
- public void setFocusedView() {
- if (this._superview == null || !this.isInViewHierarchy() && this.window() == null) {
- this.needFocus = true;
- } else {
- this._superview.setFocusedView(this);
- this.needFocus = false;
- }
- }
-
- public void describeClassInfo(ClassInfo var1) {
- var1.addClass("netscape.application.View", 2);
- var1.addField("bounds", (byte)18);
- var1.addField("minSize", (byte)18);
- var1.addField("subviews", (byte)18);
- var1.addField("resizeInstr", (byte)4);
- var1.addField("drawingDisabled", (byte)8);
- var1.addField("autoResizeSubviews", (byte)0);
- var1.addField("buffered", (byte)0);
- var1.addField("layoutManager", (byte)18);
- var1.addField("keyboardBindings", (byte)18);
- }
-
- public void encode(Encoder var1) throws CodingException {
- var1.encodeObject("bounds", this.bounds);
- var1.encodeObject("minSize", this._minSize);
- if (this.subviewCount() == 0) {
- var1.encodeObject("subviews", (Object)null);
- } else {
- var1.encodeObject("subviews", this.subviews);
- }
-
- var1.encodeByte("resizeInstr", this.resizeInstr);
- var1.encodeInt("drawingDisabled", this.drawingDisabled);
- var1.encodeBoolean("autoResizeSubviews", this.autoResizeSubviews);
- var1.encodeBoolean("buffered", this.buffered);
- var1.encodeObject("layoutManager", this.layoutManager);
- var1.encodeObject("keyboardBindings", this._keyboardBindings);
- }
-
- public void decode(Decoder var1) throws CodingException {
- int var2 = var1.versionForClassName("netscape.application.View");
- this.bounds = (Rect)var1.decodeObject("bounds");
- this._minSize = (Size)var1.decodeObject("minSize");
- Object var3 = var1.decodeObject("subviews");
- if (var3 != null) {
- this.subviews = (Vector)var3;
- }
-
- this.resizeInstr = var1.decodeByte("resizeInstr");
- this.drawingDisabled = var1.decodeInt("drawingDisabled");
- boolean var4 = var1.decodeBoolean("autoResizeSubviews");
- if (var4) {
- this.setAutoResizeSubviews(var4);
- }
-
- var4 = var1.decodeBoolean("buffered");
- if (var4) {
- this.setBuffered(var4);
- }
-
- this.layoutManager = (LayoutManager)var1.decodeObject("layoutManager");
- if (var2 >= 2) {
- this._keyboardBindings = (Hashtable)var1.decodeObject("keyboardBindings");
- }
-
- }
-
- public void finishDecoding() throws CodingException {
- int var2 = this.subviewCount();
-
- while(var2-- > 0) {
- View var1 = (View)this.subviews.elementAt(var2);
- var1.setSuperview(this);
- var1._setBounds(var1.bounds.x, var1.bounds.y, var1.bounds.width, var1.bounds.height);
- }
-
- this._setBounds(this.bounds.x, this.bounds.y, this.bounds.width, this.bounds.height);
- }
-
- Application application() {
- return Application.application();
- }
-
- public void convertToView(View var1, int var2, int var3, Point var4) {
- int var5 = var2;
- int var6 = var3;
- if (this._superview == var1) {
- var5 = var2 + this.bounds.x;
- var6 = var3 + this.bounds.y;
- } else if (var1 != null && var1._superview == this) {
- var5 = var2 - var1.bounds.x;
- var6 = var3 - var1.bounds.y;
- } else {
- View var7;
- for(var7 = this; var7._superview != null; var7 = var7._superview) {
- var5 += var7.bounds.x;
- var6 += var7.bounds.y;
- }
-
- if (var1 != null) {
- View var8;
- for(var8 = var1; var8._superview != null; var8 = var8._superview) {
- var5 -= var8.bounds.x;
- var6 -= var8.bounds.y;
- }
-
- if (var7 != var8) {
- throw new InconsistencyException("Can't convert between " + this + " and " + var1 + ", no common ancestor");
- }
- }
- }
-
- var4.x = var5;
- var4.y = var6;
- }
-
- public Point convertToView(View var1, int var2, int var3) {
- Point var4 = new Point();
- this.convertToView(var1, var2, var3, var4);
- return var4;
- }
-
- public void convertRectToView(View var1, Rect var2, Rect var3) {
- Point var4 = Point.newPoint();
- this.convertToView(var1, var2.x, var2.y, var4);
- var3.setBounds(var4.x, var4.y, var2.width, var2.height);
- Point.returnPoint(var4);
- }
-
- public void convertPointToView(View var1, Point var2, Point var3) {
- this.convertToView(var1, var2.x, var2.y, var3);
- }
-
- public Rect convertRectToView(View var1, Rect var2) {
- Rect var3 = new Rect();
- this.convertRectToView(var1, var2, var3);
- return var3;
- }
-
- public Point convertPointToView(View var1, Point var2) {
- Point var3 = new Point();
- this.convertPointToView(var1, var2, var3);
- return var3;
- }
-
- public MouseEvent convertEventToView(View var1, MouseEvent var2) {
- Point var3 = Point.newPoint();
- MouseEvent var4 = (MouseEvent)((Event)var2).clone();
- this.convertToView(var1, var2.x, var2.y, var3);
- var4.x = var3.x;
- var4.y = var3.y;
- Point.returnPoint(var3);
- return var4;
- }
-
- public void setGraphicsDebugOptions(int var1) {
- Graphics.setViewDebug(this, var1);
- }
-
- public int graphicsDebugOptions() {
- return Graphics.viewDebug(this);
- }
-
- int shouldDebugGraphics() {
- return Graphics.shouldViewDebug(this);
- }
-
- int absoluteX() {
- int var1 = 0;
-
- for(View var2 = this; var2 != null; var2 = var2._superview) {
- var1 += var2.bounds.x;
- }
-
- return var1;
- }
-
- int absoluteY() {
- int var1 = 0;
-
- for(View var2 = this; var2 != null; var2 = var2._superview) {
- var1 += var2.bounds.y;
- }
-
- return var1;
- }
-
- public void setLayoutManager(LayoutManager var1) {
- this.layoutManager = var1;
- }
-
- public LayoutManager layoutManager() {
- return this.layoutManager;
- }
-
- public void layoutView(int var1, int var2) {
- if (this.layoutManager == null) {
- this.relativeLayoutView(var1, var2);
- } else {
- this.layoutManager.layoutView(this, var1, var2);
- }
- }
-
- private void relativeLayoutView(int var1, int var2) {
- int var4;
- int var5;
- int var6;
- int var7;
- View var8;
- for(int var3 = this.subviewCount(); var3-- > 0; var8.setBounds(var4, var5, var6, var7)) {
- var8 = (View)this.subviews.elementAt(var3);
- var4 = var8.bounds.x;
- var5 = var8.bounds.y;
- var6 = var8.bounds.width;
- var7 = var8.bounds.height;
- switch (var8.horizResizeInstruction()) {
- case 0:
- break;
- case 1:
- var4 += var1;
- break;
- case 2:
- var6 += var1;
- break;
- case 32:
- var4 = (this.bounds.width - var8.bounds.width) / 2;
- break;
- default:
- throw new InconsistencyException("invalid horz resize instruction: " + var8.horizResizeInstruction());
- }
-
- switch (var8.vertResizeInstruction()) {
- case 4:
- break;
- case 8:
- var5 += var2;
- break;
- case 16:
- var7 += var2;
- break;
- case 64:
- var5 = (this.bounds.height - var8.bounds.height) / 2;
- break;
- default:
- throw new InconsistencyException("invalid vert resize instruction: " + var8.vertResizeInstruction());
- }
- }
-
- }
-
- public Rect localBounds() {
- return new Rect(0, 0, this.bounds.width, this.bounds.height);
- }
-
- public Graphics createGraphics() {
- return Graphics.newGraphics(this);
- }
-
- protected Bitmap createBuffer() {
- return new Bitmap(this.width(), this.height());
- }
-
- public String toString() {
- return super.toString() + this.bounds.toString();
- }
-
- public boolean canBecomeSelectedView() {
- return false;
- }
-
- public boolean hidesSubviewsFromKeyboard() {
- return false;
- }
-
- public View nextSelectableView() {
- return null;
- }
-
- public View previousSelectableView() {
- return null;
- }
-
- public void invalidateKeyboardSelectionOrder() {
- this.kbdOrder = null;
- }
-
- public void willBecomeSelected() {
- this.wantsKeyboardArrow = true;
- }
-
- public void willBecomeUnselected() {
- this.wantsKeyboardArrow = false;
- }
-
- public void setCommandForKey(String var1, Object var2, int var3, int var4, int var5) {
- KeyStroke var6 = new KeyStroke(var3, var4);
- if (this._keyboardBindings == null) {
- this._keyboardBindings = new Hashtable();
- }
-
- if (var1 == null) {
- this._keyboardBindings.remove(var6);
- } else {
- Hashtable var7 = new Hashtable();
- var7.put("kbdCmd", var1);
- var7.put("when", "" + var5);
- if (var2 != null) {
- var7.put("kbdData", var2);
- }
-
- this._keyboardBindings.put(var6, var7);
- }
- }
-
- public void setCommandForKey(String var1, int var2, int var3) {
- this.setCommandForKey(var1, this, var2, 0, var3);
- }
-
- public void removeCommandForKey(int var1) {
- this.setCommandForKey((String)null, (Object)null, var1, 0, 0);
- }
-
- public void removeAllCommandsForKeys() {
- this._keyboardBindings = null;
- }
-
- boolean hasKeyboardBindings() {
- return this._keyboardBindings != null && this._keyboardBindings.count() > 0;
- }
-
- boolean performCommandForKeyStroke(KeyStroke var1, int var2) {
- if (!(this instanceof Target)) {
- return false;
- } else {
- if (this._keyboardBindings != null) {
- Enumeration var3 = this._keyboardBindings.keys();
-
- while(var3.hasMoreElements()) {
- KeyStroke var4 = (KeyStroke)var3.nextElement();
- if (var4.equals(var1)) {
- boolean var5 = false;
- Hashtable var6 = (Hashtable)this._keyboardBindings.get(var4);
- String var7 = (String)var6.get("when");
- int var8 = Integer.parseInt(var7);
- switch (var8) {
- case 0:
- if (var2 == 0) {
- var5 = true;
- }
- break;
- case 1:
- if (var2 == 0 || var2 == 1) {
- var5 = true;
- }
- break;
- case 2:
- var5 = true;
- break;
- default:
- throw new InconsistencyException("Wrong condition:" + var8);
- }
-
- if (var5) {
- String var9 = (String)var6.get("kbdCmd");
- ((Target)this).performCommand(var9, var6.get("kbdData"));
- return true;
- }
- }
- }
- }
-
- return false;
- }
- }
-
- public Rect keyboardRect() {
- return this.localBounds();
- }
-
- View _firstSubview(Vector var1) {
- if (var1.count() == 0) {
- return null;
- } else {
- View var5 = (View)var1.elementAt(0);
- int var3 = var5.method_1();
- int var7 = 1;
-
- for(int var8 = var1.count(); var7 < var8; ++var7) {
- View var6 = (View)var1.elementAt(var7);
- if (var6.method_1() < var3) {
- var5 = var6;
- var3 = var6.method_1();
- }
- }
-
- View var4 = var5;
- int var2 = var5.method_0();
- var7 = 0;
-
- for(int var11 = var1.count(); var7 < var11; ++var7) {
- View var9 = (View)var1.elementAt(var7);
- if (var9 != var4 && (int)Math.sqrt((double)((var9.method_1() - var4.method_1()) * (var9.method_1() - var4.method_1()))) <= 10 && var9.method_0() < var2) {
- var4 = var9;
- var2 = var9.method_0();
- }
- }
-
- return var4;
- }
- }
-
- private void validateKeyboardOrder() {
- if (this.kbdOrder == null) {
- Vector var3 = new Vector();
- int var1 = 0;
-
- for(int var2 = this.subviews.count(); var1 < var2; ++var1) {
- var3.addElement(this.subviews.elementAt(var1));
- }
-
- this.kbdOrder = new Vector();
-
- while(var3.count() > 0) {
- View var4 = this._firstSubview(var3);
- this.kbdOrder.addElement(var4);
- var3.removeElement(var4);
-
- View var5;
- while((var5 = var4.nextSelectableView()) != null && var3.indexOfIdentical(var5) != -1) {
- this.kbdOrder.addElement(var5);
- var3.removeElement(var5);
- var4 = var5;
- }
- }
- }
-
- }
-
- View firstSubview() {
- this.validateKeyboardOrder();
- return this.kbdOrder.count() > 0 ? (View)this.kbdOrder.elementAt(0) : null;
- }
-
- View lastSubview() {
- this.validateKeyboardOrder();
- return this.kbdOrder.count() > 0 ? (View)this.kbdOrder.elementAt(this.kbdOrder.count() - 1) : null;
- }
-
- View viewAfter(View var1) {
- this.validateKeyboardOrder();
- int var2 = this.kbdOrder.indexOfIdentical(var1);
- return var2 != -1 && var2 < this.kbdOrder.count() - 1 ? (View)this.kbdOrder.elementAt(var2 + 1) : null;
- }
-
- View viewBefore(View var1) {
- this.validateKeyboardOrder();
- int var2 = this.kbdOrder.indexOfIdentical(var1);
- return var2 > 0 ? (View)this.kbdOrder.elementAt(var2 - 1) : null;
- }
-
- boolean wantsKeyboardArrow() {
- return this.wantsKeyboardArrow;
- }
-
- void getDirtyRect(Rect var1) {
- if (this.isDirty() && this.dirtyRect == null) {
- if (var1.isEmpty()) {
- var1.setBounds(this.bounds);
- } else {
- var1.unionWith(this.bounds);
- }
- } else {
- if (this.dirtyRect != null) {
- if (var1.isEmpty()) {
- var1.setBounds(this.dirtyRect.x + this.bounds.x, this.dirtyRect.y + this.bounds.y, this.dirtyRect.width, this.dirtyRect.height);
- } else {
- var1.unionWith(this.dirtyRect.x + this.bounds.x, this.dirtyRect.y + this.bounds.y, this.dirtyRect.width, this.dirtyRect.height);
- }
- }
-
- int var2 = this.subviewCount();
- if (var2 != 0) {
- var1.moveBy(-this.bounds.x, -this.bounds.y);
-
- while(var2-- > 0) {
- ((View)this.subviews.elementAt(var2)).getDirtyRect(var1);
- }
-
- var1.moveBy(this.bounds.x, this.bounds.y);
- }
-
- }
- }
- }
-