diff options
author | Derrell Lipman <derrell@samba.org> | 2007-02-06 03:23:52 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:44:34 -0500 |
commit | ef256c958066c19bb10cbe9745bdf96b6514762d (patch) | |
tree | dbe379cb3021c5af2d1b8f74528e4fff968fc712 /webapps/qooxdoo-0.6.5-sdk/frontend/framework/source/class/qx/ui/treevirtual/SimpleTreeDataCellRenderer.js | |
parent | a8d0f5df6266aeacdb20326094c0401618ab62e8 (diff) | |
download | samba-ef256c958066c19bb10cbe9745bdf96b6514762d.tar.gz samba-ef256c958066c19bb10cbe9745bdf96b6514762d.tar.bz2 samba-ef256c958066c19bb10cbe9745bdf96b6514762d.zip |
r21167: - Upgrade to latest released qooxdoo. This is step 1 of the upgrade process,
which involves adding the latest SDK. This new version has not 2, but 4
icon themes. In order to quiet Andrew B. who thinks that 9000+ files in a
gui api is too many (come on, disk space is free these days :-), I have
removed 3 of the 4 icon themes, leaving only the default, Nuvola. That
lowers the file count by 1/3. I'm sure Andrew still isn't happy, but I hope
he's a bit happier... Step 2 will make him happier yet.
(This used to be commit d161c1382c36238105b85d0499d5a1011f580f52)
Diffstat (limited to 'webapps/qooxdoo-0.6.5-sdk/frontend/framework/source/class/qx/ui/treevirtual/SimpleTreeDataCellRenderer.js')
-rw-r--r-- | webapps/qooxdoo-0.6.5-sdk/frontend/framework/source/class/qx/ui/treevirtual/SimpleTreeDataCellRenderer.js | 314 |
1 files changed, 314 insertions, 0 deletions
diff --git a/webapps/qooxdoo-0.6.5-sdk/frontend/framework/source/class/qx/ui/treevirtual/SimpleTreeDataCellRenderer.js b/webapps/qooxdoo-0.6.5-sdk/frontend/framework/source/class/qx/ui/treevirtual/SimpleTreeDataCellRenderer.js new file mode 100644 index 0000000000..71abc0eb3f --- /dev/null +++ b/webapps/qooxdoo-0.6.5-sdk/frontend/framework/source/class/qx/ui/treevirtual/SimpleTreeDataCellRenderer.js @@ -0,0 +1,314 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2007 Derrell Lipman + + License: + LGPL: http://www.gnu.org/licenses/lgpl.html + EPL: http://www.eclipse.org/org/documents/epl-v10.php + See the LICENSE file in the project's top-level directory for details. + + Authors: + * Derrell Lipman (derrell) + +************************************************************************ */ + +/* ************************************************************************ + +#module(treevirtual) + +************************************************************************ */ + +/** + * A data cell renderer for the tree column of a simple tree + */ +qx.OO.defineClass("qx.ui.treevirtual.SimpleTreeDataCellRenderer", + qx.ui.table.AbstractDataCellRenderer, +function() +{ + qx.ui.table.AbstractDataCellRenderer.call(this); + + // Base URL used for indent images + var Am = qx.manager.object.AliasManager; + this.WIDGET_TREE_URI = Am.getInstance().resolvePath("widget/tree/"); + this.STATIC_IMAGE_URI = Am.getInstance().resolvePath("static/image/") +}); + + +/** + * Set whether lines linking tree children shall be drawn on the tree. + */ +qx.OO.addProperty({ + name : "useTreeLines", + type : "boolean", + defaultValue : true, + getAlias : "useTreeLines" + }); + +/** + * Set whether the open/close button should be displayed on a branch, even if + * the branch has no children. + */ +qx.OO.addProperty({ + name : "alwaysShowOpenCloseSymbol", + type : "boolean", + defaultValue : false + }); + +/** + * When true, exclude only the first-level tree lines, creating, effectively, + * multiple unrelated root nodes. + */ +qx.OO.addProperty({ + name : "jensLautenbacherMode", + type : "boolean", + defaultValue : false + }); + + + + +// overridden +qx.Proto._getCellStyle = function(cellInfo) +{ + var node = cellInfo.value; + + // Return the style for the div for the cell. If there's cell-specific + // style information provided, append it. + var html = + qx.ui.treevirtual.SimpleTreeDataCellRenderer.MAIN_DIV_STYLE + + (node.cellStyle ? node.cellStyle + ";" : ""); + return html; +}; + + +// overridden +qx.Proto._getContentHtml = function(cellInfo) +{ + var html = ""; + var node = cellInfo.value; + var imageUrl; + var _this = this; + var Stdcr = qx.ui.treevirtual.SimpleTreeDataCellRenderer; + + function addImage(urlAndToolTip) + { + var html = Stdcr.IMG_START; + var Am = qx.manager.object.AliasManager; + + if (qx.core.Client.getInstance().isMshtml() && + /\.png$/i.test(urlAndToolTip.url)) + { + html += + this.STATIC_IMAGE_URI + "blank.gif" + + '" style="filter:' + + "progid:DXImageTransform.Microsoft.AlphaImageLoader(" + + " src='" + urlAndToolTip.url + "',sizingMethod='scale')"; + } + else + { + var imageUrl = Am.getInstance().resolvePath(urlAndToolTip.url); + html += imageUrl + '" style="'; + } + + if (urlAndToolTip.imageWidth && urlAndToolTip.imageHeight) + { + html += + ';width:' + urlAndToolTip.imageWidth + 'px' + + ';height:' + urlAndToolTip.imageHeight + 'px'; + } + + var tooltip = urlAndToolTip.tooltip; + if (tooltip != null) + { + html += Stdcr.IMG_TITLE_START + tooltip; + } + html += Stdcr.IMG_END; + + return html; + } + + // Generate the indentation. Obtain icon determination values once rather + // than each time through the loop. + var bUseTreeLines = this.getUseTreeLines(); + var bJensLautenbacherMode = this.getJensLautenbacherMode(); + var bAlwaysShowOpenCloseSymbol = this.getAlwaysShowOpenCloseSymbol(); + + for (var i = 0; i < node.level; i++) + { + imageUrl = this._getIndentSymbol(i, + node, + bUseTreeLines, + bAlwaysShowOpenCloseSymbol, + bJensLautenbacherMode); + html += addImage({ + url : imageUrl, + imageWidth : 19, + imageHeight : 16 + }); + } + + // Add the node's icon + imageUrl = (node.bSelected ? node.iconSelected : node.icon); + if (! imageUrl) + { + if (node.type == qx.ui.treevirtual.SimpleTreeDataModel.Type.LEAF) + { + imageUrl = (node.bSelected + ? "icon/16/actions/document-open.png" + : "icon/16/actions/document-new.png"); + } + else + { + imageUrl = (node.bSelected + ? "icon/16/status/folder-open.png" + : "icon/16/places/folder.png"); + } + } + html += addImage({ url:imageUrl }); + + // Add the node's label. We calculate the "left" property with: each tree + // line (indentation) icon is 19 pixels wide; the folder icon is 16 pixels + // wide, there are two pixels of padding at the left, and we want 2 pixels + // between the folder icon and the label + html += + '<div style="position:absolute;' + + 'left:' + ((node.level * 19) + 16 + 2 + 2) + ';' + + 'top:0' + + (node.labelStyle ? ";" + node.labelStyle : "") + + ';">' + + node.label + + '</div>'; + + return html; +}; + + +qx.Proto._getIndentSymbol = function(column, + node, + bUseTreeLines, + bAlwaysShowOpenCloseSymbol, + bJensLautenbacherMode) +{ + // If we're in column 0 and jensLautenbacherMode is enabled, then we treat + // this as if no tree lines were requested. + if (column == 0 && bJensLautenbacherMode) + { + bUseTreeLines = false; + } + + // If we're not on the final column... + if (column < node.level - 1) + { + // then return either a line or a blank icon, depending on bUseTreeLines + return (bUseTreeLines && ! node.lastChild[column] + ? this.WIDGET_TREE_URI + "line.gif" + : this.STATIC_IMAGE_URI + "blank.gif"); + } + + var bLastChild = node.lastChild[node.lastChild.length - 1]; + + // Is this a branch node? + if (node.type == qx.ui.treevirtual.SimpleTreeDataModel.Type.BRANCH && + (node.opened === true || node.opened === false)) + { + // Determine if this node has any children + var child = null; + for (child in node.children) + { + // If we find even one, we're done here. + break; + } + + // Does this node have any children, or do we always want the open/close + // symbol to be shown? + if (child !== null || bAlwaysShowOpenCloseSymbol) + { + // If we're not showing tree lines... + if (! bUseTreeLines) + { + // ... then just use a plus or minus + return (node.opened + ? this.WIDGET_TREE_URI + "minus.gif" + : this.WIDGET_TREE_URI + "plus.gif"); + } + + // Are we looking at a top-level, first child of its parent? + if (column == 0 && node.bFirstChild) + { + // Yup. If it's also a last child... + if (bLastChild) + { + // ... then use no tree lines. + return (node.opened + ? this.WIDGET_TREE_URI + "only_minus.gif" + : this.WIDGET_TREE_URI + "only_plus.gif"); + } + else + { + // otherwise, use descender lines but no ascender. + return (node.opened + ? this.WIDGET_TREE_URI + "start_minus.gif" + : this.WIDGET_TREE_URI + "start_plus.gif"); + } + } + + // It's not a top-level, first child. Is this the last child of its + // parent? + if (bLastChild) + { + // Yup. Return an ending plus or minus, or blank if node.opened so + // indicates. + return (node.opened + ? this.WIDGET_TREE_URI + "end_minus.gif" + : this.WIDGET_TREE_URI + "end_plus.gif"); + } + + // Otherwise, return a crossing plus or minus, or a blank if + // node.opened so indicates. + return (node.opened + ? this.WIDGET_TREE_URI + "cross_minus.gif" + : this.WIDGET_TREE_URI + "cross_plus.gif"); + } + } + + // This node does not have any children. Return an end or cross, if we're + // using tree lines. + if (bUseTreeLines) + { + // If this is a last child, return and ending line; otherwise cross. + return (bLastChild + ? this.WIDGET_TREE_URI + "end.gif" + : this.WIDGET_TREE_URI + "cross.gif"); + } + + return this.STATIC_IMAGE_URI + "blank.gif"; +} + + +// overridden +qx.Proto._createCellStyle_array_join = function(cellInfo, htmlArr) +{ + throw new Error("USE_ARRAY_JOIN not supported"); +}; + + + +qx.Proto._createContentHtml_array_join = function(cellInfo, htmlArr) +{ + throw new Error("USE_ARRAY_JOIN not supported"); +}; + +qx.Class.MAIN_DIV_STYLE = + ';overflow:hidden;white-space:nowrap;border-right:1px solid #eeeeee;' + + 'padding-left:2px;padding-right:2px;cursor:default' + + (qx.core.Client.getInstance().isMshtml() ? '' : ';-moz-user-select:none;'); + +qx.Class.IMG_START = '<img src="'; +qx.Class.IMG_END = '"/>'; +qx.Class.IMG_TITLE_START = '" title="'; + |