VOID do_posn(LONG tree, WORD obj, WORD item) { WORD pobj; GRECT o, p; if (obj != ROOT) { pobj = get_parent(tree, obj); objc_xywh(tree, pobj, &p); objc_xywh(tree, obj, &o); o.g_x = GET_X(tree, obj); o.g_y = GET_Y(tree, obj); switch (item) { case JLFTPOP: o.g_x = 0; break; case JRGTPOP: o.g_x = max(0, p.g_w - o.g_w); break; case JCENPOP: o.g_x = max(0, (p.g_w - o.g_w) / 2); break; case JTOPPOP: o.g_y = 0; break; case JBOTPOP: o.g_y = max(0, p.g_h - o.g_h); break; case JMIDPOP: o.g_y = max(0, (p.g_h - o.g_h) / 2); break; case VFILLPOP: o.g_h = p.g_h; o.g_y = 0; break; case HFILLPOP: o.g_w = p.g_w; o.g_x = 0; break; case SNAPPOP: break; default: return; } rcs_edited = TRUE; if (rcs_state != PANL_STATE || item == SNAPPOP) { snap_xy(&o.g_x, &o.g_y); snap_wh(&o.g_w, &o.g_h); } obj_redraw(tree, obj); ob_setxywh(tree, obj, &o); obj_redraw(tree, obj); } }
static void fm_build(LONG tree, WORD haveicon, WORD nummsg, WORD mlenmsg, WORD numbut, WORD mlenbut) { register WORD i; GRECT al, ic, bt, ms; OBJECT *obj; r_set(&al, 0, 0, 1+INTER_WSPACE, 1+INTER_HSPACE); r_set(&ms, 1 + INTER_WSPACE, 1 + INTER_HSPACE, mlenmsg, 1); if (haveicon) { r_set(&ic, 1+INTER_WSPACE, 1+INTER_HSPACE, 4, 4); al.g_w += ic.g_w + INTER_WSPACE + 1; al.g_h += ic.g_h + INTER_HSPACE + 1; ms.g_x = ic.g_x + ic.g_w + INTER_WSPACE + 1; } r_set(&bt, 1+INTER_WSPACE, 2+INTER_HSPACE+max(nummsg, 1), mlenbut, 1); if (haveicon && nummsg < 2) { bt.g_y += 1; } if (mlenmsg + al.g_w > numbut * mlenbut + (numbut-1) + 1+INTER_WSPACE) { al.g_w += mlenmsg + INTER_WSPACE + 1; bt.g_x = (al.g_w - numbut * mlenbut - (numbut-1)) / 2; } else { al.g_w = numbut * mlenbut + (numbut-1) + 2 * (1+INTER_WSPACE); } al.g_h = max(al.g_h, 2 + (2 * INTER_HSPACE) + nummsg + 2); /* init. root object */ ob_setxywh(tree, ROOT, &al); for(i=0, obj=(OBJECT *)tree; i<NUM_ALOBJS; i++, obj++) obj->ob_next = obj->ob_head = obj->ob_tail = -1; /* add icon object */ if (haveicon) { ob_setxywh(tree, 1, &ic); ob_add(tree, ROOT, 1); } /* add msg objects */ for(i=0; i<nummsg; i++) { ob_setxywh(tree, MSGOFF+i, &ms); ms.g_y++; ob_add(tree, ROOT, MSGOFF+i); } /* add button objects */ for(i=0, obj=((OBJECT *)tree)+BUTOFF; i<numbut; i++, obj++) { obj->ob_flags = SELECTABLE | EXIT; obj->ob_state = NORMAL; ob_setxywh(tree, BUTOFF+i, &bt); bt.g_x += mlenbut + 1; ob_add(tree, ROOT, BUTOFF+i); } /* set last object flag */ (--obj)->ob_flags |= LASTOB; }