From: adam Date: Sun, 23 Jan 2005 21:17:02 +0000 (+0000) Subject: remove align property X-Git-Tag: 01-July-2005~18 X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=commitdiff_plain;h=1d41e269453ae4f9a36027122ffdb610a39d74ae;hp=303ade80a2dd8a8f7e421b78cc3ca6b7d5e9383a remove align property darcs-hash:20050123211702-5007d-ec1d1c44155e114a6777c4994eb0c7d73821cfe3.gz --- diff --git a/src/org/ibex/core/Box.java b/src/org/ibex/core/Box.java index 8696839..35a5e5f 100644 --- a/src/org/ibex/core/Box.java +++ b/src/org/ibex/core/Box.java @@ -81,11 +81,6 @@ public final class Box extends JS.Obj implements Callable { 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; @@ -369,13 +364,13 @@ public final class Box extends JS.Obj implements Callable { 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) { @@ -388,7 +383,7 @@ public final class Box extends JS.Obj implements Callable { } } 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 } @@ -432,8 +427,8 @@ public final class Box extends JS.Obj implements Callable { 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); } @@ -493,7 +488,6 @@ public final class Box extends JS.Obj implements Callable { 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)); @@ -580,7 +574,6 @@ public final class Box extends JS.Obj implements Callable { 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(); @@ -672,36 +665,6 @@ public final class Box extends JS.Obj implements Callable { //#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;