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

  1. #---------------------------------------------------------------------------
  2. #
  3. #      (c)     Cayenne Software Inc.    1997
  4. #
  5. #      File:           @(#)menuentryd.tcl    /main/titanic/8
  6. #      Author:         <generated>
  7. #      Description:
  8. #---------------------------------------------------------------------------
  9. # SccsId = @(#)menuentryd.tcl    /main/titanic/8   10 Nov 1997 Copyright 1997 Cayenne Software Inc.
  10.  
  11. # Start user added include file section
  12. require mnemonicbu.tcl
  13. require commandpag.tcl
  14. # End user added include file section
  15.  
  16. require "menudefine.tcl"
  17.  
  18. Class MenuEntryDialog : {MenuDefineDialog} {
  19.     constructor
  20.     method destructor
  21.     method createInterface
  22.     method clearInterface
  23.     method sensitive
  24.     method fromInterface
  25.     method toInterface
  26.     method load
  27.     method objName
  28.     attribute iPage
  29.     attribute cPage
  30.     attribute ePage
  31. }
  32.  
  33. constructor MenuEntryDialog {class this name} {
  34.     set this [MenuDefineDialog::constructor $class $this $name]
  35.     # Start constructor user section
  36.     # End constructor user section
  37.     return $this
  38. }
  39.  
  40. method MenuEntryDialog::destructor {this} {
  41.     # Start destructor user section
  42.     # End destructor user section
  43.     $this MenuDefineDialog::destructor
  44. }
  45.  
  46. method MenuEntryDialog::createInterface {this} {
  47.  
  48.     #indentation of this function is 4 spaces to make it easier to read
  49.     $this MenuDefineDialog::createInterface
  50.  
  51.     # create "interface" page
  52.     interface NoteBkPage $this.InterfaceNBP {
  53.         label Interface
  54.         DlgRow NG { 
  55.             DlgColumn DC {
  56.                 DlgRow DR {
  57.                     verStretchFactor 0
  58.                     sizeEqual 1
  59.                     NamedGroup NG {
  60.                         label Name 
  61.                         DlgColumn DC {
  62.                             SingleLineText nameSLT {}
  63.                             }
  64.                     }
  65.                     NamedGroup NG {
  66.                         label Mnemonic 
  67.                         DlgRow DR {
  68.                             spaceType EVEN
  69.                             MnemonicButton  mnemonicDDL { 
  70.                                 verStretchFactor 0
  71.                                 horStretchFactor 0
  72.                 entrySet " "
  73.                             }
  74.                         }
  75.                     }
  76.                 }
  77.                 DlgRow DR {
  78.                     verStretchFactor 0
  79.                     sizeEqual 1
  80.                     NamedGroup NG {
  81.                         label "Hint text" 
  82.                         DlgColumn DC {
  83.                             SingleLineText hintSLT {}
  84.                             }
  85.                     }
  86.                 }
  87.                 DlgRow DR {
  88.                     verStretchFactor 0
  89.                     sizeEqual 1
  90.                     NamedGroup NG {
  91.                         label Accelerator
  92.                         DlgRow DR {
  93.                             DlgColumn DC {
  94.                                 CheckButton ctrlCB {
  95.                                     label Ctrl
  96.                                 }
  97.                                 CheckButton shiftCB {
  98.                                     label Shift
  99.                                 }
  100.                                 CheckButton altCB {
  101.                                     label Alt
  102.                                 }
  103.                             }
  104.                             DlgColumn DC {
  105.                                 verStretchFactor 0
  106.                                 SingleLineText  acceleratorSLT {
  107.                                     columnCount 5
  108.                                 }
  109.                             }
  110.                         }
  111.                     }
  112.                     NamedGroup NG {
  113.                         label ToolBar
  114.                         DlgColumn DC {
  115.                             Image commandIconI { 
  116.                             }
  117.                             PushButton commandIconPB {
  118.                                 label "Select Icon"
  119.                             }
  120.                             CheckButton inToolBarCB {
  121.                                 label "Place in toolbar"
  122.                             }
  123.                         }
  124.                     }
  125.                 } 
  126.                 DlgRow DR {
  127.                     verStretchFactor 0
  128.                     NamedGroup NG {
  129.                         label "Popup menu"
  130.                         DlgRow DR {
  131.                             CheckButton inPopUpMenuCB {
  132.                                 label "Place in popup menu"
  133.                             }
  134.                             SingleLineText  popUpLabelSLT {
  135.                                 columnCount 30
  136.                             }
  137.                         }
  138.                     }
  139.                 } 
  140.             } 
  141.         }
  142.     }
  143.     $this iPage $this.InterfaceNBP.NG.DC.DR.NG
  144.  
  145.     [$this iPage].DC.commandIconPB activated "[.main smallIconSelector] \
  146.                     select [$this iPage].DC.commandIconI"
  147.     [$this iPage].DC.nameSLT textModified "[$this iPage].DR.mnemonicDDL \
  148.                                         entrySet \[%this text\]"
  149.  
  150.     # create "command" page
  151.     $this cPage [CommandPage new $this.cPage]
  152.  
  153.     # create "enable/disable" page
  154.     if {[[.main editorArea] toolType] == "browser"} {
  155.     require "brenablepa.tcl"
  156.         $this ePage [BrEnablePage new $this.ePage]
  157.     } elseif {[[.main editorArea] toolType] == "class"} {
  158.     require "clenablepa.tcl"
  159.         $this ePage [ClEnablePage new $this.ePage]
  160.     } else {
  161.     require "edenablepa.tcl"
  162.         $this ePage [EdEnablePage new $this.ePage]
  163.     }
  164. }
  165.  
  166. method MenuEntryDialog::clearInterface {this} {
  167.  
  168.     $this MenuDefineDialog::clearInterface
  169.  
  170.     # clean page "Interface"
  171.     [$this iPage].DC.nameSLT text ""
  172.     [$this iPage].DC.hintSLT text ""
  173.     [$this iPage].DR.mnemonicDDL entrySet {}
  174.     [$this iPage].DR.DC.ctrlCB state 0
  175.     [$this iPage].DR.DC.shiftCB state 0
  176.     [$this iPage].DR.DC.altCB state 0
  177.     [$this iPage].DR.DC.acceleratorSLT text ""
  178.     [$this iPage].DC.commandIconI pixmap undef_16
  179.     [$this iPage].DC.inToolBarCB state 0
  180.     [$this iPage].DR.inPopUpMenuCB state 0
  181.     [$this iPage].DR.popUpLabelSLT text ""
  182.     if { [[$this curObject] type] != "CustMenuPushButton" } {    
  183.         $this.InterfaceNBP.NG.DC.stateNG.state state 0
  184.         if { [[$this curObject] type] == "CustMenuRadioButton" } {
  185.             $this.InterfaceNBP.NG.DC.arbiterNG.arbiter \
  186.                 entrySet {dummyA dummyB dummyC}
  187.         }
  188.     }        
  189.  
  190.     # clean page "Command"
  191.     [$this cPage] clearInterface
  192.  
  193.     # clean page "Enable/Disable"
  194.     [$this ePage] clearInterface
  195. }
  196.  
  197. method MenuEntryDialog::sensitive {this args} {
  198.  
  199.     $this MenuDefineDialog::sensitive $args
  200.  
  201.     if {[llength $args] == 0} {
  202.             return [[$this iPage].DC.nameSLT sensitive]
  203.     } else {
  204.         set sensitive [lindex $args 0]
  205.     }
  206.     # clean page "Interface"
  207.     [$this iPage].DC.nameSLT sensitive $sensitive
  208.     [$this iPage].DC.hintSLT sensitive $sensitive
  209.     [$this iPage].DR.mnemonicDDL sensitive $sensitive
  210.     [$this iPage].DR.DC.ctrlCB sensitive $sensitive
  211.     [$this iPage].DR.DC.shiftCB sensitive $sensitive
  212.     [$this iPage].DR.DC.altCB sensitive $sensitive
  213.     [$this iPage].DR.DC.acceleratorSLT sensitive $sensitive
  214.     [$this iPage].DC.commandIconPB sensitive $sensitive
  215.     [$this iPage].DC.commandIconI sensitive $sensitive
  216.     [$this iPage].DC.inToolBarCB sensitive $sensitive
  217.     [$this iPage].DR.inPopUpMenuCB sensitive $sensitive
  218.     [$this iPage].DR.popUpLabelSLT sensitive $sensitive
  219.     if { [[$this curObject] type] != "CustMenuPushButton" } {    
  220.         $this.InterfaceNBP.NG.DC.stateNG.state sensitive $sensitive
  221.         if { [[$this curObject] type] == "CustMenuRadioButton" } {
  222.         $this.InterfaceNBP.NG.DC.arbiterNG.arbiter sensitive $sensitive
  223.         }
  224.     }        
  225.  
  226.     [$this cPage] sensitive $args
  227.  
  228.     [$this ePage] sensitive $args
  229.  
  230.     return $sensitive
  231. }
  232.  
  233. method MenuEntryDialog::fromInterface {this} {
  234.  
  235.     # save page "Interface"
  236.     set spec [list label [[$this iPage].DC.nameSLT text]]
  237.     if {[string trim [[$this iPage].DR.mnemonicDDL selected]] != ""} {
  238.         lappend spec mnemonic [[$this iPage].DR.mnemonicDDL selected]
  239.     }
  240.     set hint [string trim [[$this iPage].DC.hintSLT text]]
  241.     if ![lempty $hint] {
  242.         lappend spec hintText $hint
  243.     }
  244.     set key [string trim [[$this iPage].DR.DC.acceleratorSLT text]]
  245.     if ![lempty $key] {
  246.         set acc ""
  247.         if [[$this iPage].DR.DC.ctrlCB state] {
  248.             set acc "Ctrl"
  249.         }
  250.         if [[$this iPage].DR.DC.shiftCB state] {
  251.             if {$acc == ""} {
  252.                 set acc "Shift"
  253.             } else {
  254.                 set acc "$acc+Shift"
  255.             }
  256.     
  257.         }
  258.         if [[$this iPage].DR.DC.altCB state] {
  259.             if {$acc == ""} {
  260.                 set acc "Alt"
  261.             } else {
  262.                 set acc "$acc+Alt"
  263.             }
  264.         }
  265.  
  266.         regsub -all {\\} $key {\\\\}  key
  267.         if {$acc == ""} {
  268.             set acc $key
  269.         } else {
  270.             set acc "$acc+$key"
  271.         }
  272.  
  273.         lappend spec accelerator $acc
  274.     }
  275.     set popUpLabel [[$this iPage].DR.popUpLabelSLT text]
  276.     if {$popUpLabel != ""} {
  277.         lappend spec popUpLabel $popUpLabel
  278.     }
  279.  
  280.     set pixmap [[$this iPage].DC.commandIconI pixmap]
  281.     if {$pixmap != "undef_16"} {
  282.         lappend spec toolBarPixmap $pixmap
  283.         [$this curObject] inToolBar [[$this iPage].DC.inToolBarCB state]
  284.     }
  285.  
  286.     [$this curObject] inPopUpMenu [[$this iPage].DR.inPopUpMenuCB state]
  287.  
  288.     if { [[$this curObject] type] != "CustMenuPushButton" } {    
  289.         lappend spec state
  290.         lappend spec [$this.InterfaceNBP.NG.DC.stateNG.state state]
  291.         if { [[$this curObject] type] == "CustMenuRadioButton" } {
  292.             set arbiter \
  293.               [$this.InterfaceNBP.NG.DC.arbiterNG.arbiter selected]
  294.             if {$arbiter != ""} {
  295.                 [$this curObject] arbiter $arbiter
  296.             } else {
  297.                 # arbiter must be selected
  298.                 wmtkerror "No Radio Arbiter selected."
  299.                 return ""
  300.             }
  301.         }
  302.     }
  303.  
  304.     # save page "Command"
  305.     set cmdSpec [[$this cPage] fromInterface]
  306.     if {$cmdSpec == ""} {
  307.         return ""
  308.     }
  309.     # don't use lappend for this purpose
  310.     if { [[$this curObject] type] == "CustMenuPushButton" } {
  311.         set spec "$spec activated $cmdSpec"
  312.     } else {
  313.         set spec "$spec stateChanged $cmdSpec"
  314.     }
  315.  
  316.     # save page "Enable/Disable"
  317.     set spec "$spec [[$this ePage] fromInterface]"
  318.  
  319.     return $spec
  320. }
  321.  
  322. method MenuEntryDialog::toInterface {this key value} {
  323.  
  324.     # page "Interface"
  325.     if {$key == "label"} {
  326.  
  327.         [$this iPage].DC.nameSLT text $value
  328.         [$this iPage].DR.mnemonicDDL entrySet $value
  329.         return
  330.     }
  331.  
  332.     if {$key == "hintText"} {
  333.         [$this iPage].DC.hintSLT text $value
  334.     }
  335.  
  336.     if {$key == "mnemonic"} { 
  337.         [$this iPage].DR.mnemonicDDL selected $value
  338.         return
  339.     }
  340.  
  341.     if {$key == "accelerator"} { 
  342.         if {[string first "Ctrl" $value] != -1} {
  343.             [$this iPage].DR.DC.ctrlCB state 1
  344.         }            
  345.         if {[string first "Shift" $value] != -1} {
  346.             [$this iPage].DR.DC.shiftCB state 1
  347.         }            
  348.         if {[string first "Alt" $value] != -1} {
  349.             [$this iPage].DR.DC.altCB state 1
  350.         }            
  351.         set index [string last "+" $value]    
  352.         if {$index == -1} {
  353.             set accKey $value
  354.         } else {
  355.             incr index
  356.             set accKey [string range $value $index end ]
  357.         }
  358.  
  359.         [$this iPage].DR.DC.acceleratorSLT text $accKey
  360.         return
  361.     }
  362.  
  363.     if {$key == "toolBarPixmap"} {
  364.         [$this iPage].DC.commandIconI pixmap $value
  365.         return
  366.     }
  367.  
  368.     if {$key == "popUpLabel"} {
  369.         [$this iPage].DR.popUpLabelSLT text $value
  370.         return
  371.     }
  372.  
  373.     # page "Command"
  374.     if {$key == "activated" || $key == "stateChanged"} {
  375.         [$this cPage] toInterface $value
  376.     }
  377.  
  378.     # page "Enable/disable"
  379.     [$this ePage] toInterface $key $value
  380.  
  381.     if {$key == "state"} {
  382.         $this.InterfaceNBP.NG.DC.stateNG.state state $value
  383.     }
  384. }
  385.  
  386. method MenuEntryDialog::load {this object} {
  387.  
  388.     if { [$object type] != "CustMenuPushButton" } {    
  389.         if ![isCommand $this.InterfaceNBP.NG.DC.stateNG] {
  390.                 interface NamedGroup $this.InterfaceNBP.NG.DC.stateNG {
  391.                     label "Initial State"
  392.                 CheckButton state {
  393.                     label State
  394.                 }
  395.                     }
  396.         }
  397.         if { [$object type] == "CustMenuRadioButton" } {
  398.             if ![isCommand $this.InterfaceNBP.NG.DC.arbiterNG] {
  399.                     interface NamedGroup \
  400.                 $this.InterfaceNBP.NG.DC.arbiterNG {
  401.                         label "Radio Arbiter"
  402.                     allowResize 1
  403.                     VerRadioGroup arbiter {
  404.                     }
  405.                         }
  406.             }
  407.         }
  408.     } else {
  409.         if [isCommand $this.InterfaceNBP.NG.DC.stateNG] {
  410.             $this.InterfaceNBP.NG.DC.stateNG delete
  411.         }
  412.         if [isCommand $this.InterfaceNBP.NG.DC.arbiterNG] {
  413.             $this.InterfaceNBP.NG.DC.arbiterNG delete
  414.         }
  415.     }
  416.  
  417.     $this MenuDefineDialog::load $object
  418.     [$this iPage].DC.inToolBarCB state [$object inToolBar]
  419.     [$this iPage].DR.inPopUpMenuCB state [$object inPopUpMenu]
  420.  
  421.     if { [$object type] == "CustMenuRadioButton" } {
  422.         set arbiters {}
  423.         foreach i [[$object parent] arbiters] {
  424.             lappend arbiters [MenuEdArea::makeTclName [lindex $i 0]]
  425.         }
  426.         $this.InterfaceNBP.NG.DC.arbiterNG.arbiter entrySet $arbiters
  427.         $this.InterfaceNBP.NG.DC.arbiterNG.arbiter selected \
  428.             [$object arbiter]
  429.     }
  430.  
  431.     if [$object editable] {
  432.         $this sensitive 1
  433.     } else {
  434.         $this sensitive 0
  435.     }
  436. }
  437.  
  438. method MenuEntryDialog::objName {this args} {
  439.     
  440.     if {$args == ""} {
  441.         return [[$this iPage].DC.nameSLT text]
  442.     } else {
  443.         [$this iPage].DC.nameSLT text [join $args]
  444.     }
  445. }
  446.  
  447. # Do not delete this line -- regeneration end marker
  448.  
  449.