Author: mlytwyn
Date: Wed Feb 1 03:13:38 2017
New Revision: 40318
URL: http://svn.gna.org/viewcvs/gnustep?rev=40318&view=rev
Log:
First pass - alternating background colors - still needs some tweaks
Modified:
libs/gui/branches/gnustep_testplant_branch/Source/GSThemeDrawing.m
libs/gui/branches/gnustep_testplant_branch/Source/NSTableView.m
Modified: libs/gui/branches/gnustep_testplant_branch/Source/GSThemeDrawing.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Source/GSThemeDrawing.m?rev=40318&r1=40317&r2=40318&view=diff
==============================================================================
--- libs/gui/branches/gnustep_testplant_branch/Source/GSThemeDrawing.m
(original)
+++ libs/gui/branches/gnustep_testplant_branch/Source/GSThemeDrawing.m Wed Feb
1 03:13:38 2017
@@ -2956,8 +2956,8 @@
width = [column width];
drawingRect.size.width = width;
cell = [column headerCell];
- if ((column == highlightedTableColumn)
- || [tableView isColumnSelected: i])
+ if ((column == highlightedTableColumn) ||
+ [tableView isColumnSelected: i])
{
[cell setHighlighted: YES];
}
@@ -3013,15 +3013,13 @@
if ([tableView usesAlternatingRowBackgroundColors])
{
- const CGFloat rowHeight = [tableView rowHeight];
- NSInteger startingRow = [tableView rowAtPoint: NSMakePoint(0,
NSMinY(aRect))];
- NSInteger endingRow;
- NSInteger i;
-
- NSArray *rowColors = [NSColor controlAlternatingRowBackgroundColors];
- const NSUInteger rowColorCount = [rowColors count];
-
- NSRect rowRect;
+ NSArray *rowColors = [NSColor
controlAlternatingRowBackgroundColors];
+ const NSUInteger rowColorCount = [rowColors count];
+ const CGFloat rowHeight = [tableView rowHeight];
+ NSInteger startingRow = [tableView rowAtPoint: NSMakePoint(0,
NSMinY(aRect))];
+ NSInteger endingRow;
+ NSInteger i;
+ NSRect rowRect;
if (rowHeight <= 0
|| rowColorCount == 0
@@ -3207,6 +3205,10 @@
[selectionColor set];
}
#endif
+ NSColor *selectionColor = [NSColor colorWithCalibratedRed: 163 / 255.0
+ green: 205 / 255.0
+ blue: 254 / 255.0
+ alpha: 1.0];
if (selectingColumns == NO)
{
@@ -3226,34 +3228,10 @@
startingRow = 0;
if (endingRow == -1)
endingRow = numberOfRows - 1;
-
- // FIXME: Take alternating row coloring into account...
- NSArray *rowColors = [NSColor controlAlternatingRowBackgroundColors];
- const NSUInteger rowColorCount = [rowColors count];
row = [selectedRows indexGreaterThanOrEqualToIndex: startingRow];
while ((row != NSNotFound) && (row <= endingRow))
{
- NSColor *selectionColor = nil;
-
- if ([tableView usesAlternatingRowBackgroundColors])
- backgroundColor = [rowColors objectAtIndex: (row % rowColorCount)];
-
- // Switch to the alternate color if the backgroundColor is white.
- if([backgroundColor isEqual: [NSColor whiteColor]])
- {
- selectionColor = [NSColor colorWithCalibratedRed: 0.86
- green: 0.92
- blue: 0.99
- alpha: 1.0];
- }
- else
- {
- selectionColor = [NSColor whiteColor];
- }
-
- //NSHighlightRect(NSIntersectionRect([tableView rectOfRow: row],
- // clipRect));
[selectionColor set];
NSRectFill(NSIntersectionRect([tableView rectOfRow: row], clipRect));
row = [selectedRows indexGreaterThanIndex: row];
@@ -3263,27 +3241,28 @@
{
NSUInteger selectedColumnsCount;
NSUInteger column;
- NSInteger startingColumn, endingColumn;
+ NSInteger startingColumn, endingColumn;
selectedColumnsCount = [selectedColumns count];
if (selectedColumnsCount == 0)
- return;
+ return;
/* highlight selected columns */
startingColumn = [tableView columnAtPoint: NSMakePoint(NSMinX(clipRect),
0)];
- endingColumn = [tableView columnAtPoint: NSMakePoint(NSMaxX(clipRect),
0)];
+ endingColumn = [tableView columnAtPoint: NSMakePoint(NSMaxX(clipRect),
0)];
if (startingColumn == -1)
- startingColumn = 0;
+ startingColumn = 0;
if (endingColumn == -1)
- endingColumn = numberOfColumns - 1;
+ endingColumn = numberOfColumns - 1;
column = [selectedColumns indexGreaterThanOrEqualToIndex:
startingColumn];
while ((column != NSNotFound) && (column <= endingColumn))
{
- NSHighlightRect(NSIntersectionRect([tableView rectOfColumn:
column], clipRect));
- column = [selectedColumns indexGreaterThanIndex: column];
+ [selectionColor set];
+ NSRectFill(NSIntersectionRect([tableView rectOfColumn: column],
clipRect));
+ column = [selectedColumns indexGreaterThanIndex: column];
}
}
}
Modified: libs/gui/branches/gnustep_testplant_branch/Source/NSTableView.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Source/NSTableView.m?rev=40318&r1=40317&r2=40318&view=diff
==============================================================================
--- libs/gui/branches/gnustep_testplant_branch/Source/NSTableView.m
(original)
+++ libs/gui/branches/gnustep_testplant_branch/Source/NSTableView.m Wed Feb
1 03:13:38 2017
@@ -4619,7 +4619,7 @@
// Group rows take up the entire row...
if ([self _isGroupRow: rowIndex])
{
- frameRect.size.width = [self frame].size.width;
+ frameRect.size.width = _bounds.size.width;
}
else
{
@@ -4661,27 +4661,6 @@
_columnAutoresizingStyle = style;
}
-- (void) sizeLastColumnToFit
-{
- if ((_super_view != nil) && (_numberOfColumns > 0))
- {
- CGFloat excess_width;
- CGFloat last_column_width;
- NSTableColumn *lastColumn;
-
- lastColumn = [_tableColumns objectAtIndex: (_numberOfColumns - 1)];
- if ([lastColumn isResizable] == NO)
- {
- return;
- }
- excess_width = NSMaxX([self convertRect: [_super_view bounds]
- fromView: _super_view]) - NSMaxX(_bounds);
- last_column_width = [lastColumn width] + excess_width;
- // This will automatically retile the table
- [lastColumn setWidth: last_column_width];
- }
-}
-
- (void) setFrame: (NSRect)frameRect
{
NSRect tmpRect = frameRect;
@@ -4692,14 +4671,13 @@
NSRect docRect = [(NSClipView *)_super_view documentVisibleRect];
if (rowsHeight < docRect.size.height)
- {
- tmpRect.size.height = docRect.size.height;
- }
- else
- {
- tmpRect.size.height = rowsHeight;
+ {
+ tmpRect.size.height = docRect.size.height;
}
- // TODO width?
+ else
+ {
+ tmpRect.size.height = rowsHeight;
+ }
}
[super setFrame: tmpRect];
}
@@ -4714,14 +4692,13 @@
NSRect docRect = [(NSClipView *)_super_view documentVisibleRect];
if (rowsHeight < docRect.size.height)
- {
- tmpSize.height = docRect.size.height;
- }
+ {
+ tmpSize.height = docRect.size.height;
+ }
else
{
tmpSize.height = rowsHeight;
}
- // TODO width?
}
[super setFrameSize: tmpSize];
}
@@ -4731,6 +4708,44 @@
[super viewWillMoveToSuperview: newSuper];
/* need to potentially enlarge to fill the documentRect of the clip view */
[self setFrame: _frame];
+}
+
+- (void) _resizeTableView
+{
+ 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);
+ }
+}
+
+- (void) sizeLastColumnToFit
+{
+ if ((_super_view != nil) && (_numberOfColumns > 0))
+ {
+ CGFloat excess_width;
+ CGFloat last_column_width;
+ NSTableColumn *lastColumn;
+
+ lastColumn = [_tableColumns objectAtIndex: (_numberOfColumns - 1)];
+ if ([lastColumn isResizable] == NO)
+ {
+ return;
+ }
+ excess_width = NSMaxX([self convertRect: [_super_view bounds]
+ fromView: _super_view]) - NSMaxX(_bounds);
+ last_column_width = [lastColumn width] + excess_width;
+ // This will automatically retile the table
+ [lastColumn setWidth: last_column_width];
+ }
}
- (void) sizeToFit
@@ -5206,9 +5221,6 @@
- (void) drawRect: (NSRect)aRect
{
- if ([[self autosaveName] isEqualToString:@"ConnectionList"])
- NSLog(@"%s:%ld:aRect: %@ clipFrame: %@", __PRETTY_FUNCTION__,
(long)__LINE__,
- NSStringFromRect(aRect), NSStringFromRect([[self superview] frame]));
[[GSTheme theme] drawTableViewRect: aRect
inView: self];
}
@@ -5927,23 +5939,9 @@
if ([aDecoder containsValueForKey: @"NSColumnAutoresizingStyle"])
{
_columnAutoresizingStyle = [aDecoder decodeIntForKey:
@"NSColumnAutoresizingStyle"];
- if ([[self autosaveName] isEqualToString: @"ConnectionList"])
- NSLog(@"%s:%ld: _columnAutoresizingStyle: %ld",
__PRETTY_FUNCTION__, (long)__LINE__, _columnAutoresizingStyle);
- 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 _resizeTableView];
[self tile]; /* Initialize _columnOrigins */
}
else
@@ -6019,6 +6017,7 @@
if (aCell == nil)
return;
+ // ??? Why PREMATURE RETURN ???
return;
for (i = 0; i < _numberOfColumns; i++)
@@ -6064,6 +6063,7 @@
width: (CGFloat)width
{
[[_tableColumns objectAtIndex: index] setWidth: width];
+ [self sizeLastColumnToFit];
}
- (CGFloat *) _columnOrigins
@@ -6342,14 +6342,7 @@
}
}
}
- if (_columnAutoresizingStyle ==
NSTableViewUniformColumnAutoresizingStyle)
- {
- [self sizeToFit];
- }
- else if (_columnAutoresizingStyle ==
NSTableViewLastColumnOnlyAutoresizingStyle)
- {
- [self sizeLastColumnToFit];
- }
+ [self _resizeTableView];
}
}
@@ -6395,41 +6388,30 @@
- (void) superviewFrameChanged: (NSNotification*)aNotification
{
+ CGFloat table_width = 0;
+
+ if (_numberOfColumns > 0)
+ {
+ table_width = (_columnOrigins[_numberOfColumns - 1] +
+ [[_tableColumns objectAtIndex: _numberOfColumns - 1]
width]);
+ }
+
if (_autoresizesAllColumnsToFit == YES)
{
- CGFloat visible_width = [self convertRect: [_super_view bounds]
- fromView: _super_view].size.width;
- CGFloat table_width = 0;
-
- if (_numberOfColumns > 0)
- {
- table_width =
- _columnOrigins[_numberOfColumns - 1] +
- [[_tableColumns objectAtIndex: _numberOfColumns - 1] width];
- }
-
- /*
- NSLog(@"columnOrigins[0] %f", _columnOrigins[0]);
- NSLog(@"superview.bounds %@",
- NSStringFromRect([_super_view bounds]));
- NSLog(@"superview.frame %@",
- NSStringFromRect([_super_view frame]));
- NSLog(@"table_width %f", table_width);
- NSLog(@"width %f", visible_width);
- NSLog(@"_superview_width %f", _superview_width);
- */
-
+ CGFloat visible_width = [_super_view bounds].size.width;
+
+#if 0 // Need to fix this...
if (table_width - _superview_width <= 0.001
&& table_width - _superview_width >= -0.001)
{
// the last column had been sized to fit
- [self sizeToFit];
+ [self _resizeTableView];
}
else if (table_width <= _superview_width
&& table_width >= visible_width)
{
// the tableView was too small and is now too large
- [self sizeToFit];
+ [self _resizeTableView];
}
else if (table_width >= _superview_width
&& table_width <= visible_width)
@@ -6437,45 +6419,29 @@
// the tableView was too large and is now too small
if (_numberOfColumns > 0)
[self scrollColumnToVisible: 0];
- [self sizeToFit];
- }
+ [self _resizeTableView];
+ }
+#else
+ [self _resizeTableView];
+#endif
_superview_width = visible_width;
}
else if (_columnAutoresizingStyle ==
NSTableViewLastColumnOnlyAutoresizingStyle)
{
- CGFloat visible_width = [self convertRect: [_super_view bounds]
- fromView: _super_view].size.width;
- CGFloat table_width = 0;
-
- if (_numberOfColumns > 0)
- {
- table_width =
- _columnOrigins[_numberOfColumns - 1] +
- [[_tableColumns objectAtIndex: _numberOfColumns - 1] width];
- }
-
- /*
- NSLog(@"columnOrigins[0] %f", _columnOrigins[0]);
- NSLog(@"superview.bounds %@",
- NSStringFromRect([_super_view bounds]));
- NSLog(@"superview.frame %@",
- NSStringFromRect([_super_view frame]));
- NSLog(@"table_width %f", table_width);
- NSLog(@"width %f", visible_width);
- NSLog(@"_superview_width %f", _superview_width);
- */
-
+ CGFloat visible_width = [_super_view bounds].size.width;
+
+#if 0 // Need to fix this...
if (table_width - _superview_width <= 0.001
&& table_width - _superview_width >= -0.001)
{
// the last column had been sized to fit
- [self sizeLastColumnToFit];
+ [self _resizeTableView];
}
else if (table_width <= _superview_width
&& table_width >= visible_width)
{
// the tableView was too small and is now too large
- [self sizeLastColumnToFit];
+ [self _resizeTableView];
}
else if (table_width >= _superview_width
&& table_width <= visible_width)
@@ -6483,11 +6449,21 @@
// the tableView was too large and is now too small
if (_numberOfColumns > 0)
[self scrollColumnToVisible: 0];
- [self sizeLastColumnToFit];
- }
+ [self _resizeTableView];
+ }
+#else
+ [self _resizeTableView];
+#endif
_superview_width = visible_width;
}
- [self setFrame:_frame];
+ else
+ {
+ _superview_width = [_super_view bounds].size.width;
+ }
+
+ NSRect frame = _frame;
+ frame.size.width = fmax(table_width, _superview_width);
+ [self setFrame: frame];
}
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs