/* ************************************************************************ 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_form) ************************************************************************ */ /*! Each instance manage vItems set of radio options: qx.ui.form.RadioButton, qx.ui.toolbar.RadioButton, ... */ qx.OO.defineClass("qx.manager.selection.RadioManager", qx.core.Target, function(vName, vMembers) { // we don't need the manager data structures qx.core.Target.call(this); // create item array this._items = []; // apply name property this.setName(qx.util.Validation.isValidString(vName) ? vName : qx.manager.selection.RadioManager.AUTO_NAME_PREFIX + this._hashCode); if (qx.util.Validation.isValidArray(vMembers)) { // add() iterates over arguments, but vMembers is an array this.add.apply(this, vMembers); } }); qx.manager.selection.RadioManager.AUTO_NAME_PREFIX = "qx-radio-"; /* --------------------------------------------------------------------------- PROPERTIES --------------------------------------------------------------------------- */ qx.OO.addProperty({ name : "selected" }); qx.OO.addProperty({ name : "name", type : "string" }); /* --------------------------------------------------------------------------- UTILITIES --------------------------------------------------------------------------- */ qx.Proto.getItems = function() { return this._items; } qx.Proto.handleItemChecked = function(vItem, vChecked) { if (vChecked) { this.setSelected(vItem); } else if (this.getSelected() == vItem) { this.setSelected(null); } } /* --------------------------------------------------------------------------- REGISTRY --------------------------------------------------------------------------- */ qx.Proto.add = function(varargs) { var vItems = arguments; var vLength = vItems.length; var vLast = vItems[vLength-1]; if (!(vLast instanceof qx.ui.core.Parent) && !(vLast instanceof qx.ui.basic.Terminator)) { vLength--; } var vItem; for (var i=0; i