NSTable* classes added.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4619 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Michael Silva 1999-07-19 19:13:10 +00:00
parent 6b38ae2e96
commit 6a4261c380
5 changed files with 258 additions and 0 deletions

View file

@ -1,3 +1,18 @@
1999-07-19 Michael Hanni <mhanni@sprintmail.com>
* Source/NSTableView.m: very incomplete implementation.
* Source/NSTableColumn.m: mostly complete NSTableColumn
implementation.
* Source/NSTableHeaderView.m: some coding left when NSTableView
works.
* Source/NSTableHeaderCell.m: once all is drawing this should be
corrected.
None of this is built for good reason. The code is not finished,
and the interfaces are not written. But committing them to CVS
makes it much easier for me to develop on the multiple machines I
use.
1999-07-18 Michael Hanni <mhanni@sprintmail.com>
* Source/NSPopUpButtonCell.m: removed debug code. Makes

139
Source/NSTableColumn.m Normal file
View file

@ -0,0 +1,139 @@
@implementation NSTableColumn
- (id)initWithIdentifier:(id)anObject
{
[super init];
tbcol_cell = [NSTableHeaderCell new];
if ([anObject isKindOfClass:[NSString class]])
[tbcol_cell setStringValue:anObject];
else
[tbcol_cell setImage:anObject];
ASSIGN(tbcol_identifier, anObject);
return self;
}
- (void)setIdentifier:(id)anObject
{
ASSIGN(tbcol_identifier, anObject);
}
- (id)identifier
{
return tbcol_identifier;
}
- (void)setTableView:(NSTableView *)aTableView
{
ASSIGN(tbcol_tableview, aTableView);
}
- (NSTableView *)tableView
{
return tbcol_tableview;
}
// Sizing.
- (void)setWidth:(float)newWidth
{
if (newWidth > tbcol_maxWidth)
tbcol_width = tbcol_maxWidth;
else if (newWidth < tbcol_minWidth)
tbcol_width = tbcol_minWidth;
else
tbcol_width = newWidth;
}
- (float)width
{
return tbcol_width;
}
- (void)setMinWidth:(float)minWidth
{
tbcol_minWidth = minWidth;
}
- (float)minWidth
{
return tbcol_minWidth;
}
- (void)setMaxWidth:(float)maxWidth
{
tbcol_maxWidth = maxWidth;
}
- (float)maxWidth
{
return maxWidth;
}
- (void)setResizable:(BOOL)flag
{
tbcol_resizable = flag;
}
- (BOOL)isResizable
{
return tbcol_resizable;
}
- (void)sizeToFit
{
NSSize cell_size = [tbcol_cell cellSize];
BOOL changed = NO;
if (tbcol_width != cell_size.width)
{
tbcol_width = cell_size.width;
changed = YES;
}
if (cellSize.width > tbcol_maxWidth)
tbcol_maxWidth = cellSize.width;
if (cellSize.width < tbcol_minWidth)
tbcol_minWidth = cellSize.width;
if (changed)
[tbcol_tableview setNeedsDisplay:YES];
}
- (void)setEditable:(BOOL)flag
{
tbcol_editable = flag;
}
- (BOOL)isEditable
{
return tbcol_editable;
}
// This cell is the cell used to draw the header.
- (void)setHeaderCell:(NSCell *)aCell
{
ASSIGN(tbcol_cell, aCell);
}
- (id)headerCell
{
return tbcol_cell;
}
// This cell is used to draw the items in this column.
- (void)setDataCell:(NSCell *)aCell
{
ASSIGN(tbcol_datacell, aCell);
}
- (id)dataCell
{
return tbcol_datacell;
}
@end

View file

@ -0,0 +1,9 @@
@implementation NSTableHeaderCell
- (void)drawInteriorWithFrame:(NSRect)cellFrame
inView:(NSView *)controlView
{
[[NSColor darkGrayColor] set];
NSRectFill(cellFrame);
[super drawInteriorWithFrame: cellFrame inView: controlView];
}
@end

View file

@ -0,0 +1,44 @@
@implementation NSTableHeaderView
- (void)setTableView:(NSTableView *)aTableView
{
ASSIGN(tbhv_tableview, aTableView);
}
- (NSTableView *)tableView
{
return tbhv_tableview;
}
- (int)draggedColumn
{
// more thought has to go into this, though the default case is -1.
return -1;
}
- (float)draggedDistance
{
// return horizontal distance from last location.
return -1;
}
- (int)resizedColumn
{
// index of resized column?
return -1;
}
- (int)columnAtPoint:(NSPoint)aPoint
{
// black magic here to deduce the column at point, quite easy.
return -1; // No such column
}
- (NSRect)headerRectOfColumn:(int)columnIndex
{
// bzzt. weird.
}
@end

51
Source/NSTableView.m Normal file
View file

@ -0,0 +1,51 @@
@implementation NSTableView
- (id)initWithFrame:(NSRect)frameRect
{
self = [super initWithFrame:frameRect];
tbv_headerview = [[NSTableHeaderView alloc] initWithFrame:NSZeroRect];
}
- (void)setDataSource:(id)anObject
{
// This method raises an NSInternalInconistencyException if anObject
// doesn't respond to either
// numberOfRowsInTableView: or tableView:objectValueForTableColumn:row:.
ASSIGN(tb_datasource, anObject);
[self tile];
}
- (id)dataSource
{
return tb_datasource;
}
- (void)reloadData
{
// anything else?
[self setNeedsDisplay:YES];
}
- (void)setDoubleAction:(SEL)aSelector
{
}
- (SEL)doubleAction
{
}
- (int)clickedColumn
{
return -1;
}
- (int)clickedRow
{
return -1;
}
@end