gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

202 lines
4.7KB

  1. # -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
  2. #
  3. # $Id: AllSampl.tcl,v 1.4 2001/12/09 05:31:07 idiscovery Exp $
  4. #
  5. # AllSampl.tcl --
  6. #
  7. # This file is a directory of all the sample programs in the
  8. # demos/samples subdirectory.
  9. #
  10. #
  11. # Copyright (c) 1996, Expert Interface Technologies
  12. #
  13. # See the file "license.terms" for information on usage and redistribution
  14. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  15. #
  16. #
  17. # The following data structures contains information about the requirements
  18. # of the sample programs, as well as the relationship/grouping of the sample
  19. # programs.
  20. #
  21. # Each element in an info list has four parts: type, name, group/filename, and
  22. # condition. A group or a file is loaded only if the conditions are met.
  23. #
  24. # types: "d" directory "f" file
  25. # conditions:
  26. # "i": an image type must exist
  27. # "c": a command must exist
  28. # "v": a variable must exist
  29. set root {
  30. {d "File Selectors" file }
  31. {d "Hierachical ListBox" hlist }
  32. {d "Tabular ListBox" tlist {c tixTList}}
  33. {d "Grid Widget" grid {c tixGrid}}
  34. {d "Manager Widgets" manager }
  35. {d "Scrolled Widgets" scroll }
  36. {d "Miscellaneous Widgets" misc }
  37. {d "Image Types" image }
  38. }
  39. set image {
  40. {d "Compound Image" cmpimg }
  41. {d "XPM Image" xpm {i pixmap}}
  42. }
  43. set cmpimg {
  44. {f "In Buttons" CmpImg.tcl }
  45. {f "In NoteBook" CmpImg2.tcl }
  46. {f "Notebook Color Tabs" CmpImg4.tcl }
  47. {f "Icons" CmpImg3.tcl }
  48. }
  49. set xpm {
  50. {f "In Button" Xpm.tcl {i pixmap}}
  51. {f "In Menu" Xpm1.tcl {i pixmap}}
  52. }
  53. set file {
  54. {f DirList DirList.tcl }
  55. {f DirTree DirTree.tcl }
  56. {f DirSelectDialog DirDlg.tcl }
  57. {f ExFileSelectDialog EFileDlg.tcl }
  58. {f FileSelectDialog FileDlg.tcl }
  59. {f FileEntry FileEnt.tcl }
  60. }
  61. set hlist {
  62. {f HList HList1.tcl }
  63. {f CheckList ChkList.tcl {c tixCheckList}}
  64. {f "ScrolledHList (1)" SHList.tcl }
  65. {f "ScrolledHList (2)" SHList2.tcl }
  66. {f Tree Tree.tcl }
  67. {f "Tree (Dynamic)" DynTree.tcl {v win}}
  68. }
  69. set tlist {
  70. {f "ScrolledTList (1)" STList1.tcl {c tixTList}}
  71. {f "ScrolledTList (2)" STList2.tcl {c tixTList}}
  72. }
  73. global tcl_platform
  74. # This demo hangs windows
  75. if {$tcl_platform(platform) != "windows"} {
  76. lappend tlist {f "TList File Viewer" STList3.tcl {c tixTList}}
  77. }
  78. set grid {
  79. {f "Simple Grid" SGrid0.tcl {c tixGrid}}
  80. {f "ScrolledGrid" SGrid1.tcl {c tixGrid}}
  81. {f "Editable Grid" EditGrid.tcl {c tixGrid}}
  82. }
  83. set scroll {
  84. {f ScrolledListBox SListBox.tcl }
  85. {f ScrolledText SText.tcl }
  86. {f ScrolledWindow SWindow.tcl }
  87. {f "Canvas Object View" CObjView.tcl {c tixCObjView}}
  88. }
  89. set manager {
  90. {f ListNoteBook ListNBK.tcl }
  91. {f NoteBook NoteBook.tcl }
  92. {f PanedWindow PanedWin.tcl }
  93. }
  94. set misc {
  95. {f Balloon Balloon.tcl }
  96. {f ButtonBox BtnBox.tcl }
  97. {f ComboBox ComboBox.tcl }
  98. {f Control Control.tcl }
  99. {f LabelEntry LabEntry.tcl }
  100. {f LabelFrame LabFrame.tcl }
  101. {f Meter Meter.tcl {c tixMeter}}
  102. {f OptionMenu OptMenu.tcl }
  103. {f PopupMenu PopMenu.tcl }
  104. {f Select Select.tcl }
  105. {f StdButtonBox StdBBox.tcl }
  106. }
  107. # ForAllSamples --
  108. #
  109. # Iterates over all the samples that can be run on this platform.
  110. #
  111. # Arguments:
  112. # name: For outside callers, it must be "root"
  113. # token: An arbtrary string passed in by the caller.
  114. # command: Command prefix to be executed for each node
  115. # in the samples hierarchy. It should return the
  116. # token of the node that it has just created, if any.
  117. #
  118. proc ForAllSamples {name token command} {
  119. global $name win
  120. if {[tix platform] == "windows"} {
  121. set win 1
  122. }
  123. foreach line [set $name] {
  124. set type [lindex $line 0]
  125. set text [lindex $line 1]
  126. set dest [lindex $line 2]
  127. set cond [lindex $line 3]
  128. case [lindex $cond 0] {
  129. c {
  130. set cmd [lindex $cond 1]
  131. if {[info command $cmd] != $cmd} {
  132. if ![auto_load $cmd] {
  133. continue
  134. }
  135. }
  136. }
  137. i {
  138. if {[lsearch [image types] [lindex $cond 1]] == -1} {
  139. continue
  140. }
  141. }
  142. v {
  143. set doit 1
  144. foreach var [lrange $cond 1 end] {
  145. if [uplevel #0 info exists [list $var]] {
  146. set doit 0
  147. break
  148. }
  149. }
  150. if !$doit {
  151. continue
  152. }
  153. }
  154. }
  155. if {$type == "d"} {
  156. set tok [eval $command [list $token] $type [list $text] \
  157. [list $dest]]
  158. ForAllSamples $dest $tok $command
  159. eval $command [list $tok] done xx xx
  160. } else {
  161. set tok [eval $command [list $token] $type [list $text] \
  162. [list $dest]]
  163. }
  164. }
  165. }
  166. proc DoAll {hlist {path ""}} {
  167. catch {
  168. set theSample [$hlist info data $path]
  169. if {$theSample != {}} {
  170. set title [lindex $theSample 0]
  171. set prog [lindex $theSample 1]
  172. RunProg $title $prog
  173. update
  174. }
  175. }
  176. foreach p [$hlist info children $path] {
  177. DoAll $hlist $p
  178. }
  179. }
上海开阖软件有限公司 沪ICP备12045867号-1