diff --git a/ChangeLog b/ChangeLog index 0e19010ef..105d0d0d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,11 @@ * Source/NSMenu.m: commented out code which did multiple menu movement as it was breaking things. Need to rethink that. + * Headers/NSTableColumn.h + Headers/NSTableHeaderView.h + Headers/NSTableHeaderCell.h + Headers/NSTableView.h: added files. + * Source/GNUMakefile: compile in NSTable classes. 1999-07-31 Michael Hanni diff --git a/Headers/gnustep/gui/NSTableColumn.h b/Headers/gnustep/gui/NSTableColumn.h new file mode 100644 index 000000000..1dbb43e3d --- /dev/null +++ b/Headers/gnustep/gui/NSTableColumn.h @@ -0,0 +1,49 @@ +#ifndef _GNUstep_H_NSTableColumn +#define _GNUstep_H_NSTableColumn + +#include + +#include +#include + +@interface NSTableColumn : NSObject +{ + NSTableHeaderCell *tbcol_cell; + NSTableView *tbcol_tableview; + id tbcol_datacell; + id tbcol_identifier; + float tbcol_maxWidth; + float tbcol_minWidth; + float tbcol_width; + BOOL tbcol_resizable; + BOOL tbcol_editable; +} + +- (id)initWithIdentifier:(id)anObject; +- (void)setIdentifier:(id)anObject; +- (id)identifier; +- (void)setTableView:(NSTableView *)aTableView; +- (NSTableView *)tableView; + +// Sizing. + +- (void)setWidth:(float)newWidth; +- (float)width; +- (void)setMinWidth:(float)minWidth; +- (float)minWidth; +- (void)setMaxWidth:(float)maxWidth; +- (float)maxWidth; +- (void)setResizable:(BOOL)flag; +- (BOOL)isResizable; +- (void)sizeToFit; +- (void)setEditable:(BOOL)flag; +- (BOOL)isEditable; +- (void)setHeaderCell:(NSCell *)aCell; +- (id)headerCell; +- (void)setDataCell:(NSCell *)aCell; +- (id)dataCell; +@end + +extern NSString *NSTableViewColumnDidResizeNotification; + +#endif diff --git a/Headers/gnustep/gui/NSTableHeaderCell.h b/Headers/gnustep/gui/NSTableHeaderCell.h new file mode 100644 index 000000000..59308cfa2 --- /dev/null +++ b/Headers/gnustep/gui/NSTableHeaderCell.h @@ -0,0 +1,11 @@ +#ifndef _GNUstep_H_NSTableHeaderCell +#define _GNUstep_H_NSTableHeaderCell + +#include + +@interface NSTableHeaderCell : NSTextFieldCell +{ +} +@end + +#endif diff --git a/Headers/gnustep/gui/NSTableHeaderView.h b/Headers/gnustep/gui/NSTableHeaderView.h new file mode 100644 index 000000000..216083865 --- /dev/null +++ b/Headers/gnustep/gui/NSTableHeaderView.h @@ -0,0 +1,21 @@ +#ifndef _GNUstep_H_NSTableHeaderView +#define _GNUstep_H_NSTableHeaderView + +#include + +@class NSTableView; + +@interface NSTableHeaderView : NSView +{ + NSTableView *tbhv_tableview; +} +- (void)setTableView:(NSTableView *)aTableView; +- (NSTableView *)tableView; +- (int)draggedColumn; +- (float)draggedDistance; +- (int)resizedColumn; +- (int)columnAtPoint:(NSPoint)aPoint; +- (NSRect)headerRectOfColumn:(int)columnIndex; +@end + +#endif diff --git a/Headers/gnustep/gui/NSTableView.h b/Headers/gnustep/gui/NSTableView.h new file mode 100644 index 000000000..fa66c10ea --- /dev/null +++ b/Headers/gnustep/gui/NSTableView.h @@ -0,0 +1,147 @@ +#ifndef _GNUstep_H_NSTableView +#define _GNUstep_H_NSTableView + +#include +#include + +@class NSColor; +@class NSTableColumn; +@class NSTableHeaderView; +@class NSView; + +@interface NSTableView : NSControl +{ + id delegate; + id tb_datasource; + BOOL tbv_allowsColumnReordering; + BOOL tbv_allowsColumnResizing; + BOOL tbv_allowsMultipleSelection; + BOOL tbv_allowsEmptySelection; + BOOL tbv_allowsColumnSelection; + BOOL tbv_autoresizesAllColumnsToFit; + NSSize tbv_interCellSpacing; + float tbv_rowHeight; + NSColor *tbv_backgroundColor; + NSMutableArray *tbv_columns; + NSMutableArray *tbv_selectedColumns; + NSMutableArray *tbv_selectedRows; + BOOL tbv_drawsGrid; + NSColor *tbv_gridColor; + NSTableHeaderView *tbv_headerView; + NSView *tbv_cornerView; +} +- (id)initWithFrame:(NSRect)frameRect; +- (void)setDataSource:(id)anObject; +- (id)dataSource; +- (void)reloadData; +- (void)setDoubleAction:(SEL)aSelector; +- (SEL)doubleAction; +- (int)clickedColumn; +- (int)clickedRow; +- (void)setAllowsColumnReordering:(BOOL)flag; +- (BOOL)allowsColumnReordering; +- (void)setAllowsColumnResizing:(BOOL)flag; +- (BOOL)allowsColumnResizing; +- (void)setAllowsMultipleSelection:(BOOL)flag; +- (BOOL)allowsMultipleSelection; +- (void)setAllowsEmptySelection:(BOOL)flag; +- (BOOL)allowsEmptySelection; +- (void)setAllowsColumnSelection:(BOOL)flag; +- (BOOL)allowsColumnSelection; +- (void)setIntercellSpacing:(NSSize)aSize; +- (NSSize)intercellSpacing; +- (void)setRowHeight:(float)rowHeight; +- (float)rowHeight; +- (void)setBackgroundColor:(NSColor *)aColor; +- (NSColor *)backgroundColor; +- (void)addTableColumn:(NSTableColumn *)aColumn; +- (void)removeTableColumn:(NSTableColumn *)aTableColumn; +- (void)moveColumn:(int)columnIndex + toColumn:(int)newIndex; +- (NSArray *)tableColumns; +- (int)columnWithIdentifier:(id)anObject; +- (NSTableColumn *)tableColumnWithIdentifier:(id)anObject; +- (void)selectColumn:(int)columnIndex byExtendingSelection:(BOOL)flag; +- (void)selectRow:(int)rowIndex byExtendingSelection:(BOOL)flag; +- (void)deselectColumn:(int)columnIndex; +- (void)deselectRow:(int)rowIndex; +- (int)numberOfSelectedColumns; +- (int)numberOfSelectedRows; +- (int)selectedColumn; +- (int)selectedRow; +- (BOOL)isColumnSelected:(int)columnIndex; +- (BOOL)isRowSelected:(int)rowIndex; +- (NSEnumerator *)selectedColumnEnumerator; +- (NSEnumerator *)selectedRowEnumerator; +- (void)selectAll:(id)sender; +- (void)deselectAll:(id)sender; +- (int)numberOfColumns; +- (int)numberOfRows; +- (void)setDrawsGrid:(BOOL)flag; +- (BOOL)drawsGrid; +- (void)setGridColor:(NSColor *)aColor ; +- (NSColor *)gridColor; +- (void)editColumn:(int)columnIndex + row:(int)rowIndex + withEvent:(NSEvent *)theEvent + select:(BOOL)flag; +- (int)editedRow; +- (int)editedColumn; +- (void)setHeaderView:(NSTableHeaderView *)aHeaderView; +- (NSTableHeaderView *)headerView; +- (void)setCornerView:(NSView *)aView; +- (NSView *)cornerView; +- (NSRect)rectOfColumn:(int)columnIndex; +- (NSRect)rectOfRow:(int)rowIndex; +- (NSRange)columnsInRect:(NSRect)aRect; +- (NSRange)rowsInRect:(NSRect)aRect; +- (int)columnAtPoint:(NSPoint)aPoint; +- (int)rowAtPoint:(NSPoint)aPoint; +- (NSRect)frameOfCellAtColumn:(int)columnIndex + row:(int)rowIndex; +- (void)setAutoresizesAllColumnsToFit:(BOOL)flag; +- (BOOL)autoresizesAllColumnsToFit; +- (void)sizeLastColumnToFit; +- (void)sizeToFit; +- (void)noteNumberOfRowsChanged; +- (void)tile; +- (void)drawRow:(int)rowIndex + clipRect:(NSRect)clipRect; +- (void)drawGridInClipRect:(NSRect)aRect; +- (void)highlightSelectionInClipRect:(NSRect)clipRect; +- (void)scrollRowToVisible:(int)rowIndex; +- (void)scrollColumnToVisible:(int)columnIndex; +- (BOOL)textShouldBeginEditing:(NSText *)textObject; +- (void)textDidBeginEditing:(NSNotification *)aNotification; +- (void)textDidChange:(NSNotification *)aNotification; +- (BOOL)textShouldEndEditing:(NSText *)textObject; +- (void)textDidEndEditing:(NSNotification *)aNotification; +@end + +@interface NSObject(NSTableViewDelegate) +- (void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(int)row; +- (BOOL)tableView:(NSTableView *)tableView shouldEditTableColumn:(NSTableColumn *)tableColumn row:(int)row; +- (BOOL)selectionShouldChangeInTableView:(NSTableView *)aTableView; +- (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(int)row; +- (BOOL)tableView:(NSTableView *)tableView shouldSelectTableColumn:(NSTableColumn *)tableColumn; +@end + +@interface NSObject(NSTableViewNotifications) +- (void)tableViewSelectionDidChange:(NSNotification *)notification; +- (void)tableViewColumnDidMove:(NSNotification *)notification; +- (void)tableViewColumnDidResize:(NSNotification *)notification; +- (void)tableViewSelectionIsChanging:(NSNotification *)notification; +@end + +@interface NSObject(NSTableDataSource) +- (int)numberOfRowsInTableView:(NSTableView *)tableView; +- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row; +- (void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(int)row; +@end + +extern NSString *NSTableViewSelectionDidChangeNotification; +extern NSString *NSTableViewColumnDidMoveNotification; // @"NSOldColumn", @"NSNewColumn" +extern NSString *NSTableViewColumnDidResizeNotification; // @"NSTableColumn", @"NSOldWidth" +extern NSString *NSTableViewSelectionIsChangingNotification; + +#endif diff --git a/Source/GNUmakefile b/Source/GNUmakefile index dbb5b3fe0..e53665f7e 100644 --- a/Source/GNUmakefile +++ b/Source/GNUmakefile @@ -109,6 +109,10 @@ NSSplitView.m \ NSStringDrawing.m \ NSTabView.m \ NSTabViewItem.m \ +NSTableColumn.m \ +NSTableHeaderView.m \ +NSTableHeaderCell.m \ +NSTableView.m \ NSText.m \ NSTextContainer.m \ NSTextField.m \ @@ -212,6 +216,10 @@ AppKit/NSSplitView.h \ AppKit/NSStringDrawing.h \ AppKit/NSTabView.h \ AppKit/NSTabViewItem.h \ +AppKit/NSTableColumn.m \ +AppKit/NSTableHeaderView.m \ +AppKit/NSTableHeaderCell.m \ +AppKit/NSTableView.m \ AppKit/NSText.h \ AppKit/NSTextAttachment.h \ AppKit/NSTextContainer.h \ diff --git a/Source/NSTableColumn.m b/Source/NSTableColumn.m index b8f947aa5..8f7ea0708 100644 --- a/Source/NSTableColumn.m +++ b/Source/NSTableColumn.m @@ -1,3 +1,5 @@ +#include + @implementation NSTableColumn - (id)initWithIdentifier:(id)anObject { diff --git a/Source/NSTableHeaderCell.m b/Source/NSTableHeaderCell.m index 3d08a3caa..99bc37cc4 100644 --- a/Source/NSTableHeaderCell.m +++ b/Source/NSTableHeaderCell.m @@ -1,3 +1,6 @@ +#include +#include + @implementation NSTableHeaderCell - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView diff --git a/Source/NSTableHeaderView.m b/Source/NSTableHeaderView.m index c7a01e2a7..a6ee7a673 100644 --- a/Source/NSTableHeaderView.m +++ b/Source/NSTableHeaderView.m @@ -1,3 +1,5 @@ +#include + @implementation NSTableHeaderView - (void)setTableView:(NSTableView *)aTableView { diff --git a/Source/NSTableView.m b/Source/NSTableView.m index b50990e6e..7958991f6 100644 --- a/Source/NSTableView.m +++ b/Source/NSTableView.m @@ -1,4 +1,9 @@ +#include +#include +#include #include +#include +#include @implementation NSTableView - (id)initWithFrame:(NSRect)frameRect @@ -138,7 +143,7 @@ - (NSColor *)backgroundColor { - return aColor; + return tbv_backgroundColor; } - (void)addTableColumn:(NSTableColumn *)aColumn @@ -168,6 +173,7 @@ - (int)columnWithIdentifier:(id)anObject { int howMany = [tbv_columns count]; + int i; for (i=0;i 0 && aRect.size.height > 0) { for (i=0;i 0 && bRect.size.height > 0) { if (!location) location = i; @@ -455,22 +463,25 @@ object with the NSTableView as the text delegate. */ return NSMakeRange(location, length); } + return NSMakeRange(0, 0); } - (NSRange)rowsInRect:(NSRect)aRect { int howMany = [self numberOfRows]; - int location; - int length; + int location = 0; + int length = 0; + int i; if (aRect.size.width > 0 && aRect.size.height > 0) { for (i=0;i 0 && bRect.size.height > 0) { if (!location) location = i; @@ -490,10 +501,11 @@ object with the NSTableView as the text delegate. */ - (int)columnAtPoint:(NSPoint)aPoint { int howMany = [tbv_columns count]; + int i; for (i=0;i