discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problems with NSMatrix insertColumn and GS vs Mac difference


From: Fred Kiefer
Subject: Re: problems with NSMatrix insertColumn and GS vs Mac difference
Date: Sat, 8 Aug 2015 00:13:40 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0

I looked at the GNUstep implementation and at the Cocoa documentation
and the GNUstep code is clearly wrong. Most likely the old documentation
wasn't as clear as the new one.

What we should do here is only expand the matrix if the column index is
bigger (or equal) than the old number of columns. This makes the code a
lot easier, as we don't need that rotation bit.
We also shouldn't use the provided cells, if there are too few of them.

This rewrite is of course also needed for rows and we should figure out,
if the _renewRows:... method could be simplified given that change. I
hope to find time to make this change on Sunday, but wouldn't complain
much if somebody beats me on that.

Fred

Am 29.07.2015 um 12:31 schrieb Riccardo Mottola:
> Hi,
> 
> I want to display a sort of "list" using a single-row NSMatrix. I add
> all cells at once.
> 
> On Mac, I have the following code, each time I update the list:
> 
> 
>   [legendMatrix removeColumn:0];
> <...>
>   [legendMatrix renewRows:[legendCellArray count] columns:1]; /* This is
> needed on Mac to resize the matrix before inserting the new column */
>   [legendMatrix insertColumn:0 withCells:legendCellArray];
>   [legendMatrix sizeToCells];
> 
> "renewRows" is absolutely needed, or insertColumn will crash. Do you
> think this code is correct? It appears to work fine
> 
> On GNUstep, this gives me second, empty column at the right of the
> column with the legendCellArray items.
> On gnustep I can remove renewRows and everything works fine.
> 
> Before saying this is a bug, I ask if the code looks sound to you.
> 
> "insertColumn" always confuses me. The Doc says:
> f column is greater than the number of columns in the receiver, enough
> columns are created to expand the receiver to be column columns wide.
> newCells should either be empty or contain a sufficient number of cells
> to fill each new column. If newCells is nil or an array with no
> elements, the call is equivalent to calling insertColumn:. Extra cells
> are ignored, unless the matrix is empty. In that case, a matrix is
> created with one column and enough rows for all the elements of newCells.
> 
> If I have none, I'd expect it to insert one (like GNUstep) and not to
> crash, perhaps 0 is a special case?
> 
> 
> Thank you - Riccardo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]