/[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.7 by humppake, Fri May 9 13:36:51 2003 UTC revision 1.8 by humppake, Mon May 12 12:30:36 2003 UTC
# Line 10  PEG cursors--humppake: Changing mouse cu Line 10  PEG cursors--humppake: Changing mouse cu
10  :Scope:    Trivial  :Scope:    Trivial
11  :Type:     Feature, Interface, Implementation  :Type:     Feature, Interface, Implementation
12    
 .. :Stakeholders:  
 .. :Type:     META|Policy|Architecture|Interface|Implementation  
   
 .. Affect-PEGs:  
   
13  This peg describes, how changing of mouse cursor to any of the default  This peg describes, how changing of mouse cursor to any of the default
14  system cursors could be easily implemented on LibVob.  system cursors could be easily implemented on LibVob.
15    
16  Issues  Issues
17  ======  ======
18    
19  .. - Do we want to change mouse cursor?  - Do we want to change mouse cursor?
20    
21          RESOLVED: Yes, we do. Different effective ares on          RESOLVED: Yes, we do. OF course, different effective areas on
22          GUI should be noticeable also without changing mouse cursor on          GUI should be noticeable also without changing mouse cursor on
23          top of them, of course, mouse cursors would work as          top of them, but mouse different cursors would work as
24          additional visual glues. Except for the effective ares, also          additional visual glues. Except for the effective ares, also
25          for the application state.          for the overall application state.
26    
27  - How the mouse cursor should be changed?  - How the mouse cursor should be changed?
28    
# Line 38  Issues Line 33  Issues
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.
35    
36            RE-RESOLVED: Calling ``org.nongnu.libvob.GraphicsAPI.Window.setCursor()``
37            with proper cursor name string as parameter.
38    
39            AWTAPI will also have setCursor() overloaded with java.awt.Cursor
40            as parameter..
41    
42    - How is changing the mouse cursor implemented?
43            
44            RESOLVED: Java AWT client uses ``java.awt.Cursor``, which can
45            be passed to any ``java.awt.Component`` - like ScreenCanvas in
46            AWTScreen. GL client needs a platform specific implementation.
47            Currently we are supporting X implementation. In X Windows,
48            mouse cursor could be changed via Xlib.
49    
50    - How cursor name string is mapped to Xlib mouse cursor values?
51    
52            RE-RESOLVED: Cursor name string is passed on in
53            ``org.nongnu.libvob.impl.gl.GLScreen`` and
54            low level implementation like using Xlib is determined later
55            on. Most probably in /src/os/Os-GLX.
56    
57    - How cursor name string is mapped to AWT mouse cursor values?
58    
59            RE-RESOLVED: Cursor name string is converted to
60            corresponding ``java.awt.Cursor``, which is passed
61            to proper AWT component.
62    
63    - What is the available set of mouse cursors?
64            
65            RESOLVED: The set of available mouse cursors is the intersection of
66            Xlib and AWT mouse cursors sets:
67    
68            - http://java.sun.com/products/jdk/1.2/docs/api/java/awt/Cursor.html
69            - http://tronche.com/gui/x/xlib/appendix/b/
70    
71            RE-RESOLVED: To be more specific, all Java AWT cursors except
72            custom cursor are available.
73    
74            RE-RESOLVED: A stable sub set of available cursor should be
75            defined in Graphics API. At start, it will be the same as Java AWT
76            cursors except the custom cursor. AWT and GL cursor APIs can
77            then be extended (also separately).
78    
79    - Should we use our own custom cursors?
80    
81            RESOLVED: Not yet. Probably we would like to use also our own
82            custom cursors in the future, but at first it is more relevant
83            to get at least changing of default system cursors work.
84    
85            NOTE: In Java, Toolkit.createCustomCursor is available since
86            JDK 1.2. How custom cursor could be used efficiently in GL?
87    
88            RE-RESOLVED: Since ustom cursors should be also possible
89            outside the AWT, using custom cursor is allowed. Althought, left
90            yet unimplemented in GL.
91    
92            RE-RESOLVED: General GraphicsAPI won't contain custom cursor
93            choice, but custom cursor can be added into GL and AWT APIs
94            later on. If some cursor is implemented to them both, it can
95            be included into general GraphicsAPI.
96    
97  - How java.awt.Cursor is mapped to Xlib mouse cursor values?  - How java.awt.Cursor is mapped to Xlib mouse cursor values?
98    
99          RESOLVED: Mapping is done in setCursor() method          RESOLVED: Mapping is done in setCursor() method
# Line 48  Issues Line 104  Issues
104          low level implementation like usin Xlib is determined later on.          low level implementation like usin Xlib is determined later on.
105          At first in /src/os/Os-GLX.          At first in /src/os/Os-GLX.
106    
107            RE-RESOLVED: Irrelevant.
108    
109  - What are the mouse cursor IDs?  - What are the mouse cursor IDs?
110                    
111          RESOLVED: IDs are our own constants mapped to integer values that          RESOLVED: IDs are our own constants mapped to integer values that
# Line 66  Issues Line 124  Issues
124    
125          RE-RESOLVED: Irrelevant.          RE-RESOLVED: Irrelevant.
126    
 - 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.  
   
127  - Since it's possible to call setCursor() with pure integer values, is  - Since it's possible to call setCursor() with pure integer values, is
128    it allowed to use AWT or Xlib specific cursors?    it allowed to use AWT or Xlib specific cursors?
129    
# Line 86  Issues Line 133  Issues
133    
134          RESOLVED: Irrelevant. Not possible anymore.          RESOLVED: Irrelevant. Not possible anymore.
135    
 - 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.  
   
136  Changes  Changes
137  =======  =======
138    
139  Java  Interfaces
140  ----  ----------
141    
142  Into ``org.nongnu.libvob.GraphicsAPI.Window``::  Into ``org.nongnu.libvob.GraphicsAPI.Window``::
143    
144      /** Set the mouse cursor for the window.      /** Set the mouse cursor for the window.
145         * Available cursor types  (case insensitive):
146         * "CROSSHAIR_CURSOR"  The crosshair cursor type.
147         * "DEFAULT_CURSOR" The default cursor type (gets set if no cursor is defined).
148         * "E_RESIZE_CURSOR" The east-resize cursor type.
149         * "HAND_CURSOR" The hand cursor type.
150         * "MOVE_CURSOR" The move cursor type.
151         * "N_RESIZE_CURSOR" The north-resize cursor type.
152         * "NE_RESIZE_CURSOR" The north-east-resize cursor type.
153         * "NW_RESIZE_CURSOR" The north-west-resize cursor type.
154         * "S_RESIZE_CURSOR" The south-resize cursor type.
155         * "SE_RESIZE_CURSOR" The south-east-resize cursor type.
156         * "SW_RESIZE_CURSOR" The south-west-resize cursor type.
157         * "TEXT_CURSOR" The text cursor type.
158         * "W_RESIZE_CURSOR" The west-resize cursor type.
159         * "WAIT_CURSOR" The wait cursor type.
160       */       */
161      void setCursor(Cursor cursor);      public void setCursor(String shape);
162    
163  Into ``org.nongnu.libvob.impl.awt.AWTScreen``::  Into ``org.nongnu.libvob.impl.awt.AWTScreen``::
164    
165      public void setCursor(cursor Cursor) {      /** Set the mouse cursor for the window.
166         canvas.setCursor(cursor);       */
167        public void setCursor(Cursor cursor) {
168            canvas.setCursor(cursor);
169      }      }
170    
 Into ``org.nongnu.libvob.gl.GL``::  
171    
172      static private native void impl_Window_setCursor(int id, String shape);  
173    Implementation
174    --------------
175    
176    Java
177    """"
178    
179    Into ``org.nongnu.libvob.impl.awt.AWTScreen``::
180    
181        public void setCursor(String cursorName) {
182            Cursor cursor = null;
183            if (cursorName == "CROSSHAIR_CURSOR")
184              cursor = new Cursor(Cursor.CROSSHAIR_CURSOR);
185            else if (cursorName == "DEFAULT_CURSOR")
186              cursor = new Cursor(Cursor.DEFAULT_CURSOR);
187            else if (cursorName == "E_RESIZE_CURSOR")
188              cursor = new Cursor(Cursor.E_RESIZE_CURSOR);
189            else if (cursorName == "HAND_CURSOR")
190              cursor = new Cursor(Cursor.HAND_CURSOR);
191            else if (cursorName == "MOVE_CURSOR")
192              cursor = new Cursor(Cursor.MOVE_CURSOR);
193            else if (cursorName == "N_RESIZE_CURSOR")
194              cursor = new Cursor(Cursor.N_RESIZE_CURSOR);
195            else if (cursorName == "NE_RESIZE_CURSOR")
196              cursor = new Cursor(Cursor.NE_RESIZE_CURSOR);
197            else if (cursorName == "NW_RESIZE_CURSOR")
198              cursor = new Cursor(Cursor.NW_RESIZE_CURSOR);
199            else if (cursorName == "S_RESIZE_CURSOR")
200              cursor = new Cursor(Cursor.S_RESIZE_CURSOR);
201            else if (cursorName == "SE_RESIZE_CURSOR")
202              cursor = new Cursor(Cursor.SE_RESIZE_CURSOR);
203            else if (cursorName == "SW_RESIZE_CURSOR")
204              cursor = new Cursor(Cursor.SW_RESIZE_CURSOR);
205            else if (cursorName == "TEXT_CURSOR")
206              cursor = new Cursor(Cursor.TEXT_CURSOR);
207            else if (cursorName == "W_RESIZE_CURSOR")
208              cursor = new Cursor(Cursor.W_RESIZE_CURSOR);
209            else if (cursorName == "WAIT_CURSOR")
210              cursor = new Cursor(Cursor.WAIT_CURSOR);
211            else throw new IllegalArgumentException("Unknown cursor: "+cursorName);
212            canvas.setCursor(cursor);
213        }
214    
215  Into ``org.nongnu.libvob.gl.GL.Window``::  Into ``org.nongnu.libvob.gl.GL.Window``::
216    
217      /** Set the mouse cursor of the window.      /** Set the mouse cursor of the window.
218       */       */
219      public void setCursor(String shape) { impl_Window_setCursor(getId(), shape); }      public void setCursor(String cursorName) { impl_Window_setCursor(getId(), cursorName); }
220    
221    Into ``org.nongnu.libvob.gl.GL``::
222    
223        static private native void impl_Window_setCursor(int id, String cursorName);
224    
225  Into ``org.nongnu.libvob.impl.GL.GLScreen``::  Into ``org.nongnu.libvob.impl.GL.GLScreen``::
226    
227      public void setCursor(Cursor cursor) {      public void setCursor(String cursorName) {
228          switch (cursor.getType()) {        if (cursorName == "CROSSHAIR_CURSOR" ||
229          case Cursor.CROSSHAIR_CURSOR: window.setCursor("CROSSHAIR_CURSOR"); break;            cursorName == "DEFAULT_CURSOR" ||
230          case Cursor.DEFAULT_CURSOR: window.setCursor("DEFAULT_CURSOR"); break;            cursorName == "E_RESIZE_CURSOR" ||
231          case Cursor.E_RESIZE_CURSOR: window.setCursor("E_RESIZE_CURSOR"); break;            cursorName == "HAND_CURSOR" ||
232          case Cursor.HAND_CURSOR: window.setCursor("HAND_CURSOR"); break;            cursorName == "MOVE_CURSOR" ||
233          case Cursor.MOVE_CURSOR: window.setCursor("MOVE_CURSOR"); break;            cursorName == "N_RESIZE_CURSOR" ||
234          case Cursor.N_RESIZE_CURSOR: window.setCursor("N_RESIZE_CURSOR"); break;            cursorName == "NE_RESIZE_CURSOR" ||
235          case Cursor.NE_RESIZE_CURSOR: window.setCursor("NE_RESIZE_CURSOR"); break;            cursorName == "NW_RESIZE_CURSOR" ||
236          case Cursor.NW_RESIZE_CURSOR: window.setCursor("NW_RESIZE_CURSOR"); break;            cursorName == "S_RESIZE_CURSOR" ||
237          case Cursor.S_RESIZE_CURSOR: window.setCursor("S_RESIZE_CURSOR"); break;            cursorName == "SE_RESIZE_CURSOR" ||
238          case Cursor.SE_RESIZE_CURSOR: window.setCursor("SE_RESIZE_CURSOR"); break;            cursorName == "SW_RESIZE_CURSOR" ||
239          case Cursor.SW_RESIZE_CURSOR: window.setCursor("SW_RESIZE_CURSOR"); break;            cursorName == "TEXT_CURSOR" ||
240          case Cursor.TEXT_CURSOR: window.setCursor("TEXT_CURSOR"); break;            cursorName == "W_RESIZE_CURSOR" ||
241          case Cursor.W_RESIZE_CURSOR: window.setCursor("W_RESIZE_CURSOR"); break;            cursorName == "WAIT_CURSOR")
242          case Cursor.WAIT_CURSOR: window.setCursor("WAIT_CURSOR"); break;              window.setCursor(cursorName);
243          case Cursor.CUSTOM_CURSOR: window.setCursor("CUSTOM_CURSOR"); break;        else throw new IllegalArgumentException("Unknown cursor: "+cursorName);
         };  
244      }      }
245    
246  C  C
247  -  "
248    
249  Into ``include/vob/os/Os.cxx Vob.Os.Window``::  Into ``include/vob/os/Os.cxx Vob.Os.Window``::
250    
251      virtual void setCursor(const std::string shape) = 0;      virtual void setCursor(const std::string cursorName) = 0;
252    
253  Into ``src/jni/Main.cxx``::  Into ``src/jni/Main.cxx``::
254    
255      jf(void, impl_1Window_1setCursor)      jf(void, impl_1Window_1setCursor)
256      (JNIEnv *env, jclass, jint id, jstring shape) {      (JNIEnv *env, jclass, jint id, jstring cursorName) {
257            Os::Window *w = (Os::Window *)windows.get(id);            Os::Window *w = (Os::Window *)windows.get(id);
258            DBG(dbg) << "Set window "<<id<<" Cursor shape "<<shape<<" at "<<(int)w<<"\n";            DBG(dbg) << "Set window "<<id<<" Cursor cursorName "<<cursorName<<" at "<<(int)w<<"\n";
259            std::string shape_str = jstr2stdstr(env, shape);            std::string cCursorName_str = jstr2stdstr(env, cursorName);
260            w->setCursor(shape_str);            w->setCursor(cCursorName_str);
261      }      }
262    
263  Into ``src/os/Os-GLX.cxx``::  Into ``src/os/Os-GLX.cxx``::
# Line 175  Into ``src/os/Os-GLX.cxx``:: Line 269  Into ``src/os/Os-GLX.cxx``::
269    
270  Into ``src/os/Os-GLX.cxx Vob.Os.LXWindow``::  Into ``src/os/Os-GLX.cxx Vob.Os.LXWindow``::
271    
272      virtual void setCursor(const std::string shape) {      virtual void setCursor(const std::string cursorName) {
273      Cursor *cursor = 0;          Cursor cursor = 0;
274          if (shape == "CROSSHAIR_CURSOR")          if (cursorName == "CROSSHAIR_CURSOR")
275            cursor = XCreateFontCursor(ws->dpy, XC_crosshair);            cursor = XCreateFontCursor(ws->dpy, XC_crosshair);
276          else if (shape == "DEFAULT_CURSOR")          else if (cursorName == "DEFAULT_CURSOR")
277            cursor = XCreateFontCursor(ws->dpy, XC_left_ptr);            cursor = XCreateFontCursor(ws->dpy, XC_left_ptr);
278          else if (shape == "E_RESIZE_CURSOR")          else if (cursorName == "E_RESIZE_CURSOR")
279            cursor = XCreateFontCursor(ws->dpy, XC_right_side);            cursor = XCreateFontCursor(ws->dpy, XC_right_side);
280          else if (shape == "HAND_CURSOR")          else if (cursorName == "HAND_CURSOR")
281            cursor = XCreateFontCursor(ws->dpy, XC_hand2);            cursor = XCreateFontCursor(ws->dpy, XC_hand2);
282          else if (shape == "MOVE_CURSOR")          else if (cursorName == "MOVE_CURSOR")
283            cursor = XCreateFontCursor(ws->dpy, XC_fleur);            cursor = XCreateFontCursor(ws->dpy, XC_fleur);
284          else if (shape == "N_RESIZE_CURSOR")          else if (cursorName == "N_RESIZE_CURSOR")
285            cursor = XCreateFontCursor(ws->dpy, XC_top_side);            cursor = XCreateFontCursor(ws->dpy, XC_top_side);
286          else if (shape == "NE_RESIZE_CURSOR")          else if (cursorName == "NE_RESIZE_CURSOR")
287            cursor = XCreateFontCursor(ws->dpy, XC_top_right_corner);            cursor = XCreateFontCursor(ws->dpy, XC_top_right_corner);
288          else if (shape == "NW_RESIZE_CURSOR")          else if (cursorName == "NW_RESIZE_CURSOR")
289            cursor = XCreateFontCursor(ws->dpy, XC_top_left_corner);            cursor = XCreateFontCursor(ws->dpy, XC_top_left_corner);
290          else if (shape == "S_RESIZE_CURSOR")          else if (cursorName == "S_RESIZE_CURSOR")
291            cursor = XCreateFontCursor(ws->dpy, XC_bottom_side);            cursor = XCreateFontCursor(ws->dpy, XC_bottom_side);
292          else if (shape == "SE_RESIZE_CURSOR")          else if (cursorName == "SE_RESIZE_CURSOR")
293            cursor = XCreateFontCursor(ws->dpy, XC_bottom_right_corner);            cursor = XCreateFontCursor(ws->dpy, XC_bottom_right_corner);
294          else if (shape == "SW_RESIZE_CURSOR")          else if (cursorName == "SW_RESIZE_CURSOR")
295            cursor = XCreateFontCursor(ws->dpy, XC_bottom_left_corner);            cursor = XCreateFontCursor(ws->dpy, XC_bottom_left_corner);
296          else if (shape == "TEXT_CURSOR")          else if (cursorName == "TEXT_CURSOR")
297            cursor = XCreateFontCursor(ws->dpy, XC_xterm);            cursor = XCreateFontCursor(ws->dpy, XC_xterm);
298          else if (shape == "W_RESIZE_CURSOR")          else if (cursorName == "W_RESIZE_CURSOR")
299            cursor = XCreateFontCursor(ws->dpy, XC_left_side);            cursor = XCreateFontCursor(ws->dpy, XC_left_side);
300          else if (shape == "WAIT_CURSOR")          else if (cursorName == "WAIT_CURSOR")
301            cursor = XCreateFontCursor(ws->dpy, XC_watch);            cursor = XCreateFontCursor(ws->dpy, XC_watch);
302          if (cursor != 0) XDefineCursor(ws->dpy, xw, cursor);          if (cursor != 0) XDefineCursor(ws->dpy, xw, cursor);
303      }      }

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

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