Re: NSLayoutManager question
Re: NSLayoutManager question
- Subject: Re: NSLayoutManager question
- From: "Erik M. Buck" <email@hidden>
- Date: Mon, 3 Feb 2003 17:24:43 -0500
I would say that if adding a space after every ten letters is purely a
display/layout issue (the space does not exist in the model data) then
displaying a space is in fact a responsibility of the view layer in a
model/view/controller architecture.
I think a nice way to handle this task is to actually use tabs (\t) rather
than spaces in the display. That way users can use the standard text ruler
with tab stops to layout the data... but anyway...
If there is _not_ a lot of data, the path of least resistance is to
manipulate the underlying text storage directly even though it is part of
the model. To display the data, iterate through the text inserting '\t' or
' ' every ten letters. When you want to process the data, remove all of the
'\t' or ' ' characters. NSScanner is ideal for this.
If you have a lot of data or you need interactive editing or you want a pure
implementation of model/view/controller, I can think of a few options in no
particular order:
1) Use NSTableView instead of NSTextView. Have a column for each set of 10
letters and rows. You can have a controller class that is the table's data
source and implicitly provides the formatting when breaking up the string
for display.
2) Start with the multi-column text example that Apple provides. Use lots
of chained text containers, one for each group of ten letters. You will
have N columns by M rows of text containers. This way if the user inserts
characters, all of the text will re-flow through the containers.
3) Create your own layout manager. This is the hardest way.
4) Use text editing delegate methods or control text editing delegate
methods to format on the fly
5) Use an NSMatrix full of cells that each display ten characters
6) write your own NSView subclass that draws the strings using Quartz/Core
Graphics any way you want (editing is difficult this way, but you could
follow the Sketch example for arbitrary editable text graphics...)
_______________________________________________
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.