diff --git a/ChangeLog b/ChangeLog index 260eb13e4..2827d49ff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +1999-09-06 Nicola Pero + + * Source/NSMatrix: Added missing method ([-sizeToFit]). + ([-deselectAllCells]): do nothing, as in MacOS-X, if mode is + NSRadioModeMatrix and empty selection is not allowed. + ([-selectCellAtRow:column:]): mark both the cells, newly selected + and deselected one, as needing redraw, not only the newly selected + cell. If row or column is negative, just deselect the currently + selected cell, as in MacOS-X. + Mon Sep 6 6:37:00 1999 Richard Frith-Macdonald * Source/NSWindow.m: added enable/disable flush fix from dawn. diff --git a/Source/NSMatrix.m b/Source/NSMatrix.m index e26d85d4a..2f9fb6d08 100644 --- a/Source/NSMatrix.m +++ b/Source/NSMatrix.m @@ -781,6 +781,9 @@ static int mouseDownFlags = 0; NSArray *row; NSCell *aCell; + if (!allowsEmptySelection && mode == NSRadioModeMatrix) + return; + for (i = 0; i < numRows; i++) { row = nil; @@ -800,9 +803,6 @@ static int mouseDownFlags = 0; } } } - - if (!allowsEmptySelection && mode == NSRadioModeMatrix) - [self selectCellAtRow: 0 column: 0]; } - (void) deselectSelectedCell @@ -852,15 +852,21 @@ static int mouseDownFlags = 0; { ((tMatrix)selectedCells)->matrix[selectedRow][selectedColumn] = NO; [selectedCell setState: 0]; + + [self setNeedsDisplayInRect: [self cellFrameAtRow: selectedRow + column: selectedColumn]]; } - selectedCell = aCell; - selectedRow = row; - selectedColumn = column; - ((tMatrix)selectedCells)->matrix[row][column] = YES; - [selectedCell setState: 1]; - - [self setNeedsDisplayInRect: [self cellFrameAtRow: row column: column]]; + if ((row >= 0) && (column >= 0)) + { + selectedCell = aCell; + selectedRow = row; + selectedColumn = column; + ((tMatrix)selectedCells)->matrix[row][column] = YES; + [selectedCell setState: 1]; + + [self setNeedsDisplayInRect: [self cellFrameAtRow: row column: column]]; + } } - (BOOL) selectCellWithTag: (int)anInt @@ -1181,6 +1187,28 @@ fprintf(stderr, " NSMatrix: selectTextAtRow --- "); [self setFrameSize: newSize]; } +- (void) sizeToFit +{ + NSSize newSize = NSZeroSize; + NSSize tmpSize; + NSMutableArray *row; + int i,j; + + for (i = 0; i < numRows; i++) + { + row = [cells objectAtIndex: i]; + for (j = 0; j < numCols; j++) + { + tmpSize = [[row objectAtIndex: j] cellSize]; + if (tmpSize.width > newSize.width) + newSize.width = tmpSize.width; + if (tmpSize.height > newSize.height) + newSize.height = tmpSize.height; + } + } + [self setCellSize: newSize]; +} + - (void) scrollCellToVisibleAtRow: (int)row column: (int)column { @@ -1997,6 +2025,7 @@ fprintf(stderr, " NSMatrix: selectTextAtRow --- "); return YES; } +// TODO: implement resize according to autosizesCells // // Methods that may not be needed FIX ME