|
|
1.1 ! root 1: /* Copyright (c) 1988 AT&T */ ! 2: /* All Rights Reserved */ ! 3: ! 4: /* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T */ ! 5: /* The copyright notice above does not evidence any */ ! 6: /* actual or intended publication of such source code. */ ! 7: ! 8: /* @(#)picasso:boxgen.c 1.0 */ ! 9: #include "picasso.h" ! 10: #include "y.tab.h" ! 11: ! 12: /* BOX parameters are a radius (default 0) for rounding corners */ ! 13: /* and the NW corner of the box -- so that the box can be rebuilt */ ! 14: /* (under transformation, the bounding box by itself may not be */ ! 15: /* sufficient, though it contains 4 of the 8 coordinate values.) */ ! 16: ! 17: obj *boxgen() ! 18: { ! 19: static double prevht = HT; ! 20: static double prevwid = WID; /* golden mean, sort of */ ! 21: static double prevrad = 0; ! 22: ! 23: struct objattr obat; ! 24: double x0, y0, x1, y1, xwith, ywith; ! 25: int i, at, with; ! 26: obj *p, *ppos; ! 27: Attr *ap; ! 28: ! 29: obat.a_ht = getfval("boxht"); ! 30: obat.a_wid = getfval("boxwid"); ! 31: obat.a_rad = getfval("boxrad"); ! 32: obat.a_layer = (int)getfval("curlayer"); ! 33: obat.a_flags = EDGED; ! 34: obat.a_weight = obat.a_lcolor = obat.a_pcolor = obat.a_tcolor = -1; ! 35: obat.a_dashpat.a = (float *)0; ! 36: set_text(); ! 37: at = with = xwith = ywith = 0; ! 38: for (i = 0; i < nattr; i++) { ! 39: ap = &attr[i]; ! 40: switch (ap->a_type) { ! 41: default: ! 42: miscattrs(ap, &obat); ! 43: break; ! 44: case SAME: ! 45: obat.a_ht = prevht; ! 46: obat.a_wid = prevwid; ! 47: obat.a_rad = prevrad; ! 48: break; ! 49: case WITH: ! 50: with = ap->a_val.i; /* corner */ ! 51: break; ! 52: case AT: ! 53: ppos = ap->a_val.o; ! 54: curx = Xformx(ppos, 1, ppos->o_x, ppos->o_y); ! 55: cury = Xformy(ppos, 0, ppos->o_x, ppos->o_y); ! 56: at++; ! 57: break; ! 58: } ! 59: } ! 60: if (with) { ! 61: switch (with) { ! 62: case NORTH: ywith = -obat.a_ht/2; break; ! 63: case SOUTH: ywith = obat.a_ht/2; break; ! 64: case EAST: xwith = -obat.a_wid/2; break; ! 65: case WEST: xwith = obat.a_wid/2; break; ! 66: case NE: xwith = -obat.a_wid/2; ! 67: ywith = -obat.a_ht/2; break; ! 68: case SE: xwith = -obat.a_wid/2; ! 69: ywith = obat.a_ht/2; break; ! 70: case NW: xwith = obat.a_wid/2; ! 71: ywith = -obat.a_ht/2; break; ! 72: case SW: xwith = obat.a_wid/2; ! 73: ywith = obat.a_ht/2; break; ! 74: case CENTER: ! 75: case START: ! 76: case END: break; ! 77: default: xwith = -obat.a_wid/2 * xdelta[with%8]; ! 78: ywith = -obat.a_ht/2 * ydelta[with%8]; break; ! 79: } ! 80: curx += xwith; ! 81: cury += ywith; ! 82: } ! 83: if (!at) { ! 84: if (isright(hvmode)) ! 85: curx += obat.a_wid/2; ! 86: else if (isleft(hvmode)) ! 87: curx -= obat.a_wid/2; ! 88: else if (isup(hvmode)) ! 89: cury += obat.a_ht/2; ! 90: else ! 91: cury -= obat.a_ht/2; ! 92: } ! 93: p = makenode(BOX, N_VAL+1, obat.a_layer); ! 94: p->o_val[N_VAL].f = obat.a_rad; ! 95: p->o_wid = obat.a_wid; ! 96: p->o_ht = obat.a_ht; ! 97: x0 = curx - obat.a_wid/2; ! 98: y0 = cury - obat.a_ht/2; ! 99: x1 = curx + obat.a_wid/2; ! 100: y1 = cury + obat.a_ht/2; ! 101: primattrs(p,&obat); ! 102: text_bounds(p); ! 103: track_bounds(x0-p->o_weight/2, y0-p->o_weight/2, ! 104: x1+p->o_weight/2, y1+p->o_weight/2); ! 105: if (isright(hvmode)) ! 106: curx = x1; ! 107: else if (isleft(hvmode)) ! 108: curx = x0; ! 109: else if (isup(hvmode)) ! 110: cury = y1; ! 111: else ! 112: cury = y0; ! 113: prevht = obat.a_ht; ! 114: prevwid = obat.a_wid; ! 115: prevrad = obat.a_rad; ! 116: return(p); ! 117: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.