diff --git a/ChangeLog b/ChangeLog index b85d36c5c..8b7d6c04b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sun Apr 18 6:30:00 1999 Richard Frith-Macdonald + + Added all improvements from mgstep. + NSBrowser.m: ([-setPath]) implemented. + NSMatrix.m: ([-getRow:column:ofCell:]) bugfix. + 1999-04-14 Adam Fedor * Headers/gnustep/gui/NSScreen.h: Add initializer. diff --git a/Source/NSBrowser.m b/Source/NSBrowser.m index 3700c7c45..8d29efb2b 100644 --- a/Source/NSBrowser.m +++ b/Source/NSBrowser.m @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -1266,7 +1267,80 @@ - (BOOL)setPath: (NSString *)path { - return NO; + NSArray *subStrings = [path componentsSeparatedByString:_pathSeparator]; + unsigned numberOfSubStrings, i; + NSString *aStr; + + [self setLastColumn: 0]; + numberOfSubStrings = [subStrings count]; + + if (numberOfSubStrings <= 2) + { + // select root path + if ([[subStrings objectAtIndex:1] length] == 0) + { + [self scrollColumnsLeftBy: [_browserColumns count]]; + return YES; + } + } + + // cycle thru str's array created from path + for (i = 1; i < numberOfSubStrings; i++) + { + NSBrowserColumn *bc = [_browserColumns objectAtIndex: i-1]; + NSMatrix *matrix = [bc columnMatrix]; + NSArray *cells = [matrix cells]; + unsigned j, numOfRows = [cells count]; + NSBrowserCell *selectedCell = nil; + + aStr = [subStrings objectAtIndex: i]; + // find the cell in the browser matrix with the equal to aStr + for (j = 0; j < numOfRows; j++) + { + NSArray *cellRow = [cells objectAtIndex: j]; + unsigned numOfCols, k; + + numOfCols = [cellRow count]; + for (k = 0; k < numOfCols; k++) + { + NSString *cellString; + + selectedCell = [cellRow objectAtIndex:k]; + cellString = [selectedCell stringValue]; + + if ([cellString isEqualToString:aStr]) + { + int r, c; + + k = numOfCols; + j = numOfRows; + if ([matrix getRow:&r column:&c ofCell:selectedCell]) + [matrix selectCellAtRow:r column:c]; + else + selectedCell = nil; + } + } + } + // if unable to find a cell whose title matches aStr return NO + if (!selectedCell) + { + NSLog(@"NSBrowser: unable to find cell in matrix\n"); + return NO; + } + // if the cell is not a leaf add a column to the browser for it + if (![selectedCell isLeaf]) + { + [self addColumn]; + [self _performLoadOfColumn: i]; + [self setLastColumn: i]; + [self _adjustMatrixOfColumn: i]; + [self scrollColumnsRightBy: 1]; + } + else + break; + } + + return YES; } - (void)setPathSeparator: (NSString *)aString @@ -1498,7 +1572,6 @@ { id matrix; id sc = [bc columnScrollView]; - id oldm = [bc columnMatrix]; NSRect matrixRect = {{0, 0}, {100, 100}}; int i; @@ -1535,7 +1608,6 @@ { id matrix; id sc = [bc columnScrollView]; - id oldm = [bc columnMatrix]; NSRect matrixRect = {{0, 0}, {100, 100}}; // create a new col matrix diff --git a/Source/NSMatrix.m b/Source/NSMatrix.m index 57ba78853..ebbc1dd50 100644 --- a/Source/NSMatrix.m +++ b/Source/NSMatrix.m @@ -713,11 +713,15 @@ static int mouseDownFlags = 0; for (i = 0; i < numRows; i++) { - NSMutableArray* row = [cells objectAtIndex: i]; + NSMutableArray* rowArray = [cells objectAtIndex: i]; for (j = 0; j < numCols; j++) - if ([row objectAtIndex: j] == aCell) - return YES; + if ([rowArray objectAtIndex: j] == aCell) + { + *row = i; + *column = j; + return YES; + } } return NO;