ListBounds1.src 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. XCOMM! CDE_INSTALLATION_TOP/bin/dtksh
  2. XCOMM $XConsortium: ListBounds1.src /main/3 1996/04/23 20:18:16 drk $
  3. XCOMM #########################################################################
  4. XCOMM (c) Copyright 1993, 1994 Hewlett-Packard Company
  5. XCOMM (c) Copyright 1993, 1994 International Business Machines Corp.
  6. XCOMM (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  7. XCOMM (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
  8. XCOMM Novell, Inc.
  9. XCOMM #########################################################################
  10. XCOMM
  11. XCOMM This sample shell script demonstrates how to create a list widget, and
  12. XCOMM also how to query the bounds for each of the list items.
  13. XCOMM
  14. integer i
  15. XCOMM Pushbutton Callback: Query the bound for each list item
  16. GetBounds()
  17. {
  18. i=1
  19. echo
  20. while XmListPosToBounds $LIST $i X Y W H; do
  21. echo "Bounds of item "$i" is ("$X $Y $W $H")"
  22. i=i+1
  23. done
  24. }
  25. XCOMM Pushbutton Callback: Delete the first list item
  26. DelFirst()
  27. {
  28. XmListDeletePos $LIST 1
  29. }
  30. XCOMM ###################### Create the Main UI ###############################
  31. XtInitialize TOPLEVEL listKbd1 ListKbd1 "$0" "$@"
  32. XtSetValues $TOPLEVEL allowShellResize:True
  33. XmCreateScrolledList LIST $TOPLEVEL list \
  34. itemCount:11 \
  35. items:"item1,item2,item3,item4,item5,item6,item7,item8,item9,item10,item11" \
  36. visibleItemCount:15 \
  37. listSizePolicy:VARIABLE
  38. XtSetValues $LIST \
  39. selectedItemCount:3 \
  40. selectedItems:"item2,item4,item6"
  41. XtManageChild $LIST
  42. XtRealizeWidget $TOPLEVEL
  43. XtCreateApplicationShell TOPLEVEL2 listKbd1a TopLevelShell
  44. XtCreateManagedWidget RC rc XmRowColumn $TOPLEVEL2 \
  45. orientation:HORIZONTAL \
  46. numColumns:2 \
  47. packing:PACK_COLUMN
  48. XtCreateManagedWidget PB1 pb1 XmPushButton $RC \
  49. labelString:"Get Item Bounds"
  50. XtAddCallback $PB1 activateCallback "GetBounds"
  51. XtCreateManagedWidget PB2 pb2 XmPushButton $RC \
  52. labelString:"Delete First Item"
  53. XtAddCallback $PB2 activateCallback "DelFirst"
  54. XtRealizeWidget $TOPLEVEL2
  55. XtMainLoop