Annotation of researchv9/jtools/src/Jpic/boxgen.c, revision 1.1

1.1     ! root        1: #include       <stdio.h>
        !             2: #include       "pic.h"
        !             3: #include       "y.tab.h"
        !             4: 
        !             5: struct obj *boxgen(type)
        !             6: {
        !             7:        static int prevh = HT;
        !             8:        static int prevw = WID; /* golden mean, sort of */
        !             9:        int i, invis, at, ddtype, ddval;
        !            10:        int with, xwith, ywith;
        !            11:        int h, w;
        !            12:        coord x0, y0, x1, y1;
        !            13:        struct obj *p, *ppos;
        !            14: 
        !            15:        h = getvar("boxht");
        !            16:        w = getvar("boxwid");
        !            17:        invis = at = 0;
        !            18:        with = xwith = ywith = 0;
        !            19:        ddtype = ddval = 0;
        !            20:        for (i = 0; i < nattr; i++) {
        !            21:                switch (attr[i].a_type) {
        !            22:                case HEIGHT:
        !            23:                        h = attr[i].a_val;
        !            24:                        break;
        !            25:                case WIDTH:
        !            26:                        w = attr[i].a_val;
        !            27:                        break;
        !            28:                case SAME:
        !            29:                        h = prevh;
        !            30:                        w = prevw;
        !            31:                        break;
        !            32:                case WITH:
        !            33:                        with = attr[i].a_val;   /* corner */
        !            34:                        break;
        !            35:                case AT:
        !            36:                        ppos = (struct obj *) attr[i].a_val;
        !            37:                        curx = ppos->o_x;
        !            38:                        cury = ppos->o_y;
        !            39:                        at++;
        !            40:                        break;
        !            41:                case INVIS:
        !            42:                        invis = INVIS;
        !            43:                        break;
        !            44:                case DOT:
        !            45:                case DASH:
        !            46:                        ddtype = attr[i].a_type;
        !            47:                        ddval = attr[i].a_val;
        !            48:                        if (ddval == 0)
        !            49:                                ddval = getvar("dashwid");
        !            50:                        break;
        !            51:                case LJUST: case RJUST: case CENTER: case SPREAD: case FILL: case ABOVE: case BELOW:
        !            52:                        savetext(attr[i].a_type, attr[i].a_val);
        !            53:                        break;
        !            54:                }
        !            55:        }
        !            56:        if (with) {
        !            57:                switch (with) {
        !            58:                case NORTH:     ywith = -((h+1) / 2); break;
        !            59:                case SOUTH:     ywith = h / 2; break;
        !            60:                case EAST:      xwith = -((w+1) / 2); break;
        !            61:                case WEST:      xwith = w / 2; break;
        !            62:                case NE:        xwith = -((w+1) / 2); ywith = -((h+1) / 2); break;
        !            63:                case SE:        xwith = -((w+1) / 2); ywith = h / 2; break;
        !            64:                case NW:        xwith = w / 2; ywith = -((h+1) / 2); break;
        !            65:                case SW:        xwith = w / 2; ywith = h / 2; break;
        !            66:                }
        !            67:                curx += xwith;
        !            68:                cury += ywith;
        !            69:        }
        !            70:        if (!at) {
        !            71:                if (isright(hvmode))
        !            72:                        curx += (w+1) / 2;
        !            73:                else if (isleft(hvmode))
        !            74:                        curx -= w / 2;
        !            75:                else if (isup(hvmode))
        !            76:                        cury += (h+1) / 2;
        !            77:                else
        !            78:                        cury -= h / 2;
        !            79:        }
        !            80:        x0 = curx - w / 2;
        !            81:        y0 = cury - h / 2;
        !            82:        x1 = curx + (w+1) / 2;
        !            83:        y1 = cury + (h+1) / 2;
        !            84:        extreme(x0, y0);
        !            85:        extreme(x1, y1);
        !            86:        p = makenode(BOX, 2);
        !            87:        p->o_val[0] = w;
        !            88:        p->o_val[1] = h;
        !            89:        p->o_dotdash = ddtype;
        !            90:        p->o_ddval = ddval;
        !            91:        p->o_attr = invis;
        !            92:        dprintf("B %d %d %d %d at %d %d, h=%d, w=%d\n", x0, y0, x1, y1, curx, cury, h, w);
        !            93:        if (isright(hvmode))
        !            94:                curx = x1;
        !            95:        else if (isleft(hvmode))
        !            96:                curx = x0;
        !            97:        else if (isup(hvmode))
        !            98:                cury = y1;
        !            99:        else
        !           100:                cury = y0;
        !           101:        prevh = h;
        !           102:        prevw = w;
        !           103:        return(p);
        !           104: }

unix.superglobalmegacorp.com

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