home *** CD-ROM | disk | FTP | other *** search
/ PC World 1998 October / PCWorld_1998-10_cd.bin / software / prehled / komix / DATA.Z / propifelem.tcl < prev    next >
Text File  |  1997-10-31  |  4KB  |  144 lines

  1. #---------------------------------------------------------------------------
  2. #
  3. #      (c)     Cayenne Software Inc.    1997
  4. #
  5. #      File:           @(#)propifelem.tcl    /main/titanic/7
  6. #      Author:         <generated>
  7. #      Description:
  8. #---------------------------------------------------------------------------
  9. # SccsId = @(#)propifelem.tcl    /main/titanic/7   31 Oct 1997 Copyright 1997 Cayenne Software Inc.
  10.  
  11. # Start user added include file section
  12.  
  13. global valueMethod labelMethod
  14. global hasEntrySet defIndex
  15.  
  16. set valueMethod(CheckButton)    state
  17. set labelMethod(CheckButton)    label
  18. set defIndex(CheckButton)    0
  19.  
  20. set valueMethod(ComboBox)    text
  21. set hasEntrySet(ComboBox)    true
  22. set defIndex(ComboBox)        0
  23.  
  24. set valueMethod(DropDwnComboBox) text
  25. set hasEntrySet(DropDwnComboBox) true
  26. set defIndex(DropDwnComboBox)    0
  27.  
  28. set valueMethod(DropDwnList)    selected
  29. set valueMethod(FloatField)    text
  30. set valueMethod(HorControlPanel) selected
  31. set valueMethod(HorRadioGroup)    selected
  32. set valueMethod(Image)        pixmap
  33. set valueMethod(IntField)    text
  34. set valueMethod(Label)        text
  35. set valueMethod(MultiLineText)    text
  36. set valueMethod(PropIfClassLib)    selected
  37.  
  38. set valueMethod(OptionMenu)    selected
  39. set hasEntrySet(OptionMenu)    true
  40. set defIndex(OptionMenu)    0
  41.  
  42. set valueMethod(SingleLineText) text
  43. set valueMethod(TextList)    selectedSet
  44. set valueMethod(VerControlPanel) selected
  45. set valueMethod(VerRadioGroup)    selected
  46.  
  47. # End user added include file section
  48.  
  49. require "propinterf.tcl"
  50.  
  51. Class PropIfElement : {PropInterface} {
  52.     method destructor
  53.     constructor
  54.     method getProperties
  55.     method setProperties
  56. }
  57.  
  58. method PropIfElement::destructor {this} {
  59.     # Start destructor user section
  60.     # End destructor user section
  61.     $this PropInterface::destructor
  62. }
  63.  
  64. constructor PropIfElement {class this guiParent propDef} {
  65.     set this [PropInterface::constructor $class $this]
  66.     $this definition $propDef
  67.     set name [$propDef name]
  68.     set class [$propDef ifClass]
  69.     global valueMethod labelMethod
  70.     if {![PropIfElement::canHandle $class]} {
  71.         error "Invalid interface class '$class'"
  72.     }
  73.     if [info exists labelMethod($class)] {
  74.         $this ifElement [eval $class new [list $guiParent.$name] \
  75.                       [$propDef ifOptions]]
  76.         [$this ifElement] $labelMethod($class) [$propDef longName]
  77.     } else {
  78.         Label new $guiParent.${name}l -text [$propDef longName]
  79.         $this ifElement [eval $class new [list $guiParent.$name] \
  80.                       [$propDef ifOptions]]
  81.     }
  82.     return $this
  83. }
  84.  
  85. proc PropIfElement::defaultValue {className ifOptions} {
  86.     set defIdx -1
  87.     global valueMethod
  88.     set optList [concat $ifOptions]
  89.     if [info exists valueMethod($className)] {
  90.         set defIdx [lsearch -exact $optList -$valueMethod($className)]
  91.     }
  92.     if {$defIdx != -1} {
  93.         return [lindex $optList [incr defIdx]]
  94.     }
  95.  
  96.     global hasEntrySet defIndex
  97.     if [info exists defIndex($className)] {
  98.         if [info exists hasEntrySet($className)] {
  99.             set entSetIdx [lsearch -exact $optList -entrySet]
  100.             if {$entSetIdx != -1} {
  101.                 set entrySet [lindex $optList [incr entSetIdx]]
  102.                 return [lindex $entrySet $defIndex($className)]
  103.             }
  104.         }
  105.         return $defIndex($className)
  106.     }
  107.  
  108.     return ""
  109. }
  110.  
  111. proc PropIfElement::canHandle {className} {
  112.     global valueMethod
  113.     return [info exists valueMethod($className)]
  114. }
  115.  
  116. method PropIfElement::getProperties {this propContainer} {
  117.     global valueMethod
  118.     set def [$this definition]
  119.     set key [$def name]
  120.     set class [$def ifClass]
  121.     set ifOpts [$def ifOptions]
  122.     set elem [$this ifElement]
  123.     set value [$propContainer getPropertyValue $key]
  124.     if {[string length $value] == 0} {
  125.         set value [PropIfElement::defaultValue $class $ifOpts]
  126.     }
  127.     $elem $valueMethod($class) $value
  128.     $elem sensitive [$propContainer isPropertyEditable $key]
  129. }
  130.  
  131. method PropIfElement::setProperties {this propContainer} {
  132.     global valueMethod
  133.     set def [$this definition]
  134.     set elem [$this ifElement]
  135.     set class [$def ifClass]
  136.     set ifOpts [$def ifOptions]
  137.     set value [$elem $valueMethod($class)]
  138.     set defVal [PropIfElement::defaultValue $class $ifOpts]
  139.     $propContainer changeProperty [$def name] $value $defVal
  140. }
  141.  
  142. # Do not delete this line -- regeneration end marker
  143.  
  144.