http://invisible-island.net/athena_widgets/XawPlus
Application Header file Class Header file Class Class Name Superclass |
<X11/XawPlus/IconList.h> <X11/XawPlus/ListP.h> iconListWidgetClass List Simple |
The List widget contains a list of strings and/or bitmaps formatted into rows and columns. When one of the strings is selected, it is highlighted, and the List widget's Notify action is invoked, calling all routines on its callback list. Only one string may be selected at a time.
Since release 3.0 of XawPlus, this widget is only a IconList compatible mapping to the List widget. Programmers may use IconList as in previous versions for the future but a List widget will be created.
When creating a List widget instance, the following resources are retrieved from the argument list of XtSetValues() or XtVaSetValues() or from the resource database:
Name | Class | Type | Default Value |
OBJECT: | |||
destroyCallback | Callback | Pointer | NULL |
RECTANGLE: | |||
borderWidth height sensitive width x y |
BorderWidth Height Sensitive Width Position Position |
Dimension Dimension Boolean Dimension Position Position |
0 12 True 12 0 0 |
CORE: | |||
border background mappedWhenManaged |
BorderColor Background MappedWhenManaged |
Pixel Pixel Boolean |
XtDefaultForeground grey75 True |
ADD3DEXT: | |||
highlightColor shadowColor buttonBorderWidth |
Background Background Width |
Pixel Pixel Dimension |
grey90 grey40 2 |
SIMPLE: | |||
cursor cursorName pointerColor pointerColorBackground insensitiveBorder |
Cursor Cursor Foreground Background Insensitive |
Cursor String Pixel Pixel Pixmap |
left_ptr NULL XtDefaultForeground XtDefaultBackground NULL |
ICONLIST: | |||
callback pasteBuffer foreground font internalHeight internalWidth defaultColumns columnSpacing rowSpacing forceColumns verticalList list longest numberStrings iconHeight iconWidth iconDepth |
Callback Boolean Foreground Font Height Width Columns Spacing Spacing Columns Boolean List Longest NumberStrings Height Width Depth |
XtCallbackList Boolean Pixel XFontStruct * Dimension Dimension int Dimension Dimension Boolean Boolean XawIconList[] int int Dimension Dimension Dimension |
NULL False XtDefaultForeground XtDefaultFont 2 4 2 6 4 False False NULL 0 0 0 0 1 |
callback | All functions on this list are called whenever the notify action is invoked. The call_data argument contains information about the element selected and is described in detail in the IconList Callbacks section. |
columnSpacing rowSpacing |
The amount of space, in pixels, between each of the rows and columns in the list. |
defaultColumns | The default number of columns. This value is used when neither the width nor the height of the IconList widget is specified or when forceColumns is True. |
forceColumns | Forces the default number of columns to be used regardless of the IconList widget's current size. |
foreground | A pixel value which indexes the widget's colormap to derive the color used to paint the text of the list elements. |
internalHeight, internalWidth |
The margin, in pixels, between the edges of the list and the corresponding edge of the IconList widget's window. |
list | An array of text strings and icons displayed in the IconList widget. If numberStrings is zero (the default) then the list must be NULL terminated. If a value is not specified for the list, then numberStrings is set to 1, and the name of the widget is used as the list, and longest is set to the length of the name of the widget. The list is used in place, and must be available to the IconList widget for the lifetime of this widget, or until it is changed with XtSetValues() or better with XawIconListChange(). Note that XtSetValues() only works well, if the memory location of the list structure changes. It is a good idea to use always XawIconListChange(). |
longest | Specifies the width, in pixels, of the longest string in the current list. The IconList widget will compute this value if zero (the default) is specified. If this resource is not correctly specified, selection of list items may not work properly. |
numberStrings | The number of strings in the current list. If a value of zero (the default) is specified, the IconList widget will compute it. When computing the number of strings the IconList widget assumes that the list is NULL terminated. |
pasteBuffer | If this resource is set to True then the name of the currently selected list element will be put into CUT_BUFFER_0. |
verticalList | If this resource is set to True then the list elements will be presented in column major order. |
iconHeight, iconWidth |
Set this resources to the width and height of your bitmap or pixmap icons. iconWidth and iconHeight are used to reserve enough space in the list entries. |
iconDepth | Use the value of 1 for traditional XBM bitmap icons or the depth of your pixmaps for color icons like XPMs. |
The IconList widget supports the following actions:
The following is the default translation table used by the IconList Widget:
<Btn1Down>,<Btn1Up> Set(), Notify()
The full list of actions supported by IconList widget is:
Set() | Sets the list element that is currently under the pointer. To inform the user that this element is currently set, it is drawn with is foreground and background colors reversed. If this action is called when there is no list element under the cursor, the currently set element will be unset. |
Unset() | Cancels the set state of the element under the pointer, and redraws it with normal foreground and background colors. |
Notify() | Calls all callbacks on the IconList widget's callback list. Information about the currently selected list element is passed in the call_data argument (see IconList Callback below). |
All procedures on the IconList widget's callback list will have a XawIconListReturnStruct passed to them as call_data. The structure is defined in the IconList widget's application header file.
typedef struct _XawIconListReturnStruct { String string; /* string shown in the list. */ int list_index; /* index of the item selected. */ } XawIconListReturnStruct;
The list_index item used to be called simply index. Unfortunately, this name collided with a global name defined on some operating systems, and had to be changed.
To change the list that is displayed, use XawIconListChange():
void XawIconListChange(w, list, nitems, longest, resize)
Widget w;
XawIconList *list;
int nitems, longest;
int width, height, depth;
Boolean resize;
w Specifies the IconList widget. list Specifies the new list for the IconList widget to display. nitems Specifies the number of items in the list. If a value less than 1 is specified, list must be NULL terminated, and the number of items will be calculated by the IconList widget. longest Specifies the length of the longest item in the list in pixels. If a value less than 1 is specified, the IconList widget will calculate the value. width,
heightSpecifies the width and height of your bitmap or pixmap icons. These values are used to reserve enough space for the icons in the list entries. iconDepth Use the value of 1 for traditional XBM bitmap icons or the depth of your pixmaps for color icons like XPMs. resize Specifies a Boolean value that if True indicates that the IconList widget should try to resize itself after making the change. The constraints of the IconList widget's parent are always enforced, regardless of the value specified here.
An XawIconList entry has the following structure:
typedef struct _XawIconList { Pixmap bitmap; /* the icon, used as left bitmap */ Pixmap clipMask; /* drawing mask for the icon */ String string; /* text for the list entry */ } XawIconList;
bitmap | A bitmap or pixmap displayed left of the string entry. Use XtUnspecifiedPixmap if you don't want to display an icon for a list entry. Use XCreateBitmapFromData() to create a 1 bit depth XBM styled pixmap or XpmCreatePixmapFromData() for XPMs included in your source code. The XPM function returns in addition a clip mask if one of the colors (normally the background color) used in the XPM source is set to None. |
clipMask | A clip mask is used to display nonrectagular icons. If you don't want to use clip masks, set this entry to XtUnspecifiedPixmap. |
string | The string for a list entry. |
To highlight an item in the list, use XawIconListHighlight():
void XawIconListHighlight(w, item)
Widget w;
int item;
w Specifies the IconList widget. item Specifies an index into the current list that indicates the item to be highlighted.
Only one item can be highlighted at a time. If an item is already highlighted when XawIconListHighlight() is called, the highlighted item is unhighlighted before the new item is highlighted.
To unhighlight the currently highlighted item in the list, use XawIconListUnhighlight():
void XawIconListUnhighlight(w)
Widget w;
w Specifies the IconList widget.
To retrieve the list element that is currently set, use XawIconListShowCurrent().
XawIconListReturnStruct *XawIconListShowCurrent(w)
Widget w;
w Specifies the IconList widget.
XawIconListShowCurrent() returns a pointer to an XawIconListReturnStruct structure, containing the currently highlighted item. If the value of the index member is XAW_LIST_NONE, the string member is undefined, and no item is currently selected.