Box nextPackedSibling() { Box b = nextSibling(); return b == null || (b.test(PACKED | VISIBLE)) ? b : b.nextPackedSibling(); }
Box firstPackedChild() { Box b = getChild(0); return b == null || (b.test(PACKED | VISIBLE)) ? b : b.nextPackedSibling(); }
- /** only for use on the root box */
- void reflow(int new_width, int new_height) {
- repack();
- /*
- new_width = bound(max(contentwidth, minwidth), new_width, test(HSHRINK) ? max(contentwidth, minwidth) : maxwidth);
- new_height = bound(max(contentheight, minheight), new_height, test(VSHRINK) ? max(contentheight, minheight) : maxheight);
- */
- resize(x, y, new_width, new_height);
- resize_children();
- }
-
/** pack the boxes into rows and columns; also computes contentwidth */
void repack() {
for(Box child = getChild(0); child != null; child = child.nextSibling()) child.repack();
//#end
}
- private void resize(LENGTH x, LENGTH y, LENGTH width, LENGTH height) {
+ void resize(LENGTH x, LENGTH y, LENGTH width, LENGTH height) {
// FEATURE reimplement, but we're destroying this
// FIXME: uncommenting this breaks; see http://bugs.xwt.org/show_bug.cgi?id=345
//if (x != this.x || y != this.y || width != this.width || height != this.height) {
//}
}
- private void resize_children() {
+ void resize_children() {
//#repeat col/row colspan/rowspan contentwidth/contentheight x/y width/height colMaxWidth/rowMaxHeight colWidth/rowHeight \
// HSHRINK/VSHRINK maxwidth/maxheight cols/rows minwidth/minheight colWidth/rowHeight x_slack/y_slack
throw new Error("unreachable"); // unreachable
}
+ void setMaxWidth(Object value) { do { CHECKSET_INT(maxwidth); MARK_RESIZE; } while(false); }
+ void setMaxHeight(Object value) { do { CHECKSET_INT(maxheight); MARK_RESIZE; } while(false); }
+
public void put(Object name, Object value) throws JSExn {
if (name instanceof Number) { put(toInt(name), value); return; }
//#switch(name)
case "shrink": put("hshrink", value); put("vshrink", value);
case "hshrink": CHECKSET_FLAG(HSHRINK); MARK_RESIZE;
case "vshrink": CHECKSET_FLAG(VSHRINK); MARK_RESIZE;
- case "width": if (parent==null&&Surface.fromBox(this)!=null) { Surface.fromBox(this).setWidth(toInt(value)); } else { put("maxwidth", value); put("minwidth", value); MARK_RESIZE; }
- case "height": if (parent == null&&Surface.fromBox(this)!=null) { Surface.fromBox(this).setHeight(toInt(value)); } else { put("maxheight", value); put("minheight", value); MARK_RESIZE; }
- case "maxwidth": CHECKSET_INT(maxwidth); 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": CHECKSET_INT(maxheight); 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;
public static boolean shift = false; ///< true iff the shift button is pressed down, in real time
public static boolean button1 = false; ///< true iff button 1 is depressed, in Scheduler-time
public static boolean button2 = false; ///< true iff button 2 is depressed, in Scheduler-time
- public static boolean button3 = false; ///< true iff button 3 is depressed, in Scheduler-time
+ public static boolean button3 = false; ///< true iff button 3 is depressed, in Scheduler-tiem
public boolean minimized = false; ///< True iff this surface is minimized, in real time
public boolean maximized = false; ///< True iff this surface is maximized, in real time
private DirtyList dirtyRegions = new DirtyList(); ///< Dirty regions on the *screen*
- private int width = 0; ///< The actual width of the surface
- private int height = 0; ///< The actual height of the surface
- public int getWidth() { return width; }
- public int getHeight() { return height; }
-
// Used For Simulating Clicks and DoubleClicks /////////////////////////////////////////////////
public abstract void setTitleBarText(String s); ///< Sets the surface's title bar text, if applicable
public abstract void setIcon(Picture i); ///< Sets the surface's title bar text, if applicable
public abstract void _dispose(); ///< Destroy the surface
-
-
- // Sizing /////////////////////////////////////////////////////////////////////////////////
-
- public void setLimits(int min_width, int min_height, int max_width, int max_height) { }
-
- public final void setWidth(int width) { setSize(width, this.height); }
- public final void setHeight(int height) { setSize(this.width, height); }
- public final void setSize(int width, int height) {
- if (this.width == width && this.height == height) return;
- this.width = Math.max(Main.scarImage.width, width);
- this.height = Math.max(Main.scarImage.height, height);
- _setSize(width, height);
- }
+ public void setLimits(int min_width, int min_height, int max_width, int max_height) { /* FIXME */ }
// Helper methods for subclasses ////////////////////////////////////////////////////////////
// FEATURE: can we avoid creating objects here?
protected final void SizeChange(final int width, final int height) {
- Scheduler.add(new Scheduler.Task() { public void perform() {
+ Scheduler.addAtFront(new Scheduler.Task() { public void perform() {
+ // dirty the place where the scar used to be
+ root.dirty(0, root.maxheight - Main.scarImage.height, Main.scarImage.width, Main.scarImage.height);
+ root.setMaxWidth(JS.N(width));
+ root.setMaxHeight(JS.N(height));
root.set(root.REFLOW);
- Surface.this.width = width;
- Surface.this.height = height;
}});
abort = true;
}
public Surface(Box root) {
this.root = root;
+ root.setMaxWidth(JS.N(Math.min(Platform.getScreenWidth(), root.maxwidth)));
+ root.setMaxHeight(JS.N(Math.min(Platform.getScreenHeight(), root.maxheight)));
Surface old = fromBox(root);
if (old != null) old.dispose(false);
else root.removeSelf();
/** runs the prerender() and render() pipelines in the root Box to regenerate the backbuffer, then blits it to the screen */
public synchronized void render() {
- // dirty the place where the scar used to be
- if (root.width != width || root.height != height)
+ // dirty the place where the scar used to be in case the root window size was programmatically changed
+ if (root.maxwidth != root.width || root.maxheight != root.height)
root.dirty(0, root.height - Main.scarImage.height, Main.scarImage.width, Main.scarImage.height);
// make sure the root is properly sized
do {
abort = false;
- root.reflow(width, height);
- setSize(width, height);
+ root.repack();
+ root.resize(root.x, root.y, root.maxwidth, root.maxheight);
+ root.resize_children();
+ _setSize(root.width, root.height);
String oldcursor = cursor;
cursor = "default";
root.Move(mousex, mousey, mousex, mousey);