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