mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 15:20:38 +00:00
Tidyup
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4033 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
80028023e4
commit
563c98aa8d
6 changed files with 992 additions and 751 deletions
|
@ -222,6 +222,22 @@
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id) copyWithZone: (NSZone *)zone
|
||||
{
|
||||
NSBitmapImageRep *copy;
|
||||
|
||||
copy = (NSBitmapImageRep*)[super copyWithZone: zone];
|
||||
|
||||
copy->bytesPerRow = bytesPerRow;
|
||||
copy->numColors = numColors;
|
||||
copy->bitsPerPixel = bitsPerPixel;
|
||||
copy->compression = compression;
|
||||
copy->_isPlanar = _isPlanar;
|
||||
copy->imagePlanes = 0;
|
||||
copy->imageData = [imageData copy];
|
||||
|
||||
return copy;
|
||||
}
|
||||
+ (BOOL) canInitWithData: (NSData *)data
|
||||
{
|
||||
TIFF *image = NULL;
|
||||
|
|
|
@ -1398,8 +1398,9 @@ NSRect mr;
|
|||
bc = [_browserColumns objectAtIndex: column];
|
||||
sc = [bc columnScrollView];
|
||||
matrix = [bc columnMatrix];
|
||||
// Adjust matrix to fit in scrollview
|
||||
if (sc && matrix && [bc isLoaded]) // do it only if column has been loaded
|
||||
|
||||
// Adjust matrix to fit in scrollview if column has been loaded
|
||||
if (sc && matrix && [bc isLoaded])
|
||||
{
|
||||
cs = [sc contentSize];
|
||||
ms = [matrix cellSize];
|
||||
|
@ -1407,11 +1408,13 @@ NSRect mr;
|
|||
[matrix setCellSize: ms];
|
||||
mr = [matrix frame];
|
||||
|
||||
if (mr.size.height < cs.height) // matrix smaller than
|
||||
{ // scrollview's content
|
||||
mr.origin.y = cs.height; // view requires origin
|
||||
[matrix setFrame: mr]; // adjustment for it to
|
||||
} // appear at top
|
||||
// matrix smaller than scrollview's content
|
||||
if (mr.size.height < cs.height)
|
||||
{
|
||||
// view requires origin adjustment for it to appear at top
|
||||
mr.origin.y = cs.height;
|
||||
[matrix setFrame: mr];
|
||||
}
|
||||
|
||||
[sc setDocumentView: matrix];
|
||||
}
|
||||
|
@ -1499,7 +1502,8 @@ NSRect mr;
|
|||
NSRect matrixRect = {{0, 0}, {100, 100}};
|
||||
int i;
|
||||
|
||||
matrix = [[[_browserMatrixClass alloc] // create a new col matrix
|
||||
// create a new col matrix
|
||||
matrix = [[[_browserMatrixClass alloc]
|
||||
initWithFrame: matrixRect
|
||||
mode: NSListModeMatrix
|
||||
prototype: _browserCellPrototype
|
||||
|
@ -1513,7 +1517,8 @@ NSRect mr;
|
|||
[matrix setAction: @selector(doClick:)];
|
||||
[matrix setDoubleAction: @selector(doDoubleClick:)];
|
||||
|
||||
[bc setColumnMatrix: matrix]; // set new col matrix and release old
|
||||
// set new col matrix and release old
|
||||
[bc setColumnMatrix: matrix];
|
||||
[sc setDocumentView: matrix];
|
||||
|
||||
// Now loop through the cells and load each one
|
||||
|
@ -1533,7 +1538,8 @@ NSRect mr;
|
|||
id oldm = [bc columnMatrix];
|
||||
NSRect matrixRect = {{0, 0}, {100, 100}};
|
||||
|
||||
matrix = [[[_browserMatrixClass alloc] // create a new col matrix
|
||||
// create a new col matrix
|
||||
matrix = [[[_browserMatrixClass alloc]
|
||||
initWithFrame: matrixRect
|
||||
mode: NSListModeMatrix
|
||||
prototype: _browserCellPrototype
|
||||
|
@ -1547,16 +1553,19 @@ NSRect mr;
|
|||
[matrix setAction: @selector(doClick:)];
|
||||
[matrix setDoubleAction: @selector(doDoubleClick:)];
|
||||
|
||||
[bc setColumnMatrix: matrix]; // set new col matrix and release old
|
||||
// set new col matrix and release old
|
||||
[bc setColumnMatrix: matrix];
|
||||
[sc setDocumentView: matrix];
|
||||
|
||||
// Tell the delegate to create the rows
|
||||
[_browserDelegate browser: self createRowsForColumn: column
|
||||
[_browserDelegate browser: self
|
||||
createRowsForColumn: column
|
||||
inMatrix: matrix];
|
||||
}
|
||||
}
|
||||
|
||||
[bc setIsLoaded: YES];
|
||||
[self setNeedsDisplayInRect: [self frameOfColumn: column]];
|
||||
}
|
||||
|
||||
- (void)_unloadFromColumn: (int)column
|
||||
|
|
|
@ -268,10 +268,9 @@ static NSImage *highlight_image;
|
|||
control_view = controlView; // remember last view cell was drawn in
|
||||
if (cell_highlighted || cell_state) // temporary hack FAR FIX ME?
|
||||
{
|
||||
NSColor *white = [NSColor whiteColor];
|
||||
NSColor *backColor = [NSColor selectedControlColor];
|
||||
|
||||
[white set];
|
||||
// [_browserText setBackgroundColor: white];
|
||||
[backColor set];
|
||||
if (!_isLeaf)
|
||||
{
|
||||
image = _highlightBranchImage;
|
||||
|
@ -288,7 +287,6 @@ static NSImage *highlight_image;
|
|||
NSColor *backColor = [[controlView window] backgroundColor];
|
||||
|
||||
[backColor set];
|
||||
// [_browserText setBackgroundColor: backColor];
|
||||
if (!_isLeaf)
|
||||
{
|
||||
image = _branchImage;
|
||||
|
|
|
@ -442,7 +442,7 @@
|
|||
delegate: (id)anObject
|
||||
start: (int)selStart
|
||||
length: (int)selLength
|
||||
{ // preliminary FIX ME
|
||||
{
|
||||
if (!controlView || !textObject || !cell_font ||
|
||||
(cell_type != NSTextCellType))
|
||||
return;
|
||||
|
@ -450,10 +450,13 @@
|
|||
[[controlView window] makeFirstResponder: textObject];
|
||||
|
||||
[textObject setFrame: aRect];
|
||||
[textObject setAlignment: text_align];
|
||||
[textObject setText: [self stringValue]];
|
||||
[textObject setDelegate: anObject];
|
||||
[controlView addSubview: textObject];
|
||||
[controlView lockFocus];
|
||||
NSEraseRect(aRect);
|
||||
[controlView unlockFocus];
|
||||
[textObject display];
|
||||
}
|
||||
|
||||
|
|
|
@ -143,6 +143,23 @@ static NSMutableArray* imageReps = NULL;
|
|||
return (NSArray *)array;
|
||||
}
|
||||
|
||||
- (id) copyWithZone: (NSZone *)zone
|
||||
{
|
||||
NSImageRep *copy;
|
||||
|
||||
copy = (NSImageRep*)NSCopyObject(self, 0, zone);
|
||||
|
||||
copy->size = size;
|
||||
copy->hasAlpha = hasAlpha;
|
||||
copy->isOpaque = isOpaque;
|
||||
copy->bitsPerSample = bitsPerSample;
|
||||
copy->_pixelsWide = _pixelsWide;
|
||||
copy->_pixelsHigh = _pixelsHigh;
|
||||
copy->_colorSpace = RETAIN(_colorSpace);
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[_colorSpace release];
|
||||
|
|
|
@ -158,7 +158,8 @@ static void insertRow (tMatrix m, int rowPosition)
|
|||
int i;
|
||||
|
||||
/* Create space for the new rows if necessary */
|
||||
if (rows > m->allocatedRows) {
|
||||
if (rows > m->allocatedRows)
|
||||
{
|
||||
m->matrix = realloc (m->matrix, rows * sizeof(BOOL*));
|
||||
m->allocatedRows = rows;
|
||||
}
|
||||
|
@ -184,7 +185,8 @@ static void insertColumn (tMatrix m, int colPosition)
|
|||
int i, j;
|
||||
|
||||
/* First grow the rows to hold `cols' elements */
|
||||
if (cols > m->allocatedCols) {
|
||||
if (cols > m->allocatedCols)
|
||||
{
|
||||
for (i = 0; i < m->numRows; i++)
|
||||
m->matrix[i] = realloc (m->matrix[i], cols * sizeof(BOOL));
|
||||
m->allocatedCols = cols;
|
||||
|
@ -193,12 +195,14 @@ static void insertColumn (tMatrix m, int colPosition)
|
|||
/* Now insert a new column between the rows, in the required position.
|
||||
If it happens that a row is NULL create a new row with the maximum
|
||||
number of columns for it. */
|
||||
for (i = 0; i < m->numRows; i++) {
|
||||
for (i = 0; i < m->numRows; i++)
|
||||
{
|
||||
BOOL* row = m->matrix[i];
|
||||
|
||||
if (!row)
|
||||
m->matrix[i] = calloc (m->allocatedCols, sizeof(BOOL));
|
||||
else {
|
||||
else
|
||||
{
|
||||
for (j = m->numCols - 1; j > colPosition; j--)
|
||||
row[j] = row[j - 1];
|
||||
row[colPosition] = NO;
|
||||
|
@ -224,7 +228,8 @@ static void removeColumn (tMatrix m, int column)
|
|||
{
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < m->numRows; i++) {
|
||||
for (i = 0; i < m->numRows; i++)
|
||||
{
|
||||
BOOL* row = m->matrix[i];
|
||||
|
||||
for (j = column; j < m->numCols - 1; j++)
|
||||
|
@ -288,7 +293,8 @@ static int mouseDownFlags = 0;
|
|||
|
||||
+ (void) initialize
|
||||
{
|
||||
if (self == [NSMatrix class]) {
|
||||
if (self == [NSMatrix class])
|
||||
{
|
||||
/* Set the initial version */
|
||||
[self setVersion: 1];
|
||||
|
||||
|
@ -352,11 +358,13 @@ static int mouseDownFlags = 0;
|
|||
|
||||
cells = [[NSMutableArray alloc] initWithCapacity: rows];
|
||||
selectedCells = newMatrix (rows, cols);
|
||||
for (i = 0; i < rows; i++) {
|
||||
for (i = 0; i < rows; i++)
|
||||
{
|
||||
NSMutableArray* row = [NSMutableArray arrayWithCapacity: cols];
|
||||
|
||||
[cells addObject: row];
|
||||
for (j = 0; j < cols; j++) {
|
||||
for (j = 0; j < cols; j++)
|
||||
{
|
||||
[row addObject: [[cellPrototype copy] autorelease]];
|
||||
}
|
||||
}
|
||||
|
@ -373,7 +381,8 @@ static int mouseDownFlags = 0;
|
|||
[self setCellBackgroundColor: [NSColor lightGrayColor]];
|
||||
[self setSelectionByRect: YES];
|
||||
[self setAutosizesCells: YES];
|
||||
if (mode == NSRadioModeMatrix && numRows && numCols) {
|
||||
if (mode == NSRadioModeMatrix && numRows && numCols)
|
||||
{
|
||||
[self selectCellAtRow: 0 column: 0];
|
||||
}
|
||||
else
|
||||
|
@ -419,7 +428,8 @@ static int mouseDownFlags = 0;
|
|||
/* Grow the matrix if necessary */
|
||||
if (column >= numCols)
|
||||
[self renewRows: (numRows == 0 ? 1 : numRows) columns: column];
|
||||
if (numRows == 0) {
|
||||
if (numRows == 0)
|
||||
{
|
||||
numRows = 1;
|
||||
[cells addObject: [NSMutableArray array]];
|
||||
}
|
||||
|
@ -440,7 +450,8 @@ static int mouseDownFlags = 0;
|
|||
/* Grow the matrix if necessary */
|
||||
if (column >= numCols)
|
||||
[self renewRows: (numRows == 0 ? 1 : numRows) columns: column];
|
||||
if (numRows == 0) {
|
||||
if (numRows == 0)
|
||||
{
|
||||
numRows = 1;
|
||||
[cells addObject: [NSMutableArray array]];
|
||||
}
|
||||
|
@ -583,14 +594,17 @@ static int mouseDownFlags = 0;
|
|||
{
|
||||
int i, j;
|
||||
|
||||
if (newColumns > numCols) {
|
||||
if (newColumns > numCols)
|
||||
{
|
||||
/* First check to see if the rows really have fewer cells than
|
||||
newColumns. This may happen because the row arrays are not shrink
|
||||
when a lower number of cells is given. */
|
||||
if (numRows && newColumns > [[cells objectAtIndex:0] count]) {
|
||||
if (numRows && newColumns > [[cells objectAtIndex: 0] count])
|
||||
{
|
||||
/* Add columns to the existing rows. Call makeCellAtRow: column:
|
||||
to be consistent. */
|
||||
for (i = 0; i < numRows; i++) {
|
||||
for (i = 0; i < numRows; i++)
|
||||
{
|
||||
for (j = numCols; j < newColumns; j++)
|
||||
[self makeCellAtRow: i column: j];
|
||||
}
|
||||
|
@ -598,8 +612,10 @@ static int mouseDownFlags = 0;
|
|||
}
|
||||
numCols = newColumns;
|
||||
|
||||
if (newRows > numRows) {
|
||||
for (i = numRows; i < newRows; i++) {
|
||||
if (newRows > numRows)
|
||||
{
|
||||
for (i = numRows; i < newRows; i++)
|
||||
{
|
||||
[cells addObject: [NSMutableArray arrayWithCapacity: numCols]];
|
||||
for (j = 0; j < numCols; j++)
|
||||
[self makeCellAtRow: i column: j];
|
||||
|
@ -636,10 +652,13 @@ static int mouseDownFlags = 0;
|
|||
|
||||
[sorted sortUsingFunction: comparator context: context];
|
||||
|
||||
for (i = 0; i < numRows; i++) {
|
||||
for (i = 0; i < numRows; i++)
|
||||
{
|
||||
row = [cells objectAtIndex: i];
|
||||
for (j = 0; j < numCols; j++) {
|
||||
[row replaceObjectAtIndex:j withObject:[sorted objectAtIndex:index]];
|
||||
for (j = 0; j < numCols; j++)
|
||||
{
|
||||
[row replaceObjectAtIndex: j
|
||||
withObject: [sorted objectAtIndex: index]];
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
@ -657,10 +676,13 @@ static int mouseDownFlags = 0;
|
|||
|
||||
[sorted sortUsingSelector: comparator];
|
||||
|
||||
for (i = 0; i < numRows; i++) {
|
||||
for (i = 0; i < numRows; i++)
|
||||
{
|
||||
row = [cells objectAtIndex: i];
|
||||
for (j = 0; j < numCols; j++) {
|
||||
[row replaceObjectAtIndex:j withObject:[sorted objectAtIndex:index]];
|
||||
for (j = 0; j < numCols; j++)
|
||||
{
|
||||
[row replaceObjectAtIndex: j
|
||||
withObject: [sorted objectAtIndex: index]];
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
@ -679,7 +701,8 @@ static int mouseDownFlags = 0;
|
|||
|
||||
if (!insideBounds || isBetweenCells)
|
||||
return NO;
|
||||
else return YES;
|
||||
else
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL) getRow: (int*)row
|
||||
|
@ -688,7 +711,8 @@ static int mouseDownFlags = 0;
|
|||
{
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < numRows; i++) {
|
||||
for (i = 0; i < numRows; i++)
|
||||
{
|
||||
NSMutableArray* row = [cells objectAtIndex: i];
|
||||
|
||||
for (j = 0; j < numCols; j++)
|
||||
|
@ -708,9 +732,11 @@ static int mouseDownFlags = 0;
|
|||
if (!aCell)
|
||||
return;
|
||||
|
||||
if (mode == NSRadioModeMatrix) {
|
||||
if (value) {
|
||||
selectedCell = aCell; // select current cell
|
||||
if (mode == NSRadioModeMatrix)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
selectedCell = aCell;
|
||||
selectedRow = row;
|
||||
selectedColumn = column;
|
||||
[selectedCell setState: 1];
|
||||
|
@ -726,14 +752,16 @@ static int mouseDownFlags = 0;
|
|||
|
||||
- (void) deselectAllCells
|
||||
{
|
||||
int i, j;
|
||||
unsigned i, j;
|
||||
NSArray *row;
|
||||
NSCell *aCell;
|
||||
|
||||
for (i = 0; i < numRows; i++) {
|
||||
for (i = 0; i < numRows; i++)
|
||||
{
|
||||
row = [cells objectAtIndex: i];
|
||||
for (j = 0; j < numCols; j++)
|
||||
if (((tMatrix)selectedCells)->matrix[i][j]) {
|
||||
if (((tMatrix)selectedCells)->matrix[i][j])
|
||||
{
|
||||
NSRect theFrame = [self cellFrameAtRow: i column: j];
|
||||
|
||||
aCell = [row objectAtIndex: j];
|
||||
|
@ -744,8 +772,8 @@ static int mouseDownFlags = 0;
|
|||
}
|
||||
}
|
||||
|
||||
if (!allowsEmptySelection) // if we don't allow an
|
||||
[self selectCellAtRow:0 column:0]; // empty selection
|
||||
if (!allowsEmptySelection)
|
||||
[self selectCellAtRow: 0 column: 0];
|
||||
}
|
||||
|
||||
- (void) deselectSelectedCell
|
||||
|
@ -758,7 +786,7 @@ static int mouseDownFlags = 0;
|
|||
|
||||
- (void) selectAll: (id)sender
|
||||
{
|
||||
int i, j;
|
||||
unsigned i, j;
|
||||
NSArray *row;
|
||||
|
||||
/* Make the selected cell the cell at (0, 0) */
|
||||
|
@ -766,10 +794,12 @@ static int mouseDownFlags = 0;
|
|||
selectedRow = 0;
|
||||
selectedColumn = 0;
|
||||
|
||||
for (i = 0; i < numRows; i++) {
|
||||
for (i = 0; i < numRows; i++)
|
||||
{
|
||||
row = [cells objectAtIndex: i];
|
||||
|
||||
for (j = 0; j < numCols; j++) {
|
||||
for (j = 0; j < numCols; j++)
|
||||
{
|
||||
[[row objectAtIndex: j] setState: 1];
|
||||
((tMatrix)selectedCells)->matrix[i][j] = YES;
|
||||
}
|
||||
|
@ -782,7 +812,8 @@ static int mouseDownFlags = 0;
|
|||
{
|
||||
NSCell* aCell = [self cellAtRow: row column: column];
|
||||
|
||||
if (mode == NSRadioModeMatrix) {
|
||||
if (mode == NSRadioModeMatrix)
|
||||
{
|
||||
/* Don't allow loss of selection if in radio mode and empty selection
|
||||
is not allowed. Otherwise deselect the selected cell. */
|
||||
if (!aCell && !allowsEmptySelection)
|
||||
|
@ -807,11 +838,14 @@ static int mouseDownFlags = 0;
|
|||
id aCell;
|
||||
int i, j;
|
||||
|
||||
for (i = numRows - 1; i >= 0; i--) {
|
||||
for (i = numRows - 1; i >= 0; i--)
|
||||
{
|
||||
row = [cells objectAtIndex: i];
|
||||
for (j = numCols - 1; j >= 0; j --) {
|
||||
for (j = numCols - 1; j >= 0; j --)
|
||||
{
|
||||
aCell = [row objectAtIndex: j];
|
||||
if ([aCell tag] == anInt) {
|
||||
if ([aCell tag] == anInt)
|
||||
{
|
||||
[self selectCellAtRow: i column: j];
|
||||
return YES;
|
||||
}
|
||||
|
@ -826,7 +860,8 @@ static int mouseDownFlags = 0;
|
|||
NSMutableArray* array = [NSMutableArray array];
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < numRows; i++) {
|
||||
for (i = 0; i < numRows; i++)
|
||||
{
|
||||
NSArray* row = [cells objectAtIndex: i];
|
||||
|
||||
for (j = 0; j < numCols; j++)
|
||||
|
@ -868,9 +903,11 @@ static int mouseDownFlags = 0;
|
|||
id aCell;
|
||||
int i, j;
|
||||
|
||||
for (i = numRows - 1; i >= 0; i--) {
|
||||
for (i = numRows - 1; i >= 0; i--)
|
||||
{
|
||||
row = [cells objectAtIndex: i];
|
||||
for (j = numCols - 1; j >= 0; j --) {
|
||||
for (j = numCols - 1; j >= 0; j --)
|
||||
{
|
||||
aCell = [row objectAtIndex: j];
|
||||
if ([aCell tag] == anInt)
|
||||
return aCell;
|
||||
|
@ -981,7 +1018,8 @@ fprintf(stderr, " NSMatrix: selectTextAtRow --- ");
|
|||
{
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < numRows; i++) {
|
||||
for (i = 0; i < numRows; i++)
|
||||
{
|
||||
NSArray* row = [cells objectAtIndex: i];
|
||||
|
||||
for (j = 0; j < numCols; j++)
|
||||
|
@ -1060,7 +1098,8 @@ fprintf(stderr, " NSMatrix: selectTextAtRow --- ");
|
|||
- (BOOL) sendAction: (SEL)theAction
|
||||
to: (id)theTarget
|
||||
{
|
||||
if (theAction) {
|
||||
if (theAction)
|
||||
{
|
||||
if (theTarget)
|
||||
return [super sendAction: theAction to: theTarget];
|
||||
else
|
||||
|
@ -1085,8 +1124,10 @@ fprintf(stderr, " NSMatrix: selectTextAtRow --- ");
|
|||
{
|
||||
int i, j;
|
||||
|
||||
if (flag) {
|
||||
for (i = 0; i < numRows; i++) {
|
||||
if (flag)
|
||||
{
|
||||
for (i = 0; i < numRows; i++)
|
||||
{
|
||||
NSMutableArray* row = [cells objectAtIndex: i];
|
||||
|
||||
for (j = 0; j < numCols; j++)
|
||||
|
@ -1095,8 +1136,10 @@ fprintf(stderr, " NSMatrix: selectTextAtRow --- ");
|
|||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (i = 0; i < numRows; i++) {
|
||||
else
|
||||
{
|
||||
for (i = 0; i < numRows; i++)
|
||||
{
|
||||
BOOL* row = ((tMatrix)selectedCell)->matrix[i];
|
||||
NSMutableArray* cellRow = [cells objectAtIndex: i];
|
||||
|
||||
|
@ -1236,7 +1279,8 @@ fprintf(stderr, " NSMatrix: selectTextAtRow --- ");
|
|||
{
|
||||
if (selectedCell)
|
||||
{
|
||||
((tMatrix)selectedCells)->matrix[selectedRow][selectedColumn] = NO;
|
||||
((tMatrix)selectedCells)->matrix[selectedRow][selectedColumn]
|
||||
= NO;
|
||||
selectedCell = nil;
|
||||
selectedRow = selectedColumn = -1;
|
||||
}
|
||||
|
@ -1260,8 +1304,9 @@ fprintf(stderr, " NSMatrix: selectTextAtRow --- ");
|
|||
{
|
||||
BOOL isBetweenCells, insideBounds;
|
||||
int row, column;
|
||||
unsigned eventMask = NSLeftMouseUpMask | NSLeftMouseDownMask | NSMouseMovedMask
|
||||
| NSLeftMouseDraggedMask | NSPeriodicMask;
|
||||
unsigned eventMask = NSLeftMouseUpMask | NSLeftMouseDownMask
|
||||
| NSMouseMovedMask | NSLeftMouseDraggedMask
|
||||
| NSPeriodicMask;
|
||||
NSPoint lastLocation = [theEvent locationInWindow];
|
||||
NSEvent* lastEvent = nil;
|
||||
BOOL done = NO;
|
||||
|
@ -1289,12 +1334,15 @@ static MPoint anchor = {0, 0};
|
|||
ASSIGN(lastEvent, theEvent);
|
||||
|
||||
[window _captureMouse: self]; // grab the mouse
|
||||
[self lockFocus]; // selection involves two steps, first
|
||||
// a loop that continues until the left
|
||||
while (!done) // mouse goes up; then a series of
|
||||
{ // steps which send actions and display
|
||||
BOOL shouldProceedEvent = NO; // the cell as it should appear after
|
||||
[self lockFocus];
|
||||
// selection involves two steps, first
|
||||
// a loop that continues until the left mouse goes up; then a series of
|
||||
// steps which send actions and display the cell as it should appear after
|
||||
// the selection process is complete
|
||||
while (!done)
|
||||
{
|
||||
BOOL shouldProceedEvent = NO;
|
||||
|
||||
insideBounds = [self _getRow: &row
|
||||
column: &column
|
||||
forPoint: lastLocation
|
||||
|
@ -1307,54 +1355,61 @@ static MPoint anchor = {0, 0};
|
|||
|
||||
switch (mode)
|
||||
{
|
||||
case NSTrackModeMatrix: // in Track mode the cell
|
||||
selectedCell = aCell; // should track the mouse
|
||||
selectedRow = row; // until the cursor either
|
||||
selectedColumn = column; // leaves the cellframe or
|
||||
case NSTrackModeMatrix:
|
||||
// in Track mode the cell should track the mouse
|
||||
// until the cursor either leaves the cellframe or
|
||||
// NSLeftMouseUp occurs
|
||||
selectedCell = aCell;
|
||||
selectedRow = row;
|
||||
selectedColumn = column;
|
||||
if ([aCell trackMouse: lastEvent
|
||||
inRect: rect
|
||||
ofView: self
|
||||
untilMouseUp:YES]) // YES if mouse
|
||||
done = YES; // went up in cell
|
||||
untilMouseUp: YES])
|
||||
done = YES;
|
||||
break;
|
||||
|
||||
case NSHighlightModeMatrix: // Highlight mode is like
|
||||
[aCell setState:1]; // Track mode except that
|
||||
selectedCell = aCell; // the cell is lit before
|
||||
selectedRow = row; // it begins tracking and
|
||||
selectedColumn = column; // unlit afterwards
|
||||
case NSHighlightModeMatrix:
|
||||
// Highlight mode is like Track mode except that
|
||||
// the cell is lit before begins tracking and
|
||||
// unlit afterwards
|
||||
[aCell setState: 1];
|
||||
selectedCell = aCell;
|
||||
selectedRow = row;
|
||||
selectedColumn = column;
|
||||
[aCell highlight: YES withFrame: rect inView: self];
|
||||
[window flushWindow];
|
||||
|
||||
if ([aCell trackMouse: lastEvent
|
||||
inRect: rect
|
||||
ofView: self
|
||||
untilMouseUp:YES]) // YES if mouse
|
||||
done = YES; // went up in cell
|
||||
untilMouseUp: YES])
|
||||
done = YES;
|
||||
|
||||
[aCell setState: 0];
|
||||
[aCell highlight: NO withFrame: rect inView: self];
|
||||
[window flushWindow];
|
||||
break;
|
||||
|
||||
case NSRadioModeMatrix: // Radio mode allows no
|
||||
if (previousCell == aCell) // more than one cell
|
||||
break; // to be selected
|
||||
case NSRadioModeMatrix:
|
||||
// Radio mode allows no more than one cell to be selected
|
||||
if (previousCell == aCell)
|
||||
break;
|
||||
|
||||
// deselect previously selected cell
|
||||
if (selectedCell)
|
||||
{
|
||||
[selectedCell setState:0]; // deselect previously
|
||||
if (!previousCell) // selected cell
|
||||
[selectedCell setState: 0];
|
||||
if (!previousCell)
|
||||
previousCellRect = [self cellFrameAtRow: selectedRow
|
||||
column: selectedColumn];
|
||||
[selectedCell highlight: NO
|
||||
withFrame: previousCellRect
|
||||
inView: self];
|
||||
((tMatrix)selectedCells)->matrix[selectedRow]
|
||||
[selectedColumn] = NO;
|
||||
((tMatrix)selectedCells)->matrix[selectedRow][selectedColumn] = NO;
|
||||
}
|
||||
selectedCell = aCell; // select current cell
|
||||
// select current cell
|
||||
selectedCell = aCell;
|
||||
selectedRow = row;
|
||||
selectedColumn = column;
|
||||
[aCell setState: 1];
|
||||
|
@ -1362,22 +1417,26 @@ static MPoint anchor = {0, 0};
|
|||
((tMatrix)selectedCells)->matrix[row][column] = YES;
|
||||
[window flushWindow];
|
||||
break;
|
||||
// List mode allows
|
||||
case NSListModeMatrix: // multiple cells to be
|
||||
{ // selected
|
||||
|
||||
case NSListModeMatrix:
|
||||
// List mode allows multiple cells to be selected
|
||||
{
|
||||
unsigned modifiers = [lastEvent modifierFlags];
|
||||
|
||||
if (previousCell == aCell)
|
||||
break; // When the user first clicks on a cell
|
||||
break;
|
||||
// When the user first clicks on a cell
|
||||
// we clear the existing selection
|
||||
if (!previousCell) // unless the Alternate or Shift keys
|
||||
{ // have been pressed.
|
||||
// unless the Alternate or Shift keys have been pressed.
|
||||
if (!previousCell)
|
||||
{
|
||||
if (!(modifiers & NSShiftKeyMask) &&
|
||||
!(modifiers & NSAlternateKeyMask))
|
||||
{
|
||||
[self deselectAllCells];
|
||||
anchor = MakePoint (column, row);
|
||||
} // Consider the selected cell as the
|
||||
}
|
||||
// Consider the selected cell as the
|
||||
// anchor from which to extend the
|
||||
// selection to the current cell
|
||||
if (!(modifiers & NSAlternateKeyMask))
|
||||
|
@ -1405,7 +1464,7 @@ static MPoint anchor = {0, 0};
|
|||
current: MakePoint (column, row)];
|
||||
|
||||
[window flushWindow];
|
||||
selectedCell = aCell; // select current cell
|
||||
selectedCell = aCell;
|
||||
selectedRow = row;
|
||||
selectedColumn = column;
|
||||
break;
|
||||
|
@ -1416,11 +1475,12 @@ static MPoint anchor = {0, 0};
|
|||
[self scrollRectToVisible: rect];
|
||||
}
|
||||
|
||||
if (done) // if done break out of
|
||||
break; // the selection loop
|
||||
// if done break out of selection loop
|
||||
if (done)
|
||||
break;
|
||||
|
||||
while (!shouldProceedEvent)
|
||||
{ // Get the next event
|
||||
{
|
||||
theEvent = [app nextEventMatchingMask: eventMask
|
||||
untilDate: [NSDate distantFuture]
|
||||
inMode: NSEventTrackingRunLoopMode
|
||||
|
@ -1429,12 +1489,16 @@ static MPoint anchor = {0, 0};
|
|||
{
|
||||
case NSPeriodic:
|
||||
NSDebugLog(@"NSMatrix: got NSPeriodic event\n");
|
||||
shouldProceedEvent = YES; // it's time to cycle
|
||||
break; // thru the loop again
|
||||
shouldProceedEvent = YES;
|
||||
break;
|
||||
|
||||
// Track and Highlight modes do not use
|
||||
// periodic events so we must break out
|
||||
// and check if the mouse is in a cell
|
||||
case NSLeftMouseUp:
|
||||
done = YES; // Track and Highlight modes do not use
|
||||
case NSLeftMouseDown: // periodic events so we must break out
|
||||
default: // and check if the mouse is in a cell
|
||||
done = YES;
|
||||
case NSLeftMouseDown:
|
||||
default:
|
||||
if ((mode == NSTrackModeMatrix) ||
|
||||
(mode == NSHighlightModeMatrix))
|
||||
shouldProceedEvent = YES;
|
||||
|
@ -1448,15 +1512,15 @@ static MPoint anchor = {0, 0};
|
|||
lastLocation = [self convertPoint: lastLocation fromView: nil];
|
||||
}
|
||||
|
||||
[window _releaseMouse: self]; // Release the mouse
|
||||
[window _releaseMouse: self];
|
||||
|
||||
switch (mode) // Finish the selection
|
||||
{ // process
|
||||
switch (mode)
|
||||
{
|
||||
case NSRadioModeMatrix:
|
||||
if (selectedCell)
|
||||
[selectedCell highlight: NO withFrame: rect inView: self];
|
||||
case NSListModeMatrix:
|
||||
[self setNeedsDisplayInRect:rect]; // not needed by XRAW
|
||||
[self setNeedsDisplayInRect: rect];
|
||||
[window flushWindow];
|
||||
case NSHighlightModeMatrix:
|
||||
case NSTrackModeMatrix:
|
||||
|
@ -1464,14 +1528,20 @@ static MPoint anchor = {0, 0};
|
|||
}
|
||||
|
||||
if (selectedCell)
|
||||
{ // send single click action
|
||||
{
|
||||
// send single click action
|
||||
if (!(selectedCellTarget = [selectedCell target]))
|
||||
{ // selected cell has no target so send single
|
||||
if (target) // click action to matrix's (self's) target
|
||||
{
|
||||
// selected cell has no target so send single
|
||||
// click action to matrix's (self's) target
|
||||
if (target)
|
||||
[target performSelector: action withObject: self];
|
||||
} // in Track and Highlight modes the single
|
||||
else // click action has already been sent by the
|
||||
{ // cell to it's target (if it has one)
|
||||
}
|
||||
else
|
||||
{
|
||||
// in Track and Highlight modes the single
|
||||
// click action has already been sent by the
|
||||
// cell to it's target (if it has one)
|
||||
if ((mode != NSTrackModeMatrix) && (mode != NSHighlightModeMatrix))
|
||||
[selectedCellTarget performSelector: [selectedCell action]
|
||||
withObject: self];
|
||||
|
@ -1507,12 +1577,16 @@ static MPoint anchor = {0, 0};
|
|||
NSMutableArray* row;
|
||||
NSString* key = [theEvent charactersIgnoringModifiers];
|
||||
|
||||
for (i = 0; i < numRows; i++) {
|
||||
for (i = 0; i < numRows; i++)
|
||||
{
|
||||
row = [cells objectAtIndex: i];
|
||||
for (j = 0; j < numCols; j++) {
|
||||
for (j = 0; j < numCols; j++)
|
||||
{
|
||||
NSCell* aCell = [row objectAtIndex: j];
|
||||
|
||||
if ([aCell isEnabled] && [[aCell keyEquivalent] isEqualToString:key]) {
|
||||
if ([aCell isEnabled]
|
||||
&& [[aCell keyEquivalent] isEqualToString: key])
|
||||
{
|
||||
NSCell* oldSelectedCell = selectedCell;
|
||||
|
||||
selectedCell = aCell;
|
||||
|
@ -1534,12 +1608,15 @@ static MPoint anchor = {0, 0};
|
|||
{
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < numRows; i++) {
|
||||
for (i = 0; i < numRows; i++)
|
||||
{
|
||||
NSArray* row = [cells objectAtIndex: i];
|
||||
|
||||
for (j = 0; j < numCols; j++) {
|
||||
for (j = 0; j < numCols; j++)
|
||||
{
|
||||
NSCell* aCell = [row objectAtIndex: j];
|
||||
[aCell resetCursorRect:[self cellFrameAtRow:i column:j] inView:self];
|
||||
[aCell resetCursorRect: [self cellFrameAtRow: i column: j]
|
||||
inView: self];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1556,48 +1633,168 @@ static MPoint anchor = {0, 0};
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void)setMode:(NSMatrixMode)aMode { mode = aMode; }
|
||||
- (NSMatrixMode)mode { return mode; }
|
||||
- (void)setCellClass:(Class)class { cellClass = class; }
|
||||
- (Class)cellClass { return cellClass; }
|
||||
- (void)setPrototype:(NSCell*)aCell { ASSIGN(cellPrototype, aCell); }
|
||||
- (id)prototype { return cellPrototype; }
|
||||
- (NSSize)cellSize { return cellSize; }
|
||||
- (NSSize)intercellSpacing { return intercell; }
|
||||
- (void)setBackgroundColor:(NSColor*)c { ASSIGN(backgroundColor, c); }
|
||||
- (NSColor*)backgroundColor { return backgroundColor; }
|
||||
- (void)setCellBackgroundColor:(NSColor*)c { ASSIGN(cellBackgroundColor, c); }
|
||||
- (NSColor*)cellBackgroundColor { return cellBackgroundColor; }
|
||||
- (void)setDelegate:(id)object { ASSIGN(delegate, object); }
|
||||
- (id)delegate { return delegate; }
|
||||
- (void)setTarget:anObject { ASSIGN(target, anObject); }
|
||||
- (id)target { return target; }
|
||||
- (void)setAction:(SEL)sel { action = sel; }
|
||||
- (SEL)action { return action; }
|
||||
- (void)setDoubleAction:(SEL)sel { doubleAction = sel; }
|
||||
- (SEL)doubleAction { return doubleAction; }
|
||||
- (void)setErrorAction:(SEL)sel { errorAction = sel; }
|
||||
- (SEL)errorAction { return errorAction; }
|
||||
- (void)setAllowsEmptySelection:(BOOL)f { allowsEmptySelection = f; }
|
||||
- (BOOL)allowsEmptySelection { return allowsEmptySelection; }
|
||||
- (void)setSelectionByRect:(BOOL)flag { selectionByRect = flag; }
|
||||
- (BOOL)isSelectionByRect { return selectionByRect; }
|
||||
- (void)setDrawsBackground:(BOOL)flag { drawsBackground = flag; }
|
||||
- (BOOL)drawsBackground { return drawsBackground; }
|
||||
- (void)setDrawsCellBackground:(BOOL)f { drawsCellBackground = f; }
|
||||
- (BOOL)drawsCellBackground { return drawsCellBackground; }
|
||||
- (void)setAutosizesCells:(BOOL)flag { autosizesCells = flag; }
|
||||
- (BOOL)autosizesCells { return autosizesCells; }
|
||||
- (BOOL)isAutoscroll { return autoscroll; }
|
||||
- (int)numberOfRows { return numRows; }
|
||||
- (int)numberOfColumns { return numCols; }
|
||||
- (id)selectedCell { return selectedCell; }
|
||||
- (int)selectedColumn { return selectedColumn; }
|
||||
- (int)selectedRow { return selectedRow; }
|
||||
- (int)mouseDownFlags { return mouseDownFlags; }
|
||||
- (void) setMode: (NSMatrixMode)aMode
|
||||
{
|
||||
mode = aMode;
|
||||
}
|
||||
- (NSMatrixMode) mode
|
||||
{
|
||||
return mode;
|
||||
}
|
||||
- (void) setCellClass: (Class)class
|
||||
{
|
||||
cellClass = class;
|
||||
}
|
||||
- (Class) cellClass
|
||||
{
|
||||
return cellClass;
|
||||
}
|
||||
- (void) setPrototype: (NSCell*)aCell
|
||||
{
|
||||
ASSIGN(cellPrototype, aCell);
|
||||
}
|
||||
- (id) prototype
|
||||
{
|
||||
return cellPrototype;
|
||||
}
|
||||
- (NSSize) cellSize
|
||||
{
|
||||
return cellSize;
|
||||
}
|
||||
- (NSSize) intercellSpacing
|
||||
{
|
||||
return intercell;
|
||||
}
|
||||
- (void) setBackgroundColor: (NSColor*)c
|
||||
{
|
||||
ASSIGN(backgroundColor, c);
|
||||
}
|
||||
- (NSColor*) backgroundColor
|
||||
{
|
||||
return backgroundColor;
|
||||
}
|
||||
- (void) setCellBackgroundColor: (NSColor*)c
|
||||
{
|
||||
ASSIGN(cellBackgroundColor, c);
|
||||
}
|
||||
- (NSColor*) cellBackgroundColor
|
||||
{
|
||||
return cellBackgroundColor;
|
||||
}
|
||||
- (void) setDelegate: (id)object
|
||||
{
|
||||
ASSIGN(delegate, object);
|
||||
}
|
||||
- (id) delegate
|
||||
{
|
||||
return delegate;
|
||||
}
|
||||
- (void) setTarget: anObject
|
||||
{
|
||||
ASSIGN(target, anObject);
|
||||
}
|
||||
- (id) target
|
||||
{
|
||||
return target;
|
||||
}
|
||||
- (void) setAction: (SEL)sel
|
||||
{
|
||||
action = sel;
|
||||
}
|
||||
- (SEL) action
|
||||
{
|
||||
return action;
|
||||
}
|
||||
- (void) setDoubleAction: (SEL)sel
|
||||
{
|
||||
doubleAction = sel;
|
||||
}
|
||||
- (SEL) doubleAction
|
||||
{
|
||||
return doubleAction;
|
||||
}
|
||||
- (void) setErrorAction: (SEL)sel
|
||||
{
|
||||
errorAction = sel;
|
||||
}
|
||||
- (SEL) errorAction
|
||||
{
|
||||
return errorAction;
|
||||
}
|
||||
- (void) setAllowsEmptySelection: (BOOL)f
|
||||
{
|
||||
allowsEmptySelection = f;
|
||||
}
|
||||
- (BOOL) allowsEmptySelection
|
||||
{
|
||||
return allowsEmptySelection;
|
||||
}
|
||||
- (void) setSelectionByRect: (BOOL)flag
|
||||
{
|
||||
selectionByRect = flag;
|
||||
}
|
||||
- (BOOL) isSelectionByRect
|
||||
{
|
||||
return selectionByRect;
|
||||
}
|
||||
- (void) setDrawsBackground: (BOOL)flag
|
||||
{
|
||||
drawsBackground = flag;
|
||||
}
|
||||
- (BOOL) drawsBackground
|
||||
{
|
||||
return drawsBackground;
|
||||
}
|
||||
- (void) setDrawsCellBackground: (BOOL)f
|
||||
{
|
||||
drawsCellBackground = f;
|
||||
}
|
||||
- (BOOL) drawsCellBackground
|
||||
{
|
||||
return drawsCellBackground;
|
||||
}
|
||||
- (void) setAutosizesCells: (BOOL)flag
|
||||
{
|
||||
autosizesCells = flag;
|
||||
}
|
||||
- (BOOL) autosizesCells
|
||||
{
|
||||
return autosizesCells;
|
||||
}
|
||||
- (BOOL) isAutoscroll
|
||||
{
|
||||
return autoscroll;
|
||||
}
|
||||
- (int) numberOfRows
|
||||
{
|
||||
return numRows;
|
||||
}
|
||||
- (int) numberOfColumns
|
||||
{
|
||||
return numCols;
|
||||
}
|
||||
- (id) selectedCell
|
||||
{
|
||||
return selectedCell;
|
||||
}
|
||||
- (int) selectedColumn
|
||||
{
|
||||
return selectedColumn;
|
||||
}
|
||||
- (int) selectedRow
|
||||
{
|
||||
return selectedRow;
|
||||
}
|
||||
- (int) mouseDownFlags
|
||||
{
|
||||
return mouseDownFlags;
|
||||
}
|
||||
|
||||
#if HAS_FLIPPED_VIEWS
|
||||
- (BOOL)isFlipped { return YES; }
|
||||
- (BOOL) isFlipped
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -1632,6 +1829,7 @@ fprintf(stderr, " NSMatrix: keyDown --- ");
|
|||
{
|
||||
[selectedCell endEditing: nil];
|
||||
[selectedCell drawInteriorWithFrame: rect inView: self];
|
||||
[self unlockFocus];
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue