Revision: 2168
          http://vexi.svn.sourceforge.net/vexi/?rev=2168&view=rev
Author:   mkpg2
Date:     2007-09-12 14:06:31 -0700 (Wed, 12 Sep 2007)

Log Message:
-----------
Feature. Expose contentwidth/contentheight.

Modified Paths:
--------------
    trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp
    trunk/core/org.vexi.core/src/org/vexi/core/Constants.java

Added Paths:
-----------
    trunk/core/org.vexi.core/src_junit/test/core/box/layout/
    trunk/core/org.vexi.core/src_junit/test/core/box/layout/TestLayout.java
    trunk/core/org.vexi.core/src_junit/test/core/box/layout/contentx.t

Modified: trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp
===================================================================
--- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp  2007-09-12 16:47:01 UTC 
(rev 2167)
+++ trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp  2007-09-12 21:06:31 UTC 
(rev 2168)
@@ -62,7 +62,7 @@
 public final class Box extends JS.Obj implements Callable, Constants{
 
     // Treat following always as tokens - x/y are perhaps to short to do the 
same
-    //#pragma tokens SC_ width Width
+    //#pragma tokens SC_ width Width WIDTH
     
     //#define PUT_BOX_FIELD(NAME,VAL,CODE,FLAG)     \
     //    if (test(FLAG)) {\
@@ -202,8 +202,9 @@
     private static final int Y_TRAP                  = 0x00800000;
     
     private static final int MINMAX_TRAPS            = 0x01000000;
-    // unused - private static final int FLAG        = 0x02000000;
-    // unused - private static final int FLAG        = 0x04000000;
+    
+    private static final int CONTENTWIDTH_TRAP       = 0x02000000;
+    private static final int CONTENTHEIGHT_TRAP      = 0x04000000;
     // unused - private static final int FLAG        = 0x08000000;
 
     private static final int MOVE_TRAP               = 0x10000000;
@@ -318,7 +319,7 @@
     private void tryResize(int width, int height) {
         if (width == this.width && height == this.height) return;
         dirty();
-        //#repeat width/height WIDTH_TRAP/HEIGHT_TRAP
+        //#repeat width/height WIDTH/HEIGHT
         if (width != this.width) {
             PUT_BOX_FIELD(SC_width,JSU.N(width),this.width = width,WIDTH_TRAP)
             // FEATURE: slightly more efficient? set(PLACE); if (parent != 
null) parent.set(PLACE_DESCENDENT);
@@ -337,7 +338,7 @@
             PUT_BOX_FIELD(SC_x,JSU.N(x),this.x = x,X_TRAP)
         }
         //#end
-        //#repeat width/height WIDTH_TRAP/HEIGHT_TRAP
+        //#repeat width/height WIDTH/HEIGHT
         if (width != this.width) {
             PUT_BOX_FIELD(SC_width,JSU.N(width),this.width = width,WIDTH_TRAP)
             // FEATURE: slightly more efficient? set(PLACE); if (parent != 
null) parent.set(PLACE_DESCENDENT);
@@ -399,10 +400,8 @@
         if (!test(CONSTRAIN)) return;
 
         // remember current size
-        int oldwidth = contentwidth, oldheight = contentheight;
-        contentwidth = 0;
-        contentheight = 0;
-
+        int newwidth = 0, newheight = 0;
+        
         if (test(PACK)) {
             //#repeat width/height HORIZONTAL/VERTICAL 
             // accumulate child contentwidth
@@ -410,7 +409,7 @@
                 int i = 0;
                 for (Box c = getChild(0); c != null; c = getChild(++i)) {
                     if (!c.test(DISPLAY)) continue;
-                    contentwidth += c.contentwidth;
+                    newwidth += c.contentwidth;
                 }
 
             // maximum child contentwidth
@@ -418,7 +417,7 @@
                 int i = 0;
                 for (Box c = getChild(0); c != null; c = getChild(++i)) {
                     if (!c.test(DISPLAY)) continue;
-                    contentwidth = max(contentwidth, c.contentwidth);
+                    newwidth = max(newwidth, c.contentwidth);
                 }
             }
             //#end
@@ -427,20 +426,21 @@
             int i = 0;
             for (Box c = getChild(0); c != null; c = getChild(++i)) {
                 if (!c.test(DISPLAY)) continue;
-                contentwidth = max(contentwidth, c.contentwidth);
-                contentheight = max(contentheight, c.contentheight);
+                newwidth = max(newwidth, c.contentwidth);
+                newheight = max(newheight, c.contentheight);
             }
         }
-
-        //#repeat width/height HAS_WIDTH_SLACK/HAS_HEIGHT_SLACK
-        if (contentwidth < minwidth || contentwidth < text.width)
+        
+        //#repeat width/height WIDTH/HEIGHT
+        if (newwidth < minwidth || newwidth < text.width)
             set(HAS_WIDTH_SLACK);
         else clear(HAS_WIDTH_SLACK);
         // constrain contentwidth
-        contentwidth = min(maxwidth, max(minwidth, max(contentwidth, 
text.width)));
+        newwidth = min(maxwidth, max(minwidth, max(newwidth, text.width)));
 
         // mark 
-        if (oldwidth != contentwidth) {
+        if (newwidth != contentwidth) {
+               
PUT_BOX_FIELD(SC_contentwidth,JSU.N(newwidth),contentwidth=newwidth,CONTENTWIDTH_TRAP)
             setPlace();
             if (parent != null) {
                 parent.set(PLACE);
@@ -1149,10 +1149,12 @@
         case "rowspan": throw new JSExn("Deprecated property read: 
"+JSU.toString(name));
         case "width": return (minwidth==maxwidth) ? JSU.N(minwidth) : 
JSU.N(width);
         case "height": return (minheight==maxheight) ? JSU.N(minheight) : 
JSU.N(height);
-        case "minwidth": return JSU.N(contentwidth);
+        case "minwidth": return JSU.N(minwidth);
         case "maxwidth": return JSU.N(maxwidth);
-        case "minheight": return JSU.N(contentheight);
+        case "minheight": return JSU.N(minheight);
         case "maxheight": return JSU.N(maxheight);
+        case "contentwidth": return JSU.N(contentwidth);
+        case "contentheight": return JSU.N(contentheight);
         case "display": return JSU.B(test(DISPLAY));
         case "visible": return isVisible() ? JSU.T : JSU.F;
         case "packed": throw new JSExn("Deprecated property read: 
"+JSU.toString(name));
@@ -1383,6 +1385,8 @@
         case "maxwidth":  set(MINMAX_TRAPS);
         case "minheight": set(MINMAX_TRAPS);
         case "maxheight": set(MINMAX_TRAPS);
+        case "contentwidth": set(CONTENTWIDTH_TRAP);
+        case "contentheight": set(CONTENTHEIGHT_TRAP);
         case "Enter":     set(ENTER_TRAP);
         case "Leave":     set(LEAVE_TRAP);
         case "_Move":     set(MOVE_TRAP);
@@ -1400,6 +1404,8 @@
         case "y":         if (getTrap(SC_y) == null) clear(Y_TRAP);
         case "width":     if (getTrap(SC_width) == null) clear(WIDTH_TRAP);
         case "height":    if (getTrap(SC_height) == null) clear(HEIGHT_TRAP);
+        case "contentwidth": if (getTrap(SC_contentwidth) == null) 
clear(CONTENTWIDTH_TRAP);
+        case "contentheight":  if (getTrap(SC_contentheight) == null) 
clear(CONTENTHEIGHT_TRAP);
         case "Enter":     if (getTrap(SC_Enter) == null) clear(ENTER_TRAP);
         case "Leave":     if (getTrap(SC_Leave) == null) clear(LEAVE_TRAP);
         case "_Move":     if (getTrap(SC__Move) == null) clear(MOVE_TRAP);

Modified: trunk/core/org.vexi.core/src/org/vexi/core/Constants.java
===================================================================
--- trunk/core/org.vexi.core/src/org/vexi/core/Constants.java   2007-09-12 
16:47:01 UTC (rev 2167)
+++ trunk/core/org.vexi.core/src/org/vexi/core/Constants.java   2007-09-12 
21:06:31 UTC (rev 2168)
@@ -8,6 +8,8 @@
        static final JS SC_box = JSU.S("box",true);
        static final JS SC_characters = JSU.S("characters",true);
        static final JS SC_Children = JSU.S("Children",true);
+       static final JS SC_contentheight = JSU.S("contentheight",true);
+       static final JS SC_contentwidth = JSU.S("contentwidth",true);
        static final JS SC_cursor = JSU.S("cursor",true);
        static final JS SC_endElement = JSU.S("endElement",true);
        static final JS SC_Enter = JSU.S("Enter",true);

Added: trunk/core/org.vexi.core/src_junit/test/core/box/layout/TestLayout.java
===================================================================
--- trunk/core/org.vexi.core/src_junit/test/core/box/layout/TestLayout.java     
                        (rev 0)
+++ trunk/core/org.vexi.core/src_junit/test/core/box/layout/TestLayout.java     
2007-09-12 21:06:31 UTC (rev 2168)
@@ -0,0 +1,34 @@
+package test.core.box.layout;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import test.core.CoreTestCase;
+import test.core.CoreTestSuite;
+import test.core.box.TestBox;
+import testdeployment.NanoHTTPD;
+
+/**
+ * @author mike
+ */
+public class TestLayout extends TestBox{
+
+    public TestLayout() {
+               super(TestLayout.class);
+       }
+    
+    protected boolean filter(String name) {
+       return super.filter(name);
+    }
+
+       public static Test suite() {
+       return CoreTestSuite.suite(new TestLayout());
+    }
+   
+    
+    public static void main(String[] args) throws Throwable {
+
+       CoreTestSuite cts = new TestLayout();
+       TestCase t = cts.createTestCase(cts.getResourceDirs(), "contentx.t");
+       t.runBare();
+       }
+}


Property changes on: 
trunk/core/org.vexi.core/src_junit/test/core/box/layout/TestLayout.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/core/org.vexi.core/src_junit/test/core/box/layout/contentx.t
===================================================================
--- trunk/core/org.vexi.core/src_junit/test/core/box/layout/contentx.t          
                (rev 0)
+++ trunk/core/org.vexi.core/src_junit/test/core/box/layout/contentx.t  
2007-09-12 21:06:31 UTC (rev 2168)
@@ -0,0 +1,21 @@
+<vexi xmlns:ui="vexi://ui" xmlns="" xmlns:lib="_lib">
+
+       var testContentx = function(dim){
+               var c1 = vexi.box;
+               c1["min"+dim]=10;c1.forcereflow();
+               .util..assertEquals(10,c1["content"+dim]);
+               
+               var x = 0;
+               c1["content"+dim]++=function(v){
+                   x = v;
+                   cascade = v;
+               };
+               c1["min"+dim]=20;c1.forcereflow();
+               .util..assertEquals(20,x);      
+       };
+    testContentx("width");
+    testContentx("height");
+   
+   
+    <ui:box/>
+</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: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to