diff options
Diffstat (limited to 'webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/toolbar')
8 files changed, 901 insertions, 0 deletions
diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/toolbar/Button.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/toolbar/Button.js new file mode 100644 index 0000000000..a231960872 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/toolbar/Button.js @@ -0,0 +1,47 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + +#module(ui_toolbar) + +************************************************************************ */ + +qx.OO.defineClass("qx.ui.toolbar.Button", qx.ui.form.Button, +function(vText, vIcon, vIconWidth, vIconHeight, vFlash) +{ + qx.ui.form.Button.call(this, vText, vIcon, vIconWidth, vIconHeight, vFlash); + + // Omit focus + this.setTabIndex(-1); +}); + +qx.OO.changeProperty({ name : "appearance", type : "string", defaultValue : "toolbar-button" }); + + + + + +/* +--------------------------------------------------------------------------- + EVENT HANDLER +--------------------------------------------------------------------------- +*/ + +qx.Proto._onkeydown = qx.util.Return.returnTrue; +qx.Proto._onkeyup = qx.util.Return.returnTrue; diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/toolbar/CheckBox.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/toolbar/CheckBox.js new file mode 100644 index 0000000000..781a8bc794 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/toolbar/CheckBox.js @@ -0,0 +1,86 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + +#module(ui_toolbar) + +************************************************************************ */ + +qx.OO.defineClass("qx.ui.toolbar.CheckBox", qx.ui.toolbar.Button, +function(vText, vIcon, vChecked) +{ + qx.ui.toolbar.Button.call(this, vText, vIcon); + + if (qx.util.Validation.isValid(vChecked)) { + this.setChecked(vChecked); + } +}); + + + +/* +--------------------------------------------------------------------------- + PROPERTIES +--------------------------------------------------------------------------- +*/ + +qx.OO.addProperty({ name : "checked", type : "boolean", defaultValue : false, getAlias:"isChecked" }); + + + + + +/* +--------------------------------------------------------------------------- + MODIFIER +--------------------------------------------------------------------------- +*/ + +qx.Proto._modifyChecked = function(propValue, propOldValue, propData) +{ + propValue ? this.addState("checked") : this.removeState("checked"); + return true; +} + + + + + +/* +--------------------------------------------------------------------------- + EVENTS +--------------------------------------------------------------------------- +*/ + +qx.Proto._onmouseup = function(e) +{ + this.setCapture(false); + + if (!this.hasState("abandoned")) + { + this.addState("over"); + this.setChecked(!this.getChecked()); + this.execute(); + } + + this.removeState("abandoned"); + this.removeState("pressed"); + + e.stopPropagation(); +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/toolbar/MenuButton.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/toolbar/MenuButton.js new file mode 100644 index 0000000000..a06c26fdc1 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/toolbar/MenuButton.js @@ -0,0 +1,258 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + +#module(ui_toolbar) +#module(ui_menu) + +************************************************************************ */ + +qx.OO.defineClass("qx.ui.toolbar.MenuButton", qx.ui.toolbar.Button, +function(vText, vMenu, vIcon, vIconWidth, vIconHeight, vFlash) +{ + qx.ui.toolbar.Button.call(this, vText, vIcon, vIconWidth, vIconHeight, vFlash); + + if (qx.util.Validation.isValidObject(vMenu)) { + this.setMenu(vMenu); + } + + /* + this._menuButton = new qx.ui.basic.Image("widget/arrows/down_small.gif"); + this._menuButton.setAnonymous(true); + this.addAtEnd(this._menuButton); + */ +}); + + + + +/* +--------------------------------------------------------------------------- + PROPERTIES +--------------------------------------------------------------------------- +*/ + +qx.OO.addProperty({ name : "menu", type : "object", instance : "qx.ui.menu.Menu" }); +qx.OO.addProperty({ name : "direction", type : "string", allowNull : false, possibleValues : [ "up", "down" ], defaultValue : "down" }); + + + + +/* +--------------------------------------------------------------------------- + UTILITIES +--------------------------------------------------------------------------- +*/ + +qx.Proto.getParentToolBar = function() +{ + var vParent = this.getParent(); + + if (vParent instanceof qx.ui.toolbar.Part) { + vParent = vParent.getParent(); + } + + return vParent instanceof qx.ui.toolbar.ToolBar ? vParent : null; +} + +qx.Proto._showMenu = function(vFromKeyEvent) +{ + var vMenu = this.getMenu(); + + if (vMenu) + { + // Caching common stuff + var vMenuParent = vMenu.getParent(); + var vMenuParentElement = vMenuParent.getElement(); + var vButtonElement = this.getElement(); + var vButtonHeight = qx.dom.Dimension.getBoxHeight(vButtonElement); + + // Apply X-Location + var vMenuParentLeft = qx.dom.Location.getPageBoxLeft(vMenuParentElement); + var vButtonLeft = qx.dom.Location.getPageBoxLeft(vButtonElement); + + vMenu.setLeft(vButtonLeft - vMenuParentLeft); + + // Apply Y-Location + switch(this.getDirection()) + { + case "up": + var vBodyHeight = qx.dom.Dimension.getInnerHeight(document.body); + var vMenuParentBottom = qx.dom.Location.getPageBoxBottom(vMenuParentElement); + var vButtonBottom = qx.dom.Location.getPageBoxBottom(vButtonElement); + + vMenu.setBottom(vButtonHeight + (vBodyHeight - vButtonBottom) - (vBodyHeight - vMenuParentBottom)); + vMenu.setTop(null); + break; + + case "down": + var vButtonTop = qx.dom.Location.getPageBoxTop(vButtonElement); + + vMenu.setTop(vButtonTop + vButtonHeight); + vMenu.setBottom(null); + break; + } + + this.addState("pressed"); + + // If this show is called from a key event occured, we want to highlight + // the first menubutton inside. + if (vFromKeyEvent) { + vMenu.setHoverItem(vMenu.getFirstActiveChild()); + } + + vMenu.show(); + } +} + +qx.Proto._hideMenu = function() +{ + var vMenu = this.getMenu(); + + if (vMenu) { + vMenu.hide(); + } +} + + + + + +/* +--------------------------------------------------------------------------- + MODIFIERS +--------------------------------------------------------------------------- +*/ + +qx.Proto._modifyMenu = function(propValue, propOldValue, propData) +{ + if (propOldValue) + { + propOldValue.setOpener(null); + + propOldValue.removeEventListener("appear", this._onmenuappear, this); + propOldValue.removeEventListener("disappear", this._onmenudisappear, this); + } + + if (propValue) + { + propValue.setOpener(this); + + propValue.addEventListener("appear", this._onmenuappear, this); + propValue.addEventListener("disappear", this._onmenudisappear, this); + } + + return true; +} + + + + + + +/* +--------------------------------------------------------------------------- + EVENTS: MOUSE +--------------------------------------------------------------------------- +*/ + +qx.Proto._onmousedown = function(e) +{ + if (e.getTarget() != this || !e.isLeftButtonPressed()) { + return; + } + + this.hasState("pressed") ? this._hideMenu() : this._showMenu(); +} + +qx.Proto._onmouseup = function(e) {} + +qx.Proto._onmouseout = function(e) +{ + if (e.getTarget() != this) { + return; + } + + this.removeState("over"); +} + +qx.Proto._onmouseover = function(e) +{ + var vToolBar = this.getParentToolBar(); + + if (vToolBar) + { + var vMenu = this.getMenu(); + + switch(vToolBar.getOpenMenu()) + { + case null: + case vMenu: + break; + + default: + // hide other menus + qx.manager.object.MenuManager.getInstance().update(); + + // show this menu + this._showMenu(); + } + } + + return qx.ui.toolbar.Button.prototype._onmouseover.call(this, e); +} + + + + + + +/* +--------------------------------------------------------------------------- + EVENTS: MENU +--------------------------------------------------------------------------- +*/ + +qx.Proto._onmenuappear = function(e) +{ + var vToolBar = this.getParentToolBar(); + + if (!vToolBar) { + return; + } + + var vMenu = this.getMenu(); + + vToolBar.setOpenMenu(vMenu); +} + +qx.Proto._onmenudisappear = function(e) +{ + var vToolBar = this.getParentToolBar(); + + if (!vToolBar) { + return; + } + + var vMenu = this.getMenu(); + + if (vToolBar.getOpenMenu() == vMenu) { + vToolBar.setOpenMenu(null); + } +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/toolbar/Part.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/toolbar/Part.js new file mode 100644 index 0000000000..292a9045c4 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/toolbar/Part.js @@ -0,0 +1,82 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + +#module(ui_toolbar) + +************************************************************************ */ + +qx.OO.defineClass("qx.ui.toolbar.Part", qx.ui.layout.HorizontalBoxLayout, +function() +{ + qx.ui.layout.HorizontalBoxLayout.call(this); + + this._handle = new qx.ui.toolbar.PartHandle; + this.add(this._handle); +}); + +qx.OO.changeProperty({ name : "appearance", type : "string", defaultValue : "toolbar-part" }); + + + + + +/* +--------------------------------------------------------------------------- + CLONE +--------------------------------------------------------------------------- +*/ + +// Omit recursive cloning of qx.ui.toolbar.PartHandle +qx.Proto._cloneRecursive = function(cloneInstance) +{ + var vChildren = this.getChildren(); + var vLength = vChildren.length; + + for (var i=0; i<vLength; i++) { + if (!(vChildren[i] instanceof qx.ui.toolbar.PartHandle)) { + cloneInstance.add(vChildren[i].clone(true)); + } + } +} + + + + + +/* +--------------------------------------------------------------------------- + DISPOSER +--------------------------------------------------------------------------- +*/ + +qx.Proto.dispose = function() +{ + if (this.getDisposed()) { + return; + } + + if (this._handle) + { + this._handle.dispose(); + this._handle = null; + } + + return qx.ui.layout.HorizontalBoxLayout.prototype.dispose.call(this); +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/toolbar/PartHandle.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/toolbar/PartHandle.js new file mode 100644 index 0000000000..4e50692832 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/toolbar/PartHandle.js @@ -0,0 +1,35 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + +#module(ui_toolbar) + +************************************************************************ */ + +qx.OO.defineClass("qx.ui.toolbar.PartHandle", qx.ui.layout.CanvasLayout, +function() +{ + qx.ui.layout.CanvasLayout.call(this); + + var l = new qx.ui.basic.Terminator; + l.setAppearance("toolbar-part-handle-line"); + this.add(l); +}); + +qx.OO.changeProperty({ name : "appearance", type : "string", defaultValue : "toolbar-part-handle" }); diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/toolbar/RadioButton.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/toolbar/RadioButton.js new file mode 100644 index 0000000000..fd222a214c --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/toolbar/RadioButton.js @@ -0,0 +1,116 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + +#module(ui_toolbar) + +************************************************************************ */ + +qx.OO.defineClass("qx.ui.toolbar.RadioButton", qx.ui.toolbar.CheckBox, +function(vText, vIcon, vChecked) { + qx.ui.toolbar.CheckBox.call(this, vText, vIcon, vChecked); +}); + + + + +/* +--------------------------------------------------------------------------- + PROPERTIES +--------------------------------------------------------------------------- +*/ + +/*! + The assigned qx.manager.selection.RadioManager which handles the switching between registered buttons +*/ +qx.OO.addProperty({ name : "manager", type : "object", instance : "qx.manager.selection.RadioManager", allowNull : true }); + +/*! + The name of the radio group. All the radio elements in a group (registered by the same manager) + have the same name (and could have a different value). +*/ +qx.OO.addProperty({ name : "name", type : "string" }); + +/*! + Prohibit the deselction of the checked radio button when clicked on it. +*/ +qx.OO.addProperty({ name : "disableUncheck", type : "boolean", defaultValue : false }); + + + + + + +/* +--------------------------------------------------------------------------- + MODIFIER +--------------------------------------------------------------------------- +*/ + +qx.Proto._modifyChecked = function(propValue, propOldValue, propData) +{ + qx.ui.toolbar.CheckBox.prototype._modifyChecked.call(this, propValue, propOldValue, propData); + + var vManager = this.getManager(); + if (vManager) { + vManager.handleItemChecked(this, propValue); + } + + return true; +} + +qx.Proto._modifyManager = function(propValue, propOldValue, propData) +{ + if (propOldValue) { + propOldValue.remove(this); + } + + if (propValue) { + propValue.add(this); + } + + return true; +} + + + + + +/* +--------------------------------------------------------------------------- + EVENTS +--------------------------------------------------------------------------- +*/ + +qx.Proto._onmouseup = function(e) +{ + this.setCapture(false); + + if (!this.hasState("abandoned")) + { + this.addState("over"); + this.setChecked(this.getDisableUncheck() || !this.getChecked()); + this.execute(); + } + + this.removeState("abandoned"); + this.removeState("pressed"); + + e.stopPropagation(); +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/toolbar/Separator.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/toolbar/Separator.js new file mode 100644 index 0000000000..61c07ee760 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/toolbar/Separator.js @@ -0,0 +1,35 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + +#module(ui_toolbar) + +************************************************************************ */ + +qx.OO.defineClass("qx.ui.toolbar.Separator", qx.ui.layout.CanvasLayout, +function() +{ + qx.ui.layout.CanvasLayout.call(this); + + var l = new qx.ui.basic.Terminator; + l.setAppearance("toolbar-separator-line"); + this.add(l); +}); + +qx.OO.changeProperty({ name : "appearance", type : "string", defaultValue : "toolbar-separator" }); diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/toolbar/ToolBar.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/toolbar/ToolBar.js new file mode 100644 index 0000000000..c3ada9e29c --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/toolbar/ToolBar.js @@ -0,0 +1,242 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + +#module(ui_toolbar) + +************************************************************************ */ + +qx.OO.defineClass("qx.ui.toolbar.ToolBar", qx.ui.layout.HorizontalBoxLayout, +function() +{ + qx.ui.layout.HorizontalBoxLayout.call(this); + + this.addEventListener("keypress", this._onkeypress); +}); + + + +/* +--------------------------------------------------------------------------- + PROPERTIES +--------------------------------------------------------------------------- +*/ + +qx.OO.addProperty({ name : "openMenu", type : "object", instance : "qx.ui.menu.Menu" }); + +/*! + Appearance of the widget +*/ +qx.OO.changeProperty({ name : "appearance", type : "string", defaultValue : "toolbar" }); + + + + + + + + + +/* +--------------------------------------------------------------------------- + UTILITIES +--------------------------------------------------------------------------- +*/ + +qx.Proto.getAllButtons = function() +{ + var vChildren = this.getChildren(); + var vLength = vChildren.length; + var vDeepChildren = []; + var vCurrent; + + for (var i=0; i<vLength; i++) + { + vCurrent = vChildren[i]; + + if (vCurrent instanceof qx.ui.toolbar.MenuButton) + { + vDeepChildren.push(vCurrent); + } + else if (vCurrent instanceof qx.ui.toolbar.Part) + { + vDeepChildren = vDeepChildren.concat(vCurrent.getChildren()); + } + } + + return vDeepChildren; +} + + + + + + + +/* +--------------------------------------------------------------------------- + EVENTS +--------------------------------------------------------------------------- +*/ + +/*! + Wraps key events to target functions +*/ +qx.Proto._onkeypress = function(e) +{ + switch(e.getKeyIdentifier()) + { + case "Left": + return this._onkeypress_left(); + + case "Right": + return this._onkeypress_right(); + } +} + +qx.Proto._onkeypress_left = function() +{ + var vMenu = this.getOpenMenu(); + if (!vMenu) { + return; + } + + var vOpener = vMenu.getOpener(); + if (!vOpener) { + return; + } + + var vChildren = this.getAllButtons(); + var vChildrenLength = vChildren.length; + var vIndex = vChildren.indexOf(vOpener); + var vCurrent; + var vPrevButton = null; + + for (var i=vIndex-1; i>=0; i--) + { + vCurrent = vChildren[i]; + + if (vCurrent instanceof qx.ui.toolbar.MenuButton && vCurrent.getEnabled()) + { + vPrevButton = vCurrent; + break; + } + } + + // If none found, try again from the begin (looping) + if (!vPrevButton) + { + for (var i=vChildrenLength-1; i>vIndex; i--) + { + vCurrent = vChildren[i]; + + if (vCurrent instanceof qx.ui.toolbar.MenuButton && vCurrent.getEnabled()) + { + vPrevButton = vCurrent; + break; + } + } + } + + if (vPrevButton) + { + // hide other menus + qx.manager.object.MenuManager.getInstance().update(); + + // show previous menu + vPrevButton._showMenu(true); + } +} + +qx.Proto._onkeypress_right = function() +{ + var vMenu = this.getOpenMenu(); + if (!vMenu) { + return; + } + + var vOpener = vMenu.getOpener(); + if (!vOpener) { + return; + } + + var vChildren = this.getAllButtons(); + var vChildrenLength = vChildren.length; + var vIndex = vChildren.indexOf(vOpener); + var vCurrent; + var vNextButton = null; + + for (var i=vIndex+1; i<vChildrenLength; i++) + { + vCurrent = vChildren[i]; + + if (vCurrent instanceof qx.ui.toolbar.MenuButton && vCurrent.getEnabled()) + { + vNextButton = vCurrent; + break; + } + } + + // If none found, try again from the begin (looping) + if (!vNextButton) + { + for (var i=0; i<vIndex; i++) + { + vCurrent = vChildren[i]; + + if (vCurrent instanceof qx.ui.toolbar.MenuButton && vCurrent.getEnabled()) + { + vNextButton = vCurrent; + break; + } + } + } + + if (vNextButton) + { + // hide other menus + qx.manager.object.MenuManager.getInstance().update(); + + // show next menu + vNextButton._showMenu(true); + } +} + + + + + + + +/* +--------------------------------------------------------------------------- + DISPOSER +--------------------------------------------------------------------------- +*/ + +qx.Proto.dispose = function() +{ + if (this.getDisposed()) { + return; + } + + this.removeEventListener("keypress", this._onkeypress); + + return qx.ui.layout.HorizontalBoxLayout.prototype.dispose.call(this); +} |