convert all Imakefile LinuxDistribution to LinuxArchitecture.
[oweals/cde.git] / cde / programs / dtksh / examples / ListItemPos1.src
1 XCOMM! CDE_INSTALLATION_TOP/bin/dtksh
2 XCOMM  $XConsortium: ListItemPos1.src /main/3 1996/04/23 20:18:21 drk $
3
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
9 XCOMM       Novell, Inc.
10 XCOMM #########################################################################
11
12
13 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".
21 XCOMM 
22
23 XCOMM  Pushbutton Callback: prints the position occupied by the first occurrence
24 XCOMM                       of the "item4" label.
25 GetItemPosition()
26 {
27    XmListItemPos POS $LIST "item4"
28    echo "First position for item4 is: "$POS
29 }
30
31 XCOMM  Pushbutton Callback: deletes the first item in the list.
32 DelFirstItem()
33 {
34    XmListDeletePos $LIST 1
35 }
36
37 XCOMM ###################### Create the Main UI ###############################
38
39 XtInitialize TOPLEVEL listItemPos1 ListItemPos1 "$0" "$@"
40 XtSetValues $TOPLEVEL allowShellResize:True
41
42 XmCreateScrolledList LIST $TOPLEVEL list \
43         itemCount:11 \
44         items:"item4,item2,item4,item3,item5,item6,item7,item8,item9,item4,item11" \
45         visibleItemCount:15 \
46         listSizePolicy:VARIABLE
47 XtSetValues $LIST \
48         selectedItemCount:3 \
49         selectedItems:"item2,item4,item6"
50 XtManageChild $LIST
51
52 XtRealizeWidget $TOPLEVEL
53
54 XtCreateApplicationShell TOPLEVEL2 ListItemPos1a TopLevelShell
55
56 XtCreateManagedWidget RC rc XmRowColumn $TOPLEVEL2 \
57          orientation:HORIZONTAL \
58          numColumns:2 \
59          packing:PACK_COLUMN 
60
61 XtCreateManagedWidget PB1 pb1 XmPushButton $RC \
62         labelString:"Get Position Of item4"
63 XtAddCallback $PB1 activateCallback "GetItemPosition"
64
65 XtCreateManagedWidget PB2 pb2 XmPushButton $RC \
66         labelString:"Delete First Item"
67 XtAddCallback $PB2 activateCallback "DelFirstItem"
68
69 XtRealizeWidget $TOPLEVEL2
70
71 XtMainLoop