home *** CD-ROM | disk | FTP | other *** search
/ PC World 1997 November / PCWorld_1997-11_cd.bin / software / programy / komix / DATA.Z / menuentryd.tcl < prev    next >
Text File  |  1996-10-24  |  12KB  |  410 lines

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