-static void *
-tabi_render_init (struct som_entity *t_, struct outp_driver *driver,
- int hl, int hr, int ht, int hb)
-{
- const struct tab_table *t = t_->ext;
- struct tab_rendering *r;
- int col, row;
- int i;
-
- tab_offset (t_->ext, 0, 0);
-
- r = xmalloc (sizeof *r);
- r->table = t;
- r->driver = driver;
- r->w = xnmalloc (t->nc, sizeof *r->w);
- r->h = xnmalloc (t->nr, sizeof *r->h);
- r->hrh = xnmalloc (t->nr + 1, sizeof *r->hrh);
- r->wrv = xnmalloc (t->nc + 1, sizeof *r->wrv);
- r->l = hl;
- r->r = hr;
- r->t = ht;
- r->b = hb;
-
- /* Figure out sizes of rules. */
- for (row = 0; row <= t->nr; row++)
- {
- int width = 0;
- for (col = 0; col < t->nc; col++)
- {
- unsigned char rh = t->rh[col + row * t->cf];
- int w = driver->horiz_line_width[rule_to_spacing_type (rh)];
- if (w > width)
- width = w;
- }
- r->hrh[row] = width;
- }
-
- for (col = 0; col <= t->nc; col++)
- {
- int width = 0;
- for (row = 0; row < t->nr; row++)
- {
- unsigned char *rv = &t->rv[col + row * (t->cf + 1)];
- int w;
- if (*rv == UCHAR_MAX)
- *rv = col != 0 && col != t->nc ? TAL_GAP : TAL_0;
- w = driver->vert_line_width[rule_to_spacing_type (*rv)];
- if (w > width)
- width = w;
- }
- r->wrv[col] = width;
- }
-
- /* Determine row heights and columns widths. */
- for (i = 0; i < t->nr; i++)
- r->h[i] = -1;
- for (i = 0; i < t->nc; i++)
- r->w[i] = -1;
-
- t->dim (r, t->dim_aux);
-
- for (i = 0; i < t->nr; i++)
- if (r->h[i] < 0)
- error (0, 0, "height of table row %d is %d (not initialized?)",
- i, r->h[i]);
- for (i = 0; i < t->nc; i++)
- if (r->w[i] < 0)
- error (0, 0, "width of table column %d is %d (not initialized?)",
- i, r->w[i]);
-
- /* Add up header sizes. */
- for (i = 0, r->wl = r->wrv[0]; i < r->l; i++)
- r->wl += r->w[i] + r->wrv[i + 1];
- for (i = 0, r->ht = r->hrh[0]; i < r->t; i++)
- r->ht += r->h[i] + r->hrh[i + 1];
- for (i = t->nc - r->r, r->wr = r->wrv[i]; i < t->nc; i++)
- r->wr += r->w[i] + r->wrv[i + 1];
- for (i = t->nr - r->b, r->hb = r->hrh[i]; i < t->nr; i++)
- r->hb += r->h[i] + r->hrh[i + 1];
-
- /* Title. */
- if (!(t->flags & SOMF_NO_TITLE))
- r->ht += driver->font_height;
-
- return r;
-}
-
-static void
-tabi_render_free (void *r_)
-{
- struct tab_rendering *r = r_;
-
- free (r->w);
- free (r->h);
- free (r->hrh);
- free (r->wrv);
- free (r);
-}
-
-/* Return the horizontal and vertical size of the entire table,
- including headers, for the current output device, into HORIZ and
- VERT. */
-static void
-tabi_area (void *r_, int *horiz, int *vert)
-{
- struct tab_rendering *r = r_;
- const struct tab_table *t = r->table;
- int width, col;
- int height, row;
-
- width = 0;
- for (col = r->l + 1, width = r->wl + r->wr + r->w[t->l];
- col < t->nc - r->r; col++)
- width += r->w[col] + r->wrv[col];
- *horiz = width;
-
- height = 0;
- for (row = r->t + 1, height = r->ht + r->hb + r->h[t->t];
- row < t->nr - t->b; row++)
- height += r->h[row] + r->hrh[row];
- *vert = height;