1 XCOMM! CDE_INSTALLATION_TOP/bin/dtksh
2 XCOMM $XConsortium: ListItemPos1.src /main/3 1996/04/23 20:18:21 drk $
4 XCOMM #########################################################################
5 XCOMM (c) Copyright 1993, 1994 Hewlett-Packard Company
6 XCOMM (c) Copyright 1993, 1994 International Business Machines Corp.
7 XCOMM (c) Copyright 1993, 1994 Sun Microsystems, Inc.
8 XCOMM (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
10 XCOMM #########################################################################
14 XCOMM This sample shell script demonstrates how to create a list widget, and
15 XCOMM verifies that the XmListItemPos command operates correctly. The list
16 XCOMM contains multiple items with the label "item4"; XmListItemPos will
17 XCOMM return the position of the first occurrence. By selecting the push
18 XCOMM button labeled "Delete First Item", you can delete the first item
19 XCOMM labeled "item4"; the next call to XmListItemPos should now return
20 XCOMM the position of the next item labeled "item4".
23 XCOMM Pushbutton Callback: prints the position occupied by the first occurrence
24 XCOMM of the "item4" label.
27 XmListItemPos POS $LIST "item4"
28 echo "First position for item4 is: "$POS
31 XCOMM Pushbutton Callback: deletes the first item in the list.
34 XmListDeletePos $LIST 1
37 XCOMM ###################### Create the Main UI ###############################
39 XtInitialize TOPLEVEL listItemPos1 ListItemPos1 "$0" "$@"
40 XtSetValues $TOPLEVEL allowShellResize:True
42 XmCreateScrolledList LIST $TOPLEVEL list \
44 items:"item4,item2,item4,item3,item5,item6,item7,item8,item9,item4,item11" \
46 listSizePolicy:VARIABLE
49 selectedItems:"item2,item4,item6"
52 XtRealizeWidget $TOPLEVEL
54 XtCreateApplicationShell TOPLEVEL2 ListItemPos1a TopLevelShell
56 XtCreateManagedWidget RC rc XmRowColumn $TOPLEVEL2 \
57 orientation:HORIZONTAL \
61 XtCreateManagedWidget PB1 pb1 XmPushButton $RC \
62 labelString:"Get Position Of item4"
63 XtAddCallback $PB1 activateCallback "GetItemPosition"
65 XtCreateManagedWidget PB2 pb2 XmPushButton $RC \
66 labelString:"Delete First Item"
67 XtAddCallback $PB2 activateCallback "DelFirstItem"
69 XtRealizeWidget $TOPLEVEL2