• 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 NSView That is iChat Chat Log Like
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom NSView That is iChat Chat Log Like


  • Subject: Re: Custom NSView That is iChat Chat Log Like
  • From: "I. Savant" <email@hidden>
  • Date: Wed, 28 Feb 2007 00:31:42 -0500


You really should consider using an NSControl subclass with an NSCell subclass. See Control and Cell Programming Topics for Cocoa guide:


http://developer.apple.com/documentation/Cocoa/Conceptual/ControlCell/ index.html

Basically, an NSView is a computationally expensive ("heavy") object. If you use a control with cells, the cell will know how to draw the text without an NSTextView ... then you can use the field editor (read up on that too, to know why it's far more efficient than a s**t-load of NSTextViews) to actually edit the contents of an individual cell in the control.

The *best* solution would be to use an NSTableView with your custom cell, using variable row height (see the archives for achieving this pre-10.4). That way, you don't have to worry about layout or row/selection management. The table view gives you all that for free. All you need to worry about is your custom cell with its custom drawing/editing methods. Recreating all that a table does for you is nontrivial and kind of pointless.

--
I.S.


On Feb 28, 2007, at 12:16 AM, Jones Curtis wrote:

Hopefully this wasn't a poor solution that I ended up using. I created a custom NSView for the NSScrollView and within that custom NSView I have an array of custom NSViews that represent each "chat messages" -- or in my case, data packets -- with hex offset, hex and ascii data in three columns, along with a background color behind the hex data to represent the direction the data was traveling (send, receive).

For the time being, the NSTextField objects that actually draw the text are allocated when the packet information is received, and retained until the window is closed. Ultimately, I'm considering having a pool of them; and the pool would grow to at most the number of instances necessary to draw the viewable data. As a set of text fields scroll off the screen and others scroll on, they'd be re-used. A binary search (or some such) would be used to find the data packet object that needs to be drawn. Presently, the per- data-packet NSTextField objects are placed within the larger custom NSView, and simply left there.

If anyone has any better suggestions (I have not yet implemented the above-described optimizations), I'd like to hear them.


-- Curtis Jones email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
40gmail.com


This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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 NSView That is iChat Chat Log Like (From: Jones Curtis <email@hidden>)
 >Re: Custom NSView That is iChat Chat Log Like (From: Andreas Mayer <email@hidden>)
 >Re: Custom NSView That is iChat Chat Log Like (From: Jones Curtis <email@hidden>)

  • Prev by Date: Re: Custom NSView That is iChat Chat Log Like
  • Next by Date: Re: Custom NSView That is iChat Chat Log Like
  • Previous by thread: Re: Custom NSView That is iChat Chat Log Like
  • Next by thread: Re: Custom NSView That is iChat Chat Log Like
  • Index(es):
    • Date
    • Thread