ListNBk.tcl 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. # -*- mode: TCL; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
  2. #
  3. # $Id: ListNBk.tcl,v 1.5 2004/03/28 02:44:57 hobbs Exp $
  4. #
  5. # ListNBk.tcl --
  6. #
  7. # "List NoteBook" widget. Acts similarly to the notebook but uses a
  8. # HList widget to represent the pages.
  9. #
  10. # Copyright (c) 1993-1999 Ioi Kim Lam.
  11. # Copyright (c) 2000-2001 Tix Project Group.
  12. # Copyright (c) 2004 ActiveState
  13. #
  14. # See the file "license.terms" for information on usage and redistribution
  15. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  16. #
  17. tixWidgetClass tixListNoteBook {
  18. -classname TixListNoteBook
  19. -superclass tixVStack
  20. -method {
  21. }
  22. -flag {
  23. -height -width
  24. }
  25. -configspec {
  26. {-width width Width 0}
  27. {-height height Height 0}
  28. }
  29. -forcecall {
  30. -dynamicgeometry -width -height
  31. }
  32. -default {
  33. {*Orientation horizontal}
  34. }
  35. }
  36. proc tixListNoteBook:ConstructWidget {w} {
  37. upvar #0 $w data
  38. tixChainMethod $w ConstructWidget
  39. set data(w_pane) [tixPanedWindow $w.pane -panerelief flat]
  40. set p1 [$data(w_pane) add p1 -expand 0]
  41. set p2 [$data(w_pane) add p2 -expand 1]
  42. set data(w_p2) $p2
  43. set data(w:shlist) [tixScrolledHList $p1.shlist]
  44. set data(w:hlist) [$data(w:shlist) subwidget hlist]
  45. if {[$data(w_pane) cget -orientation] eq "vertical"} {
  46. pack $data(w:shlist) -expand yes -fill both -padx 2 -pady 3
  47. } else {
  48. pack $data(w:shlist) -expand yes -fill both -padx 3 -pady 2
  49. }
  50. $data(w:hlist) config \
  51. -command [list tixListNoteBook:Choose $w] \
  52. -browsecmd [list tixListNoteBook:Choose $w] \
  53. -selectmode single
  54. pack $data(w_pane) -expand yes -fill both
  55. }
  56. proc tixListNoteBook:add {w child args} {
  57. upvar #0 $w data
  58. if {[string match *.* $child]} {
  59. error "the name of the page cannot contain the \".\" character"
  60. }
  61. return [eval tixChainMethod $w add $child $args]
  62. }
  63. #----------------------------------------------------------------------
  64. # Virtual Methods
  65. #----------------------------------------------------------------------
  66. proc tixListNoteBook:InitGeometryManager {w} {
  67. tixWidgetDoWhenIdle tixListNoteBook:InitialRaise $w
  68. }
  69. proc tixListNoteBook:InitialRaise {w} {
  70. upvar #0 $w data
  71. if {$data(topchild) eq ""} {
  72. set top [lindex $data(windows) 0]
  73. } else {
  74. set top $data(topchild)
  75. }
  76. if {$top ne ""} {
  77. tixCallMethod $w raise $top
  78. }
  79. }
  80. proc tixListNoteBook:CreateChildFrame {w child} {
  81. upvar #0 $w data
  82. return [frame $data(w_p2).$child]
  83. }
  84. proc tixListNoteBook:RaiseChildFrame {w child} {
  85. upvar #0 $w data
  86. if {$data(topchild) ne $child} {
  87. if {$data(topchild) ne ""} {
  88. pack forget $data(w:$data(topchild))
  89. }
  90. pack $data(w:$child) -expand yes -fill both
  91. }
  92. }
  93. #
  94. #----------------------------------------------------------------------
  95. #
  96. proc tixListNoteBook:config-dynamicgeometry {w value} {
  97. upvar #0 $w data
  98. $data(w_pane) config -dynamicgeometry $value
  99. }
  100. proc tixListNoteBook:config-width {w value} {
  101. upvar #0 $w data
  102. if {$value != 0} {
  103. $data(w_pane) config -width $value
  104. }
  105. }
  106. proc tixListNoteBook:config-height {w value} {
  107. upvar #0 $w data
  108. if {$value != 0} {
  109. $data(w_pane) config -height $value
  110. }
  111. }
  112. proc tixListNoteBook:raise {w child} {
  113. upvar #0 $w data
  114. $data(w:hlist) selection clear
  115. $data(w:hlist) selection set $child
  116. $data(w:hlist) anchor set $child
  117. tixChainMethod $w raise $child
  118. }
  119. proc tixListNoteBook:Choose {w args} {
  120. upvar #0 $w data
  121. set entry [tixEvent flag V]
  122. if {[lsearch $data(windows) $entry] != -1} {
  123. tixCallMethod $w raise $entry
  124. }
  125. }