home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
menutree.tcl
< prev
next >
Wrap
Text File
|
1997-01-13
|
6KB
|
245 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1996
#
# File: @(#)menutree.tcl /main/titanic/3
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)menutree.tcl /main/titanic/3 13 Jan 1997 Copyright 1996 Cayenne Software Inc.
# Start user added include file section
# End user added include file section
Class MenuTree : {BrowsTree} {
constructor
method destructor
method dropEvent
method isDropPossible
method selectedSet
method getMenuPartNode
method setMenuPartNode
method removeMenuPartNode
attribute levelsToWrite
attribute MenuPartNode
}
constructor MenuTree {class this name} {
set this [BrowsTree::constructor $class $this $name]
$this MenuPartNode [Dictionary new]
# Start constructor user section
# create popup menu for tree
TreePopUpMenu new $this.pop -poppedUp {
%this entrySet [[.main menuHdlr] validPopUpEntrySet]
}
# End constructor user section
return $this
}
method MenuTree::destructor {this} {
# Start destructor user section
# End destructor user section
}
method MenuTree::dropEvent {this droppedObject srcIsDst droppedAfterObject droppedForObject} {
if {$srcIsDst == 0} {
wmtkerror "Drag & drop between tools is not supported (yet)."
return
}
if { $droppedAfterObject == "" &&
![$droppedObject isA MenuBarNode] } {
wmtkerror "Object not moved, reason: no parent available."
return
}
if {![$droppedObject editable]} {
wmtkerror "Object not moved, reason: object not editable."
return
}
set obj $droppedAfterObject
if [$droppedObject isA MenuBarNode] {
set newIndex 0
while {$obj != ""} {
set newIndex [expr [$obj index] + 1]
set obj [$obj parent]
}
} else {
if [$obj isA ParentNode] {
set newIndex 0
} else {
set newIndex [expr [$obj index] + 1]
# find the parent
while {$obj != "" && (![$obj isA ParentNode] || \
[$obj foldState] == 1)} {
set obj [$obj parent]
}
}
# is a parent found
if {$obj == "" } {
return
}
}
if {[$this isDropPossible $droppedObject $obj $droppedForObject \
$droppedAfterObject] != 1} {
return
}
$droppedObject parent $obj
$droppedObject index $newIndex
if {$obj != "" } {
set dotName [$obj name].menu
} else {
set dotName ""
}
# adjust the dotnames from the object and it's children
$droppedObject changeDotName $dotName
[.main editorArea] isChanged 1
}
method MenuTree::isDropPossible {this droppedObject parentObject droppedForObject droppedAfterObject} {
if {[ $droppedObject parent] != $parentObject} {
set parent $parentObject
} else {
set parent [$droppedObject parent]
}
# check if this one is valid
set err [$droppedObject check [$droppedObject scope] \
[$droppedObject visible] [$droppedObject specLevel] $parent]
if {$err != ""} {
wmtkerror "Object '[$droppedObject displayName]' \
$err: object not moved."
return 0
}
set levelList [$droppedObject specLevel]
# check if all the children can be saved
set err ""
foreach i [$this getChildObjects $droppedObject] {
if {![$i editable]} {
lappend err "[$i displayName] "
}
}
if { $err != "" } {
wmtkerror "Object '[$droppedObject displayName]' \
$err not changeable."
return 0
}
# handle the drop of an object between object of another level
# check if no object on other levels are beneath this one
set placeBetween 0
if {$droppedForObject != "" && [$droppedForObject parent] == $parent} {
if { $parent != ""} {
set children [$parent childSet]
} else {
set children [[.main editorArea] rootSet]
}
foreach child $children {
if {[$child index] < [$droppedForObject index]} {
continue
}
if {[$child specLevel] != [$droppedObject specLevel]} {
set placeBetween 1
}
}
}
if {$placeBetween == 0} {
$droppedObject ancestor ""
$droppedObject predecessor ""
return 1
}
# check if
# - level is the same
# - ancestor is not defined in a module
# - ancestor is not defined in the user file
# - ancestor is present when object is
# - ancestor has the same parent
# - ancestor is not empty
# - ancestor is not a separator
set ancestor ""
if {$droppedForObject != ""} {
if {[$droppedForObject specLevel] != "user" &&
[$droppedForObject specLevel] != [$droppedObject specLevel] &&
[$droppedForObject specModule] == "" &&
![$droppedForObject isA SeparatorNode] &&
[$droppedObject check [$droppedObject scope] \
[$droppedObject visible] [$droppedObject specLevel] \
$droppedForObject] == "" &&
[$droppedForObject parent] == $parent} {
set ancestor [$droppedForObject name]
}
}
# check if predecessor != user and and same parent
set predecessor ""
if {$ancestor == "" && $droppedAfterObject != ""} {
if {[$droppedAfterObject specLevel] != "user" &&
[$droppedForObject specLevel] != [$droppedObject specLevel] &&
![$droppedAfterObject isA SeparatorNode] &&
[$droppedAfterObject specModule] == "" &&
[$droppedObject check [$droppedObject scope] \
[$droppedObject visible] [$droppedObject specLevel] \
$droppedAfterObject] == "" &&
[$droppedAfterObject parent] == $parent} {
set predecessor [$droppedAfterObject name]
}
}
if {$ancestor == "" && $predecessor == ""} {
wmtkerror "Object '[$droppedObject displayName]' can not be \
placed between these nodes."
return 0
} else {
set idx [string last "." $ancestor]
set ancestor [string range $ancestor $idx end]
$droppedObject ancestor $ancestor
set idx [string last "." $predecessor]
set predecessor [string range $predecessor $idx end]
$droppedObject predecessor $predecessor
}
return 1
}
method MenuTree::selectedSet {this args} {
if {$args == ""} {
return [$this selected]
} else {
$this selected [lindex $args 0]
}
}
# Do not delete this line -- regeneration end marker
method MenuTree::getMenuPartNode {this dotName} {
return [[$this MenuPartNode] set $dotName]
}
method MenuTree::setMenuPartNode {this dotName newMenuPartNode} {
[$this MenuPartNode] set $dotName $newMenuPartNode
}
method MenuTree::removeMenuPartNode {this dotName} {
[$this MenuPartNode] unset $dotName
}