git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5534 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 1999-12-16 04:53:50 +00:00
parent 56f71a1eec
commit ba0cb39440
3 changed files with 183 additions and 177 deletions

View file

@ -190,11 +190,11 @@ static SEL getSel = @selector(objectAtIndex:);
[self setFrame: frameRect]; [self setFrame: frameRect];
if ((numCols > 0) && (numRows > 0)) if ((numCols > 0) && (numRows > 0))
cellSize = NSMakeSize (frameRect.size.width/numCols, cellSize = NSMakeSize (frameRect.size.width/numCols,
frameRect.size.height/numRows); frameRect.size.height/numRows);
else else
cellSize = NSMakeSize (DEFAULT_CELL_WIDTH, DEFAULT_CELL_HEIGHT); cellSize = NSMakeSize (DEFAULT_CELL_WIDTH, DEFAULT_CELL_HEIGHT);
intercell = NSMakeSize(1, 1); intercell = NSMakeSize(1, 1);
_tabKeyTraversesCells = YES; _tabKeyTraversesCells = YES;
[self setBackgroundColor: [NSColor controlBackgroundColor]]; [self setBackgroundColor: [NSColor controlBackgroundColor]];
@ -800,7 +800,7 @@ static SEL getSel = @selector(objectAtIndex:);
{ {
if (!_selectedCell || (!allowsEmptySelection && (mode == NSRadioModeMatrix))) if (!_selectedCell || (!allowsEmptySelection && (mode == NSRadioModeMatrix)))
return; return;
selectedCells[_selectedRow][_selectedColumn] = NO; selectedCells[_selectedRow][_selectedColumn] = NO;
[_selectedCell setState: 0]; [_selectedCell setState: 0];
_selectedCell = nil; _selectedCell = nil;
@ -828,7 +828,7 @@ static SEL getSel = @selector(objectAtIndex:);
} }
} }
[self display]; [self setNeedsDisplay: YES];
} }
- (void) selectCellAtRow: (int)row column: (int)column - (void) selectCellAtRow: (int)row column: (int)column
@ -843,7 +843,7 @@ static SEL getSel = @selector(objectAtIndex:);
{ {
selectedCells[_selectedRow][_selectedColumn] = NO; selectedCells[_selectedRow][_selectedColumn] = NO;
[_selectedCell setState: 0]; [_selectedCell setState: 0];
[self setNeedsDisplayInRect: [self cellFrameAtRow: _selectedRow [self setNeedsDisplayInRect: [self cellFrameAtRow: _selectedRow
column: _selectedColumn]]; column: _selectedColumn]];
} }
@ -854,7 +854,7 @@ static SEL getSel = @selector(objectAtIndex:);
_selectedColumn = column; _selectedColumn = column;
selectedCells[row][column] = YES; selectedCells[row][column] = YES;
[_selectedCell setState: 1]; [_selectedCell setState: 1];
[self setNeedsDisplayInRect: [self cellFrameAtRow: row column: column]]; [self setNeedsDisplayInRect: [self cellFrameAtRow: row column: column]];
} }
} }
@ -1061,7 +1061,6 @@ static SEL getSel = @selector(objectAtIndex:);
startIndex: selectx startIndex: selectx
endIndex: selecty]; endIndex: selecty];
} }
[self display];
} }
- (id) cellAtRow: (int)row - (id) cellAtRow: (int)row
@ -1122,12 +1121,12 @@ static SEL getSel = @selector(objectAtIndex:);
if (window) if (window)
s = [window keyViewSelectionDirection]; s = [window keyViewSelectionDirection];
switch (s) switch (s)
{ {
// window selecting backwards // window selecting backwards
case NSSelectingPrevious: case NSSelectingPrevious:
[self _selectPreviousSelectableCellBeforeRow: numRows [self _selectPreviousSelectableCellBeforeRow: numRows
column: numCols]; column: numCols];
break; break;
// Window selecting forward // Window selecting forward
@ -1149,7 +1148,7 @@ static SEL getSel = @selector(objectAtIndex:);
break; break;
} }
} }
- (id) selectTextAtRow: (int)row column: (int)column - (id) selectTextAtRow: (int)row column: (int)column
{ {
if (row < 0 || row >= numRows || column < 0 || column >= numCols) if (row < 0 || row >= numRows || column < 0 || column >= numCols)
@ -1157,7 +1156,7 @@ static SEL getSel = @selector(objectAtIndex:);
if ([cells[row][column] isSelectable] == NO) if ([cells[row][column] isSelectable] == NO)
return nil; return nil;
if (_textObject) if (_textObject)
{ {
if (_selectedCell == cells[row][column]) if (_selectedCell == cells[row][column])
@ -1171,16 +1170,16 @@ static SEL getSel = @selector(objectAtIndex:);
[self abortEditing]; [self abortEditing];
} }
} }
// Now _textObject == nil // Now _textObject == nil
{ {
NSText *t = [window fieldEditor: YES NSText *t = [window fieldEditor: YES
forObject: self]; forObject: self];
if ([t superview] != nil) if ([t superview] != nil)
if ([t resignFirstResponder] == NO) if ([t resignFirstResponder] == NO)
return nil; return nil;
_selectedCell = cells[row][column]; _selectedCell = cells[row][column];
_selectedRow = row; _selectedRow = row;
_selectedColumn = column; _selectedColumn = column;
@ -1203,7 +1202,7 @@ static SEL getSel = @selector(objectAtIndex:);
} }
- (id) nextText - (id) nextText
{ {
return _nextKeyView; return _nextKeyView;
} }
@ -1216,8 +1215,8 @@ static SEL getSel = @selector(objectAtIndex:);
{ {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
NSDictionary *d; NSDictionary *d;
d = [NSDictionary dictionaryWithObject:[aNotification object] d = [NSDictionary dictionaryWithObject:[aNotification object]
forKey: @"NSFieldEditor"]; forKey: @"NSFieldEditor"];
[nc postNotificationName: NSControlTextDidBeginEditingNotification [nc postNotificationName: NSControlTextDidBeginEditingNotification
object: self object: self
@ -1228,8 +1227,8 @@ static SEL getSel = @selector(objectAtIndex:);
{ {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
NSDictionary *d; NSDictionary *d;
d = [NSDictionary dictionaryWithObject: [aNotification object] d = [NSDictionary dictionaryWithObject: [aNotification object]
forKey: @"NSFieldEditor"]; forKey: @"NSFieldEditor"];
[nc postNotificationName: NSControlTextDidChangeNotification [nc postNotificationName: NSControlTextDidChangeNotification
object: self object: self
@ -1244,7 +1243,7 @@ static SEL getSel = @selector(objectAtIndex:);
[self validateEditing]; [self validateEditing];
d = [NSDictionary dictionaryWithObject: [aNotification object] d = [NSDictionary dictionaryWithObject: [aNotification object]
forKey: @"NSFieldEditor"]; forKey: @"NSFieldEditor"];
[nc postNotificationName: NSControlTextDidEndEditingNotification [nc postNotificationName: NSControlTextDidEndEditingNotification
object: self object: self
@ -1285,11 +1284,11 @@ static SEL getSel = @selector(objectAtIndex:);
- (BOOL) textShouldBeginEditing: (NSText *)textObject - (BOOL) textShouldBeginEditing: (NSText *)textObject
{ {
if (_delegate && [_delegate respondsToSelector: if (_delegate && [_delegate respondsToSelector:
@selector(control:textShouldBeginEditing:)]) @selector(control:textShouldBeginEditing:)])
return [_delegate control: self return [_delegate control: self
textShouldBeginEditing: textObject]; textShouldBeginEditing: textObject];
else else
return YES; return YES;
} }
@ -1300,11 +1299,11 @@ static SEL getSel = @selector(objectAtIndex:);
[self sendAction: _errorAction to: [self target]]; [self sendAction: _errorAction to: [self target]];
return NO; return NO;
} }
if ([_delegate respondsToSelector: if ([_delegate respondsToSelector:
@selector(control:textShouldEndEditing:)]) @selector(control:textShouldEndEditing:)])
{ {
if ([_delegate control: self if ([_delegate control: self
textShouldEndEditing: aTextObject] == NO) textShouldEndEditing: aTextObject] == NO)
{ {
NSBeep (); NSBeep ();
@ -1366,7 +1365,7 @@ static SEL getSel = @selector(objectAtIndex:);
{ {
for (j = 0; j < numCols; j++) for (j = 0; j < numCols; j++)
{ {
tmpSize = [cells[i][j] cellSize]; tmpSize = [cells[i][j] cellSize];
if (tmpSize.width > newSize.width) if (tmpSize.width > newSize.width)
newSize.width = tmpSize.width; newSize.width = tmpSize.width;
if (tmpSize.height > newSize.height) if (tmpSize.height > newSize.height)
@ -1569,7 +1568,7 @@ static SEL getSel = @selector(objectAtIndex:);
{ {
if (mode == NSListModeMatrix) if (mode == NSListModeMatrix)
return NO; return NO;
else else
return YES; return YES;
} }
@ -1719,12 +1718,12 @@ static SEL getSel = @selector(objectAtIndex:);
NSApplication *app = [NSApplication sharedApplication]; NSApplication *app = [NSApplication sharedApplication];
static MPoint anchor = {0, 0}; static MPoint anchor = {0, 0};
lastLocation = [self convertPoint: lastLocation lastLocation = [self convertPoint: lastLocation
fromView: nil]; fromView: nil];
// If mouse down was on a selectable cell, start editing/selecting. // If mouse down was on a selectable cell, start editing/selecting.
if([self getRow: &row if([self getRow: &row
column: &column column: &column
forPoint: lastLocation]) forPoint: lastLocation])
{ {
if ([cells[row][column] isSelectable]) if ([cells[row][column] isSelectable])
@ -1744,7 +1743,7 @@ static SEL getSel = @selector(objectAtIndex:);
_selectedRow = row; _selectedRow = row;
_selectedColumn = column; _selectedColumn = column;
_textObject = [_selectedCell setUpFieldEditorAttributes: t]; _textObject = [_selectedCell setUpFieldEditorAttributes: t];
[_selectedCell editWithFrame: [self cellFrameAtRow: row [_selectedCell editWithFrame: [self cellFrameAtRow: row
column: column] column: column]
inView: self inView: self
editor: _textObject editor: _textObject
@ -1753,7 +1752,7 @@ static SEL getSel = @selector(objectAtIndex:);
return; return;
} }
} }
// Paranoia check -- _textObject should already be nil, since we // Paranoia check -- _textObject should already be nil, since we
// accept first responder, so NSWindow should have already given // accept first responder, so NSWindow should have already given
// us first responder status (thus already ending editing with _textObject). // us first responder status (thus already ending editing with _textObject).
@ -1773,7 +1772,7 @@ static SEL getSel = @selector(objectAtIndex:);
} }
if ((mode != NSTrackModeMatrix) && (mode != NSHighlightModeMatrix)) if ((mode != NSTrackModeMatrix) && (mode != NSHighlightModeMatrix))
[NSEvent startPeriodicEventsAfterDelay: 0.05 [NSEvent startPeriodicEventsAfterDelay: 0.05
withPeriod: 0.05]; withPeriod: 0.05];
ASSIGN(lastEvent, theEvent); ASSIGN(lastEvent, theEvent);
@ -1785,20 +1784,20 @@ static SEL getSel = @selector(objectAtIndex:);
{ {
BOOL shouldProceedEvent = NO; BOOL shouldProceedEvent = NO;
onCell = [self getRow: &row onCell = [self getRow: &row
column: &column column: &column
forPoint: lastLocation]; forPoint: lastLocation];
if (onCell) if (onCell)
{ {
aCell = [self cellAtRow: row aCell = [self cellAtRow: row
column: column]; column: column];
rect = [self cellFrameAtRow: row rect = [self cellFrameAtRow: row
column: column]; column: column];
if (aCell != previousCell) if (aCell != previousCell)
{ {
switch (mode) switch (mode)
{ {
case NSTrackModeMatrix: case NSTrackModeMatrix:
// in Track mode the cell should track the mouse // in Track mode the cell should track the mouse
// until the cursor either leaves the cellframe or // until the cursor either leaves the cellframe or
// NSLeftMouseUp occurs // NSLeftMouseUp occurs
@ -1812,7 +1811,7 @@ static SEL getSel = @selector(objectAtIndex:);
done = YES; done = YES;
break; break;
case NSHighlightModeMatrix: case NSHighlightModeMatrix:
// Highlight mode is like Track mode except that // Highlight mode is like Track mode except that
// the cell is lit before begins tracking and // the cell is lit before begins tracking and
// unlit afterwards // unlit afterwards
@ -1834,7 +1833,7 @@ static SEL getSel = @selector(objectAtIndex:);
[window flushWindow]; [window flushWindow];
break; break;
case NSRadioModeMatrix: case NSRadioModeMatrix:
// Radio mode allows no more than one cell to be selected // Radio mode allows no more than one cell to be selected
if (previousCell == aCell) if (previousCell == aCell)
break; break;
@ -1861,7 +1860,7 @@ static SEL getSel = @selector(objectAtIndex:);
[window flushWindow]; [window flushWindow];
break; break;
case NSListModeMatrix: case NSListModeMatrix:
// List mode allows multiple cells to be selected // List mode allows multiple cells to be selected
{ {
unsigned modifiers = [lastEvent modifierFlags]; unsigned modifiers = [lastEvent modifierFlags];
@ -1928,7 +1927,7 @@ static SEL getSel = @selector(objectAtIndex:);
dequeue: YES]; dequeue: YES];
switch ([theEvent type]) switch ([theEvent type])
{ {
case NSPeriodic: case NSPeriodic:
NSDebugLog(@"NSMatrix: got NSPeriodic event\n"); NSDebugLog(@"NSMatrix: got NSPeriodic event\n");
shouldProceedEvent = YES; shouldProceedEvent = YES;
break; break;
@ -1936,10 +1935,10 @@ static SEL getSel = @selector(objectAtIndex:);
// Track and Highlight modes do not use // Track and Highlight modes do not use
// periodic events so we must break out // periodic events so we must break out
// and check if the mouse is in a cell // and check if the mouse is in a cell
case NSLeftMouseUp: case NSLeftMouseUp:
done = YES; done = YES;
case NSLeftMouseDown: case NSLeftMouseDown:
default: default:
if ((mode == NSTrackModeMatrix) if ((mode == NSTrackModeMatrix)
|| (mode == NSHighlightModeMatrix)) || (mode == NSHighlightModeMatrix))
shouldProceedEvent = YES; shouldProceedEvent = YES;
@ -1955,14 +1954,14 @@ static SEL getSel = @selector(objectAtIndex:);
switch (mode) switch (mode)
{ {
case NSRadioModeMatrix: case NSRadioModeMatrix:
if (_selectedCell != nil) if (_selectedCell != nil)
[_selectedCell highlight: NO withFrame: rect inView: self]; [_selectedCell highlight: NO withFrame: rect inView: self];
case NSListModeMatrix: case NSListModeMatrix:
[self setNeedsDisplayInRect: rect]; [self setNeedsDisplayInRect: rect];
[window flushWindow]; [window flushWindow];
case NSHighlightModeMatrix: case NSHighlightModeMatrix:
case NSTrackModeMatrix: case NSTrackModeMatrix:
break; break;
} }
@ -2052,7 +2051,7 @@ static SEL getSel = @selector(objectAtIndex:);
for (j = 0; j < numCols; j++) for (j = 0; j < numCols; j++)
{ {
NSCell *aCell = cells[i][j]; NSCell *aCell = cells[i][j];
[aCell resetCursorRect: [self cellFrameAtRow: i column: j] [aCell resetCursorRect: [self cellFrameAtRow: i column: j]
inView: self]; inView: self];
} }
@ -2088,7 +2087,7 @@ static SEL getSel = @selector(objectAtIndex:);
cellClass = class; cellClass = class;
if (cellClass == nil) if (cellClass == nil)
{ {
cellClass = defaultCellClass; cellClass = defaultCellClass;
} }
cellNew = [cellClass methodForSelector: allocSel]; cellNew = [cellClass methodForSelector: allocSel];
cellInit = [cellClass instanceMethodForSelector: initSel]; cellInit = [cellClass instanceMethodForSelector: initSel];
@ -2314,11 +2313,11 @@ static SEL getSel = @selector(objectAtIndex:);
NSSize change; NSSize change;
int nc = numCols; int nc = numCols;
int nr = numRows; int nr = numRows;
[super resizeWithOldSuperviewSize: oldSize]; [super resizeWithOldSuperviewSize: oldSize];
newBoundsSize = bounds.size; newBoundsSize = bounds.size;
change.height = newBoundsSize.height - oldBoundsSize.height; change.height = newBoundsSize.height - oldBoundsSize.height;
change.width = newBoundsSize.width - oldBoundsSize.width; change.width = newBoundsSize.width - oldBoundsSize.width;
@ -2329,8 +2328,9 @@ static SEL getSel = @selector(objectAtIndex:);
if (nr <= 0) nr = 1; if (nr <= 0) nr = 1;
if (cellSize.height == 0) if (cellSize.height == 0)
{ {
cellSize.height = oldBoundsSize.height - ((nr - 1) * intercell.height); cellSize.height = oldBoundsSize.height
cellSize.height = cellSize.height / nr; - ((nr - 1) * intercell.height);
cellSize.height = cellSize.height / nr;
} }
change.height = change.height / nr; change.height = change.height / nr;
cellSize.height += change.height; cellSize.height += change.height;
@ -2339,11 +2339,12 @@ static SEL getSel = @selector(objectAtIndex:);
} }
if (change.width != 0) if (change.width != 0)
{ {
if (nc <= 0) nc = 1; if (nc <= 0) nc = 1;
if (cellSize.width == 0) if (cellSize.width == 0)
{ {
cellSize.width = oldBoundsSize.width - ((nc - 1) * intercell.width); cellSize.width = oldBoundsSize.width
cellSize.width = cellSize.width / nc; - ((nc - 1) * intercell.width);
cellSize.width = cellSize.width / nc;
} }
change.width = change.width / nc; change.width = change.width / nc;
cellSize.width += change.width; cellSize.width += change.width;
@ -2355,12 +2356,12 @@ static SEL getSel = @selector(objectAtIndex:);
{ {
if (change.height != 0) if (change.height != 0)
{ {
if (nr > 1) if (nr > 1)
{ {
if (intercell.height == 0) if (intercell.height == 0)
{ {
intercell.height = oldBoundsSize.height - (nr * cellSize.height); intercell.height = oldBoundsSize.height - (nr * cellSize.height);
intercell.height = intercell.height / (nr - 1); intercell.height = intercell.height / (nr - 1);
} }
change.height = change.height / (nr - 1); change.height = change.height / (nr - 1);
intercell.height += change.height; intercell.height += change.height;
@ -2370,18 +2371,18 @@ static SEL getSel = @selector(objectAtIndex:);
} }
if (change.width != 0) if (change.width != 0)
{ {
if (nc > 1) if (nc > 1)
{ {
if (intercell.width == 0) if (intercell.width == 0)
{ {
intercell.width = oldBoundsSize.width - (nc * cellSize.width); intercell.width = oldBoundsSize.width - (nc * cellSize.width);
intercell.width = intercell.width / (nc - 1); intercell.width = intercell.width / (nc - 1);
} }
change.width = change.width / (nc - 1); change.width = change.width / (nc - 1);
intercell.width += change.width; intercell.width += change.width;
if (intercell.width < 0) if (intercell.width < 0)
intercell.width = 0; intercell.width = 0;
} }
} }
} }
[self setNeedsDisplay: YES]; [self setNeedsDisplay: YES];
@ -2414,7 +2415,7 @@ static SEL getSel = @selector(objectAtIndex:);
_textObject = nil; _textObject = nil;
return YES; return YES;
} }
else else
return NO; return NO;
} }
@ -2426,7 +2427,7 @@ static SEL getSel = @selector(objectAtIndex:);
return nil; return nil;
} }
- (void) validateEditing - (void) validateEditing
{ {
if (_textObject) if (_textObject)
[_selectedCell setStringValue: [_textObject text]]; [_selectedCell setStringValue: [_textObject text]];
@ -2480,7 +2481,7 @@ static SEL getSel = @selector(objectAtIndex:);
} }
/* /*
* Update matrix dimension before we actually change it - so that * Update matrix dimension before we actually change it - so that
* makeCellAtRow:column: diesn't think we are trying to make a cell * makeCellAtRow:column: diesn't think we are trying to make a cell
* outside the array bounds. * outside the array bounds.
* Our implementation doesn't care, but a subclass might use * Our implementation doesn't care, but a subclass might use
@ -2633,17 +2634,19 @@ static SEL getSel = @selector(objectAtIndex:);
} }
// Otherwise, make the big cycle. // Otherwise, make the big cycle.
for (i = row + 1; i < numRows; i++) for (i = row + 1; i < numRows; i++)
for (j = 0; j < numCols; j++) {
{ for (j = 0; j < numCols; j++)
if ([cells[i][j] isSelectable]) {
{ if ([cells[i][j] isSelectable])
_selectedCell = [self selectTextAtRow: i {
column: j]; _selectedCell = [self selectTextAtRow: i
_selectedRow = i; column: j];
_selectedColumn = j; _selectedRow = i;
return YES; _selectedColumn = j;
} return YES;
} }
}
}
return NO; return NO;
} }
-(BOOL) _selectPreviousSelectableCellBeforeRow: (int)row -(BOOL) _selectPreviousSelectableCellBeforeRow: (int)row
@ -2667,17 +2670,19 @@ static SEL getSel = @selector(objectAtIndex:);
} }
// Otherwise, make the big cycle. // Otherwise, make the big cycle.
for (i = row - 1; i > -1; i--) for (i = row - 1; i > -1; i--)
for (j = numCols - 1; j > -1; j--) {
{ for (j = numCols - 1; j > -1; j--)
if ([cells[i][j] isSelectable]) {
{ if ([cells[i][j] isSelectable])
_selectedCell = [self selectTextAtRow: i {
column: j]; _selectedCell = [self selectTextAtRow: i
_selectedRow = i; column: j];
_selectedColumn = j; _selectedRow = i;
return YES; _selectedColumn = j;
} return YES;
} }
}
}
return NO; return NO;
} }
@end @end

View file

@ -55,7 +55,7 @@
#include <AppKit/NSScrollView.h> #include <AppKit/NSScrollView.h>
#include <AppKit/NSClipView.h> #include <AppKit/NSClipView.h>
struct NSWindow_struct struct NSWindow_struct
{ {
@defs(NSWindow) @defs(NSWindow)
}; };
@ -238,10 +238,10 @@ GSSetDragTypes(NSView* obj, NSArray *types)
{ {
if (_nextKeyView) if (_nextKeyView)
[_nextKeyView setPreviousKeyView: nil]; [_nextKeyView setPreviousKeyView: nil];
if (_previousKeyView) if (_previousKeyView)
[_previousKeyView setNextKeyView: nil]; [_previousKeyView setNextKeyView: nil];
RELEASE(matrixToWindow); RELEASE(matrixToWindow);
RELEASE(matrixFromWindow); RELEASE(matrixFromWindow);
RELEASE(frameMatrix); RELEASE(frameMatrix);
@ -615,7 +615,7 @@ GSSetDragTypes(NSView* obj, NSArray *types)
if (newSize.height < 0) if (newSize.height < 0)
{ {
NSWarnMLog(@"given negative height", 0); NSWarnMLog(@"given negative height", 0);
newSize.height = 0; newSize.height = 0;
} }
if (coordinates_valid) if (coordinates_valid)
(*invalidateImp)(self, invalidateSel); (*invalidateImp)(self, invalidateSel);
@ -1277,7 +1277,7 @@ GSSetDragTypes(NSView* obj, NSArray *types)
DPSgsave(ctxt); DPSgsave(ctxt);
matrix = [self _matrixToWindow]; matrix = [self _matrixToWindow];
[matrix concat]; [matrix concat];
/* /*
* Clipping - set viewclip to the visible rectangle - which will never be * Clipping - set viewclip to the visible rectangle - which will never be
* greater than the bounds of the view. * greater than the bounds of the view.
@ -1327,7 +1327,7 @@ GSSetDragTypes(NSView* obj, NSArray *types)
if (flush) if (flush)
{ {
rect = [[window_t->rectsBeingDrawn lastObject] rectValue]; rect = [[window_t->rectsBeingDrawn lastObject] rectValue];
window_t->rectNeedingFlush = window_t->rectNeedingFlush =
NSUnionRect(window_t->rectNeedingFlush, rect); NSUnionRect(window_t->rectNeedingFlush, rect);
window_t->_f.needs_flush = YES; window_t->_f.needs_flush = YES;
} }
@ -1353,7 +1353,7 @@ GSSetDragTypes(NSView* obj, NSArray *types)
return NO; return NO;
} }
- (void) display - (void) display
{ {
if (window) if (window)
{ {
@ -1766,11 +1766,11 @@ GSSetDragTypes(NSView* obj, NSArray *types)
NSPoint aPoint = vRect.origin; NSPoint aPoint = vRect.origin;
BOOL shouldScroll = NO; BOOL shouldScroll = NO;
if (vRect.size.width == 0 && vRect.size.height == 0) if (vRect.size.width == 0 && vRect.size.height == 0)
return NO; return NO;
if (!(NSMinX(vRect) <= NSMinX(aRect) if (!(NSMinX(vRect) <= NSMinX(aRect)
&& (NSMaxX(vRect) >= NSMaxX(aRect)))) && (NSMaxX(vRect) >= NSMaxX(aRect))))
{ {
shouldScroll = YES; shouldScroll = YES;
if (aRect.origin.x < vRect.origin.x) if (aRect.origin.x < vRect.origin.x)
@ -1784,8 +1784,8 @@ GSSetDragTypes(NSView* obj, NSArray *types)
} }
} }
if (!(NSMinY(vRect) <= NSMinY(aRect) if (!(NSMinY(vRect) <= NSMinY(aRect)
&& (NSMaxY(vRect) >= NSMaxY(aRect)))) && (NSMaxY(vRect) >= NSMaxY(aRect))))
{ {
shouldScroll = YES; shouldScroll = YES;
if (aRect.origin.y < vRect.origin.y) if (aRect.origin.y < vRect.origin.y)
@ -1982,7 +1982,7 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
NSView *v; NSView *v;
v = findByTag(array[i], aTag, &l); v = findByTag(array[i], aTag, &l);
if (v != nil && l < level) if (v != nil && l < level)
{ {
view = v; view = v;
@ -2128,13 +2128,13 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
_nextKeyView = nil; _nextKeyView = nil;
return; return;
} }
if ([aView isKindOfClass: viewClass]) if ([aView isKindOfClass: viewClass])
{ {
// As an exception, we do not retain aView, to avoid retain loops // As an exception, we do not retain aView, to avoid retain loops
// (the simplest being a view retaining and being retained // (the simplest being a view retaining and being retained
// by another view), which prevents objects from being ever // by another view), which prevents objects from being ever
// deallocated. To understand how we manage without retaining // deallocated. To understand how we manage without retaining
// _nextKeyView, see [NSView -dealloc]. // _nextKeyView, see [NSView -dealloc].
_nextKeyView = aView; _nextKeyView = aView;
if ([aView previousKeyView] != self) if ([aView previousKeyView] != self)
@ -2152,10 +2152,10 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
theView = _nextKeyView; theView = _nextKeyView;
while (1) while (1)
{ {
if ([theView acceptsFirstResponder] || (theView == nil) if ([theView acceptsFirstResponder] || (theView == nil)
|| (theView == self)) || (theView == self))
return theView; return theView;
theView = [theView nextKeyView]; theView = [theView nextKeyView];
} }
} }
@ -2166,7 +2166,7 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
_previousKeyView = nil; _previousKeyView = nil;
return; return;
} }
if ([aView isKindOfClass: viewClass]) if ([aView isKindOfClass: viewClass])
{ {
_previousKeyView = aView; _previousKeyView = aView;
@ -2179,16 +2179,16 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
return _previousKeyView; return _previousKeyView;
} }
- (NSView *) previousValidKeyView - (NSView *) previousValidKeyView
{ {
NSView *theView; NSView *theView;
theView = _previousKeyView; theView = _previousKeyView;
while (1) while (1)
{ {
if ([theView acceptsFirstResponder] || (theView == nil) if ([theView acceptsFirstResponder] || (theView == nil)
|| (theView == self)) || (theView == self))
return theView; return theView;
theView = [theView previousKeyView]; theView = [theView previousKeyView];
} }
} }
@ -2434,7 +2434,7 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
NSRect rect; NSRect rect;
NSEnumerator *e; NSEnumerator *e;
NSView *sub; NSView *sub;
NSArray *subs; NSArray *subs;
self = [super initWithCoder: aDecoder]; self = [super initWithCoder: aDecoder];

View file

@ -306,10 +306,10 @@ static NSMapTable* windowmaps = NULL;
/* rectBeingDrawn is variable used to optimize flushing the backing store. /* rectBeingDrawn is variable used to optimize flushing the backing store.
It is set by NSGraphicsContext during a lockFocus to tell NSWindow what It is set by NSGraphicsContext during a lockFocus to tell NSWindow what
part a view is drawing in, so NSWindow only has to flush that portion */ part a view is drawing in, so NSWindow only has to flush that portion */
rectsBeingDrawn = RETAIN([NSMutableArray arrayWithCapacity: 10]); rectsBeingDrawn = RETAIN([NSMutableArray arrayWithCapacity: 10]);
DPSwindow(context, NSMinX(contentRect), NSMinY(contentRect), DPSwindow(context, NSMinX(contentRect), NSMinY(contentRect),
NSWidth(contentRect), NSHeight(contentRect), NSWidth(contentRect), NSHeight(contentRect),
bufferingType, &window_num); bufferingType, &window_num);
DPSstylewindow(context, aStyle, window_num); DPSstylewindow(context, aStyle, window_num);
DPSsetwindowlevel(context, [self level], window_num); DPSsetwindowlevel(context, [self level], window_num);
@ -490,13 +490,13 @@ static NSMapTable* windowmaps = NULL;
*/ */
- (void) endEditingFor: (id)anObject - (void) endEditingFor: (id)anObject
{ {
NSText *t = [self fieldEditor: NO NSText *t = [self fieldEditor: NO
forObject: anObject]; forObject: anObject];
if (t && (first_responder == t)) if (t && (first_responder == t))
{ {
[[NSNotificationCenter defaultCenter] [[NSNotificationCenter defaultCenter]
postNotificationName: NSTextDidEndEditingNotification postNotificationName: NSTextDidEndEditingNotification
object: t]; object: t];
[t setText: @""]; [t setText: @""];
[t setDelegate: nil]; [t setDelegate: nil];
@ -533,9 +533,9 @@ static NSMapTable* windowmaps = NULL;
{ {
ASSIGN(_windowController, windowController); ASSIGN(_windowController, windowController);
} }
- (id) windowController - (id) windowController
{ {
return _windowController; return _windowController;
} }
@ -754,7 +754,7 @@ static NSMapTable* windowmaps = NULL;
performSelector: @selector(_handleWindowNeedsDisplay:) performSelector: @selector(_handleWindowNeedsDisplay:)
target: self target: self
argument: nil argument: nil
order: 600000 order: 600000
modes: [NSArray arrayWithObjects: modes: [NSArray arrayWithObjects:
NSDefaultRunLoopMode, NSDefaultRunLoopMode,
NSModalPanelRunLoopMode, NSModalPanelRunLoopMode,
@ -956,7 +956,7 @@ static NSMapTable* windowmaps = NULL;
- (void) setResizeIncrements: (NSSize)aSize - (void) setResizeIncrements: (NSSize)aSize
{ {
increments = aSize; increments = aSize;
DPSsetresizeincrements(GSCurrentContext(), aSize.width, aSize.height, DPSsetresizeincrements(GSCurrentContext(), aSize.width, aSize.height,
window_num); window_num);
} }
@ -1079,11 +1079,11 @@ static NSMapTable* windowmaps = NULL;
i = [rectsBeingDrawn count]; i = [rectsBeingDrawn count];
while (i-- > 0) while (i-- > 0)
{ {
rectNeedingFlush = NSUnionRect(rectNeedingFlush, rectNeedingFlush = NSUnionRect(rectNeedingFlush,
[[rectsBeingDrawn objectAtIndex: i] rectValue]); [[rectsBeingDrawn objectAtIndex: i] rectValue]);
} }
DPSflushwindowrect(context, DPSflushwindowrect(context,
NSMinX(rectNeedingFlush), NSMinY(rectNeedingFlush), NSMinX(rectNeedingFlush), NSMinY(rectNeedingFlush),
NSWidth(rectNeedingFlush), NSHeight(rectNeedingFlush), NSWidth(rectNeedingFlush), NSHeight(rectNeedingFlush),
window_num); window_num);
@ -1486,7 +1486,7 @@ resetCursorRectsForView(NSView *theView)
} }
- (void) setInitialFirstResponder: (NSView *)aView - (void) setInitialFirstResponder: (NSView *)aView
{ {
if ([aView isKindOfClass: viewClass]) if ([aView isKindOfClass: viewClass])
{ {
if (_initial_first_responder) if (_initial_first_responder)
@ -1496,25 +1496,25 @@ resetCursorRectsForView(NSView *theView)
} }
- (NSView *) initialFirstResponder - (NSView *) initialFirstResponder
{ {
return _initial_first_responder; return _initial_first_responder;
} }
- (void) keyDown: (NSEvent *)theEvent - (void) keyDown: (NSEvent *)theEvent
{ {
unsigned int key_code = [theEvent keyCode]; unsigned int key_code = [theEvent keyCode];
// If this is a TAB or TAB+SHIFT event, move to the next key view // If this is a TAB or TAB+SHIFT event, move to the next key view
if (key_code == 0x09) if (key_code == 0x09)
{ {
if ([theEvent modifierFlags] & NSShiftKeyMask) if ([theEvent modifierFlags] & NSShiftKeyMask)
[self selectPreviousKeyView: self]; [self selectPreviousKeyView: self];
else else
[self selectNextKeyView: self]; [self selectNextKeyView: self];
return; return;
} }
// If this is an ESC event, abort modal loop // If this is an ESC event, abort modal loop
if (key_code == 0x1b) if (key_code == 0x1b)
{ {
NSApplication *app = [NSApplication sharedApplication]; NSApplication *app = [NSApplication sharedApplication];
@ -1526,25 +1526,25 @@ resetCursorRectsForView(NSView *theView)
return; return;
} }
// Try to process the event as a key equivalent // Try to process the event as a key equivalent
// without Command having being pressed // without Command having being pressed
{ {
NSEvent *new_event NSEvent *new_event
= [NSEvent keyEventWithType: [theEvent type] = [NSEvent keyEventWithType: [theEvent type]
location: NSZeroPoint location: NSZeroPoint
modifierFlags: ([theEvent modifierFlags] | NSCommandKeyMask) modifierFlags: ([theEvent modifierFlags] | NSCommandKeyMask)
timestamp: [theEvent timestamp] timestamp: [theEvent timestamp]
windowNumber: [theEvent windowNumber] windowNumber: [theEvent windowNumber]
context: [theEvent context] context: [theEvent context]
characters: [theEvent characters] characters: [theEvent characters]
charactersIgnoringModifiers: [theEvent charactersIgnoringModifiers: [theEvent
charactersIgnoringModifiers] charactersIgnoringModifiers]
isARepeat: [theEvent isARepeat] isARepeat: [theEvent isARepeat]
keyCode: key_code]; keyCode: key_code];
if ([self performKeyEquivalent: new_event]) if ([self performKeyEquivalent: new_event])
return; return;
} }
// Otherwise, pass the event up // Otherwise, pass the event up
[super keyDown: theEvent]; [super keyDown: theEvent];
} }
@ -1919,7 +1919,7 @@ resetCursorRectsForView(NSView *theView)
case NSMouseExited: // Mouse exited case NSMouseExited: // Mouse exited
break; break;
case NSKeyDown: case NSKeyDown:
/* /*
* Save the first responder so that the key up goes to it and not a * Save the first responder so that the key up goes to it and not a
* possible new first responder. * possible new first responder.
@ -2018,18 +2018,18 @@ resetCursorRectsForView(NSView *theView)
dragInfo = [GSCurrentContext() _dragInfo]; dragInfo = [GSCurrentContext() _dragInfo];
if (_lastDragView && _lastDragView != v && _f.accepts_drag) if (_lastDragView && _lastDragView != v && _f.accepts_drag)
{ {
GSPerformVoidDragSelector(_lastDragView, GSPerformVoidDragSelector(_lastDragView,
@selector(draggingExited:), dragInfo); @selector(draggingExited:), dragInfo);
} }
_f.accepts_drag = GSViewAcceptsDrag(v, dragInfo); _f.accepts_drag = GSViewAcceptsDrag(v, dragInfo);
if (_lastDragView != v && _f.accepts_drag) if (_lastDragView != v && _f.accepts_drag)
{ {
GSPerformDragSelector(v, @selector(draggingEntered:), GSPerformDragSelector(v, @selector(draggingEntered:),
dragInfo, action); dragInfo, action);
} }
else else
{ {
GSPerformDragSelector(v, @selector(draggingUpdated:), GSPerformDragSelector(v, @selector(draggingUpdated:),
dragInfo, action); dragInfo, action);
} }
e = [NSEvent otherEventWithType: NSAppKitDefined e = [NSEvent otherEventWithType: NSAppKitDefined
@ -2053,7 +2053,7 @@ resetCursorRectsForView(NSView *theView)
dragInfo = [GSCurrentContext() _dragInfo]; dragInfo = [GSCurrentContext() _dragInfo];
if (_lastDragView && _f.accepts_drag) if (_lastDragView && _f.accepts_drag)
{ {
GSPerformDragSelector(_lastDragView, GSPerformDragSelector(_lastDragView,
@selector(draggingExited:), dragInfo, @selector(draggingExited:), dragInfo,
action); action);
} }
@ -2063,19 +2063,19 @@ resetCursorRectsForView(NSView *theView)
if (_lastDragView && _f.accepts_drag) if (_lastDragView && _f.accepts_drag)
{ {
dragInfo = [GSCurrentContext() _dragInfo]; dragInfo = [GSCurrentContext() _dragInfo];
GSPerformDragSelector(_lastDragView, GSPerformDragSelector(_lastDragView,
@selector(prepareForDragOperation:), @selector(prepareForDragOperation:),
dragInfo, action); dragInfo, action);
if (action) if (action)
{ {
GSPerformDragSelector(_lastDragView, GSPerformDragSelector(_lastDragView,
@selector(performDragOperation:), @selector(performDragOperation:),
dragInfo, action); dragInfo, action);
} }
if (action) if (action)
{ {
GSPerformVoidDragSelector(_lastDragView, GSPerformVoidDragSelector(_lastDragView,
@selector(concludeDragOperation:), @selector(concludeDragOperation:),
dragInfo); dragInfo);
} }
} }
@ -2101,7 +2101,7 @@ resetCursorRectsForView(NSView *theView)
} }
break; break;
case NSPeriodic: case NSPeriodic:
case NSSystemDefined: case NSSystemDefined:
case NSApplicationDefined: case NSApplicationDefined:
break; break;
@ -2121,7 +2121,7 @@ resetCursorRectsForView(NSView *theView)
- (void) selectKeyViewFollowingView: (NSView *)aView - (void) selectKeyViewFollowingView: (NSView *)aView
{ {
NSView *theView = nil; NSView *theView = nil;
if ([aView isKindOfClass: viewClass]) if ([aView isKindOfClass: viewClass])
theView = [aView nextValidKeyView]; theView = [aView nextValidKeyView];
if (theView) if (theView)
@ -2157,15 +2157,15 @@ resetCursorRectsForView(NSView *theView)
- (void) selectNextKeyView: (id)sender - (void) selectNextKeyView: (id)sender
{ {
NSView *theView = nil; NSView *theView = nil;
if ([first_responder isKindOfClass: viewClass]) if ([first_responder isKindOfClass: viewClass])
theView = [first_responder nextValidKeyView]; theView = [first_responder nextValidKeyView];
if ((theView == nil) && (_initial_first_responder)) if ((theView == nil) && (_initial_first_responder))
{ {
if ([_initial_first_responder acceptsFirstResponder]) if ([_initial_first_responder acceptsFirstResponder])
theView = _initial_first_responder; theView = _initial_first_responder;
else else
theView = [_initial_first_responder nextValidKeyView]; theView = [_initial_first_responder nextValidKeyView];
} }
@ -2184,15 +2184,15 @@ resetCursorRectsForView(NSView *theView)
- (void) selectPreviousKeyView: (id)sender - (void) selectPreviousKeyView: (id)sender
{ {
NSView *theView = nil; NSView *theView = nil;
if ([first_responder isKindOfClass: viewClass]) if ([first_responder isKindOfClass: viewClass])
theView = [first_responder previousValidKeyView]; theView = [first_responder previousValidKeyView];
if ((theView == nil) && (_initial_first_responder)) if ((theView == nil) && (_initial_first_responder))
{ {
if ([_initial_first_responder acceptsFirstResponder]) if ([_initial_first_responder acceptsFirstResponder])
theView = _initial_first_responder; theView = _initial_first_responder;
else else
theView = [_initial_first_responder previousValidKeyView]; theView = [_initial_first_responder previousValidKeyView];
} }
@ -2210,10 +2210,10 @@ resetCursorRectsForView(NSView *theView)
// This is invoked by selectText: of some views (eg matrixes), // This is invoked by selectText: of some views (eg matrixes),
// to know whether they have received it from the window, and // to know whether they have received it from the window, and
// if so, in which direction is the selection moving (so that they know // if so, in which direction is the selection moving (so that they know
// if they should select the last or the first editable cell). // if they should select the last or the first editable cell).
- (NSSelectionDirection)keyViewSelectionDirection - (NSSelectionDirection)keyViewSelectionDirection
{ {
return _selection_direction; return _selection_direction;
} }
@ -2322,7 +2322,7 @@ resetCursorRectsForView(NSView *theView)
[windowsLock lock]; [windowsLock lock];
defs = [NSUserDefaults standardUserDefaults]; defs = [NSUserDefaults standardUserDefaults];
obj = [self stringWithSavedFrame]; obj = [self stringWithSavedFrame];
if ([self isKindOfClass: [NSMenuWindow class]]) if ([self isKindOfClass: [NSMenuWindow class]])
{ {
id dict; id dict;
@ -2331,7 +2331,7 @@ resetCursorRectsForView(NSView *theView)
if (dict == nil) if (dict == nil)
{ {
dict = [NSMutableDictionary dictionaryWithCapacity: 1]; dict = [NSMutableDictionary dictionaryWithCapacity: 1];
} }
else if ([dict isKindOfClass: [NSDictionary class]] == NO) else if ([dict isKindOfClass: [NSDictionary class]] == NO)
{ {
NSLog(@"NSMenuLocations default is not a dictionary - overwriting"); NSLog(@"NSMenuLocations default is not a dictionary - overwriting");
@ -2392,7 +2392,7 @@ resetCursorRectsForView(NSView *theView)
* Autosave name cleared - remove from defaults database. * Autosave name cleared - remove from defaults database.
*/ */
defs = [NSUserDefaults standardUserDefaults]; defs = [NSUserDefaults standardUserDefaults];
if ([self isKindOfClass: [NSMenuWindow class]]) if ([self isKindOfClass: [NSMenuWindow class]])
{ {
id dict; id dict;
@ -2401,7 +2401,7 @@ resetCursorRectsForView(NSView *theView)
if (dict == nil) if (dict == nil)
{ {
dict = [NSMutableDictionary dictionaryWithCapacity: 1]; dict = [NSMutableDictionary dictionaryWithCapacity: 1];
} }
else if ([dict isKindOfClass: [NSDictionary class]] == NO) else if ([dict isKindOfClass: [NSDictionary class]] == NO)
{ {
NSLog(@"NSMenuLocations is not a dictionary - overwriting"); NSLog(@"NSMenuLocations is not a dictionary - overwriting");
@ -2545,7 +2545,7 @@ resetCursorRectsForView(NSView *theView)
[windowsLock lock]; [windowsLock lock];
defs = [NSUserDefaults standardUserDefaults]; defs = [NSUserDefaults standardUserDefaults];
if ([self isKindOfClass: [NSMenuWindow class]] == YES) if ([self isKindOfClass: [NSMenuWindow class]] == YES)
{ {
obj = [defs objectForKey: @"NSMenuLocations"]; obj = [defs objectForKey: @"NSMenuLocations"];
if (obj != nil) if (obj != nil)
@ -2655,13 +2655,14 @@ resetCursorRectsForView(NSView *theView)
{ {
if ([_delegate respondsToSelector: @selector(windowShouldClose:)]) if ([_delegate respondsToSelector: @selector(windowShouldClose:)])
{ {
BOOL ourReturn; BOOL ourReturn;
ourReturn = [_delegate windowShouldClose: sender]; ourReturn = [_delegate windowShouldClose: sender];
if (ourReturn) if (ourReturn)
{ {
ourReturn = [[_windowController document] shouldCloseWindowController: _windowController]; ourReturn = [[_windowController document]
shouldCloseWindowController: _windowController];
} }
return ourReturn; return ourReturn;