home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tkisrc04.zip / lib / tk / tk.tcl < prev   
Text File  |  1998-09-09  |  3KB  |  109 lines

  1. # tk.tcl --
  2. #
  3. # Initialization script normally executed in the interpreter for each
  4. # Tk-based application.  Arranges class bindings for widgets.
  5. #
  6. # SCCS: @(#) tk.tcl 1.81 96/02/16 10:48:13
  7. #
  8. # Copyright (c) 1992-1994 The Regents of the University of California.
  9. # Copyright (c) 1994-1996 Sun Microsystems, Inc.
  10. #
  11. # See the file "license.terms" for information on usage and redistribution
  12. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  13.  
  14. # Insist on running with compatible versions of Tcl and Tk.
  15.  
  16. package require -exact Tk 4.1
  17. package require -exact Tcl 7.5
  18.  
  19. # Add Tk's directory to the end of the auto-load search path, if it
  20. # isn't already on the path:
  21.  
  22. if {[lsearch -exact $auto_path $tk_library] < 0} {
  23.     lappend auto_path $tk_library
  24. }
  25.  
  26. # Turn off strict Motif look and feel as a default.
  27.  
  28. set tk_strictMotif 0
  29.  
  30. # tkScreenChanged --
  31. # This procedure is invoked by the binding mechanism whenever the
  32. # "current" screen is changing.  The procedure does two things.
  33. # First, it uses "upvar" to make global variable "tkPriv" point at an
  34. # array variable that holds state for the current display.  Second,
  35. # it initializes the array if it didn't already exist.
  36. #
  37. # Arguments:
  38. # screen -        The name of the new screen.
  39.  
  40. proc tkScreenChanged screen {
  41.     set disp [file rootname $screen]
  42.     uplevel #0 upvar #0 tkPriv.$disp tkPriv
  43.     global tkPriv
  44.     if [info exists tkPriv] {
  45.     set tkPriv(screen) $screen
  46.     return
  47.     }
  48.     set tkPriv(afterId) {}
  49.     set tkPriv(buttons) 0
  50.     set tkPriv(buttonWindow) {}
  51.     set tkPriv(dragging) 0
  52.     set tkPriv(focus) {}
  53.     set tkPriv(grab) {}
  54.     set tkPriv(initPos) {}
  55.     set tkPriv(inMenubutton) {}
  56.     set tkPriv(listboxPrev) {}
  57.     set tkPriv(mouseMoved) 0
  58.     set tkPriv(oldGrab) {}
  59.     set tkPriv(popup) {}
  60.     set tkPriv(postedMb) {}
  61.     set tkPriv(pressX) 0
  62.     set tkPriv(pressY) 0
  63.     set tkPriv(screen) $screen
  64.     set tkPriv(selectMode) char
  65.     set tkPriv(window) {}
  66. }
  67.  
  68. # Do initial setup for tkPriv, so that it is always bound to something
  69. # (otherwise, if someone references it, it may get set to a non-upvar-ed
  70. # value, which will cause trouble later).
  71.  
  72. tkScreenChanged [winfo screen .]
  73.  
  74. # ----------------------------------------------------------------------
  75. # Read in files that define all of the class bindings.
  76. # ----------------------------------------------------------------------
  77.  
  78. if {$tcl_platform(platform) != "macintosh"} {
  79.     source $tk_library/button.tcl
  80.     source $tk_library/entry.tcl
  81.     source $tk_library/listbox.tcl
  82.     source $tk_library/menu.tcl
  83.     source $tk_library/scale.tcl
  84.     source $tk_library/scrlbar.tcl
  85.     source $tk_library/text.tcl
  86. }
  87.  
  88. # ----------------------------------------------------------------------
  89. # Default bindings for keyboard traversal.
  90. # ----------------------------------------------------------------------
  91.  
  92. bind all <Tab> {focus [tk_focusNext %W]}
  93. bind all <Shift-Tab> {focus [tk_focusPrev %W]}
  94.  
  95. # tkCancelRepeat --
  96. # This procedure is invoked to cancel an auto-repeat action described
  97. # by tkPriv(afterId).  It's used by several widgets to auto-scroll
  98. # the widget when the mouse is dragged out of the widget with a
  99. # button pressed.
  100. #
  101. # Arguments:
  102. # None.
  103.  
  104. proc tkCancelRepeat {} {
  105.     global tkPriv
  106.     after cancel $tkPriv(afterId)
  107.     set tkPriv(afterId) {}
  108. }
  109.