home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
undocomman.tcl
< prev
next >
Wrap
Text File
|
1997-10-03
|
3KB
|
130 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1997
#
# File: @(#)undocomman.tcl /main/titanic/5
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)undocomman.tcl /main/titanic/5 3 Oct 1997 Copyright 1997 Cayenne Software Inc.
# Start user added include file section
# End user added include file section
Class UndoCommand : {Object} {
constructor
method destructor
method toggleUndo
method setUndoLabel
method addObject
method removeObject
attribute undone
attribute busy
# Name of the command, used for constructing the undo label.
#
attribute commandName
# Store orignal info in this variable before
# changing the label.
#
attribute buttonInfo
# The name of the edit menu.
#
attribute editMenu
attribute validAfterLevelChange
attribute objectSet
attribute currentObj
}
constructor UndoCommand {class this name} {
set this [Object::constructor $class $this $name]
$this undone 0
$this busy 1
$this validAfterLevelChange 0
$this objectSet [List new]
# Start constructor user section
if {! [isCommand [.main undoCommand]]} {
if [isCommand [.main currentObj]] {
$this currentObj [[.main currentObj] browsUiObj]
}
[.main undoButton] sensitive 1
}
$this editMenu [.main menuBar].edit.menu
$this buttonInfo [Dictionary new]
# End constructor user section
return $this
}
method UndoCommand::destructor {this} {
# Start destructor user section
[.main undoButton] sensitive 0
$this setUndoLabel none
# End destructor user section
}
method UndoCommand::toggleUndo {this} {
if [$this undone] {
$this redo
$this undone 0
$this setUndoLabel undo
} else {
$this undo
$this undone 1
$this setUndoLabel redo
}
}
# Sets the undo label in the Edit menu,
# based on action and commandName.
#
method UndoCommand::setUndoLabel {this action} {
# check if button exists, it may have been'customized'
set editMenu [$this editMenu]
if { ![isCommand $editMenu.undo] } {
return
}
case $action in {
{none} {
if {[[$this buttonInfo] set undoLabel] == ""} {
return
}
set newLabel [[$this buttonInfo] set undoLabel]
$editMenu.undo mnemonic [[$this buttonInfo] set undoMnemonic]
}
{undo} {
set oldLabel [[$this buttonInfo] set undoLabel]
if { $oldLabel == "" } {
set oldLabel [$editMenu.undo label]
[$this buttonInfo] set undoLabel $oldLabel
[$this buttonInfo] set undoMnemonic [$editMenu.undo mnemonic]
}
set newLabel "$oldLabel [$this commandName]"
}
{redo} {
$editMenu.undo mnemonic R
set newLabel "Redo [$this commandName]"
}
}
$editMenu.undo label $newLabel
}
# Do not delete this line -- regeneration end marker
method UndoCommand::addObject {this newObject} {
[$this objectSet] append $newObject
}
method UndoCommand::removeObject {this oldObject} {
[$this objectSet] removeValue $oldObject
}