Revision: 4068 http://vexi.svn.sourceforge.net/vexi/?rev=4068&view=rev Author: clrg Date: 2011-03-24 03:36:53 +0000 (Thu, 24 Mar 2011)
Log Message: ----------- Minor encapsulation/consistency fixes 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-24 03:35:30 UTC (rev 4067) +++ trunk/org.vexi-core.main/src/main/java/org/vexi/core/Surface.java 2011-03-24 03:36:53 UTC (rev 4068) @@ -97,18 +97,21 @@ 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 + private int x; ///< x position of surface + private int y; ///< y position of surface + private int mousex; ///< x position of the mouse + private int mousey; ///< y position of the mouse + private int newmousex = -1; ///< x position of the mouse, in real time; this lets us collapse Move's + private 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 + + protected int getMouseX() { return x; } + protected int getMouseY() { return y; } final private DirtyList dirtyRegions = new DirtyList(); ///< Dirty regions on the surface @@ -123,31 +126,31 @@ // 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 + private int last_press_x = Integer.MAX_VALUE; ///< the x-position of the mouse the last time a Press message was enqueued + private int last_press_y = Integer.MAX_VALUE; ///< the y-position of the mouse the last time a Press message was enqueued + private int lastClickButton = 0; ///< the last button to receive a Click message; used for simulating DoubleClick's + private 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 Platform 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 - 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); + public 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. + public abstract void _requestFocus(); ///< attempts to assign focus to a surface + public abstract boolean _isLockingKeyOn(int k); ///< detect current state of a lock key (on==true) + public abstract void _setMaximized(boolean b); ///< if <tt>b</tt>, maximize the surface; otherwise, un-maximize it. + public abstract void _setMinimized(boolean b); ///< if <tt>b</tt>, minimize the surface; otherwise, un-minimize it. + public abstract void _setLocation(int x, int y); ///< set the surface's x/y position to that of the root box + public 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 icon, if applicable + public abstract void _dispose(); ///< destroy the surface + public abstract void _setMaximumSize(int maxw, int maxh);///< set the maximum dimensions of the Surface root box + public abstract void _setMinimumSize(int minw, int minh);///< set the minimum dimensions of the Surface root box + public abstract void _setResizable(boolean resizable); // Surface method implementation ////////////////////////////////////////////////////////// @@ -553,7 +556,7 @@ if (x!=this.x || y!=this.y) { this.x = x; this.y = y; - _setLocation(); + _setLocation(x, y); } } @@ -755,9 +758,10 @@ abort = false; return null; } + // for later comparison + final String oldcursor = cursor; // make sure the root is properly sized abortcount = 0; - final String oldcursor = cursor; do { abort = false; abortcount ++; @@ -898,7 +902,16 @@ backbuffer.fillTriangle(x1, y1, x2, y2, x3, y3, color); } - /** This is how subclasses signal a 'shallow dirty', indicating that although the backbuffer is valid, the screen is not */ + /** Signal that an area of the Surface box tree has changed and + * the backbuffer needs to be updated + */ + public final void redraw(int x, int y, int w, int h) { + blit(x, y, w, h); + } + + /** This is how subclasses signal a 'shallow dirty', indicating that + * although the backbuffer is valid, the screen is not + */ public final void refreshFromBackbuffer(int x, int y, int w, int h) { blit(x, y, w, h); } 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-24 03:35:30 UTC (rev 4067) +++ trunk/org.vexi-core.main/src/main/java/org/vexi/plat/AWT.java 2011-03-24 03:36:53 UTC (rev 4068) @@ -84,7 +84,7 @@ 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 _setLocation(int x, int y) { 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) { @@ -118,10 +118,10 @@ discoverInsets(); window.setSize(width + (leftInset + rightInset), height + (topInset + bottomInset)); } - protected void _setMinimized(boolean b) { + public void _setMinimized(boolean b) { Log.warn(this, "JDK 1.1 platforms cannot minimize or unminimize windows"); } - protected void _setMaximized(boolean b) { + public void _setMaximized(boolean b) { if (!b) { Log.warn(this, "JDK 1.1 platforms cannot unmaximize windows"); return; @@ -247,7 +247,7 @@ // circumstances i.e. fairly complex applications. The backbuffer is valid, // it is actually correctly (briefly) painted to the window before the // _previous_ state of the backbuffer is then painted back over it (!!) - // because asynchronize blits seem to occur first-in last-out - that is, + // because asynchronous blits seem to occur first-in last-out - that is, // blit from render is called after a refresh, but refresh happens last. private boolean blithack = true; @@ -489,7 +489,7 @@ // FIXME: take into account WHEEL_BLOCK_SCROLL / WHEEL_UNIT_SCROLL VScroll(notches); } - protected boolean _isLockingKeyOn(int key) { + public boolean _isLockingKeyOn(int key) { // AWT's support for getLockingKeyState is minimal at best and // more often than not throws an UnsupportedOperationException int eventkeyid = -1; 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-24 03:35:30 UTC (rev 4067) +++ trunk/org.vexi-core.main/src/main/java/org/vexi/plat/AWTBase.java 2011-03-24 03:36:53 UTC (rev 4068) @@ -414,7 +414,7 @@ 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 _setLocation(int x, int y) { 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) { @@ -448,10 +448,10 @@ discoverInsets(); window.setSize(width + (leftInset + rightInset), height + (topInset + bottomInset)); } - protected void _setMinimized(boolean b) { + public void _setMinimized(boolean b) { Log.warn(this, "JDK 1.1 platforms cannot minimize or unminimize windows"); } - protected void _setMaximized(boolean b) { + public void _setMaximized(boolean b) { if (!b) { Log.warn(this, "JDK 1.1 platforms cannot unmaximize windows"); return; @@ -812,7 +812,7 @@ // FIXME: take into account WHEEL_BLOCK_SCROLL / WHEEL_UNIT_SCROLL VScroll(notches); } - protected boolean _isLockingKeyOn(int key) { + public boolean _isLockingKeyOn(int key) { // AWT's support for getLockingKeyState is minimal at best and // more often than not throws an UnsupportedOperationException int eventkeyid = -1; 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-24 03:35:30 UTC (rev 4067) +++ trunk/org.vexi-core.main/src/main/java/org/vexi/plat/Java2.java 2011-03-24 03:36:53 UTC (rev 4068) @@ -129,7 +129,7 @@ public Java2Surface(Box root, boolean framed) { super(root, framed); } - protected void _setMinimized(boolean b) { + public void _setMinimized(boolean b) { if (frame == null) { Log.info(this, "JDK 1.2 can only minimize frames, not windows"); } else if (b) { @@ -167,14 +167,14 @@ public void _makeVisible(boolean b) { window.setVisible(b); } - protected void _setMaximized(boolean m) { + public void _setMaximized(boolean m) { if (frame == null) { Log.warn(this, "JDK 1.4 can only maximize frames, not windows"); return; } frame.setExtendedState(m ? Frame.MAXIMIZED_BOTH : (minimized ? Frame.ICONIFIED : Frame.NORMAL)); } - protected void _setMinimized(boolean m) { + public void _setMinimized(boolean m) { if (frame == null) { Log.warn(this, "JDK 1.4 can only minimize frames, not windows"); return; 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-24 03:35:30 UTC (rev 4067) +++ trunk/org.vexi-core.main/src/main/java/org/vexi/plat/Swing.java 2011-03-24 03:36:53 UTC (rev 4068) @@ -150,7 +150,7 @@ 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 _setLocation(int x, int y) { 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) { @@ -184,7 +184,7 @@ discoverInsets(); window.setSize(width + (leftInset + rightInset), height + (topInset + bottomInset)); } - protected void _setMinimized(boolean b) { + public void _setMinimized(boolean b) { if (frame!=null) { // Swing is not thread safe; changes must be made in the EDT // @see InnerFrame.paint() @@ -193,7 +193,7 @@ Log.warn(this, "JDK 1.1 platforms cannot minimize or unminimize windows"); } } - protected void _setMaximized(boolean b) { + public void _setMaximized(boolean b) { if (frame!=null) { // Swing is not thread safe; changes must be made in the EDT // @see InnerFrame.paint() 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-24 03:35:30 UTC (rev 4067) +++ trunk/org.vexi-core.main/src/main/jpp/org/vexi/core/Box.jpp 2011-03-24 03:36:53 UTC (rev 4068) @@ -1487,8 +1487,8 @@ protected final void tryPropagateEvent(JS event, JS _event, JS value, boolean forceOnRoot) throws JSExn { Surface s = getSurface(); if (s != null) { - int s_mx = s.mousex; - int s_my = s.mousey; + final int s_mx = s.getMouseX(); + final int s_my = s.getMouseY(); if (_event==null) { _event = JSU.S('_'+JSU.toString(event)); } @@ -1587,10 +1587,10 @@ * @group(y) */ case "x": Surface s = getSurface(); - return JSU.N(globalToLocalX(Box.this, s==null?0:getSurface().mousex)); + return JSU.N(globalToLocalX(Box.this, s==null ? 0 : getSurface().getMouseX())); case "y": Surface s = getSurface(); - return JSU.N(globalToLocalY(Box.this, s==null?0:getSurface().mousey)); + return JSU.N(globalToLocalY(Box.this, s==null ? 0 : getSurface().getMouseY())); //#end return super.get(key); } @@ -2561,7 +2561,7 @@ Surface s = getSurface(); if (s!=null) { String oldcursor = s.cursor; - tryPropagateMove(s.mousex, s.mousey); + tryPropagateMove(s.getMouseX(), s.getMouseY()); if (!s.cursor.equals(oldcursor)) { 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