LazyScrollDir
By Paul S. McCarthy and Eric Sunshine
Copyright ã1995,1996,1997,1998 by Paul S. McCarthy and Eric Sunshine
March 25, 1998

Overview

This program demonstrates the use of the MiscTableScroll object in lazy mode by acting as a simple directory browser.  Basic operations such as open, delete, rename, and change directory can be performed on the listed files and directories.

Notable Features

Lazy Mode
This program illustrates how to use a lazy mode MiscTableScroll.  In lazy mode the data-delegate (or the delegate if there is no data-delegate) is responsible for supplying the cells that the MiscTableScroll will display.  In this example, the data-delegate also supplies information (such as stringValue, intValue, tag, etc.) during sorting as a speed optimization.

This program allocates a single cell for each column.  When the MiscTableScroll requests a cell for some column and row, the data-delegate takes the cell it allocated for that column, fills it with information from that row, and returns it.  As a side-effect of this, time-consuming operations such as fetching a file's icon can be delayed until the information is actually needed.

This contrasts sharply with eager mode, in which all cells are created and filled immediately.  Lazy mode is useful for exceptionally large data sets or data sets for which data retrieval is very time-consuming.  Eager mode, however, is usually easier to program.

Color
The example shows how to use color with the MiscTableScroll.  Color swatches can be dragged from the Color Panel and dropped onto the browser window.  The background of the MiscTableScroll is set to the color of the dropped swatch.

When the highlight directories switch is toggled on the rows for directories are highlighted in a color independent of the MiscTableScroll.

Font
When the MiscTableScroll is first-responder, the Font Panel can be used to change its font.

Users Preferences
This program demonstrates how to save and restore the user's column order and width preferences.  Additionally, all other user preferences -- font, color, switch settings, and window size -- are also saved and restored.

Sorting
A switch on the browser window controls whether or not rows are automatically sorted as columns are rearranged.  This demonstrates the very powerful built-in sorting capability of MiscTableScroll.  Sorting can be fine-tuned right in the nib file by adjusting the criteria on a column-by-column basis.  For instance, columns may contribute stringValue, title, intValue, tag, etc. to the row-wise comparisons.

Icon Display
One column in the browser displays the file's icon.  This demonstrates how to use icon columns in addition to text columns.

Image Dragging
MiscTableScroll allows images to be dragged directly out cells.  In this example, the file's icon can be dragged directly from the directory browser into any other application which accepts dragged filenames, such as File Viewer, Mail, Edit, etc.  A button controls whether or not the scaled or full-size image is used during the dragging operation.  This illustrates how the delegate can optionally substitute an image in place of the one already contained in the cell.

Text Editing
MiscTableScroll supports in-cell text editing.  This example program uses the editing feature to allow the user to rename files.  Double-clicking with the mouse on the file name in the Name column initiates editing.

Buttons
This example illustrates how to use ButtonCells with the MiscTableScroll.  One column contains a ButtonCell configured as a toggle switch.  It displays a padlock in either a locked or unlocked state and clicking on it toggles its state.  The padlock indicates whether or not the file can be renamed.  When unlocked, renaming is allowed, and double-clicking on the file name in the Name column initiates an edit session.  When locked, renaming is not allowed.  If you do not have permission to rename a file the browser displays a locked icon and disables the ButtonCell.

Saving (Exporting)
MiscTableScroll can export its contents in dBASEIII (.dbf) format and also a number of ASCII formats via the Save menu item on the Directory menu.

Printing
MiscTableScroll respects the various page layout options, such as shrink-to-fit, spill, crop, centering, etc.

Conclusion

LazyScrollDir was written by Paul S. McCarthy and Eric Sunshine and is copyright ã1995, 1996, 1997, 1998 by Paul S. McCarthy and Eric Sunshine.  It is included in the MiscKit by permission from the authors and is governed by the MiscKit license found in the file License.rtf in the MiscKit distribution.

Please direct comments, questions, and complaints to:

·	Paul S. McCarthy <zarnuk@mcgh.org>
·	Eric Sunshine <sunshine@sunshineco.com>

NeXT, MIME, and ASCII mail accepted.