[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gzz] fourth PEG cursors--humppake: Changing mouse cursor
From: |
Tuomas Lukka |
Subject: |
Re: [Gzz] fourth PEG cursors--humppake: Changing mouse cursor |
Date: |
Mon, 12 May 2003 16:15:02 +0300 |
User-agent: |
Mutt/1.4.1i |
This is very close to being accepted now.
On Mon, May 12, 2003 at 03:19:21PM +0300, Asko Soukka wrote:
> - How the mouse cursor should be changed?
>
> RESOLVED: Calling
> ``org.nongnu.libvob.GraphicsAPI.Window.setCursor()``
> with ID of wanted cursor as a parameter. Of course setCursor()
> method
> should be implemented separately for both AWT and GL.
>
> RE-RESOLVED: Calling
> ``org.nongnu.libvob.GraphicsAPI.Window.setCursor()``
> with java.awt.Cursor as parameter.
>
> RE-RESOLVED: Calling
> ``org.nongnu.libvob.GraphicsAPI.Window.setCursor()``
> with proper cursor name string as parameter.
>
> AWTAPI will also have setCursor() overloaded with java.awt.Cursor
> as parameter..
Resolutions should ALWAYS contain reasons for *why* it was decided
to do a certain way. This is ESPECIALLY important if you re-resolve
the issue.
> - How is changing the mouse cursor implemented?
>
> RESOLVED: Java AWT client uses ``java.awt.Cursor``, which can
> be passed to any ``java.awt.Component`` - like ScreenCanvas in
> AWTScreen. GL client needs a platform specific implementation.
> Currently we are supporting X implementation. In X Windows,
> mouse cursor could be changed via Xlib.
Is this really an issue? Did someone have a problem with this?
> - How cursor name string is mapped to Xlib mouse cursor values?
>
> RE-RESOLVED: Cursor name string is passed on in
> ``org.nongnu.libvob.impl.gl.GLScreen`` and
> low level implementation like using Xlib is determined later
> on. Most probably in /src/os/Os-GLX.
Again, why?
> Changes
> =======
>
> Interfaces
> ----------
>
> Into ``org.nongnu.libvob.GraphicsAPI.Window``::
>
> /** Set the mouse cursor for the window.
> * Available cursor types (case insensitive):
> * "CROSSHAIR_CURSOR" The crosshair cursor type.
> * "DEFAULT_CURSOR" The default cursor type (gets set if no cursor is
> defined).
> * "E_RESIZE_CURSOR" The east-resize cursor type.
> * "HAND_CURSOR" The hand cursor type.
> * "MOVE_CURSOR" The move cursor type.
> * "N_RESIZE_CURSOR" The north-resize cursor type.
> * "NE_RESIZE_CURSOR" The north-east-resize cursor type.
> * "NW_RESIZE_CURSOR" The north-west-resize cursor type.
> * "S_RESIZE_CURSOR" The south-resize cursor type.
> * "SE_RESIZE_CURSOR" The south-east-resize cursor type.
> * "SW_RESIZE_CURSOR" The south-west-resize cursor type.
> * "TEXT_CURSOR" The text cursor type.
> * "W_RESIZE_CURSOR" The west-resize cursor type.
> * "WAIT_CURSOR" The wait cursor type.
> */
ISSUE: Do we *really* want all arguments to this method have the _CURSOR
suffix?
> public void setCursor(String shape);
>
> Into ``org.nongnu.libvob.impl.awt.AWTScreen``::
>
> /** Set the mouse cursor for the window.
> */
Javadoc needs more - "to an AWT Cursor object".
> public void setCursor(Cursor cursor) {
> canvas.setCursor(cursor);
> }
>
>
>
> Implementation
> --------------
>
> Java
> """"
>
> Into ``org.nongnu.libvob.impl.awt.AWTScreen``::
>
> public void setCursor(String cursorName) {
> Cursor cursor = null;
> if (cursorName == "CROSSHAIR_CURSOR")
> cursor = new Cursor(Cursor.CROSSHAIR_CURSOR);
> else if (cursorName == "DEFAULT_CURSOR")
> cursor = new Cursor(Cursor.DEFAULT_CURSOR);
> else if (cursorName == "E_RESIZE_CURSOR")
> cursor = new Cursor(Cursor.E_RESIZE_CURSOR);
> else if (cursorName == "HAND_CURSOR")
> cursor = new Cursor(Cursor.HAND_CURSOR);
> else if (cursorName == "MOVE_CURSOR")
> cursor = new Cursor(Cursor.MOVE_CURSOR);
> else if (cursorName == "N_RESIZE_CURSOR")
> cursor = new Cursor(Cursor.N_RESIZE_CURSOR);
> else if (cursorName == "NE_RESIZE_CURSOR")
> cursor = new Cursor(Cursor.NE_RESIZE_CURSOR);
> else if (cursorName == "NW_RESIZE_CURSOR")
> cursor = new Cursor(Cursor.NW_RESIZE_CURSOR);
> else if (cursorName == "S_RESIZE_CURSOR")
> cursor = new Cursor(Cursor.S_RESIZE_CURSOR);
> else if (cursorName == "SE_RESIZE_CURSOR")
> cursor = new Cursor(Cursor.SE_RESIZE_CURSOR);
> else if (cursorName == "SW_RESIZE_CURSOR")
> cursor = new Cursor(Cursor.SW_RESIZE_CURSOR);
> else if (cursorName == "TEXT_CURSOR")
> cursor = new Cursor(Cursor.TEXT_CURSOR);
> else if (cursorName == "W_RESIZE_CURSOR")
> cursor = new Cursor(Cursor.W_RESIZE_CURSOR);
> else if (cursorName == "WAIT_CURSOR")
> cursor = new Cursor(Cursor.WAIT_CURSOR);
> else throw new IllegalArgumentException("Unknown cursor:
> "+cursorName);
> canvas.setCursor(cursor);
> }
Using reflection is also possible.
> Into ``org.nongnu.libvob.gl.GL.Window``::
>
> /** Set the mouse cursor of the window.
> */
> public void setCursor(String cursorName) {
> impl_Window_setCursor(getId(), cursorName); }
>
> Into ``org.nongnu.libvob.gl.GL``::
>
> static private native void impl_Window_setCursor(int id, String
> cursorName);
>
> Into ``org.nongnu.libvob.impl.GL.GLScreen``::
>
> public void setCursor(String cursorName) {
> if (cursorName == "CROSSHAIR_CURSOR" ||
> cursorName == "DEFAULT_CURSOR" ||
> cursorName == "E_RESIZE_CURSOR" ||
> cursorName == "HAND_CURSOR" ||
> cursorName == "MOVE_CURSOR" ||
> cursorName == "N_RESIZE_CURSOR" ||
> cursorName == "NE_RESIZE_CURSOR" ||
> cursorName == "NW_RESIZE_CURSOR" ||
> cursorName == "S_RESIZE_CURSOR" ||
> cursorName == "SE_RESIZE_CURSOR" ||
> cursorName == "SW_RESIZE_CURSOR" ||
> cursorName == "TEXT_CURSOR" ||
> cursorName == "W_RESIZE_CURSOR" ||
> cursorName == "WAIT_CURSOR")
That code won't work. Can't compare strings using ==.
> window.setCursor(cursorName);
> else throw new IllegalArgumentException("Unknown cursor:
> "+cursorName);
> }
> C
Tuomas