Re: Icons in NSOutlineView
Re: Icons in NSOutlineView
- Subject: Re: Icons in NSOutlineView
- From: "John C. Randolph" <email@hidden>
- Date: Fri, 1 Jun 2001 04:55:46 -0700
On Friday, June 1, 2001, at 02:30 AM, Max Horn wrote:
At 11:35 Uhr -0700 31.05.2001, Jared White wrote:
Hi Eric,
Thanks, that worked great! I had to use [cell setLeaf:YES] get rid of
the
right arrow at the end of each item, but other than that your example
worked
like a charm.
Everybody is suggesting to use NSBrowserCells. I used to use them, too.
they have one big problem that makes them unusable for me: while you
can hide the leaf icon, the space were they appears is *always* left
free. Hence, when the text of the items is almost as wide as the full
outline/tablewidth (or even wider), then the text is cut early - the
right is left blank. This is very irritating to the users (it suddenly
looks as if the data was cut off - not as if it was cut off visually at
a borde, but as if it was cut in memore, i.e. it just suddenly stops
without any visible reason).
I haven't found a simple solution to "fix" this with NSBrowserCell, so
I had to go with my complete own NSCell subclass :(
If anybody knows a way to fix this more easily, I am more than happy to
admit I was lame ;) But I somehow doubt it...
I would override -drawInteriorWithFrame:inView: or
-drawWithFrame:inView: and invoke the super method with a wider rect,
e.g:
static float leafIconWidth;
+ initialize
{
NSSize
iconSize = [[NSBrowserCell branchImage] size];
leafIconWidth = iconSize.width;
}
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
cellFrame.size.width += leafIconWidth;
[super drawWithFrame:cellFrame inView:controlView];
}
I haven't tried this lately in Mac OS X, but in NeXTSTEP, the
NXBrowserCells get drawn in a Matrix which lives in a ScrollView, both
of which have their own cliprects.
The upshot is that if you lie to a browser cell about what bounds it
should draw in, the clipping rectangle of the view it's drawing in
should prevent it from coloring outside the lines.
-jcr
"This is not a book to be tossed aside lightly. Rather, it should be
hurled with great force." -Dorothy Parker