On 8/6/09 5:08 PM, Grant Erickson wrote:
> I am implementing a non-editable custom table view cell (a bit similar to the
> network connection listing in the System Preferences Network preference pane)
> in a single-column, no header NSTableView.
> 
> The cell consists of an image, another image, two stacked strings (left
> aligned), another string (right aligned) and a custom-drawn graphic:
> 
>       .------..--------------------------.                   .------.
>   .--.|      ||                          |.-----------------.|      |
>   !__!|      ||--------------------------|!_________________!|      |
>       !______!!__________________________!                   !______!
> 
>   Img  Image   Strings                                String  Drawn
> 
> At this point, I've all the icons and graphics drawing correctly and the text
> displaying with attributes (i.e. inverting when selected, etc.) using
> drawAtPoint:withAttributes:.
> 
> However, with regard to the strings, particularly concerning the
> right-alignment of the non-stacked string, nudging around the X points to
> achieve the proper right-alignment seems like the wrong way to approach this
> and that I should be specifying NSTextAlignment in some way when the string is
> drawn.
> 
> In addition, paragraph style attributes (NSRightTextAlignment or
> NSLineBreakByTruncatingMiddle) seem (perhaps unsurprisingly) to not apply to
> drawAtPoint:withAttributes:.
> 
> Do I need to create or should I instead be creating three NSTextViews, one for
> each string, and adding them as subviews to my custom cell's view rather than
> trying to use drawAtPoint:withAttributes:?

It would appear that drawInRect:withAttributes: does the trick, respecting
both alignment and line breaking.

Regards,

Grant


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to