home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # (c) Westmount Technology 1994
- #
- # File: @(#)searchgrou.tcl /main/titanic/1
- # Author: <generated>
- # Description:
- #---------------------------------------------------------------------------
- # SccsId = @(#)searchgrou.tcl /main/titanic/1 12 Sep 1996 Copyright 1994 Westmount Technology
-
- # Start user added include file section
- # End user added include file section
-
-
- Class SearchGroup : {DlgColumn} {
- constructor
- method destructor
- method entrySet
- method selected
- method selectedIndex
- method textLabel
- method listLabel
- method listSelectionChanged
- method textValueChanged
- method handleActivated
- attribute _entrySet
- attribute activated
- }
-
- constructor SearchGroup {class this name} {
- set this [DlgColumn::constructor $class $this $name]
- # Start constructor user section
-
- Label new $this.textLabel -text \
- "Type the first few characters of the word:"
- SingleLineText new $this.text -textModified "$this textValueChanged"
-
- Label new $this.listLabel -text "Choose the word:"
- TextList new $this.list \
- -rowCount 16 \
- -selectionChanged "$this listSelectionChanged" \
- -activated "$this handleActivated"
-
- # End constructor user section
- return $this
- }
-
- method SearchGroup::destructor {this} {
- # Start destructor user section
- # End destructor user section
- }
-
- method SearchGroup::entrySet {this {set -}} {
- if {$set == "-"} {
- return [$this _entrySet]
- }
- set displaySet ""
- foreach entry $set {
- regsub -all {[^,][^,]*,[ ]*} $entry " " entry
- lappend displaySet $entry
- }
- $this.list entrySet $displaySet
- $this.text text ""
- $this _entrySet $set
- }
-
- method SearchGroup::selected {this {entry -}} {
- if {$entry == "-"} {
- set idx [$this.list selectedIndexSet]
- if {$idx == ""} {
- return ""
- }
- return [lindex [$this _entrySet] $idx]
- } else {
- set idx [lsearch -exact [$this _entrySet] $entry]
- if {$idx != -1} {
- $this.list selectedIndexSet $idx
- $this.text text $entry
- }
- }
- }
-
- method SearchGroup::selectedIndex {this {index -}} {
- if {$index == "-"} {
- return [$this.list selectedIndexSet]
- }
- $this.list selectedIndexSet $index
- }
-
- method SearchGroup::textLabel {this {label -}} {
- if {$label == "-"} {
- return [$this.textLabel text]
- }
- $this.textLabel text $label
- }
-
- method SearchGroup::listLabel {this {label -}} {
- if {$label == "-"} {
- return [$this.listLabel text]
- }
- $this.textLabel text $label
- }
-
- method SearchGroup::listSelectionChanged {this} {
- set idx [$this.list selectedIndexSet]
- if {$idx == ""} {
- $this.text text ""
- } else {
- $this.text text [lindex [$this _entrySet] $idx]
- }
- }
-
- method SearchGroup::textValueChanged {this} {
- set idx [SearchGroup::search [$this _entrySet] [$this.text text]]
- if {$idx != -1} {
- $this.list selectedIndexSet $idx
- $this.list setTopIndex $idx
- }
- }
-
- method SearchGroup::handleActivated {this} {
- regsub -all %this [$this activated] $this result
- uplevel #0 $result
- }
-
- proc SearchGroup::search {list entry} {
- set i 0
- # Escape special characters in entry
- regsub -all {[]|*+?\().-^$[]} $entry {\\&} entry
- foreach elem $list {
- if [regexp -nocase ^$entry $elem] {
- return $i
- }
- incr i
- }
- return -1
- }
-
- # Do not delete this line -- regeneration end marker
-
-