diff --git a/ChangeLog b/ChangeLog index a92e44b71..953e99ce7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2007-11-22 Fred Kiefer + + * Source/NSNibBindingConnector.m: Completed implementation. + * Source/NSTableView.m (-_initDefaults): New method for shared + default settings. + * Source/NSTableView.m (-initWithFrame:, initWithCoder:): Use this + new method. + * Source/NSGraphicsContext.m (-GSDrawImage::): Moved implemenation + to back. + 2007-11-22 Fred Kiefer * Headers/AppKit/NSGraphics.h: Make NSDrawBitmap a real function. diff --git a/Source/NSGraphicsContext.m b/Source/NSGraphicsContext.m index 3830fe43b..fb5da2a34 100644 --- a/Source/NSGraphicsContext.m +++ b/Source/NSGraphicsContext.m @@ -1465,16 +1465,7 @@ NSGraphicsContext *GSCurrentContext(void) been implemented yet, so it should not be used anywhere. */ - (void) GSDrawImage: (NSRect)rect: (void *)imageref { - NSBitmapImageRep *bitmap; - const unsigned char *data[5]; - - bitmap = (NSBitmapImageRep*)imageref; - [bitmap getBitmapDataPlanes: &data]; - [self NSDrawBitmap: rect : [bitmap pixelsWide] : [bitmap pixelsHigh] - : [bitmap bitsPerSample] : [bitmap samplesPerPixel] - : [bitmap bitsPerPixel] : [bitmap bytesPerRow] : [bitmap isPlanar] - : [bitmap hasAlpha] : [bitmap colorSpaceName] - : data]; + [self subclassResponsibility: _cmd]; } /* ----------------------------------------------------------------------- */ diff --git a/Source/NSNibBindingConnector.m b/Source/NSNibBindingConnector.m index 0f88d0b39..621de4daa 100644 --- a/Source/NSNibBindingConnector.m +++ b/Source/NSNibBindingConnector.m @@ -1,4 +1,4 @@ -/** NSNibAXAttributeConnector +/** NSNibBindingConnector @@ -7,6 +7,8 @@ Author: Gregory John Casamento Date: 2007 + Author: Fred Kiefer + Date: Nov 2007 This file is part of the GNUstep GUI Library. @@ -30,8 +32,18 @@ #import #import #import +#import @implementation NSNibBindingConnector + +- (void) dealloc +{ + RELEASE(_binding); + RELEASE(_keyPath); + RELEASE(_options); + [super dealloc]; +} + - (NSString *) binding { return _binding; @@ -61,4 +73,102 @@ { ASSIGN(_options, options); } + +- (void) replaceObject: (id)anObject withObject: (id)anotherObject +{ + if (_binding == anObject) + { + ASSIGN(_binding, anotherObject); + } + if (_keyPath == anObject) + { + ASSIGN(_keyPath, anotherObject); + } + if (_options == anObject) + { + ASSIGN(_options, anotherObject); + } + + [super replaceObject: anObject withObject: anotherObject]; +} + +- (void) establishConnection +{ + [_dst bind: _binding + toObject: _src + withKeyPath: _keyPath + options: _options]; +} + +- (void) encodeWithCoder: (NSCoder*)aCoder +{ + if ([aCoder allowsKeyedCoding]) + { + if (_binding != nil) + { + [aCoder encodeObject: _binding forKey: @"NSBinding"]; + } + if (_keyPath != nil) + { + [aCoder encodeObject: _keyPath forKey: @"NSKeyPath"]; + } + if (_options != nil) + { + [aCoder encodeObject: _options forKey: @"NSOptions"]; + } + } + else + { + [aCoder encodeObject: _binding]; + [aCoder encodeObject: _keyPath]; + [aCoder encodeObject: _options]; + } +} + +- (id) initWithCoder: (NSCoder*)aDecoder +{ + if (!(self = [super initWithCoder: aDecoder])) + { + return nil; + } + + if ([aDecoder allowsKeyedCoding]) + { + if ([aDecoder decodeIntForKey: @"NSNibBindingConnectorVersion"] != 2) + { + RELEASE(self); + return nil; + } + if ([aDecoder containsValueForKey: @"NSBinding"]) + { + ASSIGN(_binding, [aDecoder decodeObjectForKey: @"NSBinding"]); + } + if ([aDecoder containsValueForKey: @"NSKeyPath"]) + { + ASSIGN(_keyPath, [aDecoder decodeObjectForKey: @"NSKeyPath"]); + } + if ([aDecoder containsValueForKey: @"NSOptions"]) + { + ASSIGN(_options, [aDecoder decodeObjectForKey: @"NSOptions"]); + } + } + else + { + [aDecoder decodeValueOfObjCType: @encode(id) at: &_binding]; + [aDecoder decodeValueOfObjCType: @encode(id) at: &_keyPath]; + [aDecoder decodeValueOfObjCType: @encode(id) at: &_options]; + } + + return self; +} + +- (NSString *) description +{ + return [NSString stringWithFormat: @"<%@ binding=%@ keypath=%@ options=%@>", + [super description], + [self binding], + [self keyPath], + [self options]]; +} + @end diff --git a/Source/NSTableView.m b/Source/NSTableView.m index 9abf0e3e6..5d2e22c49 100644 --- a/Source/NSTableView.m +++ b/Source/NSTableView.m @@ -1979,28 +1979,41 @@ static void computeNewSelection * Initializing/Releasing */ -- (id) initWithFrame: (NSRect)frameRect +- (void) _initDefaults { - self = [super initWithFrame: frameRect]; _drawsGrid = YES; _rowHeight = 16.0; _intercellSpacing = NSMakeSize (5.0, 2.0); - ASSIGN (_gridColor, [NSColor gridColor]); - ASSIGN (_backgroundColor, [NSColor controlBackgroundColor]); - ASSIGN (_tableColumns, [NSMutableArray array]); - ASSIGN (_selectedColumns, [NSMutableIndexSet indexSet]); - ASSIGN (_selectedRows, [NSMutableIndexSet indexSet]); + ASSIGN(_selectedColumns, [NSMutableIndexSet indexSet]); + ASSIGN(_selectedRows, [NSMutableIndexSet indexSet]); _allowsEmptySelection = YES; _allowsMultipleSelection = NO; _allowsColumnSelection = YES; _allowsColumnResizing = YES; _allowsColumnReordering = YES; _autoresizesAllColumnsToFit = NO; + _selectingColumns = NO; + _verticalMotionDrag = NO; _editedColumn = -1; _editedRow = -1; + _clickedRow = -1; + _clickedColumn = -1; _selectedColumn = -1; _selectedRow = -1; _highlightedTableColumn = nil; +} + +- (id) initWithFrame: (NSRect)frameRect +{ + self = [super initWithFrame: frameRect]; + if (!self) + return self; + + [self _initDefaults]; + ASSIGN(_gridColor, [NSColor gridColor]); + ASSIGN(_backgroundColor, [NSColor controlBackgroundColor]); + ASSIGN(_tableColumns, [NSMutableArray array]); + _headerView = [NSTableHeaderView new]; [_headerView setFrameSize: NSMakeSize (frameRect.size.width, 22.0)]; [_headerView setTableView: self]; @@ -5563,13 +5576,13 @@ static BOOL selectContiguousRegion(NSTableView *self, [aCoder encodeObject: [self tableColumns] forKey: @"NSTableColumns"]; if (_headerView) - { - [aCoder encodeObject: _headerView forKey: @"NSHeaderView"]; - } + { + [aCoder encodeObject: _headerView forKey: @"NSHeaderView"]; + } if (_cornerView) - { - [aCoder encodeObject: _cornerView forKey: @"NSCornerView"]; - } + { + [aCoder encodeObject: _cornerView forKey: @"NSCornerView"]; + } tableViewFlags.columnSelection = [self allowsColumnSelection]; tableViewFlags.multipleSelection = [self allowsMultipleSelection]; @@ -5616,140 +5629,128 @@ static BOOL selectContiguousRegion(NSTableView *self, - (id) initWithCoder: (NSCoder*)aDecoder { self = [super initWithCoder: aDecoder]; + if (!self) + return self; if ([aDecoder allowsKeyedCoding]) { - NSSize intercellSpacing = [self intercellSpacing]; + NSSize intercellSpacing; NSArray *columns; NSEnumerator *e; NSTableColumn *col; // assign defaults, so that there's color in case none is specified - ASSIGN (_gridColor, [NSColor gridColor]); - ASSIGN (_backgroundColor, [NSColor controlBackgroundColor]); - ASSIGN (_tableColumns, [NSMutableArray array]); - ASSIGN (_selectedColumns, [NSMutableIndexSet indexSet]); - ASSIGN (_selectedRows, [NSMutableIndexSet indexSet]); + [self _initDefaults]; + ASSIGN(_gridColor, [NSColor gridColor]); + ASSIGN(_backgroundColor, [NSColor controlBackgroundColor]); + ASSIGN(_tableColumns, [NSMutableArray array]); - _autoresizesAllColumnsToFit = NO; - _clickedRow = -1; - _clickedColumn = -1; - _drawsGrid = YES; - _editedColumn = -1; - _editedRow = -1; - _highlightedTableColumn = nil; - _intercellSpacing = NSMakeSize (5.0, 2.0); - _rowHeight = 16.0; - _selectedColumn = -1; - _selectedRow = -1; - _selectingColumns = NO; - - /* - _headerView = [NSTableHeaderView new]; - [_headerView setFrameSize: NSMakeSize (_frame.size.width, 22.0)]; - [_headerView setTableView: self]; - */ - - [(NSKeyedUnarchiver *)aDecoder setClass: [GSTableCornerView class] forClassName: @"_NSCornerView"]; if ([aDecoder containsValueForKey: @"NSDataSource"]) - { - [self setDataSource: [aDecoder decodeObjectForKey: @"NSDataSource"]]; - } + { + [self setDataSource: [aDecoder decodeObjectForKey: @"NSDataSource"]]; + } if ([aDecoder containsValueForKey: @"NSDelegate"]) - { - [self setDelegate: [aDecoder decodeObjectForKey: @"NSDelegate"]]; - } + { + [self setDelegate: [aDecoder decodeObjectForKey: @"NSDelegate"]]; + } if ([aDecoder containsValueForKey: @"NSTarget"]) - { - [self setTarget: [aDecoder decodeObjectForKey: @"NSTarget"]]; - } + { + [self setTarget: [aDecoder decodeObjectForKey: @"NSTarget"]]; + } if ([aDecoder containsValueForKey: @"NSAction"]) { - NSString *action = [aDecoder decodeObjectForKey: @"NSAction"]; - [self setAction: NSSelectorFromString(action)]; - } + NSString *action = [aDecoder decodeObjectForKey: @"NSAction"]; + [self setAction: NSSelectorFromString(action)]; + } if ([aDecoder containsValueForKey: @"NSBackgroundColor"]) { - [self setBackgroundColor: [aDecoder decodeObjectForKey: @"NSBackgroundColor"]]; - } + [self setBackgroundColor: [aDecoder decodeObjectForKey: @"NSBackgroundColor"]]; + } if ([aDecoder containsValueForKey: @"NSGridColor"]) { - [self setGridColor: [aDecoder decodeObjectForKey: @"NSGridColor"]]; - } + [self setGridColor: [aDecoder decodeObjectForKey: @"NSGridColor"]]; + } + + intercellSpacing = [self intercellSpacing]; if ([aDecoder containsValueForKey: @"NSIntercellSpacingHeight"]) { - intercellSpacing.height = [aDecoder decodeFloatForKey: @"NSIntercellSpacingHeight"]; - } + intercellSpacing.height = [aDecoder decodeFloatForKey: @"NSIntercellSpacingHeight"]; + } if ([aDecoder containsValueForKey: @"NSIntercellSpacingWidth"]) { - intercellSpacing.width = [aDecoder decodeFloatForKey: @"NSIntercellSpacingWidth"]; - } + intercellSpacing.width = [aDecoder decodeFloatForKey: @"NSIntercellSpacingWidth"]; + } [self setIntercellSpacing: intercellSpacing]; + if ([aDecoder containsValueForKey: @"NSRowHeight"]) { - [self setRowHeight: [aDecoder decodeFloatForKey: @"NSRowHeight"]]; - } + [self setRowHeight: [aDecoder decodeFloatForKey: @"NSRowHeight"]]; + } + [(NSKeyedUnarchiver *)aDecoder setClass: [GSTableCornerView class] + forClassName: @"_NSCornerView"]; if ([aDecoder containsValueForKey: @"NSCornerView"]) - { - NSRect viewFrame; - float rowHeight = [self rowHeight]; - - [self setCornerView: [aDecoder decodeObjectForKey: @"NSCornerView"]]; - viewFrame = [[self cornerView] frame]; - viewFrame.size.height = rowHeight; - [[self cornerView] setFrame: viewFrame]; - } + { + NSRect viewFrame; + float rowHeight = [self rowHeight]; + + [self setCornerView: [aDecoder decodeObjectForKey: @"NSCornerView"]]; + viewFrame = [[self cornerView] frame]; + viewFrame.size.height = rowHeight; + [[self cornerView] setFrame: viewFrame]; + } + else + { + _cornerView = [GSTableCornerView new]; + } - if ([aDecoder containsValueForKey: @"NSHeaderView"]) - { - NSRect viewFrame = [self frame]; - float rowHeight = [self rowHeight]; +// if ([aDecoder containsValueForKey: @"NSHeaderView"]) + { + NSRect viewFrame = [self frame]; + float rowHeight = [self rowHeight]; - _headerView = [[NSTableHeaderView alloc] init]; - [_headerView setFrameSize: NSMakeSize(viewFrame.size.width, rowHeight)]; - [_headerView setTableView: self]; - } + _headerView = [[NSTableHeaderView alloc] init]; + [_headerView setFrameSize: NSMakeSize(viewFrame.size.width, rowHeight)]; + [_headerView setTableView: self]; + } + if ([aDecoder containsValueForKey: @"NSTvFlags"]) + { + unsigned long flags = [aDecoder decodeIntForKey: @"NSTvFlags"]; + GSTableViewFlags tableViewFlags; + memcpy((void *)&tableViewFlags,(void *)&flags,sizeof(struct _tableViewFlags)); + + [self setAllowsColumnSelection: tableViewFlags.columnSelection]; + [self setAllowsMultipleSelection: tableViewFlags.multipleSelection]; + [self setAllowsEmptySelection: tableViewFlags.emptySelection]; + [self setDrawsGrid: tableViewFlags.drawsGrid]; + [self setAllowsColumnResizing: tableViewFlags.columnResizing]; + [self setAllowsColumnReordering: tableViewFlags.columnOrdering]; + } + // get the table columns... columns = [aDecoder decodeObjectForKey: @"NSTableColumns"]; e = [columns objectEnumerator]; while ((col = [e nextObject]) != nil) { - [self addTableColumn: col]; - [col setTableView: self]; - } + [self addTableColumn: col]; + [col setTableView: self]; + } - if ([aDecoder containsValueForKey: @"NSTvFlags"]) - { - unsigned long flags = [aDecoder decodeIntForKey: @"NSTvFlags"]; - GSTableViewFlags tableViewFlags; - memcpy((void *)&tableViewFlags,(void *)&flags,sizeof(struct _tableViewFlags)); - - [self setAllowsColumnSelection: tableViewFlags.columnSelection]; - [self setAllowsMultipleSelection: tableViewFlags.multipleSelection]; - [self setAllowsEmptySelection: tableViewFlags.emptySelection]; - [self setDrawsGrid: tableViewFlags.drawsGrid]; - [self setAllowsColumnResizing: tableViewFlags.columnResizing]; - [self setAllowsColumnReordering: tableViewFlags.columnOrdering]; - } - _numberOfColumns = [columns count]; - ASSIGN (_selectedColumns, [NSMutableIndexSet indexSet]); - ASSIGN (_selectedRows, [NSMutableIndexSet indexSet]); if (_numberOfColumns) - _columnOrigins = NSZoneMalloc (NSDefaultMallocZone (), - sizeof(float) * _numberOfColumns); + _columnOrigins = NSZoneMalloc(NSDefaultMallocZone (), + sizeof(float) * _numberOfColumns); [self tile]; } else { int version = [aDecoder versionForClassName: - @"NSTableView"]; + @"NSTableView"]; id aDelegate; - _verticalMotionDrag = NO; + [self _initDefaults]; _dataSource = [aDecoder decodeObject]; _tableColumns = RETAIN([aDecoder decodeObject]); _gridColor = RETAIN([aDecoder decodeObject]); @@ -5762,7 +5763,7 @@ static BOOL selectContiguousRegion(NSTableView *self, [self setDelegate: aDelegate]; [_headerView setTableView: self]; [_tableColumns makeObjectsPerformSelector: @selector(setTableView:) - withObject: self]; + withObject: self]; [aDecoder decodeValueOfObjCType: @encode(int) at: &_numberOfRows]; [aDecoder decodeValueOfObjCType: @encode(int) at: &_numberOfColumns]; @@ -5777,37 +5778,26 @@ static BOOL selectContiguousRegion(NSTableView *self, [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_allowsColumnResizing]; if (version >= 3) { - [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_allowsColumnReordering]; - } + [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_allowsColumnReordering]; + } if (version >= 2) { - [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_autoresizesAllColumnsToFit]; - } + [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_autoresizesAllColumnsToFit]; + } if (version >= 4) { [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_verticalMotionDrag]; } - - ASSIGN (_selectedColumns, [NSMutableIndexSet indexSet]); - ASSIGN (_selectedRows, [NSMutableIndexSet indexSet]); if (_numberOfColumns) - _columnOrigins = NSZoneMalloc (NSDefaultMallocZone (), - sizeof(float) * _numberOfColumns); - - _clickedRow = -1; - _clickedColumn = -1; - _selectingColumns = NO; - _selectedColumn = -1; - _selectedRow = -1; - _editedColumn = -1; - _editedRow = -1; + _columnOrigins = NSZoneMalloc (NSDefaultMallocZone (), + sizeof(float) * _numberOfColumns); if (version == 2) { - [self tile]; - } + [self tile]; + } } return self;