Revision: 1987
          http://svn.sourceforge.net/vexi/?rev=1987&view=rev
Author:   clrg
Date:     2007-07-16 08:15:17 -0700 (Mon, 16 Jul 2007)

Log Message:
-----------
Change layout strings to "pack" and "place"

Modified Paths:
--------------
    core/trunk/org.vexi.core/src/org/vexi/core/Box.jpp
    core/trunk/org.vexi.core/src/org/vexi/core/Constants.java
    core/trunk/org.vexi.core/src_junit/test/visual/layout/absolute.t

Modified: core/trunk/org.vexi.core/src/org/vexi/core/Box.jpp
===================================================================
--- core/trunk/org.vexi.core/src/org/vexi/core/Box.jpp  2007-07-15 17:30:12 UTC 
(rev 1986)
+++ core/trunk/org.vexi.core/src/org/vexi/core/Box.jpp  2007-07-16 15:15:17 UTC 
(rev 1987)
@@ -106,8 +106,8 @@
     private final Box getRoot() { return parent == null ? this : 
parent.getRoot(); }
     protected final Surface getSurface() { return Surface.fromBox(getRoot()); }
 
-    private final int getXInParent() { return parent==null ? 0 : 
((!parent.test(ABSOLUTE) || test(ALIGN_LEFT)) ? x : 
x+((parent.width-width)/(test(ALIGN_RIGHT)?1:2))); }
-    private final int getYInParent() { return parent==null ? 0 : 
((!parent.test(ABSOLUTE) || test(ALIGN_TOP)) ? y : 
y+((parent.height-height)/(test(ALIGN_BOTTOM)?1:2))); }
+    private final int getXInParent() { return parent==null ? 0 : 
((parent.test(PACK) || test(ALIGN_LEFT)) ? x : 
x+((parent.width-width)/(test(ALIGN_RIGHT)?1:2))); }
+    private final int getYInParent() { return parent==null ? 0 : 
((parent.test(PACK) || test(ALIGN_TOP)) ? y : 
y+((parent.height-height)/(test(ALIGN_BOTTOM)?1:2))); }
     private final int globalToLocalX(int x) { return parent==null ? x : 
parent.globalToLocalX(x - getXInParent()); }
     private final int globalToLocalY(int y) { return parent==null ? y : 
parent.globalToLocalY(y - getYInParent()); }
     private final int localToGlobalX(int x) { return parent==null ? x : 
parent.localToGlobalX(x + getXInParent()); }
@@ -167,7 +167,7 @@
     private static final int DISPLAY                 = 0x00000002;
     private static final int HSHRINK                 = 0x00000004;
     private static final int VSHRINK                 = 0x00000008;
-    private static final int ABSOLUTE                = 0x00000010;
+    private static final int PACK                    = 0x00000010;
     private static final int MOUSEINSIDE             = 0x00000020;
     private static final int CURSOR                  = 0x00000040;
     private static final int MOVE_TRAP               = 0x00000080;
@@ -217,7 +217,7 @@
     private Box redirect = this;
     private int flags =
         ALIGN_TOP | ALIGN_LEFT | DISPLAY | REFLOW | ORIENT | TILE_IMAGE |
-        HAS_EMPTY_STRING | DEFAULT_FONTSIZE | DEFAULT_FONTSTREAM;
+        PACK | HAS_EMPTY_STRING | DEFAULT_FONTSIZE | DEFAULT_FONTSTREAM;
     private BasicTree bt = null;
     // rendering properties
     public int fillcolor = 0x00000000;
@@ -395,7 +395,7 @@
         // remember current size
         int oldwidth = contentwidth, oldheight = contentheight;
 
-        if (test(ABSOLUTE)) {
+        if (!test(PACK)) {
             contentwidth = 0;
             contentheight = 0;
             
@@ -449,8 +449,8 @@
             // needed for later resize()
             int child_width, child_height;
             
-            // absolute layout
-            if (test(ABSOLUTE)) {
+            // place children individually in box space
+            if (!test(PACK)) {
                 int i = 0;
                 for (Box child = getChild(0); child != null; child = 
getChild(++i)) {
                     if (!child.test(DISPLAY)) continue;
@@ -459,7 +459,7 @@
                     child.tryResize(child_width, child_height);
                 }
 
-            // packed layout
+            // pack children into available space
             } else {
                 int child_x = 0, child_y = 0;
 
@@ -658,7 +658,7 @@
         //if (path != null) path.realize(Affine.translate(globalx, 
globaly)).stroke(buf, 1, strokecolor);
         
         // absolute layout means we must attempt to render all visible children
-        if (test(ABSOLUTE)) {
+        if (!test(PACK)) {
             int i = 0;
             for (Box b = getChild(0); b != null; b = getChild(++i)) {
                 if (!b.test(DISPLAY)) continue;
@@ -941,7 +941,7 @@
         }
 
         // absolute layout - check all children
-        if (test(ABSOLUTE)) {
+        if (!test(PACK)) {
             int bx, by, i = treeSize()-1;
             for (Box b = getChild(i); b != null; b = getChild(--i)) {
                 if (!b.test(DISPLAY)) continue;
@@ -1003,7 +1003,7 @@
             return false;
 
         // absolute layout - check all children
-        if (test(ABSOLUTE)) {
+        if (!test(PACK)) {
             int bx, by, i = treeSize()-1;
             for (Box b = getChild(i); b != null; b = getChild(--i)) {
                 if (!b.test(DISPLAY)) continue;
@@ -1132,7 +1132,7 @@
         case "x": return JSU.N(x);
         case "y": return JSU.N(y);
         case "orient": return test(ORIENT) ? SC_horizontal : SC_vertical;
-        case "layout": return test(ABSOLUTE) ? SC_absolute : SC_packed;
+        case "layout": return test(PACK) ? SC_pack : SC_place;
         case "cols": throw new JSExn("Deprecated property read: 
"+JSU.toString(name));
         case "rows": throw new JSExn("Deprecated property read: 
"+JSU.toString(name));
         case "colspan": throw new JSExn("Deprecated property read: 
"+JSU.toString(name));
@@ -1301,12 +1301,12 @@
                 }
             }
         case "layout":
-            if (JSU.toString(value).equals("absolute")) {
-                if (test(ABSOLUTE)) return;
-                else set(ABSOLUTE);
-            } else if (JSU.toString(value).equals("packed")) {
-                if (test(ABSOLUTE)) clear(ABSOLUTE);
+            if (JSU.toString(value).equals("place")) {
+                if (test(PACK)) clear(PACK);
                 else return;
+            } else if (JSU.toString(value).equals("pack")) {
+                if (test(PACK)) return;
+                else set(PACK);
             } else throw new JSExn("Attempt to set Box property 'layout' to 
unsupported value '"+JSU.toString(value)+"'");
             setConstrain();
             setPlace();
@@ -1340,22 +1340,26 @@
             if (parent == null) {
                 this.x = JSU.toInt(value);
                 if (getSurface()!=null) getSurface().setPosition();
-            } else if (parent.test(ABSOLUTE)) {
+            } else if (parent.test(PACK)) {
+                throw new JSExn("Attempt to set x on a packed box");
+            } else {
                 dirty();
                 x = JSU.toInt(value);
                 dirty();
                 setParentPlace();
-            } else throw new JSExn("Attempt to set x on a packed box");
+            }
         case "y":
             if (parent == null) {
                 this.y = JSU.toInt(value);
                 if (getSurface()!=null) getSurface().setPosition();
-            } else if (parent.test(ABSOLUTE)) {
+            } else if (parent.test(PACK)) {
+                throw new JSExn("Attempt to set y on a packed box");
+            } else {
                 dirty();
                 y = JSU.toInt(value);
                 dirty();
                 setParentPlace();
-            } else throw new JSExn("Attempt to set y on a packed box");
+            } 
         case "icon":        if (parent == null && getSurface()!=null) 
getSurface().queueSetIcon(value); super.put(name, value);
         case "titlebar":    if (parent == null && getSurface()!=null) 
getSurface().setTitleBarText(JSU.toString(value)); super.put(name,value);
         default:              super.put(name, value);
@@ -1432,7 +1436,7 @@
             parent = null;
             oldparent.deleteNode(oldparent.indexNode(this));
             if (test(DISPLAY)) {
-                if (!oldparent.test(ABSOLUTE)) {
+                if (oldparent.test(PACK)) {
                     oldparent.setConstrain();
                     oldparent.setPlace();
                 }

Modified: core/trunk/org.vexi.core/src/org/vexi/core/Constants.java
===================================================================
--- core/trunk/org.vexi.core/src/org/vexi/core/Constants.java   2007-07-15 
17:30:12 UTC (rev 1986)
+++ core/trunk/org.vexi.core/src/org/vexi/core/Constants.java   2007-07-16 
15:15:17 UTC (rev 1987)
@@ -5,7 +5,6 @@
 
 public interface Constants extends org.ibex.js.Constants {
        static final JS SC_0 = JSU.S("0",true);
-    static final JS SC_absolute = JSU.S("absolute",true);
        static final JS SC_characters = JSU.S("characters",true);
        static final JS SC_Children = JSU.S("Children",true);
        static final JS SC_cursor = JSU.S("cursor",true);
@@ -24,7 +23,8 @@
     static final JS SC_Move = JSU.S("Move",true);
        static final JS SC__Move = JSU.S("_Move",true);
        static final JS SC_numchildren = JSU.S("numchildren",true);
-    static final JS SC_packed = JSU.S("packed",true);
+    static final JS SC_pack = JSU.S("pack",true);
+    static final JS SC_place = JSU.S("place",true);
        static final JS SC__Press3 = JSU.S("_Press3",true);
        static final JS SC_redirect = JSU.S("redirect",true);
        static final JS SC_shrink = JSU.S("shrink",true);

Modified: core/trunk/org.vexi.core/src_junit/test/visual/layout/absolute.t
===================================================================
(Binary files differ)


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 DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to