+--------------------------------------------------------------+
pretty long list version 1.0 Fri, Jan 3, 2003
+--------------------------------------------------------------+
This is the first time I have submitted code to the list. Hopefully it will
be useful to someone. I call it Pretty Long List. It simulates a basic
appearance-type list, but can contain over 32,000 items, and is not limited
to 32k of text. Suggestions, improvements, praise and criticism are welcome.
Also, testing on OSX would be appreciated, since I don't have it (some
flushwindowbuffers needed?). Check the drop box for the project.
This code is based on Robert Purvis' Scroll Text Any Length Version 3 and is
carbonized. I wouldn't even have attempted it if I didn't have a good base
to work from. I needed a list to display more than 4000 (probably against
HIG) items which turned out to be over 32k of text, so a standard list
wouldn't work. It seemed to be easier to modify the scrolling text code than
to write a custom LDEF, and here's what I came up with.
+--------------------------------------------------------------+
Things modified or added (from Scroll Text Any Length):
+--------------------------------------------------------------+
The list uses an arbitrary rectangle, rather than the whole window, so you
can have other items in the window, just like a real list.
Word wrap is not implemented (duh! It's a list!).
The text is stored in an array for easy access.
You can set the background and the text of the list to any silly color you
want.
All items related to the list are stored in the list record, to facilitate
local mode functions.
You can easily change margins and spacing between lines of the list.
Items can be clicked on to select them, however only one item can be
selected at a time, because that's what I needed. Feel free to change that
if you need to.
You can search the list by typing. Just type, and the list will scroll to
the line equal or greater to what you've typed, just like the finder. I used
a thread to implement the timer that resets the typing, to see if I could
make it work. It does, nicely. Thanks to Staz & Andy for making threads so
easy to use.
In the sample project, up arrow, down arrow, page up, page down, home, and
end keys are routed to the list.
The sample project fills the list with random text, then sorts it using
another contribution from the generous Mr. Purvis, an indexed Quicksort,
before displaying it.
+--------------------------------------------------------------+
Warnings:
+--------------------------------------------------------------+
If the width of an item exceeds the width of the list, it will be drawn
outside the list rectangle.
I've tested this with over 30,000 items and the list works snappily on my
iMac G3 350/sys 9.2.2. More than 32,767 items will not work properly,
because I used shorts for some items, but that's more than enough, isn't it?
Anyway, you can always modify it.
Larry T.
+--------------------------------------------------------------+
The release notes for Scroll Text Any Length are included below
+--------------------------------------------------------------+
Display a text file of any length (not limited to 32000 characters by
TextEdit)
with live vertical and horizontal scrolling.
I have chosen to implement a TextRecord (broadly similar to an official
TextEdit record)
which contains the text itself and all relevant information for FN
DisplayText.
By this means, a confusing clutter of global variables was reduced to 1.
Colossal files with more than 32760 lines are scrolled in steps of 2 lines
or more,
to work around the limit set by scroll button values.
Run the program and use the File menu's Open command to open any text file.
Robert P. January 2001
Enhancements in version 2:
---------------------------
Optionally uses ScrollRect for 1-line scrolls, instead of re-drawing the
whole thing.
This has the advantage of being 5-10 times faster (important on a slow
machine),
but if there is a floating window in front (such as the Control Strip), the
text
gets messed up.
Turn this on or off like this:
gTextRecord.fastScroll = _zTrue // _zTrue or _false
Version 3
---------
Now Carbon compatible; runs in OS X December 2001
Release 7 compliance update by STAZ { 8/9/02 }
+--------------------------------------------------------------+