From 5e7e2be35383d6fcd7524cee0cbc3f5c29db6e4a Mon Sep 17 00:00:00 2001 From: erg Date: Fri, 4 Feb 2011 18:52:31 +0000 Subject: [PATCH] Initial implementation of rounded corners for tables --- lib/common/htmllex.c | 14 ++++++++++++++ lib/common/htmltable.c | 22 ++++++++++++++++++---- lib/common/htmltable.h | 1 + 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/lib/common/htmllex.c b/lib/common/htmllex.c index 99eac0392..b8be61f4e 100644 --- a/lib/common/htmllex.c +++ b/lib/common/htmllex.c @@ -135,6 +135,19 @@ static int portfn(htmldata_t * p, char *v) return 0; } +static int stylefn(htmltbl_t * p, char *v) +{ + int rv = 0; + char c = toupper(*v); + if ((c == 'R') && !strcasecmp(v + 1, "OUNDED")) + p->style = ROUNDED; + else { + agerr(AGWARN, "Illegal value %s for STYLE - ignored\n", v); + rv = 1; + } + return rv; +} + static int targetfn(htmldata_t * p, char *v) { p->target = strdup(v); @@ -404,6 +417,7 @@ static attr_item tbl_items[] = { {"href", (attrFn) hreffn}, {"id", (attrFn) idfn}, {"port", (attrFn) portfn}, + {"style", (attrFn) stylefn}, {"target", (attrFn) targetfn}, {"title", (attrFn) titlefn}, {"tooltip", (attrFn) titlefn}, diff --git a/lib/common/htmltable.c b/lib/common/htmltable.c index edb1ffd70..677f9f530 100644 --- a/lib/common/htmltable.c +++ b/lib/common/htmltable.c @@ -372,11 +372,25 @@ emit_html_tbl(GVJ_t * job, htmltbl_t * tbl, htmlenv_t * env) else anchor = 0; - if (tbl->data.bgcolor) - doFill(job, tbl->data.bgcolor, pts); + if (tbl->style & ROUNDED) { + pointf AF[4]; + char* color = (tbl->data.pencolor ? tbl->data.pencolor : DEFAULT_COLOR); + AF[0] = pts.LL; + AF[2] = pts.UR; + AF[1].x = AF[2].x; + AF[1].y = AF[0].y; + AF[3].x = AF[0].x; + AF[3].y = AF[2].y; + round_corners (job, tbl->data.bgcolor, color, AF, 4, tbl->style, + (tbl->data.bgcolor != NULL)); + } + else { + if (tbl->data.bgcolor) + doFill(job, tbl->data.bgcolor, pts); - if (tbl->data.border) - doBorder(job, tbl->data.pencolor, tbl->data.border, pts); + if (tbl->data.border) + doBorder(job, tbl->data.pencolor, tbl->data.border, pts); + } while (*cells) { emit_html_cell(job, *cells, env); diff --git a/lib/common/htmltable.h b/lib/common/htmltable.h index 5ae805cba..7185d8470 100644 --- a/lib/common/htmltable.h +++ b/lib/common/htmltable.h @@ -105,6 +105,7 @@ extern "C" { int rc; /* number of rows */ int cc; /* number of columns */ htmlfont_t *font; /* font info */ + unsigned char style; }; struct htmllabel_t { -- 2.40.0