Revision: 3000 http://vexi.svn.sourceforge.net/vexi/?rev=3000&view=rev Author: clrg Date: 2008-07-30 18:37:49 +0000 (Wed, 30 Jul 2008)
Log Message: ----------- Improve / fix cell display of different datatypes Modified Paths: -------------- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/cell.t trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/row.t trunk/widgets/org.vexi.widgets/src/org/vexi/theme/classic/cell.t Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/cell.t =================================================================== --- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/cell.t 2008-07-30 13:56:56 UTC (rev 2999) +++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/cell.t 2008-07-30 18:37:49 UTC (rev 3000) @@ -1,47 +1,119 @@ <!-- Copyright 2007 - see COPYING for details [LGPL] --> -<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" xmlns:lay="vexi.layout"> +<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" xmlns="org.vexi.lib.role" + xmlns:theme="vexi.theme" xmlns:util="vexi.util"> <meta:doc> <author>Charles Goodwin</author> <desc>A very basic table cell implementation</desc> </meta:doc> + <tooltipable /> <ui:box> - thisbox.value ++= static.valueRead; - thisbox.value ++= static.valueWrite; + thisbox.datatype = arguments[0]; thisbox.v_container ++= static.containerWrite; </ui:box> + /** set up cell to handle incoming type */ static.containerWrite = function(v) { cascade = v; - trapee.minheight = trapee.paddingtop+trapee.paddingbottom - +vexi.ui.font.height(trapee.font, trapee.fontsize, "dy"); - trapee[0] = vexi.box; - trapee.v_textbox = trapee[0]; - trapee.v_content.layout = "place"; + var t = trapee; + t.minheight = t.paddingtop + t.paddingbottom + + vexi.ui.font.height(t.font, t.fontsize, "dy"); + t[0] = vexi.box; + t.v_textbox = t[0]; + t.v_content.layout = "place"; + switch (t.datatype) { + case "bool": + case "boolean": + t[0].shrink = true; + t[0].align = "center"; + t[0].fill = theme.image.check; + t.selected ++= static.toggleSelectWrite; + t.text ++= static.toggleTextRead; + t.value ++= static.toggleValueWrite; + break; + case "date": + t.selected ++= static.selectedWrite; + t.value ++= static.dateValueWrite; + break; + case "text": + t.selected ++= static.selectedWrite; + t.value ++= static.textValueWrite; + break; + case "time": + t.selected ++= static.selectedWrite; + t.value ++= static.timeValueWrite; + break; + default: + t.selected ++= static.selectedWrite; + t.value ++= static.valueWrite; + break; + } } var day = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]; var month = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]; - static.valueRead = function() { return cascade != null ? cascade : trapee.text; } + /** parse incoming date and display nicely */ + static.dateValueWrite = function(v) { + cascade = v; + switch (typeof(v)) { + case "date": + trapee.text = v.getDate()+" "+month[v.getMonth()]+" "+v.getFullYear(); + break; + case "string": + var d = util.date..parseDate(v, "YYYYMMDD"); + trapee.text = d.day+" "+month[d.month]+" "+d.year; + break; + } + } - static.valueWrite = function(v) { - var colh = trapee.v_head; - var cell = trapee; + /** apply suitable effects when selected */ + static.selectedWrite = function(v) { cascade = v; - if (typeof(v) == "date") { - if (colh.datatype == "day") - cell.text = day[cascade]; - else if (colh.datatype == "date") - cell.text = v.getDate()+" "+month[v.getMonth()]+" "+v.getFullYear(); - else if (colh.datatype == "time") { - var h = v.getHours(); - var m = v.getMinutes(); - var s = v.getSeconds(); - cell.text = (10>h?"0":"")+h+":"+(10>m?"0":"")+m+":"+(10>s?"0":"")+s; - } else cell.text = v.toString(); - } else cell.text = colh.map == null ? v : colh.map(v); + trapee.textcolor = v ? theme.settings..textcolor_selected : theme.settings..textcolor; } + /** only display the first line */ + static.textValueWrite = function(v) { + cascade = v; + var i = v.indexOf("\n"); + if (i!=-1) { + trapee.tooltip = v; + v = v.substring(0, i); + } + trapee.text = v; + } + + /** for time as a value */ + static.timeValueWrite = function(v) { + cascade = v; + switch (typeof(v)) { + case "date": + var h = v.getHours(); + var m = v.getMinutes(); + var s = v.getSeconds(); + trapee.text = (10>h?"0":"")+h+":"+(10>m?"0":"")+m+":"+(10>s?"0":"")+s; + break; + case "string": + trapee.text = v.substring(0, 5); + break; + } + } + + /** use highlighted check when selected */ + static.toggleSelectWrite = function(v) { + cascade = v; + trapee[0].fill = v ? theme.image.check_highlighted : theme.image.check; + } + + /** return value as substitute for text */ + static.toggleTextRead = function() { return trapee.value; } + + /** set check display to match incoming boolean */ + static.toggleValueWrite = function(v) { cascade = v; trapee[0].display = v; } + + /** generic value write to forward value on as text */ + static.valueWrite = function(v) { cascade = v; trapee.text = v; } + </vexi> Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/row.t =================================================================== --- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/row.t 2008-07-30 13:56:56 UTC (rev 2999) +++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/row.t 2008-07-30 18:37:49 UTC (rev 3000) @@ -50,11 +50,12 @@ /** default row value write trap */ static.valueWrite = function(v) { - if (!trapee.v_head) throw "v_head must be set on a row before the row value is written to"; - var n = trapee.v_head.numchildren; + var h = trapee.v_head; + if (!h) throw "v_head must be set on a row before the row value is written to"; + var n = h.numchildren; // assign new cells for (var j=0; n>j; j++) { - if (!trapee[j]) trapee[j] = .cell(vexi.box); + if (!trapee[j]) trapee[j] = .cell(vexi.box, [h[j].datatype]); trapee[j].value = v[j]; } cascade = v; Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/theme/classic/cell.t =================================================================== --- trunk/widgets/org.vexi.widgets/src/org/vexi/theme/classic/cell.t 2008-07-30 13:56:56 UTC (rev 2999) +++ trunk/widgets/org.vexi.widgets/src/org/vexi/theme/classic/cell.t 2008-07-30 18:37:49 UTC (rev 3000) @@ -6,47 +6,5 @@ <author>Charles Goodwin</author> </meta:doc> - <cell padding="2"> - thisbox.datatype ++= static.datatypeWrite; - thisbox.selected ++= static.selectedWrite; - </cell> - - /** apply suitable effects when selected */ - static.selectedWrite = function(v) { - cascade = v; - if (trapee.datatype == "toggle") - trapee[0].fill = v?theme.image.check_highlighted:theme.image.check; - else trapee.textcolor = v?theme.settings..textcolor_selected:theme.settings..textcolor; - } - - /** return value as substitute for text */ - static.toggleTextRead = function() { return trapee.value; } - - /** intercept text put and instead display toggle effect */ - static.toggleTextWrite = function(v) { - trapee[0].display = v == "TRUE" or v == "true" or (typeof(v) != "string" and v); - return; - } - - /** sets up theme specific datatype effects */ - static.datatypeWrite = function(v) { - // apply toggle effect / traps - if (v == "toggle") { - if (trapee.datatype == "toggle") return; - trapee[0].shrink = true; - trapee[0].align = "center"; - trapee[0].fill = theme.image.check; - trapee.text ++= static.toggleTextRead; - trapee.text ++= static.toggleTextWrite; - // remove toggle effect / traps - } else if (trapee.datatype == "toggle") { - trapee[0].shrink = false; - trapee[0].align = "left"; - trapee[0].fill = null; - trapee.text --= static.toggleTextRead; - trapee.text --= static.toggleTextWrite; - } - cascade = v; - } - + <cell padding="2" /> </vexi> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn