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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
|
# $Id: sort.tcl,v 1.2 1998/10/25 22:27:30 cthulhu Exp $
proc GetColList {} {
source "[xxl_library]/globalvars.tcl"
set ret_list [list [format "Column %s" [ColName [lindex $currentRange 0]]]]
set aux [lindex $currentRange 0]
while {$aux < [lindex $currentRange 2]} {
set aux [expr $aux+1]
lappend ret_list [format "Column %s" [ColName $aux]]
}
return $ret_list
}
proc GetRowList {} {
source "[xxl_library]/globalvars.tcl"
set ret_list [list [format "Row %s" [expr [lindex $currentRange 1]+1]]]
set aux [expr [lindex $currentRange 1]+1]
while {$aux <= [lindex $currentRange 3]} {
set aux [expr $aux+1]
lappend ret_list [format "Row %s" $aux]
}
return $ret_list
}
proc SwapLBox {arg} {
if {$arg == "rows"} {
ChangeListboxMenu .sort.using.listbox [GetRowList]
} else {
ChangeListboxMenu .sort.using.listbox [GetColList]
}
.sort.using.listbox.f1.list selection set 0
}
proc SortFromToolbar {dir} {
source "[xxl_library]/globalvars.tcl"
SortCells $activeSheet \
[lindex $currentRange 0] [lindex $currentRange 1] \
[lindex $currentRange 2] [lindex $currentRange 3] \
$dir 0 0
# unhighlightCurrentRange [canvasFromSheet $activeSheet]
}
proc GoSort {dir row_col} {
source "[xxl_library]/globalvars.tcl"
SortCells $activeSheet \
[lindex $currentRange 0] [lindex $currentRange 1] \
[lindex $currentRange 2] [lindex $currentRange 3] \
$dir $row_col [.sort.using.listbox.f1.list curselection]
destroy .sort
# unhighlightCurrentRange [canvasFromSheet $activeSheet]
}
proc SortCommand {} {
source "[xxl_library]/globalvars.tcl"
set globalState2 sortCells
update
if {$currentRange != ""} {
toplevel .sort
wm title .sort "Sort Options"
frame .sort.sortby
frame .sort.sortby.label
label .sort.sortby.label.text -text "Sort:"
pack .sort.sortby.label.text -side left
frame .sort.sortby.options
set RowOrCol 0
radiobutton .sort.sortby.options.cols -variable RowOrCol \
-text Columns -value 1 -command {SwapLBox rows}
radiobutton .sort.sortby.options.rows -variable RowOrCol \
-text Rows -value 0 -command {SwapLBox cols}
.sort.sortby.options.rows select
pack .sort.sortby.options.cols .sort.sortby.options.rows -side left
pack .sort.sortby.label -side top -fill both -expand yes
pack .sort.sortby.options -side left
pack .sort.sortby -side top -fill both -expand yes
frame .sort.using
frame .sort.using.lbl
label .sort.using.lbl.text -text "Using as sort key:"
pack .sort.using.lbl.text -side left
frame .sort.using.listbox
createListboxMenu .sort.using.listbox [GetColList] lixo
.sort.using.listbox.f1.list selection set 0
pack .sort.using.lbl -side top -fill both -expand yes
pack .sort.using.listbox -side top
pack .sort.using -side top -fill both -expand yes
frame .sort.order
frame .sort.order.lbl
label .sort.order.lbl.text -text "Sort direction:"
pack .sort.order.lbl.text -side left
frame .sort.order.options
radiobutton .sort.order.options.asc -variable Dir -text Ascending \
-value 1
radiobutton .sort.order.options.desc -variable Dir -text Descending \
-value 0
.sort.order.options.asc select
pack .sort.order.options.asc .sort.order.options.desc -side left
pack .sort.order.lbl -side top -fill both -expand yes
pack .sort.order.options -side left
pack .sort.order -side top -fill both -expand yes
frame .sort.endr
button .sort.endr.ok -text Ok -command {GoSort $Dir $RowOrCol}
button .sort.endr.abort -text Abort -command {destroy .sort}
pack .sort.endr.ok .sort.endr.abort -fill x -expand yes -side bottom
pack .sort.endr -side bottom -fill x -expand yes
focus .sort
grab .sort
tkwait window .sort
}
set globalState2 normal
}
# $Log: sort.tcl,v $
# Revision 1.2 1998/10/25 22:27:30 cthulhu
# Sorting no longer unhighlights sorted range.
#
# Revision 1.1 1998/08/17 20:04:14 cthulhu
# Initial revision
#
|