From: adam Date: Fri, 16 Apr 2004 02:28:54 +0000 (+0000) Subject: fix bug 556 X-Git-Tag: 01-July-2005~142 X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=commitdiff_plain;h=7331e84fbc537390dc12aefb3cfd736b897168b5 fix bug 556 darcs-hash:20040416022854-5007d-09989e8a5af21facec6184f7615fad4bb5a46a60.gz --- diff --git a/src/org/ibex/core/Box.java b/src/org/ibex/core/Box.java index 4967252..629b263 100644 --- a/src/org/ibex/core/Box.java +++ b/src/org/ibex/core/Box.java @@ -65,8 +65,8 @@ public final class Box extends JSScope implements Task { static final int MOUSEINSIDE = 0x00000001; static final int VISIBLE = 0x00000002; static final int PACKED = 0x00000004; - static final int HSHRINK = 0x00000008; - static final int VSHRINK = 0x00000010; + public static final int HSHRINK = 0x00000008; + public static final int VSHRINK = 0x00000010; static final int BLACK = 0x00000020; // for red-black code static final int FIXED = 0x00000040; @@ -123,8 +123,8 @@ public final class Box extends JSScope implements Task { public int ay = 0; // FEATURE: roll these into x/y; requires lots of changes; perhaps y()? public int width = 0; public int height = 0; - private int contentwidth = 0; // == max(minwidth, textwidth, sum(child.contentwidth)) - private int contentheight = 0; + public int contentwidth = 0; // == max(minwidth, textwidth, sum(child.contentwidth)) + public int contentheight = 0; private Path path = null; /* @@ -170,8 +170,14 @@ public final class Box extends JSScope implements Task { // Reflow //////////////////////////////////////////////////////////////////////////////////////// /** should only be invoked on the root box */ - public void reflow() { pack(); resize(x, y, maxwidth, maxheight); place(); } - + public void reflow() { + pack(); + resize(x, y, + test(HSHRINK) ? contentwidth : maxwidth, + test(VSHRINK) ? contentheight : maxheight); + place(); + } + private static Box[] frontier = new Box[65535]; /** pack the boxes into rows and columns, compute contentwidth */ public void pack() { @@ -819,7 +825,7 @@ public final class Box extends JSScope implements Task { void set(int mask) { flags |= mask; } void set(int mask, boolean setclear) { if (setclear) set(mask); else clear(mask); } void clear(int mask) { flags &= ~mask; } - boolean test(int mask) { return ((flags & mask) == mask); } + public boolean test(int mask) { return ((flags & mask) == mask); } // Tree Handling ////////////////////////////////////////////////////////////////////// diff --git a/src/org/ibex/graphics/Surface.java b/src/org/ibex/graphics/Surface.java index e6c5c4e..31ac36e 100644 --- a/src/org/ibex/graphics/Surface.java +++ b/src/org/ibex/graphics/Surface.java @@ -225,8 +225,19 @@ public abstract class Surface extends PixelBuffer implements Task { public Surface(Box root) { this.root = root; - root.setWidth(root.minwidth, Math.min(Platform.getScreenWidth(), root.maxwidth)); - root.setHeight(root.minheight, Math.min(Platform.getScreenHeight(), root.maxheight)); + // FIXME: document this in the reference + if (!root.test(root.HSHRINK) && root.maxwidth == Integer.MAX_VALUE) + root.maxwidth = Platform.getScreenWidth() / 2; + if (!root.test(root.VSHRINK) && root.maxheight == Integer.MAX_VALUE) + root.maxheight = Platform.getScreenHeight() / 2; + root.setWidth(root.minwidth, + root.test(root.HSHRINK) + ? Math.max(root.minwidth, root.contentwidth) + : Math.min(Platform.getScreenWidth(), root.maxwidth)); + root.setHeight(root.minheight, + root.test(root.VSHRINK) + ? Math.max(root.minheight, root.contentheight) + : Math.min(Platform.getScreenHeight(), root.maxheight)); Surface old = fromBox(root); if (old != null) old.dispose(false); else root.removeSelf(); @@ -247,13 +258,15 @@ public abstract class Surface extends PixelBuffer implements Task { root.setHeight(root.minheight, pendingHeight); syncRootBoxToSurface = false; } - if (root.maxwidth != root.width || root.maxheight != root.height) { + int rootwidth = root.test(root.HSHRINK) ? root.contentwidth : root.maxwidth; + int rootheight = root.test(root.VSHRINK) ? root.contentheight : root.maxheight; + if (rootwidth != root.width || rootheight != root.height) { // dirty the place where the scar used to be and where it is now dirty(0, root.height - scarImage.height, scarImage.width, scarImage.height); - dirty(0, root.maxheight - scarImage.height, scarImage.width, scarImage.height); + dirty(0, rootheight - scarImage.height, scarImage.width, scarImage.height); } root.reflow(); - setSize(root.width, root.height); + setSize(rootwidth, rootheight); /*String oldcursor = cursor; cursor = "default"; root.putAndTriggerTrapsAndCatchExceptions("_Move", JS.T);