* Source/NSOutlineView.m (-editColumn:...select:): Bring closer

to the new code in [-drawRow:clipRect:].
* Source/GSInfoPanel.m (-initWithDictionary:): Protect against
icon being nil.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@32161 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fredkiefer 2011-02-14 20:11:57 +00:00
parent 05f26e5418
commit 5f8786c804
3 changed files with 47 additions and 27 deletions

View file

@ -1,3 +1,10 @@
2011-02-14 Fred Kiefer <FredKiefer@gmx.de>
* 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 <FredKiefer@gmx.de> 2011-02-14 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSCursor.m, * Source/NSCursor.m,

View file

@ -398,7 +398,11 @@ new_label (NSString *value)
* Create GUI Objects * Create GUI Objects
*/ */
f = NSZeroRect; f = NSZeroRect;
f.size = [icon size]; if (icon != nil)
{
f.size = [icon size];
}
iconButton = AUTORELEASE([[NSButton alloc] initWithFrame: f]); iconButton = AUTORELEASE([[NSButton alloc] initWithFrame: f]);
[iconButton setImage: icon]; [iconButton setImage: icon];
[iconButton setBordered: NO]; [iconButton setBordered: NO];
@ -477,7 +481,7 @@ new_label (NSString *value)
*/ */
/** width **/ /** width **/
tmp_A = [icon size].width; tmp_A = f.size.width;
/* distance between icon and title */ /* distance between icon and title */
tmp_A += 10; tmp_A += 10;
/* compute the maximum of the following three sizes */ /* 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 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 47 should more or less work -- but beware that 200 or 20 will
*not* work. */ *not* work. */
tmp_A = [icon size].height; tmp_A = f.size.height;
if (description) if (description)
tmp_A += 10; tmp_A += 10;

View file

@ -970,9 +970,9 @@ static NSImage *unexpandable = nil;
imageRect.size.height = [image size].height; imageRect.size.height = [image size].height;
[imageCell drawWithFrame: imageRect inView: self]; [imageCell drawWithFrame: imageRect inView: self];
drawingRect.origin.x drawingRect.origin.x
+= indentationFactor + [image size].width + 5; += indentationFactor + imageRect.size.width + 5;
drawingRect.size.width drawingRect.size.width
-= indentationFactor + [image size].width + 5; -= indentationFactor + imageRect.size.width + 5;
} }
else else
{ {
@ -1459,7 +1459,7 @@ Also returns the child index relative to this parent. */
{ {
NSText *t; NSText *t;
NSTableColumn *tb; NSTableColumn *tb;
NSRect drawingRect, imageRect; NSRect drawingRect;
unsigned length = 0; unsigned length = 0;
int level = 0; int level = 0;
float indentationFactor = 0.0; float indentationFactor = 0.0;
@ -1543,8 +1543,9 @@ Also returns the child index relative to this parent. */
id item = nil; id item = nil;
NSImage *image = nil; NSImage *image = nil;
NSCell *imageCell = nil; NSCell *imageCell = nil;
NSRect imageRect;
item = [self itemAtRow: _editedRow]; item = [self itemAtRow: rowIndex];
// determine which image to use... // determine which image to use...
if ([self isItemExpanded: item]) if ([self isItemExpanded: item])
{ {
@ -1557,38 +1558,46 @@ Also returns the child index relative to this parent. */
if (![self isExpandable: item]) if (![self isExpandable: item])
{ {
// image = unexpandable; image = unexpandable;
image = nil;
} }
level = [self levelForItem: item]; level = [self levelForItem: item];
indentationFactor = _indentationPerLevel * level; indentationFactor = _indentationPerLevel * level;
// create the image cell.. // create the image cell..
imageCell = [[NSCell alloc] initImageCell: image]; 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; [_delegate outlineView: self
imageRect.origin.y = drawingRect.origin.y; 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 else
{ {
imageRect.origin.x = drawingRect.origin.x; // move the drawing rect over like in the drawRow routine...
imageRect.origin.y = drawingRect.origin.y; 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); RELEASE(imageCell);
} }