home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1997 November
/
PCWorld_1997-11_cd.bin
/
software
/
programy
/
komix
/
DATA.Z
/
menuedarea.tcl
< prev
next >
Wrap
Text File
|
1996-10-24
|
13KB
|
527 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1996
#
# File: @(#)menuedarea.tcl /main/hindenburg/4
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)menuedarea.tcl /main/hindenburg/4 24 Oct 1996 Copyright 1996 Cayenne Software Inc.
# Start user added include file section
require cascadenod.tcl
require checkbutto.tcl
require menubarnod.tcl
require pushbutton.tcl
require radiobutto.tcl
require separatorn.tcl
require custmenufi.tcl
# End user added include file section
require "custedarea.tcl"
require "menutree.tcl"
Class MenuEdArea : {MenuTree CustEdArea} {
method destructor
constructor
method newObject
method deleteObjects
method createObject
method redefineObject
method writeObject
method getObjects
method clearArea
method getChildObjects
method determineObjectType
method getParentTypeObjects
method getParent
method load
method edit
method loadGeneric
attribute separatorCount
attribute genericCurName
attribute parentDefiner
attribute separatorDefiner
attribute radioEntryDefiner
attribute pushEntryDefiner
attribute checkEntryDefiner
}
method MenuEdArea::destructor {this} {
# Start destructor user section
# End destructor user section
$this MenuTree::destructor
$this CustEdArea::destructor
}
constructor MenuEdArea {class this name} {
set this [MenuTree::constructor $class $this $name]
set this [CustEdArea::constructor $class $this $name]
$this font "[m4_var get M4_font -context uce]"
$this rowCount 12
$this columnCount 60
$this separatorCount 0
$this destinationSet "WMT_MENUNODE dropEvent"
global classCount
$this filter [CustMenuFilter new CustMenuFilter$classCount $this]
incr classCount
return $this
}
method MenuEdArea::newObject {this menuEntryType name parent {edit 0}} {
$this isChanged 1
set user 0
if {[$this _level] == "user"} {
set user 1
}
set dotName [MenuEdArea::makeTclName $name]
set objSpec "label \\\"$name\\\""
if { $menuEntryType != "CustMenuBarButton" } {
# parent is the 'label' of the parent, now search for
# the parent object
set parentObj ""
foreach i [$this getParentTypeObjects] {
if {[$i label] == $parent} {
set parentObj $i
}
}
set dotName [$parentObj name].menu.$dotName
if {$menuEntryType == "CustMenuSeparator"} {
set objSpec ""
}
set parentScope "[$parentObj scope]"
} else {
set dotName .$dotName
set parentScope {}
}
# the tclName of the menuparententry is set only once,
# this should be done better, it should also change
# when the displayName changes, but this means that
# there should be a global name change to adjust the children's
# tclName (object path)
# use as much of the scope of the parent object
set scope [$this _scope]
for {set i [llength $scope]} {$i < [llength $parentScope]} {incr i} {
lappend scope [lindex $parentScope $i]
}
set obj [$this createObject "displayName \"$name\"
scope \"$scope\"
specLevel \"[$this _level]\"
userDefined $user
name \"$dotName\"
type $menuEntryType
visible {1 1 1 1 1}
objSpec \"$objSpec\"" \
[$this _level]]
if $edit {
$obj open
}
}
method MenuEdArea::deleteObjects {this objs} {
$this isChanged 1
foreach i $objs {
$i delete
}
.main selectionChanged
}
method MenuEdArea::createObject {this objSpec level} {
set class [$this determineObjectType $objSpec]
# do not create object if unknown class
if { $class == "" } {
return ""
}
global classCount
set node [$class new $this.Tree$classCount $objSpec]
incr classCount
# if invalid scope (level) specified, set scope to corporate
if {$icaseLevel([llength [$node scope]]) == ""} {
$node scope ""
}
$this adjustCreatedObject $node $level
# put node on the right place
set parent [$this getParent $node]
if { $parent != ""} {
$node parent $parent
set children [$parent childSet]
} else {
set children [$this rootSet]
}
$node updateView
# now check if the objectname already exists
# if so place the node right under the existing one
# ( not for separators)
if [$node isA SeparatorNode] {
# no check and no registration needed
return $node
}
set sameNodes "$node"
foreach sameNode [$this getMenuPartNode [$node name]] {
set sameNodes "$sameNodes $sameNode"
$node index [ expr {[$sameNode index]+1}]
}
$this setMenuPartNode [$node name] $sameNodes
return $node
}
method MenuEdArea::redefineObject {this obj} {
set object [$this CustEdArea::redefineObject $obj]
if [isCommand $object] {
if {[$object isA ChildNode] && ![$object isA SeparatorNode]} {
$object inToolBar [$obj inToolBar]
$object inPopUpMenu [$obj inPopUpMenu]
}
$object updateView
$this sortArea
}
return $object
}
method MenuEdArea::writeObject {this obj fid} {
#indentation of this function is 4 spaces to make it easier to read
set list ""
if [$obj readOnly] {
set list "$list readOnly [$obj readOnly]"
}
if { [$obj scope] != "" } {
set list "$list scope \{[$obj scope]\}"
}
if {[$obj isA ChildNode] && ![$obj isA SeparatorNode]} {
if [$obj inToolBar] {
set list "$list inToolBar [$obj inToolBar]"
}
if [$obj inPopUpMenu] {
set list "$list inPopUpMenu [$obj inPopUpMenu]"
}
}
# build the new TCL name here
if [$obj isA SeparatorNode] {
# make u unique name for the separator
set count [$this separatorCount]
incr count
$this separatorCount $count
if {[$obj parent] == ""} {
return
}
set list "$list name [[$obj parent] name].menu.[$this _level]\_$count"
} else {
set list "$list name [$obj name]"
}
set list "$list type [$obj type]"
if { [$obj visible] != "" && [$obj visible] != "1 1 1 1 1"} {
set list "$list visible \{[$obj visible]\}"
}
if [$obj isA RadioButtonNode] {
set list "$list arbiter \"[$obj arbiter]\""
}
set list "$list objSpec [CustEdArea::indentList [$obj objSpec] 1 1]"
puts $fid "registerObject [CustEdArea::indentList $list 0 1]"
set list ""
if [$obj isA ParentNode] {
set name [$obj name].menu
if { [$obj scope] != "" } {
set list "$list scope \{[$obj scope]\}"
}
set list "$list name $name"
set list "$list type CustMenu"
if { [$obj visible] != "" } {
set list "$list visible \{[$obj visible]\}"
}
if {[$obj pinnable] == 1} {
set list "$list objSpec [CustEdArea::indentList {pinnable 1} 1 1]"
}
puts $fid "registerObject [CustEdArea::indentList $list 0 1]"
# now take care of the arbiters
foreach i [$obj arbiters] {
set list ""
set name [MenuEdArea::makeTclName [lindex $i 0]]
set name [$obj name].menu.$name
if { [$obj scope] != "" } {
set list "$list scope \{[$obj scope]\}"
}
set list "$list name $name"
set list "$list type CustMenuArbiter"
if { [$obj visible] != "" } {
set list "$list visible \{[$obj visible]\}"
}
set objSpec "currentButtonChanged \{[lindex $i 1]\}"
set list "$list objSpec [CustEdArea::indentList $objSpec 1 1]"
puts $fid "registerObject [CustEdArea::indentList $list 0 1]"
}
}
}
method MenuEdArea::getObjects {this} {
set objs [$this rootSet]
return [concat $objs [$this getChildObjects $objs]]
}
method MenuEdArea::clearArea {this} {
foreach obj [$this rootSet] {
$obj delete
}
# reinitialise the dictionary
$this MenuPartNode [Dictionary new]
.main selectionChanged
}
proc MenuEdArea::makeTclName {displayName} {
regsub -all "\\\.| |\t" $displayName "" strippedString
return [string tolower $strippedString]
}
method MenuEdArea::getChildObjects {this parentObjs} {
set objs {}
foreach i $parentObjs {
if [$i hasChildren] {
set objs [concat $objs [$i childSet]]
set objs [concat $objs [$this getChildObjects \
[$i childSet]]]
}
}
return $objs
}
method MenuEdArea::determineObjectType {this objSpec} {
set objType ""
set menuPartSpec ""
set name ""
set index [lsearch $objSpec "type"]
if {$index != -1} {
incr index
set objType [lindex $objSpec $index]
}
if {$objType == "CustMenuPushButton"} {
return PushButtonNode
}
if {$objType == "CustMenuBarButton"} {
return MenuBarNode
}
if {$objType == "CustCascadeButton"} {
return CascadeNode
}
if {$objType == "CustMenuSeparator"} {
return SeparatorNode
}
if {$objType == "CustMenuCheckButton"} {
return CheckButtonNode
}
if {$objType == "CustMenuRadioButton"} {
return RadioButtonNode
}
if {$objType == "CustMenu"} {
# skip menus
# if the menu has 'pinnable == 1' , set the parents pinnable
set pinnable 0
set menuPartSpec ""
set index [lsearch $objSpec "objSpec"]
if {$index != -1} {
incr index
set menuPartSpec [lindex $objSpec $index]
}
set index [lsearch $menuPartSpec "pinnable"]
if {$index != -1} {
incr index
set pinnable [lindex $menuPartSpec $index]
}
if {$pinnable == 0} {
return ""
}
set index [lsearch $objSpec "name"]
if {$index != -1} {
incr index
set name [lindex $objSpec $index]
}
foreach parent [$this getMenuPartNode [getParent $name]] {
if {$parent != "" && [$parent isA ParentNode] } {
$parent pinnable 1
break
}
}
}
if {$objType == "CustMenuArbiter"} {
# skip menuarbiters
# registrate the arbiters in the menuparents
set currentButtonChanged ""
set menuPartSpec ""
set index [lsearch $objSpec "objSpec"]
if {$index != -1} {
incr index
set menuPartSpec [lindex $objSpec $index]
}
set index [lsearch $menuPartSpec "currentButtonChanged"]
if {$index != -1} {
incr index
set currentButtonChanged [lindex $menuPartSpec $index]
}
set index [lsearch $objSpec "name"]
if {$index != -1} {
incr index
set name [lindex $objSpec $index]
}
set idx [string last "." $name]
set arbiterName [string range $name [expr {$idx +1}] end]
set par [string range $name 0 [expr {$idx -1}]]
set idx [string last "." $par]
set par [string range $par 0 [expr {$idx -1}]]
foreach parent [$this getMenuPartNode $par] {
if {$parent != "" && [$parent isA ParentNode]} {
set arbiters [$parent arbiters]
lappend arbiters "\{$arbiterName\} \
\{$currentButtonChanged\}"
$parent arbiters $arbiters
break
}
}
}
return ""
}
method MenuEdArea::getParentTypeObjects {this} {
set objs [$this getObjects]
set parentObjs {}
foreach i $objs {
if { [$i type] == "CustMenuBarButton" ||
[$i type] == "CustCascadeButton" } {
lappend parentObjs $i
}
}
return $parentObjs
}
method MenuEdArea::getParent {this child} {
set parent ""
set parentName [getParent [$child name]]
set parentName [getParent $parentName]
foreach parent [$this getMenuPartNode $parentName] {
if [$parent isA ParentNode] {
break
}
}
return $parent
# because the menu is not shown in the customization
# editor interface the child-of-a-menu must be shown
# in the customization editor as the child-of-the-parent-
# of-a-menu
}
method MenuEdArea::load {this obj} {
if {[$this genericCurName] != "" && [.main permanentReadOnly] == 1} {
$this loadGeneric $obj
}
$this CustEdArea::load $obj
}
method MenuEdArea::edit {this obj} {
if {[$this genericCurName] != ""} {
$this loadGeneric $obj
}
$this CustEdArea::edit $obj
}
method MenuEdArea::loadGeneric {this obj} {
set curName [$this _curName]
set curType [$this _curType]
$this isReadOnly 1
if [isCommand $obj] {
$this _curName [$this genericCurName]
$this _curType [[$obj customFile] type]
if {[llength [$this _path]] > 0} {
$this read [lindex [$this _path] 0] corporate
}
if {[llength [$this _path]] > 1} {
$this read [lindex [$this _path] 1] project
}
if {[llength [$this _path]] > 2} {
$this read [lindex [$this _path] 2] configuration
}
if {[llength [$this _path]] > 3} {
$this read [lindex [$this _path] 3] phase
}
if {[llength [$this _path]] > 4} {
$this read [lindex [$this _path] 4] system
}
$this readUserObjects
} else {
# if user is the case, the name of the file is given
# ~/icase/<obj>.[$this _curType]
set index [string last "." $obj]
$this _curName [$this genericCurName]
$this _curType [string range $obj [expr {$index+1}] end]
$this _level user
$this readCorporateObjects
$this readUserObjects
}
$this isReadOnly 0
$this _curName $curName
$this _curType $curType
}
# Do not delete this line -- regeneration end marker