File: tablesel.tcl

package info (click to toggle)
moomps 4.6-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,444 kB
  • ctags: 2,307
  • sloc: tcl: 34,882; sh: 167; makefile: 91
file content (43 lines) | stat: -rw-r--r-- 1,622 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# copyright (C) 1997-2005 Jean-Luc Fontaine (mailto:jfontain@free.fr)
# this program is free software: please read the COPYRIGHT file enclosed in this package or use the Help Copyright menu

# $Id: tablesel.tcl,v 1.14 2005/01/02 00:45:07 jfontain Exp $

# implements selection on table cells, identified by row and column indices

class tableSelector {

    proc tableSelector {this args} selector {$args} {}

    proc ~tableSelector {this} {}

    ### public procedures follow:

    proc extend {this cell} {
        if {[info exists selector::($this,lastSelected)]} {
            scan $selector::($this,lastSelected) %d,%d startRow startColumn
            scan $cell %d,%d lastRow lastColumn
            if {$lastRow < $startRow} {                                                                                ;# order rows
                set last $startRow
                set startRow $lastRow
                set lastRow $last
            }
            if {$lastColumn < $startColumn} {                                                                       ;# order columns
                set last $startColumn
                set startColumn $lastColumn
                set lastColumn $last
            }
            set list {}
            for {set row $startRow} {$row <= $lastRow} {incr row} {
                for {set column $startColumn} {$column <= $lastColumn} {incr column} {
                    lappend list $row,$column
                }
            }
            selector::clear $this
            selector::set $this $list 1
        } else {
            selector::select $this $cell
        }
    }

}