gzz-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz] PEG cursors--humppake: Changing mouse cursor


From: Asko Soukka
Subject: [Gzz] PEG cursors--humppake: Changing mouse cursor
Date: Fri, 9 May 2003 13:40:23 +0300 (EEST)

==========================================================================
PEG cursors--humppake: Changing mouse cursor
==========================================================================

:Authors:  Asko Soukka
:Date-Created: 2003-05-09
:Last-Modified: $Date: 2003/04/25 12:29:33 $
:Revision: $Revision: 1.2 $
:Status:   Incomplete
:Scope:    Trivial
:Type:     Feature, Interface, Implementation

.. :Stakeholders:
.. :Type:     META|Policy|Architecture|Interface|Implementation

.. Affect-PEGs:

This peg describes, how changing of mouse cursor to any of the default
system cursors could be easily implemented on LibVob.

Issues
======

.. - Do we want to change mouse cursor?

        RESOLVED: Yes, we do. Different effective ares on
        GUI should be noticeable also without changing mouse cursor on
        top of them, of course, mouse cursors would work as
        additional visual glues. Except for the effective ares, also
        for the application state.

- 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.

- What are the mouse cursor IDs?
        
        RESOLVED: IDs are our own constants mapped to integer values that
        correspond the mouse cursors in current environment. Integers 
        for specific mouse cursors are different in AWT and Xlib and 
that's
        why we need our own mapping for them.

- Where are the mouse cursor ID mappings located?
        
        RESOLVED: Mouse cursor constants are described with AWT values as 
default
        in ``org.nongnu.libvob.GraphicsAPI``. For GL implementation those
        mappings must be overwritten into
        ``org.nongnu.libvob.impl.gl.GLAPI``.

- What is the available set of mouse cursors?
        
        RESOLVED: The set of available mouse cursors is the interserction 
of
        Xlib and AWT mouse cursors sets:

        - 
http://java.sun.com/products/jdk/1.2/docs/api/java/awt/Cursor.html
        - http://tronche.com/gui/x/xlib/appendix/b/

- Since it's possible to call setCursor() with pure integer values, is
  it allowed to use AWT or Xlib specific cursors?

        RESOLVED: Yes, but with care. If the application is runnable under
        both AWT and GL, there should be checking for proper GraphicsAPI..

- Should we use our own custom cursors?

        RESOLVED: Not yet. Probably we would like to use also our own
        custom cursors in the future, but at first it is more relevant
        to get at least changing of default system cursors work.

        NOTE: In Java, Toolkit.createCustomCursor is available since
        JDK 1.2. How custom cursor could be used efficiently in GL?

Changes
=======

Java
----

Into ``org.nongnu.libvob.GraphicsAPI``::

    /** Available mouse cursor, set after AWT by default, must
     * be overwritten in GL.
     */
    public static int CROSSHAIR_CURSOR = Cursor.CROSSHAIR_CURSOR;
    public static int DEFAULT_CURSOR = Cursor.DEFAULT_CURSOR;
    public static int E_RESIZE_CURSOR = Cursor.E_RESIZE_CURSOR;
    public static int HAND_CURSOR = Cursor.HAND_CURSOR;
    public static int MOVE_CURSOR = Cursor.MOVE_CURSOR;
    public static int N_RESIZE_CURSOR = Cursor.N_RESIZE_CURSOR;
    public static int NE_RESIZE_CURSOR = Cursor.NE_RESIZE_CURSOR;
    public static int NW_RESIZE_CURSOR = Cursor.NW_RESIZE_CURSOR;
    public static int S_RESIZE_CURSOR = Cursor.S_RESIZE_CURSOR;
    public static int SE_RESIZE_CURSOR = Cursor.SE_RESIZE_CURSOR;
    public static int SW_RESIZE_CURSOR = Cursor.SW_RESIZE_CURSOR;
    public static int TEXT_CURSOR = Cursor.TEXT_CURSOR;
    public static int W_RESIZE_CURSOR = Cursor.W_RESIZE_CURSOR;
    public static int WAIT_CURSOR = Cursor.WAIT_CURSOR;

Into ``org.nongnu.libvob.GraphicsAPI.Window``::

    /** Sets the mouse cursors shape.
     */
    void setCursor(int shape);

Into ``org.nongnu.libvob.impl.awt.AWTScreen``::
 
    public void setCursor(int shape) {
       canvas.setCursor(new Cursor(shape));
    }

Into ``org.nongnu.libvob.impl.GL.GLAPI``::

    /** Available mouse cursor
     * After Xlib: http://tronche.com/gui/x/xlib/appendix/b/
     */
    public static int CROSSHAIR_CURSOR = 130; // XC_tcross
    public static int DEFAULT_CURSOR = 68; // XC_left_ptr
    public static int E_RESIZE_CURSOR = 98; // XC_righside
    public static int HAND_CURSOR = 60; // XC_hand2
    public static int MOVE_CURSOR = 52; // XC_fleur
    public static int N_RESIZE_CURSOR = 138; // XC_top_side
    public static int NE_RESIZE_CURSOR = 136; // XC_top_right_corner
    public static int NW_RESIZE_CURSOR = 134; // XC_top_left_corner
    public static int S_RESIZE_CURSOR = 16; // XC_bottom_side
    public static int SE_RESIZE_CURSOR = 14; // XC_bottom_right_corner
    public static int SW_RESIZE_CURSOR = 12; // XC_bottom_left_corner
    public static int TEXT_CURSOR = 152; // XC_xterm
    public static int W_RESIZE_CURSOR = 70; // XC_left_side
    public static int WAIT_CURSOR = 150; // XC_watch

Into ``org.nongnu.libvob.GL``::

    static private native void impl_Window_setCursor(int id, int shape);

Into ``org.nongnu.libvob.GL.Window``::

    /** Changes mouse cursor on the window.
     */
    public void setCursor(int shape) { impl_Window_setCursor(getId(), 
shape); }

Into ``org.nongnu.libvob.impl.GL.GLScreen``::

    public void setCursor(int shape) {
       window.setCursor(shape);
    }

C
-

Into ``include/vob/os/Os.cxx Vob.Os.Window``::

    virtual void setCursor(int shape) = 0;

Into ``src/jni/Main.cxx``::

    jf(void, impl_1Window_1setCursor)
    (JNIEnv *env, jclass, jint id, jint shape) {
          Os::Window *w = (Os::Window *)windows.get(id);
          DBG(dbg) << "Set window "<<id<<" Cursor shape "<<shape<<" at 
"<<(int)w<<"\n";
          w->setCursor(shape);
    }

Into ``src/os/Os-GLX.cxx``::

    #include <X11/Xlib.h>

Into ``src/os/Os-GLX.cxx Vob.Os.LXWindow``::

    virtual void setCursor(int shape) {
       XDefineCursor(ws->dpy, xw, XCreateFontCursor(ws->dpy, shape));
    }

-- 
Asko Soukka <address@hidden>
<http://www.iki.fi/asko.soukka/>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]