Annotation of researchv9/jerq/src/lib/pot/pot.c, revision 1.1.1.1

1.1       root        1: #include       <CC/jerq.h>
                      2: #include       "pot.pri"
                      3: 
                      4: Pot *base = 0;
                      5: 
                      6: Pot.Pot(Rectangle rect, short fl, short v)
                      7: {
                      8:        r = rect;
                      9:        flags = fl&P_MASK;
                     10:        val = v;
                     11:        help = "";
                     12:        next = base;
                     13:        base = this;
                     14: }
                     15: 
                     16: void
                     17: Pot.draw()
                     18: {
                     19:        rectf(&display, r, F_OR);
                     20: }
                     21: 
                     22: void
                     23: Pot.mod(int i)
                     24: {
                     25:        rectf(&display, r, F_OR);
                     26:        i++;    /* shut CC up */
                     27: }
                     28: 
                     29: void
                     30: Pot.resize(Rectangle rect)
                     31: {
                     32:        r = rect;
                     33: }
                     34: 
                     35: hitpot(int but)
                     36: {
                     37:        register Pot *pot;
                     38:        Point p;
                     39: 
                     40:        p = mouse.xy;
                     41:        for(pot = base; pot; pot = pot->next)
                     42:                if(ptinrect(p, inset(pot->r, -25))) break;
                     43:        if(pot == 0) return(0);
                     44:        pot->mod(but);
                     45:        return(1);
                     46: }
                     47: 
                     48: void
                     49: helppot(int but)
                     50: {
                     51:        register Pot *pot;
                     52:        Point p;
                     53: 
                     54:        p = mouse.xy;
                     55:        for(pot = base; pot; pot = pot->next)
                     56:                if(ptinrect(p, inset(pot->r, -25))) break;
                     57:        if(pot && pot->help && pot->help[0])
                     58:        {
                     59:                int x = strwidth(&defont, pot->help);
                     60:                Bitmap *b;
                     61: 
                     62:                if((p.x = pot->r.o.x-x-100) > 0)
                     63:                        p.y = (pot->r.o.y+pot->r.c.y)/2-7;
                     64:                else if((p.x = pot->r.c.x+100)+x < XMAX)
                     65:                        p.y = (pot->r.o.y+pot->r.c.y)/2-7;
                     66:                if(b = balloc(raddp(Rect(0, 0, x+6, 20), p)))
                     67:                {
                     68:                        rectf(b, b->rect, F_OR);
                     69:                        rectf(b, inset(b->rect, 1), F_CLR);
                     70:                        string(&defont, pot->help, b, add(b->rect.o, Pt(3, 3)), F_OR);
                     71:                        screenswap(b, b->rect, b->rect);
                     72:                        while(button(but)) nap(2);
                     73:                        screenswap(b, b->rect, b->rect);
                     74:                        bfree(b);
                     75:                }
                     76:        }
                     77: }
                     78: 
                     79: void
                     80: drawpot()
                     81: {
                     82:        register Pot *pot;
                     83: 
                     84:        for(pot = base; pot; pot = pot->next)
                     85:                pot->draw();
                     86: }
                     87: 
                     88: void
                     89: reshapepot(Rectangle oldr, Rectangle newr)
                     90: {
                     91:        register Pot *pot;
                     92:        Rectangle r;
                     93:        Point o = oldr.c-oldr.o, n = newr.c-newr.o;
                     94: 
                     95:        for(pot = base; pot; pot = pot->next)
                     96:        {
                     97:                r.o.x = muldiv(pot->r.o.x-oldr.o.x, n.x, o.x);
                     98:                r.o.y = muldiv(pot->r.o.y-oldr.o.y, n.y, o.y);
                     99:                r.c.x = muldiv(pot->r.c.x-oldr.o.x, n.x, o.x);
                    100:                r.c.y = muldiv(pot->r.c.y-oldr.o.y, n.y, o.y);
                    101:                pot->resize(r);
                    102:        }
                    103: }
                    104: 
                    105: void
                    106: prval(Point p, short v)
                    107: {
                    108:        char buf[20];
                    109: 
                    110:        sprintf(buf, "%d", v);
                    111:        string(&defont, buf, &display, p, F_XOR);
                    112: }
                    113: 
                    114: Rectangle
                    115: rcenter(Rectangle r, Rectangle q)
                    116: {
                    117:        Point qc = div(add(q.o, q.c), 2);
                    118:        Point rc = div(add(r.o, r.c), 2);
                    119: 
                    120:        return(raddp(r, sub(qc, rc)));
                    121: }
                    122: 
                    123: extern void
                    124: bord(Bitmap *bp, Rectangle r, int i, int c)
                    125: {
                    126:        rectf(bp, Rectangle(r.o.x, r.o.y, r.c.x, r.o.y+i), c);
                    127:        rectf(bp, Rect(r.o.x, r.o.y+i, r.o.x+i, r.c.y-i), c);
                    128:        rectf(bp, Rect(r.c.x-i, r.o.y+i, r.c.x, r.c.y-i), c);
                    129:        rectf(bp, Rect(r.o.x, r.c.y-1, r.c.x, r.c.y), c);
                    130: }

unix.superglobalmegacorp.com

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