Annotation of researchv9/jtools/src/blitblt/button.c, revision 1.1.1.1

1.1       root        1: #include "jerq.h"
                      2: 
                      3: #define        UP      0
                      4: #define        DOWN    1
                      5: 
                      6: static short boxcurs_bits[] = {
                      7:        0x43FF, 0xE001, 0x7001, 0x3801, 0x1D01, 0x0F01, 0x8701, 0x8F01,
                      8:        0x8001, 0x8001, 0x8001, 0x8001, 0x8001, 0x8001, 0x8001, 0xFFFF,
                      9: };
                     10: static Cursor boxcurs;
                     11: static int firstime = 1;
                     12: 
                     13: Rectangle
                     14: getrect (n)
                     15: int n;
                     16: {
                     17:        return getrectb(8>>n, 1);
                     18: }
                     19: 
                     20: Rectangle
                     21: getrectb (n, block)
                     22: int n, block;
                     23: {
                     24:        Rectangle r, canon();
                     25:        Point p1, p2;
                     26:        Cursor *prev;
                     27:        
                     28:        if (firstime) {
                     29:                boxcurs = ToCursor(boxcurs_bits, boxcurs_bits, 8, 8);
                     30:                firstime = 0;
                     31:        }
                     32:        prev = cursswitch(&boxcurs);
                     33:        Jscreengrab();
                     34:        if(block){
                     35:                buttons(UP);
                     36:                buttons(DOWN);
                     37:        }
                     38:        if(!(mouse.buttons&n)){
                     39:                r.origin.x=r.origin.y=r.corner.x=r.corner.y=0;
                     40:                buttons(UP);
                     41:                goto Return;
                     42:        }
                     43:        p1 = add(mouse.xy, Joffset);
                     44:        p2 = p1;
                     45:        r = canon(p1, p2);
                     46:        outline(r);
                     47:        for(; mouse.buttons&n; nap(2)){
                     48:                outline(r);
                     49:                p2 = add(mouse.xy, Joffset);
                     50:                r = canon(p1, p2);
                     51:                outline(r);
                     52:        }
                     53:        outline(r);     /* undraw for the last time */
                     54:     Return:
                     55:        Jscreenrelease();
                     56:        cursswitch(prev);
                     57:        return r;
                     58: }
                     59: 
                     60: buttons (updown)
                     61: {
                     62:        while((button123()!=0) != updown)
                     63:                nap(2);
                     64: }
                     65: 
                     66: Rectangle
                     67: canon (p1, p2)
                     68: Point p1, p2;
                     69: {
                     70:        Rectangle r;
                     71:        r.origin.x = min(p1.x, p2.x);
                     72:        r.origin.y = min(p1.y, p2.y);
                     73:        r.corner.x = max(p1.x, p2.x);
                     74:        r.corner.y = max(p1.y, p2.y);
                     75:        return(r);
                     76: }
                     77: 
                     78: static outline(r)
                     79: Rectangle  r;
                     80: {
                     81:        segment(&Jfscreen, r.org, Pt(r.cor.x, r.org.y), F_XOR);
                     82:        segment(&Jfscreen, Pt(r.cor.x, r.org.y), r.cor, F_XOR);
                     83:        segment(&Jfscreen, r.cor, Pt(r.org.x, r.cor.y), F_XOR);
                     84:        segment(&Jfscreen, Pt(r.org.x, r.cor.y), r.org, F_XOR);
                     85: }
                     86: 
                     87: Cursor *
                     88: cursswitch (cp)
                     89: Cursor *cp;
                     90: {
                     91:        Cursor *rc;
                     92: #ifdef SUNTOOLS
                     93:        extern struct pixrectops mem_ops;
                     94:        static struct mpr_data d = 
                     95:                {mpr_linebytes(16,1), (short *)0, {0, 0}, 0, 0};
                     96:        static struct pixrect curs = {&mem_ops, 16, 16, 1, (caddr_t)&d};
                     97:        static struct cursor cursor = {7, 7, F_XOR, &curs};
                     98: #endif SUNTOOLS
                     99: 
                    100:        if (cp == (Cursor *)0)
                    101:                cp = &normalcursor;
                    102: #ifdef X11
                    103:        XDefineCursor(dpy, display.dr, *cp);
                    104: #endif X11
                    105: #ifdef SUNTOOLS
                    106:        cursor.cur_xhot = cp->hotx;
                    107:        cursor.cur_yhot = cp->hoty;
                    108:        d.md_image = cp->bits;
                    109:        win_setcursor(displayfd, &cursor);
                    110: #endif SUNTOOLS
                    111:        rc = P->cursor;
                    112:        P->cursor = cp;
                    113:        return rc;
                    114: }
                    115: 
                    116: cursset (p)
                    117: Point p;
                    118: {
                    119: #ifdef X11
                    120:        XWarpPointer(dpy, display.dr, display.dr, mouse.xy.x, mouse.xy.y,
                    121:                display.rect.corner.x, display.rect.corner.y, p.x, p.y);
                    122: #endif X11
                    123: #ifdef SUNTOOLS
                    124:        win_setmouseposition(displayfd, p.x, p.y);
                    125: #endif SUNTOOLS
                    126:        mouse.xy.x = p.x;
                    127:        mouse.xy.y = p.y;
                    128: }

unix.superglobalmegacorp.com

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