Initial fix(es) for drawing table heading exceeding the end of the last table header column

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/branches/gnustep_testplant_branch@37727 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Marcian Lytwyn 2014-03-06 16:48:06 +00:00
parent c96089be04
commit 1d8e1bb0b5
3 changed files with 90 additions and 58 deletions

View file

@ -109,7 +109,8 @@ typedef enum _NSTableViewColumnAutoresizingStyle
NSString *_autosaveName;
BOOL _verticalMotionDrag;
NSArray *_sortDescriptors;
NSTableViewColumnAutoresizingStyle _columnAutoresizingStyle;
/*
* Ivars Acting as Control...
*/

View file

@ -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

View file

@ -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;