BtnBox.tcl 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. # -*- mode: TCL; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
  2. #
  3. # $Id: BtnBox.tcl,v 1.2 2001/12/09 05:04:02 idiscovery Exp $
  4. #
  5. # BtnBox.tcl --
  6. #
  7. # Implements the tixButtonBox widget
  8. #
  9. # Copyright (c) 1993-1999 Ioi Kim Lam.
  10. # Copyright (c) 2000-2001 Tix Project Group.
  11. #
  12. # See the file "license.terms" for information on usage and redistribution
  13. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  14. #
  15. tixWidgetClass tixButtonBox {
  16. -superclass tixPrimitive
  17. -classname TixButtonBox
  18. -method {
  19. add invoke button buttons
  20. }
  21. -flag {
  22. -orientation -orient -padx -pady -state
  23. }
  24. -static {
  25. -orientation
  26. }
  27. -configspec {
  28. {-orientation orientation Orientation horizontal}
  29. {-padx padX Pad 0}
  30. {-pady padY Pad 0}
  31. {-state state State normal}
  32. }
  33. -alias {
  34. {-orient -orientation}
  35. }
  36. -default {
  37. {.borderWidth 1}
  38. {.relief raised}
  39. {.padX 5}
  40. {.padY 10}
  41. {*Button.anchor c}
  42. {*Button.padX 5}
  43. }
  44. }
  45. proc tixButtonBox:InitWidgetRec {w} {
  46. upvar #0 $w data
  47. tixChainMethod $w InitWidgetRec
  48. set data(g:buttons) ""
  49. }
  50. #----------------------------------------------------------------------
  51. # CONFIG OPTIONS
  52. #----------------------------------------------------------------------
  53. proc tixButtonBox:config-padx {w arg} {
  54. upvar #0 $w data
  55. foreach item $data(g:buttons) {
  56. pack configure $w.$item -padx $arg
  57. }
  58. }
  59. proc tixButtonBox:config-pady {w arg} {
  60. upvar #0 $w data
  61. foreach item $data(g:buttons) {
  62. pack configure $w.$item -pady $arg
  63. }
  64. }
  65. proc tixButtonBox:config-state {w arg} {
  66. upvar #0 $w data
  67. foreach item $data(g:buttons) {
  68. $w.$item config -state $arg
  69. }
  70. }
  71. #----------------------------------------------------------------------
  72. # Methods
  73. # WIDGET COMMANDS
  74. #----------------------------------------------------------------------
  75. proc tixButtonBox:add {w name args} {
  76. upvar #0 $w data
  77. eval button $w.$name $args
  78. if {$data(-orientation) == "horizontal"} {
  79. pack $w.$name -side left -expand yes -fill y\
  80. -padx $data(-padx) -pady $data(-pady)
  81. } else {
  82. pack $w.$name -side top -expand yes -fill x\
  83. -padx $data(-padx) -pady $data(-pady)
  84. }
  85. # allow for subwidget access
  86. #
  87. lappend data(g:buttons) $name
  88. set data(w:$name) $w.$name
  89. return $w.$name
  90. }
  91. proc tixButtonBox:button {w name args} {
  92. return [eval tixCallMethod $w subwidget $name $args]
  93. }
  94. proc tixButtonBox:buttons {w args} {
  95. return [eval tixCallMethod $w subwidgets -group buttons $args]
  96. }
  97. #
  98. # call the command
  99. proc tixButtonBox:invoke {w name} {
  100. upvar #0 $w data
  101. $w.$name invoke
  102. }