fixed table-columns are resized

13 views
Skip to first unread message

m.meier

unread,
Jun 16, 2011, 3:23:30 AM6/16/11
to tkhtml3, me...@fuh.de
Hello,

if i have a html-table like
----------------------------------------------
<TABLE width=100% >
<TR bgcolor=grey>
<TD width=120px>Column1 120px</TD>
<TD width=120px>Column2 120px</TD>
<TD width=120px>Column3 120px</TD>
<TD>Column4</TD>
</TR>
</TABLE>
----------------------------------------------

all the columns (and not only the last) are resized if the widget ist
smaller then it should be.

To fix this i patched htmltable.c:

...
/* Allocate pixels to explicit width columns */
#if 20110615
for (ii = 0; ii < pData->nCol; ii++) {
if (aReqWidth[ii].eType == CELL_WIDTH_PIXELS) {
int iReq = MAX(0, aReqWidth[ii].x.iVal - aWidth[ii]);
aWidth[ii] += iReq;
iRemaining -= iReq;
}
}
#else
if (iRemaining > 0) {
for (ii = 0; ii < pData->nCol; ii++) {
if (aReqWidth[ii].eType == CELL_WIDTH_PIXELS) {
int iReq = MAX(0, aReqWidth[ii].x.iVal - aWidth[ii]);
aWidth[ii] += iReq;
iRemaining -= iReq;
}
}
}
#endif
...
assert(CELL_WIDTH_AUTO == 0);
assert(CELL_WIDTH_PIXELS == 1);
assert(CELL_WIDTH_PERCENT == 2);
for (jj = 0; iRemaining < 0 && jj < 3; jj++) {
#if 20110615
/*
------------------------------------------------------------ *
* Only reduce columns with CELL_WIDTH_AUTO or
CELL_WIDTH_PERCENT
*
------------------------------------------------------------ */
if (jj != CELL_WIDTH_AUTO || jj != CELL_WIDTH_PERCENT )
{
continue;
};
#endif
....


Here some tcl-Code to test:

-------------------------------------------------------------------------------
package require Tkhtml

html .h
grid .h -sticky nesw

grid columnconfigure . 0 -weight 1
grid rowconfigure . 0 -weight 1

set data "
<HTML>
<BODY >
<TABLE width=100% >
<TR bgcolor=grey>
<TD width=120px>Column1 120px</TD>
<TD width=120px>Column2 120px</TD>
<TD width=120px>Column3 120px</TD>
<TD >Column4</TD>
</TR>
</TABLE>
</BODY></HTML>
"

.h parse -final $data
-------------------------------------------------------------------------------

And then resize the html-widget.


Shall i commit this fix to htmltable.c? Where? How?


Matthias






jemptymethod

unread,
Jun 17, 2011, 4:53:48 AM6/17/11
to tkhtml3
On Jun 16, 3:23 am, "m.meier" <me...@fuh-e.de> wrote:
> Hello,
>
> if i have a html-table like
> ----------------------------------------------
> <TABLE  width=100% >
> <TR bgcolor=grey>
> <TD width=120px>Column1 120px</TD>
> <TD width=120px>Column2 120px</TD>
> <TD width=120px>Column3 120px</TD>
> <TD>Column4</TD>
> </TR>
> </TABLE>
> ----------------------------------------------
>
> all the columns (and not only the last) are resized if the widget ist
> smaller then it should be.
>
> To fix this i patched htmltable.c:
>
snip
>
> Shall i commit this fix to htmltable.c? Where? How?

I'll look into the mechanics of committing the fix, starting this
weekend. Timing is good for me, I have made some significant initial
strides as to creating an ereader based on Hv3
Reply all
Reply to author
Forward
0 new messages