• 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: Custom Table View Cells and String Text Alignment and Breaking
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom Table View Cells and String Text Alignment and Breaking


  • Subject: Re: Custom Table View Cells and String Text Alignment and Breaking
  • From: Grant Erickson <email@hidden>
  • Date: Thu, 06 Aug 2009 18:27:52 -0700
  • Thread-topic: Custom Table View Cells and String Text Alignment and Breaking

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 (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

References: 
 >Custom Table View Cells and String Text Alignment and Breaking (From: Grant Erickson <email@hidden>)

  • Prev by Date: Re: Custom Table View Cells and String Text Alignment and Breaking
  • Next by Date: embedding framework in Application bundle?
  • Previous by thread: Re: Custom Table View Cells and String Text Alignment and Breaking
  • Next by thread: embedding framework in Application bundle?
  • Index(es):
    • Date
    • Thread