2003/11/16 08:28:09
[org.ibex.core.git] / src / org / xwt / Box.java
index 3ac48d4..864d332 100644 (file)
@@ -97,7 +97,7 @@ public abstract class Box extends JSScope implements JSTrap.JSTrappable {
 
     private String text = null;
     private Font font = null;
-    private Picture texture;
+    private Picture.Holder texture;
     private short strokewidth = 1;
     private int fillcolor = 0x00000000;
     private int strokecolor = 0xFF000000;
@@ -152,9 +152,8 @@ public abstract class Box extends JSScope implements JSTrap.JSTrappable {
         }
     }
 
-    // fixme
     public void putAndTriggerJSTraps(Object key, Object value) {
-        put(key, value);
+        JSContext.invokeTrap(this, key, value);
     }
 
     /** update MOUSEINSIDE, check for Enter/Leave/Move */
@@ -334,10 +333,10 @@ public abstract class Box extends JSScope implements JSTrap.JSTrappable {
         if ((fillcolor & 0xFF000000) != 0x00000000)
             buf.fillTrapezoid(globalx, globalx + width, globaly, globalx, globalx + width, globaly + height, fillcolor);
 
-        if (texture != null)
-            for(int x = globalx; x < cx2; x += texture.getWidth())
-                for(int y = globaly; y < cy2; y += texture.getHeight())
-                    buf.drawPicture(texture, x, y, cx1, cy1, cx2, cy2);
+        if (texture != null && texture.picture != null)
+            for(int x = globalx; x < cx2; x += texture.picture.getWidth())
+                for(int y = globaly; y < cy2; y += texture.picture.getHeight())
+                    buf.drawPicture(texture.picture, x, y, cx1, cy1, cx2, cy2);
 
        if (text != null && !text.equals("") && font != null)
             if (font.rasterizeGlyphs(text, buf, strokecolor, globalx, globaly, cx1, cy1, cx2, cy2, null) == -1)
@@ -529,23 +528,26 @@ public abstract class Box extends JSScope implements JSTrap.JSTrappable {
         if (value == null) return;
         if (value instanceof String) {
             // FIXME check double set
-            fillcolor = stringToColor((String)value);
+            int newfillcolor = stringToColor((String)value);
+            if (newfillcolor == fillcolor) return;
+            fillcolor = newfillcolor;
+            dirty();
+            return;
         }
         if (!(value instanceof Res)) return;
-        Picture pic = Picture.fromRes((Res)value, null);
-        if (pic != null) {
-            texture = pic;
-            minwidth = texture.getWidth();
-            minheight = texture.getHeight();
+        texture = Picture.fromRes((Res)value, null);
+        if (texture != null) {
+            minwidth = texture.picture.getWidth();
+            minheight = texture.picture.getHeight();
             MARK_REFLOW;
             dirty();
-        } else Picture.fromRes((Res)value, new Callback() { public Object call(Object arg) {
-            texture = (Picture)arg;
-            minwidth = texture.getWidth();
-            minheight = texture.getHeight();
+            return;
+        }
+        texture = Picture.fromRes((Res)value, new Scheduler.Task() { public void perform() {
+            minwidth = texture.picture.getWidth();
+            minheight = texture.picture.getHeight();
             Box b = Box.this; MARK_REFLOW_b;
             dirty();
-            return null;
         } });
     }