home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
m4optdlgel.tcl
< prev
next >
Wrap
Text File
|
1997-07-30
|
6KB
|
236 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1996
#
# File: @(#)m4optdlgel.tcl /main/titanic/6
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)m4optdlgel.tcl /main/titanic/6 30 Jul 1997 Copyright 1996 Cayenne Software Inc.
# Start user added include file section
require m4optionbr.tcl
# End user added include file section
Class M4OptDlgElem : {DlgColumn} {
constructor
method destructor
method options
method selOption
method setOption
method delOption
attribute list
attribute text
attribute optionBrowser
}
constructor M4OptDlgElem {class this name} {
set this [DlgColumn::constructor $class $this $name]
# Start constructor user section
$this verStretchFactor 100
interface DlgColumn $this.gui {
verStretchFactor 100
TextList list {
rowCount 4
selectionPolicy BROWSE
verStretchFactor 100
entrySet { }
}
DlgRow r {
horStretchFactor 100
verStretchFactor 0
spaceType NONE
DlgColumn t {
spaceType EVEN
horStretchFactor 100
verStretchFactor 0
SingleLineText text {
horStretchFactor 100
verStretchFactor 0
columnCount 20
text "M4_"
cursorIndex 3
}
}
PushButton sel {
horStretchFactor 0
label "Select"
}
PushButton set {
horStretchFactor 0
label "Set"
sensitive 0
}
PushButton del {
horStretchFactor 0
label "Delete"
sensitive 0
}
}
}
$this list $this.gui.list
$this text $this.gui.r.t.text
set sel $this.gui.r.sel
set set $this.gui.r.set
set del $this.gui.r.del
[$this list] selectionChanged "
set selected \[lindex \[%this selectedSet] 0]
[$this text] text \$selected
if \[lempty \$selected] {
$set sensitive 0
$del sensitive 0
} else {
eval \[[$this text] textModified]
$del sensitive 1
}"
[$this text] textModified "
set t \[%this text]
set n \[string length \$t]
if {\$n >= 4 && \[string range \$t 0 2] == \"M4_\"} {
$set sensitive 1
} else {
$set sensitive 0
}"
$sel activated "$this selOption"
$set activated "$this setOption"
$del activated "$this delOption"
# End constructor user section
return $this
}
method M4OptDlgElem::destructor {this} {
# Start destructor user section
# End destructor user section
}
method M4OptDlgElem::options {this {list {}}} {
if [lempty $list] {
set entrySet {}
foreach entry [[$this list] entrySet] {
lappend entrySet [M4OptDlgElem::normalize $entry 0]
}
return $entrySet
} else {
set entrySet {}
foreach entry $list {
lappend entrySet [M4OptDlgElem::normalize $entry]
}
[$this list] entrySet $entrySet
}
}
proc M4OptDlgElem::normalize {option {quote 1}} {
# Remove all spaces before the '=',
#
set list [split $option =]
regsub -all {[ "]} [lindex $list 0] {} name
set value [join [lrange $list 1 end] =]
# Remove all leading and trailing spaces.
#
set value [string trim $value]
# Remove any double quotes since we'll quote the entire option
# ourselves later if it contains spaces.
#
regsub -all {"} $value {} value
if {$quote && [string first " " $value] != -1} {
set value "\"$value\""
}
return [join [list $name $value] =]
}
method M4OptDlgElem::selOption {this} {
if {[$this optionBrowser] == ""} {
$this optionBrowser [M4OptionBrowser new .main.optbrowser \
[Repository::serverOptions] \
-okPressed "set value \[%this selectedOption]=; \
[$this text] text \$value; \
[$this text] cursorIndex \[string length \$value]; \
eval \[[$this text] textModified]"]
}
[$this optionBrowser] selectedSet NONE
[$this optionBrowser] popUp
}
method M4OptDlgElem::setOption {this} {
set option [M4OptDlgElem::normalize [[$this text] text]]
if ![regexp "^M4_\[^=]*" $option optionName] {
wmtkerror "Invalid format for option '$option'."
return
}
set index 0
set selIndex -1
set newEntries {}
set overwritten 0
foreach entry [[$this list] entrySet] {
if ![regexp "${optionName}=.*" $entry] {
lappend newEntries $entry
} else {
lappend newEntries $option
set overwritten 1
set selIndex $index
}
incr index
}
if !$overwritten {
lappend newEntries $option
set selIndex $index
}
[$this list] entrySet $newEntries
[$this list] selectedIndexSet $selIndex
[$this list] makeIndexVisible $selIndex
$this.gui.r.del sensitive 1
}
method M4OptDlgElem::delOption {this} {
set index [[$this list] selectedIndexSet]
set entries [[$this list] entrySet]
set count [llength $entries]
if {$index == 0} {
[$this list] entrySet [lrange $entries 1 end]
} else {
set i $index
incr i -1
set head [lrange $entries 0 $i]
incr i 2
set tail [lrange $entries $i end]
[$this list] entrySet [concat $head $tail]
if {$index == $count - 1} {
incr index -1
}
}
set newEntry [lindex [[$this list] entrySet] $index]
[$this list] selectedIndexSet $index
[$this text] text $newEntry
[$this text] cursorIndex [string length $newEntry]
if [lempty [[$this list] selectedIndexSet]] {
$this.gui.r.set sensitive 0
$this.gui.r.del sensitive 0
[$this text] text "M4_"
[$this text] cursorIndex 3
} else {
$this.gui.r.del sensitive 1
}
}
# Do not delete this line -- regeneration end marker