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

@ -744,7 +744,7 @@ static int mouseDownFlags = 0;
}
}
if(!allowsEmptySelection) // if we don't allow an
if (!allowsEmptySelection) // if we don't allow an
[self selectCellAtRow:0 column:0]; // empty selection
}
@ -990,7 +990,7 @@ fprintf(stderr, " NSMatrix: selectTextAtRow --- ");
[cellPrototype setScrollable:flag];
}
- (void)drawRect:(NSRect)rect
- (void) drawRect: (NSRect)rect
{
int i, j;
int row1, col1; // The cell at the upper left corner
@ -1003,47 +1003,56 @@ fprintf(stderr, " NSMatrix: selectTextAtRow --- ");
NSRectFill(rect);
}
[self _getRow:&row1 column:&col1
forPoint:rect.origin
above:NO right:NO
isBetweenCells:NULL];
[self _getRow:&row2 column:&col2
forPoint:NSMakePoint(NSMaxX(rect), NSMaxY(rect))
above:NO right:NO
isBetweenCells:NULL];
[self _getRow: &row1 column: &col1 forPoint: rect.origin
above: NO right: NO isBetweenCells: NULL];
[self _getRow: &row2 column: &col2
forPoint: NSMakePoint(NSMaxX(rect), NSMaxY(rect))
above: NO right: NO isBetweenCells: NULL];
if (row1 < 0)
row1 = 0;
if (col1 < 0)
col1 = 0;
//NSLog (@"display cells between (%d, %d) and (%d, %d)",row1,col1, row2, col2);
/* Draw the cells within the drawing rectangle. */
for (i = row1; i <= row2 && i < numRows; i++)
for (j = col1; j <= col2 && j < numCols; j++)
[self drawCellAtRow:i column:j];
[self drawCellAtRow: i column: j];
}
- (void)drawCellAtRow:(int)row column:(int)column
- (void) drawCellAtRow: (int)row column: (int)column
{
NSCell *aCell = [self cellAtRow:row column:column];
NSRect cellFrame = [self cellFrameAtRow:row column:column];
[aCell drawWithFrame:cellFrame inView:self];
}
- (void)highlightCell:(BOOL)flag
atRow:(int)row
column:(int)column
{
NSCell *aCell = [self cellAtRow:row column:column];
NSCell *aCell = [self cellAtRow: row column: column];
if (aCell)
{
[aCell highlight:flag
withFrame:[self cellFrameAtRow:row column:column]
inView:self];
NSRect cellFrame = [self cellFrameAtRow: row column: column];
if (drawsCellBackground)
{
[cellBackgroundColor set];
NSRectFill(cellFrame);
}
[aCell drawWithFrame: cellFrame inView: self];
}
}
- (void) highlightCell: (BOOL)flag atRow: (int)row column: (int)column
{
NSCell *aCell = [self cellAtRow: row column: column];
if (aCell)
{
NSRect cellFrame = [self cellFrameAtRow: row column: column];
if (drawsCellBackground)
{
[cellBackgroundColor set];
NSRectFill(cellFrame);
}
[aCell highlight: flag
withFrame: cellFrame
inView: self];
}
}
@ -1111,7 +1120,7 @@ fprintf(stderr, " NSMatrix: selectTextAtRow --- ");
[self sendAction];
}
- (BOOL)acceptsFirstMouse:(NSEvent*)theEvent
- (BOOL) acceptsFirstMouse: (NSEvent*)theEvent
{
return mode == NSListModeMatrix ? NO : YES;
}
@ -1303,7 +1312,7 @@ static MPoint anchor = {0, 0};
selectedRow = row; // until the cursor either
selectedColumn = column; // leaves the cellframe or
// NSLeftMouseUp occurs
if([aCell trackMouse:lastEvent
if ([aCell trackMouse:lastEvent
inRect:rect
ofView:self
untilMouseUp:YES]) // YES if mouse
@ -1318,7 +1327,7 @@ static MPoint anchor = {0, 0};
[aCell highlight: YES withFrame: rect inView: self];
[window flushWindow];
if([aCell trackMouse:lastEvent
if ([aCell trackMouse:lastEvent
inRect:rect
ofView:self
untilMouseUp:YES]) // YES if mouse
@ -1333,7 +1342,7 @@ static MPoint anchor = {0, 0};
if (previousCell == aCell) // more than one cell
break; // to be selected
if(selectedCell)
if (selectedCell)
{
[selectedCell setState:0]; // deselect previously
if (!previousCell) // selected cell
@ -1444,7 +1453,7 @@ static MPoint anchor = {0, 0};
switch (mode) // Finish the selection
{ // process
case NSRadioModeMatrix:
if(selectedCell)
if (selectedCell)
[selectedCell highlight:NO withFrame:rect inView:self];
case NSListModeMatrix:
[self setNeedsDisplayInRect:rect]; // not needed by XRAW
@ -1454,9 +1463,9 @@ static MPoint anchor = {0, 0};
break;
}
if(selectedCell)
if (selectedCell)
{ // send single click action
if(!(selectedCellTarget = [selectedCell target]))
if (!(selectedCellTarget = [selectedCell target]))
{ // selected cell has no target so send single
if (target) // click action to matrix's (self's) target
[target performSelector:action withObject:self];
@ -1480,21 +1489,16 @@ static MPoint anchor = {0, 0};
[lastEvent release];
}
- (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])
{
[self setNeedsDisplayInRect:[self cellFrameAtRow:r column:c]];
- (void) updateCell: (NSCell*)aCell
{
int row, col;
NSRect rect;
return;
}
}
// oh well, update the
[self setNeedsDisplay:YES]; // whole matrix
if ([self getRow: &row column: &col ofCell: aCell] == NO)
return; // Not a cell in this matrix - we can't update it.
rect = [self cellFrameAtRow: row column: col];
[self setNeedsDisplayInRect: rect];
}
- (BOOL)performKeyEquivalent:(NSEvent*)theEvent
@ -1674,12 +1678,12 @@ fprintf(stderr, " NSMatrix: keyDown --- ");
Note that the cell numbering is flipped relative to the coordinate system.
*/
- (BOOL)_getRow:(int*)row
column:(int*)column
forPoint:(NSPoint)point
above:(BOOL)aboveRequired
right:(BOOL)rightRequired
isBetweenCells:(BOOL*)isBetweenCells
- (BOOL) _getRow: (int*)row
column: (int*)column
forPoint: (NSPoint)point
above: (BOOL)aboveRequired
right: (BOOL)rightRequired
isBetweenCells: (BOOL*)isBetweenCells
{
BOOL rowReady = NO, colReady = NO;
BOOL betweenRows = NO, betweenCols = NO;
@ -1688,20 +1692,24 @@ fprintf(stderr, " NSMatrix: keyDown --- ");
SET_POINTER_VALUE(isBetweenCells, NO);
/* First check the limit cases */
if (point.x > theBounds.size.width) {
if (point.x > theBounds.size.width)
{
SET_POINTER_VALUE(column, numCols - 1);
colReady = YES;
}
else if (point.x < 0) {
else if (point.x < 0)
{
SET_POINTER_VALUE(column, 0);
colReady = YES;
}
if (point.y > theBounds.size.height) {
if (point.y > theBounds.size.height)
{
SET_POINTER_VALUE(row, numRows - 1);
rowReady = YES;
}
else if (point.y < 0) {
else if (point.y < 0)
{
SET_POINTER_VALUE(row, 0);
rowReady = YES;
}
@ -1709,7 +1717,8 @@ fprintf(stderr, " NSMatrix: keyDown --- ");
if (rowReady && colReady)
return NO;
if (!rowReady) {
if (!rowReady)
{
int approxRow = point.y / (cellSize.height + intercell.height);
float approxRowsHeight = approxRow * (cellSize.height + intercell.height);
@ -1722,22 +1731,24 @@ fprintf(stderr, " NSMatrix: keyDown --- ");
if (aboveRequired && betweenRows)
approxRow++;
#if HAS_FLIPPED_VIEWS
SET_POINTER_VALUE(row, approxRow);
#else
SET_POINTER_VALUE(row, numRows - approxRow - 1);
#if HAS_FLIPPED_VIEWS == 0
approxRow = numRows - approxRow - 1;
#endif
if (*row < 0) {
*row = -1;
if (approxRow < 0)
{
approxRow = -1;
rowReady = YES;
}
else if (*row >= numRows) {
*row = numRows - 1;
else if (approxRow >= numRows)
{
approxRow = numRows - 1;
rowReady = YES;
}
SET_POINTER_VALUE(row, approxRow);
}
if (!colReady) {
if (!colReady)
{
int approxCol = point.x / (cellSize.width + intercell.width);
float approxColsWidth = approxCol * (cellSize.width + intercell.width);
@ -1750,15 +1761,17 @@ fprintf(stderr, " NSMatrix: keyDown --- ");
if (rightRequired && betweenCols)
approxCol++;
if (approxCol < 0)
{
approxCol = -1;
colReady = YES;
}
else if (approxCol >= numCols)
{
approxCol = numCols - 1;
colReady = YES;
}
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 */