示例#1
0
/* endAnchor:
 * Pop context pushed by initAnchor.
 * This is done by ending current anchor, restoring old values and
 * freeing new, and reopening previous anchor if necessary.
 *
 * NB: We don't save or restore geometric map info. This is because
 * this preservation of map context is only necessary for SVG-like
 * systems where graphical items are wrapped in an anchor, and we map
 * top-down. For ordinary map anchors, this is all done bottom-up, so
 * the geometric map info at the higher level hasn't been emitted yet.
 */
static void
endAnchor (GVJ_t* job, htmlmap_data_t* save, int openPrev)
{
    obj_state_t *obj = job->obj;

    if (obj->url || obj->explicit_tooltip)
	gvrender_end_anchor(job);
    RESET(url);
    RESET(tooltip);
    RESET(target);
    RESET(id);
    obj->explicit_tooltip = save->explicit_tooltip;
    if (openPrev && (obj->url || obj->explicit_tooltip))
	gvrender_begin_anchor(job,
		obj->url, obj->tooltip, obj->target, obj->id);
}
示例#2
0
/* 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;
}
示例#3
0
static void doAnchorEnd(GVJ_t * job)
{
    gvrender_end_anchor(job);
}