Minor tidyup.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3836 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 1999-03-02 20:01:17 +00:00
parent 3fa6c2695a
commit ee0eb44c06

View file

@ -1003,22 +1003,17 @@ fprintf(stderr, " NSMatrix: selectTextAtRow --- ");
NSRectFill(rect); NSRectFill(rect);
} }
[self _getRow:&row1 column:&col1 [self _getRow: &row1 column: &col1 forPoint: rect.origin
forPoint:rect.origin above: NO right: NO isBetweenCells: NULL];
above:NO right:NO
isBetweenCells:NULL];
[self _getRow: &row2 column: &col2 [self _getRow: &row2 column: &col2
forPoint: NSMakePoint(NSMaxX(rect), NSMaxY(rect)) forPoint: NSMakePoint(NSMaxX(rect), NSMaxY(rect))
above:NO right:NO above: NO right: NO isBetweenCells: NULL];
isBetweenCells:NULL];
if (row1 < 0) if (row1 < 0)
row1 = 0; row1 = 0;
if (col1 < 0) if (col1 < 0)
col1 = 0; col1 = 0;
//NSLog (@"display cells between (%d, %d) and (%d, %d)",row1,col1, row2, col2);
/* Draw the cells within the drawing rectangle. */ /* Draw the cells within the drawing rectangle. */
for (i = row1; i <= row2 && i < numRows; i++) for (i = row1; i <= row2 && i < numRows; i++)
for (j = col1; j <= col2 && j < numCols; j++) for (j = col1; j <= col2 && j < numCols; j++)
@ -1028,21 +1023,35 @@ fprintf(stderr, " NSMatrix: selectTextAtRow --- ");
- (void) drawCellAtRow: (int)row column: (int)column - (void) drawCellAtRow: (int)row column: (int)column
{ {
NSCell *aCell = [self cellAtRow: row column: column]; NSCell *aCell = [self cellAtRow: row column: column];
if (aCell)
{
NSRect cellFrame = [self cellFrameAtRow: row column: column]; NSRect cellFrame = [self cellFrameAtRow: row column: column];
if (drawsCellBackground)
{
[cellBackgroundColor set];
NSRectFill(cellFrame);
}
[aCell drawWithFrame: cellFrame inView: self]; [aCell drawWithFrame: cellFrame inView: self];
} }
}
- (void)highlightCell:(BOOL)flag - (void) highlightCell: (BOOL)flag atRow: (int)row column: (int)column
atRow:(int)row
column:(int)column
{ {
NSCell *aCell = [self cellAtRow: row column: column]; NSCell *aCell = [self cellAtRow: row column: column];
if (aCell) if (aCell)
{ {
NSRect cellFrame = [self cellFrameAtRow: row column: column];
if (drawsCellBackground)
{
[cellBackgroundColor set];
NSRectFill(cellFrame);
}
[aCell highlight: flag [aCell highlight: flag
withFrame:[self cellFrameAtRow:row column:column] withFrame: cellFrame
inView: self]; inView: self];
} }
} }
@ -1481,20 +1490,15 @@ static MPoint anchor = {0, 0};
} }
- (void) updateCell: (NSCell*)aCell - (void) updateCell: (NSCell*)aCell
{ // attempt to update
int r, c; // only the cell and
// not the hole matrix
if([aCell isOpaque])
{ {
if([self getRow:&r column:&c ofCell:aCell]) int row, col;
{ NSRect rect;
[self setNeedsDisplayInRect:[self cellFrameAtRow:r column:c]];
return; if ([self getRow: &row column: &col ofCell: aCell] == NO)
} return; // Not a cell in this matrix - we can't update it.
}
// oh well, update the rect = [self cellFrameAtRow: row column: col];
[self setNeedsDisplay:YES]; // whole matrix [self setNeedsDisplayInRect: rect];
} }
- (BOOL)performKeyEquivalent:(NSEvent*)theEvent - (BOOL)performKeyEquivalent:(NSEvent*)theEvent
@ -1688,20 +1692,24 @@ fprintf(stderr, " NSMatrix: keyDown --- ");
SET_POINTER_VALUE(isBetweenCells, NO); SET_POINTER_VALUE(isBetweenCells, NO);
/* First check the limit cases */ /* First check the limit cases */
if (point.x > theBounds.size.width) { if (point.x > theBounds.size.width)
{
SET_POINTER_VALUE(column, numCols - 1); SET_POINTER_VALUE(column, numCols - 1);
colReady = YES; colReady = YES;
} }
else if (point.x < 0) { else if (point.x < 0)
{
SET_POINTER_VALUE(column, 0); SET_POINTER_VALUE(column, 0);
colReady = YES; colReady = YES;
} }
if (point.y > theBounds.size.height) { if (point.y > theBounds.size.height)
{
SET_POINTER_VALUE(row, numRows - 1); SET_POINTER_VALUE(row, numRows - 1);
rowReady = YES; rowReady = YES;
} }
else if (point.y < 0) { else if (point.y < 0)
{
SET_POINTER_VALUE(row, 0); SET_POINTER_VALUE(row, 0);
rowReady = YES; rowReady = YES;
} }
@ -1709,7 +1717,8 @@ fprintf(stderr, " NSMatrix: keyDown --- ");
if (rowReady && colReady) if (rowReady && colReady)
return NO; return NO;
if (!rowReady) { if (!rowReady)
{
int approxRow = point.y / (cellSize.height + intercell.height); int approxRow = point.y / (cellSize.height + intercell.height);
float approxRowsHeight = approxRow * (cellSize.height + intercell.height); float approxRowsHeight = approxRow * (cellSize.height + intercell.height);
@ -1722,22 +1731,24 @@ fprintf(stderr, " NSMatrix: keyDown --- ");
if (aboveRequired && betweenRows) if (aboveRequired && betweenRows)
approxRow++; approxRow++;
#if HAS_FLIPPED_VIEWS #if HAS_FLIPPED_VIEWS == 0
SET_POINTER_VALUE(row, approxRow); approxRow = numRows - approxRow - 1;
#else
SET_POINTER_VALUE(row, numRows - approxRow - 1);
#endif #endif
if (*row < 0) { if (approxRow < 0)
*row = -1; {
approxRow = -1;
rowReady = YES; rowReady = YES;
} }
else if (*row >= numRows) { else if (approxRow >= numRows)
*row = numRows - 1; {
approxRow = numRows - 1;
rowReady = YES; rowReady = YES;
} }
SET_POINTER_VALUE(row, approxRow);
} }
if (!colReady) { if (!colReady)
{
int approxCol = point.x / (cellSize.width + intercell.width); int approxCol = point.x / (cellSize.width + intercell.width);
float approxColsWidth = approxCol * (cellSize.width + intercell.width); float approxColsWidth = approxCol * (cellSize.width + intercell.width);
@ -1750,15 +1761,17 @@ fprintf(stderr, " NSMatrix: keyDown --- ");
if (rightRequired && betweenCols) if (rightRequired && betweenCols)
approxCol++; approxCol++;
if (approxCol < 0)
{
approxCol = -1;
colReady = YES;
}
else if (approxCol >= numCols)
{
approxCol = numCols - 1;
colReady = YES;
}
SET_POINTER_VALUE(column, approxCol); SET_POINTER_VALUE(column, approxCol);
if (*column < 0) {
*column = -1;
colReady = YES;
}
else if (*column >= numCols) {
*column = numCols - 1;
colReady = YES;
}
} }
/* If the point is outside the matrix bounds return NO */ /* If the point is outside the matrix bounds return NO */