//Determine vertical line coordinate and length
if ((cp->ruled & HTML_VRULE) && (cp->col + cp->cspan < cp->parent->cc)) {
if(cp->row == 0) { // first row
- // extend to table border and add half cell spacing
- base = cp->parent->data.border + cp->parent->data.space/2;
+ // extend to center of table border and add half cell spacing
+ base = cp->parent->data.border/2 + cp->parent->data.space/2;
rule_pt.y = pts.LL.y - cp->parent->data.space/2;
}
else if(cp->row + cp->rspan == cp->parent->rc){ // bottom row
- // extend to table border and add half cell spacing
- base = cp->parent->data.border + cp->parent->data.space/2;
+ // extend to center of table border and add half cell spacing
+ base = cp->parent->data.border/2 + cp->parent->data.space/2;
rule_pt.y = pts.LL.y - cp->parent->data.space/2 - base;
}
else {
//Determine the horizontal coordinate and length
if ((cp->ruled & HTML_HRULE) && (cp->row + cp->rspan < cp->parent->rc)) {
if(cp->col == 0) { // first column
- // extend to table border and add half cell spacing
- base = cp->parent->data.border + cp->parent->data.space/2;
- rule_pt.x = pts.LL.x - base - cp->parent->data.space/2;
+ // extend to center of table border and add half cell spacing
+ base = cp->parent->data.border/2 + cp->parent->data.space/2;
+ rule_pt.x = pts.LL.x - base - cp->parent->data.space/2;
}
else if(cp->col + cp->cspan == cp->parent->cc){ // last column
- // extend to table border and add half cell spacing
- base = cp->parent->data.border + cp->parent->data.space/2;
+ // extend to center of table border and add half cell spacing
+ base = cp->parent->data.border/2 + cp->parent->data.space/2;
rule_pt.x = pts.LL.x - cp->parent->data.space/2;
}
else {
anchor = 0;
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));
+ if(tbl->data.border == 0 ){ //no need to display border, just fill if required
+ if (tbl->data.bgcolor)
+ doFill(job, tbl->data.bgcolor, pts);
+ }
+ else {
+ 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;
+ gvrender_set_fillcolor(job, tbl->data.bgcolor); /* emit fill color */
+ gvrender_set_pencolor(job, color);
+ gvrender_rounded_box(job, AF, 4, (tbl->data.bgcolor != NULL), tbl->data.border);
+
+ }
}
else {
if (tbl->data.bgcolor)
}
//render table rules
while ((cp = *cells++)){
- if (cp->ruled) emit_html_rules(job, cp, env, tbl->data.bgcolor);
- }
+ if (cp->ruled) emit_html_rules(job, cp, env, tbl->data.pencolor);
+ }
cells = tbl->u.n.cells;
while (*cells) {
extern void gvrender_set_style(GVJ_t * job, char **s);
extern void gvrender_ellipse(GVJ_t * job, pointf * AF, int n, boolean filled);
extern void gvrender_polygon(GVJ_t * job, pointf * AF, int n, boolean filled);
+ extern void gvrender_rounded_box(GVJ_t * job, pointf * AF, int n, boolean filled, int border);
extern void gvrender_box(GVJ_t * job, boxf BF, boolean filled);
extern void gvrender_beziercurve(GVJ_t * job, pointf * AF, int n,
int arrow_at_start, int arrow_at_end, boolean filled);
/* storage for temporary hacks until client API is FP */
static pointf *AF;
static int sizeAF;
+#define PARAM_OFFSET 1000
/* end hack */
int gvrender_select(GVJ_t * job, const char *str)
}
}
+void gvrender_rounded_box(GVJ_t * job, pointf * af, int n, boolean filled, int border)
+{
+ gvrender_engine_t *gvre = job->render.engine;
+ int n_border;
+
+ //encode the border size within the point count parameter
+ //it has to be passed through polygon() to cairogen_rounded_rectangle()
+ n_border = border * PARAM_OFFSET + n;
+ if (gvre) {
+ if (gvre->polygon && job->obj->pen != PEN_NONE) {
+ if (job->flags & GVRENDER_DOES_TRANSFORM)
+ gvre->polygon(job, af, n_border, filled);
+ else {
+ if (sizeAF < n) {
+ sizeAF = n+10;
+ AF = grealloc(AF, sizeAF * sizeof(pointf));
+ }
+ gvrender_ptf_A(job, af, AF, n);
+ gvre->polygon(job, AF, n_border, filled);
+ }
+ }
+ }
+}
+
void gvrender_box(GVJ_t * job, boxf B, boolean filled)
{
pointf A[4];
} format_type;
#define ARRAY_SIZE(A) (sizeof(A)/sizeof(A[0]))
-
+#define RBCONST 12
+#define PARAM_OFFSET 1000
static double dashed[] = {6.};
static int dashed_len = ARRAY_SIZE(dashed);
cairo_stroke(cr);
}
+//create a rounded path and implement border width by setting line width
static void
-cairogen_polygon(GVJ_t * job, pointf * A, int n, int filled)
+cairogen_rounded_rectangle(GVJ_t * job, pointf * AF, int n, int filled, int border)
{
obj_state_t *obj = job->obj;
+ cairo_t *cr = (cairo_t *) job->context;
+ pointf p0, p1;
+ double d, dx, dy, radius;
+ double x,y,height,width;
+ int seg, sides;
+ double degrees = -(M_PI / 180.0); //sign inversion required due to y-coordinate inversion
+
+ radius = RBCONST;
+ sides = n;
+ for (seg = 0; seg < sides; seg++) {
+ p0 = AF[seg];
+ if (seg < sides - 1)
+ p1 = AF[seg + 1];
+ else
+ p1 = AF[0];
+ dx = p1.x - p0.x;
+ dy = p1.y - p0.y;
+ d = sqrt(dx * dx + dy * dy);
+ radius = MIN(radius, d / 3.0);
+ }
+
+
+ x = AF[0].x + border/2;
+ y = -AF[0].y - border/2;
+ width = AF[2].x - AF[0].x - border;
+ height = AF[2].y - AF[0].y - border;
+
+ cairogen_set_penstyle(job, cr);
+ cairogen_set_color(cr, &(obj->pencolor));
+
+ cairo_new_sub_path (cr);
+ cairo_arc (cr, x + width - radius, y - radius, radius,0 * degrees, -90 * degrees); //lower right
+ cairo_arc (cr, x + radius, y - radius, radius, -90 * degrees, 180 * degrees); //lower left
+ cairo_arc (cr, x + radius, y - height + radius, radius, 180 * degrees, 90 * degrees); //upper left
+ cairo_arc (cr, x + width - radius, y - height + radius, radius, 90 * degrees, 0 * degrees); //upper right
+ cairo_close_path (cr);
+
+
+ if (filled) {
+ cairogen_set_color(cr, &(obj->fillcolor));
+ cairo_fill_preserve(cr);
+ }
+
+ cairogen_set_color(cr, &(obj->pencolor));
+ cairo_set_line_width (cr, border);
+ cairo_stroke(cr);
+
+
+}
+
+static void
+cairogen_polygon(GVJ_t * job, pointf * A, int n, int filled)
+{
+
+//if a rounded rectangle is being rendered, extract the border
+//value that is encoded in the point count parameter
+if( n > PARAM_OFFSET){
+ int border = n/PARAM_OFFSET;
+ n = n%PARAM_OFFSET;
+ cairogen_rounded_rectangle(job, A, n, filled, border);
+ return;
+ }
+
+obj_state_t *obj = job->obj;
cairo_t *cr = (cairo_t *) job->context;
int i;