home *** CD-ROM | disk | FTP | other *** search
/ Freelog Special Freeware 31 / FreelogHS31.iso / Texte / scribus / scribus-1.3.3.9-win32-install.exe / tcl / tix8.1 / BtnBox.tcl < prev    next >
Text File  |  2001-11-03  |  3KB  |  121 lines

  1. # -*- mode: TCL; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
  2. #
  3. #    $Id: BtnBox.tcl,v 1.1.1.1.2.1 2001/11/03 06:43:50 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.  
  16. tixWidgetClass tixButtonBox {
  17.     -superclass tixPrimitive
  18.     -classname  TixButtonBox
  19.     -method {
  20.     add invoke button buttons
  21.     }
  22.     -flag {
  23.     -orientation -orient -padx -pady -state
  24.     }
  25.     -static {
  26.     -orientation
  27.     }
  28.     -configspec {
  29.     {-orientation orientation Orientation horizontal}
  30.     {-padx padX Pad 0}
  31.     {-pady padY Pad 0}
  32.     {-state state State normal}
  33.     }
  34.     -alias {
  35.     {-orient -orientation}
  36.     }
  37.     -default {
  38.     {.borderWidth         1}
  39.     {.relief         raised}
  40.     {.padX             5}
  41.     {.padY             10}
  42.     {*Button.anchor        c}
  43.     {*Button.padX        5}
  44.     }
  45. }
  46.  
  47. proc tixButtonBox:InitWidgetRec {w} {
  48.     upvar #0 $w data
  49.  
  50.     tixChainMethod $w InitWidgetRec
  51.  
  52.     set data(g:buttons) ""
  53. }
  54.  
  55. #----------------------------------------------------------------------
  56. #                           CONFIG OPTIONS
  57. #----------------------------------------------------------------------
  58. proc tixButtonBox:config-padx {w arg} {
  59.     upvar #0 $w data
  60.  
  61.     foreach item $data(g:buttons) {
  62.     pack configure $w.$item -padx $arg
  63.     }
  64. }
  65.  
  66. proc tixButtonBox:config-pady {w arg} {
  67.     upvar #0 $w data
  68.  
  69.     foreach item $data(g:buttons) {
  70.     pack configure $w.$item -pady $arg
  71.     }
  72. }
  73.  
  74. proc tixButtonBox:config-state {w arg} {
  75.     upvar #0 $w data
  76.  
  77.     foreach item $data(g:buttons) {
  78.     $w.$item config -state $arg
  79.     }
  80. }
  81.  
  82. #----------------------------------------------------------------------
  83. # Methods
  84. #                     WIDGET COMMANDS
  85. #----------------------------------------------------------------------
  86. proc tixButtonBox:add {w name args} {
  87.     upvar #0 $w data
  88.  
  89.     eval button $w.$name $args
  90.     if {$data(-orientation) == "horizontal"} {
  91.     pack $w.$name -side left -expand yes -fill y\
  92.         -padx $data(-padx) -pady $data(-pady)
  93.     } else {
  94.     pack $w.$name -side top -expand yes  -fill x\
  95.         -padx $data(-padx) -pady $data(-pady)
  96.     }
  97.  
  98.     # allow for subwidget access
  99.     #
  100.     lappend data(g:buttons) $name
  101.     set data(w:$name) $w.$name
  102.  
  103.     return $w.$name
  104. }
  105.  
  106. proc tixButtonBox:button {w name args} {
  107.     return [eval tixCallMethod $w subwidget $name $args]
  108. }
  109.  
  110. proc tixButtonBox:buttons {w args} {
  111.     return [eval tixCallMethod $w subwidgets -group buttons $args]
  112. }
  113.  
  114. #
  115. # call the command
  116. proc tixButtonBox:invoke {w name} {
  117.     upvar #0 $w data
  118.  
  119.     $w.$name invoke
  120. }
  121.