mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 12:00:45 +00:00
Move method back, eliminate possible duplicate call to render outline cell, changes suggested by review with @fredkiefer
This commit is contained in:
parent
f8fca4e162
commit
77bf2f823b
3 changed files with 77 additions and 86 deletions
|
@ -1346,6 +1346,12 @@ APPKIT_EXPORT_CLASS
|
|||
clipRect: (NSRect)clipRect
|
||||
inView: (NSTableView *)v;
|
||||
|
||||
- (NSRect) drawOutlineCell: (NSTableColumn *)tb
|
||||
outlineView: (NSOutlineView *)outlineView
|
||||
item: (id)item
|
||||
drawingRect: (NSRect)inputRect
|
||||
rowIndex: (NSInteger)rowIndex;
|
||||
|
||||
- (void) drawOutlineViewRow: (NSInteger)rowIndex
|
||||
clipRect: (NSRect)clipRect
|
||||
inView: (NSOutlineView *)view;
|
||||
|
|
|
@ -84,13 +84,6 @@
|
|||
row: (NSInteger)index;
|
||||
@end
|
||||
|
||||
@interface NSOutlineView (Private)
|
||||
- (NSRect) _drawOutlineCell: (NSTableColumn *)tb
|
||||
item: (id)item
|
||||
drawingRect: (NSRect)inputRect
|
||||
rowIndex: (NSInteger)rowIndex;
|
||||
@end
|
||||
|
||||
@interface NSCell (Private)
|
||||
- (void) _setInEditing: (BOOL)flag;
|
||||
- (BOOL) _inEditing;
|
||||
|
@ -3496,6 +3489,71 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
|||
}
|
||||
}
|
||||
|
||||
- (NSRect) drawOutlineCell: (NSTableColumn *)tb
|
||||
outlineView: (NSOutlineView *)outlineView
|
||||
item: (id)item
|
||||
drawingRect: (NSRect)inputRect
|
||||
rowIndex: (NSInteger)rowIndex
|
||||
{
|
||||
NSRect drawingRect = inputRect;
|
||||
NSImage *image = nil;
|
||||
NSInteger level = 0;
|
||||
CGFloat indentationFactor = 0.0;
|
||||
CGFloat indentationPerLevel = [outlineView indentationPerLevel];
|
||||
NSCell *imageCell = nil;
|
||||
NSRect imageRect;
|
||||
id delegate = [outlineView delegate];
|
||||
|
||||
// display the correct arrow...
|
||||
if ([outlineView isItemExpanded: item])
|
||||
{
|
||||
image = [NSImage imageNamed: @"common_ArrowDownH"];
|
||||
}
|
||||
else
|
||||
{
|
||||
image = [NSImage imageNamed: @"common_ArrowRightH"];
|
||||
}
|
||||
|
||||
if (![outlineView isExpandable: item])
|
||||
{
|
||||
image = AUTORELEASE([[NSImage alloc] initWithSize: NSMakeSize(14.0,14.0)]);
|
||||
}
|
||||
|
||||
level = [outlineView levelForItem: item];
|
||||
indentationFactor = indentationPerLevel * level;
|
||||
imageCell = [[NSCell alloc] initImageCell: image];
|
||||
imageRect = [outlineView frameOfOutlineCellAtRow: rowIndex];
|
||||
|
||||
if ([delegate respondsToSelector: @selector(outlineView:willDisplayOutlineCell:forTableColumn:item:)])
|
||||
{
|
||||
[delegate outlineView: outlineView
|
||||
willDisplayOutlineCell: imageCell
|
||||
forTableColumn: tb
|
||||
item: item];
|
||||
}
|
||||
|
||||
/* Do not indent if the delegate set the image to nil. */
|
||||
if ([imageCell image])
|
||||
{
|
||||
imageRect.size.width = [image size].width;
|
||||
imageRect.size.height = [image size].height + 5;
|
||||
[imageCell drawWithFrame: imageRect inView: outlineView];
|
||||
drawingRect.origin.x
|
||||
+= indentationFactor + imageRect.size.width + 5;
|
||||
drawingRect.size.width
|
||||
-= indentationFactor + imageRect.size.width + 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
drawingRect.origin.x += indentationFactor;
|
||||
drawingRect.size.width -= indentationFactor;
|
||||
}
|
||||
|
||||
RELEASE(imageCell);
|
||||
|
||||
return drawingRect;
|
||||
}
|
||||
|
||||
- (void) drawOutlineViewRow: (NSInteger)rowIndex
|
||||
clipRect: (NSRect)clipRect
|
||||
inView: (NSOutlineView *)outlineView
|
||||
|
@ -3509,7 +3567,6 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
|||
NSRect drawingRect;
|
||||
NSInteger i;
|
||||
id dataSource = [outlineView dataSource];
|
||||
NSTableColumn *outlineTableColumn = [outlineView outlineTableColumn];
|
||||
|
||||
if (dataSource == nil)
|
||||
{
|
||||
|
@ -3554,14 +3611,6 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
|||
drawingRect = [outlineView frameOfCellAtColumn: i
|
||||
row: rowIndex];
|
||||
|
||||
if (tb == outlineTableColumn)
|
||||
{
|
||||
drawingRect = [outlineView _drawOutlineCell: tb
|
||||
item: item
|
||||
drawingRect: drawingRect
|
||||
rowIndex: rowIndex];
|
||||
}
|
||||
|
||||
[cell drawWithFrame: drawingRect inView: outlineView];
|
||||
if (i == editedColumn && rowIndex == editedRow)
|
||||
{
|
||||
|
|
|
@ -185,7 +185,6 @@ static NSImage *unexpandable = nil;
|
|||
if (self != nil)
|
||||
{
|
||||
[self _initOutlineDefaults];
|
||||
//_outlineTableColumn = nil;
|
||||
}
|
||||
|
||||
return self;
|
||||
|
@ -2208,70 +2207,6 @@ Also returns the child index relative to this parent. */
|
|||
return cell;
|
||||
}
|
||||
|
||||
- (NSRect) _drawOutlineCell: (NSTableColumn *)tb
|
||||
item: (id)item
|
||||
drawingRect: (NSRect)inputRect
|
||||
rowIndex: (NSInteger)rowIndex
|
||||
{
|
||||
NSRect drawingRect = inputRect;
|
||||
NSImage *image = nil;
|
||||
NSInteger level = 0;
|
||||
CGFloat indentationFactor = 0.0;
|
||||
CGFloat indentationPerLevel = [self indentationPerLevel];
|
||||
NSCell *imageCell = nil;
|
||||
NSRect imageRect;
|
||||
id delegate = [self delegate];
|
||||
|
||||
// display the correct arrow...
|
||||
if ([self isItemExpanded: item])
|
||||
{
|
||||
image = [NSImage imageNamed: @"common_ArrowDownH"];
|
||||
}
|
||||
else
|
||||
{
|
||||
image = [NSImage imageNamed: @"common_ArrowRightH"];
|
||||
}
|
||||
|
||||
if (![self isExpandable: item])
|
||||
{
|
||||
image = AUTORELEASE([[NSImage alloc] initWithSize: NSMakeSize(14.0,14.0)]);
|
||||
}
|
||||
|
||||
level = [self levelForItem: item];
|
||||
indentationFactor = indentationPerLevel * level;
|
||||
imageCell = [[NSCell alloc] initImageCell: image];
|
||||
imageRect = [self frameOfOutlineCellAtRow: rowIndex];
|
||||
|
||||
if ([delegate respondsToSelector: @selector(outlineView:willDisplayOutlineCell:forTableColumn:item:)])
|
||||
{
|
||||
[delegate outlineView: self
|
||||
willDisplayOutlineCell: imageCell
|
||||
forTableColumn: tb
|
||||
item: item];
|
||||
}
|
||||
|
||||
/* Do not indent if the delegate set the image to nil. */
|
||||
if ([imageCell image])
|
||||
{
|
||||
imageRect.size.width = [image size].width;
|
||||
imageRect.size.height = [image size].height + 5;
|
||||
[imageCell drawWithFrame: imageRect inView: self];
|
||||
drawingRect.origin.x
|
||||
+= indentationFactor + imageRect.size.width + 5;
|
||||
drawingRect.size.width
|
||||
-= indentationFactor + imageRect.size.width + 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
drawingRect.origin.x += indentationFactor;
|
||||
drawingRect.size.width -= indentationFactor;
|
||||
}
|
||||
|
||||
RELEASE(imageCell);
|
||||
|
||||
return drawingRect;
|
||||
}
|
||||
|
||||
- (NSView *) viewAtColumn: (NSInteger)column row: (NSInteger)row makeIfNecessary: (BOOL)flag
|
||||
{
|
||||
NSTableColumn *tb = [_tableColumns objectAtIndex: column];
|
||||
|
@ -2284,12 +2219,13 @@ Also returns the child index relative to this parent. */
|
|||
|
||||
if (tb == _outlineTableColumn)
|
||||
{
|
||||
drawingRect = [self _drawOutlineCell: tb
|
||||
item: item
|
||||
drawingRect: drawingRect
|
||||
rowIndex: row];
|
||||
drawingRect = [[GSTheme theme] drawOutlineCell: tb
|
||||
outlineView: self
|
||||
item: item
|
||||
drawingRect: drawingRect
|
||||
rowIndex: row];
|
||||
}
|
||||
|
||||
|
||||
if (view == nil
|
||||
&& flag == YES)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue