NEWRECT(3R)

NAME
newrect - get swept or default rectangle

SYNOPSIS
#include <dmd.h>

Rectangle newrect (btn, rect)
int btn;
Rectangle rect;

DESCRIPTION
The newrect function prompts the user with a sweep cursor and an outline of the specified Rectangle rect, which then moves with the mouse. The function then busy waits for a Rectangle to be swept out with the specified btn button, or for the outline to be chosen by a click of btn. The function then returns the screen coordinates of the created Rectangle. If any button other than btn is depressed at any stage of the operation, newrect returns a null size Rectangle (i.e., the lower right corner is equal to the upper left origin). If rect is a null size Rectangle, no outline will be presented; only a sweep cursor will appear.

EXAMPLE
The following routine will permit the user to sweep out a Rectangle. As long as the Rectangle swept out does not have any points in common with Drect, the user will be prompted to sweep out another Rectangle. Once the swept out Rectangle has points within Drect, the Rectangle will be clipped to Drect and returned.

    #include <dmd.h>
    Rectangle
    sweep_rect( )
    {
           Rectangle r;
           do
                   r = newrect(2, Drect);
           while (!rectclip(&r, Drect));
           return r;
    }

SEE ALSO
box(3R), rectclip(3R).

DIAGNOSTICS
A mouse click is detected by the amount of mouse movement, not by the time between a button depression and release. The function newrect will see as a click any sweeping action whose result is a Rectangle less than 20 by 20 pixels.