/* initAnchor: * Save current map values * Initialize fields in job->obj pertaining to anchors. * In particular, this also sets the output rectangle. * If there is something to do, close current anchor if * necessary, start the anchor and returns 1. * Otherwise, it returns 0. * * FIX: Should we provide a tooltip if none is set, as is done * for nodes, edges, etc. ? */ static int initAnchor (GVJ_t* job, htmlenv_t* env, htmldata_t* data, boxf b, htmlmap_data_t* save, int closePrev) { obj_state_t *obj = job->obj; int changed; char* id; static int anchorId; int internalId = 0; agxbuf xb; char intbuf[30]; /* hold 64-bit decimal integer */ unsigned char buf[SMALLBUF]; save->url = obj->url; save->tooltip = obj->tooltip; save->target = obj->target; save->id = obj->id; save->explicit_tooltip = obj->explicit_tooltip; id = data->id; if (!id || !*id) { /* no external id, so use the internal one */ agxbinit(&xb, SMALLBUF, buf); if (!env->objid) { env->objid = strdup (getObjId (job, obj->u.n, &xb)); env->objid_set = 1; } agxbput (&xb, env->objid); sprintf (intbuf, "_%d", anchorId++); agxbput (&xb, intbuf); id = agxbuse (&xb); internalId = 1; } changed = initMapData (job, NULL, data->href, data->title, data->target, id, obj->u.g); if (internalId) agxbfree (&xb); if (changed) { if (closePrev && (save->url || save->explicit_tooltip)) gvrender_end_anchor(job); if (obj->url || obj->explicit_tooltip) { emit_map_rect(job, b); gvrender_begin_anchor(job, obj->url, obj->tooltip, obj->target, obj->id); } } return changed; }
static void emit_html_cell(GVJ_t * job, htmlcell_t * cp, htmlenv_t * env) { box pts = cp->data.box; point p = env->p; pts.LL.x += p.x; pts.UR.x += p.x; pts.LL.y += p.y; pts.UR.y += p.y; /* gvrender_begin_context(); */ if (cp->data.href) { emit_map_rect(job, pts.LL, pts.UR); doAnchorStart(job, &cp->data); } if (cp->data.bgcolor) doFill(job, cp->data.bgcolor, pts); if (cp->child.kind == HTML_TBL) emit_html_tbl(job, cp->child.u.tbl, env); else if (cp->child.kind == HTML_IMAGE) emit_html_img(job, cp->child.u.img, env); else emit_html_txt(job, cp->child.u.txt, env); if (cp->data.border) doBorder(job, cp->data.pencolor, cp->data.border, pts); if (cp->data.href) doAnchorEnd(job); /* gvrender_end_context(); */ }