FROM : Mike Ferris
DATE : Mon Dec 09 19:30:54 2002
Both TextEdit and Sketch do this sort of thing. Mostly,
programmatically creating a text system is simple. If you just
alloc/init the pieces and hook them up, you'll get something that
behaves, by default, pretty much like the one in IB (the one in IB is
inside a scroll view, but you can do that too if you want).
TextEdit does it for its main editor, but it has no document/controller
separation so it creates the whole chain from storage to view together.
Sketch uses a setup very similar to what I described for editing the
text of TextArea graphics. The TextArea is the model object in this
case, and it has-a NSTextStorage. It also has code in the
-startEditingWithEvent:inView: method that shows how to contruct the
layout manager, container, and text view and then how to hook it up to
the storage.
There's some extra baggage in Sketch because of the whole "editor"
business (eg the fact that the same "editor" is used to edit multiple
NSTextStorage objects over time), but the basics are exactly the same
as I was suggesting.
Mike
Begin forwarded message:
> From: Chaffinch <<email_removed>>
> Date: Mon Dec 9, 2002 5:30:38 AM US/Pacific
> To: <email_removed>
> Subject: Re: Subclassing NSWindowController
>
> --- Mike Ferris <<email_removed>> wrote:
>
>> Here's one possible implementation strategy:
>>
>> - document has-a NSTextStorage
>> - init method of your document creates an NSTextStorage
>> - load or read method of your document loads or reads into the
>> NSTextStorage
>> - window controller has-a
>> NSTextView-NSTextContainer-NSLayoutManager chain of objects (but no
>> NSTextStorage).
>> - window controller creates these objects programmatically,
>> probably
>> - window controller's setDocument: makes sure the NSLayoutManager
>> gets connected to the NSTextStorage of the new document (using
>> NSTextStorage's addLayoutManager:).
>
>
> Thanks to Mike and everyone else who offered suggestions to me on this
> topic.
> I modified my code and got the original design working great.
> However, I am interested in the points raised about using an
> NSTextStorage
> and keeping the model and view seperate. Therefore I am no
> reimplementing my
> code to use the NSTextView-NSTextContainer-NSLayoutManager chain of
> objects
> mentioned by Mike.
>
> But I have one more question, the Cocoa docs have an article titled
> "Assembling the Text System by Hand" which shows how to create the
> TextStorage, Container and LayoutManager. Is this the procedire I
> should
> follow or am I over complicating things.
>
> Regards
>
>
> =====
> Regards
>
> Chaffinch
> ----------------------------------------------
> Everything you'll ever need on one web page
> from News and Sport to Email and Music Charts
> http://uk.my.yahoo.com
> _______________________________________________
> cocoa-dev mailing list | <email_removed>
> Help/Unsubscribe/Archives:
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
DATE : Mon Dec 09 19:30:54 2002
Both TextEdit and Sketch do this sort of thing. Mostly,
programmatically creating a text system is simple. If you just
alloc/init the pieces and hook them up, you'll get something that
behaves, by default, pretty much like the one in IB (the one in IB is
inside a scroll view, but you can do that too if you want).
TextEdit does it for its main editor, but it has no document/controller
separation so it creates the whole chain from storage to view together.
Sketch uses a setup very similar to what I described for editing the
text of TextArea graphics. The TextArea is the model object in this
case, and it has-a NSTextStorage. It also has code in the
-startEditingWithEvent:inView: method that shows how to contruct the
layout manager, container, and text view and then how to hook it up to
the storage.
There's some extra baggage in Sketch because of the whole "editor"
business (eg the fact that the same "editor" is used to edit multiple
NSTextStorage objects over time), but the basics are exactly the same
as I was suggesting.
Mike
Begin forwarded message:
> From: Chaffinch <<email_removed>>
> Date: Mon Dec 9, 2002 5:30:38 AM US/Pacific
> To: <email_removed>
> Subject: Re: Subclassing NSWindowController
>
> --- Mike Ferris <<email_removed>> wrote:
>
>> Here's one possible implementation strategy:
>>
>> - document has-a NSTextStorage
>> - init method of your document creates an NSTextStorage
>> - load or read method of your document loads or reads into the
>> NSTextStorage
>> - window controller has-a
>> NSTextView-NSTextContainer-NSLayoutManager chain of objects (but no
>> NSTextStorage).
>> - window controller creates these objects programmatically,
>> probably
>> - window controller's setDocument: makes sure the NSLayoutManager
>> gets connected to the NSTextStorage of the new document (using
>> NSTextStorage's addLayoutManager:).
>
>
> Thanks to Mike and everyone else who offered suggestions to me on this
> topic.
> I modified my code and got the original design working great.
> However, I am interested in the points raised about using an
> NSTextStorage
> and keeping the model and view seperate. Therefore I am no
> reimplementing my
> code to use the NSTextView-NSTextContainer-NSLayoutManager chain of
> objects
> mentioned by Mike.
>
> But I have one more question, the Cocoa docs have an article titled
> "Assembling the Text System by Hand" which shows how to create the
> TextStorage, Container and LayoutManager. Is this the procedire I
> should
> follow or am I over complicating things.
>
> Regards
>
>
> =====
> Regards
>
> Chaffinch
> ----------------------------------------------
> Everything you'll ever need on one web page
> from News and Sport to Email and Music Charts
> http://uk.my.yahoo.com
> _______________________________________________
> cocoa-dev mailing list | <email_removed>
> Help/Unsubscribe/Archives:
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
| Related mails | Author | Date |
|---|---|---|
| Chaffinch | Dec 5, 11:16 | |
| Dietrich Epp | Dec 5, 11:50 | |
| Chaffinch | Dec 5, 15:16 | |
| Jérôme Laurens | Dec 5, 15:59 | |
| Mike Ferris | Dec 5, 18:51 | |
| Bill Cheeseman | Dec 6, 00:14 | |
| Steve Martin | Dec 6, 00:26 | |
| Dietrich Epp | Dec 7, 01:09 | |
| Chaffinch | Dec 9, 14:30 | |
| Mike Ferris | Dec 9, 19:30 | |
| Jérôme Laurens | Dec 10, 11:07 | |
| Chaffinch | Dec 10, 13:51 | |
| Mike Ferris | Dec 10, 20:16 | |
| Chaffinch | Dec 16, 19:56 |






Cocoa mail archive

