From: Fernando Rodr�guez
Subject: How to model an html table?
Date: 
Message-ID: <n7b74t4s9v579b8rmp7lkroenr1flk22ko@4ax.com>
Hi!

	I need a set of classes to model an html table (actually it will be an
rtf table, but that's irrelevant). I was considering the table as a sequence
of row objects that contain a sequence of cell objects.

	The only problem is that the cell objects will have a width property
(just like the width attribute in html) that changes the width of nearby
cells. So, whenever a cell's width is changed it must check if the new value
is acceptable (to do this, it must know the width of the other cells) and
notify the nearby cells so they can change their width too.  

	What's the best design and algorithm to model this and avoid endless
recursive calls (a cell modifies it's neirbours widths who modify their own
neibours, etc...)? O:-)

	Is there any sample code I can take a look at? O:-)

TIA




//-----------------------------------------------
//	Fernando Rodriguez Romero
//
//	frr at mindless dot com
//------------------------------------------------

From: Jochen Schmidt
Subject: Re: How to model an html table?
Date: 
Message-ID: <920me7$5mhf6$1@ID-22205.news.dfncis.de>
Fernando Rodr�guez wrote:

> Hi!
> 
> I need a set of classes to model an html table (actually it will be an
> rtf table, but that's irrelevant). I was considering the table as a
> sequence of row objects that contain a sequence of cell objects.
> 
> The only problem is that the cell objects will have a width property
> (just like the width attribute in html) that changes the width of nearby
> cells. So, whenever a cell's width is changed it must check if the new
> value is acceptable (to do this, it must know the width of the other
> cells) and notify the nearby cells so they can change their width too.
> 
> What's the best design and algorithm to model this and avoid endless
> recursive calls (a cell modifies it's neirbours widths who modify their
> own neibours, etc...)? O:-)
> 
> Is there any sample code I can take a look at? O:-)

I have no example code, but the problem sounds similar to GUI-Object
layouting things I've done some time ago.
Each cell should have a method that calculates the cells width based on e.g.
the width property of this cells.
Each row has then a method that calls "cell-width" to each of it's cells, 
summing the values together. This would lead to an approach where the
table-width is mandated through the content-width.
To get a model that is a bit more like that you described, you could have a
"cell-width-changed" method in your row that is called whenever the cell 
changes. (The cell would have to know it's parent). This cell-width-changed
method could then recalculate the other cells appropriately.
To avoid an endless loop you could give your cells priorities or you could 
say that each cell has only a fixed amount of recalculations available or 
something similar.

Regards,
Jochen 

> 
> TIA
> 
> 
> 
> 
> //-----------------------------------------------
> //    Fernando Rodriguez Romero
> //
> //    frr at mindless dot com
> //------------------------------------------------
> 
From: Jochen Schmidt
Subject: Re: How to model an html table?
Date: 
Message-ID: <920u2c$5hpuj$1@ID-22205.news.dfncis.de>
You might try this as an algorithm:
In the beginning the cell-width of each cells is (/ table-width no-of-cells)
Go through the cells of the row from left to right.
If the chosen cell is a "fixed cell" (Cell with width-property set) then
Distribute delta-width = (- (init-width cell) (width cell)) equaly to both 
sides (If only the left (right) cell is a "variable" cell then the
complete delta-width goes to that. If neither the left nor the
right cell are "variable" then you have to change the table-width
(As an alternative you can try to find another variable-cell to be modified 
by searching to both directions)
If the chosen cell is a "variable-cell" then go to the next cell.

Regards,
Jochen
From: Kenny Tilton
Subject: Re: How to model an html table?
Date: 
Message-ID: <3A44D131.7A9A9F4F@nyc.rr.com>
I might have something that would help. But clarify for me:


>         The only problem is that the cell objects will have a width property
> (just like the width attribute in html) that changes the width of nearby
> cells. So, whenever a cell's width is changed it must check if the new value
> is acceptable (to do this, it must know the width of the other cells) and
> notify the nearby cells so they can change their width too.

Sorry, my HTML is weak. I can see how cells in a column have to have the same
width, but what is this about (I gather) neighbors to left and right? Is this
something like: I can grow, but the outer container has a fixed width, and my
neighbor to my right might have a minimum width, so I can grow only up to the
point where that minimum still obtains?

It sounds also from another post that if I cannot satisfy my desire for growth by
expanding to the right, possibly the neghbor to my left is above some declared
minimum and can be asked to shrink.

And since columns should be nice and neat, this really is a question about columns
having widths, minima, maxima... all derived by the max of the mins of the cells
in a column, and the min of the maxes?

t