home *** CD-ROM | disk | FTP | other *** search
/ Freesoft 1999 February / Freesoft_1999-02_cd.bin / Recenz / Utility / DisplayDoctorLinux / scitech-display-doctor-1.0beta-3.i386.rpm / scitech-display-doctor-1.0beta.3.cpio.gz / scitech-display-doctor-1.0beta.3.cpio / usr / lib / nucleus / XF86Setup / tcllib / optionMenu.tcl < prev    next >
Text File  |  1998-09-19  |  2KB  |  54 lines

  1. # $XConsortium: optionMenu.tcl /main/1 1996/09/21 14:15:53 kaleb $
  2. #
  3. #
  4. #
  5. #
  6. # $XFree86: xc/programs/Xserver/hw/xfree86/XF86Setup/tcllib/optionMenu.tcl,v 3.1 1996/12/27 06:55:02 dawes Exp $
  7. #
  8. # optionMenu.tcl --
  9. #
  10. # This file defines the procedure tk_optionMenu, which creates
  11. # an option button and its associated menu.
  12. #
  13. # @(#) optionMenu.tcl 1.6 95/01/06 11:18:53
  14. #
  15. # Copyright (c) 1994 The Regents of the University of California.
  16. # Copyright (c) 1994 Sun Microsystems, Inc.
  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.  
  22. # tk_optionMenu --
  23. # This procedure creates an option button named $w and an associated
  24. # menu.  Together they provide the functionality of Motif option menus:
  25. # they can be used to select one of many values, and the current value
  26. # appears in the global variable varName, as well as in the text of
  27. # the option menubutton.  The name of the menu is returned as the
  28. # procedure's result, so that the caller can use it to change configuration
  29. # options on the menu or otherwise manipulate it.
  30. #
  31. # Arguments:
  32. # w -            The name to use for the menubutton.
  33. # varName -        Global variable to hold the currently selected value.
  34. # firstValue -        First of legal values for option (must be >= 1).
  35. # args -        Any number of additional values.
  36.  
  37. proc tk_optionMenu {w varName firstValue args} {
  38.     upvar #0 $varName var
  39.  
  40.     if ![info exists var] {
  41.     set var $firstValue
  42.     }
  43.     menubutton $w -textvariable $varName -indicatoron 1 -menu $w.menu \
  44.         -relief raised -bd 2 -padx 4p -pady 4p -highlightthickness 2 \
  45.         -anchor c
  46.     menu $w.menu -tearoff 0
  47.     $w.menu add command -label $firstValue \
  48.         -command [list set $varName $firstValue]
  49.     foreach i $args {
  50.     $w.menu add command -label $i -command [list set $varName $i]
  51.     }
  52.     return $w.menu
  53. }
  54.