NSMatrix rewrite

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5122 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 1999-11-02 20:59:56 +00:00
parent fbb3135f8c
commit 0eb467fa57
3 changed files with 758 additions and 673 deletions

View file

@ -1,5 +1,10 @@
Tue Nov 2 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/NSMatrix.m: Complete rewrite of code for handling cells
within a matrix - use plain C arrays for holding the objects and
cache method implementations for creating new cells. Also make GC
aware for some future date when we can use GC.
* Headers/AppKit/NSMatrix.h: ivar changes for rewrite.
* Source/NSCell.m: Updated to notice changes in system colors,
also optimised a little by caching some classes.

View file

@ -1,7 +1,7 @@
/*
NSMatrix.h
Copyright (C) 1996 Free Software Foundation, Inc.
Copyright (C) 1996,1997,1999 Free Software Foundation, Inc.
Author: Ovidiu Predescu <ovidiu@net-community.com>
Date: March 1997
@ -17,7 +17,7 @@
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
@ -49,246 +49,252 @@ typedef enum _NSMatrixMode {
@interface NSMatrix : NSControl <NSCoding>
{
NSMutableArray* cells;
NSMatrixMode mode;
int numRows;
int numCols;
Class cellClass;
id cellPrototype;
NSSize cellSize;
NSSize intercell;
NSColor* backgroundColor;
NSColor* cellBackgroundColor;
id delegate;
id target;
SEL action;
SEL doubleAction;
SEL errorAction;
id selectedCell;
int selectedRow;
int selectedColumn;
void* selectedCells;
BOOL allowsEmptySelection;
BOOL selectionByRect;
BOOL drawsBackground;
BOOL drawsCellBackground;
BOOL autosizesCells;
BOOL autoscroll;
id **cells;
BOOL **selectedCells;
int maxRows;
int maxCols;
int numRows;
int numCols;
NSZone *myZone;
Class cellClass;
id cellPrototype;
IMP cellNew;
IMP cellInit;
NSMatrixMode mode;
NSSize cellSize;
NSSize intercell;
NSColor *backgroundColor;
NSColor *cellBackgroundColor;
id delegate;
id target;
SEL action;
SEL doubleAction;
SEL errorAction;
id selectedCell;
int selectedRow;
int selectedColumn;
BOOL allowsEmptySelection;
BOOL selectionByRect;
BOOL drawsBackground;
BOOL drawsCellBackground;
BOOL autosizesCells;
BOOL autoscroll;
}
//
// Initializing the NSMatrix Class
//
+ (Class)cellClass;
+ (void)setCellClass:(Class)classId;
/*
* Initializing the NSMatrix Class
*/
+ (Class) cellClass;
+ (void) setCellClass: (Class)classId;
//
// Initializing an NSMatrix Object
//
- (id)initWithFrame:(NSRect)frameRect;
- (id)initWithFrame:(NSRect)frameRect
mode:(int)aMode
cellClass:(Class)classId
numberOfRows:(int)rowsHigh
numberOfColumns:(int)colsWide;
- (id)initWithFrame:(NSRect)frameRect
mode:(int)aMode
prototype:(NSCell *)aCell
numberOfRows:(int)rowsHigh
numberOfColumns:(int)colsWide;
/*
* Initializing an NSMatrix Object
*/
- (id) initWithFrame: (NSRect)frameRect;
- (id) initWithFrame: (NSRect)frameRect
mode: (int)aMode
cellClass: (Class)classId
numberOfRows: (int)rowsHigh
numberOfColumns: (int)colsWide;
- (id) initWithFrame: (NSRect)frameRect
mode: (int)aMode
prototype: (NSCell *)aCell
numberOfRows: (int)rowsHigh
numberOfColumns: (int)colsWide;
//
// Setting the Selection Mode
//
- (NSMatrixMode)mode;
- (void)setMode:(NSMatrixMode)aMode;
/*
* Setting the Selection Mode
*/
- (NSMatrixMode) mode;
- (void) setMode: (NSMatrixMode)aMode;
//
// Configuring the NSMatrix
//
- (BOOL)allowsEmptySelection;
- (BOOL)isSelectionByRect;
- (void)setAllowsEmptySelection:(BOOL)flag;
- (void)setSelectionByRect:(BOOL)flag;
/*
* Configuring the NSMatrix
*/
- (BOOL) allowsEmptySelection;
- (BOOL) isSelectionByRect;
- (void) setAllowsEmptySelection: (BOOL)flag;
- (void) setSelectionByRect: (BOOL)flag;
//
// Setting the Cell Class
//
- (Class)cellClass;
- (id)prototype;
- (void)setCellClass:(Class)classId;
- (void)setPrototype:(NSCell *)aCell;
/*
* Setting the Cell Class
*/
- (Class) cellClass;
- (id) prototype;
- (void) setCellClass: (Class)classId;
- (void) setPrototype: (NSCell *)aCell;
//
// Laying Out the NSMatrix
//
- (void)addColumn;
- (void)addColumnWithCells:(NSArray *)cellArray;
- (void)addRow;
- (void)addRowWithCells:(NSArray *)cellArray;
- (NSRect)cellFrameAtRow:(int)row
column:(int)column;
- (NSSize)cellSize;
- (void)getNumberOfRows:(int *)rowCount
columns:(int *)columnCount;
- (void)insertColumn:(int)column;
- (void)insertColumn:(int)column withCells:(NSArray *)cellArray;
- (void)insertRow:(int)row;
- (void)insertRow:(int)row withCells:(NSArray *)cellArray;
- (NSSize)intercellSpacing;
- (NSCell *)makeCellAtRow:(int)row
column:(int)column;
- (void)putCell:(NSCell *)newCell
atRow:(int)row
column:(int)column;
- (void)removeColumn:(int)column;
- (void)removeRow:(int)row;
- (void)renewRows:(int)newRows
columns:(int)newColumns;
- (void)setCellSize:(NSSize)aSize;
- (void)setIntercellSpacing:(NSSize)aSize;
- (void)sortUsingFunction:(int (*)(id element1, id element2, void *userData))comparator
context:(void *)context;
- (void)sortUsingSelector:(SEL)comparator;
- (int)numberOfColumns;
- (int)numberOfRows;
/*
* Laying Out the NSMatrix
*/
- (void) addColumn;
- (void) addColumnWithCells: (NSArray *)cellArray;
- (void) addRow;
- (void) addRowWithCells: (NSArray *)cellArray;
- (NSRect) cellFrameAtRow: (int)row
column: (int)column;
- (NSSize) cellSize;
- (void) getNumberOfRows: (int *)rowCount
columns: (int *)columnCount;
- (void) insertColumn: (int)column;
- (void) insertColumn: (int)column withCells: (NSArray *)cellArray;
- (void) insertRow: (int)row;
- (void) insertRow: (int)row withCells: (NSArray *)cellArray;
- (NSSize) intercellSpacing;
- (NSCell *) makeCellAtRow: (int)row
column: (int)column;
- (void) putCell: (NSCell *)newCell
atRow: (int)row
column: (int)column;
- (void) removeColumn: (int)column;
- (void) removeRow: (int)row;
- (void) renewRows: (int)newRows
columns: (int)newColumns;
- (void) setCellSize: (NSSize)aSize;
- (void) setIntercellSpacing: (NSSize)aSize;
- (void) sortUsingFunction: (int (*)(id element1, id element2, void *userData))comparator
context: (void *)context;
- (void) sortUsingSelector: (SEL)comparator;
- (int) numberOfColumns;
- (int) numberOfRows;
//
// Finding Matrix Coordinates
//
- (BOOL)getRow:(int *)row
column:(int *)column
forPoint:(NSPoint)aPoint;
- (BOOL)getRow:(int *)row
column:(int *)column
ofCell:(NSCell *)aCell;
/*
* Finding Matrix Coordinates
*/
- (BOOL) getRow: (int *)row
column: (int *)column
forPoint: (NSPoint)aPoint;
- (BOOL) getRow: (int *)row
column: (int *)column
ofCell: (NSCell *)aCell;
//
// Modifying Individual Cells
//
- (void)setState:(int)value
atRow:(int)row
column:(int)column;
/*
* Modifying Individual Cells
*/
- (void) setState: (int)value
atRow: (int)row
column: (int)column;
//
// Selecting Cells
//
- (void)deselectAllCells;
- (void)deselectSelectedCell;
- (void)selectAll:(id)sender;
- (void)selectCellAtRow:(int)row
column:(int)column;
- (BOOL)selectCellWithTag:(int)anInt;
- (id)selectedCell;
- (NSArray *)selectedCells;
- (int)selectedColumn;
- (int)selectedRow;
- (void)setSelectionFrom:(int)startPos
to:(int)endPos
anchor:(int)anchorPos
highlight:(BOOL)flag;
/*
* Selecting Cells
*/
- (void) deselectAllCells;
- (void) deselectSelectedCell;
- (void) selectAll: (id)sender;
- (void) selectCellAtRow: (int)row
column: (int)column;
- (BOOL) selectCellWithTag: (int)anInt;
- (id) selectedCell;
- (NSArray *) selectedCells;
- (int) selectedColumn;
- (int) selectedRow;
- (void) setSelectionFrom: (int)startPos
to: (int)endPos
anchor: (int)anchorPos
highlight: (BOOL)flag;
//
// Finding Cells
//
- (id)cellAtRow:(int)row
column:(int)column;
- (id)cellWithTag:(int)anInt;
- (NSArray *)cells;
/*
* Finding Cells
*/
- (id) cellAtRow: (int)row
column: (int)column;
- (id) cellWithTag: (int)anInt;
- (NSArray *) cells;
//
// Modifying Graphic Attributes
//
- (NSColor *)backgroundColor;
- (NSColor *)cellBackgroundColor;
- (BOOL)drawsBackground;
- (BOOL)drawsCellBackground;
- (void)setBackgroundColor:(NSColor *)aColor;
- (void)setCellBackgroundColor:(NSColor *)aColor;
- (void)setDrawsBackground:(BOOL)flag;
- (void)setDrawsCellBackground:(BOOL)flag;
/*
* Modifying Graphic Attributes
*/
- (NSColor *) backgroundColor;
- (NSColor *) cellBackgroundColor;
- (BOOL) drawsBackground;
- (BOOL) drawsCellBackground;
- (void) setBackgroundColor: (NSColor *)aColor;
- (void) setCellBackgroundColor: (NSColor *)aColor;
- (void) setDrawsBackground: (BOOL)flag;
- (void) setDrawsCellBackground: (BOOL)flag;
//
// Editing Text in Cells
//
- (void)selectText:(id)sender;
- (id)selectTextAtRow:(int)row
column:(int)column;
- (void)textDidBeginEditing:(NSNotification *)notification;
- (void)textDidChange:(NSNotification *)notification;
- (void)textDidEndEditing:(NSNotification *)notification;
- (BOOL)textShouldBeginEditing:(NSText *)textObject;
- (BOOL)textShouldEndEditing:(NSText *)textObject;
/*
* Editing Text in Cells
*/
- (void) selectText: (id)sender;
- (id) selectTextAtRow: (int)row
column: (int)column;
- (void) textDidBeginEditing: (NSNotification *)notification;
- (void) textDidChange: (NSNotification *)notification;
- (void) textDidEndEditing: (NSNotification *)notification;
- (BOOL) textShouldBeginEditing: (NSText *)textObject;
- (BOOL) textShouldEndEditing: (NSText *)textObject;
//
// Setting Tab Key Behavior
//
- (id)nextText;
- (id)previousText;
- (void)setNextText:(id)anObject;
- (void)setPreviousText:(id)anObject;
/*
* Setting Tab Key Behavior
*/
- (id) keyCell;
- (id) nextText;
- (id) previousText;
- (void) setNextText: (id)anObject;
- (void) setPreviousText: (id)anObject;
//
// Assigning a Delegate
//
- (void)setDelegate:(id)anObject;
- (id)delegate;
/*
* Assigning a Delegate
*/
- (void) setDelegate: (id)anObject;
- (id) delegate;
//
// Resizing the Matrix and Cells
//
- (BOOL)autosizesCells;
- (void)setAutosizesCells:(BOOL)flag;
- (void)setValidateSize:(BOOL)flag;
- (void)sizeToCells;
/*
* Resizing the Matrix and Cells
*/
- (BOOL) autosizesCells;
- (void) setAutosizesCells: (BOOL)flag;
- (void) setValidateSize: (BOOL)flag;
- (void) sizeToCells;
//
// Scrolling
//
- (BOOL)isAutoscroll;
- (void)scrollCellToVisibleAtRow:(int)row
column:(int)column;
- (void)setAutoscroll:(BOOL)flag;
- (void)setScrollable:(BOOL)flag;
/*
* Scrolling
*/
- (BOOL) isAutoscroll;
- (void) scrollCellToVisibleAtRow: (int)row
column: (int)column;
- (void) setAutoscroll: (BOOL)flag;
- (void) setScrollable: (BOOL)flag;
//
// Displaying
//
- (void)drawCellAtRow:(int)row
column:(int)column;
- (void)highlightCell:(BOOL)flag
atRow:(int)row
column:(int)column;
/*
* Displaying
*/
- (void) drawCellAtRow: (int)row
column: (int)column;
- (void) highlightCell: (BOOL)flag
atRow: (int)row
column: (int)column;
//
//Target and Action
//
- (void)setAction:(SEL)aSelector;
- (SEL)action;
- (void)setDoubleAction:(SEL)aSelector;
- (SEL)doubleAction;
- (void)setErrorAction:(SEL)aSelector;
- (SEL)errorAction;
- (BOOL)sendAction;
- (void)sendAction:(SEL)aSelector
to:(id)anObject
forAllCells:(BOOL)flag;
- (void)sendDoubleAction;
- (void)setErrorAction:(SEL)aSelector;
/*
*Target and Action
*/
- (void) setAction: (SEL)aSelector;
- (SEL) action;
- (void) setDoubleAction: (SEL)aSelector;
- (SEL) doubleAction;
- (void) setErrorAction: (SEL)aSelector;
- (SEL) errorAction;
- (BOOL) sendAction;
- (void) sendAction: (SEL)aSelector
to: (id)anObject
forAllCells: (BOOL)flag;
- (void) sendDoubleAction;
- (void) setErrorAction: (SEL)aSelector;
//
// Handling Event and Action Messages
//
- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent;
- (void)mouseDown:(NSEvent *)theEvent;
- (int)mouseDownFlags;
- (BOOL)performKeyEquivalent:(NSEvent *)theEvent;
/*
* Handling Event and Action Messages
*/
- (BOOL) acceptsFirstMouse: (NSEvent *)theEvent;
- (void) mouseDown: (NSEvent *)theEvent;
- (int) mouseDownFlags;
- (BOOL) performKeyEquivalent: (NSEvent *)theEvent;
//
// Managing the Cursor
//
- (void)resetCursorRects;
/*
* Managing the Cursor
*/
- (void) resetCursorRects;
@end
#endif // _GNUstep_H_NSMatrix
#endif /* _GNUstep_H_NSMatrix */

File diff suppressed because it is too large Load diff