MkScroll.tcl 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. # -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
  2. #
  3. # $Id: MkScroll.tcl,v 1.3 2001/12/09 05:34:59 idiscovery Exp $
  4. #
  5. # MkScroll.tcl --
  6. #
  7. # This file implements the "Scrolled Widgets" page in the widget demo
  8. #
  9. # This file has not been properly documented. It is NOT intended
  10. # to be used as an introductory demo program about Tix
  11. # programming. For such demos, please see the files in the
  12. # demos/samples directory or go to the "Samples" page in the
  13. # "widget demo"
  14. #
  15. #
  16. # Copyright (c) 1996, Expert Interface Technologies
  17. #
  18. # See the file "license.terms" for information on usage and redistribution
  19. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  20. #
  21. proc MkScroll {nb page} {
  22. set w [$nb subwidget $page]
  23. set name [tixOptionName $w]
  24. option add *$name*TixLabelFrame*label.padX 4
  25. tixLabelFrame $w.sls -label "tixScrolledListBox"
  26. tixLabelFrame $w.swn -label "tixScrolledWindow"
  27. tixLabelFrame $w.stx -label "tixScrolledText"
  28. MkSList [$w.sls subwidget frame]
  29. MkSText [$w.stx subwidget frame]
  30. MkSWindow [$w.swn subwidget frame]
  31. tixForm $w.sls -top 0 -left 0 -right %33 -bottom -1
  32. tixForm $w.swn -top 0 -left $w.sls -right %66 -bottom -1
  33. tixForm $w.stx -top 0 -left $w.swn -right -1 -bottom -1
  34. }
  35. #----------------------------------------------------------------------
  36. # ScrolledListBox
  37. #----------------------------------------------------------------------
  38. proc MkSList {w} {
  39. frame $w.top -width 300 -height 330
  40. frame $w.bot
  41. message $w.top.msg \
  42. -relief flat -width 200 -anchor n\
  43. -text {This TixScrolledListBox is configured so that it uses\
  44. scrollbars only when it is necessary. Use the handles to\
  45. resize the listbox and watch the scrollbars automatically\
  46. appear and disappear.}
  47. set list [tixScrolledListBox $w.top.list -scrollbar auto]
  48. place $list -x 50 -y 150 -width 120 -height 80
  49. $list subwidget listbox insert end Alabama
  50. $list subwidget listbox insert end California
  51. $list subwidget listbox insert end Montana
  52. $list subwidget listbox insert end "New Jersy"
  53. $list subwidget listbox insert end "New York"
  54. $list subwidget listbox insert end Pennsylvania
  55. $list subwidget listbox insert end Washington
  56. set rh [tixResizeHandle $w.top.r -relief raised \
  57. -handlesize 8 -gridded true -minwidth 50 -minheight 30]
  58. button $w.bot.btn -text Reset -command "SList:Reset $rh $list"
  59. pack propagate $w.top 0
  60. pack $w.top.msg -fill x
  61. pack $w.bot.btn -anchor c
  62. pack $w.top -expand yes -fill both
  63. pack $w.bot -fill both
  64. bind $list <Map> "tixDoWhenIdle $rh attachwidget $list"
  65. }
  66. proc SList:Reset {rh list} {
  67. place $list -x 50 -y 150 -width 120 -height 80
  68. update
  69. $rh attachwidget $list
  70. }
  71. #----------------------------------------------------------------------
  72. # ScrolledWindow
  73. #----------------------------------------------------------------------
  74. proc MkSWindow {w} {
  75. global demo_dir
  76. frame $w.top -width 330 -height 330
  77. frame $w.bot
  78. message $w.top.msg \
  79. -relief flat -width 200 -anchor n\
  80. -text {The TixScrolledWindow widget allows you\
  81. to scroll any kind of TK widget. It is more versatile\
  82. than a scrolled canvas widget}
  83. set win [tixScrolledWindow $w.top.win -scrollbar auto]
  84. set f [$win subwidget window]
  85. set image [image create photo -file $demo_dir/bitmaps/tix.gif]
  86. label $f.b1 -image $image
  87. pack $f.b1 -expand yes -fill both
  88. place $win -x 30 -y 150 -width 190 -height 120
  89. set rh [tixResizeHandle $w.top.r -relief raised \
  90. -handlesize 8 -gridded true -minwidth 50 -minheight 30]
  91. button $w.bot.btn -text Reset -command "SWindow:Reset $rh $win"
  92. pack propagate $w.top 0
  93. pack $w.top.msg -fill x
  94. pack $w.bot.btn -anchor c
  95. pack $w.top -expand yes -fill both
  96. pack $w.bot -fill both
  97. bind $win <Map> "tixDoWhenIdle $rh attachwidget $win"
  98. }
  99. proc SWindow:Reset {rh win} {
  100. place $win -x 30 -y 150 -width 190 -height 120
  101. update
  102. $rh attachwidget $win
  103. }
  104. #----------------------------------------------------------------------
  105. # ScrolledText
  106. #----------------------------------------------------------------------
  107. proc MkSText {w} {
  108. frame $w.top -width 330 -height 330
  109. frame $w.bot
  110. message $w.top.msg \
  111. -relief flat -width 200 -anchor n\
  112. -text {The TixScrolledWindow widget allows you\
  113. to scroll any kind of TK widget. It is more versatile\
  114. than a scrolled canvas widget}
  115. set win [tixScrolledText $w.top.win -scrollbar both]
  116. $win subwidget text config -wrap none
  117. place $win -x 30 -y 150 -width 190 -height 100
  118. set rh [tixResizeHandle $w.top.r -relief raised \
  119. -handlesize 8 -gridded true -minwidth 50 -minheight 30]
  120. button $w.bot.btn -text Reset -command "SText:Reset $rh $win"
  121. pack propagate $w.top 0
  122. pack $w.top.msg -fill x
  123. pack $w.bot.btn -anchor c
  124. pack $w.top -expand yes -fill both
  125. pack $w.bot -fill both
  126. bind $win <Map> "tixDoWhenIdle $rh attachwidget $win"
  127. }
  128. proc SText:Reset {rh win} {
  129. place $win -x 30 -y 150 -width 190 -height 100
  130. update
  131. $rh attachwidget $win
  132. }