mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 15:31:56 +00:00
Table view and cell drawing updates
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/branches/gnustep_testplant_branch@37351 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b951ff0d8b
commit
e1498b311a
3 changed files with 91 additions and 9 deletions
|
@ -70,6 +70,7 @@
|
||||||
- (float *)_columnOrigins;
|
- (float *)_columnOrigins;
|
||||||
- (void) _willDisplayCell: (NSCell*)cell forTableColumn: (NSTableColumn *)tb row: (int)index;
|
- (void) _willDisplayCell: (NSCell*)cell forTableColumn: (NSTableColumn *)tb row: (int)index;
|
||||||
- (NSCell *) _dataCellForTableColumn: (NSTableColumn *)tb row: (int) rowIndex;
|
- (NSCell *) _dataCellForTableColumn: (NSTableColumn *)tb row: (int) rowIndex;
|
||||||
|
- (BOOL)_isGroupRow: (NSInteger)rowIndex;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface NSCell (Private)
|
@interface NSCell (Private)
|
||||||
|
@ -2611,11 +2612,9 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL respondsToIsGroupRow = [[tableView delegate] respondsToSelector:@selector(tableView:isGroupRow:)];
|
|
||||||
|
|
||||||
// First, determine whether the table view delegate wants this row
|
// First, determine whether the table view delegate wants this row
|
||||||
// to be a grouped cell row...
|
// to be a grouped cell row...
|
||||||
if (respondsToIsGroupRow && [[tableView delegate] tableView:tableView isGroupRow:rowIndex])
|
if ([tableView _isGroupRow:rowIndex])
|
||||||
{
|
{
|
||||||
cell = [tableView preparedCellAtColumn: -1 row:rowIndex];
|
cell = [tableView preparedCellAtColumn: -1 row:rowIndex];
|
||||||
if (cell)
|
if (cell)
|
||||||
|
@ -2631,7 +2630,6 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
||||||
[cell _setInEditing: NO];
|
[cell _setInEditing: NO];
|
||||||
[cell setShowsFirstResponder:NO];
|
[cell setShowsFirstResponder:NO];
|
||||||
[cell setFocusRingType:NSFocusRingTypeNone];
|
[cell setFocusRingType:NSFocusRingTypeNone];
|
||||||
[cell setBackgroundStyle:NSBackgroundStyleDark];
|
|
||||||
|
|
||||||
// Get the drawing rectangle...
|
// Get the drawing rectangle...
|
||||||
drawingRect = [tableView frameOfCellAtColumn: 0 row: rowIndex];
|
drawingRect = [tableView frameOfCellAtColumn: 0 row: rowIndex];
|
||||||
|
|
|
@ -2870,10 +2870,10 @@ static NSColor *dtxtCol;
|
||||||
|
|
||||||
switch (_cell.background_style)
|
switch (_cell.background_style)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
case NSBackgroundStyleDark:
|
case NSBackgroundStyleDark:
|
||||||
{
|
{
|
||||||
NSFont *font = [NSFont fontWithName:@"LucidaGrande-Bold" size:12.0];
|
NSColor *color = [NSColor alternateSelectedControlTextColor];
|
||||||
NSColor *color = [NSColor colorWithCalibratedWhite:0.458824 alpha:1.0];
|
|
||||||
|
|
||||||
/* Note: There are only a few possible paragraph styles for cells.
|
/* Note: There are only a few possible paragraph styles for cells.
|
||||||
TODO: Cache them and reuse them for the whole app lifetime. */
|
TODO: Cache them and reuse them for the whole app lifetime. */
|
||||||
|
@ -2883,7 +2883,7 @@ static NSColor *dtxtCol;
|
||||||
[paragraphStyle setAlignment: [self alignment]];
|
[paragraphStyle setAlignment: [self alignment]];
|
||||||
|
|
||||||
attr = [[NSDictionary alloc] initWithObjectsAndKeys:
|
attr = [[NSDictionary alloc] initWithObjectsAndKeys:
|
||||||
font, NSFontAttributeName,
|
_font, NSFontAttributeName,
|
||||||
color, NSForegroundColorAttributeName,
|
color, NSForegroundColorAttributeName,
|
||||||
paragraphStyle, NSParagraphStyleAttributeName,
|
paragraphStyle, NSParagraphStyleAttributeName,
|
||||||
nil];
|
nil];
|
||||||
|
@ -2891,11 +2891,49 @@ static NSColor *dtxtCol;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Add raised style settings...
|
|
||||||
case NSBackgroundStyleRaised:
|
case NSBackgroundStyleRaised:
|
||||||
|
{
|
||||||
|
NSColor *color = [NSColor colorWithCalibratedWhite: 0.0 alpha: 1.0];
|
||||||
|
|
||||||
|
/* Note: There are only a few possible paragraph styles for cells.
|
||||||
|
TODO: Cache them and reuse them for the whole app lifetime. */
|
||||||
|
NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
|
||||||
|
[paragraphStyle setLineBreakMode: [self lineBreakMode]];
|
||||||
|
[paragraphStyle setBaseWritingDirection: [self baseWritingDirection]];
|
||||||
|
[paragraphStyle setAlignment: [self alignment]];
|
||||||
|
|
||||||
|
attr = [[NSDictionary alloc] initWithObjectsAndKeys:
|
||||||
|
_font, NSFontAttributeName,
|
||||||
|
color, NSForegroundColorAttributeName,
|
||||||
|
paragraphStyle, NSParagraphStyleAttributeName,
|
||||||
|
nil];
|
||||||
|
RELEASE (paragraphStyle);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Add lowered style settings...
|
// TODO: Add lowered style settings...
|
||||||
case NSBackgroundStyleLowered:
|
case NSBackgroundStyleLowered:
|
||||||
|
{
|
||||||
|
NSColor *color = [NSColor colorWithCalibratedWhite: 1.0 alpha: 1.0];
|
||||||
|
|
||||||
|
/* Note: There are only a few possible paragraph styles for cells.
|
||||||
|
TODO: Cache them and reuse them for the whole app lifetime. */
|
||||||
|
NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
|
||||||
|
[paragraphStyle setLineBreakMode: [self lineBreakMode]];
|
||||||
|
[paragraphStyle setBaseWritingDirection: [self baseWritingDirection]];
|
||||||
|
[paragraphStyle setAlignment: [self alignment]];
|
||||||
|
|
||||||
|
attr = [[NSDictionary alloc] initWithObjectsAndKeys:
|
||||||
|
_font, NSFontAttributeName,
|
||||||
|
color, NSForegroundColorAttributeName,
|
||||||
|
paragraphStyle, NSParagraphStyleAttributeName,
|
||||||
|
nil];
|
||||||
|
RELEASE (paragraphStyle);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case NSBackgroundStyleLight:
|
case NSBackgroundStyleLight:
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
NSColor *color = [self textColor];
|
NSColor *color = [self textColor];
|
||||||
|
|
|
@ -3189,6 +3189,35 @@ byExtendingSelection: (BOOL)flag
|
||||||
* Providing Cells
|
* Providing Cells
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
- (void)_addGroupRowAttributesToCell:(NSCell*)cell withData:(id)objectValue highlighted:(BOOL)highlighted
|
||||||
|
{
|
||||||
|
if ([objectValue isKindOfClass:[NSString class]])
|
||||||
|
{
|
||||||
|
NSString *fontname = [NSString stringWithFormat:@"%@-Bold",[[cell font] fontName]];
|
||||||
|
CGFloat fontsize = [[cell font] pointSize];
|
||||||
|
NSFont *font = [NSFont fontWithName:fontname size:fontsize];
|
||||||
|
NSColor *color = [NSColor colorWithCalibratedWhite:0.458824 alpha:1.0];
|
||||||
|
|
||||||
|
/* Note: There are only a few possible paragraph styles for cells.
|
||||||
|
TODO: Cache them and reuse them for the whole app lifetime. */
|
||||||
|
NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
|
||||||
|
[paragraphStyle setLineBreakMode: [cell lineBreakMode]];
|
||||||
|
[paragraphStyle setBaseWritingDirection: [cell baseWritingDirection]];
|
||||||
|
[paragraphStyle setAlignment: [cell alignment]];
|
||||||
|
|
||||||
|
NSDictionary *attributes = [[NSDictionary alloc] initWithObjectsAndKeys:
|
||||||
|
font, NSFontAttributeName,
|
||||||
|
color, NSForegroundColorAttributeName,
|
||||||
|
paragraphStyle, NSParagraphStyleAttributeName,
|
||||||
|
nil];
|
||||||
|
objectValue = [[NSAttributedString alloc] initWithString:objectValue attributes:attributes];
|
||||||
|
RELEASE(paragraphStyle);
|
||||||
|
|
||||||
|
// Replace the cell's object value...
|
||||||
|
[cell setObjectValue:objectValue];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (NSCell *) preparedCellAtColumn: (NSInteger)columnIndex row: (NSInteger)rowIndex
|
- (NSCell *) preparedCellAtColumn: (NSInteger)columnIndex row: (NSInteger)rowIndex
|
||||||
{
|
{
|
||||||
NSCell *cell = nil;
|
NSCell *cell = nil;
|
||||||
|
@ -3210,7 +3239,24 @@ byExtendingSelection: (BOOL)flag
|
||||||
if (cell)
|
if (cell)
|
||||||
{
|
{
|
||||||
// Get the object value from the delegate or nil...
|
// Get the object value from the delegate or nil...
|
||||||
[cell setObjectValue:[self _objectValueForTableColumn:tb row:rowIndex]];
|
id objectValue = [self _objectValueForTableColumn:tb row:rowIndex];
|
||||||
|
|
||||||
|
// Set the cell's object value...
|
||||||
|
[cell setObjectValue:objectValue];
|
||||||
|
|
||||||
|
// If grouped row the add the necessary group row attributes...
|
||||||
|
if ([self _isGroupRow:rowIndex])
|
||||||
|
{
|
||||||
|
// Force reset from other attributes then set dark...
|
||||||
|
[cell setBackgroundStyle:NSBackgroundStyleLight];
|
||||||
|
[cell setBackgroundStyle:NSBackgroundStyleDark];
|
||||||
|
|
||||||
|
// If the object value is a NSString type...
|
||||||
|
// Cocoa uses the object value as is if it is a NSAttributedString already...
|
||||||
|
if ([cell isKindOfClass:[NSTextFieldCell class]] &&
|
||||||
|
[objectValue isKindOfClass:[NSString class]])
|
||||||
|
[self _addGroupRowAttributesToCell:cell withData:objectValue highlighted:YES];
|
||||||
|
}
|
||||||
|
|
||||||
// Inform delegate we are getting ready to display
|
// Inform delegate we are getting ready to display
|
||||||
[self _willDisplayCell: cell forTableColumn: tb row: rowIndex];
|
[self _willDisplayCell: cell forTableColumn: tb row: rowIndex];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue