Re: How to indent in NSOutlineView?
Re: How to indent in NSOutlineView?
- Subject: Re: How to indent in NSOutlineView?
- From: John Terranova <email@hidden>
- Date: Wed, 09 Jul 2008 22:38:24 -0700
Did you try the levelForItem:, or frameOfCellAtColumn:row:, or both?
Did they both have the same results? More information on what you
have tried and what the results were would make it easier to help you.
You haven't turned off [NSOutlineView indentationMarkerFollowsCell],
have you? Is "Indentation Follows Cell" checked in Interface
Builder? Add a couple well-placed
NSLog(@"indentationMarkerFollowsCell: %d", [outlineView
indentationMarkerFollowsCell]) statements and make sure it always
reports 1.
john
On Jul 8, 2008, at 10:47 PM, Aman Alam wrote:
I tried the same code earlier. This will indent the text displaying
in cell but the disclosure button still at its old place.
In normal case, when there is child item in NSOutlineView then the
button gets indented. But in my case the button doesn't get indent.
The most likely solution, off the top of my head, would involve
subclassing the NSOutlineView and overriding some method to tell
Cocoa to indent some rows more than others.
Here is one possibility. I don't know that it works, but it
might. Try it and see.
// you would need to subclass NSOutlineView, if you haven't
already and override this method
- (NSInteger)levelForItem:(id)item
{
NSInteger level = [super levelForItem:item];
if ([item needsExtraIndenting] == YES) // whatever your test is here
level++;
return level;
}
Another possibility would involve overriding something else, maybe
like this:
- (NSRect)frameOfCellAtColumn:(NSInteger)column row:(NSInteger)row
{
NSRect rc = [super frameOfCellAtColumn:column row:row];
if ([[self itemAtRow:row] needsExtraIndenting] == YES) // whatever
your test is here
{
CGFloat indent = [self indentationPerLevel];
rc.origin.x += indent;
rc.size.width -= indent;
}
return rc;
}
Again, I don't know that this works, but this is the type of
solution I would look for first. Look through NSOutlineView.h
and NSTableView.h for interesting methods that you can override
and customize. That's what I did to find these two.
john
On Jul 8, 2008, at 3:48 AM, Aman Alam wrote:
Is there a way to indent main headings in NSOutlineView as
follows: -
Heading 1
Item
Item
Heading 2
Item
Heading 2.1
Item
Item
Heading 3
Item
I tried many ways to indent the headings but not succeeded. The
disclosure triangle doesn't indent with headings. I required
heading within heading and the heading should be independent of
its parent heading. The parent heading may contain any number of
items within.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
No virus found in this incoming message.
Checked by AVG - http://www.avg.com Version: 8.0.138 / Virus
Database: 270.4.7/1541 - Release Date: 7/8/2008 7:50 PM
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden