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 / FloatEnt.tcl < prev    next >
Text File  |  2001-11-03  |  3KB  |  132 lines

  1. # -*- mode: TCL; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
  2. #
  3. #    $Id: FloatEnt.tcl,v 1.2.2.1 2001/11/03 07:43:10 idiscovery Exp $
  4. #
  5. # FloatEnt.tcl --
  6. #
  7. #    An entry widget that can be attached on top of any widget to
  8. #    provide dynamic editing. It is used to provide dynamic editing
  9. #    for the tixGrid widget, among other things.
  10. #
  11. # Copyright (c) 1993-1999 Ioi Kim Lam.
  12. # Copyright (c) 2000-2001 Tix Project Group.
  13. #
  14. # See the file "license.terms" for information on usage and redistribution
  15. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  16. #
  17.  
  18. tixWidgetClass tixFloatEntry {
  19.     -classname TixFloatEntry
  20.     -superclass tixPrimitive
  21.     -method {
  22.     invoke post unpost
  23.     }
  24.     -flag {
  25.     -command -value
  26.     }
  27.     -configspec {
  28.     {-value value Value ""}
  29.     {-command command Command ""}
  30.     }
  31.     -default {
  32.     {.entry.highlightThickness    0}
  33.     }
  34. }
  35.  
  36. #----------------------------------------------------------------------
  37. #
  38. #    Initialization bindings
  39. #
  40. #----------------------------------------------------------------------
  41.  
  42. proc tixFloatEntry:InitWidgetRec {w} {
  43.     upvar #0 $w data
  44.  
  45.     tixChainMethod $w InitWidgetRec
  46. }
  47.  
  48. proc tixFloatEntry:ConstructWidget {w} {
  49.     upvar #0 $w data
  50.  
  51.     tixChainMethod $w ConstructWidget
  52.     set data(w:entry) [entry $w.entry]
  53.     pack $data(w:entry) -expand yes -fill both
  54. }
  55.  
  56. proc tixFloatEntry:SetBindings {w} {
  57.     upvar #0 $w data
  58.  
  59.     tixChainMethod $w SetBindings
  60.     tixBind $data(w:entry) <Return> "tixFloatEntry:invoke $w"
  61. }
  62.  
  63. #----------------------------------------------------------------------
  64. #
  65. #    Class bindings
  66. #
  67. #----------------------------------------------------------------------
  68.  
  69. proc tixFloatEntryBind {} {
  70.     tixBind TixFloatEntry <FocusIn>  {
  71.       if {![tixStrEq [focus -displayof [set %W(w:entry)]] [set %W(w:entry)]]} {
  72.       focus [%W subwidget entry]
  73.       [set %W(w:entry)] selection from 0
  74.       [set %W(w:entry)] selection to end
  75.       [set %W(w:entry)] icursor end
  76.       }
  77.     }
  78. }
  79.  
  80. #----------------------------------------------------------------------
  81. #
  82. #    Public methods
  83. #
  84. #----------------------------------------------------------------------
  85. proc tixFloatEntry:post {w x y {width ""} {height ""}} {
  86.     upvar #0 $w data
  87.  
  88.     if {$width == ""} {
  89.     set width [winfo reqwidth $data(w:entry)]
  90.     }
  91.     if {$height == ""} {
  92.     set height [winfo reqheight $data(w:entry)]
  93.     }
  94.  
  95.     place $w -x $x -y $y -width $width -height $height -bordermode ignore
  96.     raise $w
  97.     focus $data(w:entry)
  98. }
  99.  
  100. proc tixFloatEntry:unpost {w} {
  101.     upvar #0 $w data
  102.  
  103.     place forget $w
  104. }
  105.  
  106. proc tixFloatEntry:config-value {w val} {
  107.     upvar #0 $w data
  108.  
  109.     $data(w:entry) delete 0 end
  110.     $data(w:entry) insert 0 $val
  111.  
  112.     $data(w:entry) selection from 0
  113.     $data(w:entry) selection to end
  114.     $data(w:entry) icursor end
  115. }
  116. #----------------------------------------------------------------------
  117. #
  118. #    Private methods
  119. #
  120. #----------------------------------------------------------------------
  121.  
  122. proc tixFloatEntry:invoke {w} {
  123.     upvar #0 $w data
  124.  
  125.     if {![tixStrEq $data(-command) ""]} {
  126.     set bind(specs) {%V}
  127.     set bind(%V)    [$data(w:entry) get]
  128.  
  129.     tixEvalCmdBinding $w $data(-command) bind $bind(%V)
  130.     }
  131. }
  132.