+ void setMaxWidth(Object value) {
+ do { CHECKSET_INT(maxwidth); MARK_RESIZE; } while(false);
+ if (parent == null && getSurface() != null) getSurface().pendingWidth = maxwidth;
+ }
+ void setMaxHeight(Object value) {
+ do { CHECKSET_INT(maxheight); MARK_RESIZE; } while(false);
+ if (parent == null && getSurface() != null) getSurface().pendingHeight = maxheight;
+ }
+
+ public void put(Object name, Object value) throws JSExn {
+ if (name instanceof Number) { put(toInt(name), value); return; }
+ //#switch(name)
+ case "text": CHECKSET_STRING(text); MARK_RESIZE; dirty();
+ case "strokecolor": value = N(stringToColor((String)value)); CHECKSET_INT(strokecolor); MARK_RESIZE; dirty();
+ case "textcolor": value = N(stringToColor((String)value)); CHECKSET_INT(strokecolor); MARK_RESIZE; dirty();
+ case "text": CHECKSET_STRING(text); MARK_RESIZE; dirty();
+ case "strokewidth": CHECKSET_SHORT(strokewidth); dirty();
+ case "shrink": put("hshrink", value); put("vshrink", value);
+ case "hshrink": CHECKSET_FLAG(HSHRINK); MARK_RESIZE;
+ case "vshrink": CHECKSET_FLAG(VSHRINK); MARK_RESIZE;
+ case "width": put("maxwidth", value); put("minwidth", value); MARK_RESIZE;
+ case "height": put("maxheight", value); put("minheight", value); MARK_RESIZE;
+ case "maxwidth": setMaxWidth(value);
+ case "minwidth": CHECKSET_INT(minwidth); MARK_RESIZE;
+ case "maxheight": setMaxHeight(value);
+ case "minheight": CHECKSET_INT(minheight); MARK_RESIZE;
+ case "colspan": CHECKSET_SHORT(colspan); MARK_REPACK_parent;
+ case "rowspan": CHECKSET_SHORT(rowspan); MARK_REPACK_parent;
+ case "rows": CHECKSET_SHORT(rows); if (rows==0){set(FIXED, COLS);if(cols==0)cols=1;} else set(FIXED, ROWS); MARK_REPACK;
+ case "cols": CHECKSET_SHORT(cols); if (cols==0){set(FIXED, ROWS);if(rows==0)rows=1;} else set(FIXED, COLS); MARK_REPACK;
+ case "clip": CHECKSET_FLAG(CLIP); if (parent == null) dirty(); else parent.dirty();
+ case "visible": CHECKSET_FLAG(VISIBLE); dirty(); MARK_RESIZE; dirty();
+ case "packed": CHECKSET_FLAG(PACKED); MARK_REPACK_parent;
+ case "aspect": CHECKSET_INT(aspect); dirty();
+ case "globalx": put("x", N(globalToLocalX(toInt(value))));
+ case "globaly": put("y", N(globalToLocalY(toInt(value))));
+ case "align": clear(ALIGNS); setAlign(value == null ? "center" : value); MARK_RESIZE;
+ case "cursor": setCursor(value);
+ case "fill": setFill(value);
+ case "mouse":
+ int mousex = toInt(((JS)value).get("x"));
+ int mousey = toInt(((JS)value).get("y"));
+ getSurface()._mousex = localToGlobalX(mousex);
+ getSurface()._mousey = localToGlobalY(mousey);
+ case "Minimized": if (parent == null && getSurface() != null) getSurface().minimized = toBoolean(value); // FEATURE
+ case "Maximized": if (parent == null && getSurface() != null) getSurface().maximized = toBoolean(value); // FEATURE
+ case "Close": if (parent == null && getSurface() != null) getSurface().dispose(true);
+ case "toback": if (parent == null && getSurface() != null && toBoolean(value)) { getSurface().toBack(); }
+ case "tofront": if (parent == null && getSurface() != null && toBoolean(value)) { getSurface().toFront(); }
+ case "redirect": if (redirect == this) redirect = (Box)value; else Log.info(this, "redirect can only be set once");
+ case "font": font = value == null ? null : Font.getFont((Res)value, font == null ? 10 : font.pointsize); MARK_RESIZE; dirty();
+ case "fontsize": font = Font.getFont(font == null ? null : font.res, toInt(value)); MARK_RESIZE; dirty();
+ case "x": if (parent==null && Surface.fromBox(this)!=null) { CHECKSET_INT(x); } else { if (test(PACKED) && parent != null) return; CHECKSET_INT(x); dirty(); MARK_RESIZE; dirty(); }
+ case "y": if (parent==null && Surface.fromBox(this)!=null) { CHECKSET_INT(y); } else { if (test(PACKED) && parent != null) return; CHECKSET_INT(y); dirty(); MARK_RESIZE; dirty(); }
+
+ case "Press1": if (!test(STOP_UPWARD_PROPAGATION) && parent != null) parent.put(name, value);
+ case "Press2": if (!test(STOP_UPWARD_PROPAGATION) && parent != null) parent.put(name, value);
+ case "Press3": if (!test(STOP_UPWARD_PROPAGATION) && parent != null) parent.put(name, value);
+ case "Release1": if (!test(STOP_UPWARD_PROPAGATION) && parent != null) parent.put(name, value);
+ case "Release2": if (!test(STOP_UPWARD_PROPAGATION) && parent != null) parent.put(name, value);
+ case "Release3": if (!test(STOP_UPWARD_PROPAGATION) && parent != null) parent.put(name, value);
+ case "Click1": if (!test(STOP_UPWARD_PROPAGATION) && parent != null) parent.put(name, value);
+ case "Click2": if (!test(STOP_UPWARD_PROPAGATION) && parent != null) parent.put(name, value);
+ case "Click3": if (!test(STOP_UPWARD_PROPAGATION) && parent != null) parent.put(name, value);
+ case "DoubleClick1": if (!test(STOP_UPWARD_PROPAGATION) && parent != null) parent.put(name, value);
+ case "DoubleClick2": if (!test(STOP_UPWARD_PROPAGATION) && parent != null) parent.put(name, value);
+ case "DoubleClick3": if (!test(STOP_UPWARD_PROPAGATION) && parent != null) parent.put(name, value);
+ case "KeyPressed": if (!test(STOP_UPWARD_PROPAGATION) && parent != null) parent.put(name, value);
+ case "KeyReleased": if (!test(STOP_UPWARD_PROPAGATION) && parent != null) parent.put(name, value);
+ case "Move": if (!test(STOP_UPWARD_PROPAGATION) && parent != null) parent.put(name, value);
+ case "Enter": if (!test(STOP_UPWARD_PROPAGATION) && parent != null) parent.put(name, value);
+ case "Leave": if (!test(STOP_UPWARD_PROPAGATION) && parent != null) parent.put(name, value);
+
+ case "_Move": propagateDownward(name, value, false);
+ case "_Press1": propagateDownward(name, value, false);
+ case "_Press2": propagateDownward(name, value, false);
+ case "_Press3": propagateDownward(name, value, false);
+ case "_Release1": propagateDownward(name, value, false);
+ case "_Release2": propagateDownward(name, value, false);
+ case "_Release3": propagateDownward(name, value, false);
+ case "_Click1": propagateDownward(name, value, false);
+ case "_Click2": propagateDownward(name, value, false);
+ case "_Click3": propagateDownward(name, value, false);
+ case "_DoubleClick1": propagateDownward(name, value, false);
+ case "_DoubleClick2": propagateDownward(name, value, false);
+ case "_DoubleClick3": propagateDownward(name, value, false);
+ case "_KeyPressed": propagateDownward(name, value, false);
+ case "_KeyReleased": propagateDownward(name, value, false);
+
+ case "PosChange": return;
+ case "SizeChange": return;
+ case "childadded": return;
+ case "childremoved": return;
+
+ case "thisbox": if (value == null) removeSelf();
+
+ default: super.put(name, value);
+ //#end
+ }
+
+ private String alignToString() {
+ switch(flags & ALIGNS) {
+ case (ALIGN_TOP | ALIGN_LEFT): return "topleft";
+ case (ALIGN_BOTTOM | ALIGN_LEFT): return "bottomleft";
+ case (ALIGN_TOP | ALIGN_RIGHT): return "topright";
+ case (ALIGN_BOTTOM | ALIGN_RIGHT): return "bottomright";
+ case ALIGN_TOP: return "top";
+ case ALIGN_BOTTOM: return "bottom";
+ case ALIGN_LEFT: return "left";
+ case ALIGN_RIGHT: return "right";
+ case 0: return "center";
+ default: throw new Error("invalid alignment flags: " + (flags & ALIGNS));
+ }
+ }
+
+ private void setAlign(Object value) {
+ //#switch(value)
+ case "center": clear(ALIGNS);
+ case "topleft": set(ALIGN_TOP | ALIGN_LEFT);
+ case "bottomleft": set(ALIGN_BOTTOM | ALIGN_LEFT);
+ case "topright": set(ALIGN_TOP | ALIGN_RIGHT);
+ case "bottomright": set(ALIGN_BOTTOM | ALIGN_RIGHT);
+ case "top": set(ALIGN_TOP);
+ case "bottom": set(ALIGN_BOTTOM);
+ case "left": set(ALIGN_LEFT);
+ case "right": set(ALIGN_RIGHT);
+ default: JS.log("invalid alignment \"" + value + "\"");
+ //#end
+ }
+
+ private void setCursor(Object value) {
+ if (value == null) { clear(CURSOR); boxToCursor.remove(this); return; }
+ if (value.equals(boxToCursor.get(this))) return;
+ set(CURSOR);
+ boxToCursor.put(this, value);
+ Surface surface = getSurface();
+ String tempcursor = surface.cursor;
+ // FIXME
+ //Move(surface.mousex, surface.mousey, surface.mousex, surface.mousey);
+ if (surface.cursor != tempcursor) surface.syncCursor();
+ }
+
+ private void setFill(Object value) {
+ if (value == null) return;
+ if (value instanceof String) {
+ // FIXME check double set
+ int newfillcolor = stringToColor((String)value);
+ if (newfillcolor == fillcolor) return;
+ fillcolor = newfillcolor;
+ dirty();
+ return;