gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] libvob/doc/pegboard/cursors--humppake peg.rst


From: Asko Soukka
Subject: [Gzz-commits] libvob/doc/pegboard/cursors--humppake peg.rst
Date: Tue, 13 May 2003 10:40:53 -0400

CVSROOT:        /cvsroot/libvob
Module name:    libvob
Changes by:     Asko Soukka <address@hidden>    03/05/13 10:40:53

Modified files:
        doc/pegboard/cursors--humppake: peg.rst 

Log message:
        update

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/doc/pegboard/cursors--humppake/peg.rst.diff?tr1=1.8&tr2=1.9&r1=text&r2=text

Patches:
Index: libvob/doc/pegboard/cursors--humppake/peg.rst
diff -u libvob/doc/pegboard/cursors--humppake/peg.rst:1.8 
libvob/doc/pegboard/cursors--humppake/peg.rst:1.9
--- libvob/doc/pegboard/cursors--humppake/peg.rst:1.8   Mon May 12 08:30:36 2003
+++ libvob/doc/pegboard/cursors--humppake/peg.rst       Tue May 13 10:40:53 2003
@@ -4,8 +4,8 @@
 
 :Authors:  Asko Soukka
 :Date-Created: 2003-05-09
-:Last-Modified: $Date: 2003/05/12 12:30:36 $
-:Revision: $Revision: 1.8 $
+:Last-Modified: $Date: 2003/05/13 14:40:53 $
+:Revision: $Revision: 1.9 $
 :Status:   Current
 :Scope:    Trivial
 :Type:     Feature, Interface, Implementation
@@ -31,34 +31,15 @@
         should be implemented separately for both AWT and GL.
 
        RE-RESOLVED: Calling 
``org.nongnu.libvob.GraphicsAPI.Window.setCursor()``
-       with java.awt.Cursor as parameter.
+       with java.awt.Cursor as parameter. This will simplify the interface and
+        make it consistent with ``java.awt.Component.setCursor()``.
 
        RE-RESOLVED: Calling 
``org.nongnu.libvob.GraphicsAPI.Window.setCursor()``
-       with proper cursor name string as parameter.
-
+       with proper cursor name string as parameter. This is to avoid unwanted
+        initializing of AWT, when using GL.
+   
        AWTAPI will also have setCursor() overloaded with java.awt.Cursor 
-        as parameter..
-
-- 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.
-
-- 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.
-
-- How cursor name string is mapped to AWT mouse cursor values?
-
-       RE-RESOLVED: Cursor name string is converted to
-        corresponding ``java.awt.Cursor``, which is passed
-       to proper AWT component. 
+        as parameter, since then we *use* AWT.
 
 - What is the available set of mouse cursors?
        
@@ -76,6 +57,12 @@
         cursors except the custom cursor. AWT and GL cursor APIs can
         then be extended (also separately).
 
+        Names of the default cursors are similar to ones in
+        ``java.awt.Cursor`` without the suffix "_CURSOR". In
+        awt.Cursor there's a *reason* to have the
+        suffix: they are data members of the class and it makes sense
+        to separate the namespace. Here, that doesn't make sense.
+
 - Should we use our own custom cursors?
 
        RESOLVED: Not yet. Probably we would like to use also our own
@@ -130,7 +117,6 @@
        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.
 
 Changes
@@ -142,23 +128,26 @@
 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.
+     * Available cursor types. These are similar to ones
+     * in java.awt.Cursor, tough the "_CURSOR" suffix
+     * is dropped.
+     *
+     * "CROSSHAIR"  The crosshair cursor type.
+     * "DEFAULT" The default cursor type (gets set if no cursor is defined).
+     * "E_RESIZE" The east-resize cursor type.
+     * "HAND" The hand cursor type.
+     * "MOVE" The move cursor type.
+     * "N_RESIZE" The north-resize cursor type.
+     * "NE_RESIZE" The north-east-resize cursor type.
+     * "NW_RESIZE" The north-west-resize cursor type.
+     * "S_RESIZE" The south-resize cursor type.
+     * "SE_RESIZE" The south-east-resize cursor type.
+     * "SW_RESIZE" The south-west-resize cursor type.
+     * "TEXT" The text cursor type.
+     * "W_RESIZE" The west-resize cursor type.
+     * "WAIT" The wait cursor type.
      */
-    public void setCursor(String shape);
+    public void setCursor(String name);
 
 Into ``org.nongnu.libvob.impl.awt.AWTScreen``::
  
@@ -168,79 +157,70 @@
         canvas.setCursor(cursor);
     }
 
-
-
 Implementation
 --------------
 
+Description
+"""""""""""
+
+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.
+
+In GL implementation the 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.
+
+In AWT the cursor name string is converted to corresponding
+``java.awt.Cursor``, which is passed to proper AWT component.
+
 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);
+    public void setCursor(String name) {
+       try {
+           Cursor cursor = new 
Cursor(Cursor.class.getField(name.toUpperCase()+"_CURSOR").getInt(null));
+           canvas.setCursor(cursor);
+       } catch (Exception e) {
+           throw new IllegalArgumentException("Unknown cursor: "+name);
+       }
     }
 
 Into ``org.nongnu.libvob.gl.GL.Window``::
 
     /** Set the mouse cursor of the window.
      */
-    public void setCursor(String cursorName) { impl_Window_setCursor(getId(), 
cursorName); }
+    public void setCursor(String name) { impl_Window_setCursor(getId(), name); 
}
 
 Into ``org.nongnu.libvob.gl.GL``::
 
-    static private native void impl_Window_setCursor(int id, String 
cursorName);
+    static private native void impl_Window_setCursor(int id, String name);
 
 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")
-            window.setCursor(cursorName);
-      else throw new IllegalArgumentException("Unknown cursor: "+cursorName);
+    public void setCursor(String name) {
+      name = name.toUpperCase();
+      if (name.equals("CROSSHAIR") ||
+         name.equals("DEFAULT") ||
+         name.equals("E_RESIZE") ||
+         name.equals("HAND") ||
+         name.equals("MOVE") ||
+         name.equals("N_RESIZE") ||
+         name.equals("NE_RESIZE") ||
+         name.equals("NW_RESIZE") ||
+         name.equals("S_RESIZE") ||
+         name.equals("SE_RESIZE") ||
+         name.equals("SW_RESIZE") ||
+         name.equals("TEXT") ||
+         name.equals("W_RESIZE") ||
+         name.equals("WAIT"))
+            window.setCursor(name);
+      else throw new IllegalArgumentException("Unknown cursor: "+name);
     }
 
 C
@@ -248,16 +228,16 @@
 
 Into ``include/vob/os/Os.cxx Vob.Os.Window``::
 
-    virtual void setCursor(const std::string cursorName) = 0;
+    virtual void setCursor(const std::string name) = 0;
 
 Into ``src/jni/Main.cxx``::
 
     jf(void, impl_1Window_1setCursor)
-    (JNIEnv *env, jclass, jint id, jstring cursorName) {
+    (JNIEnv *env, jclass, jint id, jstring name) {
           Os::Window *w = (Os::Window *)windows.get(id);
-          DBG(dbg) << "Set window "<<id<<" Cursor cursorName "<<cursorName<<" 
at "<<(int)w<<"\n";
-          std::string cCursorName_str = jstr2stdstr(env, cursorName);
-          w->setCursor(cCursorName_str);
+          DBG(dbg) << "Set window "<<id<<" Cursor name "<<name<<" at 
"<<(int)w<<"\n";
+          std::string name_str = jstr2stdstr(env, name);
+          w->setCursor(name_str);
     }
 
 Into ``src/os/Os-GLX.cxx``::
@@ -269,35 +249,35 @@
 
 Into ``src/os/Os-GLX.cxx Vob.Os.LXWindow``::
 
-    virtual void setCursor(const std::string cursorName) {
+    virtual void setCursor(const std::string name) {
         Cursor cursor = 0;
-       if (cursorName == "CROSSHAIR_CURSOR")
+       if (name == "CROSSHAIR")
          cursor = XCreateFontCursor(ws->dpy, XC_crosshair);
-       else if (cursorName == "DEFAULT_CURSOR")
+       else if (name == "DEFAULT")
          cursor = XCreateFontCursor(ws->dpy, XC_left_ptr);
-       else if (cursorName == "E_RESIZE_CURSOR")
+       else if (name == "E_RESIZE")
          cursor = XCreateFontCursor(ws->dpy, XC_right_side);
-       else if (cursorName == "HAND_CURSOR")
+       else if (name == "HAND")
          cursor = XCreateFontCursor(ws->dpy, XC_hand2);
-       else if (cursorName == "MOVE_CURSOR")
+       else if (name == "MOVE")
          cursor = XCreateFontCursor(ws->dpy, XC_fleur);
-       else if (cursorName == "N_RESIZE_CURSOR")
+       else if (name == "N_RESIZE")
          cursor = XCreateFontCursor(ws->dpy, XC_top_side);
-       else if (cursorName == "NE_RESIZE_CURSOR")
+       else if (name == "NE_RESIZE")
          cursor = XCreateFontCursor(ws->dpy, XC_top_right_corner);
-       else if (cursorName == "NW_RESIZE_CURSOR")
+       else if (name == "NW_RESIZE")
          cursor = XCreateFontCursor(ws->dpy, XC_top_left_corner);
-       else if (cursorName == "S_RESIZE_CURSOR")
+       else if (name == "S_RESIZE")
          cursor = XCreateFontCursor(ws->dpy, XC_bottom_side);
-       else if (cursorName == "SE_RESIZE_CURSOR")
+       else if (name == "SE_RESIZE")
          cursor = XCreateFontCursor(ws->dpy, XC_bottom_right_corner);
-       else if (cursorName == "SW_RESIZE_CURSOR")
+       else if (name == "SW_RESIZE")
          cursor = XCreateFontCursor(ws->dpy, XC_bottom_left_corner);
-       else if (cursorName == "TEXT_CURSOR")
+       else if (name == "TEXT")
          cursor = XCreateFontCursor(ws->dpy, XC_xterm);
-       else if (cursorName == "W_RESIZE_CURSOR")
+       else if (name == "W_RESIZE")
          cursor = XCreateFontCursor(ws->dpy, XC_left_side);
-       else if (cursorName == "WAIT_CURSOR")
+       else if (name == "WAIT")
          cursor = XCreateFontCursor(ws->dpy, XC_watch);
        if (cursor != 0) XDefineCursor(ws->dpy, xw, cursor);
     } 




reply via email to

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