home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 November / CPNL0711.ISO / beeld / teken / scribus-1.3.3.9-win32-install.exe / tcl / tix8.1 / SText.tcl < prev    next >
Text File  |  2001-12-08  |  3KB  |  135 lines

  1. # -*- mode: TCL; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
  2. #
  3. #    $Id: SText.tcl,v 1.2.2.2 2001/12/09 02:54:02 idiscovery Exp $
  4. #
  5. # SText.tcl --
  6. #
  7. #    This file implements Scrolled Text widgets
  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.  
  17.  
  18. tixWidgetClass tixScrolledText {
  19.     -classname TixScrolledText
  20.     -superclass tixScrolledWidget
  21.     -method {
  22.     }
  23.     -flag {
  24.     }
  25.     -static {
  26.     }
  27.     -configspec {
  28.     }
  29.     -default {
  30.     {.scrollbar            both}
  31.     {*Scrollbar.takeFocus        0}
  32.     }
  33.     -forcecall {
  34.     -scrollbar
  35.     }
  36. }
  37.  
  38. proc tixScrolledText:ConstructWidget {w} {
  39.     upvar #0 $w data
  40.     global tcl_platform
  41.  
  42.     tixChainMethod $w ConstructWidget
  43.  
  44.     set data(w:text) \
  45.     [text $w.text]
  46.     set data(w:hsb) \
  47.     [scrollbar $w.hsb -orient horizontal]
  48.     set data(w:vsb) \
  49.     [scrollbar $w.vsb -orient vertical]
  50.  
  51.     if {$data(-sizebox) && $tcl_platform(platform) == "windows"} {
  52. #       set data(w:sizebox) [ide_sizebox $w.sizebox]
  53.     }
  54.  
  55.     set data(pw:client) $data(w:text)
  56. }
  57.  
  58. proc tixScrolledText:SetBindings {w} {
  59.     upvar #0 $w data
  60.  
  61.     tixChainMethod $w SetBindings
  62.  
  63.     $data(w:text) config \
  64.     -xscrollcommand "tixScrolledText:XScroll $w"\
  65.     -yscrollcommand "tixScrolledText:YScroll $w"
  66.  
  67.     $data(w:hsb) config -command "$data(w:text) xview"
  68.     $data(w:vsb) config -command "$data(w:text) yview"
  69. }
  70.  
  71. #----------------------------------------------------------------------
  72. #
  73. #        option configs
  74. #----------------------------------------------------------------------
  75. proc tixScrolledText:config-takefocus {w value} {
  76.     upvar #0 $w data
  77.   
  78.     $data(w:text) config -takefocus $value
  79. }    
  80.  
  81. proc tixScrolledText:config-scrollbar {w value} {
  82.     upvar #0 $w data
  83.   
  84.     if {[string match "auto*" $value]} {
  85.     set value "both"
  86.     }
  87.     set data(-scrollbar) $value
  88.  
  89.     tixChainMethod $w config-scrollbar $value
  90.  
  91.     return $value
  92. }    
  93.  
  94. #----------------------------------------------------------------------
  95. #
  96. #        Widget commands
  97. #----------------------------------------------------------------------
  98.  
  99.  
  100. #----------------------------------------------------------------------
  101. #
  102. #        Private Methods
  103. #----------------------------------------------------------------------
  104.  
  105. #----------------------------------------------------------------------
  106. # virtual functions to query the client window's scroll requirement
  107. #----------------------------------------------------------------------
  108. proc tixScrolledText:GeometryInfo {w mW mH} {
  109.     upvar #0 $w data
  110.  
  111.     return [list "$data(x,first) $data(x,last)" "$data(y,first) $data(y,last)"]
  112. }
  113.  
  114. proc tixScrolledText:XScroll {w first last} {
  115.     upvar #0 $w data
  116.  
  117.     set data(x,first) $first
  118.     set data(x,last)  $last
  119.  
  120.     $data(w:hsb) set $first $last
  121.  
  122.     tixWidgetDoWhenIdle tixScrolledWidget:Configure $w
  123. }
  124.  
  125. proc tixScrolledText:YScroll {w first last} {
  126.     upvar #0 $w data
  127.  
  128.     set data(y,first) $first
  129.     set data(y,last)  $last
  130.     
  131.     $data(w:vsb) set $first $last
  132.  
  133.     tixWidgetDoWhenIdle tixScrolledWidget:Configure $w
  134. }
  135.