Re: [Q] Trouble setting an image in an NSOutlineView [SOLVED]
Re: [Q] Trouble setting an image in an NSOutlineView [SOLVED]
- Subject: Re: [Q] Trouble setting an image in an NSOutlineView [SOLVED]
- From: Mark de Jong <email@hidden>
- Date: Mon, 26 Aug 2002 13:45:37 -0700
Ok. I feel a bit silly about the solution to this problem, but I'll
share it in the hopes that I'm not the only silly one. :-)
When using an NSOutlineView, unless you specify it, the first column is
used to display the disclosure/hierarchy triangle. In my case, below,
the first column held my 16x16 icon and its row was not expandable, so
no triangle was displayed. However, NSOutlineView needs to ensure that
there's room for the triangle should that row become expandable.
My icon was being pushed to the right, outside of the boundary of the
cell, in order to make room for the triangle.
Once I made the column wider, or specified a different column as the
"triangle keeper" (setOutlineTableColumn:), my icon appeared as it was
supposed to.
Thanks to Ryan for hanging in there with several good suggestions. :-)
-- Mark
On Sunday, August 25, 2002, at 11:13 PM, Ryan Stevens wrote:
>
Have you tried setting the alignment of the cell? To
>
NSImageAlignCenter perhaps?
>
>
It sounds like maybe the cell is aligning the image with
>
NSImageAlignRight as the default for some reason.
>
>
Other than that, I don't know what to try. Maybe you'll already have
>
tried that by the time you get this ! ;-)
>
>
On Sunday, August 25, 2002, at 01:15 PM, Mark de Jong wrote:
>
>
> Yeah, I noticed that too. It did not fix the problem.
>
>
>
> However, what I found out was that the icon is being displayed to the
>
> far right of the cell. Even though the image is only 12x12, the cell
>
> needs to be at least 20 wide before I see the icon.
>
>
>
> So, the problem seems to be that the NSImage is appearing outside
>
> (clipped) of the table cell. Again, if I make the cell wide enough, I
>
> can see the image.
>
>
>
> This is still puzzling. If the NSImage is 12x12, it should easily fit
>
> in a 16x16 cell, right?
>
>
>
> -- Mark
>
>
>
> On Sunday, August 25, 2002, at 08:44 AM, Ryan Stevens wrote:
>
>
>
>> See below. I can't believe I missed this...
>
>>
>
>> On Saturday, August 24, 2002, at 08:54 PM, Mark de Jong wrote:
>
>>
>
>>> Thanks, Ryan.
>
>>>
>
>>> I read about that in the archives. The problem is, the rect is
>
>>> still too large and it overlaps the next column in the
>
>>> NSOutlineView. I guess I could fix that.
>
>>>
>
>>> It just seems like NSImageCell should do exactly what I want it to
>
>>> do and I'm puzzled why it doesn't work.
>
>>>
>
>>> Anyway, thanks for your suggestion. I appreciate you taking the
>
>>> time to answer my query.
>
>>>
>
>>> -- Mark
>
>>>
>
>>> On Saturday, August 24, 2002, at 08:38 PM, Ryan Stevens wrote:
>
>>>
>
>>>>
>
>>>> On Saturday, August 24, 2002, at 08:18 PM, Mark de Jong wrote:
>
>>>>
>
>>>>> Hi!
>
>>>>>
>
>>>>> I cannot seem to get an NSImageCell to appear in an NSOutlineView.
>
>>>>>
>
>>>>> I set things up with:
>
>>>>>
>
>>>>> aTableColumn = [table tableColumnWithIdentifier:@"icon"];
>
>>
>
>> You're changing the cell type for the column identified as "icon".
>
>> Then...
>
>>
>
>>>>> imageCell = [[NSImageCell alloc] initImageCell:nil];
>
>>>>> [aTableColumn setDataCell: imageCell];
>
>>>>> [imageCell release];
>
>>>>>
>
>>>>> Then, I add this delegate:
>
>>>>>
>
>>>>> - (void)outlineView:(NSOutlineView *)outlineView
>
>>>>> willDisplayCell:(id)cell
>
>>>>> forTableColumn:(NSTableColumn *)tableColumn
>
>>>>> item:(id)item
>
>>>>> {
>
>>>>> NSString *identifier = [tableColumn identifier];
>
>>>>>
>
>>>>> if( [identifier isEqual:@"activated"] ) {
>
>>
>
>> Why look for "activated"?
>
>>
>
>> Shouldn't this be:
>
>> if ([identifier isEqualToString:@"icon"]) { /* ... */ }
>
>> ?
>
>>
>
>>>>> NSLog( @"about to set the image" );
>
>>>>> [cell setImage:fontIsDamagedImage];
>
>>>>> }
>
>>>>> }
>
>>>>>
>
>>>>> However, no icon appears.
>
>>>>>
>
>>>>> If, however, I change the second line to:
>
>>>>>
>
>>>>> imageCell = [[NSBrowserCell alloc] initImageCell:nil];
>
>>>>>
>
>>>>> Then my icon appears, with the "disclosure triangle" next to it,
>
>>>>> which
>
>>>>> is not what I'm looking for. I've look through the archives but
>
>>>>> cannot
>
>>>>> seem to find a solution. What's even worse is that I had this
>
>>>>> working
>
>>>>> at one point. I just cannot make it work again. :-)
>
>>>>>
>
>>>>> Does anyone here know how I can make my icon appear using
>
>>>>> NSImageCell?
>
>>>>>
>
>>>>
>
>>>> Not sure about the image cell but for the browser cell just
>
>>>> setLeaf:YES (removing the triangle) on it and go...?
>
> _______________________________________________
>
> cocoa-dev mailing list | email@hidden
>
> Help/Unsubscribe/Archives:
>
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.