From b751aed5b0d08e01b07a62e5a4e798c81a1605e5 Mon Sep 17 00:00:00 2001 From: fredkiefer Date: Fri, 27 Sep 2013 13:10:23 +0000 Subject: [PATCH] * Source/NSBrowserCell.m (-drawInteriorWithFrame:inView:): Don't draw string when editing. * Source/NSBrowserCell.m (-titleRectForBounds:): Implement to exactly match calculation in -drawInteriorWithFrame:inView:. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@37159 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 13 ++++++--- Source/NSBrowserCell.m | 60 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 68 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8a2068ff6..749aa6929 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2013-09-27 Fred Kiefer + + * Source/NSBrowserCell.m (-drawInteriorWithFrame:inView:): Don't + draw string when editing. + * Source/NSBrowserCell.m (-titleRectForBounds:): Implement to + exactly match calculation in -drawInteriorWithFrame:inView:. + 2013-09-27 German Arias * Source/NSMenuView.m (- _trackWithEvent:startingMenuView:): If menu @@ -26,7 +33,7 @@ * Source/NSImage.m: Missing -retain inside the method -compositeToPoint:fromRect:operation:fraction: caused a crash inside Opal backend. - + * Source/NSImage.m: Missing -retain inside the method -drawInRect:fromRect:... caused a crash inside Opal backend. @@ -59,8 +66,8 @@ 2013-09-17 Ivan Vucica - * Source/NSLayoutManager.m: - advancementbuf[0] was not being filled. Most backends, including cairo, + * Source/NSLayoutManager.m: + advancementbuf[0] was not being filled. Most backends, including cairo, ignore advancements, so the bug was not immediately apparent until opal backend started using the advancements. diff --git a/Source/NSBrowserCell.m b/Source/NSBrowserCell.m index 34b48ecb5..4b619dd3b 100644 --- a/Source/NSBrowserCell.m +++ b/Source/NSBrowserCell.m @@ -276,6 +276,55 @@ static NSFont *_leafFont; */ } +- (NSRect) titleRectForBounds: (NSRect)theRect +{ + NSRect titleRect = [super titleRectForBounds: theRect]; + NSImage *branch_image = nil; + NSImage *cell_image = [self image]; + + if (_cell.is_highlighted || _cell.state) + { + if (!_browsercell_is_leaf) + { + branch_image = [object_getClass(self) highlightedBranchImage]; + } + if (nil != [self alternateImage]) + { + cell_image = [self alternateImage]; + } + } + else + { + if (!_browsercell_is_leaf) + { + branch_image = [object_getClass(self) branchImage]; + } + } + + if (branch_image) + { + NSRect imgRect; + + imgRect.size = [branch_image size]; + titleRect.size.width -= imgRect.size.width + 8; + } + + if (cell_image) + { + NSRect imgRect; + + imgRect.size = [cell_image size]; + titleRect.origin.x += imgRect.size.width + 4; + titleRect.size.width -= imgRect.size.width + 4; + } + + // Skip 2 points from the left border + titleRect.origin.x += 2; + titleRect.size.width -= 2; + + return titleRect; +} + /* * Displaying */ @@ -358,8 +407,15 @@ static NSFont *_leafFont; } // Draw the body of the cell - [self _drawAttributedText: [self attributedStringValue] - inFrame: title_rect]; + if (_cell.in_editing) + { + [self _drawEditorWithFrame: cellFrame inView: controlView]; + } + else + { + [self _drawAttributedText: [self attributedStringValue] + inFrame: title_rect]; + } } /*