CURSOR(3R)

NAME
cursor: cursinhibit, cursallow, cursswitch, cursset, cursxyon, cursxyoff, Cursinhibit, Cursallow, Cursswitch - cursor control

SYNOPSIS
#include <dmd.h>

void cursallow ( )
void Cursallow ( )

void cursinhibit ( )
void Cursinhibit ( )

Texture16 *cursswitch (t)
Texture16 *Cursswitch (t)

void cursset (p)

void cursxyon ( )

void cursxyoff ( )

Texture16 *t;
Point p;

Texture16 C_target, C_arrows, C_insert;

Texture16 C_cup, C_deadmouse, C_skull;

DESCRIPTION
The cursinhibit function turns off the interrupt-time cursor tracking (the drawing of the cursor on the screen), but the mouse coordinates are still kept current and available in the global structure mouse.

The cursallow function enables interrupt-time cursor tracking.

The functions cursallow and cursinhibit stack. To enable cursor tracking after two calls to cursinhibit, two calls to cursallow are required.

The cursswitch function changes the mouse cursor to the Texture16 specified by t. If t is (Texture16 *)0, the cursor is restored to the default arrow. The cursswitch function returns the previous value of the cursor, the argument of the previous call to cursswitch.

The Cursallow, Cursinhibit, and Cursswitch functions are the same as those described above, but they do not require ownership of the mouse or that the mouse be in the window.

The cursset function moves the mouse cursor from the current screen position to the new screen position at Point p.

The cursxyon function restricts interrupt-time cursor tracking to only the vertical or horizontal axis. The choice of movement along an axis is determined at interrupt-time and depends on the greater mouse movement along the axes. The lesser movement is ignored. This function is used by tmenuhit to help restrict the mouse's movement.

The cursxyoff function restores normal cursor tracking.

All of these functions require the mouse to be requested first. They work on a per process basis. They will not affect the mouse operation of other processes.

The Texture16s listed are resident in the 630 MTG. Their names explain what they look like.

EXAMPLE
The following example divides a window into four Rectangles. Based on which Rectangle the mouse is in, this program either switches the cursor to the default arrow, switches the cursor to the AT&T Logo, inhibits the cursor, or sets the cursor to Drect.origin.

    #include <dmd.h>
    Texture16 att = {
             0x07E0, 0x1F08, 0x0000, 0x7FFE,
             0x3FC2, 0x0000, 0xFFFF, 0x7FC1,
             0x0000, 0xFFFF, 0x1F01, 0x0000,
             0x7FFE, 0x0000, 0x1008, 0x07E0,
    };
    Point div(), sub(), add();
    main()
    {
        Point o, p;
        Rectangle tl, tr, bl, br;
        int lastr = 0;
        o = div (sub (Drect.corner,
                 Drect.origin), 2);
        tl.origin = tr.origin = bl.origin
                  = br.origin = Drect.origin;
        tr.origin.x += o.x;
        bl.origin.y += o.y;
        br.origin = add (br.origin, o);
        tl.corner = add (tl.origin, o);
        tr.corner = add (tr.origin, o);
        bl.corner = add (bl.origin, o);
        br.corner = add (br.origin, o);
        request (MOUSE|KBD);
        while( kbdchar() == -1 ){
             wait (MOUSE);
             p = mouse.xy;
             if( ptinrect (p, tl) && lastr!=1 ){
               if( lastr==3) cursallow ();
               lastr = 1;
               cursswitch((Texture16 *)0);
             } else if( ptinrect (p, tr) &&
                        lastr!=2 ){
                      if( lastr==3) cursallow ();
                      lastr = 2;
                      cursswitch (&att);
             } else if( ptinrect (p, bl) &&
                        lastr!=3 ){
                      lastr = 3;
                      cursinhibit ();
             } else if( ptinrect (p, br) &&
                        lastr!=4 ){
                      if( lastr==3) cursallow ();
                      lastr = 4;
                      cursset (Drect.origin);
            }
        }
    }

SEE ALSO
resources(3R), sleep(3R), structures(3R).

WARNING
The Cursallow, Cursinhibit, and Cursswitch functions change the state of the mouse cursor without informing the 630 MTG operating system. Any action they do must be undone before calling sleep or wait. Also, they should not be mixed with the other cursor control routines.