/[libvob]/libvob/doc/pegboard/cursors--humppake/peg.rst
ViewVC logotype

Diff of /libvob/doc/pegboard/cursors--humppake/peg.rst

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by humppake, Mon May 12 12:30:36 2003 UTC revision 1.9 by humppake, Tue May 13 14:40:53 2003 UTC
# Line 31  Issues Line 31  Issues
31          should be implemented separately for both AWT and GL.          should be implemented separately for both AWT and GL.
32    
33          RE-RESOLVED: Calling ``org.nongnu.libvob.GraphicsAPI.Window.setCursor()``          RE-RESOLVED: Calling ``org.nongnu.libvob.GraphicsAPI.Window.setCursor()``
34          with java.awt.Cursor as parameter.          with java.awt.Cursor as parameter. This will simplify the interface and
35            make it consistent with ``java.awt.Component.setCursor()``.
36    
37          RE-RESOLVED: Calling ``org.nongnu.libvob.GraphicsAPI.Window.setCursor()``          RE-RESOLVED: Calling ``org.nongnu.libvob.GraphicsAPI.Window.setCursor()``
38          with proper cursor name string as parameter.          with proper cursor name string as parameter. This is to avoid unwanted
39            initializing of AWT, when using GL.
40      
41          AWTAPI will also have setCursor() overloaded with java.awt.Cursor          AWTAPI will also have setCursor() overloaded with java.awt.Cursor
42          as parameter..          as parameter, since then we *use* AWT.
   
 - 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.  
43    
44  - What is the available set of mouse cursors?  - What is the available set of mouse cursors?
45                    
# Line 76  Issues Line 57  Issues
57          cursors except the custom cursor. AWT and GL cursor APIs can          cursors except the custom cursor. AWT and GL cursor APIs can
58          then be extended (also separately).          then be extended (also separately).
59    
60            Names of the default cursors are similar to ones in
61            ``java.awt.Cursor`` without the suffix "_CURSOR". In
62            awt.Cursor there's a *reason* to have the
63            suffix: they are data members of the class and it makes sense
64            to separate the namespace. Here, that doesn't make sense.
65    
66  - Should we use our own custom cursors?  - Should we use our own custom cursors?
67    
68          RESOLVED: Not yet. Probably we would like to use also our own          RESOLVED: Not yet. Probably we would like to use also our own
# Line 130  Issues Line 117  Issues
117          RESOLVED: Yes, but with care. If the application is runnable under          RESOLVED: Yes, but with care. If the application is runnable under
118          both AWT and GL, there should be checking for proper GraphicsAPI..          both AWT and GL, there should be checking for proper GraphicsAPI..
119    
   
120          RESOLVED: Irrelevant. Not possible anymore.          RESOLVED: Irrelevant. Not possible anymore.
121    
122  Changes  Changes
# Line 142  Interfaces Line 128  Interfaces
128  Into ``org.nongnu.libvob.GraphicsAPI.Window``::  Into ``org.nongnu.libvob.GraphicsAPI.Window``::
129    
130      /** Set the mouse cursor for the window.      /** Set the mouse cursor for the window.
131       * Available cursor types  (case insensitive):       * Available cursor types. These are similar to ones
132       * "CROSSHAIR_CURSOR"  The crosshair cursor type.       * in java.awt.Cursor, tough the "_CURSOR" suffix
133       * "DEFAULT_CURSOR" The default cursor type (gets set if no cursor is defined).       * is dropped.
134       * "E_RESIZE_CURSOR" The east-resize cursor type.       *
135       * "HAND_CURSOR" The hand cursor type.       * "CROSSHAIR"  The crosshair cursor type.
136       * "MOVE_CURSOR" The move cursor type.       * "DEFAULT" The default cursor type (gets set if no cursor is defined).
137       * "N_RESIZE_CURSOR" The north-resize cursor type.       * "E_RESIZE" The east-resize cursor type.
138       * "NE_RESIZE_CURSOR" The north-east-resize cursor type.       * "HAND" The hand cursor type.
139       * "NW_RESIZE_CURSOR" The north-west-resize cursor type.       * "MOVE" The move cursor type.
140       * "S_RESIZE_CURSOR" The south-resize cursor type.       * "N_RESIZE" The north-resize cursor type.
141       * "SE_RESIZE_CURSOR" The south-east-resize cursor type.       * "NE_RESIZE" The north-east-resize cursor type.
142       * "SW_RESIZE_CURSOR" The south-west-resize cursor type.       * "NW_RESIZE" The north-west-resize cursor type.
143       * "TEXT_CURSOR" The text cursor type.       * "S_RESIZE" The south-resize cursor type.
144       * "W_RESIZE_CURSOR" The west-resize cursor type.       * "SE_RESIZE" The south-east-resize cursor type.
145       * "WAIT_CURSOR" The wait cursor type.       * "SW_RESIZE" The south-west-resize cursor type.
146         * "TEXT" The text cursor type.
147         * "W_RESIZE" The west-resize cursor type.
148         * "WAIT" The wait cursor type.
149       */       */
150      public void setCursor(String shape);      public void setCursor(String name);
151    
152  Into ``org.nongnu.libvob.impl.awt.AWTScreen``::  Into ``org.nongnu.libvob.impl.awt.AWTScreen``::
153    
# Line 168  Into ``org.nongnu.libvob.impl.awt.AWTScr Line 157  Into ``org.nongnu.libvob.impl.awt.AWTScr
157          canvas.setCursor(cursor);          canvas.setCursor(cursor);
158      }      }
159    
   
   
160  Implementation  Implementation
161  --------------  --------------
162    
163    Description
164    """""""""""
165    
166    Java AWT client uses ``java.awt.Cursor``, which can be passed to any
167    ``java.awt.Component`` - like ScreenCanvas in AWTScreen. GL client
168    needs a platform specific implementation. Currently we are supporting
169    X implementation. In X Windows, mouse cursor could be changed via
170    Xlib.
171    
172    In GL implementation the cursor name string is passed on in
173    ``org.nongnu.libvob.impl.gl.GLScreen`` and low level implementation
174    like using Xlib is determined later on. Most probably in
175    /src/os/Os-GLX.
176    
177    In AWT the cursor name string is converted to corresponding
178    ``java.awt.Cursor``, which is passed to proper AWT component.
179    
180  Java  Java
181  """"  """"
182    
183  Into ``org.nongnu.libvob.impl.awt.AWTScreen``::  Into ``org.nongnu.libvob.impl.awt.AWTScreen``::
184    
185      public void setCursor(String cursorName) {      public void setCursor(String name) {
186          Cursor cursor = null;          try {
187          if (cursorName == "CROSSHAIR_CURSOR")              Cursor cursor = new Cursor(Cursor.class.getField(name.toUpperCase()+"_CURSOR").getInt(null));
188            cursor = new Cursor(Cursor.CROSSHAIR_CURSOR);              canvas.setCursor(cursor);
189          else if (cursorName == "DEFAULT_CURSOR")          } catch (Exception e) {
190            cursor = new Cursor(Cursor.DEFAULT_CURSOR);              throw new IllegalArgumentException("Unknown cursor: "+name);
191          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);  
192      }      }
193    
194  Into ``org.nongnu.libvob.gl.GL.Window``::  Into ``org.nongnu.libvob.gl.GL.Window``::
195    
196      /** Set the mouse cursor of the window.      /** Set the mouse cursor of the window.
197       */       */
198      public void setCursor(String cursorName) { impl_Window_setCursor(getId(), cursorName); }      public void setCursor(String name) { impl_Window_setCursor(getId(), name); }
199    
200  Into ``org.nongnu.libvob.gl.GL``::  Into ``org.nongnu.libvob.gl.GL``::
201    
202      static private native void impl_Window_setCursor(int id, String cursorName);      static private native void impl_Window_setCursor(int id, String name);
203    
204  Into ``org.nongnu.libvob.impl.GL.GLScreen``::  Into ``org.nongnu.libvob.impl.GL.GLScreen``::
205    
206      public void setCursor(String cursorName) {      public void setCursor(String name) {
207        if (cursorName == "CROSSHAIR_CURSOR" ||        name = name.toUpperCase();
208            cursorName == "DEFAULT_CURSOR" ||        if (name.equals("CROSSHAIR") ||
209            cursorName == "E_RESIZE_CURSOR" ||            name.equals("DEFAULT") ||
210            cursorName == "HAND_CURSOR" ||            name.equals("E_RESIZE") ||
211            cursorName == "MOVE_CURSOR" ||            name.equals("HAND") ||
212            cursorName == "N_RESIZE_CURSOR" ||            name.equals("MOVE") ||
213            cursorName == "NE_RESIZE_CURSOR" ||            name.equals("N_RESIZE") ||
214            cursorName == "NW_RESIZE_CURSOR" ||            name.equals("NE_RESIZE") ||
215            cursorName == "S_RESIZE_CURSOR" ||            name.equals("NW_RESIZE") ||
216            cursorName == "SE_RESIZE_CURSOR" ||            name.equals("S_RESIZE") ||
217            cursorName == "SW_RESIZE_CURSOR" ||            name.equals("SE_RESIZE") ||
218            cursorName == "TEXT_CURSOR" ||            name.equals("SW_RESIZE") ||
219            cursorName == "W_RESIZE_CURSOR" ||            name.equals("TEXT") ||
220            cursorName == "WAIT_CURSOR")            name.equals("W_RESIZE") ||
221              window.setCursor(cursorName);            name.equals("WAIT"))
222        else throw new IllegalArgumentException("Unknown cursor: "+cursorName);              window.setCursor(name);
223          else throw new IllegalArgumentException("Unknown cursor: "+name);
224      }      }
225    
226  C  C
# Line 248  C Line 228  C
228    
229  Into ``include/vob/os/Os.cxx Vob.Os.Window``::  Into ``include/vob/os/Os.cxx Vob.Os.Window``::
230    
231      virtual void setCursor(const std::string cursorName) = 0;      virtual void setCursor(const std::string name) = 0;
232    
233  Into ``src/jni/Main.cxx``::  Into ``src/jni/Main.cxx``::
234    
235      jf(void, impl_1Window_1setCursor)      jf(void, impl_1Window_1setCursor)
236      (JNIEnv *env, jclass, jint id, jstring cursorName) {      (JNIEnv *env, jclass, jint id, jstring name) {
237            Os::Window *w = (Os::Window *)windows.get(id);            Os::Window *w = (Os::Window *)windows.get(id);
238            DBG(dbg) << "Set window "<<id<<" Cursor cursorName "<<cursorName<<" at "<<(int)w<<"\n";            DBG(dbg) << "Set window "<<id<<" Cursor name "<<name<<" at "<<(int)w<<"\n";
239            std::string cCursorName_str = jstr2stdstr(env, cursorName);            std::string name_str = jstr2stdstr(env, name);
240            w->setCursor(cCursorName_str);            w->setCursor(name_str);
241      }      }
242    
243  Into ``src/os/Os-GLX.cxx``::  Into ``src/os/Os-GLX.cxx``::
# Line 269  Into ``src/os/Os-GLX.cxx``:: Line 249  Into ``src/os/Os-GLX.cxx``::
249    
250  Into ``src/os/Os-GLX.cxx Vob.Os.LXWindow``::  Into ``src/os/Os-GLX.cxx Vob.Os.LXWindow``::
251    
252      virtual void setCursor(const std::string cursorName) {      virtual void setCursor(const std::string name) {
253          Cursor cursor = 0;          Cursor cursor = 0;
254          if (cursorName == "CROSSHAIR_CURSOR")          if (name == "CROSSHAIR")
255            cursor = XCreateFontCursor(ws->dpy, XC_crosshair);            cursor = XCreateFontCursor(ws->dpy, XC_crosshair);
256          else if (cursorName == "DEFAULT_CURSOR")          else if (name == "DEFAULT")
257            cursor = XCreateFontCursor(ws->dpy, XC_left_ptr);            cursor = XCreateFontCursor(ws->dpy, XC_left_ptr);
258          else if (cursorName == "E_RESIZE_CURSOR")          else if (name == "E_RESIZE")
259            cursor = XCreateFontCursor(ws->dpy, XC_right_side);            cursor = XCreateFontCursor(ws->dpy, XC_right_side);
260          else if (cursorName == "HAND_CURSOR")          else if (name == "HAND")
261            cursor = XCreateFontCursor(ws->dpy, XC_hand2);            cursor = XCreateFontCursor(ws->dpy, XC_hand2);
262          else if (cursorName == "MOVE_CURSOR")          else if (name == "MOVE")
263            cursor = XCreateFontCursor(ws->dpy, XC_fleur);            cursor = XCreateFontCursor(ws->dpy, XC_fleur);
264          else if (cursorName == "N_RESIZE_CURSOR")          else if (name == "N_RESIZE")
265            cursor = XCreateFontCursor(ws->dpy, XC_top_side);            cursor = XCreateFontCursor(ws->dpy, XC_top_side);
266          else if (cursorName == "NE_RESIZE_CURSOR")          else if (name == "NE_RESIZE")
267            cursor = XCreateFontCursor(ws->dpy, XC_top_right_corner);            cursor = XCreateFontCursor(ws->dpy, XC_top_right_corner);
268          else if (cursorName == "NW_RESIZE_CURSOR")          else if (name == "NW_RESIZE")
269            cursor = XCreateFontCursor(ws->dpy, XC_top_left_corner);            cursor = XCreateFontCursor(ws->dpy, XC_top_left_corner);
270          else if (cursorName == "S_RESIZE_CURSOR")          else if (name == "S_RESIZE")
271            cursor = XCreateFontCursor(ws->dpy, XC_bottom_side);            cursor = XCreateFontCursor(ws->dpy, XC_bottom_side);
272          else if (cursorName == "SE_RESIZE_CURSOR")          else if (name == "SE_RESIZE")
273            cursor = XCreateFontCursor(ws->dpy, XC_bottom_right_corner);            cursor = XCreateFontCursor(ws->dpy, XC_bottom_right_corner);
274          else if (cursorName == "SW_RESIZE_CURSOR")          else if (name == "SW_RESIZE")
275            cursor = XCreateFontCursor(ws->dpy, XC_bottom_left_corner);            cursor = XCreateFontCursor(ws->dpy, XC_bottom_left_corner);
276          else if (cursorName == "TEXT_CURSOR")          else if (name == "TEXT")
277            cursor = XCreateFontCursor(ws->dpy, XC_xterm);            cursor = XCreateFontCursor(ws->dpy, XC_xterm);
278          else if (cursorName == "W_RESIZE_CURSOR")          else if (name == "W_RESIZE")
279            cursor = XCreateFontCursor(ws->dpy, XC_left_side);            cursor = XCreateFontCursor(ws->dpy, XC_left_side);
280          else if (cursorName == "WAIT_CURSOR")          else if (name == "WAIT")
281            cursor = XCreateFontCursor(ws->dpy, XC_watch);            cursor = XCreateFontCursor(ws->dpy, XC_watch);
282          if (cursor != 0) XDefineCursor(ws->dpy, xw, cursor);          if (cursor != 0) XDefineCursor(ws->dpy, xw, cursor);
283      }      }

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26