Changeset 1681 for branches


Ignore:
Timestamp:
Apr 1, 2010, 10:58:58 AM (14 years ago)
Author:
gah
Message:
 
Location:
branches/blt4
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/blt4/examples/zoo/filechoice/tool.xml

    r1677 r1681  
    7070        <description>From the home directory</description>
    7171        <label>Choose Files</label>
     72       <icon>
     73          R0lGODlhGgASAKEBAAAAAP///////////yH+FUNyZWF0ZWQgd2l0aCBUaGUgR0lNUAAh+QQBCgAB
     74          ACwAAAAAGgASAAACLoyPqcvtD8CRj8VZrYw8h/tRn2eA4Eiaosa1qttC1EmW81qrtbYvdG8DCodE
     75          RQEAOw==
     76                </icon>
    7277    </about>
     78
    7379    <pattern>@@input.choice(stats)@@</pattern>
    7480  </filelist>
  • branches/blt4/gui/scripts/controlOwner.tcl

    r1675 r1681  
    320320        # send out any callback notifications
    321321        foreach owner [array names _owner2paths] {
    322             puts stderr "owner=$_owner $_owner2paths($owner) path=$path"
    323322            foreach pattern $_owner2paths($owner) {
    324323                if {[string match $pattern $path]} {
    325                     puts stderr "owner=$_owner calling $_callbacks($owner/$pattern)"
    326324                    uplevel #0 $_callbacks($owner/$pattern)
    327325                    break
     
    408406            set i [lsearch -exact $plist $path]
    409407            if {$i < 0} { lappend _owner2paths($owner) $path }
    410             puts stderr "_callbacks($owner/$path)=$cb"
    411408            set _callbacks($owner/$path) $cb
    412409        }
  • branches/blt4/gui/scripts/filechoiceentry.tcl

    r1677 r1681  
    185185# ----------------------------------------------------------------------
    186186itcl::body Rappture::FileChoiceEntry::_rebuild {} {
    187     puts stderr "filechoiceentry rebuild"
    188187    set _rebuildPending 0
    189188    # get rid of any existing choices
     
    199198        set glob [string trim [$_owner xml get $_path.$cname]]
    200199        # Successively replace each template with its value.
    201         puts stderr "before glob=$glob"
    202200        while { [regexp -indices {@@[^@]*@@} $glob range] } {
    203201            foreach {first last} $range break
     
    206204            set cpath [string range $glob $i1 $i2]
    207205            set value [$_owner xml get $cpath.current]
    208             puts stderr "$cpath.current: value=$value"
    209206            if { $value == "" } {
    210                 puts stderr "$_owner xml get $cpath.default"
    211207                set value [$_owner xml get $cpath.default]
    212                 puts stderr "$cpath.default: value=$value"
    213208            }
    214209            set glob [string replace $glob $first $last $value]
     
    252247itcl::body Rappture::FileChoiceEntry::_tooltip {} {
    253248    set tip [string trim [$_owner xml get $_path.about.description]]
    254     puts stderr "tip=$tip, $_owner=$_owner path=$_path.about.description"
    255249    # get the description for the current choice, if there is one
    256250    set str [$itk_component(choice) value]
  • branches/blt4/gui/scripts/filelistentry.tcl

    r1680 r1681  
    2727    private variable _owner ""    ;# thing managing this control
    2828    private variable _path ""     ;# path in XML to this number
     29    private variable _icon ""
    2930
    3031    constructor {owner path args} {
     
    3940    public method tooltip {}
    4041
    41     private method Toggle { id }
    4242    protected method _rebuild {}
    4343    protected method _newValue { args }
    4444    protected method _tooltip {}
    4545    protected method _whenidle {}
    46 
    4746}
    4847
     
    8786            -tree $_tree \
    8887            -font "Arial 9" \
    89             -flat yes -separator /
    90     }
    91     $itk_component(tree) column insert 0 "show" \
    92         -text "" -weight 0.0 -pad 0 -borderwidth 0
    93     $itk_component(tree) style checkbox "check" -showvalue no \
    94         -onvalue 1 -offvalue 0
     88            -flat yes -separator /  \
     89            -selectcommand [itcl::code $this _newValue]
     90    }
    9591    $itk_component(tree) column configure "treeView" -justify left \
    9692        -weight 1.0 -text "" -pad 0 -borderwidth 0 -edit no
    97     $itk_component(tree) column configure "show" -style "check" -pad {0 0} \
    98         -edit no
    9993    pack $itk_component(scrollset) -fill both -expand yes
    10094
    10195    blt::table $itk_interior \
    10296        0,0 $itk_component(scrollset) -fill both 
    103     $_tree trace create all "show" w [itcl::code $this _newValue]
    10497    bind $itk_component(tree) <<Value>> [itcl::code $this _newValue]
    105     $itk_component(tree) bin Entry <Double-ButtonPress-1> \
    106         +[itcl::code $this Toggle current]
    107 
     98
     99    # Standard ButtonPress-1
     100    $itk_component(tree) bind Entry <ButtonPress-1> {   
     101        Rappture::FileListEntry::SetSelectionAnchor %W current yes set
     102        set blt::TreeView::_private(scroll) 1
     103    }
     104    # Standard B1-Motion
     105    $itk_component(tree) bind Entry <B1-Motion> {
     106        set blt::TreeView::_private(x) %x
     107        set blt::TreeView::_private(y) %y
     108        set index [%W nearest %x %y]
     109        Rappture::FileListEntry::SetSelectionAnchor %W $index yes set
     110    }
     111    # Standard ButtonRelease-1
     112    $itk_component(tree) button bind all <ButtonRelease-1> {
     113        set index [%W nearest %x %y blt::TreeView::_private(who)]
     114        if { [%W index current] == $index &&
     115             $blt::TreeView::_private(who) == "button" } {
     116            %W see -anchor nw current
     117            %W toggle current
     118        }
     119    }
     120    # Shift-ButtonPress-1
     121    $itk_component(tree) bind Entry <Shift-ButtonPress-1> {     
     122        Rappture::FileListEntry::SetSelectionAnchor %W current yes set
     123        set blt::TreeView::_private(scroll) 1
     124    }
     125    # Shift-B1-Motion
     126    $itk_component(tree) bind Entry <Shift-B1-Motion> {
     127        set blt::TreeView::_private(x) %x
     128        set blt::TreeView::_private(y) %y
     129        set index [%W nearest %x %y]
     130        if { [%W cget -selectmode] == "multiple" } {
     131            %W selection mark $index
     132        } else {
     133            Rappture::FileListEntry::SetSelectionAnchor %W $index yes set
     134        }
     135    }
     136    # Shift-ButtonRelease-1
     137    $itk_component(tree) bind Entry <Shift-ButtonRelease-1> {
     138        if { [%W cget -selectmode] == "multiple" } {
     139            %W selection anchor current
     140        }
     141        after cancel $blt::TreeView::_private(afterId)
     142        set blt::TreeView::_private(afterId) -1
     143        set blt::TreeView::_private(scroll) 0
     144    }
     145    $itk_component(tree) bind Entry <Control-ButtonPress-1> {   
     146        Rappture::FileListEntry::SetSelectionAnchor %W current no toggle
     147        set blt::TreeView::_private(scroll) 1
     148    }
     149    $itk_component(tree) bind Entry <Control-B1-Motion> {
     150        set blt::TreeView::_private(x) %x
     151        set blt::TreeView::_private(y) %y
     152        set index [%W nearest %x %y]
     153        if { [%W cget -selectmode] == "multiple" } {
     154            %W selection mark $index
     155        } else {
     156            Rappture::FileListEntry::SetSelectionAnchor %W $index no toggle
     157        }
     158    }
     159    $itk_component(tree) bind Entry <Control-ButtonRelease-1> {
     160        if { [%W cget -selectmode] == "multiple" } {
     161            %W selection anchor current
     162        }
     163        after cancel $blt::TreeView::_private(afterId)
     164        set blt::TreeView::_private(afterId) -1
     165        set blt::TreeView::_private(scroll) 0
     166    }
    108167    # First time, parse the <pattern> elements to generate notify callbacks
    109168    # for each template found.
     
    123182    $_owner notify sync
    124183    eval itk_initialize $args
     184
     185    # if the control has an icon, plug it in
     186    set str [$_owner xml get $path.about.icon]
     187    if {$str != ""} {
     188        set _icon [image create picture -data $str]
     189    }
    125190    _rebuild
    126191}
     
    155220            return
    156221        }
    157         foreach id [$_tree children root] {
     222        foreach id [$itk_component(tree) curselection] {
    158223            set path [$_tree get $id "path" ""]
    159224            set path2id($path) $id
    160225        }
    161226        set paths [split $newval ,]
    162         $_tree set all "show" 0
    163         foreach path $paths {
    164             if { [info exists path2id($path)] } {
    165                 $_tree set $path2id($path) "show" 1
    166             }
    167         }
    168227    } elseif {[llength $args] != 0} {
    169228        error "wrong # args: should be \"value ?-check? ?newval?\""
     
    174233    #
    175234    set list {}
    176     foreach id [$_tree children root] {
    177         if { [$_tree get $id "show" 0] } {
    178             set path [$_tree get $id "path" ""]
    179             if { $path != "" } {
    180                 lappend list $path
    181             }
     235    foreach id [$itk_component(tree) curselection] {
     236        set path [$_tree get $id "path" ""]
     237        if { $path != "" } {
     238            lappend list $path
    182239        }
    183240    }
     
    221278# ----------------------------------------------------------------------
    222279itcl::body Rappture::FileListEntry::_rebuild {} {
    223     puts stderr "filelistentry rebuild"
    224 
    225280    set _rebuildPending 0
    226281
     
    256311            set first $tail
    257312        }
     313        set tail [file root $tail]
    258314        set id [$_tree index root->"$tail"]
    259315        if { $id < 0 } {
     
    266322        if {$len > $max} { set max $len }
    267323    }
     324    $itk_component(tree) entry configure all -icon $_icon
    268325    eval $_tree delete [$_tree tag nodes unused]
    269326    $itk_component(tree) configure -width $max
    270     $itk_component(tree) selection set 0
     327    #$itk_component(tree) selection set 0
    271328}
    272329
     
    290347itcl::body Rappture::FileListEntry::_tooltip {} {
    291348    set tip [string trim [$_owner xml get $_path.about.description]]
    292     puts stderr "tip=$tip, $_owner=$_owner path=$_path.about.description"
    293349    # get the description for the current choice, if there is one
    294350    set path ""
     
    322378}
    323379
    324 itcl::body Rappture::FileListEntry::Toggle { index } {
    325     set id [$itk_component(tree) index $index]
    326     set show [$_tree get $id "show" 0]
    327     set show [expr $show==0]
    328     $_tree set $id "show" $show
    329 }
     380proc Rappture::FileListEntry::SetSelectionAnchor { w tagOrId clear how } {
     381    set index [$w index $tagOrId]
     382    if { $clear } {
     383        $w selection clearall
     384    }
     385    $w see $index
     386    $w focus $index
     387    $w selection $how $index
     388    $w selection anchor $index
     389}
     390
     391
Note: See TracChangeset for help on using the changeset viewer.