📄 window.js
字号:
_p.setShowClose = function(b){ if (this._showClose != b) { this._showClose = b; this._closeButton.setVisible(b); this._layoutChrome(); }};_p.setCaption = function(sCaption){ var oldCaption = this._captionLabel.getText(); this._captionLabel.setText(sCaption); if (oldCaption != this._captionLabel.getText()) this.dispatchEvent(new BiEvent("captionchanged"));};_p.getCaption = function(){ return this._captionLabel.getText();} ;_p.getIcon = function(){ if (this._icon == null) this._icon = new BiImage(this._windowIcon.getUri(), 16, 16); return this._icon;};_p.setIcon = function(oImage){ if (oImage == null) oImage = new BiImage(BiWindow.DEFAULT_ICON, 16, 16); var oldUri = this.getIcon().getUri(); this._windowIcon.setUri(oImage.getUri()); this._icon = oImage; if (oldUri != oImage.getUri()) this.dispatchEvent(new BiEvent("iconchanged"));};_p.setCanMinimize = function(b){ if (this._canMinimize != b) { this._canMinimize = b; this._minimizeButton.setEnabled(b); }};BiWindow.prototype.getCanMinimize = function(){ return this._canMinimize;} ;_p.setHideChrome = function(b){ if (this._hideChrome != b) { this._hideChrome = b; this._windowCaption.setVisible(!b); this._setContentPaneSize(); }};_p._setContentPaneSize = function(){ if (this._hideChrome) { this._contentPane.setLocation(0, 0); this._contentPane.setRight(0); this._contentPane.setBottom(0); } else { this._contentPane.setLocation(2, 21); this._contentPane.setRight(2); this._contentPane.setBottom(2); }};BiWindow.prototype.getHideChrome = function(){ return this._hideChrome;} ;_p.setResizable = function(b){ if (this._resizable != b) { this._resizable = b; this._maximizeButton.setEnabled(b); }};BiWindow.prototype.getResizable = function(){ return this._resizable;} ;_p.getMovable = function(){ return this.getState() == "normal" && this._movable;} ;BiWindow.prototype.setMovable = function(v){ this._movable = v;} ;_p.getMaximumWidth = function(){ return this._maximumWidth;} ;_p.getMinimumWidth = function(){ return this._minimumWidth;} ;_p.getMaximumHeight = function(){ return this._maximumHeight;} ;_p.getMinimumHeight = function(){ return this._minimumHeight;} ;_p.getPreferredWidth = function(){ return this.getInsetLeft() + this._contentPane.getLeft() + this._contentPane.getPreferredWidth() + this._contentPane.getRight() + this.getInsetRight();} ;_p.getPreferredHeight = function(){ return this.getInsetTop() + this._contentPane.getTop() + this._contentPane.getPreferredHeight() + this._contentPane.getBottom() + this.getInsetBottom();} ;_p.layoutComponentX = function(){ if (this._width != null) this._width = Math.max(this.getMinimumWidth(), Math.min(this.getMaximumWidth(), this._width)); BiComponent.prototype.layoutComponentX.call(this);};_p.layoutComponentY = function(){ if (this._height != null) this._height = Math.max(this.getMinimumHeight(), Math.min(this.getMaximumHeight(), this._height)); BiComponent.prototype.layoutComponentY.call(this);};_p.layoutComponent = function(){ if (this._width != null) this._width = Math.max(this.getMinimumWidth(), Math.min(this.getMaximumWidth(), this._width)); if (this._height != null) this._height = Math.max(this.getMinimumHeight(), Math.min(this.getMaximumHeight(), this._height)); BiComponent.prototype.layoutComponent.call(this);};_p.close = function(){ var rv = this.dispatchEvent(new BiEvent("beforeclose")); if (rv) { if (this._parent) this._parent.remove(this); this.dispatchEvent(new BiEvent("close")); this.dispose(); }};_p.setState = function(s){ if (s == "minimized" && !this._canMinimize || s == "maximized" && !this._resizable) return; if (this._state != s) { if (this._state == "normal") { this._normalWidth = this.getWidth(); this._normalHeight = this.getHeight(); this._normalLeft = this.getLeft(); this._normalTop = this.getTop(); if (this._normalLeft == null) this._normalLeft = 0; if (this._normalTop == null) this._normalTop = 0; } this._state = s; this.setVisible(this._state != "minimized"); if (this._state == "maximized") { var h = this.getContentPane().getHeight(); this.setLocation(-4, -4); this.setRight(-4); this.setBottom(-4); this._maximizeButton.setHtml("<span>2</span>"); this._maximizeButton._setHtmlAttribute("buttontype", "restore"); if (h <= 0) this.layoutAllChildren(); } else if (this._state == "normal") { this.setLocation(this._normalLeft, this._normalTop); this.setRight(null); this.setBottom(null); this.setSize(this._normalWidth, this._normalHeight); this._maximizeButton.setHtml("<span>1</span>"); this._maximizeButton._setHtmlAttribute("buttontype", "maximize"); } this.dispatchEvent(new BiEvent("statechanged")); }};BiWindow.prototype.getState = function(){ return this._state;} ;_p.activate = function(){ this.setActive(true);} ;_p.setActive = function(b){ if (this._active != b) { this._active = b; this.setCssClassName("bi-window" + (b ? " active" : "")); if (b) { this.bringToFront(); this.setFocused(true); this.dispatchEvent(new BiEvent("activated")); } else { this.setFocused(false); this.dispatchEvent(new BiEvent("deactivated")); } }};BiWindow.prototype.getActive = function(){ return this._active;} ;_p.bringToFront = function(){ var p = this._parent; if (this.getCreated() && p) { var cs = p.getChildren(); var max = -Infinity; for (var i = 0; i < cs.length; i++) max = Math.max(max, cs[i].getZIndex()); } this.setZIndex(max + 1);};_p.sendToBack = function(){ var p = this._parent; if (this.getCreated() && p) { var cs = p.getChildren(); var min = Infinity; for (var i = 0; i < cs.length; i++) min = Math.min(min, cs[i].getZIndex()); } this.setZIndex(min - 1);};_p.getFocusRoot = function(){ return this;} ;_p.isFocusRoot = function(){ return true;} ;_p.getActiveComponent = function(){ if (this._activeComponent && this._activeComponent.getDisposed()) this._activeComponent = null; return this._activeComponent;};BiWindow.prototype.getAcceptButton = function(){ return this._acceptButton;} ;BiWindow.prototype.setAcceptButton = function(v){ this._acceptButton = v;} ;BiWindow.prototype.getCancelButton = function(){ return this._cancelButton;} ;BiWindow.prototype.setCancelButton = function(v){ this._cancelButton = v;} ;_p.addCommand = function(c){ if (c.getOwnerWindow()) c.getOwnerWindow().removeCommand(c); this._commands[c.toHashCode()] = c; c._ownerWindow = this;};_p.removeCommand = function(c){ delete this._commands[c.toHashCode()]; c._ownerWindow = null;};_p._onCloseButtonClick = function(e){ this.close();} ;_p._onMinimizeButtonClick = function(e){ if (this._canMinimize) this.setState("minimized");};_p._onMaximizeButtonClick = function(e){ if (this._resizable) { if (this.getState() == "normal") this.setState("maximized"); else this.setState("normal"); }};_p._onCaptionDown = function(e){ this.setActive(true); if (!this.getMovable()) return; this._moveHandler.startMove(e);};_p._onMouseEvent = function(e){ e.stopPropagation();} ;_p._checkForResize = function(e){ if (this._resizeData) return; this._resizeDir = ""; if (this._moveData == null && e.getTarget() == this) { if (this.getResizable()) { var oy = e.getOffsetY(); if (oy <= 20) this._resizeDir += "n"; else if (oy >= this.getHeight() - 20) this._resizeDir += "s"; var ox = e.getOffsetX(); if (ox <= 20) this._resizeDir += "w"; else if (ox >= this.getWidth() - 20) this._resizeDir += "e"; } if (this._resizeDir != "") this.setCursor(this._resizeDir + "-resize"); else this.setCursor("default"); }};_p._onEdgeDown = function(e){ this.setActive(true); if (this._resizeDir != "" && e.getTarget() == this) { this._resizeHandler.startResize(this._resizeDir, e); }};_p._onFocus = function(e){ if (this._lastActive && this.contains(this._lastActive) && this._lastActive.getCanFocus()) { this._lastActive.setFocused(true); }};_p._onFocusIn = function(e){ if (e.getTarget() != this) this._lastActive = e.getTarget(); this.activate(); e.stopPropagation();};_p._onFocusOut = function(e){ if (this.contains(e.getRelatedTarget())) return; else this.setActive(false); e.stopPropagation();};_p._onkeydown = function(e){ this._focusManager.processKeyEvent(this, e);} ;_p._onDefaultButtonKeyDown = function(e){ var c; for (var hc in this._commands) { c = this._commands[hc]; if (c.matchesKeyboardEvent(e)) { c.execute(); e.preventDefault(); } } var t = e.getTarget(); switch (e.getKeyCode()) { case BiKeyboardEvent.ENTER: if (this._acceptButton && !t._acceptsEnter && !e.getAltKey()) { this._acceptButton.dispatchEvent(new BiEvent("action")); if (this._acceptButton && typeof this._acceptButton.getCommand == "function" && this._acceptButton.getCommand())
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -