/* size_html_tbl: * Determine the size of a table by first determining the * size of each cell. */ static int size_html_tbl(graph_t *g, htmltbl_t * tbl, htmlcell_t * parent, htmlenv_t * env) { int i, wd, ht; int rv = 0; htmlfont_t savef; if (tbl->font) pushFontInfo(env, tbl->font, &savef); tbl->u.n.parent = parent; rv = processTbl(g, tbl, env); /* Set up border and spacing */ if (!(tbl->data.flags & SPACE_SET)) { tbl->data.space = DEFAULT_CELLSPACING; } if (!(tbl->data.flags & BORDER_SET)) { tbl->data.border = DEFAULT_BORDER; } sizeArray(tbl); wd = (tbl->cc + 1) * tbl->data.space + 2 * tbl->data.border; ht = (tbl->rc + 1) * tbl->data.space + 2 * tbl->data.border; for (i = 0; i < tbl->cc; i++) wd += tbl->widths[i]; for (i = 0; i < tbl->rc; i++) ht += tbl->heights[i]; if (tbl->data.flags & FIXED_FLAG) { if (tbl->data.width && tbl->data.height) { if ((tbl->data.width < wd) || (tbl->data.height < ht)) { agerr(AGWARN, "table size too small for content\n"); rv = 1; } wd = ht = 0; } else { agerr(AGWARN, "fixed table size with unspecified width or height\n"); rv = 1; } } tbl->data.box.UR.x = MAX(wd, tbl->data.width); tbl->data.box.UR.y = MAX(ht, tbl->data.height); if (tbl->font) popFontInfo(env, &savef); return rv; }
static void emit_html_tbl(GVJ_t * job, htmltbl_t * tbl, htmlenv_t * env) { box pts = tbl->data.box; point p = env->p; htmlcell_t **cells = tbl->u.n.cells; htmlfont_t savef; if (tbl->font) pushFontInfo(env, tbl->font, &savef); pts.LL.x += p.x; pts.UR.x += p.x; pts.LL.y += p.y; pts.UR.y += p.y; /* gvrender_begin_context(job); */ if (tbl->data.href) doAnchorStart(job, &tbl->data); if (tbl->data.bgcolor) doFill(job, tbl->data.bgcolor, pts); while (*cells) { emit_html_cell(job, *cells, env); cells++; } if (tbl->data.border) doBorder(job, tbl->data.pencolor, tbl->data.border, pts); if (tbl->data.href) doAnchorEnd(job); /* gvrender_end_context(job); */ if (tbl->font) popFontInfo(env, &savef); }
static void emit_html_tbl(GVJ_t * job, htmltbl_t * tbl, htmlenv_t * env) { boxf pts = tbl->data.box; pointf pos = env->pos; htmlcell_t **cells = tbl->u.n.cells; htmlcell_t *cp; static htmlfont_t savef; htmlmap_data_t saved; int anchor; /* if true, we need to undo anchor settings. */ int doAnchor = (tbl->data.href || tbl->data.target); pointf AF[4]; if (tbl->font) pushFontInfo(env, tbl->font, &savef); pts.LL.x += pos.x; pts.UR.x += pos.x; pts.LL.y += pos.y; pts.UR.y += pos.y; if (doAnchor && !(job->flags & EMIT_CLUSTERS_LAST)) anchor = initAnchor(job, env, &tbl->data, pts, &saved, 1); else anchor = 0; /* Set up rounded style */ if (tbl->data.style & ROUNDED) { AF[0] = pts.LL; AF[2] = pts.UR; if (tbl->data.border) { double delta = ((double)tbl->data.border)/2.0; AF[0].x += delta; AF[0].y += delta; AF[2].x -= delta; AF[2].y -= delta; } AF[1].x = AF[2].x; AF[1].y = AF[0].y; AF[3].x = AF[0].x; AF[3].y = AF[2].y; } /* Fill first */ if (tbl->data.bgcolor) { char* clrs[2]; int filled = setFill (job, tbl->data.bgcolor, tbl->data.gradientangle, tbl->data.style, clrs); if (tbl->data.style & ROUNDED){ round_corners (job, AF, 4, tbl->data.style, filled); } else gvrender_box(job, pts, filled); free (clrs[0]); } while (*cells) { emit_html_cell(job, *cells, env); cells++; } /* Draw table rules and border. * Draw after cells so we can draw over any fill. * At present, we set the penwidth to 1 for rules until we provide the calculations to take * into account wider rules. */ cells = tbl->u.n.cells; gvrender_set_penwidth(job, 1.0); while ((cp = *cells++)){ if (cp->ruled) emit_html_rules(job, cp, env, tbl->data.pencolor); } if (tbl->data.border) { if (tbl->data.style & ROUNDED) { char* color = (tbl->data.pencolor ? tbl->data.pencolor : DEFAULT_COLOR); gvrender_set_penwidth(job, tbl->data.border); gvrender_set_pencolor(job, color); round_corners (job, AF, 4, tbl->data.style, 0); } else doBorder(job, tbl->data.pencolor, tbl->data.border, pts); } if (anchor) endAnchor (job, &saved, 1); if (doAnchor && (job->flags & EMIT_CLUSTERS_LAST)) { if (initAnchor(job, env, &tbl->data, pts, &saved, 0)) endAnchor (job, &saved, 0); } if (tbl->font) popFontInfo(env, &savef); }