2003/09/27 06:42:26
[org.ibex.core.git] / src / org / xwt / Box.java.pp
index f2c45a0..71da82f 100644 (file)
@@ -92,6 +92,7 @@ public final class Box extends JS.Scope {
     static int TILE_FLAG         = 0x00000020;
     static int FONT_CHANGED_FLAG = 0x00000040;  // set when font changes, cleared during repack
     static int ISROOT_FLAG       = 0x00000080;
+    static int NOCLIP_FLAG       = 0x00000100;
 
 
     // Geometry ////////////////////////////////////////////////////////////////////////////
@@ -150,10 +151,12 @@ public final class Box extends JS.Scope {
     public final void dirty() { dirty(0, 0, width, height); }
     public final void dirty(int x, int y, int w, int h) {
         for(Box cur = this; cur != null; cur = cur.parent) {
-            w = min(x + w, cur.width) - max(x, 0);
-            h = min(y + h, cur.height) - max(y, 0);
-            x = max(x, 0);
-            y = max(y, 0);
+            if ((flags & NOCLIP_FLAG) == 0) {
+                w = min(x + w, cur.width) - max(x, 0);
+                h = min(y + h, cur.height) - max(y, 0);
+                x = max(x, 0);
+                y = max(y, 0);
+            }
             if (w <= 0 || h <= 0) return;
             if (cur.parent == null && cur.surface != null) cur.surface.dirty(x, y, w, h);
             x += cur.x;
@@ -391,14 +394,16 @@ public final class Box extends JS.Scope {
         int globaly = parenty + (parent == null ? 0 : y);
 
         // intersect the x,y,w,h rendering window with ourselves; quit if it's empty
-        clipw = min(max(clipx, parent == null ? 0 : globalx) + clipw, (parent == null ? 0 : globalx) + width) - globalx;
-        cliph = min(max(clipy, parent == null ? 0 : globaly) + cliph, (parent == null ? 0 : globaly) + height) - globaly;
-        clipx = max(clipx, parent == null ? 0 : globalx);
-        clipy = max(clipy, parent == null ? 0 : globaly);
+        if ((flags & NOCLIP_FLAG) == 0) {
+            clipw = min(max(clipx, parent == null ? 0 : globalx) + clipw, (parent == null ? 0 : globalx) + width) - globalx;
+            cliph = min(max(clipy, parent == null ? 0 : globaly) + cliph, (parent == null ? 0 : globaly) + height) - globaly;
+            clipx = max(clipx, parent == null ? 0 : globalx);
+            clipy = max(clipy, parent == null ? 0 : globaly);
+        }
         if (clipw <= 0 || cliph <= 0) return;
 
         if ((fillcolor & 0xFF000000) != 0x00000000)
-            buf.fillRect(clipx, clipy, clipx + clipw, clipy + cliph, fillcolor);
+            buf.fillTrapezoid(clipx, clipx + clipw, clipy, clipx, clipx + clipw, clipy + cliph, fillcolor);
 
         if (image != null)
             if ((flags & TILE_FLAG) != 0) renderTiledImage(globalx, globaly, clipx, clipy, clipw, cliph, buf);
@@ -408,10 +413,12 @@ public final class Box extends JS.Scope {
             renderText(globalx, globaly, clipx, clipy, clipw, cliph, buf);
 
         // now subtract the pad region from the clip region before proceeding
-        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);
+        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())
             b.render(globalx, globaly, clipx, clipy, clipw, cliph, buf);   
@@ -1056,6 +1063,15 @@ public final class Box extends JS.Scope {
                         b.dirty();
                     } });
         
+            specialBoxProperties.put("noclip", new SpecialBoxProperty() {
+                    public Object get(Box b) { return ((b.flags & NOCLIP_FLAG) != 0) ? Boolean.TRUE : Boolean.FALSE; }
+                    public void put(Box b, Object value) {
+                        if (((b.flags & NOCLIP_FLAG) != 0) == stob(value)) return;
+                        if (stob(value)) b.flags |= NOCLIP_FLAG; else b.flags &= ~NOCLIP_FLAG;
+                        MARK_FOR_REFLOW_b;
+                        b.dirty();
+                    } });
+        
             specialBoxProperties.put("invisible", new SpecialBoxProperty() {
                     public Object get(Box b) {
                         for (Box cur = b; cur != null; cur = cur.parent) {