Example #1
0
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);
}
Example #2
0
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);
}