ListTree Widget Web Page

# ListTree Widget

A low resource widget designed to display text strings in a "directory list" sort of structure.

- Current Version
- Screen Shots
  - Basic Demo
  - File Selector Demo
- Important version 2.0 changes
- Overview
- Features
- Requirements
- History
- Author's Note
- Thanks
- Copyright

- Programmer's Documentation

## Current Version

The current version is 2.0. Source is available at ftp.x.org.

## Screen Shots

### Basic Demo

This picture shows the formatting of the ListTree widget:

### File Selector Demo

A more complete (but unsupported) demo is also included with the ListTree widget. Using the 3D Athena widgets, this tree file selector shows more of the potential usage of the widget:

## Important version 2.0 changes

Why is this version 2.0, rather than a simple update to 1.1?

Mostly because of a change in the callbacks. Version 1.0 required the user to free the callback return structure, ala Motif. I didn't like to code it that way originally, but I did. Once I figured out that that XtCallCallbacks didn't return to the widget until the callbacks return (rather than asyncronously), I changed the callback code so that the user doesn't free the return structure.

The old callbacks still exist in the widget, but should now be considered historical and unsupported. So, go ahead and switch to the new callbacks now, because I might remove the historical callbacks in a future release. If you switch now, you won't be mad when I really do take out the old, hacky callback routines. :) Check the Programmer's Documentation for more information on converting to the new methods. It's easy!

The other new features in the widget are multiple highlighting, and a change in the operating methodology of the widget. Single clicking on the text of on item highlights the item, but does not open it. Single clicking and dragging selects multiple items. Double clicking the text highlights the item, unselects everything else, and opens the item. Single clicking on the icon opens the item.

## Overview

The ListTree Widget is small list widget capable of displaying lists of text strings (with an optional pixmap) in a heirarchal directory list sort of format. Unlike all of the other freely available tree widgets that I could find, this widget does not use widgets for each item displayed in the tree. Instead, it is a list of text strings that contain pointers to parents and children in the tree. This reduces memory usage over widget tree widgets, and also simplifies use.

This widget was designed for use in file manager type programs, so an optional pixmap is available for displaying to the left of the text item. The pixmap has an open and closed state, and different types of pixmaps are available for items with and without children. Currently, pixmaps for different file types are not available.

The lists are activated by clicking the left mouse button on the Pixmap of the item, or double clicking ond the name of the item. The state of the item is then toggled, and if the item is open, its children are displayed. Ranges of items can also be toggled by clicking and dragging the left mouse button over the names of the items you want to highlight.

Because everyone has different tastes in scrollbar asthetics, the ListTree widget doesn't have any built-in scrolling capability. It is designed to be placed in some sort of container widget, and use the container's functions to scroll around.

## Features

Features provided in the widget include the following:

- Pixmap displayed to the left of the text string
- Different pixmaps for open and closed states
- Item highlighting (single or multiple items)
- Double click name or single click on icon to open or close
- Callbacks: (called when selected or unselected)
  - Changing state
  - Highlighting
  - Historical (Superceded, but still exist in version 2.0.)
    - Any item
    - Item with children
    - Item without children
- Selectable line width
- Selectable font
- Various spacing options
- Convenience Functions:
  - Add Item
  - Delete Item (also deletes dependent children)
  - Reparent Item
  - Reparent item's children
  - Order items
  - Order item's children
  - Search for item text
  - Highlight item

## Requirements

The ListTree code requires X11R4 or later and an ANSI C compiler. The code may compile on a non-ANSI compiler if it supports new style function definitions.

The widget is compatible with MOTIF, but does not require it. It looks great with the Athena 3D widgets.

## History

This code was originally developed on an IBM RS/6000 running AIX 4.1 and X11R5. Version 2.0 was developed on a Linux machine running kernel 1.3.* and XFree86 3.1.2 (X11R6). It was also tested on two other machines: a DEC Alpha/AXP running OSF/1 3.0 with X11R5; and an SGI Indigo running IRIX 4.0.5 with X11R4.

## Author's Note

This widget is supplied as freeware, in the hope that it will be useful for developers in the X community. If you do use this widget, I do request that you include mention of the ListTree widget in the documentation. Also, remember to include a copy of the entire copyright and permission notice! Thanks.

Patches, improvements, suggestions, bug reports, job offers, volleyball games, and money you love donating to programmers who make your life so much easier are welcome at `<rwmcm@orion.ae.utexas.edu>`. I will periodically post patches and improvements to ftp.x.org and the ListTree web page at http://www.ae.utexas.edu/~rwmcm/ListTree.html

## Thanks

Thanks to the following people for providing fixes and suggestions:

- Kevin Carson `<kcarson@direct.ca>`
- Tessa Lau `<tlau@allegra.att.com>`
- Pierre Duchene `<pierre@ovs.com>`
- Xyvind Yrke `<oyvind@stavanger.geco-prakla.slb.com>`
- Douglas Kosovic `<douglask@dstc.edu.au>`

## Copyright

Copyright (c) 1995 Robert W. McMullen

###### Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. All work developed as a consequence of the use of this program should duly acknowledge such use. The author makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.

###### THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

About the author | Send me E-mail | ListTree Programmer's Reference | Top of page