Revision: 4554
          http://sourceforge.net/p/vexi/code/4554
Author:   clrg
Date:     2013-09-18 17:40:48 +0000 (Wed, 18 Sep 2013)
Log Message:
-----------
Fix tablist population logic

Modified Paths:
--------------
    branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/tabpane.t

Modified: 
branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/tabpane.t
===================================================================
--- branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/tabpane.t 
2013-09-18 16:20:19 UTC (rev 4553)
+++ branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/tabpane.t 
2013-09-18 17:40:48 UTC (rev 4554)
@@ -15,14 +15,15 @@
         thisbox.maxtabsize = 0;
         thisbox.shrinktabs = true;
         thisbox.displayclose = false;
+        
         thisbox.tabpolicy;
         thisbox.taborder = new vec();
+        
         thisbox.th_add;
         thisbox.th_head;
         thisbox.th_headwrap;
         thisbox.th_tablist;
         thisbox.v_content;
-        thisbox.v_tabwidthtotal = 0;
         
         // to be implemented by user
         thisbox.createTab;
@@ -37,7 +38,7 @@
                 child.v_tab.closeable = c==null ? v : c;
             }
         }
-            
+        
         /** select tab of shown card */
         thisbox.show ++= function(v) {
             var s = show;
@@ -48,42 +49,40 @@
             taborder.unshift(show);
         }
         
-        var sumWidths = function(v) {
-            v_tabwidthtotal -= trapee.width;
-            cascade = v;
-            v_tabwidthtotal += trapee.width;
-        }
-        
-        var tabListPolicy = function(v) {
-            cascade = v;
+        var updateTabList = function(v) {
             var hw = th_headwrap.width;
-            var displayall = th_tablist.display;
-            th_tablist.display = v_tabwidthtotal>hw;
-            displayall = displayall and !th_tablist.display;
-            if (th_tablist.display or displayall) {
-                // display as many as will fit, recently displayed first
-                var c = taborder.first;
-                for (var cw = 0; c!=null; c = taborder.after(c)) {
-                    if (c.v_tab.enabled == false) {
+            // display as many as will fit, recently displayed first
+            var c = taborder.first;
+            for (var cw = createTab?th_add.width:0; c!=null; c = 
taborder.after(c)) {
+                if (c.v_tab.enabled == false) {
+                    c.v_tab.display = false;
+                    continue;
+                }
+                // test whether we have room to display more tabs
+                // cw = current width, hw = headwrap width
+                if (cw > 0 and cw + c.v_tab.width > hw) {
+                    // hide the rest
+                    while (c!=null) {
                         c.v_tab.display = false;
-                        continue;
+                        c.v_tabitem.text = c.tabtext;
+                        c = taborder.after(c);
                     }
-                    if (cw > 0 and cw + c.v_tab.width > hw) {
-                        break;
-                    }
-                    c.v_tab.display = true;
-                    c.v_tabitem.text = "* "+c.tabtext;
-                    cw += c.v_tab.width;
+                    th_tablist.display = true;
+                    return;
                 }
-                // hide the rest
-                while (c!=null) {
-                    c.v_tab.display = false;
-                    c.v_tabitem.text = c.tabtext;
-                    c = taborder.after(c);
-                }
+                c.v_tab.display = true;
+                c.v_tabitem.text = "* "+c.tabtext;
+                cw += c.v_tab.width;
             }
+            th_tablist.display = false;
         }
         
+        var tabListPolicy = function(v) {
+            cascade = v;
+            if (tabpolicy == "list")
+                updateTabList();
+        }
+        
         var tabScrollPolicy = function(v) {
             cascade = v;
             th_next.display = th_head.width>th_headwrap.width;
@@ -100,21 +99,21 @@
                     // disable tablist
                     if (th_tablist) th_list.display = false;
                     th_headwrap.width --= tabListPolicy;
-                    v_tabwidthtotal --= tabListPolicy;
                     show --= tabListPolicy;
                     // disable scrolling
                     if (th_next) th_next.display = false;
                     if (th_prev) th_prev.display = false;
                     th_headwrap.width --= tabScrollPolicy;
-                    th_head.width --= tabScrollPolicy; 
+                    th_head.width --= tabScrollPolicy;
                     show --= tabScrollPolicy;
+                    v_content.Chdilren --= tabListPolicy;
                     break;
                 case "scroll":
                     throw "not implemented";
                     // disable tablist
                     if (th_tablist) th_tablist.display = false;
                     th_headwrap.width --= tabListPolicy;
-                    v_tabwidthtotal --= tabListPolicy;
+                    th_head.width --= tabListPolicy;
                     show --= tabListPolicy;
                     // enable scrolling
                     th_headwrap.width ++= tabScrollPolicy;
@@ -131,7 +130,7 @@
                     show --= tabListPolicy;
                     // enable tablist
                     th_headwrap.width ++= tabListPolicy;
-                    v_tabwidthtotal ++= tabListPolicy;
+                    th_head.width ++= tabListPolicy;
                     show ++= tabListPolicy; 
                     break;
             }
@@ -180,10 +179,9 @@
                     // selection
                     t.v_card = c;
                     t.selected ++= tabselectWrite;
+                    t.width ++= tabListPolicy;
                     c.tabtext ++= static.tabtextWrite;
                     c.v_tab.text = c.tabtext;
-                    c.v_tab.width ++= sumWidths;
-                    v_tabwidthtotal += c.v_tab.width;
                     // place the tab
                     taborder.push(c);
                     th_head[trapname] = t;
@@ -201,10 +199,9 @@
                     var _c = v_content[trapname];
                     if (_c) {
                         _c.v_tab.selected --= tabselectWrite;
-                        _c.v_tab.width --= sumWidths;
+                        _c.v_tab.width --= tabListPolicy;
                         _c.v_tab.thisbox = null;
                         _c.v_tabitem.thisbox = null;
-                        v_tabwidthtotal -= _c.v_tab.width;
                         taborder.remove(_c);
                     }
                     var nextc = taborder.first;
@@ -225,10 +222,17 @@
         thisbox.th_tablist ++= function(v) {
             cascade = v;
             if (v) {
+                v.discover();
                 v.value ++= tablistShow;
             }
         }
         
+        thisbox.addlabel ++= function(v) {
+            cacsade = v;
+            if (th_addlabel)
+                th_addlabel.text = !v?:"   "+v; // FIXME: "   " spacing hack
+        }
+        
         thisbox.createTab ++= function(v) {
             cascade = v;
             if (th_add) {

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99!
1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint
2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes
Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13. 
http://pubads.g.doubleclick.net/gampad/clk?id=58041151&iu=/4140/ostg.clktrk
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to