home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 3 / CD ACTUAL 3.iso / linux / incoming / jstools-.6v3 / jstools- / jstools-tk3.6v3.0 / lib / jtkversion.tcl < prev    next >
Encoding:
Text File  |  1995-02-05  |  1.5 KB  |  60 lines

  1. # jtkversion.tcl - procedures to deal with multiple Tk versions
  2. # Copyright 1995 by Jay Sekora.  All rights reserved, except 
  3. # that this file may be freely redistributed in whole or in part 
  4. # for non¡profit, noncommercial use.
  5.  
  6. ######################################################################
  7. # j:tk4 - perform an action if running under Tk 4.0 or greater
  8. ######################################################################
  9.  
  10. proc j:tk4 { {command ""} } {
  11.   global tk_version
  12.   
  13.   set major_version [lindex [split $tk_version .] 0]
  14.   
  15.   if {$major_version >= 4} {
  16.     if [string length $command] {
  17.       uplevel 1 [list eval $command]
  18.     }
  19.     return 1
  20.   } else {
  21.     return 0
  22.   }
  23. }
  24.  
  25. ######################################################################
  26. # j:tk3 - perform an action if running under Tk 3.X or earlier
  27. ######################################################################
  28.  
  29. proc j:tk3 { {command ""} } {
  30.   global tk_version
  31.   
  32.   set major_version [lindex [split $tk_version .] 0]
  33.   
  34.   if {$major_version <= 3} {
  35.     if [string length $command] {
  36.       uplevel 1 [list eval $command]
  37.     }
  38.     return 1
  39.   } else {
  40.     return 0
  41.   }
  42. }
  43.  
  44. ######################################################################
  45. # j:current_focus - return current focus (assumes only one display!)
  46. ######################################################################
  47.  
  48. proc j:current_focus { {w .} } {
  49.   global tk_version
  50.   
  51.   set major_version [lindex [split $tk_version .] 0]
  52.   
  53.   if {$major_version <= 3} {
  54.     return [focus]
  55.   } else {
  56.     return [focus -lastfor $w]
  57.   }
  58. }
  59.