[comp.sys.next] Matrix: why homogeneous size?

jacob@gore.com (Jacob Gore) (08/29/89)

From class description of Matrix (SysRefMan 21-1):

	The Matrix Class allows creation of matrices of cells of the same
	or of different type.  The main restriction is that all cells must
	have the same size. 

Ugh...  I could see a conceptual reason (or, at least, an excuse) for this
restriction if the cells had to be of the same type.  But I think a much
more reasonable matrix class would be one where each row and each column
could be of different size, if necessary.  In other words, the restriction
should only be "that the width of all cells in any given column must be the
same, and the height of all cells in any given row must be the same".

I need such a class for displaying and editing a table.  Actually, in my
case, I can live with the restriction that all rows are the same height,
but not with having all columns be of the same width.

Is there a recommended way of doing this?  (I heard that somebody is
working on a spreadsheet... they aren't going to restrict all columns to
the same width, are they?)

Will Matrix in 1.0 still have the current homogeneous-size restriction?
Does anybody have a more general matrix class they can share (or at least
give some advice on creating one)?

Jacob
--
Jacob Gore	Jacob@Gore.Com		{nucsrl,boulder}!gore!jacob

ali@polya.Stanford.EDU (Ali T. Ozer) (08/31/89)

In article <130014@gore.com> jacob@gore.com (Jacob Gore) writes:
>From class description of Matrix (SysRefMan 21-1):
>	The Matrix Class allows creation of matrices of cells of the same
>	or of different type.  The main restriction is that all cells must
>	have the same size. 
>Ugh...  I could see a conceptual reason (or, at least, an excuse) for this
>restriction if the cells had to be of the same type.  But I think a much
>more reasonable matrix class would be one where each row and each column
>could be of different size, if necessary.  In other words, the restriction
>should only be "that the width of all cells in any given column must be the
>same, and the height of all cells in any given row must be the same".

Looks like the Matrix class is not the way to go; it doesn't seem to
be possible to subclass Matrix to get the behaviour you want. At least
not easily. The above restriction is indeed true --- the Matrix class is
supposed provide an efficient way to collect many controls together, and
one of the tradeoffs is the requirement that all cells be the same size.
This is a design decision that will remain true in 1.0.

If you want table behaviour, with different width columns, then you
might get away with using a number of matrices, and maybe creating a class
to manage such a "Table" structure. Of course, you will lose the 
tracking feature (between columns), and such a class will be less
efficient than using just a single matrix. (Might not be a problem for
fixed sized tables with a small number of columns.)

Ali Ozer, NeXT Developer Support
aozer@NeXT.com