diff --git a/ChangeLog b/ChangeLog index 4e8294933..278833bed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-02-14 Fred Kiefer + + * Source/NSOutlineView.m (-editColumn:...select:): Bring closer to + the new code in [-drawRow:clipRect:]. + * Source/GSInfoPanel.m (-initWithDictionary:): Protect against + icon being nil. + 2011-02-14 Fred Kiefer * Source/NSCursor.m, diff --git a/Source/GSInfoPanel.m b/Source/GSInfoPanel.m index 38b67e9bb..88ecd636c 100644 --- a/Source/GSInfoPanel.m +++ b/Source/GSInfoPanel.m @@ -398,7 +398,11 @@ new_label (NSString *value) * Create GUI Objects */ f = NSZeroRect; - f.size = [icon size]; + if (icon != nil) + { + f.size = [icon size]; + } + iconButton = AUTORELEASE([[NSButton alloc] initWithFrame: f]); [iconButton setImage: icon]; [iconButton setBordered: NO]; @@ -477,7 +481,7 @@ new_label (NSString *value) */ /** width **/ - tmp_A = [icon size].width; + tmp_A = f.size.width; /* distance between icon and title */ tmp_A += 10; /* compute the maximum of the following three sizes */ @@ -533,7 +537,7 @@ new_label (NSString *value) standard height of 48. The code tries to be nice so that 50 or 47 should more or less work -- but beware that 200 or 20 will *not* work. */ - tmp_A = [icon size].height; + tmp_A = f.size.height; if (description) tmp_A += 10; diff --git a/Source/NSOutlineView.m b/Source/NSOutlineView.m index 6f36eb677..7d9dee22a 100644 --- a/Source/NSOutlineView.m +++ b/Source/NSOutlineView.m @@ -970,9 +970,9 @@ static NSImage *unexpandable = nil; imageRect.size.height = [image size].height; [imageCell drawWithFrame: imageRect inView: self]; drawingRect.origin.x - += indentationFactor + [image size].width + 5; + += indentationFactor + imageRect.size.width + 5; drawingRect.size.width - -= indentationFactor + [image size].width + 5; + -= indentationFactor + imageRect.size.width + 5; } else { @@ -1459,7 +1459,7 @@ Also returns the child index relative to this parent. */ { NSText *t; NSTableColumn *tb; - NSRect drawingRect, imageRect; + NSRect drawingRect; unsigned length = 0; int level = 0; float indentationFactor = 0.0; @@ -1543,8 +1543,9 @@ Also returns the child index relative to this parent. */ id item = nil; NSImage *image = nil; NSCell *imageCell = nil; + NSRect imageRect; - item = [self itemAtRow: _editedRow]; + item = [self itemAtRow: rowIndex]; // determine which image to use... if ([self isItemExpanded: item]) { @@ -1557,38 +1558,46 @@ Also returns the child index relative to this parent. */ if (![self isExpandable: item]) { -// image = unexpandable; - image = nil; + image = unexpandable; } level = [self levelForItem: item]; indentationFactor = _indentationPerLevel * level; - // create the image cell.. imageCell = [[NSCell alloc] initImageCell: image]; - if (_indentationMarkerFollowsCell) + imageRect = [self frameOfOutlineCellAtRow: rowIndex]; + + if ([_delegate respondsToSelector: @selector(outlineView:willDisplayOutlineCell:forTableColumn:item:)]) { - imageRect.origin.x = drawingRect.origin.x + indentationFactor; - imageRect.origin.y = drawingRect.origin.y; + [_delegate outlineView: self + willDisplayOutlineCell: imageCell + forTableColumn: tb + item: item]; + } + + + if ([imageCell image]) + { + + imageRect.size.width = [image size].width; + imageRect.size.height = [image size].height; + + // draw... + [self lockFocus]; + [imageCell drawWithFrame: imageRect inView: self]; + [self unlockFocus]; + + // move the drawing rect over like in the drawRow routine... + drawingRect.origin.x += indentationFactor + 5 + imageRect.size.width; + drawingRect.size.width -= indentationFactor + 5 + imageRect.size.width; } else { - imageRect.origin.x = drawingRect.origin.x; - imageRect.origin.y = drawingRect.origin.y; + // move the drawing rect over like in the drawRow routine... + drawingRect.origin.x += indentationFactor; + drawingRect.size.width -= indentationFactor; } - imageRect.size.width = [image size].width; - imageRect.size.height = [image size].height; - - // draw... - [self lockFocus]; - [imageCell drawWithFrame: imageRect inView: self]; - [self unlockFocus]; - - // move the drawing rect over like in the drawRow routine... - drawingRect.origin.x += indentationFactor + 5 + [image size].width; - drawingRect.size.width -= indentationFactor + 5 + [image size].width; - RELEASE(imageCell); }