tsui@silver.bacs.indiana.edu (07/19/89)
/* Written 9:51 pm Jul 18, 1989 by tsui@silver.bacs.indiana.edu in silver:cs.works.next */
/* ---------- "anquestions" ---------- */
The following is a simple example. Several questions:
1) If I do not define newFrame::::: , then though I can creat an object of
MyMatrix but it does not response to cellPresssed. Why? I really do not
think it is necessary to "overwrite" newFrame this way because I can
setAutodisplay etc. after I create object.
2) What should I do to make highlightCell:: work? The cell seems not
highlighted at all.
/*
MyMatrix.m
*/
#import "MyMatrix.h"
#import <appkit/ButtonCell.h>
@implementation MyMatrix
+ newFrame:(const NXRect *)frameRect
mode:(int)aMode
prototype:aCell
numRows:(int)rowsHigh
numCols:(int)colsWide
{
self = [super newFrame:frameRect
mode:aMode
prototype:aCell
numRows:rowsHigh
numCols:colsWide];
[self setAutodisplay:YES];
[self setEnabled:YES];
[self setTarget:self];
/* [self setDoubleAction:@selector(deleteSelf)]; */
[self setAction:@selector(deleteSelf)];
counter = 0;
return self;
}
- cellPressed:sender
{
id aCell;
int row=0,col=0;
counter++;
aCell = [sender selectedCell];
[sender getRow:&row andCol:&col ofCell:aCell];
[sender selectCellAt:-1:-1];
aCell = [[sender cellAt:row:col] copy];
[self setPrototype:aCell];
[self addCol];
[self putCell:aCell at:1:counter];
/* [self setTag:counter at:1:counter];
[self drawCellAt:1:counter]; */
[self sizeToCells];
[self lockFocus];
[self highlightCellAt:1:counter lit:YES];
[self unlockFocus];
return self;
}
- deleteSelf:sender
{
id aCell;
int row=0,col=0,i;
aCell=[self selectedCell];
[self getRow:&row andCol:&col ofCell:aCell];
/* [self lockFocus];
[self highlightCellAt:row:col lit:NO];
[self unlockFocus];*/
[self removeColAt:col andFree:YES];
[self sizeToCells];
counter--;
/* for (i=col+1;i<=counter;i++)[self setTag:i at:1:i];*/
return self;
}
@end
/* End of text from silver:cs.works.next */