Revision: 3366
          http://vexi.svn.sourceforge.net/vexi/?rev=3366&view=rev
Author:   clrg
Date:     2009-01-21 01:37:32 +0000 (Wed, 21 Jan 2009)

Log Message:
-----------
Set table column sizes using column.size (in number of characters wide) + other 
table tweaks

Modified Paths:
--------------
    trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/body.t
    trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/cell.t
    trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/column.t
    trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/head.t
    trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/row.t
    trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/table.t

Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/body.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/body.t       
2009-01-21 01:35:44 UTC (rev 3365)
+++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/body.t       
2009-01-21 01:37:32 UTC (rev 3366)
@@ -26,23 +26,24 @@
         
         /** update alternating row colors */
         var updateFills = function() {
-            for (var i=0; thisbox.numchildren>i; i++)
-                thisbox[i].rowfill = (startindex+i)%2 ? fill2 : fill1;
-                
-            if (selected and !selected.display)
-                selected = null;
-            else if (selected) selected.selected = true;
+            var n = thisbox.numchildren;
+            for (var i=startindex%2; n>i; i+=2) thisbox[i].rowfill = fill1;
+            for (var i=startindex+1%2; n>i; i+=2) thisbox[i].rowfill = fill2;
+         //   if (selected) {
+         //       if (!selected.display) selected = null;
+         //       else selected.selected = true;
+         //   }
         }
         
         var rowindexRead = function() { return thisbox.indexof(selected); }
         
         /** done outside of loadData in-case data is loaded manually */
         var childrenWrite = function(v) {
-            var updatefills = numchildren > trapname;
+            var invalidates_fills = numchildren > trapname;
             if (v != null) {
                 v.rowindex ++= rowindexRead;
                 v.Press1 ++= pressEvent;
-                if (!updatefills)
+                if (!invalidates_fills)
                     v.rowfill = (startindex+(trapname-1))%2 ? fill2 : fill1;
             } else {
                 updatefills = true;
@@ -54,7 +55,7 @@
                 }
             }
             cascade = v;
-            if (updatefills) updateFills();
+            if (invalidates_fills) updateFills();
         }
         Children ++= childrenWrite;
         
@@ -79,25 +80,35 @@
         
         /** set a filter against the data - hides non-matching rows */
         thisbox.setFilter = function(c, f) {
+            var n = numchildren;
             if (typeof(f) == "string") {
                 var str = f.toLowerCase();
-                for (var i=0; thisbox.numchildren > i; i++)
-                    thisbox[i].display = 
thisbox[i][c].value.toLowerCase().indexOf(str) > -1;
+                for (var i=0; n>i; i++) {
+                    var r = thisbox[i];
+                    r.display = r[c].value.toLowerCase().indexOf(str) > -1;
+                }
             } else {
-                for (var i=0; thisbox.numchildren > i; i++)
-                    thisbox[i].display = thisbox[i][c].value.indexOf(f) > -1;
+                for (var i=0; n>i; i++) {
+                    var r = thisbox[i];
+                    r.display = r[c].value.indexOf(f) > -1;
+                }
             }
         }
         
         /** set a filter against current data - only applies to visible rows */
         thisbox.setCompoundFilter = function(c, f) {
+            var n = numchildren;
             if (typeof(f) == "string") {
                 var str = f.toLowerCase();
-                for (var i=0; thisbox.numchildren > i; i++)
-                    thisbox[i].display = thisbox[i].display and 
thisbox[i][c].value.toLowerCase().indexOf(str) > -1;
+                for (var i=0; n>i; i++) {
+                    var r = thisbox[i];
+                    r.display = r.display and 
r[c].value.toLowerCase().indexOf(str) > -1;
+                }
             } else {
-                for (var i=0; thisbox.numchildren > i; i++)
-                    thisbox[i].display = thisbox[i].display and 
thisbox[i][c].value.indexOf(f) > -1;
+                for (var i=0; n>i; i++) {
+                    var r = thisbox[i];
+                    r.display = r.display and r[c].value.indexOf(f) > -1;
+                }
             }
         }
         
@@ -209,60 +220,19 @@
             
             updateFills();
         }
-
+        
+        thisbox.clear ++= static.clearWrite;
         thisbox.focused ++= static.focusWrite;
         thisbox.selected ++= static.selectedRow;
         thisbox.selectedindex ++= static.indexRead;
         thisbox.selectedindex ++= static.selectByIndex;
+        thisbox.KeyPressed ++= static.keypressWrite;
         
-        /** navigate up and down the table */
-        KeyPressed ++= function(k) {
-            if (k == "escape") {
-                selected = null;
-                return;
-            }
-            
-            if (!selected) {
-                selectedindex = 0;
-                return;
-            }
-            
-            switch (k) {
-            case "down":
-            case "DOWN":
-                selectedindex++;
-                break;
-            case "up":
-            case "UP":
-                selectedindex--;
-                break;
-            case "home":
-            case "HOME":
-                selectedindex = 0;
-                break;
-            case "end":
-            case "END":
-                selectedindex = rowcount;
-                break;
-            case "enter":
-            case "ENTER":
-            case ' ':
-                selected.action = true;
-                break;
-            case "page_up":
-            case "PAGE_UP":
-                selectedindex -= vexi.math.floor(viewportheight / rowheight);
-                break;
-            case "page_down":
-            case "PAGE_DOWN":
-                selectedindex += vexi.math.floor(viewportheight / rowheight);
-                break;
-            }
-            cascade = k;
-        }
-        
     </ui:box>
     
+    /** clear body contents */
+    static.clearWrite = function(v) { while (trapee[0]) trapee[0] = null; 
return; }
+    
     /** desaturate selected fill when not focused */
     static.focusWrite = function(v) {
         if (trapee.selected) trapee.selected.focused = v;
@@ -272,6 +242,52 @@
     /** return the correct row index */
     static.indexRead = function() { return trapee.selected ? 
trapee.selected.rowindex : null; }
     
+    /** navigate up and down the table */
+    static.keypressWrite = function(k) {
+        if (k == "escape") {
+            trapee.selected = null;
+            return;
+        }
+        
+        if (!trapee.selected) {
+            trapee.selectedindex = 0;
+            return;
+        }
+        
+        switch (k) {
+        case "down":
+        case "DOWN":
+            trapee.selectedindex++;
+            break;
+        case "up":
+        case "UP":
+            trapee.selectedindex--;
+            break;
+        case "home":
+        case "HOME":
+            trapee.selectedindex = 0;
+            break;
+        case "end":
+        case "END":
+            trapee.selectedindex = trapee.rowcount;
+            break;
+        case "enter":
+        case "ENTER":
+        case ' ':
+            trapee.selected.action = true;
+            break;
+        case "page_up":
+        case "PAGE_UP":
+            trapee.selectedindex -= vexi.math.floor(viewportheight / 
rowheight);
+            break;
+        case "page_down":
+        case "PAGE_DOWN":
+            trapee.selectedindex += vexi.math.floor(viewportheight / 
rowheight);
+            break;
+        }
+        cascade = k;
+    }
+    
     /** sets the selected row */
     static.selectedRow = function(s) {
         if (trapee.selected) {

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       
2009-01-21 01:35:44 UTC (rev 3365)
+++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/cell.t       
2009-01-21 01:37:32 UTC (rev 3366)
@@ -54,6 +54,11 @@
             t.selected ++= static.selectedWrite;
             t.value ++= static.timeValueWrite;
             break;
+        case "integer":
+            t[0].align = "right";
+            t.selected ++= static.selectedWrite;
+            t.value ++= static.valueWrite;
+            break;
         default:
             t.selected ++= static.selectedWrite;
             t.value ++= static.valueWrite;

Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/column.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/column.t     
2009-01-21 01:35:44 UTC (rev 3365)
+++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/column.t     
2009-01-21 01:37:32 UTC (rev 3366)
@@ -1,21 +1,52 @@
 <!-- Copyright 2008 - see COPYING for details [LGPL] -->
 
-<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" 
xmlns="org.vexi.lib.widget">
+<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" xmlns="org.vexi.lib.role">
     <meta:doc>
         <author>Charles Goodwin</author>
     </meta:doc>
-    
+ 
+    <tooltipable />   
     <ui:box>
         
-        thisbox.fixedwidth = false;
-        thisbox.resizeable = false;
-        thisbox.sort;
-        thisbox.value;
+        thisbox.datatype ++= static.datatypeWrite;
+        thisbox.size ++= static.sizeWrite;
+        thisbox.value ++= static.valueRead;
         
-        value ++= static.valueRead;
+        var setTooltip = function(v) { cascade = v; tooltip = v; };
         
+        thisbox.v_container ++= function(v) {
+            cascade = v;
+            thisbox.v_textbox.text ++= setTooltip;
+        }
+        
     </ui:box>
     
+    static.datatypeWrite = function(v) {
+        cascade = v;
+        switch (v) {
+        case "date":
+            trapee.size = 10; break;
+        case "time":
+            trapee.size = 5; break;
+        case "datetime":
+            trapee.size = 16; break;
+        case "integer":
+        case "number":
+            trapee.size = 7; break;
+        case "bool":
+        case "boolean":
+            trapee.size = 3; break;
+        case "default":
+            trapee.size = 0; break;
+        }
+    }
+    
+    static.sizeWrite = function(v) {
+        cascade = v;
+        trapee.minwidth = trapee.paddingleft + trapee.paddingright
+            + v * vexi.ui.font.width(trapee.font, trapee.fontsize, "0");
+    }
+    
     static.valueRead = function() { return cascade ? cascade : trapee.text; }
     
 </vexi>

Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/head.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/head.t       
2009-01-21 01:35:44 UTC (rev 3365)
+++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/head.t       
2009-01-21 01:37:32 UTC (rev 3366)
@@ -9,8 +9,10 @@
         
         thisbox.Children ++= function(c) {
             if (c) c.Press1 ++= static.pressEvent;
-            if (c == null and thisbox[trapname])
-                thisbox[trapname].Press1 --= static.pressEvent;
+            if (c == null) {
+                var _c = thisbox[trapname];
+                if (_c) _c.Press1 --= static.pressEvent;
+            }
             cascade = c;
         }
         

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        
2009-01-21 01:35:44 UTC (rev 3365)
+++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/row.t        
2009-01-21 01:37:32 UTC (rev 3366)
@@ -20,9 +20,12 @@
     static.childrenWrite = function(v) {
         if (!trapee.v_head) { cascade = v; return; }
         if (v) {
-            v.v_head = trapee.v_head[trapname];
-            v.display = v.v_head.display;
-            v.minwidth = v.v_head.contentwidth;
+            var h = trapee.v_head[trapname];
+            v.v_head = h;
+            v.hshrink = h.hshrink;
+            v.display = h.display;
+            v.minwidth = h.contentwidth;
+            v.maxwidth = h.maxwidth;
         } else {
             var _v = trapee[trapname];
             if (_v) _v.v_head = null;
@@ -41,7 +44,8 @@
                 continue;
             }
             var h = v[i];
-            c.shrink = h.hshrink;
+            c.v_head = h;
+            c.hshrink = h.hshrink;
             c.display = h.display;
             c.minwidth = h.contentwidth;
             c.maxwidth = h.maxwidth;

Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/table.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/table.t      
2009-01-21 01:35:44 UTC (rev 3365)
+++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/table.t      
2009-01-21 01:37:32 UTC (rev 3366)
@@ -318,9 +318,12 @@
         \***************************/
         
         
+        /** reset the row contents of this table */
+        thisbox.clear = function() { th_body.clear = true; }
+        
         /** reset the contents of this table */
         thisbox.reset = function() {
-            while (th_body[0]) th_body[0] = null;
+            clear();
             while (th_head[0]) th_head[0] = null;
             if (sortby) sortby.sort = null;
             sortby = null;


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:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to