From: ellson Date: Sat, 2 Apr 2005 13:59:31 +0000 (+0000) Subject: add support for title="xxx" to and X-Git-Tag: LAST_LIBGRAPH~32^2~7754 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fb0fda2616bf0af4340177b24ac1408fc9e29030;p=graphviz add support for title="xxx" to
and and add support for 'tooltip="xxx"' as an alias for title. --- diff --git a/lib/common/htmllex.c b/lib/common/htmllex.c index 3a4072e6a..ae56fbe26 100644 --- a/lib/common/htmllex.c +++ b/lib/common/htmllex.c @@ -122,6 +122,12 @@ static int hreffn(htmldata_t * p, char *v) return 0; } +static int titlefn(htmldata_t * p, char *v) +{ + p->title = strdup(v); + return 0; +} + static int portfn(htmldata_t * p, char *v) { p->port = strdup(v); @@ -350,6 +356,8 @@ static attr_item tbl_items[] = { {"href", (attrFn) hreffn}, {"port", (attrFn) portfn}, {"target", (attrFn) targetfn}, + {"title", (attrFn) titlefn}, + {"tooltip", (attrFn) titlefn}, {"valign", (attrFn) valignfn}, {"width", (attrFn) widthfn}, }; @@ -367,6 +375,8 @@ static attr_item cell_items[] = { {"port", (attrFn) portfn}, {"rowspan", (attrFn) rowspanfn}, {"target", (attrFn) targetfn}, + {"title", (attrFn) titlefn}, + {"tooltip", (attrFn) titlefn}, {"valign", (attrFn) valignfn}, {"width", (attrFn) widthfn}, }; diff --git a/lib/common/htmltable.c b/lib/common/htmltable.c index 8bb9512e2..7c4c0358d 100644 --- a/lib/common/htmltable.c +++ b/lib/common/htmltable.c @@ -251,7 +251,7 @@ static void doFill(GVC_t * gvc, char *color, box pts) static void doAnchorStart(GVC_t * gvc, htmldata_t * data, void *obj) { - gvrender_begin_anchor(gvc, data->href, "", data->target); + gvrender_begin_anchor(gvc, data->href, data->title, data->target); } static void doAnchorEnd(GVC_t * gvc) @@ -402,6 +402,7 @@ void free_html_data(htmldata_t * dp) free(dp->href); free(dp->port); free(dp->target); + free(dp->title); free(dp->bgcolor); } diff --git a/lib/common/htmltable.h b/lib/common/htmltable.h index aac73df19..9fba071db 100644 --- a/lib/common/htmltable.h +++ b/lib/common/htmltable.h @@ -62,6 +62,7 @@ extern "C" { char *href; /* pointer to an external resource */ char *port; char *target; + char *title; char *bgcolor; char *pencolor; signed char space; diff --git a/lib/common/mapgen.c b/lib/common/mapgen.c index d6e39ec02..5c29203ba 100644 --- a/lib/common/mapgen.c +++ b/lib/common/mapgen.c @@ -215,8 +215,9 @@ static void init_imap(void) static void doHTMLdata(htmldata_t * dp, point p, void *obj) { - char *url, *target; + char *url, *target, *title; pointf p1, p2; + int havetitle=0; if ((url = dp->href) && url[0]) { @@ -234,13 +235,32 @@ static void doHTMLdata(htmldata_t * dp, point p, void *obj) if (!(target = dp->target) || !target[0]) { target = ""; } + if ((title = dp->title) && title[0]) { + havetitle++; + switch (agobjkind(obj)) { + case AGGRAPH: + title = strdup_and_subst_graph(title, (graph_t *) obj); + break; + case AGNODE: + title = strdup_and_subst_node(title, (node_t *) obj); + break; + case AGEDGE: + title = strdup_and_subst_edge(title, (edge_t *) obj); + break; + } + } + else { + title = ""; + } p1.x = p.x + dp->box.LL.x; p1.y = p.y + dp->box.LL.y; p2.x = p.x + dp->box.UR.x; p2.y = p.y + dp->box.UR.y; - map_output_rect(p1, p2, url, target, "", 0); + map_output_rect(p1, p2, url, target, "", title); free(url); + if (havetitle) + free(title); } }