[qooxdoo-commit] SF.net SVN: qooxdoo: [12980] trunk/qooxdoo/frontend/framework/source/class/ qx/ui
Brought to you by:
ecker,
martinwittemann
From: <wp...@us...> - 2008-04-15 08:22:48
|
Revision: 12980 http://qooxdoo.svn.sourceforge.net/qooxdoo/?rev=12980&view=rev Author: wpbasti Date: 2008-04-15 01:22:46 -0700 (Tue, 15 Apr 2008) Log Message: ----------- Moved more selection stuff from List to Widget selection mgr. Modified Paths: -------------- trunk/qooxdoo/frontend/framework/source/class/qx/ui/core/selection/IContainer.js trunk/qooxdoo/frontend/framework/source/class/qx/ui/core/selection/Widget.js trunk/qooxdoo/frontend/framework/source/class/qx/ui/form/List.js Modified: trunk/qooxdoo/frontend/framework/source/class/qx/ui/core/selection/IContainer.js =================================================================== --- trunk/qooxdoo/frontend/framework/source/class/qx/ui/core/selection/IContainer.js 2008-04-15 07:49:40 UTC (rev 12979) +++ trunk/qooxdoo/frontend/framework/source/class/qx/ui/core/selection/IContainer.js 2008-04-15 08:22:46 UTC (rev 12980) @@ -26,11 +26,6 @@ { members : { - /** - * Get all selectable items - * - * @return {qx.ui.core.Widget[]} An array of all selectable items - */ - getSelectables : function() {} + } }); \ No newline at end of file Modified: trunk/qooxdoo/frontend/framework/source/class/qx/ui/core/selection/Widget.js =================================================================== --- trunk/qooxdoo/frontend/framework/source/class/qx/ui/core/selection/Widget.js 2008-04-15 07:49:40 UTC (rev 12979) +++ trunk/qooxdoo/frontend/framework/source/class/qx/ui/core/selection/Widget.js 2008-04-15 08:22:46 UTC (rev 12980) @@ -118,43 +118,133 @@ // overridden _isSelectable : function(item) { - return this._widget.isSelectable(item); + return (item instanceof qx.ui.form.ListItem) && item.getLayoutParent() === this._widget.getContent(); }, // overridden - _selectableToHashCode : function(item) { - return item.$$hash; + _getSelectables : function() + { + var children = this._widget.getChildren(); + var result = []; + var child; + + for (var i=0, l=children.length; i<l; i++) + { + child = children[i]; + + if (child.isEnabled()) { + result.push(child); + } + } + + return result; }, // overridden - _getSelectables : function() { - return this._widget.getSelectables(); + _getSelectableRange : function(item1, item2) + { + // Fast path for identical items + if (item1 === item2) { + return [item1]; + } + + // Iterate over children and collect all items + // between the given two (including them) + var children = this._widget.getChildren(); + var result = []; + var active = false; + var child; + + for (var i=0, l=children.length; i<l; i++) + { + child = children[i]; + + if (child === item1 || child === item2) + { + if (active) + { + result.push(child); + break; + } + else + { + active = true; + } + } + + if (active && child.isEnabled()) { + result.push(child); + } + } + + return result; }, // overridden - _getSelectableRange : function(item1, item2) { - return this._widget.getSelectableRange(item1, item2); + _getFirstSelectable : function() + { + var children = this._widget.getChildren(); + for (var i=0, l=children.length; i<l; i++) + { + if (children[i].isEnabled()) { + return children[i]; + } + } + + return null; }, // overridden - _getFirstSelectable : function() { - return this._widget.getFirstSelectable(); + _getLastSelectable : function() + { + var children = this._widget.getChildren(); + for (var i=children.length-1; i>0; i--) + { + if (children[i].isEnabled()) { + return children[i]; + } + } + + return null; }, // overridden - _getLastSelectable : function() { - return this._widget.getLastSelectable(); + _getRelatedSelectable : function(item, relation) + { + var vertical = this._widget.getOrientation() === "vertical"; + + var layout = this._widget.getContent().getLayout(); + var sibling = item; + + if ((vertical && relation === "above") || (!vertical && relation === "left")) + { + do { + sibling = layout.getPreviousSibling(sibling); + } while (sibling && !sibling.isEnabled()); + } + else if ((vertical && relation === "under") || (!vertical && relation === "right")) + { + do { + sibling = layout.getNextSibling(sibling); + } while (sibling && !sibling.isEnabled()); + } + else + { + return null; + } + + return sibling; }, // overridden - _getRelatedSelectable : function(item, relation) { - return this._widget.getRelatedSelectable(item, relation); + _selectableToHashCode : function(item) { + return item.$$hash; }, Modified: trunk/qooxdoo/frontend/framework/source/class/qx/ui/form/List.js =================================================================== --- trunk/qooxdoo/frontend/framework/source/class/qx/ui/form/List.js 2008-04-15 07:49:40 UTC (rev 12979) +++ trunk/qooxdoo/frontend/framework/source/class/qx/ui/form/List.js 2008-04-15 08:22:46 UTC (rev 12980) @@ -166,142 +166,7 @@ - /* - --------------------------------------------------------------------------- - SELECTION MANAGER INTERFACE - --------------------------------------------------------------------------- - */ - // interface implementation - isSelectable : function(item) { - return (item instanceof qx.ui.form.ListItem) && item.getLayoutParent() === this.getContent(); - }, - - - // interface implementation - getSelectables : function() - { - var children = this.getContent().getLayoutChildren(); - var result = []; - var child; - - for (var i=0, l=children.length; i<l; i++) - { - child = children[i]; - - if (child.isEnabled()) { - result.push(child); - } - } - - return result; - }, - - - // interface implementation - getSelectableRange : function(item1, item2) - { - // Fast path for identical items - if (item1 === item2) { - return [item1]; - } - - // Iterate over children and collect all items - // between the given two (including them) - var children = this.getContent().getLayoutChildren(); - var result = []; - var active = false; - var child; - - for (var i=0, l=children.length; i<l; i++) - { - child = children[i]; - - if (child === item1 || child === item2) - { - if (active) - { - result.push(child); - break; - } - else - { - active = true; - } - } - - if (active && child.isEnabled()) { - result.push(child); - } - } - - return result; - }, - - - // interface implementation - getFirstSelectable : function() - { - var children = this.getContent().getLayoutChildren(); - for (var i=0, l=children.length; i<l; i++) - { - if (children[i].isEnabled()) { - return children[i]; - } - } - - return null; - }, - - - // interface implementation - getLastSelectable : function() - { - var children = this.getContent().getLayoutChildren(); - for (var i=children.length-1; i>0; i--) - { - if (children[i].isEnabled()) { - return children[i]; - } - } - - return null; - }, - - - // interface implementation - getRelatedSelectable : function(item, relation) - { - var vertical = this.getOrientation() === "vertical"; - - var layout = this.getContent().getLayout(); - var sibling = item; - - if ((vertical && relation === "above") || (!vertical && relation === "left")) - { - do { - sibling = layout.getPreviousSibling(sibling); - } while (sibling && !sibling.isEnabled()); - } - else if ((vertical && relation === "under") || (!vertical && relation === "right")) - { - do { - sibling = layout.getNextSibling(sibling); - } while (sibling && !sibling.isEnabled()); - } - else - { - return null; - } - - return sibling; - }, - - - - - - /* --------------------------------------------------------------------------- EVENT HANDLER This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |