Annotation of researchv10dc/630/man/src/p_man/man3/ptinrect.3r, revision 1.1

1.1     ! root        1: .ds ZZ DEVELOPMENT PACKAGE
        !             2: .TH PTINRECT 3R "630 MTG"
        !             3: .SH NAME
        !             4: ptinrect \- check for Point inclusion in a Rectangle
        !             5: .SH SYNOPSIS
        !             6: .ft B
        !             7: # include <dmd.h>
        !             8: .sp
        !             9: int ptinrect (p, r)
        !            10: .br
        !            11: Point p;
        !            12: .br
        !            13: Rectangle r;
        !            14: .SH DESCRIPTION
        !            15: The
        !            16: .I ptinrect 
        !            17: function
        !            18: returns 1 if
        !            19: .I p
        !            20: is a Point within Rectangle
        !            21: .I r ;
        !            22: and 0, otherwise.
        !            23: .SH EXAMPLE
        !            24: The following routine will draw a box in the middle of a window.
        !            25: Then when button 1 is depressed within the box,
        !            26: the bell will ring.
        !            27: The routine returns when a key is typed.
        !            28: .PP
        !            29: .RS 3
        !            30: .nf
        !            31: .ft CM
        !            32: #include <dmd.h>
        !            33: Point add();
        !            34: Point sub();
        !            35: Point div();
        !            36: 
        !            37: ringbox()
        !            38: {
        !            39:    Point center, offset;
        !            40:    Rectangle midbox;
        !            41: 
        !            42:    offset = div (sub (Drect.corner,
        !            43:                 Drect.origin), 2);
        !            44:    center = add (Drect.origin, offset);
        !            45:    midbox.origin = sub (center, Pt (16, 16));
        !            46:    midbox.corner = add (center, Pt (16, 16));
        !            47:    box (&display, midbox, F_XOR);
        !            48:    request (MOUSE|KBD);
        !            49:    while (kbdchar () == -1){
        !            50:        wait (MOUSE);
        !            51:        if (ptinrect (mouse.xy, midbox) &&
        !            52:              button1()) ringbell();
        !            53:    }
        !            54: }
        !            55: \fR
        !            56: .fi
        !            57: .RE

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.