X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fcore%2FBox.java;h=053357a905394e90f984df20e80c7f7a9b8073a6;hp=29cd9bcb57e88acbd0eff7c3fa500e7956c73de4;hb=2d6763644359578428d56d004b998edd10463a84;hpb=76982fccac3c46ccc47621dd22dc0c96b6b9cd62 diff --git a/src/org/ibex/core/Box.java b/src/org/ibex/core/Box.java index 29cd9bc..053357a 100644 --- a/src/org/ibex/core/Box.java +++ b/src/org/ibex/core/Box.java @@ -57,7 +57,11 @@ public final class Box extends JSScope implements Task { // FIXME memory leak static Hash boxToCursor = new Hash(500, 3); - static final Font DEFAULT_FONT = Font.getFont((Stream)Main.builtin.get(JS.S("fonts/vera/Vera.ttf")), 10); + static final Font DEFAULT_FONT; + static { + try { DEFAULT_FONT = Font.getFont(Main.builtin.get(JS.S("fonts/vera/Vera.ttf")), 10); } + catch(JSExn e) { throw new Error("Error loading default font: " + e); } + } // Flags ////////////////////////////////////////////////////////////////////// @@ -439,7 +443,7 @@ public final class Box extends JSScope implements Task { public JS callMethod(JS method, JS a0, JS a1, JS a2, JS[] rest, int nargs) throws JSExn { switch (nargs) { case 1: { - //#switch(JS.toString(method)) + //#jswitch(method) case "indexof": Box b = (Box)a0; if (b.parent != this) @@ -465,7 +469,7 @@ public final class Box extends JSScope implements Task { if (JS.isInt(name)) return redirect == null ? null : redirect == this ? getChild(JS.toInt(name)) : redirect.get(name); - //#switch(JS.toString(name)) + //#jswitch(name) case "surface": return parent == null ? null : parent.getAndTriggerTraps(name); case "indexof": return METHOD; case "distanceto": return METHOD; @@ -523,7 +527,7 @@ public final class Box extends JSScope implements Task { private class Mouse extends JS implements JS.Cloneable { public JS get(JS key) throws JSExn { - //#switch(JS.toString(key)) + //#jswitch(key) case "x": return N(globalToLocalX(getSurface()._mousex)); case "y": return N(globalToLocalY(getSurface()._mousey)); @@ -551,7 +555,7 @@ public final class Box extends JSScope implements Task { public void put(JS name, JS value) throws JSExn { if (JS.isInt(name)) { put(JS.toInt(name), value); return; } - //#switch(JS.toString(name)) + //#jswitch(name) case "thisbox": if (value == null) removeSelf(); case "text": { String s = value == null ? "" : JS.toString(value); CHECKSET_STRING(text); RECONSTRAIN(); dirty(); } case "strokecolor": value = N(Color.stringToColor(JS.toString(value))); CHECKSET_INT(strokecolor); dirty(); @@ -571,7 +575,7 @@ public final class Box extends JSScope implements Task { case "rowspan": if (toInt(value) > 0) { CHECKSET_SHORT(rowspan); if (parent != null) parent.REPACK(); } case "visible": CHECKSET_FLAG(VISIBLE); RECONSTRAIN(); dirty(); case "packed": CHECKSET_FLAG(PACKED); if (parent != null) { parent.REPACK(); } else { REPACK(); } - case "align": clear(ALIGNS); setAlign(value == null ? "center" : JS.toString(value)); REPLACE(); + case "align": clear(ALIGNS); setAlign(value); REPLACE(); case "cursor": setCursor(JS.toString(value)); case "fill": setFill(value); case "clip": CHECKSET_FLAG(CLIP); if (parent == null) dirty(); else parent.dirty(); @@ -678,9 +682,9 @@ public final class Box extends JSScope implements Task { } } - private void setAlign(String value) { + private void setAlign(JS value) throws JSExn { clear(ALIGNS); - //#switch(value) + //#jswitch(value) case "topleft": set(ALIGN_TOP | ALIGN_LEFT); case "bottomleft": set(ALIGN_BOTTOM | ALIGN_LEFT); case "topright": set(ALIGN_TOP | ALIGN_RIGHT); @@ -689,7 +693,7 @@ public final class Box extends JSScope implements Task { case "bottom": set(ALIGN_BOTTOM); case "left": set(ALIGN_LEFT); case "right": set(ALIGN_RIGHT); - default: JS.log("invalid alignment \"" + value + "\""); + default: JS.log("invalid alignment \"" + JS.debugToString(value) + "\""); //#end }