convert all Imakefile LinuxDistribution to LinuxArchitecture.
[oweals/cde.git] / cde / programs / dtksh / examples / ListBounds1.src
1 XCOMM! CDE_INSTALLATION_TOP/bin/dtksh
2 XCOMM  $XConsortium: ListBounds1.src /main/3 1996/04/23 20:18:16 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 how to query the bounds for each of the list items.
16 XCOMM 
17
18 integer i
19
20 XCOMM  Pushbutton Callback: Query the bound for each list item
21 GetBounds()
22 {
23    i=1
24    echo
25    while XmListPosToBounds $LIST $i X Y W H; do
26       echo "Bounds of item "$i" is ("$X $Y $W $H")"
27       i=i+1
28    done
29 }
30
31 XCOMM  Pushbutton Callback: Delete the first list item
32 DelFirst()
33 {
34    XmListDeletePos $LIST 1
35 }
36
37 XCOMM ###################### Create the Main UI ###############################
38
39 XtInitialize TOPLEVEL listKbd1 ListKbd1 "$0" "$@"
40 XtSetValues $TOPLEVEL allowShellResize:True
41
42 XmCreateScrolledList LIST $TOPLEVEL list \
43         itemCount:11 \
44         items:"item1,item2,item3,item4,item5,item6,item7,item8,item9,item10,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 listKbd1a 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 Item Bounds"
63 XtAddCallback $PB1 activateCallback "GetBounds"
64
65 XtCreateManagedWidget PB2 pb2 XmPushButton $RC \
66         labelString:"Delete First Item"
67 XtAddCallback $PB2 activateCallback "DelFirst"
68
69 XtRealizeWidget $TOPLEVEL2
70
71 XtMainLoop