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.InconsistencyException;
- import netscape.util.Vector;
-
- public class InternalWindow extends View implements Window {
- RootView rootView;
- WindowOwner _owner;
- WindowContentView _contentView;
- View _focusedView;
- View _defaultSelectedView;
- Button _closeButton;
- MenuView menuView;
- Font _titleFont;
- String _title;
- Border _border;
- int _layer;
- int _type;
- int _lastX;
- int _lastY;
- int _resizePart;
- boolean _closeable;
- boolean _resizable;
- boolean _canBecomeMain;
- boolean _containsDocument;
- boolean _drewOnLastDrag;
- boolean _drawToBackingStore;
- boolean _dragStart;
- boolean _onscreen;
- boolean _createdDrawingBuffer;
- boolean transparent;
- boolean scrollToVisible;
- static Vector _resizeWindowVector = new Vector();
- static final int ABOVE = 0;
- static final int BEHIND = 1;
- static final int NO_PART = 0;
- static final int LEFT_PART = 1;
- static final int MIDDLE_PART = 2;
- static final int RIGHT_PART = 3;
- static final String ownerKey = "owner";
- static final String contentViewKey = "contentView";
- static final String focusedViewKey = "focusedView";
- static final String closeButtonKey = "closeButton";
- static final String titleFontKey = "titleFont";
- static final String titleKey = "title";
- static final String borderKey = "border";
- static final String layerKey = "layer";
- static final String typeKey = "type";
- static final String closeableKey = "closeable";
- static final String resizableKey = "resizeable";
- static final String canBecomeMainKey = "canBecomeMain";
- static final String containsDocumentKey = "canBecomeDocument";
- static final String onscreenKey = "onscreen";
- static final String transparentKey = "transparent";
- static final String scrollToVisibleKey = "scrollToVisible";
- static final String defaultSelectedViewKey = "defaultSelectedView";
- static final String menuViewKey = "menuView";
- public static final int DEFAULT_LAYER = 0;
- public static final int PALETTE_LAYER = 100;
- public static final int MODAL_LAYER = 200;
- public static final int POPUP_LAYER = 300;
- public static final int DRAG_LAYER = 400;
- public static final int IGNORE_WINDOW_CLIPVIEW_LAYER = 500;
-
- public InternalWindow() {
- this(0, 0, 0, 0);
- }
-
- public InternalWindow(Rect var1) {
- this(var1.x, var1.y, var1.width, var1.height);
- }
-
- public InternalWindow(int var1, int var2, int var3, int var4) {
- this(1, var1, var2, var3, var4);
- }
-
- public InternalWindow(int var1, int var2, int var3, int var4, int var5) {
- super(var2, var3, var4, var5);
- this._title = "";
- this._type = 1;
- this._canBecomeMain = true;
- this._containsDocument = false;
- this._onscreen = true;
- this.transparent = false;
- this.rootView = ((View)this).application().mainRootView();
- this._titleFont = Font.fontNamed("Helvetica", 1, 12);
- this._contentView = new WindowContentView(0, 0, 1, 1);
- this._contentView.setHorizResizeInstruction(2);
- this._contentView.setVertResizeInstruction(16);
- this.addSubviewToWindow(this._contentView);
- this._layer = 0;
- this._border = new InternalWindowBorder(this);
- this.layoutParts();
- this.setType(var1);
- this._defaultSelectedView = this;
- }
-
- int menuViewHeight() {
- return this.menuView == null ? 0 : this.menuView.height();
- }
-
- int titleBarMargin() {
- return this._type == 0 ? 0 : this._border.topMargin();
- }
-
- int leftBorderMargin() {
- return this._type == 0 ? 0 : this._border.leftMargin();
- }
-
- int rightBorderMargin() {
- return this._type == 0 ? 0 : this._border.rightMargin();
- }
-
- int bottomBorderMargin() {
- return this._type == 0 ? 0 : this._border.bottomMargin();
- }
-
- public WindowContentView contentView() {
- return this._contentView;
- }
-
- public Size contentSize() {
- return this._contentView == null ? null : new Size(this._contentView.bounds.width, this._contentView.bounds.height);
- }
-
- public void layoutParts() {
- if (this._contentView != null) {
- this._contentView.setAutoResizeSubviews(false);
- this._contentView.setBounds(this.leftBorderMargin(), this.titleBarMargin() + this.menuViewHeight(), super.bounds.width - (this.leftBorderMargin() + this.rightBorderMargin()), super.bounds.height - (this.titleBarMargin() + this.menuViewHeight() + this.bottomBorderMargin()));
- this._contentView.setAutoResizeSubviews(true);
- }
-
- if (this._closeButton != null) {
- this._closeButton.removeFromSuperview();
- this._closeButton.moveTo(0, 2 + (this.titleBarMargin() - 4 - this._closeButton.bounds.height) / 2);
- if (this._closeable) {
- this.addSubview(this._closeButton);
- }
- }
-
- }
-
- public void addSubview(View var1) {
- if (var1 != this._contentView && var1 != this._closeButton) {
- if (this._contentView != null) {
- this._contentView.addSubview(var1);
- }
-
- } else {
- this.addSubviewToWindow(var1);
- }
- }
-
- public void addSubviewToWindow(View var1) {
- super.addSubview(var1);
- }
-
- public void setRootView(RootView var1) {
- if (this.rootView != var1 && this.rootView != null && super._superview != null) {
- this.rootView.removeWindow(this);
- }
-
- this.rootView = var1;
- }
-
- public void show() {
- if (this.rootView == null) {
- throw new InconsistencyException("Can't show Window. No RootView");
- } else {
- if (this._owner == null || this._owner.windowWillShow(this)) {
- if (super._superview == null) {
- this.rootView.addWindowRelativeTo(this, 0, (InternalWindow)null);
- } else {
- this.rootView.makeWindowVisible(this, 0, (InternalWindow)null);
- }
-
- if (this._owner != null) {
- this._owner.windowDidShow(this);
- }
- }
-
- }
- }
-
- public void showModally() {
- Application var1 = Application.application();
- EventLoop var3 = var1.eventLoop();
- int var4 = this.layer();
- if (var4 < 200) {
- this.setLayer(200);
- }
-
- this.show();
- ((View)this).rootView()._setMainWindow(this);
- var1.beginModalSessionForView(this);
- var1.drawAllDirtyViews();
-
- while(this.isVisible()) {
- Event var2 = var3.getNextEvent();
-
- try {
- var3.processEvent(var2);
- } catch (Exception var6) {
- System.err.println("Uncaught Exception.");
- ((Throwable)var6).printStackTrace(System.err);
- System.err.println("Restarting modal EventLoop.");
- }
- }
-
- var1.endModalSessionForView(this);
- if (var4 != this.layer()) {
- this.setLayer(var4);
- }
-
- }
-
- public void showInFrontOf(InternalWindow var1) {
- if (var1.rootView != this.rootView) {
- this.setRootView(var1.rootView);
- this.rootView.addWindowRelativeTo(this, 0, var1);
- } else if (super._superview == null) {
- this.rootView.addWindowRelativeTo(this, 0, var1);
- } else {
- this.rootView.makeWindowVisible(this, 0, var1);
- }
- }
-
- public void showBehind(InternalWindow var1) {
- if (var1.rootView != this.rootView) {
- this.setRootView(var1.rootView);
- this.rootView.addWindowRelativeTo(this, 1, var1);
- } else {
- if (super._superview == null) {
- this.rootView.addWindowRelativeTo(this, 1, var1);
- }
-
- }
- }
-
- public void moveToFront() {
- if (this.isVisible()) {
- InternalWindow var1 = this.rootView.frontWindowWithLayer(this.layer());
- if (var1 != null && var1 != this) {
- this.rootView.makeWindowVisible(this, 0, var1);
- }
-
- }
- }
-
- public void moveToBack() {
- if (this.isVisible()) {
- InternalWindow var1 = this.rootView.backWindowWithLayer(this.layer());
- if (var1 != null && var1 != this) {
- this.rootView.makeWindowVisible(this, 1, var1);
- }
-
- }
- }
-
- public void hide() {
- if (this.isVisible() && (this._owner == null || this._owner.windowWillHide(this))) {
- if (this.containsDocument() && this.isCurrentDocument()) {
- Application.application().chooseNextCurrentDocumentWindow(this);
- }
-
- RootView var1 = ((View)this).rootView();
- if (var1 != null) {
- var1.removeWindow(this);
- }
-
- if (this._owner != null) {
- this._owner.windowDidHide(this);
- }
- }
-
- }
-
- public void setCanBecomeMain(boolean var1) {
- this._canBecomeMain = var1;
- if (this.isMain() && !this._canBecomeMain && this.rootView != null) {
- this.rootView._setMainWindow((InternalWindow)null);
- }
-
- }
-
- public boolean canBecomeMain() {
- return this._canBecomeMain;
- }
-
- public boolean isVisible() {
- return super._superview != null;
- }
-
- public void setOnscreenAtStartup(boolean var1) {
- this._onscreen = var1;
- }
-
- public boolean onscreenAtStartup() {
- return this._onscreen;
- }
-
- public boolean isMain() {
- return this.rootView != null && this.rootView.mainWindow() == this;
- }
-
- protected Button createCloseButton() {
- Button var1 = new Button(0, 0, 1, 1);
- var1.setImage(Bitmap.bitmapNamed("netscape/application/CloseButton.gif"));
- var1.setAltImage(Bitmap.bitmapNamed("netscape/application/CloseButtonActive.gif"));
- var1.setTransparent(true);
- ((View)var1).sizeToMinSize();
- ((View)var1).setHorizResizeInstruction(0);
- ((View)var1).setVertResizeInstruction(4);
- ((View)var1).moveTo(0, 2 + (this.titleBarMargin() - 4 - var1.bounds.height) / 2);
- var1.setTarget(this);
- var1.setCommand("hide");
- ((View)var1).removeAllCommandsForKeys();
- return var1;
- }
-
- public void setCloseable(boolean var1) {
- this._closeable = var1;
- if (this._type == 0) {
- this._closeable = false;
- }
-
- if (this._closeable && this._closeButton == null) {
- this._closeButton = this.createCloseButton();
- }
-
- if (this._closeable) {
- this.addSubviewToWindow(this._closeButton);
- } else {
- if (this._closeButton != null) {
- this._closeButton.removeFromSuperview();
- }
-
- }
- }
-
- public boolean isCloseable() {
- return this._closeable;
- }
-
- public void setResizable(boolean var1) {
- if (var1 != this._resizable) {
- this._resizable = var1;
- if (this._resizable) {
- this._contentView.setHorizResizeInstruction(2);
- this._contentView.setVertResizeInstruction(16);
- }
-
- if (this._type == 1) {
- this.drawBottomBorder();
- this.layoutParts();
- }
- }
-
- }
-
- public boolean isResizable() {
- return this._resizable;
- }
-
- int resizePartWidth() {
- return this._border instanceof InternalWindowBorder ? ((InternalWindowBorder)this._border).resizePartWidth() : 0;
- }
-
- public Size windowSizeForContentSize(int var1, int var2) {
- return new Size(var1 + this.leftBorderMargin() + this.rightBorderMargin(), var2 + this.titleBarMargin() + this.menuViewHeight() + this.bottomBorderMargin());
- }
-
- public void setTitle(String var1) {
- if (this._title == null || var1 == null || !this._title.equals(var1)) {
- this._title = var1;
- this.drawTitleBar();
- }
- }
-
- public String title() {
- return this._title;
- }
-
- public void setBorder(Border var1) {
- this._border = var1;
- }
-
- public Border border() {
- return this._border;
- }
-
- public void setLayer(int var1) {
- this._layer = var1;
- }
-
- public int layer() {
- return this._layer;
- }
-
- public Size minSize() {
- if (super._minSize != null) {
- return new Size(super._minSize);
- } else {
- ((View)this).setMinSize(this.resizePartWidth() * 2 + 1, this.titleBarMargin() + this.menuViewHeight() + 2);
- if (this._type == 0) {
- super._minSize.width = 0;
- super._minSize.height = 0;
- return super._minSize;
- } else {
- if (super._minSize.width < this.leftBorderMargin() + this.rightBorderMargin()) {
- super._minSize.width = this.leftBorderMargin() + this.rightBorderMargin();
- }
-
- if (super._minSize.height < this.titleBarMargin() + this.menuViewHeight() + this.bottomBorderMargin()) {
- super._minSize.height = this.titleBarMargin() + this.menuViewHeight() + this.bottomBorderMargin();
- }
-
- return new Size(super._minSize);
- }
- }
- }
-
- public void setOwner(WindowOwner var1) {
- this._owner = var1;
- }
-
- public WindowOwner owner() {
- return this._owner;
- }
-
- public void setMenuView(MenuView var1) {
- if (var1 == null || var1 != this.menuView) {
- if (this.menuView != null) {
- this.menuView.removeFromSuperview();
- }
-
- this.menuView = var1;
- int var2 = this.leftBorderMargin();
- int var3 = this.titleBarMargin();
- int var4 = super.bounds.width - (this.leftBorderMargin() + this.rightBorderMargin());
- int var5 = this.menuView.height();
- if (var5 == 0) {
- var5 = this.menuView.minSize().height;
- }
-
- this.menuView.setBounds(var2, var3, var4, var5);
- this.addSubviewToWindow(this.menuView);
- this.layoutParts();
- }
- }
-
- public MenuView menuView() {
- return this.menuView;
- }
-
- public boolean isPointInBorder(int var1, int var2) {
- if (this._type == 0) {
- return Rect.contains(0, 0, super.bounds.width, super.bounds.height, var1, var2);
- } else if (this._resizable && var2 > super.bounds.height - this.bottomBorderMargin()) {
- if (var1 < this.resizePartWidth()) {
- this._resizePart = 1;
- } else if (var1 > super.bounds.width - this.resizePartWidth()) {
- this._resizePart = 3;
- } else {
- this._resizePart = 2;
- }
-
- return true;
- } else {
- return var2 <= this.titleBarMargin();
- }
- }
-
- public View viewForMouse(int var1, int var2) {
- Object var3 = super.viewForMouse(var1, var2);
- if (this._type == 0 && var3 == this._contentView) {
- var3 = this;
- }
-
- return (View)var3;
- }
-
- public void setTransparent(boolean var1) {
- this.transparent = var1;
- if (this.transparent) {
- this._contentView.setTransparent(true);
- ((View)this).setBuffered(true);
- } else {
- ((View)this).setBuffered(false);
- this._contentView.setTransparent(false);
- }
- }
-
- public boolean isTransparent() {
- return this.transparent;
- }
-
- public void setType(int var1) {
- this._type = var1;
- if (this._type == 0) {
- this.setCanBecomeMain(false);
- this.setCloseable(false);
- }
-
- this.layoutParts();
- }
-
- public int type() {
- return this._type;
- }
-
- void updateDrawingBuffer() {
- if (super.drawingBuffer != null) {
- if (this.rootView == null) {
- throw new InconsistencyException("Can't draw window - no RootView");
- } else {
- Rect var7 = Rect.newRect();
- this.rootView.disableWindowsAbove(this, true);
- ((View)this).reenableDrawing();
- Graphics var6 = super.drawingBuffer.createGraphics();
- var6.setDebugOptions(((View)this).shouldDebugGraphics());
- ((View)this).superview().convertRectToView((View)null, super.bounds, var7);
- var6.pushState();
- var6.translate(-var7.x, -var7.y);
- this.rootView.draw(var6, var7);
- var6.popState();
- int var4 = this.isTransparent() ? this.rootView.windows.count() : this.rootView.windows.indexOf(this);
- int var5 = 0;
- int var3 = var4;
-
- while(var3-- > 0 && var5 == 0) {
- InternalWindow var1 = (InternalWindow)this.rootView.windows.elementAt(var3);
- if (!var1.isTransparent() && var1.bounds.contains(super.bounds)) {
- var5 = var3;
- }
- }
-
- if (var5 == 0) {
- View var2 = this.rootView.viewWithBuffer(this.rootView, var7);
- if (var2 != null) {
- Rect var8 = Rect.newRect(0, 0, ((View)this).width(), ((View)this).height());
- ((View)this).convertRectToView(var2, var8, var8);
- var6.pushState();
- var6.translate(-var8.x, -var8.y);
- var2.draw(var6, var8);
- var6.popState();
- Rect.returnRect(var8);
- }
- }
-
- for(int var10 = var5; var10 < var4; ++var10) {
- InternalWindow var9 = (InternalWindow)this.rootView.windows.elementAt(var10);
- if (var9.bounds.intersects(super.bounds)) {
- var7.setBounds(0, 0, ((View)this).width(), ((View)this).height());
- ((View)this).convertRectToView(var9, var7, var7);
- var6.pushState();
- var6.translate(-var7.x, -var7.y);
- var9.draw(var6, var7);
- var6.popState();
- }
- }
-
- Rect.returnRect(var7);
- this.rootView.disableWindowsAbove(this, false);
- ((View)this).reenableDrawing();
- var6.dispose();
- }
- }
- }
-
- public boolean mouseDown(MouseEvent var1) {
- this.rootView.makeWindowVisible(this, 0, (InternalWindow)null);
- if (!this.isPointInBorder(var1.x, var1.y)) {
- return false;
- } else {
- this._lastX = var1.x + super.bounds.x;
- this._lastY = var1.y + super.bounds.y;
- if (this._resizePart != 0) {
- InternalWindow var2 = new InternalWindow(super.bounds.x, super.bounds.y, 1, super.bounds.height);
- var2.setType(0);
- var2._contentView.setTransparent(false);
- var2._contentView.setBackgroundColor(Color.darkGray);
- var2.setLayer(400);
- ((View)var2).setVertResizeInstruction(16);
- var2.setRootView(((View)this).rootView());
- var2.show();
- _resizeWindowVector.addElement(var2);
- var2 = new InternalWindow(super.bounds.maxX() - 1, super.bounds.y, 1, super.bounds.height);
- var2.setType(0);
- var2._contentView.setTransparent(false);
- var2._contentView.setBackgroundColor(Color.darkGray);
- var2.setLayer(400);
- ((View)var2).setVertResizeInstruction(16);
- var2.setRootView(((View)this).rootView());
- var2.show();
- _resizeWindowVector.addElement(var2);
- var2 = new InternalWindow(super.bounds.x + 1, super.bounds.y, super.bounds.width - 2, 1);
- var2.setType(0);
- var2._contentView.setTransparent(false);
- var2._contentView.setBackgroundColor(Color.darkGray);
- var2.setLayer(400);
- ((View)var2).setHorizResizeInstruction(2);
- var2.setRootView(((View)this).rootView());
- var2.show();
- _resizeWindowVector.addElement(var2);
- var2 = new InternalWindow(super.bounds.x + 1, super.bounds.maxY() - 1, super.bounds.width - 2, 1);
- var2.setType(0);
- var2._contentView.setTransparent(false);
- var2._contentView.setBackgroundColor(Color.darkGray);
- var2.setLayer(400);
- ((View)var2).setHorizResizeInstruction(2);
- var2.setRootView(((View)this).rootView());
- var2.show();
- _resizeWindowVector.addElement(var2);
- return true;
- } else {
- this._dragStart = true;
- return true;
- }
- }
- }
-
- public void setBounds(int var1, int var2, int var3, int var4) {
- int var5 = var1 - super.bounds.x;
- int var6 = var2 - super.bounds.y;
- int var7 = var3 - super.bounds.width;
- int var8 = var4 - super.bounds.height;
- if (this.isVisible()) {
- this.moveByAndSizeBy(var5, var6, var7, var8);
- } else {
- this._moveBy(var5, var6);
- this._sizeBy(var7, var8);
- ((View)this)._setBounds(var1, var2, var3, var4);
- }
- }
-
- private void _super_moveBy(int var1, int var2) {
- if (var1 != 0 || var2 != 0) {
- ((View)this)._setBounds(super.bounds.x + var1, super.bounds.y + var2, super.bounds.width, super.bounds.height);
- if (super._superview != null) {
- super._superview.subviewDidMove(this);
- }
-
- ((View)this).didMoveBy(var1, var2);
- }
- }
-
- private void _super_sizeBy(int var1, int var2) {
- if (var1 != 0 || var2 != 0) {
- ((View)this)._setBounds(super.bounds.x, super.bounds.y, super.bounds.width + var1, super.bounds.height + var2);
- if (super.buffered) {
- if (super.bounds.width != 0 && super.bounds.height != 0) {
- super.drawingBuffer = new Bitmap(super.bounds.width, super.bounds.height);
- super.drawingBufferValid = false;
- } else if (super.drawingBuffer != null) {
- super.drawingBuffer.flush();
- super.drawingBuffer = null;
- }
- }
-
- ((View)this).disableDrawing();
- if (super._superview != null) {
- super._superview.subviewDidResize(this);
- }
-
- super.didSizeBy(var1, var2);
- ((View)this).reenableDrawing();
- }
- }
-
- protected void willMoveTo(Point var1) {
- }
-
- private void _moveBy(int var1, int var2) {
- if (var1 != 0 || var2 != 0) {
- Point var4 = Point.newPoint(super.bounds.x + var1, super.bounds.y + var2);
- this.willMoveTo(var4);
- var1 = var4.x - super.bounds.x;
- var2 = var4.y - super.bounds.y;
- Point.returnPoint(var4);
- if (!this.isVisible()) {
- this._super_moveBy(var1, var2);
- } else {
- this._lastX = super.bounds.x;
- this._lastY = super.bounds.y;
- this._dragStart = true;
- MouseEvent var3 = new MouseEvent(0L, -2, this._lastX + var1, this._lastY + var2, 0);
- this.mouseDragged(var3);
- this._dragStart = false;
- }
- }
- }
-
- void _checkSize(Size var1) {
- Size var2 = this.minSize();
- if (super.bounds.width + var1.width < var2.width) {
- var1.width = var2.width - super.bounds.width;
- }
-
- if (super.bounds.height + var1.height < var2.height) {
- var1.height = var2.height - super.bounds.height;
- }
-
- if (this._owner != null) {
- this._owner.windowWillSizeBy(this, var1);
- }
-
- }
-
- private void _sizeBy(int var1, int var2) {
- if (var1 != 0 || var2 != 0) {
- Size var4 = Size.newSize(var1, var2);
- this._checkSize(var4);
- var1 = var4.width;
- var2 = var4.height;
- Size.returnSize(var4);
- if (!this.isVisible()) {
- this._super_sizeBy(var1, var2);
- this.layoutParts();
- } else {
- Rect var3 = Rect.newRect(super.bounds);
- this._super_sizeBy(var1, var2);
- this.layoutParts();
- if (((View)this).canDraw()) {
- var3.unionWith(super.bounds);
- ((View)this).superview().convertRectToView((View)null, var3, var3);
- this.rootView.redraw(var3);
- }
-
- Rect.returnRect(var3);
- }
- }
- }
-
- private void moveByAndSizeBy(int var1, int var2, int var3, int var4) {
- if (var1 != 0 || var2 != 0 || var3 != 0 || var4 != 0) {
- Size var6 = Size.newSize(var3, var4);
- this._checkSize(var6);
- var3 = var6.width;
- var4 = var6.height;
- Size.returnSize(var6);
- Point var7 = Point.newPoint(super.bounds.x + var1, super.bounds.y + var2);
- this.willMoveTo(var7);
- var1 = var7.x - super.bounds.x;
- var2 = var7.y - super.bounds.y;
- Point.returnPoint(var7);
- if (!this.isVisible()) {
- this._super_moveBy(var1, var2);
- this._super_sizeBy(var3, var4);
- this.layoutParts();
- } else {
- Rect var5 = Rect.newRect(super.bounds);
- this._super_moveBy(var1, var2);
- this._super_sizeBy(var3, var4);
- if (var3 != 0 || var4 != 0) {
- this.layoutParts();
- }
-
- var5.unionWith(super.bounds);
- if (((View)this).superview() != this.rootView) {
- ((View)this).superview().convertRectToView(this.rootView, var5, var5);
- }
-
- if (this.isTransparent()) {
- ((View)this).disableDrawing();
- this.rootView.redraw(var5);
- ((View)this).reenableDrawing();
- ((View)this).draw();
- } else {
- this.rootView.redraw(var5);
- }
-
- Rect.returnRect(var5);
- }
- }
- }
-
- private void moveToAndSizeTo(int var1, int var2, int var3, int var4) {
- this.moveByAndSizeBy(var1 - super.bounds.x, var2 - super.bounds.y, var3 - super.bounds.width, var4 - super.bounds.height);
- }
-
- public void setScrollsToVisible(boolean var1) {
- this.scrollToVisible = var1;
- }
-
- public boolean scrollsToVisible() {
- return this.scrollToVisible;
- }
-
- public void scrollRectToVisible(Rect var1) {
- int var6 = 0;
- int var7 = 0;
- if (this.scrollToVisible) {
- Rect var2 = Rect.newRect();
- ((View)this).computeVisibleRect(var2);
- if (var2.width == super.bounds.width && var2.height == super.bounds.height) {
- Rect.returnRect(var2);
- } else {
- if (!var2.contains(var1)) {
- ((View)this).convertRectToView((View)null, var2, var2);
- Rect var3 = Rect.newRect();
- ((View)this).convertRectToView((View)null, var1, var3);
- Rect var4 = Rect.newRect(0, 0, ((View)this).width(), ((View)this).height());
- ((View)this).convertRectToView((View)null, var4, var4);
- if (var3.x < var2.x && var2.x > var4.x) {
- var6 = var2.x - var3.x;
- } else if (var3.maxX() > var2.maxX() && var2.maxX() < var4.maxX()) {
- var6 = var2.maxX() - var3.maxX();
- }
-
- if (var3.y < var2.y && var2.y > var4.y) {
- var7 = var2.y - var3.y;
- } else if (var3.maxY() > var2.maxY() && var2.maxY() < var4.maxY()) {
- var7 = var2.maxY() - var3.maxY();
- }
-
- Rect var5 = ((View)this).rootView().bounds;
- if (var6 > 0 && var4.x + var6 > 3) {
- var6 = 3 - var4.x;
- } else if (var6 < 0 && var4.maxX() + var6 < var5.maxX() - 3) {
- var6 = var5.maxX() - 3 - var4.maxX();
- }
-
- if (var7 > 0 && var4.y + var7 > 3) {
- var7 = 3 - var4.y;
- } else if (var7 < 0 && var4.maxY() + var7 < var5.maxY() - 3) {
- var7 = var5.maxY() - 3 - var4.maxY();
- }
-
- ((View)this).moveBy(var6, var7);
- Rect.returnRect(var3);
- Rect.returnRect(var4);
- }
-
- Rect.returnRect(var2);
- }
- }
- }
-
- public void subviewDidResize() {
- }
-
- public void center() {
- Rect var1 = this.rootView.bounds;
- Rect var2 = new Rect((var1.width - super.bounds.width) / 2, (var1.height - super.bounds.height) / 2, super.bounds.width, super.bounds.height);
- if (var2.y < 0) {
- var2.y = 0;
- }
-
- ((View)this).setBounds(var2);
- }
-
- void mouseResizeDrag(MouseEvent var1) {
- int var5 = 0;
- var1.x += super.bounds.x;
- var1.y += super.bounds.y;
- if (this._resizePart == 2) {
- var1.x = this._lastX;
- }
-
- Rect var3 = Rect.newRect(super.bounds);
- if (this._resizePart == 1) {
- var3.moveBy(var1.x - this._lastX, 0);
- var3.sizeBy(this._lastX - var1.x, var1.y - this._lastY);
- } else {
- var3.sizeBy(var1.x - this._lastX, var1.y - this._lastY);
- }
-
- if (var3.height > ((View)this).superview().height() - var3.y) {
- var3.sizeBy(0, ((View)this).superview().height() - var3.height - var3.y);
- }
-
- Size var4 = Size.newSize(var3.width - super.bounds.width, var3.height - super.bounds.height);
- this._checkSize(var4);
- if (this._resizePart == 1) {
- if (var3.x > super.bounds.x + super.bounds.width) {
- var3.moveBy(super.bounds.x - var3.x - var4.width, 0);
- } else {
- var3.moveBy(var3.width - super.bounds.width - var4.width, 0);
- }
- }
-
- var3.sizeBy(var4.width - (var3.width - super.bounds.width), var4.height - (var3.height - super.bounds.height));
- Size.returnSize(var4);
- InternalWindow var2 = (InternalWindow)_resizeWindowVector.elementAt(0);
- var5 = var3.height - var2.bounds.height;
- if (this._resizePart == 1) {
- if (var5 < 0) {
- var2 = (InternalWindow)_resizeWindowVector.elementAt(1);
- ((View)var2).sizeTo(1, var3.height);
- var2 = (InternalWindow)_resizeWindowVector.elementAt(2);
- var2.moveToAndSizeTo(var3.x + 1, var3.y, var3.width - 2, 1);
- var2 = (InternalWindow)_resizeWindowVector.elementAt(3);
- var2.moveToAndSizeTo(var3.x + 1, var3.maxY() - 1, var3.width - 2, 1);
- var2 = (InternalWindow)_resizeWindowVector.elementAt(0);
- var2.moveToAndSizeTo(var3.x, var3.y, 1, var3.height);
- } else {
- var2 = (InternalWindow)_resizeWindowVector.elementAt(0);
- var2.moveToAndSizeTo(var3.x, var3.y, 1, var3.height);
- var2 = (InternalWindow)_resizeWindowVector.elementAt(3);
- var2.moveToAndSizeTo(var3.x + 1, var3.maxY() - 1, var3.width - 2, 1);
- var2 = (InternalWindow)_resizeWindowVector.elementAt(2);
- var2.moveToAndSizeTo(var3.x + 1, var3.y, var3.width - 2, 1);
- var2 = (InternalWindow)_resizeWindowVector.elementAt(1);
- ((View)var2).sizeTo(1, var3.height);
- }
- } else if (this._resizePart == 2) {
- if (var5 < 0) {
- var2 = (InternalWindow)_resizeWindowVector.elementAt(1);
- ((View)var2).sizeTo(1, var3.height);
- var2 = (InternalWindow)_resizeWindowVector.elementAt(0);
- ((View)var2).sizeTo(1, var3.height);
- var2 = (InternalWindow)_resizeWindowVector.elementAt(3);
- var2.moveToAndSizeTo(var3.x + 1, var3.maxY() - 1, var2.bounds.width, var2.bounds.height);
- } else {
- var2 = (InternalWindow)_resizeWindowVector.elementAt(3);
- var2.moveToAndSizeTo(var3.x + 1, var3.maxY() - 1, var2.bounds.width, var2.bounds.height);
- var2 = (InternalWindow)_resizeWindowVector.elementAt(1);
- ((View)var2).sizeTo(1, var3.height);
- var2 = (InternalWindow)_resizeWindowVector.elementAt(0);
- ((View)var2).sizeTo(1, var3.height);
- }
- } else if (var5 < 0) {
- var2 = (InternalWindow)_resizeWindowVector.elementAt(0);
- ((View)var2).sizeTo(1, var3.height);
- var2 = (InternalWindow)_resizeWindowVector.elementAt(2);
- ((View)var2).sizeTo(var3.width - 2, 1);
- var2 = (InternalWindow)_resizeWindowVector.elementAt(3);
- var2.moveToAndSizeTo(var3.x + 1, var3.maxY() - 1, var3.width - 2, 1);
- var2 = (InternalWindow)_resizeWindowVector.elementAt(1);
- var2.moveToAndSizeTo(var3.maxX() - 1, var3.y, 1, var3.height);
- } else {
- var2 = (InternalWindow)_resizeWindowVector.elementAt(1);
- var2.moveToAndSizeTo(var3.maxX() - 1, var3.y, 1, var3.height);
- var2 = (InternalWindow)_resizeWindowVector.elementAt(3);
- var2.moveToAndSizeTo(var3.x + 1, var3.maxY() - 1, var3.width - 2, 1);
- var2 = (InternalWindow)_resizeWindowVector.elementAt(2);
- ((View)var2).sizeTo(var3.width - 2, 1);
- var2 = (InternalWindow)_resizeWindowVector.elementAt(0);
- ((View)var2).sizeTo(1, var3.height);
- }
-
- Rect.returnRect(var3);
- }
-
- public void mouseDragged(MouseEvent var1) {
- if (this._resizePart != 0) {
- this.mouseResizeDrag(var1);
- } else {
- int var14 = var1.x + super.bounds.x;
- int var15 = var1.y + super.bounds.y;
- int var11;
- if (this._type == 0) {
- var11 = -5;
- } else {
- var11 = -this.titleBarMargin() + 5;
- }
-
- int var13 = ((View)this).superview().height() - 5;
- int var9 = super.bounds.y + var15 - this._lastY;
- if (var9 < var11) {
- var15 = var11 + this._lastY - super.bounds.y;
- } else if (var9 > var13) {
- var15 = var13 + this._lastY - super.bounds.y;
- }
-
- int var10 = -super.bounds.width + 5;
- int var12 = ((View)this).superview().width() - 5;
- int var8 = super.bounds.x + var14 - this._lastX;
- if (var8 < var10) {
- var14 = var10 + this._lastX - super.bounds.x;
- } else if (var8 > var12) {
- var14 = var12 + this._lastX - super.bounds.x;
- }
-
- Point var7 = Point.newPoint(super.bounds.x + var14 - this._lastX, super.bounds.y + var15 - this._lastY);
- this.willMoveTo(var7);
- var14 = var7.x + this._lastX - super.bounds.x;
- var15 = var7.y + this._lastY - super.bounds.y;
- Point.returnPoint(var7);
- Rect var6 = Rect.newRect();
- ((View)this).computeVisibleRect(var6);
- Rect var4 = Rect.newRect();
- ((View)this).convertRectToView((View)null, var6, var4);
- Rect var5 = Rect.newRect(var6);
- var5.moveBy(var14 - this._lastX, var15 - this._lastY);
- boolean var18 = var6.contains(var5);
- ((View)this).convertRectToView((View)null, var5, var5);
- Vector var3 = this.rootView.windowRects(var5, this);
- if (this._dragStart) {
- if (var3 == null || var3.isEmpty()) {
- var3 = this.rootView.windowRects(var4, this);
- }
-
- this._dragStart = false;
- }
-
- boolean var16;
- boolean var17;
- if ((var3 == null || var3.isEmpty()) && var18 && !this.isTransparent()) {
- var16 = true;
- var17 = false;
- } else {
- var16 = false;
- var17 = true;
- if (!this.isTransparent() && super.drawingBuffer == null) {
- this._createdDrawingBuffer = true;
- ((View)this).setBuffered(true);
- this._drawToBackingStore = true;
- Graphics var19 = super.drawingBuffer.createGraphics();
- var19.setDebugOptions(((View)this).shouldDebugGraphics());
- this.draw(var19, (Rect)null);
- var19.dispose();
- Object var23 = null;
- this._drawToBackingStore = false;
- }
- }
-
- VectorCache.returnVector(var3);
- if (var16 && !this._drewOnLastDrag) {
- Graphics var2 = ((View)this).rootView().createGraphics();
- this._super_moveBy(var14 - this._lastX, var15 - this._lastY);
- var2.setClipRect(var6);
- var2.copyArea(var4.x, var4.y, var4.width, var4.height, super.bounds.x, super.bounds.y);
- var2.dispose();
- Object var20 = null;
- } else if (var16) {
- this._super_moveBy(var14 - this._lastX, var15 - this._lastY);
- this._drewOnLastDrag = false;
- var17 = true;
- } else {
- this._super_moveBy(var14 - this._lastX, var15 - this._lastY);
- }
-
- if (var17 && !this.isTransparent()) {
- if (super.drawingBuffer != null) {
- super.drawingBufferIsBitCache = true;
- }
-
- ((View)this).draw();
- if (super.drawingBuffer != null) {
- super.drawingBufferIsBitCache = false;
- }
-
- if (!var16) {
- this._drewOnLastDrag = true;
- }
- }
-
- if (this.isTransparent()) {
- ((View)this).draw();
- }
-
- this.rootView.disableWindowsAbove(this, true);
- this.rootView.redraw(var4);
- this.rootView.disableWindowsAbove(this, false);
- this._lastX = var14;
- this._lastY = var15;
- var4.unionWith(super.bounds);
- this.rootView.redrawTransparentWindows(var4, this);
- Rect.returnRect(var6);
- }
- }
-
- public void mouseUp(MouseEvent var1) {
- if (this._resizePart != 0) {
- InternalWindow var2 = (InternalWindow)_resizeWindowVector.elementAt(0);
- InternalWindow var3 = (InternalWindow)_resizeWindowVector.elementAt(1);
- if (this._resizePart == 1) {
- this.moveByAndSizeBy(var2.bounds.x - super.bounds.x, 0, var3.bounds.x - var2.bounds.x - super.bounds.width + 1, var2.bounds.height - super.bounds.height);
- } else {
- ((View)this).sizeTo(var3.bounds.x - var2.bounds.x + 1, var2.bounds.height);
- }
-
- int var4 = _resizeWindowVector.count();
-
- while(var4-- > 0) {
- var2 = (InternalWindow)_resizeWindowVector.elementAt(var4);
- var2.hide();
- }
-
- _resizeWindowVector.removeAllElements();
- this._resizePart = 0;
- }
-
- if (this._createdDrawingBuffer) {
- ((View)this).setBuffered(false);
- this._createdDrawingBuffer = false;
- }
-
- }
-
- void _drawLine(Graphics var1, int var2, int var3, int var4, Color var5, Color var6) {
- var1.setColor(var5);
-
- for(int var7 = var2; var7 <= var3; var7 += 2) {
- var1.drawLine(var7, var4, var7, var4);
- }
-
- var1.setColor(var6);
-
- for(int var8 = var2 + 1; var8 <= var3; var8 += 2) {
- var1.drawLine(var8, var4, var8, var4);
- }
-
- }
-
- public void drawView(Graphics var1) {
- if ((super.drawingBuffer == null || var1.isDrawingBuffer()) && this._type != 0) {
- this._border.drawInRect(var1, 0, 0, super.bounds.width, super.bounds.height);
- }
- }
-
- public void drawTitleBar() {
- if (this._type != 0) {
- Rect var1 = Rect.newRect(0, 0, super.bounds.width, this.titleBarMargin());
- ((View)this).draw(var1);
- Rect.returnRect(var1);
- }
- }
-
- public void drawBottomBorder() {
- if (this._type != 0) {
- Rect var1 = Rect.newRect(0, super.bounds.height - this.bottomBorderMargin(), super.bounds.width, this.bottomBorderMargin());
- ((View)this).draw(var1);
- Rect.returnRect(var1);
- }
- }
-
- public void draw(Graphics var1, Rect var2) {
- if (this.isTransparent() && (var1 == null || !var1.isDrawingBuffer()) && this.rootView._redrawTransWindows) {
- Object var3 = null;
- if (var3 == null || ((View)var3).isTransparent()) {
- this.updateDrawingBuffer();
- }
- }
-
- super.draw(var1, var2);
- }
-
- public void didBecomeMain() {
- this.drawTitleBar();
- if (this._owner != null) {
- this._owner.windowDidBecomeMain(this);
- }
-
- this.rootView.setFocusedView(this.focusedView(), false);
- if (this.containsDocument()) {
- Application.application().makeCurrentDocumentWindow(this);
- }
-
- }
-
- public void didResignMain() {
- this.drawTitleBar();
- if (this._owner != null) {
- this._owner.windowDidResignMain(this);
- }
-
- if (this.rootView != null) {
- this.rootView.setFocusedView((View)null, false);
- }
-
- }
-
- public void setContainsDocument(boolean var1) {
- this._containsDocument = var1;
- }
-
- public boolean containsDocument() {
- return this._containsDocument;
- }
-
- public void setCanBecomeDocument(boolean var1) {
- this.setContainsDocument(var1);
- }
-
- public boolean canBecomeDocument() {
- return this.containsDocument();
- }
-
- public void didBecomeCurrentDocument() {
- }
-
- public void didResignCurrentDocument() {
- }
-
- public boolean isCurrentDocument() {
- return Application.application().currentDocumentWindow() == this;
- }
-
- public void setFocusedView(View var1) {
- this._focusedView = var1;
- if (this.rootView != null) {
- if (this.rootView.mainWindow() == this && var1 != null) {
- this.rootView.makeWindowVisible(this, 0, (InternalWindow)null);
- }
-
- this.rootView.setFocusedView(this.focusedView());
- }
-
- }
-
- public View focusedView() {
- if (this._focusedView != null && this._focusedView.descendsFrom(this)) {
- return this._focusedView;
- } else {
- this._focusedView = null;
- return this._focusedView;
- }
- }
-
- public void describeClassInfo(ClassInfo var1) {
- super.describeClassInfo(var1);
- var1.addClass("netscape.application.InternalWindow", 3);
- var1.addField("owner", (byte)18);
- var1.addField("contentView", (byte)18);
- var1.addField("focusedView", (byte)18);
- var1.addField("closeButton", (byte)18);
- var1.addField("titleFont", (byte)18);
- var1.addField("title", (byte)16);
- var1.addField("border", (byte)18);
- var1.addField("layer", (byte)8);
- var1.addField("type", (byte)8);
- var1.addField("closeable", (byte)0);
- var1.addField("resizeable", (byte)0);
- var1.addField("canBecomeMain", (byte)0);
- var1.addField("canBecomeDocument", (byte)0);
- var1.addField("onscreen", (byte)0);
- var1.addField("transparent", (byte)0);
- var1.addField("scrollToVisible", (byte)0);
- var1.addField("defaultSelectedView", (byte)18);
- var1.addField("menuView", (byte)18);
- }
-
- public void encode(Encoder var1) throws CodingException {
- super.encode(var1);
- var1.encodeObject("owner", (Codable)this._owner);
- var1.encodeObject("contentView", this._contentView);
- var1.encodeObject("focusedView", this.focusedView());
- var1.encodeObject("closeButton", this._closeButton);
- var1.encodeObject("titleFont", this._titleFont);
- var1.encodeString("title", this._title);
- var1.encodeObject("border", this._border);
- var1.encodeInt("layer", this._layer);
- var1.encodeInt("type", this._type);
- var1.encodeBoolean("closeable", this._closeable);
- var1.encodeBoolean("resizeable", this._resizable);
- var1.encodeBoolean("canBecomeMain", this._canBecomeMain);
- var1.encodeBoolean("canBecomeDocument", this._containsDocument);
- var1.encodeBoolean("onscreen", this._onscreen);
- var1.encodeBoolean("transparent", this.transparent);
- var1.encodeBoolean("scrollToVisible", this.scrollToVisible);
- var1.encodeObject("defaultSelectedView", this._defaultSelectedView);
- var1.encodeObject("menuView", this.menuView);
- }
-
- public void decode(Decoder var1) throws CodingException {
- int var2 = var1.versionForClassName("netscape.application.TextField");
- super.decode(var1);
- this._owner = (WindowOwner)var1.decodeObject("owner");
- this._contentView = (WindowContentView)var1.decodeObject("contentView");
- this._focusedView = (View)var1.decodeObject("focusedView");
- this._closeButton = (Button)var1.decodeObject("closeButton");
- this._titleFont = (Font)var1.decodeObject("titleFont");
- this._title = var1.decodeString("title");
- this._border = (Border)var1.decodeObject("border");
- this._layer = var1.decodeInt("layer");
- this._type = var1.decodeInt("type");
- this._closeable = var1.decodeBoolean("closeable");
- this._resizable = var1.decodeBoolean("resizeable");
- this._canBecomeMain = var1.decodeBoolean("canBecomeMain");
- this._containsDocument = var1.decodeBoolean("canBecomeDocument");
- this._onscreen = var1.decodeBoolean("onscreen");
- this.transparent = var1.decodeBoolean("transparent");
- this.scrollToVisible = var1.decodeBoolean("scrollToVisible");
- if (var2 > 1) {
- this._defaultSelectedView = (View)var1.decodeObject("defaultSelectedView");
- }
-
- if (var2 > 2) {
- this.menuView = (MenuView)var1.decodeObject("menuView");
- }
-
- }
-
- public void finishDecoding() throws CodingException {
- super.finishDecoding();
- if (this._closeButton != null) {
- this._closeButton.removeAllCommandsForKeys();
- }
-
- }
-
- public String toString() {
- return this._title != null ? "InternalWindow (" + this._title + ")" : super.toString();
- }
-
- View ancestorWithDrawingBuffer() {
- return super.drawingBuffer != null ? this : null;
- }
-
- public InternalWindow window() {
- return this;
- }
-
- public Font font() {
- return this._titleFont;
- }
-
- public void performCommand(String var1, Object var2) {
- if ("show".equals(var1)) {
- this.show();
- } else if ("hide".equals(var1)) {
- this.hide();
- } else {
- throw new NoSuchMethodError("unknown command: " + var1);
- }
- }
-
- public boolean hidesSubviewsFromKeyboard() {
- return true;
- }
-
- public void setDefaultSelectedView(View var1) {
- this._defaultSelectedView = var1;
- }
-
- public View defaultSelectedView() {
- return this._defaultSelectedView;
- }
-
- public boolean canBecomeSelectedView() {
- return this.isMain();
- }
-
- boolean wantsKeyboardArrow() {
- return false;
- }
- }
-