home *** CD-ROM | disk | FTP | other *** search
-
- static char RCSId[]="$Id: CellScrollView.m,v 1.1.1.1 1993/03/18 03:31:24 davis Exp $";
-
-
- /*
- * Based heavily on the NeXTSTEP MiniExample CellScrollView
- * by R. Dunbar Poor and Mai Nguyen.
- */
-
- #import "CellScrollView.h"
- #import "MultipleSelectionMatrix.h"
- #import "SubCell.h"
-
-
- @implementation CellScrollView
-
- - init
- {
- return [self initFrame:NULL];
- }
-
-
- /* Designated initializer */
- - initFrame:(const NXRect *)frameRect
- {
- [super initFrame:frameRect];
- cellMatrix = nil;
-
- return self;
- }
-
-
- - initMatrix:classId
- {
- NXSize interCellSpacing = {0.0, 0.0}, docSize;
-
- /*
- * This method should only be called once. Check to see if
- * cellMatrix already exists.
- */
- if (cellMatrix || !classId)
- return nil;
-
- cellMatrix = [[MultipleSelectionMatrix alloc] initFrame: &frame
- mode: NX_LISTMODE
- cellClass: (cellClass = classId)
- numRows: 0
- numCols: 1];
-
- [cellMatrix setIntercell:&interCellSpacing];
- [cellMatrix sizeToCells]; /* Resize matrix to contain cells */
- [cellMatrix setAutosizeCells:YES];
-
- [cellMatrix setAutoscroll:YES]; /* Auto-scroll on drag if necessary */
- [cellMatrix setAutosizing:NX_WIDTHSIZABLE];
-
- [[self setDocView:cellMatrix] free];
-
- [self setVertScrollerRequired:YES];
- [self setBorderType:NX_BEZEL];
- [self setAutoresizeSubviews:YES];
- /* This is the only way to get the clipview to resize too */
- [[cellMatrix superview] setAutoresizeSubviews:YES];
-
- /* Resize the matrix to fill the inside of the scrollview */
- [self getContentSize:&docSize];
- [cellMatrix sizeTo:docSize.width :docSize.height];
-
- return self;
- }
-
-
- - free
- {
- if (cellMatrix)
- [cellMatrix free];
-
- return [super free];
- }
-
-
- - cellMatrix
- {
- return cellMatrix;
- }
-
-
- - loadCellsFrom:(List *)cellObjects
- /*
- * Fill the matrix with Cells, associate each Cell with a cellObject.
- *
- * Since we recycle the cells (via renewRows:cols:), we also set the
- * state of each cell to 0 and unhighlight it. If we don't do that,
- * the recycled cells will display their previous state.
- */
- {
- int i, cellCount;
-
- cellCount = [cellObjects count];
-
- /* tell the matrix there are 0 cells in it (but don't deallocate them) */
- [cellMatrix renewRows:0 cols:1];
- [cellMatrix lockFocus]; /* for highlightCellAt::lit: */
- for (i=0;i<cellCount;i++) {
- id cell;
- /*
- * Add a row to the matrix. (This doesn't necessarily allocate
- * a new cell, thanks to renewRows:cols:).
- */
- [cellMatrix addRow];
- cell = [cellMatrix cellAt:i:0];
- /* make sure the cell is neither selected nor highlighted */
- [cellMatrix highlightCellAt:i:0 lit:NO];
- [cell setState:0];
- /* install the cellObject in that cell */
- [cell setSubObject:[cellObjects objectAt:i]];
- }
- [cellMatrix unlockFocus];
- [cellMatrix sizeToCells];
- [cellMatrix display];
-
- return self;
- }
-
-
- // Shuts up the compiler about unused RCSId
- - (const char *) rcsid
- {
- return RCSId;
- }
-
-
- @end
-