convert all Imakefile LinuxDistribution to LinuxArchitecture.
[oweals/cde.git] / cde / programs / dtksh / examples / ListPosSel1.src
1 XCOMM! CDE_INSTALLATION_TOP/bin/dtksh
2 XCOMM  $XConsortium: ListPosSel1.src /main/3 1996/04/23 20:18:25 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  also verifies that the XmListPosSelected command works; this command
16 XCOMM  returns information about whether an indicated list item is selected.
17 XCOMM 
18
19 integer i
20
21 XCOMM  Pushbutton Callback: print the selection state of each list item.
22 GetSelectionStatus()
23 {
24    i=1
25    echo
26    while (($i <= 11 )); do
27       if XmListPosSelected $LIST $i; then
28          echo "Item "$i" is selected"
29       else
30          echo "Item "$i" is not selected"
31       fi
32       i=i+1
33    done
34 }
35
36 XCOMM ###################### Create the Main UI ###############################
37
38 XtInitialize TOPLEVEL listPosSel1 ListPosSel1 "$0" "$@"
39 XtSetValues $TOPLEVEL allowShellResize:True
40
41 XmCreateScrolledList LIST $TOPLEVEL list \
42         itemCount:11 \
43         items:"item1,item2,item3,item4,item5,item6,item7,item8,item9,item10,item11" \
44         visibleItemCount:15 \
45         listSizePolicy:VARIABLE
46 XtSetValues $LIST \
47         selectedItemCount:3 \
48         selectedItems:"item2,item4,item6"
49 XtManageChild $LIST
50
51 XtRealizeWidget $TOPLEVEL
52
53 XtCreateApplicationShell TOPLEVEL2 ListPosSel1a TopLevelShell
54
55 XtCreateManagedWidget RC rc XmRowColumn $TOPLEVEL2 \
56          orientation:HORIZONTAL \
57          numColumns:2 \
58          packing:PACK_COLUMN 
59
60 XtCreateManagedWidget PB1 pb1 XmPushButton $RC \
61         labelString:"Get Item Selection Status"
62 XtAddCallback $PB1 activateCallback "GetSelectionStatus"
63
64 XtRealizeWidget $TOPLEVEL2
65
66 XtMainLoop