Revision: 4065 http://vexi.svn.sourceforge.net/vexi/?rev=4065&view=rev Author: clrg Date: 2011-03-23 13:52:15 +0000 (Wed, 23 Mar 2011)
Log Message: ----------- Implementation consistency and fix missing cursor update post-reflow - all platform-specified functions start with _ - do not call Surface._* functions outside of Surface - TODO: clearer naming required to indicate method intent (e.g. platform*, core*, internal*) Modified Paths: -------------- trunk/org.vexi-core.main/src/main/java/org/vexi/core/Surface.java trunk/org.vexi-core.main/src/main/java/org/vexi/plat/AWT.java trunk/org.vexi-core.main/src/main/java/org/vexi/plat/AWTBase.java trunk/org.vexi-core.main/src/main/java/org/vexi/plat/Java2.java trunk/org.vexi-core.main/src/main/java/org/vexi/plat/Swing.java trunk/org.vexi-core.main/src/main/jpp/org/vexi/core/Box.jpp Modified: trunk/org.vexi-core.main/src/main/java/org/vexi/core/Surface.java =================================================================== --- trunk/org.vexi-core.main/src/main/java/org/vexi/core/Surface.java 2011-03-23 12:48:48 UTC (rev 4064) +++ trunk/org.vexi-core.main/src/main/java/org/vexi/core/Surface.java 2011-03-23 13:52:15 UTC (rev 4065) @@ -78,13 +78,13 @@ public volatile int pendingHeight = 0; // NOTE: it is up to the platform implementation to set these keys - public static boolean alt = false; ///< true iff the alt button is pressed down - public static boolean control = false; ///< true iff the control button is pressed down - public static boolean shift = false; ///< true iff the shift button is pressed down + public static boolean alt = false; ///< true iff the alt button is pressed down + public static boolean control = false; ///< true iff the control button is pressed down + public static boolean shift = false; ///< true iff the shift button is pressed down - public static boolean button1 = false; ///< true iff button 1 is depressed - public static boolean button2 = false; ///< true iff button 2 is depressed - public static boolean button3 = false; ///< true iff button 3 is depressed + public static boolean button1 = false; ///< true iff button 1 is depressed + public static boolean button2 = false; ///< true iff button 2 is depressed + public static boolean button3 = false; ///< true iff button 3 is depressed final public static int CAPS_LOCK = 1; final public static int KANA_LOCK = 2; @@ -92,25 +92,25 @@ final public static int SCROLL_LOCK = 4; - // Instance Data /////////////////////////////////////////////////////////////////////// + // Instance Data //////////////////////////////////////////////////////////////////////// - public Box root; ///< the Box at the root of this surface - public String cursor = "default"; ///< the active cursor to switch to when syncCursor() is called - public boolean cursorset = false; ///< used to prevent overlapped boxes overwriting the cursor - public int x; ///< x position of surface - public int y; ///< y position of surface - public int mousex; ///< x position of the mouse - public int mousey; ///< y position of the mouse - public int newmousex = -1; ///< x position of the mouse, in real time; this lets us collapse Move's - public int newmousey = -1; ///< y position of the mouse, in real time; this lets us collapse Move's - 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 - protected Picture icon; - private boolean visible = false; - private boolean resizable = false; - private boolean mouseUpdateRequired = false; ///< reflow requests refresh of cursor + public Box root; ///< the Box at the root of this surface + protected String cursor = "default"; ///< the active cursor to switch to when _updateMouseCursor() is called + protected boolean cursorset = false; ///< used to prevent overlapping boxes overwriting the cursor + public int x; ///< x position of surface + public int y; ///< y position of surface + public int mousex; ///< x position of the mouse + public int mousey; ///< y position of the mouse + public int newmousex = -1; ///< x position of the mouse, in real time; this lets us collapse Move's + public int newmousey = -1; ///< y position of the mouse, in real time; this lets us collapse Move's + 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 + protected Picture icon; ///< user specified icon for the surface + private boolean visible = false; ///< visible state of the surface + private boolean resizable = false; ///< whether a user may resize this surface + private boolean mouseUpdateRequired = false; ///< reflow requests refresh of cursor - final private DirtyList dirtyRegions = new DirtyList(); ///< Dirty regions on the surface + final private DirtyList dirtyRegions = new DirtyList(); ///< Dirty regions on the surface public int topInset = 0; public int leftInset = 0; @@ -121,35 +121,55 @@ private boolean bottomAlign = false; private boolean rightAlign = false; - // Used For Simulating Clicks and DoubleClicks ///////////////////////////////////////////////// + // Used For Simulating Clicks and DoubleClicks //////////////////////////////////////////// - int last_press_x = Integer.MAX_VALUE; ///< the x-position of the mouse the last time a Press message was enqueued - int last_press_y = Integer.MAX_VALUE; ///< the y-position of the mouse the last time a Press message was enqueued - int lastClickButton = 0; ///< the last button to receive a Click message; used for simulating DoubleClick's - long lastClickTime = 0; ///< the last time a Click message was processed; used for simulating DoubleClick's + int last_press_x = Integer.MAX_VALUE; ///< the x-position of the mouse the last time a Press message was enqueued + int last_press_y = Integer.MAX_VALUE; ///< the y-position of the mouse the last time a Press message was enqueued + int lastClickButton = 0; ///< the last button to receive a Click message; used for simulating DoubleClick's + long lastClickTime = 0; ///< the last time a Click message was processed; used for simulating DoubleClick's - // Methods to be overridden by subclasses /////////////////////////////////////////////////////// + // Methods to be overridden by subclasses ///////////////////////////////////////////////// - public abstract PixelBuffer getPixelBuffer(); ///< returns a PixelBuffer representing this Surface - 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 makeVisible(boolean b); ///< If <tt>b</tt>, make window invisible; otherwise, make it non-invisible. - protected abstract void requestFocus(); ///< attempts to assign focus to a surface - protected abstract boolean _isLockingKeyOn(int k); ///< detect current state of a lock key (on==true) - 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 - protected abstract void _setSize(int w, int h); ///< set the actual size of the surface - 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 + public abstract PixelBuffer _getPixelBuffer(); ///< returns a PixelBuffer representing this Surface + 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 + protected abstract void _updateCursor(String cursor); ///< set the actual cursor to this.cursor if they do not match + public abstract void _makeVisible(boolean b); ///< If <tt>b</tt>, make window visible; otherwise, make it non-visible. + protected abstract void _requestFocus(); ///< attempts to assign focus to a surface + protected abstract boolean _isLockingKeyOn(int k); ///< detect current state of a lock key (on==true) + 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 + protected abstract void _setSize(int w, int h); ///< set the actual size of the surface + 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 protected abstract void _setMaximumSize(int maxx, int maxy); protected abstract void _setMinimumSize(int minx, int miny); protected abstract void _setResizable(boolean resizable); + + + // Surface method implementation ////////////////////////////////////////////////////////// + + /** Request that the Surface receives input focus */ + protected void requestFocus() { _requestFocus(); } + + /** Request to set size of the Surface to the given width 'w' and height 'h' */ protected void setSize(int w, int h) { pendingWidth = w; pendingHeight = h; _setSize(w, h); } + /** Set the titlebar text of the Surface to the given 'text' */ + protected void setTitleBarText(String text) { _setTitleBarText(text); } + + /** Move this Surface to the front of the window stack */ + protected void toBack() { _toBack(); } + + /** Drop this Surface to the back of the window stack */ + protected void toFront() { _toFront(); } + + /** Signal that an update to the mouse cursor has been made */ + protected void updateCursor() { _updateCursor(cursor); } + /** Experimental attempt to access locking key states - note that * the Java version does not work on Linux */ @@ -167,12 +187,16 @@ return false; } + // Used as the default icon for new Surfaces // FIXME: this should be a Picture protected static URL vexiIcon = Main.class.getResource("builtin/vexi-icon.png"); + + // The scar image which is rendered over an unsigned Vexi Surface + // to let users know the application is not from a trusted source protected static Picture scarImage = null; - // Event Handling Helper methods for subclasses /////////////////// + // Event Handling Helper methods for subclasses /////////////////////////////////////////// private boolean keypress_scheduled = false; protected final void KeyPressed(String key) { @@ -322,7 +346,7 @@ // root (ONLY) gets motion events outside itself (if trapped) root.tryPropagateMove(mousex, mousey); if (!cursor.equals(oldcursor)) { - syncCursor(); + updateCursor(); } return o; } @@ -424,12 +448,12 @@ public final void setIcon(JS newicon) throws JSExn { icon = newicon == null ? null : Picture.load(newicon, seticon); if (icon==null) { - setIcon(icon); + _setIcon(icon); Refresh(); } } private Callable seticon = new Callable() { - private synchronized void call() { setIcon(icon); } + private synchronized void call() { _setIcon(icon); } public Object run(Object o) { call(); Refresh(); @@ -529,7 +553,7 @@ if (x!=this.x || y!=this.y) { this.x = x; this.y = y; - setLocation(); + _setLocation(); } } @@ -579,7 +603,7 @@ } if (visible != Box.testDisplay(root)) { visible = Box.testDisplay(root); - makeVisible(visible); + _makeVisible(visible); } if (visible) { render(); @@ -684,11 +708,12 @@ // handle frame-specific box properties JS title = b.getAndTriggerTraps(SC_frametitle); if (title == null || JSU.toString(title).trim().equals("")) { - surface.setTitleBarText("Vexi Application"); + surface._setTitleBarText("Vexi Application"); } else { - surface.setTitleBarText(JSU.toString(title)); + surface._setTitleBarText(JSU.toString(title)); } + // get and assign the surface icon JS icon = b.getAndTriggerTraps(SC_frameicon); surface.setIcon(icon); @@ -732,6 +757,7 @@ } // make sure the root is properly sized abortcount = 0; + final String oldcursor = cursor; do { abort = false; abortcount ++; @@ -752,12 +778,15 @@ setMinimumSize(root.contentwidth, root.contentheight); } } while (abort); + if (!cursor.equals(oldcursor)) { + updateCursor(); + } final int numregions = dirtyRegions.num(); final int[] dirt = dirtyRegions.flush(); if (dirt==null) return null; - final PixelBuffer buf = getPixelBuffer(); + final PixelBuffer buf = _getPixelBuffer(); final int rwidth = root.width; final int rheight = root.height; final int scar_y = rheight-scarImage.height; @@ -823,7 +852,7 @@ public static abstract class DoubleBufferedSurfaceNoBlit extends Surface implements PixelBuffer { public DoubleBufferedSurfaceNoBlit(Box root) { super(root); } - public PixelBuffer getPixelBuffer() { return this; } + public PixelBuffer _getPixelBuffer() { return this; } protected PixelBuffer backbuffer = Platform.createPixelBuffer(Platform.getScreenBounds().width, Platform.getScreenBounds().height, this); /** Draw an unscaled image onto the backbuffer where: Modified: trunk/org.vexi-core.main/src/main/java/org/vexi/plat/AWT.java =================================================================== --- trunk/org.vexi-core.main/src/main/java/org/vexi/plat/AWT.java 2011-03-23 12:48:48 UTC (rev 4064) +++ trunk/org.vexi-core.main/src/main/java/org/vexi/plat/AWT.java 2011-03-23 13:52:15 UTC (rev 4065) @@ -77,17 +77,17 @@ /** some JDKs let us recycle a single Dimension object when calling getSize() */ Dimension singleSize = new Dimension(); - public void toBack() { if (window != null) window.toBack(); } - public void toFront() { + public void _toBack() { if (window != null) window.toBack(); } + public void _toFront() { // window.toFront() does not work well //if (window != null) window.toFront(); if (window != null) { window.setVisible(false); window.setVisible(true); } } - public void requestFocus() { if (window != null) window.requestFocus(); } - public void setLocation() { if (window != null) window.setLocation(x, y); } - public void setTitleBarText(String s) { if (frame != null) frame.setTitle(s); } + public void _requestFocus() { if (window != null) window.requestFocus(); } + public void _setLocation() { if (window != null) window.setLocation(x, y); } + public void _setTitleBarText(String s) { if (frame != null) frame.setTitle(s); } public void setInvisible(boolean b) { window.setVisible(!b); } - public void setIcon(final Picture i) { + public void _setIcon(final Picture i) { if (frame == null) { return; } @@ -335,7 +335,7 @@ // IMPORTANT: makeVisible must be called before render() // to ensure that our peer has been created - public void makeVisible(boolean b) { + public void _makeVisible(boolean b) { window.setVisible(b); // respect a frame's requested maximized state // NB must be called after setVisible(true) @@ -354,7 +354,7 @@ window.dispose(); } - public void syncCursor() { + public void _updateCursor(String cursor) { if (cursor.equals("crosshair")) window.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); else if (cursor.equals("east")) window.setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR)); else if (cursor.equals("move")) window.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); Modified: trunk/org.vexi-core.main/src/main/java/org/vexi/plat/AWTBase.java =================================================================== --- trunk/org.vexi-core.main/src/main/java/org/vexi/plat/AWTBase.java 2011-03-23 12:48:48 UTC (rev 4064) +++ trunk/org.vexi-core.main/src/main/java/org/vexi/plat/AWTBase.java 2011-03-23 13:52:15 UTC (rev 4065) @@ -407,17 +407,17 @@ /** some JDKs let us recycle a single Dimension object when calling getSize() */ Dimension singleSize = new Dimension(); - public void toBack() { if (window != null) window.toBack(); } - public void toFront() { + public void _toBack() { if (window != null) window.toBack(); } + public void _toFront() { // window.toFront() does not work well //if (window != null) window.toFront(); if (window != null) { window.setVisible(false); window.setVisible(true); } } - public void requestFocus() { if (window != null) window.requestFocus(); } - public void setLocation() { if (window != null) window.setLocation(x, y); } - public void setTitleBarText(String s) { if (frame != null) frame.setTitle(s); } + public void _requestFocus() { if (window != null) window.requestFocus(); } + public void _setLocation() { if (window != null) window.setLocation(x, y); } + public void _setTitleBarText(String s) { if (frame != null) frame.setTitle(s); } public void setInvisible(boolean b) { window.setVisible(!b); } - public void setIcon(final Picture i) { + public void _setIcon(final Picture i) { if (frame == null) { return; } @@ -665,7 +665,7 @@ // 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 _makeVisible(boolean b) { window.setVisible(b); } public void _dispose() { window.removeMouseListener(this); @@ -677,7 +677,7 @@ window.dispose(); } - public void syncCursor() { + public void _updateCursor(String cursor) { if (cursor.equals("crosshair")) window.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); else if (cursor.equals("east")) window.setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR)); else if (cursor.equals("move")) window.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); Modified: trunk/org.vexi-core.main/src/main/java/org/vexi/plat/Java2.java =================================================================== --- trunk/org.vexi-core.main/src/main/java/org/vexi/plat/Java2.java 2011-03-23 12:48:48 UTC (rev 4064) +++ trunk/org.vexi-core.main/src/main/java/org/vexi/plat/Java2.java 2011-03-23 13:52:15 UTC (rev 4065) @@ -139,11 +139,11 @@ } } - public void syncCursor() { + public void _updateMouseCursor() { if (cursor.equals("invisible")) { window.setCursor(invisibleCursor); } else { - super.syncCursor(); + super._updateCursor("default"); } } } @@ -165,7 +165,7 @@ window.addMouseWheelListener(this); } - protected void makeVisible() { } + public void _makeVisible(boolean b) { window.setVisible(b); } protected void _setMaximized(boolean m) { if (frame == null) { Modified: trunk/org.vexi-core.main/src/main/java/org/vexi/plat/Swing.java =================================================================== --- trunk/org.vexi-core.main/src/main/java/org/vexi/plat/Swing.java 2011-03-23 12:48:48 UTC (rev 4064) +++ trunk/org.vexi-core.main/src/main/java/org/vexi/plat/Swing.java 2011-03-23 13:52:15 UTC (rev 4065) @@ -143,17 +143,17 @@ /** some JDKs let us recycle a single Dimension object when calling getSize() */ Dimension singleSize = new Dimension(); - public void toBack() { if (window != null) window.toBack(); } - public void toFront() { + public void _toBack() { if (window != null) window.toBack(); } + public void _toFront() { // window.toFront() does not work well //if (window != null) window.toFront(); if (window != null) { window.setVisible(false); window.setVisible(true); } } - public void requestFocus() { if (window != null) window.requestFocus(); } - public void setLocation() { if (window != null) window.setLocation(x, y); } - public void setTitleBarText(String s) { if (frame != null) frame.setTitle(s); } + public void _requestFocus() { if (window != null) window.requestFocus(); } + public void _setLocation() { if (window != null) window.setLocation(x, y); } + public void _setTitleBarText(String s) { if (frame != null) frame.setTitle(s); } public void setInvisible(boolean b) { window.setVisible(!b); } - public void setIcon(final Picture i) { + public void _setIcon(final Picture i) { if (frame == null) { return; } @@ -544,7 +544,7 @@ // IMPORTANT: makeVisible must be called before render() // to ensure that our peer has been created - public void makeVisible(boolean b) { + public void _makeVisible(boolean b) { window.setVisible(b); } @@ -559,7 +559,7 @@ window.dispose(); } - public void syncCursor() { + public void _updateCursor(String cursor) { if (cursor.equals("crosshair")) window.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); else if (cursor.equals("east")) window.setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR)); else if (cursor.equals("move")) window.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); Modified: trunk/org.vexi-core.main/src/main/jpp/org/vexi/core/Box.jpp =================================================================== --- trunk/org.vexi-core.main/src/main/jpp/org/vexi/core/Box.jpp 2011-03-23 12:48:48 UTC (rev 4064) +++ trunk/org.vexi-core.main/src/main/jpp/org/vexi/core/Box.jpp 2011-03-23 13:52:15 UTC (rev 4065) @@ -2563,7 +2563,7 @@ String oldcursor = s.cursor; tryPropagateMove(s.mousex, s.mousey); if (!s.cursor.equals(oldcursor)) { - s.syncCursor(); + s.updateCursor(); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn