Source/NSTableView.m

Source/NSTableColumn.m


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@13269 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Pierre-Yves Rivaille 2002-03-29 16:04:24 +00:00
parent 975edabd6f
commit ec12ecf723
3 changed files with 99 additions and 16 deletions

View file

@ -1,3 +1,13 @@
2002-03-29 Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
* Source/NSTableView.m ([NSTableView -encodeWithCoder:]):
([NSTableView -initWithCoder:]): encodes _allowsColumnReordering.
* Source/NSTableView.m (computeNewSelection):
fixed bug when updating selection.
* Source/NSTableColumn.m ([NSTableColumn -encodeWithCoder:]):
([NSTableColumn -initWithCoder:]): new encoding scheme
(fixes a bug when decoding a tableview)
Thu Mar 28 11:08:56 2002 Nicola Pero <n.pero@mi.flashnet.it>
Patches by Jeff Teunissen <deek@d2dc.net>:

View file

@ -81,7 +81,7 @@
+ (void) initialize
{
if (self == [NSTableColumn class])
[self setVersion: 1];
[self setVersion: 2];
}
/*
@ -370,29 +370,52 @@
- (void) encodeWithCoder: (NSCoder*)aCoder
{
[aCoder encodeObject: _identifier];
[aCoder encodeObject: _headerCell];
[aCoder encodeObject: _dataCell];
[aCoder encodeValueOfObjCType: @encode(float) at: &_width];
[aCoder encodeValueOfObjCType: @encode(float) at: &_min_width];
[aCoder encodeValueOfObjCType: @encode(float) at: &_max_width];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_is_resizable];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_is_editable];
[aCoder encodeObject: _headerCell];
[aCoder encodeObject: _dataCell];
}
- (id) initWithCoder: (NSCoder*)aDecoder
{
self = [super init];
_identifier = RETAIN([aDecoder decodeObject]);
_headerCell = RETAIN([aDecoder decodeObject]);
_dataCell = RETAIN([aDecoder decodeObject]);
int version = [aDecoder versionForClassName:
@"NSTableColumn"];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_width];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_min_width];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_max_width];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_is_resizable];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_is_editable];
return self;
if (version == 2)
{
self = [super init];
_identifier = RETAIN([aDecoder decodeObject]);
[aDecoder decodeValueOfObjCType: @encode(float) at: &_width];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_min_width];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_max_width];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_is_resizable];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_is_editable];
_headerCell = RETAIN([aDecoder decodeObject]);
_dataCell = RETAIN([aDecoder decodeObject]);
return self;
}
else
{
self = [super init];
_identifier = RETAIN([aDecoder decodeObject]);
_headerCell = RETAIN([aDecoder decodeObject]);
_dataCell = RETAIN([aDecoder decodeObject]);
[aDecoder decodeValueOfObjCType: @encode(float) at: &_width];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_min_width];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_max_width];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_is_resizable];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_is_editable];
return self;
}
}
@end

View file

@ -48,7 +48,7 @@
#include <math.h>
static NSNotificationCenter *nc = nil;
static const int currentVersion = 2;
static const int currentVersion = 3;
static NSRect oldDraggingRect;
static int oldDropRow;
@ -2227,7 +2227,7 @@ static void computeNewSelection
if (((pos = [_selectedRows
indexOfObject:
[NSNumber numberWithInt: i]])
!= NSNotFound) && (count > 0))
!= NSNotFound) && (count > 1))
{
[tv setNeedsDisplayInRect:
[tv rectOfRow: i]];
@ -2261,7 +2261,7 @@ static void computeNewSelection
if (((pos = [_selectedRows
indexOfObject:
[NSNumber numberWithInt: i]])
!= NSNotFound) && (count > 0))
!= NSNotFound) && (count > 1))
{
[tv setNeedsDisplayInRect:
[tv rectOfRow: i]];
@ -6320,6 +6320,7 @@ byExtendingSelection: (BOOL)flag
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_allowsEmptySelection];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_allowsColumnSelection];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_allowsColumnResizing];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_allowsColumnReordering];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_autoresizesAllColumnsToFit];
}
@ -6352,6 +6353,55 @@ byExtendingSelection: (BOOL)flag
[aDecoder decodeValueOfObjCType: @encode(int) at: &_numberOfRows];
[aDecoder decodeValueOfObjCType: @encode(int) at: &_numberOfColumns];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_drawsGrid];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_rowHeight];
[aDecoder decodeValueOfObjCType: @encode(SEL) at: &_doubleAction];
_intercellSpacing = [aDecoder decodeSize];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_allowsMultipleSelection];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_allowsEmptySelection];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_allowsColumnSelection];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_allowsColumnResizing];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_allowsColumnReordering];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_autoresizesAllColumnsToFit];
ASSIGN (_selectedColumns, [NSMutableArray array]);
ASSIGN (_selectedRows, [NSMutableArray array]);
if (_numberOfColumns)
_columnOrigins = NSZoneMalloc (NSDefaultMallocZone (),
sizeof(float) * _numberOfColumns);
_clickedRow = -1;
_clickedColumn = -1;
_selectingColumns = NO;
_selectedColumn = -1;
_selectedRow = -1;
_editedColumn = -1;
_editedRow = -1;
[self tile];
}
else if (version == 2)
{
self = [super initWithCoder: aDecoder];
_dataSource = [aDecoder decodeObject];
_tableColumns = RETAIN([aDecoder decodeObject]);
_gridColor = RETAIN([aDecoder decodeObject]);
_backgroundColor = RETAIN([aDecoder decodeObject]);
_headerView = RETAIN([aDecoder decodeObject]);
_cornerView = RETAIN([aDecoder decodeObject]);
aDelegate = [aDecoder decodeObject];
_target = [aDecoder decodeObject];
[self setDelegate: aDelegate];
[_headerView setTableView: self];
[_tableColumns makeObjectsPerformSelector: @selector(setTableView:)
withObject: self];
[aDecoder decodeValueOfObjCType: @encode(int) at: &_numberOfRows];
[aDecoder decodeValueOfObjCType: @encode(int) at: &_numberOfColumns];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_drawsGrid];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_rowHeight];
[aDecoder decodeValueOfObjCType: @encode(SEL) at: &_doubleAction];