home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # (c) Cayenne Software Inc. 1996
- #
- # File: @(#)m4optdlgel.tcl /main/hindenburg/3
- # Author: <generated>
- # Description:
- #---------------------------------------------------------------------------
- # SccsId = @(#)m4optdlgel.tcl /main/hindenburg/3 4 Jun 1997 Copyright 1996 Cayenne Software Inc.
-
- # Start user added include file section
- # End user added include file section
-
-
- Class M4OptDlgElem : {DlgColumn} {
- constructor
- method destructor
- method options
- method addOption
- method delOption
- attribute list
- attribute text
- }
-
- 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
- verStretchFactor 0
- SingleLineText text {
- horStretchFactor 100
- verStretchFactor 0
- columnCount 20
- text "M4_"
- cursorIndex 3
- }
- }
- PushButton add {
- label "Add"
- sensitive 0
- }
- PushButton del {
- label "Delete"
- sensitive 0
- }
- }
- }
-
- $this list $this.gui.list
- $this text $this.gui.r.t.text
- set add $this.gui.r.add
- set del $this.gui.r.del
-
- [$this list] selectionChanged "
- set selected \[lindex \[%this selectedSet] 0]
- [$this text] text \$selected
- if \[lempty \$selected] {
- $add 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_\"} {
- $add sensitive 1
- } else {
- $add sensitive 0
- }"
-
- $add activated "$this addOption"
- $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::addOption {this} {
- set option [M4OptDlgElem::normalize [[$this text] text]]
- [$this list] entrySet [concat [list $option] [[$this list] entrySet]]
- [$this list] selectedIndexSet 0
- [$this list] makeIndexVisible 0
- $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.add 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
-
-