[w3m-dev 03898] Re: table rendering
* table.c (check_relative_width): added (set_table_matrix): use check_relative_width From: Akinori Ito <aito@fw.ipsj.or.jp>
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
2003-05-14 Akinori Ito <aito@fw.ipsj.or.jp>
|
||||||
|
|
||||||
|
* [w3m-dev 03898] Re: table rendering
|
||||||
|
* table.c (check_relative_width): added
|
||||||
|
(set_table_matrix): use check_relative_width
|
||||||
|
|
||||||
2003-05-13 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
|
2003-05-13 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
|
||||||
|
|
||||||
* [w3m-dev 03896] html_quote in textarea in frame
|
* [w3m-dev 03896] html_quote in textarea in frame
|
||||||
@@ -7809,4 +7815,4 @@ a * [w3m-dev 03276] compile error on EWS4800
|
|||||||
* release-0-2-1
|
* release-0-2-1
|
||||||
* import w3m-0.2.1
|
* import w3m-0.2.1
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.835 2003/05/12 16:33:16 ukai Exp $
|
$Id: ChangeLog,v 1.836 2003/05/13 17:08:19 ukai Exp $
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: table.c,v 1.40 2003/02/20 15:39:22 ukai Exp $ */
|
/* $Id: table.c,v 1.41 2003/05/13 17:08:20 ukai Exp $ */
|
||||||
/*
|
/*
|
||||||
* HTML table
|
* HTML table
|
||||||
*/
|
*/
|
||||||
@@ -3490,6 +3490,81 @@ set_table_matrix0(struct table *t, int maxwidth)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
check_relative_width(struct table *t,int maxwidth)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
double rel_total = 0;
|
||||||
|
int size = t->maxcol+1;
|
||||||
|
double *rcolwidth = New_N(double,size);
|
||||||
|
struct table_cell *cell = &t->cell;
|
||||||
|
int n_leftcol = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < size; i++)
|
||||||
|
rcolwidth[i] = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < size; i++) {
|
||||||
|
if (t->fixed_width[i] < 0)
|
||||||
|
rcolwidth[i] = -(double)t->fixed_width[i]/100.0;
|
||||||
|
else if (t->fixed_width[i] > 0)
|
||||||
|
rcolwidth[i] = (double)t->fixed_width[i]/maxwidth;
|
||||||
|
else
|
||||||
|
n_leftcol++;
|
||||||
|
}
|
||||||
|
for (i = 0; i <= cell->maxcell; i++) {
|
||||||
|
if (cell->fixed_width[i] < 0) {
|
||||||
|
double w = -(double)cell->fixed_width[i]/100.0;
|
||||||
|
double r;
|
||||||
|
int j,k;
|
||||||
|
int n_leftcell = 0;
|
||||||
|
k = cell->col[i];
|
||||||
|
r = 0.0;
|
||||||
|
for (j = 1; j < cell->colspan[i]; j++) {
|
||||||
|
if (rcolwidth[j+k] > 0)
|
||||||
|
r += rcolwidth[j+k];
|
||||||
|
else
|
||||||
|
n_leftcell++;
|
||||||
|
}
|
||||||
|
if (w < r || (w == r && n_leftcell > 0)) {
|
||||||
|
cell->fixed_width[i] = -100*r;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (j = 1; j < cell->colspan[i]; j++) {
|
||||||
|
if (rcolwidth[j+k] == 0)
|
||||||
|
rcolwidth[j+k] = (w-r)/n_leftcell;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (cell->fixed_width[i] > 0) {
|
||||||
|
/* todo */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* sanity check */
|
||||||
|
for (i = 0; i < size; i++)
|
||||||
|
rel_total += rcolwidth[i];
|
||||||
|
|
||||||
|
if ((n_leftcol == 0 && rel_total < 0.9) || 1.1 < rel_total) {
|
||||||
|
for (i = 0; i < size; i++) {
|
||||||
|
rcolwidth[i] /= rel_total;
|
||||||
|
}
|
||||||
|
for (i = 0; i < size; i++) {
|
||||||
|
if (t->fixed_width[i] < 0)
|
||||||
|
t->fixed_width[i] = -rcolwidth[i]*100;
|
||||||
|
}
|
||||||
|
for (i = 0; i <= cell->maxcell; i++) {
|
||||||
|
if (cell->fixed_width[i] < 0) {
|
||||||
|
double r;
|
||||||
|
int j,k;
|
||||||
|
k = cell->col[i];
|
||||||
|
r = 0.0;
|
||||||
|
for (j = 1; j < cell->colspan[i]; j++)
|
||||||
|
r += rcolwidth[j+k];
|
||||||
|
cell->fixed_width[i] = -r*100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
set_table_matrix(struct table *t, int width)
|
set_table_matrix(struct table *t, int width)
|
||||||
{
|
{
|
||||||
@@ -3510,6 +3585,8 @@ set_table_matrix(struct table *t, int width)
|
|||||||
v_set_val(t->vector, i, 0.);
|
v_set_val(t->vector, i, 0.);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_relative_width(t,width);
|
||||||
|
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
if (t->fixed_width[i] > 0) {
|
if (t->fixed_width[i] > 0) {
|
||||||
a = max(t->fixed_width[i], t->minimum_width[i]);
|
a = max(t->fixed_width[i], t->minimum_width[i]);
|
||||||
|
|||||||
Reference in New Issue
Block a user