2003/10/09 07:59:35
authormegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:39:01 +0000 (07:39 +0000)
committermegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:39:01 +0000 (07:39 +0000)
darcs-hash:20040130073901-2ba56-2752ff9d1cfa520fcb191850fdcb2c97d93ac692.gz

src/org/xwt/Box.java.pp

index 09035f9..5c7a242 100644 (file)
@@ -107,8 +107,6 @@ public final class Box extends JS.Scope {
     public LENGTH minheight = 0;        
     public LENGTH maxwidth = MAX_LENGTH;
     public LENGTH maxheight = MAX_LENGTH;
-    private LENGTH hpad = 0;
-    private LENGTH vpad = 0;
     private String text = null;
     private Res font = null;
     private int fontsize = 10;
@@ -128,7 +126,7 @@ public final class Box extends JS.Scope {
     public LENGTH height = 0;
     private int row = 0;  // FEATURE use a short
     private int col = 0;  // FEATURE use a short
-    private LENGTH contentwidth = 0;             // == max(minwidth, textwidth+pad, sum(child.contentwidth) + pad)
+    private LENGTH contentwidth = 0;             // == max(minwidth, textwidth, sum(child.contentwidth))
     private LENGTH contentheight = 0;
     private LENGTH offset_x = 0;
     private LENGTH offset_y = 0;
@@ -200,7 +198,7 @@ public final class Box extends JS.Scope {
         if (isinside && cursor != null) getRoot().cursor = cursor;
 
         // if the mouse has moved into our padding region, it is considered 'outside' all our children
-        if (!(mousex >= hpad && mousey >= vpad && mousex < width - hpad && mousey < height + vpad)) forceleave = true;
+        if (!(mousex >= 0 && mousey >= 0 && mousex < width && mousey < height)) forceleave = true;
 
         for(Box b = getChild(numChildren() - 1); b != null; b = b.prevSibling()) {
             b.Move(oldmousex - b.x, oldmousey - b.y, mousex - b.x, mousey - b.y, forceleave);
@@ -266,8 +264,7 @@ public final class Box extends JS.Scope {
         // --- Phase 2 ----------------------------------------------------------------------
         // compute the min/max sizes of the columns and rows and set our contentwidth
         if (numChildren() != 0) {
-            //#repeat x/y y/x width/height col/row cols/rows colspan/rowspan colWidth/rowHeight maxwidth/maxheight minwidth/minheight contentwidth/contentheight colMaxWidth/rowMaxHeight numCols/numRows hpad/vpad
-            contentwidth = 2 * hpad;
+            //#repeat x/y y/x width/height col/row cols/rows colspan/rowspan colWidth/rowHeight maxwidth/maxheight minwidth/minheight contentwidth/contentheight colMaxWidth/rowMaxHeight numCols/numRows
             int numCols = cols;
             if (numCols == 0)
                 for(Box child = getChild(0); child != null; child = child.nextSibling())
@@ -277,7 +274,7 @@ public final class Box extends JS.Scope {
                 if (!(((child.flags & NOTPACKED_FLAG) != 0) || ((child.flags & INVISIBLE_FLAG) != 0)))
                     colWidth[child.col] = max(colWidth[child.col], child.contentwidth / child.colspan);
             for(int col=0; col<numCols; col++) contentwidth += colWidth[col];
-            contentwidth = max(textwidth + 2 * hpad, contentwidth);
+            contentwidth = max(textwidth, contentwidth);
             contentwidth = bound(minwidth, contentwidth, maxwidth);
             //#end               
         }
@@ -370,8 +367,8 @@ public final class Box extends JS.Scope {
         // --- Phase 3 ----------------------------------------------------------------------
         // hand out the slack
         int slack;
-        //#repeat x/y y/x width/height col/row cols/rows colspan/rowspan colWidth/rowHeight maxwidth/maxheight minwidth/minheight contentwidth/contentheight colMaxWidth/rowMaxHeight numCols/numRows hpad/vpad
-        slack = width - 2 * hpad;
+        //#repeat x/y y/x width/height col/row cols/rows colspan/rowspan colWidth/rowHeight maxwidth/maxheight minwidth/minheight contentwidth/contentheight colMaxWidth/rowMaxHeight numCols/numRows
+        slack = width;
         for(int i=0; i<numCols; i++) slack -= colWidth[i];
         if (numChildren() > 0)
             while(slack > 0) {  
@@ -396,14 +393,14 @@ public final class Box extends JS.Scope {
             if ((child.flags & NOTPACKED_FLAG) != 0) {
                 child_x = child.x;
                 child_y = child.y;
-                child_width = ((child.flags & HSHRINK_FLAG) != 0) ? child.contentwidth : min(child.maxwidth, width - child.x - hpad);
-                child_height = ((child.flags & VSHRINK_FLAG) != 0) ? child.contentheight : min(child.maxheight, height - child.y - vpad);
+                child_width = ((child.flags & HSHRINK_FLAG) != 0) ? child.contentwidth : min(child.maxwidth, width - child.x);
+                child_height = ((child.flags & VSHRINK_FLAG) != 0) ? child.contentheight : min(child.maxheight, height - child.y);
             } else {
                 int diff;
-                //#repeat x/y y/x width/height col/row cols/rows colspan/rowspan colWidth/rowHeight maxwidth/maxheight minwidth/minheight contentwidth/contentheight colMaxWidth/rowMaxHeight HSHRINK_FLAG/VSHRINK_FLAG marginWidth/marginHeight hpad/vpad child_x/child_y child_width/child_height
+                //#repeat x/y y/x width/height col/row cols/rows colspan/rowspan colWidth/rowHeight maxwidth/maxheight minwidth/minheight contentwidth/contentheight colMaxWidth/rowMaxHeight HSHRINK_FLAG/VSHRINK_FLAG marginWidth/marginHeight child_x/child_y child_width/child_height
                 child_width = 0; for(int i=child.col; i<child.col+child.colspan && i<colWidth.length; i++) child_width += colWidth[i];
                 diff = bound(child.contentwidth, child_width, ((child.flags & HSHRINK_FLAG) != 0) ? child.contentwidth : child.maxwidth) - child_width;
-                if (transform == null) child_x = max(hpad, marginWidth / 2);
+                if (transform == null) child_x = marginWidth / 2;
                 for(int i=0; i<child.col; i++) child_x += colWidth[i];
                 if (diff < 0) child_x += -1 * (diff / 2);
                 child_width += diff;
@@ -460,14 +457,6 @@ public final class Box extends JS.Scope {
             if ((fillcolor & 0xff000000) != 0) rpath.fill(buf, new VectorGraphics.SingleColorPaint(fillcolor));
         }
 
-        // now subtract the pad region from the clip region before proceeding
-        if ((flags & NOCLIP_FLAG) == 0) {
-            clipw = min(max(clipx, globalx + hpad) + clipw, globalx + width - hpad) - clipx;
-            cliph = min(max(clipy, globaly + vpad) + cliph, globaly + height - vpad) - clipy;
-            clipx = max(clipx, globalx + hpad);
-            clipy = max(clipy, globaly + vpad);
-        }
-
         for(Box b = getChild(0); b != null; b = b.nextSibling()) {
             VectorGraphics.Affine a2 = VectorGraphics.Affine.translate(b.x, b.y);
             if (transform != null) a2.multiply(transform);
@@ -510,10 +499,10 @@ public final class Box extends JS.Scope {
             char c = text.charAt(i);
             Glyph g = Glyph.getGlyph(font, fontsize, c);
            buf.drawPictureAlphaOnly(g.p,
-                                     x + hpad,
-                                     y + vpad + g.max_ascent - g.baseline,
-                                     x + hpad + g.p.getWidth(),
-                                     y + vpad + g.max_ascent - g.baseline + g.p.getHeight(),
+                                     x,
+                                     y + g.max_ascent - g.baseline,
+                                     x + g.p.getWidth(),
+                                     y + g.max_ascent - g.baseline + g.p.getHeight(),
                                      0, 0,
                                      g.p.getWidth(), g.p.getHeight(),
                                      textcolor);
@@ -1365,24 +1354,6 @@ public final class Box extends JS.Scope {
             specialBoxProperties.put("PosChange", new SpecialBoxProperty());
             specialBoxProperties.put("SizeChange", new SpecialBoxProperty());
 
-            //#repeat hpad/vpad 
-            specialBoxProperties.put("hpad", new SpecialBoxProperty() {
-                    public Object get(Box b) {
-                        if (b.redirect == null) return new Integer(0);
-                        if (b.redirect != b) return get(b.redirect);
-                        return new Integer(b.hpad);
-                    }
-                    public void put(Box b, Object value) {
-                        if (b.redirect == null) return;
-                        if (b.redirect != b) { put(b.redirect, value); return; }
-                        int newval = stoi(value);
-                        if (newval == b.hpad) return;
-                        b.hpad = newval;
-                        MARK_FOR_REFLOW_b;
-                    }
-                });
-            //#end
-
             //#repeat minwidth/minheight maxwidth/maxheight
             specialBoxProperties.put("minwidth", new SpecialBoxProperty() {
                     public Object get(Box b) { return new Integer(b.minwidth); }