2003/09/24 07:33:32
[org.ibex.core.git] / src / org / xwt / Box.java.pp
index 554b287..f18182c 100644 (file)
@@ -102,10 +102,10 @@ public final class Box extends JS.Scope {
     //#define MIN_LENGTH Integer.MIN_VALUE
 
     // always correct (set directly by user)
-    LENGTH minwidth = 0;        
-    LENGTH minheight = 0;        
-    LENGTH maxwidth = MAX_LENGTH;
-    LENGTH maxheight = MAX_LENGTH;
+    public LENGTH minwidth = 0;        
+    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;
@@ -137,7 +137,7 @@ public final class Box extends JS.Scope {
     //private SVG.Paint fill = null;
     //private SVG.Paint stroke = null;
 
-    private Picture image;                       // will disappear
+    public Picture image;                        // will disappear
     private int fillcolor = 0x00000000;          // will become SVG.Paint
     private int strokecolor = 0xFF000000;        // will become SVG.Paint
 
@@ -196,10 +196,11 @@ public final class Box extends JS.Scope {
 
     // Reflow ////////////////////////////////////////////////////////////////////////////////////////
 
-    void reflow() {
+    void reflow() { reflow(width, height); }
+    void reflow(int new_width, int new_height) {
         repack();
         if (Surface.abort) return;
-        resize(x, y, width, height);
+        resize(x, y, new_width, new_height);
     }
 
     /** Checks if the Box's size has changed, dirties it if necessary, and makes sure childrens' sizes are up to date */
@@ -270,8 +271,8 @@ public final class Box extends JS.Scope {
     }
 
 
-    void resize(LENGTH x, LENGTH y, LENGTH width, LENGTH height) {
-
+    private void resize(LENGTH x, LENGTH y, LENGTH width, LENGTH height) {
+        
         // --- Phase 1 ----------------------------------------------------------------------
         // run PosChange/SizeChange, dirty as needed
         if (x != this.x || y != this.y || width != this.width || height != this.height) {
@@ -286,8 +287,8 @@ public final class Box extends JS.Scope {
                     if (Log.on) Log.logJS(this, "Warning, more than 500 SizeChange/PosChange traps triggered since last complete render");
                 } else {
                     sizePosChangesSinceLastRender++;
-                    if (sizechange) put("SizeChange", Boolean.TRUE);
-                    if (poschange) put("PosChange", Boolean.TRUE);
+                    try { if (sizechange) put("SizeChange", Boolean.TRUE); } catch (Exception e) { Log.log(this, e); }
+                    try { if (poschange) put("PosChange", Boolean.TRUE); } catch (Exception e) { Log.log(this, e); }
                     Surface.abort = true;
                     return;
                 }
@@ -390,17 +391,14 @@ 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;
+        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 || parent == null)
-            buf.fillRect(clipx, clipy, clipx + clipw, clipy + cliph,
-                         (fillcolor & 0xFF000000) != 0 ? fillcolor : 0xFF777777);
+        if ((fillcolor & 0xFF000000) != 0x00000000)
+            buf.fillRect(clipx, clipy, clipx + clipw, clipy + cliph, fillcolor);
 
         if (image != null)
             if ((flags & TILE_FLAG) != 0) renderTiledImage(globalx, globaly, clipx, clipy, clipw, cliph, buf);
@@ -1126,6 +1124,7 @@ public final class Box extends JS.Scope {
                     public Object get(Box b) { return b.image == null ? null : ImageDecoder.imageToNameMap.get(b.image); }
                     */
                     public void put(Box b, Object value) {
+                        //if (image != null) System.out.println("hit");
                         if (value == null) {
                             b.image = null;
                         } else if (value instanceof Res) {