A virtual listbox is a listbox that presents an arbitrarily large list
without keeping the entire list in memory.
Instead of maintaining all the list entries, the virtual listbox maintains
a smaller cache of list entries for presentation. As the listbox's visible
window moves, the contents of the cache are managed so that the visible
items are in memory.
We modified the tkListbox.c source to produce tkVlistbox.c, which
implements a new Tk command, vlistbox. The vlistbox command works
just like the listbox command, except as follows:
1. There are several additional configuration options.
-cachesize
This is the maximum number of elements maintained in memory at any
one time. It must be at least as large as the visible number of
entries. The default for the cachesize is 100.
-numelements
This is the total number of elements in the list. We need this to
properly position the thumb of the scrollbar.
This option is required.
-getelementcommand
This is a user-supplied script that supplies the string to be
displayed at any given position. The script takes a single
parameter, a 0-based index. It returns a list consisting of
a return code and the string to be displayed at that index.
the return code is:
0 (TCL_OK) if everything is ok
3 (TCL_BREAK) if the string is not available
1 (TCL_ERROR) in any other case
If the return code is 0, then the second element of the list
is the string to be displayed.
This option is required.
2. There is an additional widget command, "flush", that tells the
vlistbox to dump its cache and repopulate it with calls to the user
script.
3. There is no insert or delete command.
These are not necessary, since the list element for every position
is provided, as needed, by a script.
4. There is currently no multiple selection.
We didn't need it right away, and haven't gotten around to it yet.
To Do List
1. Add multiple selection
2. Add some more error handling (like missing required options)
3. port to Tcl 7.4 / Tk 4.0
How to get it.
The virtual listbox package consists of a single source file
(tkVlistbox.c), this documentation, instructions for installing it,
and two simple demo scripts.
For now, I will email a copy to anyone who requests it. If there is
enough demand, or when I've done a couple of the items on the
"To Do List" I'll submit it to alcatel.
--
Greg Goodman
gr...@neosoft.com
<URL: http://starbase.neosoft.com/~gregg>