TextDisp1.src 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. XCOMM! CDE_INSTALLATION_TOP/bin/dtksh
  2. XCOMM $XConsortium: TextDisp1.src /main/3 1996/04/23 20:18:56 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 exercises the commands which enable and disable
  12. XCOMM updating in a text widget. If the update is disabled, and the value of
  13. XCOMM the text field is then changed, the text field will not update what is
  14. XCOMM shown, until update is again enabled.
  15. XCOMM
  16. XCOMM Pushbutton Callback: enable update in the text widget
  17. EnableUpdate()
  18. {
  19. XmTextEnableRedisplay $TEXT
  20. }
  21. XCOMM Pushbutton Callback: disable update in the text widget
  22. DisableUpdate()
  23. {
  24. XmTextDisableRedisplay $TEXT
  25. }
  26. XCOMM Pushbutton Callback: changes the text value
  27. ChangeValue1()
  28. {
  29. XmTextSetString $TEXT "line A
  30. line B
  31. line C
  32. line D
  33. line E
  34. line F
  35. line G"
  36. }
  37. XCOMM Pushbutton Callback: changes the text value
  38. ChangeValue2()
  39. {
  40. XmTextSetString $TEXT "line a
  41. line b
  42. line c
  43. line d
  44. line e
  45. line f
  46. line g"
  47. }
  48. XCOMM ###################### Create the Main UI ###############################
  49. XtInitialize TOPLEVEL textDisp1 TextDisp1 "$0" "$@"
  50. XtSetValues $TOPLEVEL allowShellResize:True
  51. XmCreateScrolledText TEXT $TOPLEVEL text \
  52. columns:20 \
  53. rows:5 \
  54. editMode:MULTI_LINE_EDIT \
  55. value:\
  56. "line 1
  57. line 2
  58. line 3
  59. line 4"
  60. XtManageChild $TEXT
  61. XtRealizeWidget $TOPLEVEL
  62. XtCreateApplicationShell TOPLEVEL2 textDisp1a TopLevelShell
  63. XtCreateManagedWidget RC rc XmRowColumn $TOPLEVEL2 \
  64. orientation:HORIZONTAL \
  65. numColumns:2 \
  66. packing:PACK_COLUMN
  67. XtCreateManagedWidget PB1 pb1 XmPushButton $RC \
  68. labelString:"Disable Update"
  69. XtAddCallback $PB1 activateCallback "DisableUpdate"
  70. XtCreateManagedWidget PB2 pb2 XmPushButton $RC \
  71. labelString:"Enable Update"
  72. XtAddCallback $PB2 activateCallback "EnableUpdate"
  73. XtCreateManagedWidget PB3 pb3 XmPushButton $RC \
  74. labelString:"Change Value 1"
  75. XtAddCallback $PB3 activateCallback "ChangeValue1"
  76. XtCreateManagedWidget PB4 pb4 XmPushButton $RC \
  77. labelString:"Change Value 2"
  78. XtAddCallback $PB4 activateCallback "ChangeValue2"
  79. XtRealizeWidget $TOPLEVEL2
  80. XtMainLoop