static final int RECONSTRAIN = 0x00000200;
static final int REPLACE = 0x00000400;
- static final int ALIGN_TOP = 0x00001000;
- static final int ALIGN_BOTTOM = 0x00002000;
- static final int ALIGN_LEFT = 0x00004000;
- static final int ALIGN_RIGHT = 0x00008000;
- static final int ALIGNS = 0x0000f000;
static final int CURSOR = 0x00010000; // if true, this box has a cursor in the cursor hash; FEATURE: GC issues?
static final int CLIP = 0x00020000;
static final int STOP_UPWARD_PROPAGATION = 0x00040000;
child_height = max(child.minheight, child_height);
int gap_x = width - child_width;
int gap_y = height - child_height;
- child_x = child.ax + (child.test(ALIGN_RIGHT) ? gap_x : !child.test(ALIGN_LEFT) ? gap_x / 2 : 0);
- child_y = child.ay + (child.test(ALIGN_BOTTOM) ? gap_y : !child.test(ALIGN_TOP) ? gap_y / 2 : 0);
+ child_x = child.ax + gap_x / 2;
+ child_y = child.ay + gap_y / 2;
} else {
int diff;
//#repeat col/row colspan/rowspan contentwidth/contentheight width/height colMaxWidth/rowMaxHeight \
// child_x/child_y x/y HSHRINK/VSHRINK maxwidth/maxheight cols/rows minwidth/minheight x_slack/y_slack \
- // child_width/child_height ALIGN_RIGHT/ALIGN_BOTTOM ALIGN_LEFT/ALIGN_TOP lp_h/lp \
+ // child_width/child_height lp_h/lp \
// numregions/numregions_v regions/regions_v targetColumnSize/targetRowSize sizes/sizes_v
child_x = 0;
if (cols == 1) {
}
}
diff = (child_width - (child.test(HSHRINK) ? child.contentwidth : min(child_width, child.maxwidth)));
- child_x += (child.test(ALIGN_RIGHT) ? diff : child.test(ALIGN_LEFT) ? 0 : diff / 2);
+ child_x += diff / 2;
child_width -= diff;
//#end
}
if (text != null && !text.equals("") && font != null) {
int gap_x = width - font.textwidth(text);
int gap_y = height - font.textheight(text);
- int text_x = globalx + (test(ALIGN_RIGHT) ? gap_x : !test(ALIGN_LEFT) ? gap_x/2 : 0);
- int text_y = globaly + (test(ALIGN_BOTTOM) ? gap_y : !test(ALIGN_TOP) ? gap_y/2 : 0);
+ int text_x = globalx + gap_x/2;
+ int text_y = globaly + gap_y/2;
font.rasterizeGlyphs(text, buf, strokecolor, text_x, text_y, cx1, cy1, cx2, cy2);
}
case "font": return font == null ? null : font.stream;
case "fontsize": return font == null ? JSU.N(10) : JSU.N(font.pointsize);
case "strokewidth": return JSU.N(strokewidth);
- case "align": return JSU.S(alignToString());
case "thisbox": return this;
case "shrink": return JSU.B(test(HSHRINK) || test(VSHRINK));
case "hshrink": return JSU.B(test(HSHRINK));
case "rowspan": if (JSU.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); REPLACE();
case "cursor": setCursor(JSU.toString(value));
case "fill": setFill(value);
case "clip": CHECKSET_FLAG(CLIP); if (parent == null) dirty(); else parent.dirty();
//#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(JS value) throws JSExn {
- clear(ALIGNS);
- //#switch(JSU.toString(value))
- 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: JSU.log("invalid alignment \"" + JSU.str(value) + "\"");
- //#end
- }
-
private void setCursor(String value) throws JSExn {
if (value == null) { clear(CURSOR); boxToCursor.remove(this); return; }
if (value.equals(boxToCursor.get(this))) return;