mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 10:50:37 +00:00
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:
parent
6b38ae2e96
commit
6a4261c380
5 changed files with 258 additions and 0 deletions
139
Source/NSTableColumn.m
Normal file
139
Source/NSTableColumn.m
Normal 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
|
9
Source/NSTableHeaderCell.m
Normal file
9
Source/NSTableHeaderCell.m
Normal 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
|
44
Source/NSTableHeaderView.m
Normal file
44
Source/NSTableHeaderView.m
Normal 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
51
Source/NSTableView.m
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue