gzz-dev
[Top][All Lists]
Advanced

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

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


From: Asko Soukka
Subject: [Gzz] Third, PEG cursors--humppake: Changing mouse cursor
Date: Fri, 9 May 2003 16:42:15 +0300 (EEST)

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

:Authors:  Asko Soukka
:Date-Created: 2003-05-09
:Last-Modified: $Date: 2003/05/09 13:24:57 $
:Revision: $Revision: 1.6 $
:Status:   Current
: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.

        RE-RESOLVED: Calling 
``org.nongnu.libvob.GraphicsAPI.Window.setCursor()``
        with java.awt.Cursor as parameter.

- How java.awt.Cursor is mapped to Xlib mouse cursor values?

        RESOLVED: Mapping is done in setCursor() method
        in ``org.nongnu.libvob.impl.gl.GLScreen`` using switch structure.

        RE-RESOLVED: String value corresponding to cursor is 
        passed to on in ``org.nongnu.libvob.impl.gl.GLScreen`` and
        low level implementation like usin Xlib is determined later on.
        At first in /src/os/Os-GLX.

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

        RE-RESOLVED: Irrelevant.

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

        RE-RESOLVED: Irrelevant.

- What is the available set of mouse cursors?
        
        RESOLVED: The set of available mouse cursors is the intersection 
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/

        RE-RESOLVED: To be more specific, all Java AWT cursors except 
        custom cursor are available.

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


        RESOLVED: Irrelevant. Not possible anymore.

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

        RE-RESOLVED: Since ustom cursors should be also possible 
        outside the AWT, using custom cursor is allowed. Althought, left
        yet unimplemented in GL.

Changes
=======

Java
----

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

    /** Set the mouse cursor for the window.
     */
    void setCursor(Cursor cursor);

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

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

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

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

    /** Set the mouse cursor of the window.
     */
    public void setCursor(String shape) { impl_Window_setCursor(getId(), 
shape); }

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

    public void setCursor(Cursor cursor) {
        switch (cursor.getType()) {
        case Cursor.CROSSHAIR_CURSOR: 
window.setCursor("CROSSHAIR_CURSOR"); break;
        case Cursor.DEFAULT_CURSOR: window.setCursor("DEFAULT_CURSOR"); 
break;
        case Cursor.E_RESIZE_CURSOR: window.setCursor("E_RESIZE_CURSOR"); 
break;
        case Cursor.HAND_CURSOR: window.setCursor("HAND_CURSOR"); break;
        case Cursor.MOVE_CURSOR: window.setCursor("MOVE_CURSOR"); break;
        case Cursor.N_RESIZE_CURSOR: window.setCursor("N_RESIZE_CURSOR"); 
break;
        case Cursor.NE_RESIZE_CURSOR: 
window.setCursor("NE_RESIZE_CURSOR"); break;
        case Cursor.NW_RESIZE_CURSOR: 
window.setCursor("NW_RESIZE_CURSOR"); break;
        case Cursor.S_RESIZE_CURSOR: window.setCursor("S_RESIZE_CURSOR"); 
break;
        case Cursor.SE_RESIZE_CURSOR: 
window.setCursor("SE_RESIZE_CURSOR"); break;
        case Cursor.SW_RESIZE_CURSOR: 
window.setCursor("SW_RESIZE_CURSOR"); break;
        case Cursor.TEXT_CURSOR: window.setCursor("TEXT_CURSOR"); break;
        case Cursor.W_RESIZE_CURSOR: window.setCursor("W_RESIZE_CURSOR"); 
break;
        case Cursor.WAIT_CURSOR: window.setCursor("WAIT_CURSOR"); break;
        case Cursor.CUSTOM_CURSOR: window.setCursor("CUSTOM_CURSOR"); 
break;
        };
    }

C
-

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

    virtual void setCursor(const std::string shape) = 0;

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

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

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

    // For setCursor()
    #include <X11/Xlib.h>
    #include <X11/cursorfont.h>
    //

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

    virtual void setCursor(const std::string shape) {
    Cursor *cursor = 0;
        if (shape == "CROSSHAIR_CURSOR")
          cursor = XCreateFontCursor(ws->dpy, XC_crosshair);
        else if (shape == "DEFAULT_CURSOR")
          cursor = XCreateFontCursor(ws->dpy, XC_left_ptr);
        else if (shape == "E_RESIZE_CURSOR")
          cursor = XCreateFontCursor(ws->dpy, XC_right_side);
        else if (shape == "HAND_CURSOR")
          cursor = XCreateFontCursor(ws->dpy, XC_hand2);
        else if (shape == "MOVE_CURSOR")
          cursor = XCreateFontCursor(ws->dpy, XC_fleur);
        else if (shape == "N_RESIZE_CURSOR")
          cursor = XCreateFontCursor(ws->dpy, XC_top_side);
        else if (shape == "NE_RESIZE_CURSOR")
          cursor = XCreateFontCursor(ws->dpy, XC_top_right_corner);
        else if (shape == "NW_RESIZE_CURSOR")
          cursor = XCreateFontCursor(ws->dpy, XC_top_left_corner);
        else if (shape == "S_RESIZE_CURSOR")
          cursor = XCreateFontCursor(ws->dpy, XC_bottom_side);
        else if (shape == "SE_RESIZE_CURSOR")
          cursor = XCreateFontCursor(ws->dpy, XC_bottom_right_corner);
        else if (shape == "SW_RESIZE_CURSOR")
          cursor = XCreateFontCursor(ws->dpy, XC_bottom_left_corner);
        else if (shape == "TEXT_CURSOR")
          cursor = XCreateFontCursor(ws->dpy, XC_xterm);
        else if (shape == "W_RESIZE_CURSOR")
          cursor = XCreateFontCursor(ws->dpy, XC_left_side);
        else if (shape == "WAIT_CURSOR")
          cursor = XCreateFontCursor(ws->dpy, XC_watch);
        if (cursor != 0) XDefineCursor(ws->dpy, xw, cursor);
    } 
 



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





reply via email to

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