コード例 #1
0
ファイル: htmltable.c プロジェクト: TidyHuang/vizgems
static void
emit_html_cell(GVJ_t * job, htmlcell_t * cp, htmlenv_t * env)
{
    htmlmap_data_t saved;
    boxf pts = cp->data.box;
    pointf pos = env->pos;
    int inAnchor, doAnchor = (cp->data.href || cp->data.target);

    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))
	inAnchor = initAnchor(job, env, &cp->data, pts, &saved, 1);
    else
	inAnchor = 0;

    if (cp->data.bgcolor) {
	char* clrs[2];
	int filled = setFill (job, cp->data.bgcolor, cp->data.gradientangle, cp->data.style, clrs);
	gvrender_box(job, pts, filled);
	free (clrs[0]);
    }

    if (cp->data.border)
	doBorder(job, cp->data.pencolor, cp->data.border, 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 (inAnchor)
	endAnchor (job, &saved, 1);

    if (doAnchor && (job->flags & EMIT_CLUSTERS_LAST)) {
	if (initAnchor(job, env, &cp->data, pts, &saved, 0))
	    endAnchor (job, &saved, 0);
    }
}
コード例 #2
0
ファイル: htmltable.c プロジェクト: Chaduke/bah.mod
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);
}
コード例 #3
0
ファイル: htmltable.c プロジェクト: Chaduke/bah.mod
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(); */
}
コード例 #4
0
ファイル: htmltable.c プロジェクト: TidyHuang/vizgems
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);
}