1023
1023
$w.glist tag configure fsmall -font font_Small
1024
1024
menu $w.glist.header_menu
1025
1025
menu $w.glist.header_menu.addcol
1026
menu $w.glist.header_menu.sort -disabledforeground blue
1027
1026
menu $w.glist.game_menu
1028
1027
bind $w.glist <Configure> "set ::glistResized($w.glist) 1"
1029
1028
bind $w.glist <2> "glist.popupmenu_ %W %x %y %X %Y $layout"
1030
1029
bind $w.glist <3> "glist.popupmenu_ %W %x %y %X %Y $layout"
1031
1030
bind $w.glist <ButtonRelease-1> "glist.release_ %W %x %y $layout"
1032
bind $w.glist <Double-ButtonPress-1> {
1033
foreach {idx ply} [split [%W selection] "_"] {}
1034
if {[info exist idx]} {
1035
sc_base switch $::glistBase(%W)
1036
::game::Load $idx $ply
1031
bind $w.glist <Double-ButtonRelease-1> "glist.doubleclick_ %W %x %y $layout"
1039
1032
bind $w.glist <Destroy> "glist.destroy_ $w.glist"
1236
proc glist.doubleclick_ {{w} {x} {y} {layout}} {
1237
lassign [$w identify $x $y] what
1238
if {$what == "heading"} {
1239
foreach {c dir} $::glist_Sort($layout) { $w heading $c -image "" }
1240
set ::glist_Sort($layout) {}
1241
glist.sortClickHandle_ $w $x $y $layout
1243
foreach {idx ply} [split [$w selection] "_"] {}
1244
if {[info exist idx]} {
1245
sc_base switch $::glistBase($w)
1246
::game::Load $idx $ply
1244
1251
proc glist.popupmenu_ {{w} {x} {y} {abs_x} {abs_y} {layout}} {
1245
1252
# identify region requires at least tk 8.5.9
1246
1253
# identify row have scrollbar problems
1297
1304
set col_idx [lsearch -exact $::glist_Headers [$w column $col -id] ]
1298
1305
$w.header_menu delete 0 end
1301
$w.header_menu.sort delete 0 end
1302
if {"???" != [lindex $::glist_SortShortcuts $col_idx]} {
1303
$w.header_menu.sort add command -label $::tr(GlistNewSort) -image ::glist_Arrows(0)\
1304
-compound right -command [list glist.sortBy_ $w $col_idx + $layout 1]
1305
$w.header_menu.sort add command -label $::tr(GlistNewSort) -image ::glist_Arrows(1)\
1306
-compound right -command [list glist.sortBy_ $w $col_idx - $layout 1]
1307
set a1 [llength $::glist_Sort($layout)]
1308
set a2 [expr $a1 +1]
1309
if {[lsearch -exact $::glist_Sort($layout) $col_idx ] == -1 && $a1 <= 16} {
1310
$w.header_menu.sort add separator
1311
$w.header_menu.sort add command -label $::tr(GlistAddToSort) -image ::glist_Arrows($a1)\
1312
-compound right -command [list glist.sortBy_ $w $col_idx + $layout 0]
1313
$w.header_menu.sort add command -label $::tr(GlistAddToSort) -image ::glist_Arrows($a2)\
1314
-compound right -command [list glist.sortBy_ $w $col_idx - $layout 0]
1316
$w.header_menu.sort add separator
1318
$w.header_menu.sort add command -label $::tr(GlistCurrentSep) -state disabled
1320
foreach {c dir} $::glist_Sort($layout) {
1321
set h [lindex $::glist_Headers $c]
1322
set arrow_idx [expr $i *2]
1323
if {$dir == "-"} { incr arrow_idx }
1324
$w.header_menu.sort add command -label $::tr($h) -image ::glist_Arrows($arrow_idx) \
1325
-compound left -state disabled
1328
$w.header_menu add cascade -label $::tr(Sort) -menu $w.header_menu.sort
1330
1307
#CHANGE ALIGNMENT
1331
$w.header_menu add separator
1332
1308
set cur_a [lindex $::glist_ColAnchor($layout) $col_idx]
1333
1309
if {$cur_a != "w"} {
1334
1310
$w.header_menu add command -label $::tr(GlistAlignL) \
1384
proc glist.sortBy_ {w col direction {layout} clear} {
1385
foreach {c dir} $::glist_Sort($layout) { $w heading $c -image "" }
1386
if {$clear} { unset ::glist_Sort($layout) }
1387
lappend ::glist_Sort($layout) $col $direction
1360
proc glist.sortClickHandle_ {{w} {x} {y} {layout}} {
1361
set col [$w identify column $x $y]
1362
set col_idx [lsearch -exact $::glist_Headers [$w column $col -id] ]
1363
if {"???" == [lindex $::glist_SortShortcuts $col_idx]} {
1364
# TODO: notify the user that the column cannot be used for sorting
1368
set exists [lsearch -exact $::glist_Sort($layout) $col_idx ]
1369
if {$exists == -1} {
1370
lappend ::glist_Sort($layout) $col_idx -
1373
if {[lindex $::glist_Sort($layout) $exists ] == "+"} {
1374
lset ::glist_Sort($layout) $exists {-}
1376
lset ::glist_Sort($layout) $exists {+}
1388
1380
glist.sortInit_ $w $layout
1389
1381
if {[info exist ::glistBase($w)]} { glist.update_ $w $::glistBase($w) }
1515
1507
set from [expr [string trimleft $::ttk::treeview::State(heading) {#}] -1]
1516
1508
set to [expr [string trimleft $new_col {#}] -1]
1517
1509
set val [lindex $::glist_ColOrder($layout) $from]
1518
set ::glist_ColOrder($layout) [lreplace $::glist_ColOrder($layout) $from $from]
1519
set ::glist_ColOrder($layout) [linsert $::glist_ColOrder($layout) $to $val]
1520
$w configure -displaycolumns $::glist_ColOrder($layout)
1511
set ::glist_ColOrder($layout) [lreplace $::glist_ColOrder($layout) $from $from]
1512
set ::glist_ColOrder($layout) [linsert $::glist_ColOrder($layout) $to $val]
1513
$w configure -displaycolumns $::glist_ColOrder($layout)
1515
glist.sortClickHandle_ $w $x $y $layout