⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 window.js

📁 Bindows 1.01 完全版 Bindows 框架提供给你: 基于类的面向对象 API; 一个完整的窗口系统
💻 JS
📖 第 1 页 / 共 5 页
字号:
            {                this._acceptButton.getCommand().execute()            }            e.preventDefault();            e.stopPropagation();        }        break;        case BiKeyboardEvent.ESC:        if (this._cancelButton && !t._acceptsEsc)        {            this._cancelButton.dispatchEvent(new BiEvent("action"));            if (this._cancelButton                && typeof this._cancelButton.getCommand == "function" && this._cancelButton.getCommand())            {                this._cancelButton.getCommand().execute()            }            e.preventDefault();            e.stopPropagation();        }        break;    }};_p._onKeyEvent = function(e){    e.stopPropagation();} ;_p.dispose = function(){    if (this._disposed)        return;    try    {        this._element.outerHTML = "";    }    catch (ex)    {    }    BiComponent.prototype.dispose.call(this);    for (var c in this._commands)        delete this._commands;    this._commands = null;    this._focusManager.dispose();    this._resizeHandler.dispose();    this._moveHandler.dispose();    this._activeComponent = null;    this._lastActive = null;    this._icon = null;    this._focusManager = null;    this._resizeHandler = null;    this._moveHandler = null;    this._acceptButton = null;    this._cancelButton = null;};_p.addXmlNode = function(oNode, oXmlResourceParser){    if (oNode.nodeType == 1)    {        var o = oXmlResourceParser.fromNode(oNode);        if (o instanceof BiComponent)            this._contentPane.add(o);        else if (o instanceof BiCommand)            this.addCommand(o);    }};function BiWindowManager(oComponent){    BiObject.call(this);    this._windows = [];    this._menuItemsHash = {    };    this._lastStatesHash = {    };    this._component = oComponent;}var _p = BiWindowManager.prototype = new BiObject;_p._className = "BiWindowManager";BiWindowManager.CASCADE_ICON = application.getPath() + "images/cascade.16.gif";BiWindowManager.TILE_HORIZONTALLY_ICON = application.getPath() + "images/tilehorizontally.16.gif";BiWindowManager.TILE_VERTICALLY_ICON = application.getPath() + "images/tilevertically.16.gif";BiWindowManager.CLOSE_ALL_ICON = BiImage.BLANK_IMAGE_URI;_p._component = null;_p._lastLeft = 0;_p._lastTop = 0;_p._positionOffset = 25;_p._activeWindow = null;BiWindowManager.prototype.getComponent = function(){    return this._component;} ;BiWindowManager.prototype.setComponent = function(v){    this._component = v;} ;BiWindowManager.prototype.getWindows = function(){    return this._windows;} ;BiWindowManager.prototype.getActiveWindow = function(){    return this._activeWindow;} ;_p.setActiveWindow = function(oWindow){    if (oWindow != null)        oWindow.setActive(true);    else if (this._activeWindow != null)        this._activeWindow.setActive(false);};_p.getWindowsMenu = function(){    if (this._windowsMenu == null)        this._createWindowsMenu();    return this._windowsMenu;};_p.add = function(oWindow){    if (this._windows.contains(oWindow))        return;    this._windows.push(oWindow);    if (oWindow._left == null)        this._positionWindowX(oWindow);    if (oWindow._top == null)        this._positionWindowY(oWindow);    oWindow.addEventListener("close", this._onclose, this);    oWindow.addEventListener("statechanged", this._onstatechanged, this);    oWindow.addEventListener("activated", this._onactivatechanged, this);    oWindow.addEventListener("deactivated", this._onactivatechanged, this);    oWindow.addEventListener("captionchanged", this._oncaptionchanged, this);    if (oWindow.getActive())        this._activeWindow = oWindow;    if (this._windowsMenu)    {        var mi = new BiRadioButtonMenuItem(oWindow.getCaption(), oWindow.getActive());        mi.addEventListener("action", this._onmenuitemaction, this)        this._menuItemsHash[oWindow.toHashCode()] = mi;        mi._menuItemForWindow = oWindow;        if (this._windows.length > 0)            this._separatorItem.setVisible(true);        this._windowsMenu.add(mi);    }};_p.remove = function(oWindow){    if (!this._windows.contains(oWindow))        return oWindow;    if (this._windowsMenu)    {        var mi = this._menuItemsHash[oWindow.toHashCode()];        this._windowsMenu.remove(mi);        mi._menuItemForWindow = null;        mi.dispose();    }    oWindow.removeEventListener("close", this._onclose, this);    oWindow.removeEventListener("statechanged", this._onstatechanged, this);    oWindow.removeEventListener("activated", this._onactivatechanged, this);    oWindow.removeEventListener("deactivated", this._onactivatechanged, this);    oWindow.removeEventListener("captionchanged", this._oncaptionchanged, this);    if (this._activeWindow == oWindow)        this._activeWindow = null;    this._windows.remove(oWindow);    if (this._windowsMenu)    {        delete this._menuItemsHash[oWindow.toHashCode()];        if (this._windows.length == 0)            this._separatorItem.setVisible(false);    }    return oWindow;};_p._positionWindowX = function(oWindow){    if (!oWindow.getMovable())        return;    if (oWindow.getCreated() && oWindow.getWidth() + this._lastLeft > this._component.getClientWidth())        this._lastLeft = 0;    oWindow.setLeft(this._lastLeft);    this._lastLeft += this._positionOffset;};_p._positionWindowY = function(oWindow){    if (!oWindow.getMovable())        return;    if (oWindow.getCreated() && oWindow.getHeight() + this._lastTop > this._component.getClientHeight())        this._lastTop = 0;    oWindow.setTop(this._lastTop);    this._lastTop += this._positionOffset;};_p.cascade = function(){    var sorted = this._getShownWindows();    sorted.sort(this._compareByZIndex);    this._lastLeft = 0;    this._lastTop = 0;    var w = this._component.getClientWidth() * 0.75;    var h = this._component.getClientHeight() * 0.75;    for (var i = 0; i < sorted.length; i++)    {        if (sorted[i].getState() == "maximized")            sorted[i].setState("normal");        if (sorted[i].getResizable())            sorted[i].setSize(w, h);        this._positionWindowX(sorted[i]);        this._positionWindowY(sorted[i]);    }};_p.tileVertically = function(){    var sorted = this._getShownWindows();    sorted.sort(this._compareByZIndex);    sorted.reverse();    var l = sorted.length;    if (l == 0)        return;    var cw = this._component.getClientWidth();    var ch = this._component.getClientHeight();    var w = cw / l;    var x = 0;    for (var i = 0; i < l; i++)    {        if (sorted[i].getState() == "maximized")            sorted[i].setState("normal");        if (sorted[i].getResizable() && sorted[i].getMovable())            sorted[i].setBounds(x, 0, w, ch);        else if (sorted[i].getResizable())            sorted[i].setSize(w, ch);        else if (sorted[i].getMovable())            sorted[i].setLocation(x, 0);        x += w;    }};_p.tileHorizontally = function(){    var sorted = this._getShownWindows();    sorted.sort(this._compareByZIndex);    sorted.reverse();    var l = sorted.length;    if (l == 0)        return;    var cw = this._component.getClientWidth();    var ch = this._component.getClientHeight();    var h = ch / l;    var y = 0;    for (var i = 0; i < l; i++)    {        if (sorted[i].getState() == "maximized")            sorted[i].setState("normal");        if (sorted[i].getResizable() && sorted[i].getMovable())            sorted[i].setBounds(0, y, cw, h);        else if (sorted[i].getResizable())            sorted[i].setSize(cw, h);        else if (sorted[i].getMovable())            sorted[i].setLocation(0, y);        y += h;    }};_p.closeAll = function(){    for (var i = this._windows.length - 1; i >= 0; i--)        this._windows[i].close();};_p.minimizeAll = function(){    for (var i = this._windows.length - 1; i >= 0; i--)        this._windows[i].setState("minimize");};_p._compareByZIndex = function(w1, w2){    return w1.getZIndex() - w2.getZIndex();} ;_p.getLastState = function(oWindow){    return this._lastStatesHash[oWindow.toHashCode()];} ;_p.activateNext = function(){    var sorted = this._getShownWindows();    if (sorted.length < 1)        return;    sorted.sort(this._compareByZIndex);    sorted[sorted.length - 1].setActive(true);};_p._createWindowsMenu = function(){    this._windowsMenu = new BiMenu;    this._cascadeItem = new BiMenuItem("Cascade");    this._cascadeItem.setMnemonic("s");    this._cascadeItem.setIcon(new BiImage(BiWindowManager.CASCADE_ICON));    this._windowsMenu.add(this._cascadeItem);    this._tileHorizontallyItem = new BiMenuItem("Tile Horizontally");    this._tileHorizontallyItem.setMnemonic("h");    this._tileHorizontallyItem.setIcon(new BiImage(BiWindowManager.TILE_HORIZONTALLY_ICON));    this._windowsMenu.add(this._tileHorizontallyItem);    this._tileVerticallyItem = new BiMenuItem("Tile Vertically");    this._tileVerticallyItem.setMnemonic("v");    this._tileVerticallyItem.setIcon(new BiImage(BiWindowManager.TILE_VERTICALLY_ICON));    this._windowsMenu.add(this._tileVerticallyItem);    this._closeAllItem = new BiMenuItem("Close All");    this._closeAllItem.setMnemonic("a");    this._closeAllItem.setIcon(new BiImage(BiWindowManager.CLOSE_ALL_ICON));    this._windowsMenu.add(this._closeAllItem);    this._separatorItem = new BiMenuSeparator;    this._separatorItem.setVisible(false);    this._windowsMenu.add(this._separatorItem);    this._cascadeItem.addEventListener("action", this.cascade, this);    this._tileHorizontallyItem.addEventListener("action", this.tileHorizontally, this);    this._tileVerticallyItem.addEventListener("action", this.tileVertically, this);    this._closeAllItem.addEventListener("action", this.closeAll, this);    for (var i = 0; i < this._windows.length; i++)    {        var win = this._windows[i];        var mi = new BiRadioButtonMenuItem(win.getCaption(), win.getActive());        mi.addEventListener("action", this._onmenuitemaction, this)        this._menuItemsHash[win.toHashCode()] = mi;        mi._menuItemForWindow = win;        this._windowsMenu.add(mi);    }    if (this._windows.length > 0)        this._separatorItem.setVisible(true);};_p._getShownWindows = function(){    var res = [];    for (var i = 0; i < this._windows.length; i++)    {        if (this._windows[i].getIsVisible())            res.push(this._windows[i]);    }    return res;};_p._onclose = function(e){    var win = e.getTarget();    this.remove(win);};_p._onstatechanged = function(e){    var win = e.getTarget();    if (win.getState() != "minimized")        this._lastStatesHash[win.toHashCode()] = win.getState();    else    {        if (win.getActive())            this.activateNext();        if (win.getActive())            win.setActive(false);    }};_p._onmenuitemaction = function(e){    var mi = e.getTarget();    var win = mi._menuItemForWindow;    if (win.getState() == "minimized")        win.setState(this.getLastState(win));    win.setActive(true);};_p._onactivatechanged = function(e){    var win = e.getTarget();    if (this._windowsMenu)    {        var mi = this._menuItemsHash[win.toHashCode()];        mi.setValue(win.getActive());    }    if (win.getActive())        this._activeWindow = win;};_p._oncaptionchanged = function(e){    var win = e.getTarget();    if (this._windowsMenu)    {        var mi = this._menuItemsHash[win.toHashCode()];        mi.setText(win.getCaption());    }};_p.dispose = function(){    if (this._disposed)        return;    BiObject.prototype.dispose.call(this);    this._windows = null;    this._menuItemsHash = null;    this._lastStatesHash = null;    this._component = null;    this._activeWindow = null;    if (this._windowsMenu)    {        var cs = this._windowsMenu.getChildren();        for (var i = cs.length - 1; i >= 0; i--)        {            cs[i]._menuItemForWindow = null;        }        this._windowsMenu.dispose();        this._windowsMenu = null;    }};function BiDesktopPane(){    BiComponent.call(this);    this.setBackColor("AppWorkspace");    this._windowManager = new BiWindowManager(this);}var _p = BiDesktopPane.prototype = new BiComponent;_p._className = "BiDesktopPane";

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -