• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Determining width of a cell in an NSOutlineView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Determining width of a cell in an NSOutlineView


  • Subject: Re: Determining width of a cell in an NSOutlineView
  • From: Eric Gorr <email@hidden>
  • Date: Mon, 5 Jan 2009 11:56:10 -0500


On Dec 19, 2008, at 6:03 PM, Corbin Dunn wrote:


On Dec 19, 2008, at 2:30 PM, Eric Gorr wrote:



I just need to know the width so I base the height on the width.


For that, you want to use -cellSizeForBounds: -- pass in a large height, but a constrained width. Use a width that is equal to the [tableColumn width] minus indentation * (level + 1) ---- although, the actual value that outlineview uses for indentation is dependent on some internal logic (ie: if you are using "group rows", or the "source list highlighting style"). But, this should give you a value that is fairly close to what you want.

I guess I spoke to soon. This doesn't actually seem to work.

I have the following code in my -outlineView:heightOfRowByItem: method:

NSTableColumn *column = [outlineView outlineTableColumn];
NSUInteger nItems = [item count];
CGFloat indentation = [outlineView indentationPerLevel];
NSInteger level = [outlineView levelForItem:item];
NSRect bounds = NSMakeRect(0, 0, [column width], 10000);
NSCell *tableCell = [column dataCell];
CGFloat totalOffset = ( indentation * ( level + 1 ) );
NSSize cellSize = [tableCell cellSizeForBounds:bounds];
NSUInteger nItemsPerRow = ( cellSize.width - totalOffset ) / 80;


The width of the column is 711. However, cellSize.width is just 42.xx when it should be around 700 as well.

Any thoughts?
_______________________________________________

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


  • Follow-Ups:
    • Re: Determining width of a cell in an NSOutlineView
      • From: Corbin Dunn <email@hidden>
  • Prev by Date: Re: Which language to get started with cocoa development?
  • Next by Date: Re: Pull Down Toolbar Item
  • Previous by thread: Re: Determining width of a cell in an NSOutlineView
  • Next by thread: Re: Determining width of a cell in an NSOutlineView
  • Index(es):
    • Date
    • Thread