GRAPHICS_CURSOR
In this appendix we describe how to specify a mouse cursor object and how to set it in your applications.
There is special class GRAPHICS_CURSOR which is responsible for the mouse cursor shape.
make (cursor_code : INTEGER)
Parameter cursor_code specifies one of the predefined cursor shapes available in GRAPE.DLL. See our On-Line Help Reference for the full list of them.
You can create also your own cursor and include it into your resource project using Interface Builder - see feature load and the chapter about resources.
To set the cursor you can use feature set_cursor of class TILE:
TILE.set_cursor ( c : GRAPHICS_CURSOR)
And its usage is very simple:
local cur : GRAPHICS_CURSOR do !!cur.make (cur. ARROW_NWSE_CURSOR) set_cursor (cur) ...
The basic idea is that every tile object can have its own cursor. When User moves the
mouse pointer over a particular tile window cursor takes the shape specified for this tile
or the default shape.
In conclusion - a small example from the /EXAMPLES/PAINTER directory.
cursor_shape (p : POINT, c : GRAPHICS_CURSOR) : INTEGER is -- called when mouse pointer is under object -- return cursor shape according to p require distance (p) = 0 do if p.is_equal (top_left) or p.is_equal (bottom_right) then Result := c.ARROW_NWSE_CURSOR elseif p.is_equal (top_right) or p.is_equal (bottom_left) then Result := c.ARROW_NESW_CURSOR elseif is_top ( p ) or is_bottom ( p ) then Result := c.ARROW_NS_CURSOR elseif is_left ( p ) or is_right ( p ) then Result := c.ARROW_WE_CURSOR else Result := c.CROSS_BLACK_SMALL_CURSOR end end -- cursor_shape
Feature on_mouse_move is a good place to change the cursor shape.
on_mouse_move ( xx, yy : INTEGER ) : INTEGER is local p : POINT new_cursor : GRAPHICS_CURSOR do !!p.make ( xx, yy ) !!new_cursor.make ( selected_obj.cursor_shape ( p, new_cursor ) ) set_cursor ( new_cursor ) end -- on_mouse_move