home *** CD-ROM | disk | FTP | other *** search
/ Freelog Special Freeware 31 / FreelogHS31.iso / Texte / scribus / scribus-1.3.3.9-win32-install.exe / tcl / tix8.1 / FileCbx.tcl < prev    next >
Text File  |  2001-11-03  |  2KB  |  106 lines

  1. # -*- mode: TCL; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
  2. #
  3. #    $Id: FileCbx.tcl,v 1.3.2.1 2001/11/03 06:43:50 idiscovery Exp $
  4. #
  5. # tixFileCombobox --
  6. #
  7. #    A combobox widget for entering file names, directory names, file
  8. #    patterns, etc.
  9. #
  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. # tixFileComboBox displays and accepts the DOS pathnames only. It doesn't
  18. # recognize UNC file names or Tix VPATHS.
  19. #
  20. tixWidgetClass tixFileComboBox {
  21.     -classname TixFileComboBox
  22.     -superclass tixPrimitive
  23.     -method {
  24.     invoke
  25.     }
  26.     -flag {
  27.     -command -defaultfile -directory -text
  28.     }
  29.     -forcecall {
  30.     -directory
  31.     }
  32.     -configspec {
  33.     {-defaultfile defaultFile DefaultFile ""}
  34.     {-directory directory Directory ""}
  35.     {-command command Command ""}
  36.     {-text text Text ""}
  37.     }
  38.     -default {
  39.     }
  40. }
  41.  
  42. proc tixFileComboBox:InitWidgetRec {w} {
  43.     upvar #0 $w data
  44.  
  45.     tixChainMethod $w InitWidgetRec
  46.  
  47.     if {![string comp $data(-directory) ""]} {
  48.     set data(-directory) [tixFSPWD]
  49.     }
  50. }
  51.  
  52. proc tixFileComboBox:ConstructWidget {w} {
  53.     upvar #0 $w data
  54.  
  55.     tixChainMethod $w ConstructWidget
  56.     set data(w:combo) [tixComboBox $w.combo -editable true -dropdown true]
  57.     pack $data(w:combo) -expand yes -fill both
  58. }
  59.  
  60. proc tixFileComboBox:SetBindings {w} {
  61.     upvar #0 $w data
  62.  
  63.     tixChainMethod $w SetBindings
  64.     $data(w:combo) config -command [list tixFileComboBox:OnComboCmd $w]
  65. }
  66.  
  67. proc tixFileComboBox:OnComboCmd {w args} {
  68.     upvar #0 $w data
  69.  
  70.     set text [string trim [tixEvent value]]
  71.  
  72.     set fInfo [tixFSNorm [tixFSVPath $data(-directory)] \
  73.     $text $data(-defaultfile) "" errorMsg]
  74.     if {[info exists errorMsg]} {
  75.  
  76.     } else {
  77.     tixSetSilent $data(w:combo) [lindex $fInfo 0]
  78.     if {[string compare $data(-command) ""]} {
  79.         set bind(specs) {%V}
  80.         set bind(%V)    $fInfo
  81.         tixEvalCmdBinding $w $data(-command) bind $fInfo
  82.     }
  83.     }
  84. }
  85.  
  86. proc tixFileComboBox:config-text {w val} {
  87.     upvar #0 $w data
  88.  
  89.     tixSetSilent $data(w:combo) $val
  90. }
  91.  
  92. proc tixFileComboBox:config-directory {w val} {
  93.     upvar #0 $w data
  94.  
  95.     set data(-directory) [tixFSNormDir $val]
  96.     return $data(-directory)
  97. }
  98.  
  99. proc tixFileComboBox:invoke {w} {
  100.     upvar #0 $w data
  101.  
  102.     $data(w:combo) invoke
  103. }
  104.  
  105.  
  106.