diff --git a/Headers/AppKit/NSTableView.h b/Headers/AppKit/NSTableView.h index 94afe3cc8..8b0005648 100644 --- a/Headers/AppKit/NSTableView.h +++ b/Headers/AppKit/NSTableView.h @@ -109,7 +109,8 @@ typedef enum _NSTableViewColumnAutoresizingStyle NSString *_autosaveName; BOOL _verticalMotionDrag; NSArray *_sortDescriptors; - + NSTableViewColumnAutoresizingStyle _columnAutoresizingStyle; + /* * Ivars Acting as Control... */ diff --git a/Source/GSThemeDrawing.m b/Source/GSThemeDrawing.m index bf26ca150..d58d04d32 100644 --- a/Source/GSThemeDrawing.m +++ b/Source/GSThemeDrawing.m @@ -2286,8 +2286,15 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil}; columns = [tableView tableColumns]; highlightedTableColumn = [tableView highlightedTableColumn]; +#if 0 + NSLog(@"%s:rect: %@ super: %@ visible: %@ first: %d last: %d", __PRETTY_FUNCTION__, + NSStringFromRect(aRect), + NSStringFromRect([[tableView superview] frame]), + NSStringFromRect([(NSClipView*)[tableView superview] documentVisibleRect]), + firstColumnToDraw, lastColumnToDraw); +#endif - for (i = firstColumnToDraw; i < lastColumnToDraw; i++) + for (i = firstColumnToDraw; i <= lastColumnToDraw; i++) { column = [columns objectAtIndex: i]; width = [column width]; @@ -2302,48 +2309,36 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil}; { [cell setHighlighted: NO]; } +#if 0 + NSLog(@"%s:---> i: %d drawRect: %@", __PRETTY_FUNCTION__, i, NSStringFromRect(drawingRect)); +#endif [cell drawWithFrame: drawingRect - inView: tableHeaderView]; + inView: tableHeaderView]; drawingRect.origin.x += width; } + + // Fill out table header to end if needed... if (lastColumnToDraw == [tableView numberOfColumns] - 1) + { + // This is really here to handle extending the table headers using the + // WinUXTheme (or one equivalent to) that writes directly to the MS windows + // device contexts... + NSRect clipFrame = [(NSClipView*)[tableView superview] documentVisibleRect]; + CGFloat maxWidth = NSMaxX(clipFrame); + if (drawingRect.origin.x < maxWidth) { + drawingRect.size.width = maxWidth - drawingRect.origin.x; column = [columns objectAtIndex: lastColumnToDraw]; - width = [column width] - 1; - drawingRect.size.width = width; - cell = [column headerCell]; - if ((column == highlightedTableColumn) - || [tableView isColumnSelected: lastColumnToDraw]) - { - [cell setHighlighted: YES]; - } - else - { - [cell setHighlighted: NO]; - } + cell = [column headerCell]; //AUTORELEASE([[column headerCell] copy]); + //[cell setTitle:@""]; + [cell setHighlighted: NO]; +#if 0 + NSLog(@"%s:---> i: %d drawRect: %@", __PRETTY_FUNCTION__, -2, NSStringFromRect(drawingRect)); +#endif [cell drawWithFrame: drawingRect - inView: tableHeaderView]; - drawingRect.origin.x += width; - } - else - { - column = [columns objectAtIndex: lastColumnToDraw]; - width = [column width]; - drawingRect.size.width = width; - cell = [column headerCell]; - if ((column == highlightedTableColumn) - || [tableView isColumnSelected: lastColumnToDraw]) - { - [cell setHighlighted: YES]; - } - else - { - [cell setHighlighted: NO]; - } - [cell drawWithFrame: drawingRect - inView: tableHeaderView]; - drawingRect.origin.x += width; + inView: tableHeaderView]; } + } } - (void) drawPopUpButtonCellInteriorWithFrame: (NSRect)cellFrame diff --git a/Source/NSTableView.m b/Source/NSTableView.m index 71a7b332b..4a9b47a25 100644 --- a/Source/NSTableView.m +++ b/Source/NSTableView.m @@ -98,9 +98,13 @@ typedef struct _tableViewFlags unsigned int emptySelection:1; unsigned int multipleSelection:1; unsigned int columnSelection:1; - unsigned int _unused:26; + unsigned int unknown1:1; + unsigned int columnAutosave:1; + unsigned int _unused:24; #else - unsigned int _unused:26; + unsigned int _unused:24; + unsigned int columnAutosave:1; + unsigned int unknown1:1; unsigned int columnSelection:1; unsigned int multipleSelection:1; unsigned int emptySelection:1; @@ -5854,6 +5858,7 @@ This method is deprecated, use -columnIndexesInRect:. */ [self setDrawsGrid: tableViewFlags.drawsGrid]; [self setAllowsColumnResizing: tableViewFlags.columnResizing]; [self setAllowsColumnReordering: tableViewFlags.columnOrdering]; + [self setAutosaveTableColumns: tableViewFlags.columnAutosave]; } // get the table columns... @@ -5865,6 +5870,29 @@ This method is deprecated, use -columnIndexesInRect:. */ allocate _columnsOrigins */ [self addTableColumn: col]; } + + if ([aDecoder containsValueForKey: @"NSAutosaveName"]) + { + [self setAutosaveName:[aDecoder decodeObjectForKey: @"NSAutosaveName"]]; + } + + if ([aDecoder containsValueForKey: @"NSColumnAutoresizingStyle"]) + { + _columnAutoresizingStyle = [aDecoder decodeIntForKey: @"NSColumnAutoresizingStyle"]; + if (_columnAutoresizingStyle == NSTableViewUniformColumnAutoresizingStyle) + { + [self setAutoresizesAllColumnsToFit:YES]; + [self sizeToFit]; + } + else if (_columnAutoresizingStyle == NSTableViewLastColumnOnlyAutoresizingStyle) + { + [self sizeLastColumnToFit]; + } + else if (_columnAutoresizingStyle != NSTableViewNoColumnAutoresizing) + { + NSLog(@"%s:unsupported column autoresizing style: %d", __PRETTY_FUNCTION__, _columnAutoresizingStyle); + } + } [self tile]; /* Initialize _columnOrigins */ } @@ -6241,25 +6269,33 @@ This method is deprecated, use -columnIndexesInRect:. */ _autosaveName]; config = [defaults objectForKey: tableKey]; if (config != nil) - { - NSEnumerator *en = [[config allKeys] objectEnumerator]; - NSString *colKey; - NSArray *colDesc; - NSTableColumn *col; - - while ((colKey = [en nextObject]) != nil) - { - col = [self tableColumnWithIdentifier: colKey]; - - if (col != nil) - { - colDesc = [config objectForKey: colKey]; - [col setWidth: [[colDesc objectAtIndex: 0] intValue]]; - [self moveColumn: [self columnWithIdentifier: colKey] - toColumn: [[colDesc objectAtIndex: 1] intValue]]; - } - } - } + { + NSEnumerator *en = [[config allKeys] objectEnumerator]; + NSString *colKey; + NSArray *colDesc; + NSTableColumn *col; + + while ((colKey = [en nextObject]) != nil) + { + col = [self tableColumnWithIdentifier: colKey]; + + if (col != nil) + { + colDesc = [config objectForKey: colKey]; + [col setWidth: [[colDesc objectAtIndex: 0] intValue]]; + [self moveColumn: [self columnWithIdentifier: colKey] + toColumn: [[colDesc objectAtIndex: 1] intValue]]; + } + } + } + if (_columnAutoresizingStyle == NSTableViewUniformColumnAutoresizingStyle) + { + [self sizeToFit]; + } + else if (_columnAutoresizingStyle == NSTableViewLastColumnOnlyAutoresizingStyle) + { + [self sizeLastColumnToFit]; + } } } @@ -6351,7 +6387,7 @@ This method is deprecated, use -columnIndexesInRect:. */ } _superview_width = visible_width; } - else + else if (_columnAutoresizingStyle == NSTableViewLastColumnOnlyAutoresizingStyle) { float visible_width = [self convertRect: [_super_view bounds] fromView: _super_view].size.width;