Revision: 3226 http://vexi.svn.sourceforge.net/vexi/?rev=3226&view=rev Author: clrg Date: 2008-11-19 14:58:18 +0000 (Wed, 19 Nov 2008)
Log Message: ----------- Tidy up icon handling, add root.display awareness for Surfaces Modified Paths: -------------- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp trunk/core/org.vexi.core/src/org/vexi/core/Surface.java trunk/core/org.vexi.core/src/org/vexi/core/builtin/vexi-icon.png trunk/core/org.vexi.core/src/org/vexi/plat/AWT.java Modified: trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp 2008-11-19 14:49:25 UTC (rev 3225) +++ trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp 2008-11-19 14:58:18 UTC (rev 3226) @@ -1559,10 +1559,15 @@ /** recursively attempt to fetch a surface object */ static private final JS getSurfaceObject(Box b) throws JSExn { - if (b == null) return null; - if (b.test(SURFACE_READ_TRAP)) return b.getAndTriggerTraps(SC_surface); - return getSurfaceObject(b.parent); + do { + if (b == null) return null; + if (b.test(SURFACE_READ_TRAP)) return b.getAndTriggerTraps(SC_surface); + b = b.parent; + } while(true); } + + /** for Surface to check it a root box is visible */ + static final boolean testDisplay(Box b) { return b.test(DISPLAY); } /** establish visible, invoking read traps if required */ private final boolean isVisible() throws JSExn { Modified: trunk/core/org.vexi.core/src/org/vexi/core/Surface.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Surface.java 2008-11-19 14:49:25 UTC (rev 3225) +++ trunk/core/org.vexi.core/src/org/vexi/core/Surface.java 2008-11-19 14:58:18 UTC (rev 3226) @@ -4,6 +4,8 @@ package org.vexi.core; +import java.net.URL; + import org.ibex.js.Interpreter; import org.ibex.js.JS; import org.ibex.js.JSExn; @@ -63,7 +65,7 @@ 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 DirtyList dirtyRegions = new DirtyList(); ///< Dirty regions on the surface - private Picture icon; + protected Picture icon; public int topInset = 0; public int leftInset = 0; @@ -84,7 +86,7 @@ public abstract void toBack(); ///< should push surface to the back of the stacking order public abstract void toFront(); ///< should pull surface to the front of the stacking order public abstract void syncCursor(); ///< set the actual cursor to this.cursor if they do not match - //public abstract void setInvisible(boolean b); ///< If <tt>b</tt>, make window invisible; otherwise, make it non-invisible. + public abstract void makeVisible(boolean b); ///< If <tt>b</tt>, make window invisible; otherwise, make it non-invisible. protected abstract void _setMaximized(boolean b); ///< If <tt>b</tt>, maximize the surface; otherwise, un-maximize it. protected abstract void _setMinimized(boolean b); ///< If <tt>b</tt>, minimize the surface; otherwise, un-minimize it. public abstract void setLocation(); ///< Set the surface's x/y position to that of the root box @@ -96,8 +98,10 @@ protected abstract void _setMinimumSize(int minx, int miny); protected abstract void _setResizable(boolean resizable); protected void setSize(int w, int h) { _setSize(w, h); } - + public static Picture scarImage = null; + // FIXME: this should be a Picture + public final static URL vexiIcon = Main.class.getResource("builtin/vexi-icon.png"); // Event Handling Helper methods for subclasses /////////////////// @@ -248,11 +252,17 @@ // FIXME: handle exceptions etc - better checking of types? /** prepare an image for setting it as the icon of this surface */ - protected final void queueSetIcon(JS icon) throws JSExn { this.icon = Picture.load(icon, seticon); } + protected final void queueSetIcon(JS newicon) throws JSExn { + icon = newicon == null ? null : Picture.load(newicon, seticon); + if (icon==null) { + setIcon(icon); + Refresh(); + } + } private Callable seticon = new Callable() { public Object run(Object o) { - Log.warn(this, "setting icon"); setIcon(icon); + Refresh(); return o; } }; @@ -336,7 +346,10 @@ /** only run if scheduled */ public Object run(Object o) { - render(); + // TODO: document this in the reference + boolean b = Box.testDisplay(root); + makeVisible(b); + if (b) render(); return null; } @@ -381,18 +394,18 @@ pendingWidth = fw != null ? JSU.toInt(fw) : Platform.getScreenWidth() / 2; JS fh = root.getAndTriggerTraps(SC_frameheight); pendingHeight = fh != null ? JSU.toInt(fh) : Platform.getScreenHeight() / 2; + // queueSetIcon invokes Refresh JS icon = root.getAndTriggerTraps(SC_icon); - if (icon != null) queueSetIcon(icon); + queueSetIcon(icon); JS titlebar = root.getAndTriggerTraps(SC_titlebar); if (titlebar != null) setTitleBarText(JSU.toString(titlebar)); + setPosition(); + setResizable(root.isRootResizable()); } catch (JSExn jse) { - // FIXME: handle exceptions properly - Log.uWarn(this, "Caught JSExn from setParent() in Surface constructor - this should not happen"); + // FIXME: handle exceptions from icon/titlebar traps properly + Log.uWarn(this, "Caught JSExn during Surface construction"); Log.uInfo(this, jse); } - setPosition(); - setResizable(root.isRootResizable()); - Refresh(); } // unused - private static Affine identity = Affine.identity(); Modified: trunk/core/org.vexi.core/src/org/vexi/core/builtin/vexi-icon.png =================================================================== (Binary files differ) Modified: trunk/core/org.vexi.core/src/org/vexi/plat/AWT.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/plat/AWT.java 2008-11-19 14:49:25 UTC (rev 3225) +++ trunk/core/org.vexi.core/src/org/vexi/plat/AWT.java 2008-11-19 14:58:18 UTC (rev 3226) @@ -355,11 +355,11 @@ public void setInvisible(boolean b) { window.setVisible(!b); } public void setIcon(Picture i) { if (frame == null) return; - //frame.setIconImage(image); - // BROKEN - setting the icon - // ... problem setting icon causes java to hang if from AWTPicture's image - // ImageIcon(..).getImage() seems to work however. - // frame.setIconImage(((AWTPicture)i).i); + if (i==null) { + frame.setIconImage(new ImageIcon(Surface.vexiIcon).getImage()); + } else { + frame.setIconImage(new ImageIcon(((AWTPicture)i).i).getImage()); + } } public void _setSize(int width, int height) { discoverInsets(); @@ -505,11 +505,6 @@ Log.error(this, "Exception thrown in AWTSurface$InnerFrame() -- this should never happen"); Log.error(this, e); } - - // set the default icon image to the vexi logo - if (frame != null) - frame.setIconImage(new ImageIcon(Main.class.getResource("builtin/vexi-icon.png")).getImage()); - // Theoretically pack causes the insets to be calculated. // @@ -518,7 +513,11 @@ // that only a guess is returned. window.pack(); setLocation(); - setSize(pendingWidth, pendingHeight); // setSize handles the insets + // setSize handles the insets + setSize(pendingWidth, pendingHeight); + // frame is null during Surface constructor + // forcing us to reinvoke setIcon here + setIcon(icon); // initialise the backbuffer and window with the root colour // REMARK - this is for nicer initial rendering @@ -539,22 +538,16 @@ } catch (UnsupportedOperationException e) { Log.warn(this, "setCompositionEnabled() failed. Are you running OS X?"); } - //window.add - - // IMPORTANT: this must be called before render() to ensure - // that our peer has been created - makeVisible(); } - protected void makeVisible() { window.setVisible(true); } + // IMPORTANT: makeVisible must be called before render() + // to ensure that our peer has been created + public void makeVisible(boolean b) { window.setVisible(b); } public void _dispose() { window.removeMouseListener(this); window.removeMouseWheelListener(this); - - // removed to work around a jdk1.3 bug - /* window.removeKeyListener(this); */ - + window.removeKeyListener(this); // previously removed to work around a jdk1.3 bug window.removeComponentListener(this); window.removeMouseMotionListener(this); window.removeWindowListener(this); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn