Re: Multi-Column NSTextField
Re: Multi-Column NSTextField
- Subject: Re: Multi-Column NSTextField
- From: Douglas Davidson <email@hidden>
- Date: Fri, 18 Oct 2002 10:36:49 -0700
On Friday, October 18, 2002, at 10:18 AM, email@hidden wrote:
Two questions about using Cocoa's Text System (NSText, NSTextStorage,
NSTextContainers, NSLayoutManager) with regard to a multi-columns
application. Assume that I am writing an application that displays
multipage's of text, and allows users to switch between 1 to 3 columns
where
the text flows from one column to another, one page to another.
When user selects one column, the application can create one Text
Container &
one Text Field to display the information. The column would be as wide
as a
printable width of page, while the length would be what is needed to
display
entire text (regardless of how long the printable page is). When the
user
prints, the print engine will break the large display area up into
separate
print pages.
However, when user selects 2 or more columns, the program has to create
multiple Text Container/Text Field pairs, to fill up each page. For
example,
if user selects 3 column style of page, and there is enough text for 8
columns, the program needs to calculate and create 8 Text
Containers/Text
fields (each the height of the printable area of the page). First the
program
would create three columns, side by side, then move down to bottom of
first
column, and create 3 more columns, and then move down for last two
columns.
This way the page would be split correctly when displayed and printed
out
with page break.
Does this sounds correct? Or is there a simplier way?
That sounds about right. That should be "text view" rather than "text
field", though.
Second question, when working with more than 1 column, I have to first
create
a Container/Field pair that are the width of the column size I want,
then
fill the text into it and resized it! I need this resized information
to know
how much height is need to display the text over multiple containers
for a
given width.
Does this sound correct? Or is there a simplier way?
That's one way to do it. However, it would probably be more efficient
to just create and fill the text containers one at a time until you
have enough to hold the text. This is what TextEdit does when it is in
wrap-to-page mode, except that TextEdit's containers each cover an
entire page, not a single column. See the TextEdit sources for details.
Douglas Davidson
_______________________________________________
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.