Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | * scripts/*.tcl: Support for interactive cell editing with the aid of the ctext widget; added the "canceledediting" subcommand; sped up the "selection" and "cellselection" subcommands by orders of magnitude; significally reduced the performance penalty imposed by the "-(select)background" and "-(select)foreground options at column, row, and cell levels; improved the keyboard traversal during interactive cell editing; using the "-data" option for most virtual events; improvements related to the selection mode "extended"; further code improvements; eliminated a regression introduced in Tablelist 5.6, related to vertical scrolling under Tk 8.5 or later in the presence of embedded images or windows. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: | 3661737db3a1479be218720ffeb35a077faf109c |
User & Date: | csaba 2013-04-13 18:34:57 |
Context
2013-04-13
| ||
18:35 | * scripts/tclIndex: Newly generated. check-in: 1e3b14655e user: csaba tags: trunk | |
18:34 | * scripts/*.tcl: Support for interactive cell editing with the aid of the ctext widget; added the "canceledediting" subcommand; sped up the "selection" and "cellselection" subcommands by orders of magnitude; significally reduced the performance penalty imposed by the "-(select)background" and "-(select)foreground options at column, row, and cell levels; improved the keyboard traversal during interactive cell editing; using the "-data" option for most virtual events; improvements related to the selection mode "extended"; further code improvements; eliminated a regression introduced in Tablelist 5.6, related to vertical scrolling under Tk 8.5 or later in the presence of embedded images or windows. check-in: 3661737db3 user: csaba tags: trunk | |
18:33 | * *.tcl: Bumped the version number to 5.8. * COPYRIGHT.txt: * README.txt: check-in: 3a0c83b46d user: csaba tags: trunk | |
Changes
Changes to modules/tablelist/scripts/mwutil.tcl.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#==============================================================================
# Contains utility procedures for mega-widgets.
#
# Structure of the module:
# - Namespace initialization
# - Public utility procedures
#
# Copyright (c) 2000-2012 Csaba Nemethi (E-mail: csaba.nemethi@t-online.de)
#==============================================================================
package require Tcl 8
package require Tk 8
#
# Namespace initialization
|
| |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#==============================================================================
# Contains utility procedures for mega-widgets.
#
# Structure of the module:
# - Namespace initialization
# - Public utility procedures
#
# Copyright (c) 2000-2013 Csaba Nemethi (E-mail: csaba.nemethi@t-online.de)
#==============================================================================
package require Tcl 8
package require Tk 8
#
# Namespace initialization
|
Changes to modules/tablelist/scripts/repair.tcl.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# "tablelistSort.tcl", and "tablelistUtil.tcl" by defining the procedure
# "arrElemExists" and replacing all invocations of "[info exists
# <array>(<name>)]" with "[arrElemExists <array> <name>]". This works around a
# bug in Tcl versions 8.2, 8.3.0 - 8.3.2, and 8.4a1 (fixed in Tcl 8.3.3 and
# 8.4a2), which causes excessive memory use when calling "info exists" on
# non-existent array elements.
#
# Copyright (c) 2001-2012 Csaba Nemethi (E-mail: csaba.nemethi@t-online.de)
#==============================================================================
set procDef {
#
# The following procedure returns 1 if arrName($name) exists and
# 0 otherwise. It is a (partial) replacement for [info exists
# arrName($name)], which -- due to a bug in Tcl versions 8.2,
|
| |
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# "tablelistSort.tcl", and "tablelistUtil.tcl" by defining the procedure
# "arrElemExists" and replacing all invocations of "[info exists
# <array>(<name>)]" with "[arrElemExists <array> <name>]". This works around a
# bug in Tcl versions 8.2, 8.3.0 - 8.3.2, and 8.4a1 (fixed in Tcl 8.3.3 and
# 8.4a2), which causes excessive memory use when calling "info exists" on
# non-existent array elements.
#
# Copyright (c) 2001-2013 Csaba Nemethi (E-mail: csaba.nemethi@t-online.de)
#==============================================================================
set procDef {
#
# The following procedure returns 1 if arrName($name) exists and
# 0 otherwise. It is a (partial) replacement for [info exists
# arrName($name)], which -- due to a bug in Tcl versions 8.2,
|
Changes to modules/tablelist/scripts/tablelistBind.tcl.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ... 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 ... 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 .... 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 .... 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 .... 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 .... 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 .... 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 .... 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 .... 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 |
# Structure of the module: # - Public helper procedures # - Binding tag Tablelist # - Binding tag TablelistWindow # - Binding tag TablelistBody # - Binding tags TablelistLabel, TablelistSubLabel, and TablelistArrow # # Copyright (c) 2000-2012 Csaba Nemethi (E-mail: csaba.nemethi@t-online.de) #============================================================================== # # Public helper procedures # ======================== # ................................................................................ # # Conditionally deactivate the previously activated expand/collapse control # variable priv set prevCellIdx $priv(prevActExpCollCtrlCell) if {[string compare $prevCellIdx ""] != 0 && [info exists data($prevCellIdx-indent)] && (!$inExpCollCtrl || [string compare $prevCellIdx $key,$col] != 0)} { set data($prevCellIdx-indent) \ [strMap {"Act" ""} $data($prevCellIdx-indent)] $data(body).ind_$prevCellIdx configure -image $data($prevCellIdx-indent) set priv(prevActExpCollCtrlCell) "" } if {!$inExpCollCtrl || [string compare $prevCellIdx $key,$col] == 0} { ................................................................................ # # Activate the expand/collapse control under the mouse pointer # variable ${treeStyle}_collapsedActImg if {[info exists ${treeStyle}_collapsedActImg]} { set data($key,$col-indent) [strMap {"expanded" "expandedAct" "collapsed" "collapsedAct"} $data($key,$col-indent)] $data(body).ind_$key,$col configure -image $data($key,$col-indent) set priv(prevActExpCollCtrlCell) $key,$col } } #------------------------------------------------------------------------------ # tablelist::wasExpCollCtrlClicked # ................................................................................ browse { ::$win selection clear 0 end ::$win selection set $row set priv(prevRow) $row event generate $win <<TablelistSelect>> } extended { if {[string compare $priv(prevRow) ""] != 0} { ::$win selection clear anchor $priv(prevRow) } ::$win selection set anchor $row set priv(prevRow) $row event generate $win <<TablelistSelect>> } } } cell { ................................................................................ ::$win cellselection clear 0,0 end ::$win cellselection set $row,$col set priv(prevRow) $row set priv(prevCol) $col event generate $win <<TablelistSelect>> } extended { if {[string compare $priv(prevRow) ""] != 0 && [string compare $priv(prevCol) ""] != 0} { ::$win cellselection clear anchor \ $priv(prevRow),$priv(prevCol) } ::$win cellselection set anchor $row,$col set priv(prevRow) $row set priv(prevCol) $col event generate $win <<TablelistSelect>> } } } } ................................................................................ variable priv if {$priv(clickedInEditWin) && $priv(releasedInEditWin)} { return "" } upvar ::tablelist::ns${win}::data data if {[info exists data(sourceRow)]} { set sourceKey [lindex $data(keyList) $data(sourceRow)] unset data(sourceRow) unset data(sourceEndRow) unset data(sourceDescCount) unset data(sourceParentKey) unset data(sourceParentRow) unset data(sourceParentEndRow) bind [winfo toplevel $win] <Escape> $data(topEscBinding) $data(body) configure -cursor $data(-cursor) place forget $data(rowGap) if {[info exists data(targetRow)]} { if {$data(targetRow) > $data(lastRow)} { if {[catch {::$win move $sourceKey $data(targetRow)}] != 0} { ::$win move $sourceKey root end } } else { set targetChildIdx $data(targetChildIdx) if {$targetChildIdx == 0} { set targetParentKey [lindex $data(keyList) $data(targetRow)] # # The first expand invocation below is necessary in # case the target node has already children, while # the second one is needed in the opposite case. # ::$win expand $targetParentKey -partly ::$win move $sourceKey $targetParentKey $targetChildIdx ::$win expand $targetParentKey -partly } else { set targetParentKey [::$win parentkey $data(targetRow)] set targetChildIdx [::$win childindex $data(targetRow)] ::$win move $sourceKey $targetParentKey $targetChildIdx } } event generate $win <<TablelistRowMoved>> unset data(targetRow) unset data(targetChildIdx) } else { switch $data(-selecttype) { row { ::$win activate $row } cell { ::$win activatecell $row,$col } } } } else { ................................................................................ $data(body) tag configure visibleLines -tabs {} if {$data(colResized)} { redisplayCol $win $col 0 end adjustColumns $win {} 0 stretchColumns $win $col updateColors $win event generate $win <<TablelistColumnResized>> } } else { if {[info exists data(X)]} { unset data(X) after cancel $data(afterId) set data(afterId) "" } ................................................................................ uplevel #0 $data(-labelcommand) [list $win $col] } } } elseif {$data(-movablecolumns)} { $data(hdrTxtFrCanv)$col configure -cursor $data(-cursor) if {[info exists data(targetCol)]} { moveCol $win $col $data(targetCol) event generate $win <<TablelistColumnMoved>> } catch {unset data(targetCol)} } } set data(labelClicked) 0 } #------------------------------------------------------------------------------ ................................................................................ if {!$data(isDisabled) && $data(-resizablecolumns) && $data($col-resizable)} { if {$shiftPressed} { doColConfig $col $win -width -$data($col-lastStaticWidth) } else { doColConfig $col $win -width 0 } event generate $win <<TablelistColumnResized>> } } #------------------------------------------------------------------------------ # tablelist::labelDblB1 # # This procedure is invoked when the header label w of a tablelist widget is ................................................................................ if {!$data(isDisabled) && [inResizeArea $w $x col] && $data(-resizablecolumns) && $data($col-resizable)} { if {$shiftPressed} { doColConfig $col $win -width -$data($col-lastStaticWidth) } else { doColConfig $col $win -width 0 } event generate $win <<TablelistColumnResized>> } } #------------------------------------------------------------------------------ # tablelist::escape # # This procedure is invoked to process <Escape> events in the top-level window |
| | > | > | > | > > > | > > > > > > > | | > > | < > > > > | > > > > > > | > > > | | > > | > > > > > < > | | | | | | | | | > > > | > > | | | > > | > | |
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ... 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 ... 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 .... 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 .... 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 .... 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 .... 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 .... 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 .... 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 .... 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 |
# Structure of the module: # - Public helper procedures # - Binding tag Tablelist # - Binding tag TablelistWindow # - Binding tag TablelistBody # - Binding tags TablelistLabel, TablelistSubLabel, and TablelistArrow # # Copyright (c) 2000-2013 Csaba Nemethi (E-mail: csaba.nemethi@t-online.de) #============================================================================== # # Public helper procedures # ======================== # ................................................................................ # # Conditionally deactivate the previously activated expand/collapse control # variable priv set prevCellIdx $priv(prevActExpCollCtrlCell) if {[string compare $prevCellIdx ""] != 0 && [info exists data($prevCellIdx-indent)] && (!$inExpCollCtrl || [string compare $prevCellIdx $key,$col] != 0) && [winfo exists $data(body).ind_$prevCellIdx]} { set data($prevCellIdx-indent) \ [strMap {"Act" ""} $data($prevCellIdx-indent)] $data(body).ind_$prevCellIdx configure -image $data($prevCellIdx-indent) set priv(prevActExpCollCtrlCell) "" } if {!$inExpCollCtrl || [string compare $prevCellIdx $key,$col] == 0} { ................................................................................ # # Activate the expand/collapse control under the mouse pointer # variable ${treeStyle}_collapsedActImg if {[info exists ${treeStyle}_collapsedActImg]} { set data($key,$col-indent) [strMap {"expanded" "expandedAct" "collapsed" "collapsedAct"} $data($key,$col-indent)] $indentLabel configure -image $data($key,$col-indent) set priv(prevActExpCollCtrlCell) $key,$col } } #------------------------------------------------------------------------------ # tablelist::wasExpCollCtrlClicked # ................................................................................ browse { ::$win selection clear 0 end ::$win selection set $row set priv(prevRow) $row event generate $win <<TablelistSelect>> } extended { set prevRow $priv(prevRow) if {[string compare $prevRow ""] == 0} { set prevRow $row ::$win selection set $row } if {[::$win selection includes anchor]} { ::$win selection clear $prevRow $row ::$win selection set anchor $row } else { ::$win selection set $prevRow $row ::$win selection clear anchor $row } set priv(prevRow) $row event generate $win <<TablelistSelect>> } } } cell { ................................................................................ ::$win cellselection clear 0,0 end ::$win cellselection set $row,$col set priv(prevRow) $row set priv(prevCol) $col event generate $win <<TablelistSelect>> } extended { set prevRow $priv(prevRow) set prevCol $priv(prevCol) if {[string compare $prevRow ""] == 0 || [string compare $prevCol ""] == 0} { set prevRow $row set prevcol $col ::$win cellselection set $row,$col } if {[::$win cellselection includes anchor]} { ::$win cellselection clear \ $prevRow,$priv(prevCol) $row,$col ::$win cellselection set anchor $row,$col } else { ::$win cellselection set \ $prevRow,$priv(prevCol) $row,$col ::$win cellselection clear anchor $row,$col } set priv(prevRow) $row set priv(prevCol) $col event generate $win <<TablelistSelect>> } } } } ................................................................................ variable priv if {$priv(clickedInEditWin) && $priv(releasedInEditWin)} { return "" } upvar ::tablelist::ns${win}::data data if {[info exists data(sourceRow)]} { set sourceRow $data(sourceRow) unset data(sourceRow) unset data(sourceEndRow) unset data(sourceDescCount) unset data(sourceParentKey) unset data(sourceParentRow) unset data(sourceParentEndRow) bind [winfo toplevel $win] <Escape> $data(topEscBinding) $data(body) configure -cursor $data(-cursor) place forget $data(rowGap) if {[info exists data(targetRow)]} { set targetRow $data(targetRow) unset data(targetRow) if {$targetRow > $data(lastRow)} { if {[catch {::$win move $sourceRow $targetRow}] == 0} { set targetParentNodeIdx [::$win parentkey $sourceRow] } else { ::$win move $sourceRow root end set targetParentNodeIdx root } set targetChildIdx [::$win childcount $targetParentNodeIdx] } else { set targetChildIdx $data(targetChildIdx) unset data(targetChildIdx) if {$targetChildIdx == 0} { set targetParentNodeIdx $targetRow # # The first expand invocation below is necessary in # case the target node has already children, while # the second one is needed in the opposite case. # ::$win expand $targetParentNodeIdx -partly ::$win move $sourceRow $targetParentNodeIdx $targetChildIdx ::$win expand $targetParentNodeIdx -partly } else { set targetParentNodeIdx [::$win parentkey $targetRow] set targetChildIdx [::$win childindex $targetRow] ::$win move $sourceRow $targetParentNodeIdx $targetChildIdx } } if {[string compare $targetParentNodeIdx "root"] != 0} { set targetParentNodeIdx [::$win index $targetParentNodeIdx] } set userData [list $sourceRow $targetParentNodeIdx $targetChildIdx] genVirtualEvent $win <<TablelistRowMoved>> $userData } else { switch $data(-selecttype) { row { ::$win activate $row } cell { ::$win activatecell $row,$col } } } } else { ................................................................................ $data(body) tag configure visibleLines -tabs {} if {$data(colResized)} { redisplayCol $win $col 0 end adjustColumns $win {} 0 stretchColumns $win $col updateColors $win genVirtualEvent $win <<TablelistColumnResized>> $col } } else { if {[info exists data(X)]} { unset data(X) after cancel $data(afterId) set data(afterId) "" } ................................................................................ uplevel #0 $data(-labelcommand) [list $win $col] } } } elseif {$data(-movablecolumns)} { $data(hdrTxtFrCanv)$col configure -cursor $data(-cursor) if {[info exists data(targetCol)]} { moveCol $win $col $data(targetCol) set userData [list $col $data(targetCol)] genVirtualEvent $win <<TablelistColumnMoved>> $userData unset data(targetCol) } } } set data(labelClicked) 0 } #------------------------------------------------------------------------------ ................................................................................ if {!$data(isDisabled) && $data(-resizablecolumns) && $data($col-resizable)} { if {$shiftPressed} { doColConfig $col $win -width -$data($col-lastStaticWidth) } else { doColConfig $col $win -width 0 } genVirtualEvent $win <<TablelistColumnResized>> $col } } #------------------------------------------------------------------------------ # tablelist::labelDblB1 # # This procedure is invoked when the header label w of a tablelist widget is ................................................................................ if {!$data(isDisabled) && [inResizeArea $w $x col] && $data(-resizablecolumns) && $data($col-resizable)} { if {$shiftPressed} { doColConfig $col $win -width -$data($col-lastStaticWidth) } else { doColConfig $col $win -width 0 } genVirtualEvent $win <<TablelistColumnResized>> $col } } #------------------------------------------------------------------------------ # tablelist::escape # # This procedure is invoked to process <Escape> events in the top-level window |
Changes to modules/tablelist/scripts/tablelistConfig.tcl.
1 2 3 4 5 6 7 8 9 10 11 .... 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 .... 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 .... 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 .... 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 .... 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 .... 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 .... 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 .... 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 .... 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 .... 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 .... 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 .... 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 .... 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 .... 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 .... 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 .... 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 .... 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 .... 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 .... 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 .... 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 |
#============================================================================== # Contains private configuration procedures for tablelist widgets. # # Copyright (c) 2000-2012 Csaba Nemethi (E-mail: csaba.nemethi@t-online.de) #============================================================================== #------------------------------------------------------------------------------ # tablelist::extendConfigSpecs # # Extends the elements of the array configSpecs. #------------------------------------------------------------------------------ ................................................................................ } -background - -foreground { set w $data(body) set name $col$opt if {[info exists data($name)] && (!$data($col-hide) || $canElide)} { # # Remove the tag col$opt-$data($name) # from the elements of the given column # set tag col$opt-$data($name) for {set line 1} {$line <= $data(itemCount)} {incr line} { findTabs $win $line $col $col tabIdx1 tabIdx2 $w tag remove $tag $tabIdx1 $tabIdx2+1c } } if {[string compare $val ""] == 0} { if {[info exists data($name)]} { unset data($name) } } else { # # Configure the tag col$opt-$val in the body text widget # set tag col$opt-$val $w tag configure $tag $opt $val $w tag lower $tag if {!$data($col-hide) || $canElide} { # # Apply the tag to the elements of the given column # for {set line 1} {$line <= $data(itemCount)} {incr line} { findTabs $win $line $col $col tabIdx1 tabIdx2 if {[lsearch -exact [$w tag names $tabIdx1] select] < 0} { $w tag add $tag $tabIdx1 $tabIdx2+1c } } } # # Save val in data($name) # set data($name) $val } if {!$data(isDisabled)} { updateColorsWhenIdle $win } # # Rebuild the lists of the column fonts and tag names # makeColFontAndTagLists $win } -changesnipside - -wrap { # # Save the boolean value specified by val in data($col$opt) and # make sure the given column will be redisplayed at idle time ................................................................................ [string compare $data(-selecttype) "row"] == 0} { foreach row [curSelection $win] { rowSelection $win set $row $row } } } updateViewWhenIdle $win event generate $win <<TablelistColHiddenStateChanged>> } } -labelalign { if {[string compare $val ""] == 0} { # # Unset data($col$opt) ................................................................................ } -selectbackground - -selectforeground { set w $data(body) set name $col$opt if {[info exists data($name)] && (!$data($col-hide) || $canElide)} { # # Remove the tag col$opt-$data($name) # from the elements of the given column # set tag col$opt-$data($name) for {set line 1} {$line <= $data(itemCount)} {incr line} { findTabs $win $line $col $col tabIdx1 tabIdx2 $w tag remove $tag $tabIdx1 $tabIdx2+1c } } if {[string compare $val ""] == 0} { if {[info exists data($name)]} { unset data($name) } } else { # # Configure the tag col$opt-$val in the body text widget # set tag col$opt-$val set optTail [string range $opt 7 end] ;# remove the -select $w tag configure $tag -$optTail $val $w tag raise $tag select if {!$data($col-hide) || $canElide} { # # Apply the tag to the selected elements of the given column # set selRange [$w tag nextrange select 1.0] while {[llength $selRange] != 0} { set selStart [lindex $selRange 0] set line [expr {int($selStart)}] findTabs $win $line $col $col tabIdx1 tabIdx2 if {[lsearch -exact [$w tag names $tabIdx1] select] >= 0} { $w tag add $tag $tabIdx1 $tabIdx2+1c } set selRange \ [$w tag nextrange select "$selStart lineend"] } } # # Save val in data($name) # set data($name) $val } if {!$data(isDisabled)} { ................................................................................ switch -- $opt { -background - -foreground { set key [lindex $data(keyList) $row] set name $key$opt if {[info exists data($name)]} { # # Remove the tag row$opt-$data($name) from the given row # set line [expr {$row + 1}] $w tag remove row$opt-$data($name) $line.0 $line.end } if {[string compare $val ""] == 0} { if {[info exists data($name)]} { unset data($name) incr data(rowTagRefCount) -1 } } else { # # Configure the tag row$opt-$val in the body text widget and # apply it to the non-selected elements of the given row # set tag row$opt-$val $w tag configure $tag $opt $val $w tag lower $tag active set line [expr {$row + 1}] if {[llength [$w tag nextrange select $line.0 $line.end]] == 0} { $w tag add $tag $line.0 $line.end } else { set textIdx1 [expr {double($line)}] for {set col 0} {$col < $data(colCount)} {incr col} { if {$data($col-hide) && !$canElide} { continue } set textIdx2 \ [$w search $elide "\t" $textIdx1+1c $line.end]+1c if {[lsearch -exact [$w tag names $textIdx1] select] < 0} { $w tag add $tag $textIdx1 $textIdx2 } set textIdx1 $textIdx2 } } # # Save val in data($name) # if {![info exists data($name)]} { incr data(rowTagRefCount) } set data($name) $val } if {!$data(isDisabled)} { updateColorsWhenIdle $win } } ................................................................................ # set colWidthsChanged 0 set colIdxList {} set displayedItem [lrange $item 0 $data(lastCol)] if {$data(hasFmtCmds)} { set displayedItem [formatItem $win $key $row $displayedItem] } set col 0 foreach text [strToDispStr $displayedItem] \ {pixels alignment} $data(colList) { if {($data($col-hide) && !$canElide) || $pixels != 0} { incr col continue } getAuxData $win $key $col auxType auxWidth getIndentData $win $key $col indentWidth ................................................................................ set data($name) $val } set displayedItem [lrange $item 0 $data(lastCol)] if {$data(hasFmtCmds)} { set displayedItem [formatItem $win $key $row $displayedItem] } set colWidthsChanged 0 set colIdxList {} set line [expr {$row + 1}] set textIdx1 $line.1 set col 0 foreach text [strToDispStr $displayedItem] \ {pixels alignment} $data(colList) { if {$data($col-hide) && !$canElide} { incr col continue } # # Adjust the cell text and the image or window width ................................................................................ # set colWidthsChanged 0 set colIdxList {} set displayedItem [lrange $item 0 $data(lastCol)] if {$data(hasFmtCmds)} { set displayedItem [formatItem $win $key $row $displayedItem] } set col 0 foreach text [strToDispStr $displayedItem] \ {pixels alignment} $data(colList) { if {($data($col-hide) && !$canElide) || $pixels != 0} { incr col continue } getAuxData $win $key $col auxType auxWidth getIndentData $win $key $col indentWidth ................................................................................ # is configureWidget, in order to make sure that only # one event per caller proc invocation will be generated # if {[string match "*configureWidget" $callerProc]} { makeStripesWhenIdle $win showLineNumbersWhenIdle $win updateViewWhenIdle $win event generate $win <<TablelistRowHiddenStateChanged>> } } } -name { set key [lindex $data(keyList) $row] if {[string compare $val ""] == 0} { ................................................................................ } -selectbackground - -selectforeground { set key [lindex $data(keyList) $row] set name $key$opt if {[info exists data($name)]} { # # Remove the tag row$opt-$data($name) from the given row # set line [expr {$row + 1}] $w tag remove row$opt-$data($name) $line.0 $line.end } if {[string compare $val ""] == 0} { if {[info exists data($name)]} { unset data($name) } } else { # # Configure the tag row$opt-$val in the body text widget # and apply it to the selected elements of the given row # set tag row$opt-$val set optTail [string range $opt 7 end] ;# remove the -select $w tag configure $tag -$optTail $val $w tag lower $tag active set line [expr {$row + 1}] set selRange [$w tag nextrange select $line.0 $line.end] while {[llength $selRange] != 0} { foreach {selStart selEnd} $selRange {} $w tag add $tag $selStart $selEnd set selRange [$w tag nextrange select $selEnd $line.end] } # # Save val in data($name) # set data($name) [$w tag cget $tag -$optTail] } ................................................................................ set key [lindex $oldItem end] set newItem [adjustItem $val $data(colCount)] if {$data(hasFmtCmds)} { set displayedItem [formatItem $win $key $row $newItem] } else { set displayedItem $newItem } set line [expr {$row + 1}] set textIdx1 $line.1 set col 0 foreach text [strToDispStr $displayedItem] \ {pixels alignment} $data(colList) { if {$data($col-hide) && !$canElide} { incr col continue } # # Adjust the cell text and the image or window width ................................................................................ } } else { set oldText [lindex $oldItem $col] if {[lindex $data(fmtCmdFlagList) $col]} { set oldText \ [formatElem $win $key $row $col $oldText] } set oldText [strToDispStr $oldText] set oldElemWidth [getElemWidth $win $oldText $auxWidth \ $indentWidth $cellFont] if {$oldElemWidth < $data($col-elemWidth) && $newElemWidth == $data($col-elemWidth)} { incr data($col-widestCount) } elseif {$oldElemWidth == $data($col-elemWidth) && $newElemWidth < $oldElemWidth && ................................................................................ switch -- $opt { -background - -foreground { set key [lindex $data(keyList) $row] set name $key,$col$opt if {[info exists data($name)] && (!$data($col-hide) || $canElide)} { # # Remove the tag cell$opt-$data($name) from the given cell # findTabs $win [expr {$row + 1}] $col $col tabIdx1 tabIdx2 $w tag remove cell$opt-$data($name) $tabIdx1 $tabIdx2+1c } if {[string compare $val ""] == 0} { if {[info exists data($name)]} { unset data($name) incr data(cellTagRefCount) -1 } } else { # # Configure the tag cell$opt-$val in the body text widget # set tag cell$opt-$val $w tag configure $tag $opt $val $w tag lower $tag disabled if {!$data($col-hide) || $canElide} { # # Apply the tag to the given cell if it is not selected # findTabs $win [expr {$row + 1}] $col $col tabIdx1 tabIdx2 if {[lsearch -exact [$w tag names $tabIdx1] select] < 0} { $w tag add $tag $tabIdx1 $tabIdx2+1c } } # # Save val in data($name) # if {![info exists data($name)]} { incr data(cellTagRefCount) } set data($name) $val } if {!$data(isDisabled)} { updateColorsWhenIdle $win } } ................................................................................ # # Adjust the cell text and the image or window width # set text [lindex $item $col] if {[lindex $data(fmtCmdFlagList) $col]} { set text [formatElem $win $key $row $col $text] } set text [strToDispStr $text] set multiline [string match "*\n*" $text] set cellFont [getCellFont $win $key $col] set pixels [lindex $data(colList) [expr {2*$col}]] set workPixels $pixels if {$pixels == 0} { ;# convention: dynamic width set textSav $text getAuxData $win $key $col auxType auxWidthSav ................................................................................ # set pixels [lindex $data(colList) [expr {2*$col}]] set workPixels $pixels set text [lindex $item $col] if {[lindex $data(fmtCmdFlagList) $col]} { set text [formatElem $win $key $row $col $text] } set text [strToDispStr $text] set oldText $text set multiline [string match "*\n*" $text] set cellFont [getCellFont $win $key $col] if {$pixels == 0} { ;# convention: dynamic width set textSav $text getAuxData $win $key $col auxType auxWidthSav getIndentData $win $key $col indentWidthSav ................................................................................ # set pixels [lindex $data(colList) [expr {2*$col}]] set workPixels $pixels set text [lindex $item $col] if {[lindex $data(fmtCmdFlagList) $col]} { set text [formatElem $win $key $row $col $text] } set text [strToDispStr $text] set oldText $text set multiline [string match "*\n*" $text] set cellFont [getCellFont $win $key $col] if {$pixels == 0} { ;# convention: dynamic width set textSav $text getAuxData $win $key $col auxType auxWidthSav getIndentData $win $key $col indentWidthSav ................................................................................ } -selectbackground - -selectforeground { set key [lindex $data(keyList) $row] set name $key,$col$opt if {[info exists data($name)] && (!$data($col-hide) || $canElide)} { # # Remove the tag cell$opt-$data($name) from the given cell # findTabs $win [expr {$row + 1}] $col $col tabIdx1 tabIdx2 $w tag remove cell$opt-$data($name) $tabIdx1 $tabIdx2+1c } if {[string compare $val ""] == 0} { if {[info exists data($name)]} { unset data($name) } } else { # # Configure the tag cell$opt-$val in the body text widget # set tag cell$opt-$val set optTail [string range $opt 7 end] ;# remove the -select $w tag configure $tag -$optTail $val $w tag lower $tag disabled if {!$data($col-hide) || $canElide} { # # Apply the tag to the given cell if it is selected # findTabs $win [expr {$row + 1}] $col $col tabIdx1 tabIdx2 if {[lsearch -exact [$w tag names $tabIdx1] select] >= 0} { $w tag add $tag $tabIdx1 $tabIdx2+1c } } # # Save val in data($name) # set data($name) $val } if {!$data(isDisabled)} { ................................................................................ } set pixels [lindex $data(colList) [expr {2*$col}]] set text [lindex $item $col] if {[lindex $data(fmtCmdFlagList) $col]} { set text [formatElem $win $key $row $col $text] } set text [strToDispStr $text] set multiline [string match "*\n*" $text] set cellFont [getCellFont $win $key $col] if {$pixels == 0} { ;# convention: dynamic width if {$data($col-maxPixels) > 0} { if {$data($col-reqPixels) > $data($col-maxPixels)} { set pixels $data($col-maxPixels) } ................................................................................ set text $val set oldItem [lindex $data(itemList) $row] set key [lindex $oldItem end] set fmtCmdFlag [lindex $data(fmtCmdFlagList) $col] if {$fmtCmdFlag} { set text [formatElem $win $key $row $col $text] } set text [strToDispStr $text] set textSav $text set multiline [string match "*\n*" $text] set cellFont [getCellFont $win $key $col] if {$pixels == 0} { ;# convention: dynamic width getAuxData $win $key $col auxType auxWidthSav getIndentData $win $key $col indentWidthSav ................................................................................ adjustColumns $win {} 1 } } else { set oldText [lindex $oldItem $col] if {$fmtCmdFlag} { set oldText [formatElem $win $key $row $col $oldText] } set oldText [strToDispStr $oldText] set oldElemWidth [getElemWidth $win $oldText $auxWidth \ $indentWidth $cellFont] if {$oldElemWidth < $data($col-elemWidth) && $newElemWidth == $data($col-elemWidth)} { incr data($col-widestCount) } elseif {$oldElemWidth == $data($col-elemWidth) && $newElemWidth < $oldElemWidth && ................................................................................ # set pixels [lindex $data(colList) [expr {2*$col}]] set workPixels $pixels set text [lindex $item $col] if {[lindex $data(fmtCmdFlagList) $col]} { set text [formatElem $win $key $row $col $text] } set text [strToDispStr $text] set oldText $text set multiline [string match "*\n*" $text] set cellFont [getCellFont $win $key $col] if {$pixels == 0} { ;# convention: dynamic width set textSav $text getAuxData $win $key $col auxType auxWidthSav getIndentData $win $key $col indentWidthSav |
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < > | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < > > > < | > > > < | > > > < | > | < < < < < < < < < < < < < < < < > > > < | > | > < < < < < < < < < < < < < < < < < < < < < < < > | > > | > > | > < < < < < < < < < < < < < < < < < < < > | > > | > > | > > | > |
1 2 3 4 5 6 7 8 9 10 11 .... 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 .... 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 .... 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 .... 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 .... 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 .... 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 .... 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 .... 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 .... 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 .... 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 .... 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 .... 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 .... 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 .... 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 .... 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 .... 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 .... 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 .... 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 .... 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 .... 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 |
#============================================================================== # Contains private configuration procedures for tablelist widgets. # # Copyright (c) 2000-2013 Csaba Nemethi (E-mail: csaba.nemethi@t-online.de) #============================================================================== #------------------------------------------------------------------------------ # tablelist::extendConfigSpecs # # Extends the elements of the array configSpecs. #------------------------------------------------------------------------------ ................................................................................ } -background - -foreground { set w $data(body) set name $col$opt if {[string compare $val ""] == 0} { if {[info exists data($name)]} { unset data($name) } } else { # # Configure the tag col$opt-$val in the body text widget # set tag col$opt-$val $w tag configure $tag $opt $val $w tag lower $tag # # Save val in data($name) # set data($name) $val } if {!$data(isDisabled)} { updateColorsWhenIdle $win } } -changesnipside - -wrap { # # Save the boolean value specified by val in data($col$opt) and # make sure the given column will be redisplayed at idle time ................................................................................ [string compare $data(-selecttype) "row"] == 0} { foreach row [curSelection $win] { rowSelection $win set $row $row } } } updateViewWhenIdle $win genVirtualEvent $win <<TablelistColHiddenStateChanged>> $col } } -labelalign { if {[string compare $val ""] == 0} { # # Unset data($col$opt) ................................................................................ } -selectbackground - -selectforeground { set w $data(body) set name $col$opt if {[string compare $val ""] == 0} { if {[info exists data($name)]} { unset data($name) } } else { # # Configure the tag col$opt-$val in the body text widget # set tag col$opt-$val set optTail [string range $opt 7 end] ;# remove the -select $w tag configure $tag -$optTail $val $w tag raise $tag select # # Save val in data($name) # set data($name) $val } if {!$data(isDisabled)} { ................................................................................ switch -- $opt { -background - -foreground { set key [lindex $data(keyList) $row] set name $key$opt if {[string compare $val ""] == 0} { if {[info exists data($name)]} { unset data($name) } } else { # # Configure the tag row$opt-$val in the body text widget # set tag row$opt-$val $w tag configure $tag $opt $val $w tag lower $tag active # # Save val in data($name) # set data($name) $val } if {!$data(isDisabled)} { updateColorsWhenIdle $win } } ................................................................................ # set colWidthsChanged 0 set colIdxList {} set displayedItem [lrange $item 0 $data(lastCol)] if {$data(hasFmtCmds)} { set displayedItem [formatItem $win $key $row $displayedItem] } if {[string match "*\t*" $displayedItem]} { set displayedItem [mapTabs $displayedItem] } set col 0 foreach text $displayedItem {pixels alignment} $data(colList) { if {($data($col-hide) && !$canElide) || $pixels != 0} { incr col continue } getAuxData $win $key $col auxType auxWidth getIndentData $win $key $col indentWidth ................................................................................ set data($name) $val } set displayedItem [lrange $item 0 $data(lastCol)] if {$data(hasFmtCmds)} { set displayedItem [formatItem $win $key $row $displayedItem] } if {[string match "*\t*" $displayedItem]} { set displayedItem [mapTabs $displayedItem] } set colWidthsChanged 0 set colIdxList {} set line [expr {$row + 1}] set textIdx1 $line.1 set col 0 foreach text $displayedItem {pixels alignment} $data(colList) { if {$data($col-hide) && !$canElide} { incr col continue } # # Adjust the cell text and the image or window width ................................................................................ # set colWidthsChanged 0 set colIdxList {} set displayedItem [lrange $item 0 $data(lastCol)] if {$data(hasFmtCmds)} { set displayedItem [formatItem $win $key $row $displayedItem] } if {[string match "*\t*" $displayedItem]} { set displayedItem [mapTabs $displayedItem] } set col 0 foreach text $displayedItem {pixels alignment} $data(colList) { if {($data($col-hide) && !$canElide) || $pixels != 0} { incr col continue } getAuxData $win $key $col auxType auxWidth getIndentData $win $key $col indentWidth ................................................................................ # is configureWidget, in order to make sure that only # one event per caller proc invocation will be generated # if {[string match "*configureWidget" $callerProc]} { makeStripesWhenIdle $win showLineNumbersWhenIdle $win updateViewWhenIdle $win genVirtualEvent $win <<TablelistRowHiddenStateChanged>> $row } } } -name { set key [lindex $data(keyList) $row] if {[string compare $val ""] == 0} { ................................................................................ } -selectbackground - -selectforeground { set key [lindex $data(keyList) $row] set name $key$opt if {[string compare $val ""] == 0} { if {[info exists data($name)]} { unset data($name) } } else { # # Configure the tag row$opt-$val in the body text widget # set tag row$opt-$val set optTail [string range $opt 7 end] ;# remove the -select $w tag configure $tag -$optTail $val $w tag lower $tag active # # Save val in data($name) # set data($name) [$w tag cget $tag -$optTail] } ................................................................................ set key [lindex $oldItem end] set newItem [adjustItem $val $data(colCount)] if {$data(hasFmtCmds)} { set displayedItem [formatItem $win $key $row $newItem] } else { set displayedItem $newItem } if {[string match "*\t*" $displayedItem]} { set displayedItem [mapTabs $displayedItem] } set line [expr {$row + 1}] set textIdx1 $line.1 set col 0 foreach text $displayedItem] {pixels alignment} $data(colList) { if {$data($col-hide) && !$canElide} { incr col continue } # # Adjust the cell text and the image or window width ................................................................................ } } else { set oldText [lindex $oldItem $col] if {[lindex $data(fmtCmdFlagList) $col]} { set oldText \ [formatElem $win $key $row $col $oldText] } if {[string match "*\t*" $oldText]} { set oldText [mapTabs $oldText] } set oldElemWidth [getElemWidth $win $oldText $auxWidth \ $indentWidth $cellFont] if {$oldElemWidth < $data($col-elemWidth) && $newElemWidth == $data($col-elemWidth)} { incr data($col-widestCount) } elseif {$oldElemWidth == $data($col-elemWidth) && $newElemWidth < $oldElemWidth && ................................................................................ switch -- $opt { -background - -foreground { set key [lindex $data(keyList) $row] set name $key,$col$opt if {[string compare $val ""] == 0} { if {[info exists data($name)]} { unset data($name) } } else { # # Configure the tag cell$opt-$val in the body text widget # set tag cell$opt-$val $w tag configure $tag $opt $val $w tag lower $tag disabled # # Save val in data($name) # set data($name) $val } if {!$data(isDisabled)} { updateColorsWhenIdle $win } } ................................................................................ # # Adjust the cell text and the image or window width # set text [lindex $item $col] if {[lindex $data(fmtCmdFlagList) $col]} { set text [formatElem $win $key $row $col $text] } if {[string match "*\t*" $text]} { set text [mapTabs $text] } set multiline [string match "*\n*" $text] set cellFont [getCellFont $win $key $col] set pixels [lindex $data(colList) [expr {2*$col}]] set workPixels $pixels if {$pixels == 0} { ;# convention: dynamic width set textSav $text getAuxData $win $key $col auxType auxWidthSav ................................................................................ # set pixels [lindex $data(colList) [expr {2*$col}]] set workPixels $pixels set text [lindex $item $col] if {[lindex $data(fmtCmdFlagList) $col]} { set text [formatElem $win $key $row $col $text] } if {[string match "*\t*" $text]} { set text [mapTabs $text] } set oldText $text set multiline [string match "*\n*" $text] set cellFont [getCellFont $win $key $col] if {$pixels == 0} { ;# convention: dynamic width set textSav $text getAuxData $win $key $col auxType auxWidthSav getIndentData $win $key $col indentWidthSav ................................................................................ # set pixels [lindex $data(colList) [expr {2*$col}]] set workPixels $pixels set text [lindex $item $col] if {[lindex $data(fmtCmdFlagList) $col]} { set text [formatElem $win $key $row $col $text] } if {[string match "*\t*" $text]} { set text [mapTabs $text] } set oldText $text set multiline [string match "*\n*" $text] set cellFont [getCellFont $win $key $col] if {$pixels == 0} { ;# convention: dynamic width set textSav $text getAuxData $win $key $col auxType auxWidthSav getIndentData $win $key $col indentWidthSav ................................................................................ } -selectbackground - -selectforeground { set key [lindex $data(keyList) $row] set name $key,$col$opt if {[string compare $val ""] == 0} { if {[info exists data($name)]} { unset data($name) } } else { # # Configure the tag cell$opt-$val in the body text widget # set tag cell$opt-$val set optTail [string range $opt 7 end] ;# remove the -select $w tag configure $tag -$optTail $val $w tag lower $tag disabled # # Save val in data($name) # set data($name) $val } if {!$data(isDisabled)} { ................................................................................ } set pixels [lindex $data(colList) [expr {2*$col}]] set text [lindex $item $col] if {[lindex $data(fmtCmdFlagList) $col]} { set text [formatElem $win $key $row $col $text] } if {[string match "*\t*" $text]} { set text [mapTabs $text] } set multiline [string match "*\n*" $text] set cellFont [getCellFont $win $key $col] if {$pixels == 0} { ;# convention: dynamic width if {$data($col-maxPixels) > 0} { if {$data($col-reqPixels) > $data($col-maxPixels)} { set pixels $data($col-maxPixels) } ................................................................................ set text $val set oldItem [lindex $data(itemList) $row] set key [lindex $oldItem end] set fmtCmdFlag [lindex $data(fmtCmdFlagList) $col] if {$fmtCmdFlag} { set text [formatElem $win $key $row $col $text] } if {[string match "*\t*" $text]} { set text [mapTabs $text] } set textSav $text set multiline [string match "*\n*" $text] set cellFont [getCellFont $win $key $col] if {$pixels == 0} { ;# convention: dynamic width getAuxData $win $key $col auxType auxWidthSav getIndentData $win $key $col indentWidthSav ................................................................................ adjustColumns $win {} 1 } } else { set oldText [lindex $oldItem $col] if {$fmtCmdFlag} { set oldText [formatElem $win $key $row $col $oldText] } if {[string match "*\t*" $oldText]} { set oldText [mapTabs $oldText] } set oldElemWidth [getElemWidth $win $oldText $auxWidth \ $indentWidth $cellFont] if {$oldElemWidth < $data($col-elemWidth) && $newElemWidth == $data($col-elemWidth)} { incr data($col-widestCount) } elseif {$oldElemWidth == $data($col-elemWidth) && $newElemWidth < $oldElemWidth && ................................................................................ # set pixels [lindex $data(colList) [expr {2*$col}]] set workPixels $pixels set text [lindex $item $col] if {[lindex $data(fmtCmdFlagList) $col]} { set text [formatElem $win $key $row $col $text] } if {[string match "*\t*" $text]} { set text [mapTabs $text] } set oldText $text set multiline [string match "*\n*" $text] set cellFont [getCellFont $win $key $col] if {$pixels == 0} { ;# convention: dynamic width set textSav $text getAuxData $win $key $col auxType auxWidthSav getIndentData $win $key $col indentWidthSav |
Changes to modules/tablelist/scripts/tablelistEdit.tcl.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ... 535 536 537 538 539 540 541 542 543 544 545 546 547 548 ... 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 .... 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 .... 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 .... 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 .... 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 .... 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 .... 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 .... 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 .... 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 .... 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 .... 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 .... 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 .... 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 .... 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 |
# # Structure of the module: # - Namespace initialization # - Public procedures related to interactive cell editing # - Private procedures implementing the interactive cell editing # - Private procedures used in bindings related to interactive cell editing # # Copyright (c) 2003-2012 Csaba Nemethi (E-mail: csaba.nemethi@t-online.de) #============================================================================== # # Namespace initialization # ======================== # ................................................................................ $name-isEntryLike 1 \ $name-focusWin {[%W component entry]} \ $name-reservedKeys {Left Right Up Down Control-p Control-n} \ ] return $name } #------------------------------------------------------------------------------ # tablelist::addOakleyCombobox # # Registers Bryan Oakley's combobox widget for interactive cell editing. #------------------------------------------------------------------------------ proc tablelist::addOakleyCombobox {{name combobox}} { ................................................................................ # of digits after the decimal point, with or without the -comma option, for # interactive cell editing. #------------------------------------------------------------------------------ proc tablelist::addFixedPointMentry {cnt1 cnt2 args} { # # Check the arguments cnt1 and cnt2 # if {[catch {format %d $cnt1}] != 0 || $cnt1 <= 0} { return -code error "expected positive integer but got \"$cnt1\"" } if {[catch {format %d $cnt2}] != 0 || $cnt2 <= 0} { return -code error "expected positive integer but got \"$cnt2\"" } # # Parse the remaining arguments (if any) # switch [llength $args] { ................................................................................ return -code error $result } catch {$w configure -highlightthickness 0} clearTakefocusOpt $w set class [winfo class $w] set isCheckbtn [string match "*Checkbutton" $class] set isMenubtn [string match "*Menubutton" $class] set isText [expr {[string compare $class "Text"] == 0}] set isMentry [expr {[string compare $class "Mentry"] == 0}] if {!$isCheckbtn && !$isMenubtn} { catch {$w configure -relief ridge} catch {$w configure -borderwidth 2} } if {$isText && $data($col-wrap) && $::tk_version >= 8.5} { $w configure -wrap word ................................................................................ # # Adjust the frame's height # if {$isText} { if {[string compare [$w cget -wrap] "none"] == 0 || $::tk_version < 8.5} { scan [$w index end-1c] "%d" numLines $w configure -height $numLines $f configure -height [winfo reqheight $w] } else { bind $w <Configure> { %W configure -height [%W count -displaylines 1.0 end] [winfo parent %W] configure -height [winfo reqheight %W] } } ................................................................................ return "" } set col $data(editCol) # # Invoke the command specified by the -editendcommand option if needed # if {$data(-forceeditendcommand) && [string compare $data(-editendcommand) ""] != 0} { uplevel #0 $data(-editendcommand) \ [list $win $row $col $data(origEditText)] } if {[winfo exists $data(bodyFr)]} { ................................................................................ break } } doCellConfig $row $col $win -text [lindex $item $col] } focus $data(body) set data(canceled) 1 event generate $win <<TablelistCellRestored>> updateViewWhenIdle $win return "" } #------------------------------------------------------------------------------ # tablelist::doFinishEditing ................................................................................ doCellConfig $row $col $win -text $text set result 1 } else { set result 0 } focus $data(body) event generate $win <<TablelistCellUpdated>> } updateViewWhenIdle $win return $result } #------------------------------------------------------------------------------ ................................................................................ } } #------------------------------------------------------------------------------ # tablelist::adjustTextHeight # # This procedure is an after-insert and after-delete callback asociated with a # text widget used for interactive cell editing. It sets the height of the # edit window to the number of lines currently contained in it. #------------------------------------------------------------------------------ proc tablelist::adjustTextHeight {w args} { if {$::tk_version >= 8.5} { # # Count the display lines (taking into account the line wraps) # set numLines [$w count -displaylines 1.0 end] } else { # # We can only count the logical lines (irrespective of wrapping) # scan [$w index end-1c] "%d" numLines } $w configure -height $numLines set path [wcb::pathname $w] [winfo parent $path] configure -height [winfo reqheight $path] } ................................................................................ # Saves some data of the edit window associated with the tablelist widget win. #------------------------------------------------------------------------------ proc tablelist::saveEditData win { upvar ::tablelist::ns${win}::data data set w $data(bodyFrEd) set entry $data(editFocus) set class [winfo class $w] set isText [expr {[string compare $class "Text"] == 0}] set isMentry [expr {[string compare $class "Mentry"] == 0}] # # Miscellaneous data # set name [getEditWindow $win $data(editRow) $data(editCol)] variable editWin ................................................................................ # win. #------------------------------------------------------------------------------ proc tablelist::restoreEditData win { upvar ::tablelist::ns${win}::data data set w $data(bodyFrEd) set entry $data(editFocus) set class [winfo class $w] set isText [expr {[string compare $class "Text"] == 0}] set isMentry [expr {[string compare $class "Mentry"] == 0}] set isIncrDateTimeWidget [regexp {^(Date.+|Time.+)$} $class] # # Miscellaneous data # set name [getEditWindow $win $data(editRow) $data(editCol)] ................................................................................ } } bind TablelistEdit <Control-i> { tablelist::insertChar %W "\t" } bind TablelistEdit <Control-j> { tablelist::insertChar %W "\n" } bind TablelistEdit <Escape> { tablelist::cancelEditing %W } foreach key {Return KP_Enter} { bind TablelistEdit <$key> { if {[string compare [winfo class %W] "Text"] == 0} { tablelist::insertChar %W "\n" } else { tablelist::finishEditing %W } } bind TablelistEdit <Control-$key> { tablelist::finishEditing %W ................................................................................ # tablelist::insertChar # # Inserts the string str ("\t" or "\n") into the entry-like widget w at the # point of the insertion cursor. #------------------------------------------------------------------------------ proc tablelist::insertChar {w str} { set class [winfo class $w] if {[string compare $class "Text"] == 0} { if {[string compare $str "\n"] == 0} { eval [strMap {"%W" "$w"} [bind Text <Return>]] } else { eval [strMap {"%W" "$w"} [bind Text <Control-i>]] } return -code break "" } elseif {[regexp {^(T?Entry|TCombobox|T?Spinbox)$} $class]} { ................................................................................ set row $data(editRow) set col $data(editCol) set cmd condChangeSelection } else { foreach {row col} $args {} set cmd changeSelection } set oldRow $row set oldCol $col while 1 { incr col $amount if {$col < 0} { ................................................................................ } set win [getTablelistPath $w] upvar ::tablelist::ns${win}::data data set row $data(editRow) set col $data(editCol) while 1 { incr col $amount if {$col < 0 || $col > $data(lastCol)} { return -code break "" } elseif {!$data($col-hide) && [isCellEditable $win $row $col]} { doEditCell $win $row $col 0 condChangeSelection ................................................................................ # Moves the edit window into the last or first editable cell that is located in # the specified column and has a row index less/greater than the given one, if # there is such a cell. #------------------------------------------------------------------------------ proc tablelist::goToPrevNextLine {w amount row col cmd} { set win [getTablelistPath $w] upvar ::tablelist::ns${win}::data data while 1 { incr row $amount if {$row < 0 || $row > $data(lastRow)} { return 0 } elseif {[isRowViewable $win $row] && [isCellEditable $win $row $col]} { |
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | > | > > > > > | | > > > | | | | > | > | > | > > > > > > > > > > > > > |
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ... 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 ... 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 .... 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 .... 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 .... 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 .... 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 .... 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 .... 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 .... 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 .... 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 .... 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 .... 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 .... 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 .... 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 .... 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 |
# # Structure of the module: # - Namespace initialization # - Public procedures related to interactive cell editing # - Private procedures implementing the interactive cell editing # - Private procedures used in bindings related to interactive cell editing # # Copyright (c) 2003-2013 Csaba Nemethi (E-mail: csaba.nemethi@t-online.de) #============================================================================== # # Namespace initialization # ======================== # ................................................................................ $name-isEntryLike 1 \ $name-focusWin {[%W component entry]} \ $name-reservedKeys {Left Right Up Down Control-p Control-n} \ ] return $name } #------------------------------------------------------------------------------ # tablelist::addCtext # # Registers the ctext widget for interactive cell editing. #------------------------------------------------------------------------------ proc tablelist::addCtext {{name ctext}} { checkEditWinName $name array set ::tablelist::editWin [list \ $name-creationCmd "ctext %W -padx 2 -pady 2 -wrap none" \ $name-putValueCmd "%W delete 1.0 end; %W insert 1.0 %T" \ $name-getValueCmd "%W get 1.0 end-1c" \ $name-putTextCmd "%W delete 1.0 end; %W insert 1.0 %T" \ $name-getTextCmd "%W get 1.0 end-1c" \ $name-putListCmd "" \ $name-getListCmd "" \ $name-selectCmd "" \ $name-invokeCmd "" \ $name-fontOpt -font \ $name-useFormat 1 \ $name-useReqWidth 0 \ $name-usePadX 0 \ $name-isEntryLike 1 \ $name-focusWin %W.t \ $name-reservedKeys {Left Right Up Down Prior Next Control-Home Control-End Meta-b Meta-f Control-p Control-n Meta-less Meta-greater} \ ] return $name } #------------------------------------------------------------------------------ # tablelist::addOakleyCombobox # # Registers Bryan Oakley's combobox widget for interactive cell editing. #------------------------------------------------------------------------------ proc tablelist::addOakleyCombobox {{name combobox}} { ................................................................................ # of digits after the decimal point, with or without the -comma option, for # interactive cell editing. #------------------------------------------------------------------------------ proc tablelist::addFixedPointMentry {cnt1 cnt2 args} { # # Check the arguments cnt1 and cnt2 # if {![isInteger $cnt1] || $cnt1 <= 0} { return -code error "expected positive integer but got \"$cnt1\"" } if {![isInteger $cnt2] || $cnt2 <= 0} { return -code error "expected positive integer but got \"$cnt2\"" } # # Parse the remaining arguments (if any) # switch [llength $args] { ................................................................................ return -code error $result } catch {$w configure -highlightthickness 0} clearTakefocusOpt $w set class [winfo class $w] set isCheckbtn [string match "*Checkbutton" $class] set isMenubtn [string match "*Menubutton" $class] set isText [expr {[string compare $class "Text"] == 0 || [string compare $class "Ctext"] == 0}] set isMentry [expr {[string compare $class "Mentry"] == 0}] if {!$isCheckbtn && !$isMenubtn} { catch {$w configure -relief ridge} catch {$w configure -borderwidth 2} } if {$isText && $data($col-wrap) && $::tk_version >= 8.5} { $w configure -wrap word ................................................................................ # # Adjust the frame's height # if {$isText} { if {[string compare [$w cget -wrap] "none"] == 0 || $::tk_version < 8.5} { set numLines [expr {int([$w index end-1c])}] $w configure -height $numLines update idletasks ;# needed for ctext if {![array exists ::tablelist::ns${win}::data]} { return "" } $f configure -height [winfo reqheight $w] } else { bind $w <Configure> { %W configure -height [%W count -displaylines 1.0 end] [winfo parent %W] configure -height [winfo reqheight %W] } } ................................................................................ return "" } set col $data(editCol) # # Invoke the command specified by the -editendcommand option if needed # set data(canceled) 1 if {$data(-forceeditendcommand) && [string compare $data(-editendcommand) ""] != 0} { uplevel #0 $data(-editendcommand) \ [list $win $row $col $data(origEditText)] } if {[winfo exists $data(bodyFr)]} { ................................................................................ break } } doCellConfig $row $col $win -text [lindex $item $col] } focus $data(body) set userData [list $row $col] genVirtualEvent $win <<TablelistCellRestored>> $userData updateViewWhenIdle $win return "" } #------------------------------------------------------------------------------ # tablelist::doFinishEditing ................................................................................ doCellConfig $row $col $win -text $text set result 1 } else { set result 0 } focus $data(body) set userData [list $row $col] genVirtualEvent $win <<TablelistCellUpdated>> $userData } updateViewWhenIdle $win return $result } #------------------------------------------------------------------------------ ................................................................................ } } #------------------------------------------------------------------------------ # tablelist::adjustTextHeight # # This procedure is an after-insert and after-delete callback asociated with a # (c)text widget used for interactive cell editing. It sets the height of the # edit window to the number of lines currently contained in it. #------------------------------------------------------------------------------ proc tablelist::adjustTextHeight {w args} { if {$::tk_version >= 8.5} { # # Count the display lines (taking into account the line wraps) # set numLines [$w count -displaylines 1.0 end] } else { # # We can only count the logical lines (irrespective of wrapping) # set numLines [expr {int([$w index end-1c])}] } $w configure -height $numLines set path [wcb::pathname $w] [winfo parent $path] configure -height [winfo reqheight $path] } ................................................................................ # Saves some data of the edit window associated with the tablelist widget win. #------------------------------------------------------------------------------ proc tablelist::saveEditData win { upvar ::tablelist::ns${win}::data data set w $data(bodyFrEd) set entry $data(editFocus) set class [winfo class $w] set isText [expr {[string compare $class "Text"] == 0 || [string compare $class "Ctext"] == 0}] set isMentry [expr {[string compare $class "Mentry"] == 0}] # # Miscellaneous data # set name [getEditWindow $win $data(editRow) $data(editCol)] variable editWin ................................................................................ # win. #------------------------------------------------------------------------------ proc tablelist::restoreEditData win { upvar ::tablelist::ns${win}::data data set w $data(bodyFrEd) set entry $data(editFocus) set class [winfo class $w] set isText [expr {[string compare $class "Text"] == 0 || [string compare $class "Ctext"] == 0}] set isMentry [expr {[string compare $class "Mentry"] == 0}] set isIncrDateTimeWidget [regexp {^(Date.+|Time.+)$} $class] # # Miscellaneous data # set name [getEditWindow $win $data(editRow) $data(editCol)] ................................................................................ } } bind TablelistEdit <Control-i> { tablelist::insertChar %W "\t" } bind TablelistEdit <Control-j> { tablelist::insertChar %W "\n" } bind TablelistEdit <Escape> { tablelist::cancelEditing %W } foreach key {Return KP_Enter} { bind TablelistEdit <$key> { if {[string compare [winfo class %W] "Text"] == 0 || [string compare [winfo class %W] "Ctext"] == 0} { tablelist::insertChar %W "\n" } else { tablelist::finishEditing %W } } bind TablelistEdit <Control-$key> { tablelist::finishEditing %W ................................................................................ # tablelist::insertChar # # Inserts the string str ("\t" or "\n") into the entry-like widget w at the # point of the insertion cursor. #------------------------------------------------------------------------------ proc tablelist::insertChar {w str} { set class [winfo class $w] if {[string compare $class "Text"] == 0 || [string compare $class "Ctext"] == 0} { if {[string compare $str "\n"] == 0} { eval [strMap {"%W" "$w"} [bind Text <Return>]] } else { eval [strMap {"%W" "$w"} [bind Text <Control-i>]] } return -code break "" } elseif {[regexp {^(T?Entry|TCombobox|T?Spinbox)$} $class]} { ................................................................................ set row $data(editRow) set col $data(editCol) set cmd condChangeSelection } else { foreach {row col} $args {} set cmd changeSelection } if {![doFinishEditing $win]} { return "" } set oldRow $row set oldCol $col while 1 { incr col $amount if {$col < 0} { ................................................................................ } set win [getTablelistPath $w] upvar ::tablelist::ns${win}::data data set row $data(editRow) set col $data(editCol) if {![doFinishEditing $win]} { return "" } while 1 { incr col $amount if {$col < 0 || $col > $data(lastCol)} { return -code break "" } elseif {!$data($col-hide) && [isCellEditable $win $row $col]} { doEditCell $win $row $col 0 condChangeSelection ................................................................................ # Moves the edit window into the last or first editable cell that is located in # the specified column and has a row index less/greater than the given one, if # there is such a cell. #------------------------------------------------------------------------------ proc tablelist::goToPrevNextLine {w amount row col cmd} { set win [getTablelistPath $w] upvar ::tablelist::ns${win}::data data if {![doFinishEditing $win]} { return "" } while 1 { incr row $amount if {$row < 0 || $row > $data(lastRow)} { return 0 } elseif {[isRowViewable $win $row] && [isCellEditable $win $row $col]} { |
Changes to modules/tablelist/scripts/tablelistImages.tcl.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
#==============================================================================
# Contains procedures that create various bitmap and photo images. The
# argument w specifies a canvas displaying a sort arrow, while the argument win
# stands for a tablelist widget.
#
# Copyright (c) 2006-2012 Csaba Nemethi (E-mail: csaba.nemethi@t-online.de)
#==============================================================================
#------------------------------------------------------------------------------
# tablelist::flat6x4Arrows
#------------------------------------------------------------------------------
proc tablelist::flat6x4Arrows w {
image create bitmap triangleUp$w -data "
|
| |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
#==============================================================================
# Contains procedures that create various bitmap and photo images. The
# argument w specifies a canvas displaying a sort arrow, while the argument win
# stands for a tablelist widget.
#
# Copyright (c) 2006-2013 Csaba Nemethi (E-mail: csaba.nemethi@t-online.de)
#==============================================================================
#------------------------------------------------------------------------------
# tablelist::flat6x4Arrows
#------------------------------------------------------------------------------
proc tablelist::flat6x4Arrows w {
image create bitmap triangleUp$w -data "
|
Changes to modules/tablelist/scripts/tablelistMove.tcl.
1
2
3
4
5
6
7
8
9
10
11
...
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
#============================================================================== # Contains the implementation of the tablelist move and movecolumn subcommands. # # Copyright (c) 2003-2012 Csaba Nemethi (E-mail: csaba.nemethi@t-online.de) #============================================================================== #------------------------------------------------------------------------------ # tablelist::moveRow # # Processes the 1st form of the tablelist move subcommand. #------------------------------------------------------------------------------ ................................................................................ set targetLine [expr {$target1 + 1}] $w insert $targetLine.0 "\n" set snipStr $data(-snipstring) set dispItem [lrange $sourceItem 0 $data(lastCol)] if {$data(hasFmtCmds)} { set dispItem [formatItem $win $sourceKey $source $dispItem] } set col 0 foreach text [strToDispStr $dispItem] \ colTags $data(colTagsList) \ {pixels alignment} $data(colList) { if {$data($col-hide) && !$canElide} { incr col continue } # # Build the list of tags to be applied to the cell # set cellFont [getCellFont $win $sourceKey $col] set cellTags $colTags foreach opt {-background -foreground -font} { if {[info exists data($sourceKey,$col$opt)]} { lappend cellTags cell$opt-$data($sourceKey,$col$opt) } } # # Append the text and the labels or window (if # any) to the target line of the body text widget # appendComplexElem $win $sourceKey $source $col $text $pixels \ $alignment $snipStr $cellFont $cellTags $targetLine incr col } foreach opt {-background -foreground -font} { if {[info exists data($sourceKey$opt)]} { $w tag add row$opt-$data($sourceKey$opt) \ $targetLine.0 $targetLine.end } } if {[info exists data($sourceKey-elide)]} { $w tag add elidedRow $targetLine.0 $targetLine.end+1c } if {[info exists data($sourceKey-hide)]} { $w tag add hiddenRow $targetLine.0 $targetLine.end+1c } |
|
>
>
>
<
|
<
|
|
<
<
|
<
|
<
|
1
2
3
4
5
6
7
8
9
10
11
...
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
#============================================================================== # Contains the implementation of the tablelist move and movecolumn subcommands. # # Copyright (c) 2003-2013 Csaba Nemethi (E-mail: csaba.nemethi@t-online.de) #============================================================================== #------------------------------------------------------------------------------ # tablelist::moveRow # # Processes the 1st form of the tablelist move subcommand. #------------------------------------------------------------------------------ ................................................................................ set targetLine [expr {$target1 + 1}] $w insert $targetLine.0 "\n" set snipStr $data(-snipstring) set dispItem [lrange $sourceItem 0 $data(lastCol)] if {$data(hasFmtCmds)} { set dispItem [formatItem $win $sourceKey $source $dispItem] } if {[string match "*\t*" $dispItem]} { set dispItem [mapTabs $dispItem] } set col 0 foreach text $dispItem colTags $data(colTagsList) \ {pixels alignment} $data(colList) { if {$data($col-hide) && !$canElide} { incr col continue } # # Build the list of tags to be applied to the cell # set cellFont [getCellFont $win $sourceKey $col] set cellTags $colTags if {[info exists data($sourceKey,$col-font)]} { lappend cellTags cell-font-$data($sourceKey,$col-font) } # # Append the text and the labels or window (if # any) to the target line of the body text widget # appendComplexElem $win $sourceKey $source $col $text $pixels \ $alignment $snipStr $cellFont $cellTags $targetLine incr col } if {[info exists data($sourceKey-font)]} { $w tag add row-font-$data($sourceKey-font) $targetLine.0 $targetLine.end } if {[info exists data($sourceKey-elide)]} { $w tag add elidedRow $targetLine.0 $targetLine.end+1c } if {[info exists data($sourceKey-hide)]} { $w tag add hiddenRow $targetLine.0 $targetLine.end+1c } |
Changes to modules/tablelist/scripts/tablelistSort.tcl.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 .. 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 ... 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 ... 382 383 384 385 386 387 388 389 390 391 392 393 394 395 ... 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 ... 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 ... 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 ... 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 ... 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 |
# tablelist::addToSortColumns commands, as well as of the tablelist sort, # sortbycolumn, and sortbycolumnlist subcommands. # # Structure of the module: # - Public procedures related to sorting # - Private procedures implementing the sorting # # Copyright (c) 2000-2012 Csaba Nemethi (E-mail: csaba.nemethi@t-online.de) #============================================================================== # # Public procedures related to sorting # ==================================== # ................................................................................ set sortOrder increasing } # # Sort the widget's contents based on the given column # if {[catch {::$win sortbycolumn $col -$sortOrder} result] == 0} { event generate $win <<TablelistColumnSorted>> return $sortOrder } else { return -code error $result } } #------------------------------------------------------------------------------ ................................................................................ # # Sort the widget's contents according to the # modified lists of sort columns and orders # if {[catch {::$win sortbycolumnlist $sortColList $sortOrderList} result] == 0} { event generate $win <<TablelistColumnsSorted>> return $sortOrder } else { return -code error $result } } # ................................................................................ set key [lindex $item end] lappend descKeyList $key set data($key-row) $row set dispItem [lrange $item 0 $data(lastCol)] if {$data(hasFmtCmds)} { set dispItem [formatItem $win $key $row $dispItem] } # # Clip the elements if necessary and # insert them with the corresponding tags # if {$rowTagRefCount == 0} { set hasRowFont 0 ................................................................................ } else { set hasRowFont [info exists data($key-font)] } set col 0 if {$isSimple} { set insertArgs {} set multilineData {} foreach text [strToDispStr $dispItem] \ colFont $data(colFontList) \ colTags $data(colTagsList) \ {pixels alignment} $data(colList) { if {$data($col-hide) && !$canElide} { incr col continue } ................................................................................ set cellFont $colFont } set cellTags $colTags if {$cellTagRefCount != 0} { if {[info exists data($key,$col-font)]} { set cellFont $data($key,$col-font) lappend cellTags cell-font-$data($key,$col-font) } foreach opt {-background -foreground} { if {[info exists data($key,$col$opt)]} { lappend cellTags cell$opt-$data($key,$col$opt) } } } # # Clip the element if necessary # set multiline [string match "*\n*" $text] ................................................................................ findTabs $win $line $col $col tabIdx1 tabIdx2 set msgScript [list ::tablelist::displayText $win $key \ $col $text $font $pixels $alignment] $w window create $tabIdx2 -pady $padY -create $msgScript } } else { foreach text [strToDispStr $dispItem] \ colFont $data(colFontList) \ colTags $data(colTagsList) \ {pixels alignment} $data(colList) { if {$data($col-hide) && !$canElide} { incr col continue } ................................................................................ set cellFont $colFont } set cellTags $colTags if {$cellTagRefCount != 0} { if {[info exists data($key,$col-font)]} { set cellFont $data($key,$col-font) lappend cellTags cell-font-$data($key,$col-font) } foreach opt {-background -foreground} { if {[info exists data($key,$col$opt)]} { lappend cellTags cell$opt-$data($key,$col$opt) } } } # # Insert the text and the label or window # (if any) into the body text widget # ................................................................................ $alignment $snipStr $cellFont $cellTags $line incr col } } if {$rowTagRefCount != 0} { foreach opt {-background -foreground -font} { if {[info exists data($key$opt)]} { $w tag add row$opt-$data($key$opt) $line.0 $line.end } } } if {[info exists data($key-elide)]} { $w tag add elidedRow $line.0 $line.end+1c } if {[info exists data($key-hide)]} { |
| > | > > | > > > > | < < < < < | < < < < < < | < < > |
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 .. 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 ... 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 ... 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 ... 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 ... 425 426 427 428 429 430 431 432 433 434 435 436 437 438 ... 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 ... 510 511 512 513 514 515 516 517 518 519 520 521 522 523 ... 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 |
# tablelist::addToSortColumns commands, as well as of the tablelist sort, # sortbycolumn, and sortbycolumnlist subcommands. # # Structure of the module: # - Public procedures related to sorting # - Private procedures implementing the sorting # # Copyright (c) 2000-2013 Csaba Nemethi (E-mail: csaba.nemethi@t-online.de) #============================================================================== # # Public procedures related to sorting # ==================================== # ................................................................................ set sortOrder increasing } # # Sort the widget's contents based on the given column # if {[catch {::$win sortbycolumn $col -$sortOrder} result] == 0} { set userData [list $col $sortOrder] genVirtualEvent $win <<TablelistColumnSorted>> $userData return $sortOrder } else { return -code error $result } } #------------------------------------------------------------------------------ ................................................................................ # # Sort the widget's contents according to the # modified lists of sort columns and orders # if {[catch {::$win sortbycolumnlist $sortColList $sortOrderList} result] == 0} { set userData [list $sortColList $sortOrderList] genVirtualEvent $win <<TablelistColumnsSorted>> $userData return $sortOrder } else { return -code error $result } } # ................................................................................ set key [lindex $item end] lappend descKeyList $key set data($key-row) $row set dispItem [lrange $item 0 $data(lastCol)] if {$data(hasFmtCmds)} { set dispItem [formatItem $win $key $row $dispItem] } if {[string match "*\t*" $dispItem]} { set dispItem [mapTabs $dispItem] } # # Clip the elements if necessary and # insert them with the corresponding tags # if {$rowTagRefCount == 0} { set hasRowFont 0 ................................................................................ } else { set hasRowFont [info exists data($key-font)] } set col 0 if {$isSimple} { set insertArgs {} set multilineData {} foreach text $dispItem \ colFont $data(colFontList) \ colTags $data(colTagsList) \ {pixels alignment} $data(colList) { if {$data($col-hide) && !$canElide} { incr col continue } ................................................................................ set cellFont $colFont } set cellTags $colTags if {$cellTagRefCount != 0} { if {[info exists data($key,$col-font)]} { set cellFont $data($key,$col-font) lappend cellTags cell-font-$data($key,$col-font) } } # # Clip the element if necessary # set multiline [string match "*\n*" $text] ................................................................................ findTabs $win $line $col $col tabIdx1 tabIdx2 set msgScript [list ::tablelist::displayText $win $key \ $col $text $font $pixels $alignment] $w window create $tabIdx2 -pady $padY -create $msgScript } } else { foreach text $dispItem \ colFont $data(colFontList) \ colTags $data(colTagsList) \ {pixels alignment} $data(colList) { if {$data($col-hide) && !$canElide} { incr col continue } ................................................................................ set cellFont $colFont } set cellTags $colTags if {$cellTagRefCount != 0} { if {[info exists data($key,$col-font)]} { set cellFont $data($key,$col-font) lappend cellTags cell-font-$data($key,$col-font) } } # # Insert the text and the label or window # (if any) into the body text widget # ................................................................................ $alignment $snipStr $cellFont $cellTags $line incr col } } if {$rowTagRefCount != 0} { if {[info exists data($key-font)]} { $w tag add row-font-$data($key-font) $line.0 $line.end } } if {[info exists data($key-elide)]} { $w tag add elidedRow $line.0 $line.end+1c } if {[info exists data($key-hide)]} { |
Changes to modules/tablelist/scripts/tablelistThemes.tcl.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
#
# Structure of the module:
# - Public procedures related to tile themes
# - Private procedures related to tile themes
# - Private procedures performing RGB <-> HSV conversions
# - Private procedures related to global KDE configuration options
#
# Copyright (c) 2005-2012 Csaba Nemethi (E-mail: csaba.nemethi@t-online.de)
#==============================================================================
#
# Public procedures related to tile themes
# ========================================
#
|
| |
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
#
# Structure of the module:
# - Public procedures related to tile themes
# - Private procedures related to tile themes
# - Private procedures performing RGB <-> HSV conversions
# - Private procedures related to global KDE configuration options
#
# Copyright (c) 2005-2013 Csaba Nemethi (E-mail: csaba.nemethi@t-online.de)
#==============================================================================
#
# Public procedures related to tile themes
# ========================================
#
|
Changes to modules/tablelist/scripts/tablelistUtil.tcl.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 .. 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 ... 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 ... 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 ... 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 .... 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 .... 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 .... 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 .... 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 .... 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 .... 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 .... 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 .... 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 .... 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 .... 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 .... 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 .... 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 |
#============================================================================== # Contains private utility procedures for tablelist widgets. # # Structure of the module: # - Namespace initialization # - Private utility procedures # # Copyright (c) 2000-2012 Csaba Nemethi (E-mail: csaba.nemethi@t-online.de) #============================================================================== # # Namespace initialization # ======================== # ................................................................................ # tablelist. checkRange must be a boolean value: if true, it is additionally # checked whether the numerical value corresponding to idx is within the # allowed range. #------------------------------------------------------------------------------ proc tablelist::rowIndex {win idx endIsSize {checkRange 0}} { upvar ::tablelist::ns${win}::data data if {[catch {format "%d" $idx} index] == 0} { # nothing } elseif {[string first $idx "end"] == 0} { if {$endIsSize} { set index $data(itemCount) } else { set index $data(lastRow) } } elseif {[string first $idx "top"] == 0} { ................................................................................ # error. checkRange must be a boolean value: if true, it is additionally # checked whether the numerical value corresponding to idx is within the # allowed range. #------------------------------------------------------------------------------ proc tablelist::colIndex {win idx checkRange {decrX 1}} { upvar ::tablelist::ns${win}::data data if {[catch {format "%d" $idx} index] == 0} { # nothing } elseif {[string first $idx "end"] == 0} { set index $data(lastCol) } elseif {[string first $idx "left"] == 0} { return [colIndex $win @0,0 $checkRange 0] } elseif {[string first $idx "right"] == 0} { return [colIndex $win @$data(rightX),0 $checkRange 0] } elseif {[string first $idx "active"] == 0 && [string length $idx] >= 2} { ................................................................................ # # Returns the row of the child item identified by childIdx of the node given by # parentKey within the tablelist widget win. #------------------------------------------------------------------------------ proc tablelist::nodeRow {win parentKey childIdx} { upvar ::tablelist::ns${win}::data data if {[catch {format "%d" $childIdx} idx] == 0} { if {$idx < [llength $data($parentKey-children)]} { set childKey [lindex $data($parentKey-children) $idx] return [keyToRow $win $childKey] } else { return [expr {[keyToRow $win $parentKey] + [descCount $win $parentKey] + 1}] } } elseif {[string first $childIdx "end"] == 0} { return [expr {[keyToRow $win $parentKey] + ................................................................................ } # # Remove the elements with names of the form k*,$col-* # foreach name [array names data k*,$col-*] { unset data($name) if {[string match "k*,$col-\[bf\]*" $name]} { incr data(cellTagRefCount) -1 } elseif {[string match "k*,$col-image" $name]} { incr data(imgCount) -1 } elseif {[string match "k*,$col-window" $name]} { incr data(winCount) -1 } elseif {[string match "k*,$col-indent" $name]} { incr data(indentCount) -1 ................................................................................ lappend data(colFontList) $data($col-font) lappend tagNames col-font-$data($col-font) set data(hasColTags) 1 } else { lappend data(colFontList) $widgetFont } foreach opt {-background -foreground} { if {[info exists data($col$opt)]} { lappend tagNames col$opt-$data($col$opt) set data(hasColTags) 1 } } if {$viewable && $data($col-hide) && $canElide} { lappend tagNames hiddenCol set data(hasColTags) 1 } lappend data(colTagsList) $tagNames } ................................................................................ # # Get the column alignment # set alignment left if {[incr n] < $argCount} { set next [lindex $columns $n] if {[catch {format "%d" $next}] == 0} { ;# integer check incr n -1 } else { set alignment [mwutil::fullOpt "alignment" $next $alignments] } } # ................................................................................ continue } set text [lindex $item $col] if {$fmtCmdFlag} { set text [formatElem $win $key $row $col $text] } set text [strToDispStr $text] getAuxData $win $key $col auxType auxWidth getIndentData $win $key $col indentWidth set cellFont [getCellFont $win $key $col] set elemWidth [getElemWidth $win $text $auxWidth $indentWidth $cellFont] if {$elemWidth == $data($col-elemWidth)} { incr data($col-widestCount) } elseif {$elemWidth > $data($col-elemWidth)} { ................................................................................ set updateAll 0 } if {$data(itemCount) == 0 || $data(colCount) == 0} { return "" } if {$updateAll && $data(isDisabled)} { $w tag add disabled $fromTextIdx $toTextIdx } set hasExpCollCtrlSelImgs [expr {$::tk_version >= 8.3 && [info exists tablelist::$data(-treestyle)_collapsedSelImg]}] foreach {dummy path textIdx} [$w dump -window $fromTextIdx $toTextIdx] { if {[string compare $path ""] == 0} { ................................................................................ incr col continue } if {$fmtCmdFlag} { set text [formatElem $win $key $row $col $text] } set text [strToDispStr $text] # # Build the list of tags to be applied to the cell # if {$hasRowFont} { set cellFont $data($key-font) } else { ................................................................................ set cellFont $colFont } set cellTags $colTags if {$cellTagRefCount != 0} { if {[info exists data($key,$col-font)]} { set cellFont $data($key,$col-font) lappend cellTags cell-font-$data($key,$col-font) } foreach opt {-background -foreground} { if {[info exists data($key,$col$opt)]} { lappend cellTags cell$opt-$data($key,$col$opt) } } } # # Clip the element if necessary # set multiline [string match "*\n*" $text] ................................................................................ incr col continue } if {$fmtCmdFlag} { set text [formatElem $win $key $row $col $text] } set text [strToDispStr $text] # # Build the list of tags to be applied to the cell # if {$hasRowFont} { set cellFont $data($key-font) } else { ................................................................................ set cellFont $colFont } set cellTags $colTags if {$cellTagRefCount != 0} { if {[info exists data($key,$col-font)]} { set cellFont $data($key,$col-font) lappend cellTags cell-font-$data($key,$col-font) } foreach opt {-background -foreground} { if {[info exists data($key,$col$opt)]} { lappend cellTags cell$opt-$data($key,$col$opt) } } } # # Insert the text and the label or window # (if any) into the body text widget # ................................................................................ $alignment $snipStr $cellFont $cellTags $line incr col } } if {$rowTagRefCount != 0} { foreach opt {-background -foreground -font} { if {[info exists data($key$opt)]} { $w tag add row$opt-$data($key$opt) $line.0 $line.end } } } if {[info exists data($key-elide)]} { $w tag add elidedRow $line.0 $line.end+1c } if {[info exists data($key-hide)]} { ................................................................................ # # Format the item # set dispItem [lrange $item 0 $data(lastCol)] if {$data(hasFmtCmds)} { set dispItem [formatItem $win $key $row $dispItem] } set tabIdx1 $line.0 set col 0 foreach text [strToDispStr $dispItem] \ colFont $data(colFontList) \ colTags $data(colTagsList) \ {pixels alignment} $data(colList) { if {$data($col-hide) && !$canElide} { incr col continue } set tabIdx2 [$w search $elide "\t" $tabIdx1+1c $line.end] if {[string compare $text ""] == 0 || [string compare [$w get $tabIdx1+1c $tabIdx2] ""] != 0 || ($row == $data(editRow) && $col == $data(editCol))} { set tabIdx1 [$w index $tabIdx2+1c] incr col continue } ................................................................................ } } if {$pixels != 0} { incr pixels $data($col-delta) } # # Adjust the cell text and the image or window width # set multiline [string match "*\n*" $text] set aux [getAuxData $win $key $col auxType auxWidth $pixels] set indent [getIndentData $win $key $col indentWidth] set maxTextWidth $pixels if {[info exists data($key,$col-font)]} { set cellFont $data($key,$col-font) } elseif {[info exists data($key-font)]} { set cellFont $data($key-font) } else { ................................................................................ # # Adjust the cell text and the image or window width # set text [lindex $item $col] if {$fmtCmdFlag} { set text [formatElem $win $key $row $col $text] } set text [strToDispStr $text] set multiline [string match "*\n*" $text] set aux [getAuxData $win $key $col auxType auxWidth $pixels] set indent [getIndentData $win $key $col indentWidth] set maxTextWidth $pixels if {[info exists data($key,$col-font)]} { set cellFont $data($key,$col-font) } elseif {[info exists data($key-font)]} { |
| | | | | | | | | < < < < < < < | > | > > | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > < < < < < > | > < < < < < < | < < > > > > | > > > > > > > > > > > > > > | < > | > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 .. 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 ... 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 ... 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 ... 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 .... 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 .... 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 .... 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 .... 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 .... 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 .... 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 .... 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 .... 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 .... 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 .... 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 .... 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 .... 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 |
#============================================================================== # Contains private utility procedures for tablelist widgets. # # Structure of the module: # - Namespace initialization # - Private utility procedures # # Copyright (c) 2000-2013 Csaba Nemethi (E-mail: csaba.nemethi@t-online.de) #============================================================================== # # Namespace initialization # ======================== # ................................................................................ # tablelist. checkRange must be a boolean value: if true, it is additionally # checked whether the numerical value corresponding to idx is within the # allowed range. #------------------------------------------------------------------------------ proc tablelist::rowIndex {win idx endIsSize {checkRange 0}} { upvar ::tablelist::ns${win}::data data if {[isInteger $idx]} { set index [expr {int($idx)}] } elseif {[string first $idx "end"] == 0} { if {$endIsSize} { set index $data(itemCount) } else { set index $data(lastRow) } } elseif {[string first $idx "top"] == 0} { ................................................................................ # error. checkRange must be a boolean value: if true, it is additionally # checked whether the numerical value corresponding to idx is within the # allowed range. #------------------------------------------------------------------------------ proc tablelist::colIndex {win idx checkRange {decrX 1}} { upvar ::tablelist::ns${win}::data data if {[isInteger $idx]} { set index [expr {int($idx)}] } elseif {[string first $idx "end"] == 0} { set index $data(lastCol) } elseif {[string first $idx "left"] == 0} { return [colIndex $win @0,0 $checkRange 0] } elseif {[string first $idx "right"] == 0} { return [colIndex $win @$data(rightX),0 $checkRange 0] } elseif {[string first $idx "active"] == 0 && [string length $idx] >= 2} { ................................................................................ # # Returns the row of the child item identified by childIdx of the node given by # parentKey within the tablelist widget win. #------------------------------------------------------------------------------ proc tablelist::nodeRow {win parentKey childIdx} { upvar ::tablelist::ns${win}::data data if {[isInteger $childIdx]} { if {$childIdx < [llength $data($parentKey-children)]} { set childKey [lindex $data($parentKey-children) $childIdx] return [keyToRow $win $childKey] } else { return [expr {[keyToRow $win $parentKey] + [descCount $win $parentKey] + 1}] } } elseif {[string first $childIdx "end"] == 0} { return [expr {[keyToRow $win $parentKey] + ................................................................................ } # # Remove the elements with names of the form k*,$col-* # foreach name [array names data k*,$col-*] { unset data($name) if {[string match "k*,$col-font" $name]} { incr data(cellTagRefCount) -1 } elseif {[string match "k*,$col-image" $name]} { incr data(imgCount) -1 } elseif {[string match "k*,$col-window" $name]} { incr data(winCount) -1 } elseif {[string match "k*,$col-indent" $name]} { incr data(indentCount) -1 ................................................................................ lappend data(colFontList) $data($col-font) lappend tagNames col-font-$data($col-font) set data(hasColTags) 1 } else { lappend data(colFontList) $widgetFont } if {$viewable && $data($col-hide) && $canElide} { lappend tagNames hiddenCol set data(hasColTags) 1 } lappend data(colTagsList) $tagNames } ................................................................................ # # Get the column alignment # set alignment left if {[incr n] < $argCount} { set next [lindex $columns $n] if {[isInteger $next]} { incr n -1 } else { set alignment [mwutil::fullOpt "alignment" $next $alignments] } } # ................................................................................ continue } set text [lindex $item $col] if {$fmtCmdFlag} { set text [formatElem $win $key $row $col $text] } if {[string match "*\t*" $text]} { set text [mapTabs $text] } getAuxData $win $key $col auxType auxWidth getIndentData $win $key $col indentWidth set cellFont [getCellFont $win $key $col] set elemWidth [getElemWidth $win $text $auxWidth $indentWidth $cellFont] if {$elemWidth == $data($col-elemWidth)} { incr data($col-widestCount) } elseif {$elemWidth > $data($col-elemWidth)} { ................................................................................ set updateAll 0 } if {$data(itemCount) == 0 || $data(colCount) == 0} { return "" } if {$updateAll} { if {$data(isDisabled)} { $w tag add disabled $fromTextIdx $toTextIdx } set topLine [expr {int([$w index @0,0])}] set btmLine [expr {int([$w index @0,$data(btmY)])}] for {set line $topLine; set row [expr {$line - 1}]} \ {$line <= $btmLine} {set row $line; incr line} { set key [lindex $data(keyList) $row] if {[info exists data($key-elide)] || [info exists data($key-hide)]} { continue } # # Handle the -(select)background and -(select)foreground # column, row, and cell configuration options in this row # set textIdx1 $line.0 for {set col 0} {$col < $data(colCount)} {incr col} { if {$data($col-hide) && !$canElide} { continue } set tabIdx2 [$w search -elide "\t" $textIdx1+1c $line.end] set selected [expr \ {[lsearch -exact [$w tag names $tabIdx2] select] >= 0}] set textIdx2 $tabIdx2+1c foreach optTail {background foreground} { set normalOpt -$optTail set selectOpt -select$optTail foreach level [list col row cell] \ normalName [list $col$normalOpt $key$normalOpt \ $key,$col$normalOpt] \ selectName [list $col$selectOpt $key$selectOpt \ $key,$col$selectOpt] { if {$selected} { if {[info exists data($normalName)]} { $w tag remove \ $level$normalOpt-$data($normalName) \ $textIdx1 $textIdx2 } if {[info exists data($selectName)]} { $w tag add \ $level$selectOpt-$data($selectName) \ $textIdx1 $textIdx2 } } else { if {[info exists data($selectName)]} { $w tag remove \ $level$selectOpt-$data($selectName) \ $textIdx1 $textIdx2 } if {[info exists data($normalName)]} { $w tag add \ $level$normalOpt-$data($normalName) \ $textIdx1 $textIdx2 } } } } set textIdx1 $textIdx2 } } } set hasExpCollCtrlSelImgs [expr {$::tk_version >= 8.3 && [info exists tablelist::$data(-treestyle)_collapsedSelImg]}] foreach {dummy path textIdx} [$w dump -window $fromTextIdx $toTextIdx] { if {[string compare $path ""] == 0} { ................................................................................ incr col continue } if {$fmtCmdFlag} { set text [formatElem $win $key $row $col $text] } if {[string match "*\t*" $text]} { set text [mapTabs $text] } # # Build the list of tags to be applied to the cell # if {$hasRowFont} { set cellFont $data($key-font) } else { ................................................................................ set cellFont $colFont } set cellTags $colTags if {$cellTagRefCount != 0} { if {[info exists data($key,$col-font)]} { set cellFont $data($key,$col-font) lappend cellTags cell-font-$data($key,$col-font) } } # # Clip the element if necessary # set multiline [string match "*\n*" $text] ................................................................................ incr col continue } if {$fmtCmdFlag} { set text [formatElem $win $key $row $col $text] } if {[string match "*\t*" $text]} { set text [mapTabs $text] } # # Build the list of tags to be applied to the cell # if {$hasRowFont} { set cellFont $data($key-font) } else { ................................................................................ set cellFont $colFont } set cellTags $colTags if {$cellTagRefCount != 0} { if {[info exists data($key,$col-font)]} { set cellFont $data($key,$col-font) lappend cellTags cell-font-$data($key,$col-font) } } # # Insert the text and the label or window # (if any) into the body text widget # ................................................................................ $alignment $snipStr $cellFont $cellTags $line incr col } } if {$rowTagRefCount != 0} { if {[info exists data($key-font)]} { $w tag add row-font-$data($key-font) $line.0 $line.end } } if {[info exists data($key-elide)]} { $w tag add elidedRow $line.0 $line.end+1c } if {[info exists data($key-hide)]} { ................................................................................ # # Format the item # set dispItem [lrange $item 0 $data(lastCol)] if {$data(hasFmtCmds)} { set dispItem [formatItem $win $key $row $dispItem] } if {[string match "*\t*" $dispItem]} { set dispItem [mapTabs $dispItem] } set tabIdx1 $line.0 set col 0 foreach text $dispItem \ colFont $data(colFontList) \ colTags $data(colTagsList) \ {pixels alignment} $data(colList) { if {$data($col-hide) && !$canElide} { incr col continue } set tabIdx2 [$w search $elide "\t" $tabIdx1+1c $line.end] # # Nothing to do if the text is empty or is already displayed, # or if interactive editing for this cell is in progress # if {[string compare $text ""] == 0 || [string compare [$w get $tabIdx1+1c $tabIdx2] ""] != 0 || ($row == $data(editRow) && $col == $data(editCol))} { set tabIdx1 [$w index $tabIdx2+1c] incr col continue } ................................................................................ } } if {$pixels != 0} { incr pixels $data($col-delta) } # # Nothing to do if the cell has an image or window # set aux [getAuxData $win $key $col auxType auxWidth $pixels] if {$auxWidth != 0} { set tabIdx1 [$w index $tabIdx2+1c] incr col continue } # # Adjust the cell text # set multiline [string match "*\n*" $text] set indent [getIndentData $win $key $col indentWidth] set maxTextWidth $pixels if {[info exists data($key,$col-font)]} { set cellFont $data($key,$col-font) } elseif {[info exists data($key-font)]} { set cellFont $data($key-font) } else { ................................................................................ # # Adjust the cell text and the image or window width # set text [lindex $item $col] if {$fmtCmdFlag} { set text [formatElem $win $key $row $col $text] } if {[string match "*\t*" $text]} { set text [mapTabs $text] } set multiline [string match "*\n*" $text] set aux [getAuxData $win $key $col auxType auxWidth $pixels] set indent [getIndentData $win $key $col indentWidth] set maxTextWidth $pixels if {[info exists data($key,$col-font)]} { set cellFont $data($key,$col-font) } elseif {[info exists data($key-font)]} { |
Changes to modules/tablelist/scripts/tablelistWidget.tcl.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ... 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 ... 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 ... 642 643 644 645 646 647 648 649 650 651 652 653 654 655 .... 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 .... 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 .... 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 .... 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 .... 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 .... 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 .... 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 .... 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 .... 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 .... 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 .... 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 .... 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 .... 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 .... 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 .... 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 .... 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 .... 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 .... 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 .... 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 |
# Structure of the module: # - Namespace initialization # - Private procedure creating the default bindings # - Public procedure creating a new tablelist widget # - Private procedures implementing the tablelist widget command # - Private callback procedures # # Copyright (c) 2000-2012 Csaba Nemethi (E-mail: csaba.nemethi@t-online.de) #============================================================================== # # Namespace initialization # ======================== # ................................................................................ lappend cellConfigSpecs(-stretchwindow) - 0 # # Use a list to facilitate the handling of the command options # variable cmdOpts [list \ activate activatecell applysorting attrib bbox bodypath bodytag \ cancelediting cellattrib cellbbox cellcget cellconfigure cellindex \ cellselection cget childcount childindex childkeys collapse \ collapseall columnattrib columncget columnconfigure columncount \ columnindex columnwidth config configcelllist configcells \ configcolumnlist configcolumns configrowlist configrows configure \ containing containingcell containingcolumn cornerlabelpath cornerpath \ curcellselection curselection depth delete deletecolumns \ descendantcount editcell editinfo editwinpath editwintag entrypath \ expand expandall expandedkeys fillcolumn finishediting formatinfo get \ getcells getcolumns getformatted getformattedcells \ getformattedcolumns getfullkeys getkeys hasattrib hascellattrib \ ................................................................................ # # The array maxIndentDepths holds the current max. # indentation depth for every tree style in use # variable maxIndentDepths # # Define the procedure strToDispStr, which returns the string # obtained by replacing all \t characters in its argument with # \\t, as well as the procedure strMap, needed because the # "string map" command is not available in Tcl 8.0 and 8.1.0. # if {[catch {string map {} ""}] == 0} { proc strToDispStr str { if {[string match "*\t*" $str]} { return [string map {"\t" "\\t"} $str] } else { return $str } } interp alias {} ::tablelist::strMap {} string map } else { proc strToDispStr str { if {[string match "*\t*" $str]} { regsub -all "\t" $str "\\t" str } return $str } proc strMap {charMap str} { foreach {key val} $charMap { # # We will only need this for noncritical key and str values # regsub -all $key $str $val str } return $str } } interp alias {} ::tablelist::configSubCmd \ {} ::tablelist::configureSubCmd interp alias {} ::tablelist::insertchildSubCmd \ {} ::tablelist::insertchildrenSubCmd } ................................................................................ labelClicked 0 arrowColList {} sortColList {} sortOrder "" editKey "" editRow -1 editCol -1 fmtKey "" fmtRow -1 fmtCol -1 prevCell "" prevCol -1 forceAdjust 0 fmtCmdFlagList {} ................................................................................ if {[llength $argList] != 0} { mwutil::wrongNumArgs "$win bodytag" } upvar ::tablelist::ns${win}::data data return $data(bodyTag) } #------------------------------------------------------------------------------ # tablelist::canceleditingSubCmd #------------------------------------------------------------------------------ proc tablelist::canceleditingSubCmd {win argList} { if {[llength $argList] != 0} { mwutil::wrongNumArgs "$win cancelediting" ................................................................................ makeStripes $win showLineNumbersWhenIdle $win adjustElidedText $win redisplayVisibleItems $win updateColorsWhenIdle $win adjustSepsWhenIdle $win updateVScrlbarWhenIdle $win event generate $win <<TablelistRowHiddenStateChanged>> } return "" } #------------------------------------------------------------------------------ # tablelist::collapseallSubCmd ................................................................................ makeStripes $win showLineNumbersWhenIdle $win adjustElidedText $win redisplayVisibleItems $win updateColorsWhenIdle $win adjustSepsWhenIdle $win updateVScrlbarWhenIdle $win event generate $win <<TablelistRowHiddenStateChanged>> return "" } #------------------------------------------------------------------------------ # tablelist::columnattribSubCmd #------------------------------------------------------------------------------ proc tablelist::columnattribSubCmd {win argList} { ................................................................................ makeStripes $win showLineNumbersWhenIdle $win adjustElidedText $win redisplayVisibleItems $win updateColorsWhenIdle $win adjustSepsWhenIdle $win updateVScrlbarWhenIdle $win event generate $win <<TablelistRowHiddenStateChanged>> } return "" } #------------------------------------------------------------------------------ # tablelist::expandallSubCmd ................................................................................ makeStripes $win showLineNumbersWhenIdle $win adjustElidedText $win redisplayVisibleItems $win updateColorsWhenIdle $win adjustSepsWhenIdle $win updateVScrlbarWhenIdle $win event generate $win <<TablelistRowHiddenStateChanged>> return "" } #------------------------------------------------------------------------------ # tablelist::expandedkeysSubCmd #------------------------------------------------------------------------------ proc tablelist::expandedkeysSubCmd {win argList} { ................................................................................ upvar ::tablelist::ns${win}::data data set item [lindex $data(itemList) $row] set key [lindex $item end] set fullText [lindex $item $col] if {[lindex $data(fmtCmdFlagList) $col]} { set fullText [formatElem $win $key $row $col $fullText] } set fullText [strToDispStr $fullText] set pixels [lindex $data(colList) [expr {2*$col}]] if {$pixels == 0} { ;# convention: dynamic width if {$data($col-maxPixels) > 0 && $data($col-reqPixels) > $data($col-maxPixels)} { set pixels $data($col-maxPixels) } ................................................................................ if {[string compare $data(-selecttype) "row"] == 0} { foreach row [curSelection $win] { rowSelection $win set $row $row } } updateViewWhenIdle $win event generate $win <<TablelistColHiddenStateChanged>> return "" } #------------------------------------------------------------------------------ # tablelist::togglerowhideSubCmd #------------------------------------------------------------------------------ proc tablelist::togglerowhideSubCmd {win argList} { ................................................................................ synchronize $win displayItems $win set first [lindex $argList 0] # # Toggle the value of the -hide option of the specified rows # set count 0 if {$argCount == 1} { foreach elem $first { set row [rowIndex $win $elem 0 1] doRowConfig $row $win -hide [expr {![doRowCget $row $win -hide]}] incr count } } else { set firstRow [rowIndex $win $first 0 1] set lastRow [rowIndex $win [lindex $argList 1] 0 1] for {set row $firstRow} {$row <= $lastRow} {incr row} { doRowConfig $row $win -hide [expr {![doRowCget $row $win -hide]}] incr count } } if {$count != 0} { makeStripesWhenIdle $win showLineNumbersWhenIdle $win updateViewWhenIdle $win event generate $win <<TablelistRowHiddenStateChanged>> } return "" } #------------------------------------------------------------------------------ # tablelist::toplevelkeySubCmd ................................................................................ } if {$lastCol < $firstCol} { set tmp $firstCol set firstCol $lastCol set lastCol $tmp } set firstTextIdx [expr {$firstRow + 1}].0 set lastTextIdx [expr {$lastRow + 1}].end # # Find the (partly) selected lines of the body text # widget in the text range specified by the two indices # set w $data(body) variable canElide variable elide set selRange [$w tag nextrange select $firstTextIdx $lastTextIdx] while {[llength $selRange] != 0} { set selStart [lindex $selRange 0] set line [expr {int($selStart)}] set row [expr {$line - 1}] set key [lindex $data(keyList) $row] # # Deselect the relevant elements of the row and handle # the -(select)background and -(select)foreground # cell and column configuration options for them # findTabs $win $line $firstCol $lastCol firstTabIdx lastTabIdx set textIdx1 $firstTabIdx for {set col $firstCol} {$col <= $lastCol} {incr col} { if {$data($col-hide) && !$canElide} { continue } set textIdx2 \ [$w search $elide "\t" $textIdx1+1c $lastTabIdx+1c]+1c $w tag remove select $textIdx1 $textIdx2 foreach optTail {background foreground} { set opt -select$optTail foreach name [list $col$opt $key$opt $key,$col$opt] \ level [list col row cell] { if {[info exists data($name)]} { $w tag remove $level$opt-$data($name) \ $textIdx1 $textIdx2 } } foreach name [list $col-$optTail $key-$optTail \ $key,$col-$optTail] \ level [list col row cell] { if {[info exists data($name)]} { $w tag add $level-$optTail-$data($name) \ $textIdx1 $textIdx2 } } } set textIdx1 $textIdx2 } set selRange \ [$w tag nextrange select "$selStart lineend" $lastTextIdx] } updateColorsWhenIdle $win return "" } includes { ................................................................................ # set key [lindex $data(keyList) $row] if {[info exists data($key-selectable)]} { continue } # # Select the relevant elements of the row and handle # the -(select)background and -(select)foreground # cell and column configuration options for them # findTabs $win $line $firstCol $lastCol firstTabIdx lastTabIdx set textIdx1 $firstTabIdx for {set col $firstCol} {$col <= $lastCol} {incr col} { if {$data($col-hide) && !$canElide} { continue } set textIdx2 \ [$w search $elide "\t" $textIdx1+1c $lastTabIdx+1c]+1c $w tag add select $textIdx1 $textIdx2 foreach optTail {background foreground} { set opt -select$optTail foreach name [list $col$opt $key$opt $key,$col$opt] \ level [list col row cell] { if {[info exists data($name)]} { $w tag add $level$opt-$data($name) \ $textIdx1 $textIdx2 } } foreach name [list $col-$optTail $key-$optTail \ $key,$col-$optTail] \ level [list col row cell] { if {[info exists data($name)]} { set tag $level-$optTail-$data($name) $w tag remove $level-$optTail-$data($name) \ $textIdx1 $textIdx2 } } } set textIdx1 $textIdx2 } } # # If the selection is exported and there are any selected # cells in the widget then make win the new owner of the ................................................................................ # Format the item # set key [lindex $item end] set dispItem [lrange $item 0 $data(lastCol)] if {$data(hasFmtCmds)} { set dispItem [formatItem $win $key $row $dispItem] } set col 0 foreach text [strToDispStr $dispItem] \ {pixels alignment} $data(colList) { if {($data($col-hide) && !$canElide) || $pixels != 0} { incr col continue } getAuxData $win $key $col auxType auxWidth getIndentData $win $key $col indentWidth ................................................................................ if {$count != $data(itemCount)} { lappend data(freeKeyList) $key } foreach opt {-background -foreground -font} { if {[info exists data($key$opt)]} { unset data($key$opt) incr data(rowTagRefCount) -1 } } set isElided [info exists data($key-elide)] set isHidden [info exists data($key-hide)] if {$isElided && $isHidden} { unset data($key-elide) unset data($key-hide) ................................................................................ unset attribs($name) } for {set col 0} {$col < $data(colCount)} {incr col} { foreach opt {-background -foreground -font} { if {[info exists data($key,$col$opt)]} { unset data($key,$col$opt) incr data(cellTagRefCount) -1 } } foreach opt {-editable -editwindow -selectbackground -selectforeground -windowdestroy -windowupdate} { if {[info exists data($key,$col$opt)]} { unset data($key,$col$opt) } ................................................................................ # # Format the item # set dispItem [lrange $item 0 $data(lastCol)] if {$data(hasFmtCmds)} { set dispItem [formatItem $win $key $row $dispItem] } if {$isEmpty} { set isEmpty 0 } else { $w insert $line.0 "\n" } if {$data(nonViewableRowCount) != 0} { ................................................................................ $w tag remove elidedRow $line.0 $w tag remove hiddenRow $line.0 } set multilineData {} set col 0 if {$data(hasColTags)} { set insertArgs {} foreach text [strToDispStr $dispItem] \ colFont $data(colFontList) \ colTags $data(colTagsList) \ {pixels alignment} $data(colList) { if {$data($col-hide) && !$canElide} { incr col continue } ................................................................................ # if {[llength $insertArgs] != 0} { eval [list $w insert $line.0] $insertArgs } } else { set insertStr "" foreach text [strToDispStr $dispItem] \ {pixels alignment} $data(colList) { if {$data($col-hide) && !$canElide} { incr col continue } # # Update the column width or clip the element if necessary ................................................................................ # # Check the column alignment # set alignment left if {[incr n] < $argCount} { set next [lindex $argList $n] if {[catch {format "%d" $next}] == 0} { ;# integer check incr n -1 } else { mwutil::fullOpt "alignment" $next $alignments } } incr count ................................................................................ # if {$last < $first} { set tmp $first set first $last set last $tmp } set firstTextIdx [expr {$first + 1}].0 set lastTextIdx [expr {$last + 1}].end # # Find the (partly) selected lines of the body text # widget in the text range specified by the two indices # set w $data(body) variable canElide variable elide set selRange [$w tag nextrange select $firstTextIdx $lastTextIdx] while {[llength $selRange] != 0} { set selStart [lindex $selRange 0] $w tag remove select $selStart "$selStart lineend" # # Handle the -(select)background and -(select)foreground cell # and column configuration options for each element of the row # set row [expr {int($selStart) - 1}] set key [lindex $data(keyList) $row] set textIdx1 "$selStart linestart" for {set col 0} {$col < $data(colCount)} {incr col} { if {$data($col-hide) && !$canElide} { continue } set textIdx2 [$w search $elide "\t" \ $textIdx1+1c "$selStart lineend"]+1c foreach optTail {background foreground} { set opt -select$optTail foreach name [list $col$opt $key$opt $key,$col$opt] \ level [list col row cell] { if {[info exists data($name)]} { $w tag remove $level$opt-$data($name) \ $textIdx1 $textIdx2 } } foreach name [list $col-$optTail $key-$optTail \ $key,$col-$optTail] \ level [list col row cell] { if {[info exists data($name)]} { $w tag add $level-$optTail-$data($name) \ $textIdx1 $textIdx2 } } } set textIdx1 $textIdx2 } set selRange \ [$w tag nextrange select "$selStart lineend" $lastTextIdx] } updateColorsWhenIdle $win return "" } includes { set w $data(body) set textIdx [expr {double($first + 1)}] set selRange [$w tag nextrange select $textIdx "$textIdx lineend"] if {[llength $selRange] > 0} { return 1 } else { return 0 } } set { # # Swap the indices if necessary and adjust # the range to fit within the existing items # ................................................................................ variable elide for {set row $first; set line [expr {$first + 1}]} \ {$row <= $last} {set row $line; incr line} { # # Check whether the row is selectable # set key [lindex $data(keyList) $row] if {[info exists data($key-selectable)]} { continue } # # Select the elements of the row and handle the # -(select)background and -(select)foreground # cell and column configuration options for them # set textIdx1 $line.0 for {set col 0} {$col < $data(colCount)} {incr col} { if {$data($col-hide) && !$canElide} { continue } set textIdx2 \ [$w search $elide "\t" $textIdx1+1c $line.end]+1c $w tag add select $textIdx1 $textIdx2 foreach optTail {background foreground} { set opt -select$optTail foreach name [list $col$opt $key$opt $key,$col$opt] \ level [list col row cell] { if {[info exists data($name)]} { $w tag add $level$opt-$data($name) \ $textIdx1 $textIdx2 } } foreach name [list $col-$optTail $key-$optTail \ $key,$col-$optTail] \ level [list col row cell] { if {[info exists data($name)]} { $w tag remove $level-$optTail-$data($name) \ $textIdx1 $textIdx2 } } } set textIdx1 $textIdx2 } } # # If the selection is exported and there are any selected # cells in the widget then make win the new owner of the # PRIMARY selection and register a callback to be invoked |
| | | | | | | | | | < < < < < < < | < < > | < < < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > < < < < < > | > | > > > | | | | | | | < < < < < < < < < < < < < < < < < < < < | | < < < < < < < < < < < < < < < < < < < < < > > | > < | > | > > | > > > > | < | | | | < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < > | | < < < < | < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < |
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ... 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 ... 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 ... 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 .... 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 .... 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 .... 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 .... 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 .... 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 .... 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 .... 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 .... 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 .... 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 .... 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 .... 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 .... 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 .... 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 .... 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 .... 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 .... 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 .... 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 .... 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 .... 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 |
# Structure of the module: # - Namespace initialization # - Private procedure creating the default bindings # - Public procedure creating a new tablelist widget # - Private procedures implementing the tablelist widget command # - Private callback procedures # # Copyright (c) 2000-2013 Csaba Nemethi (E-mail: csaba.nemethi@t-online.de) #============================================================================== # # Namespace initialization # ======================== # ................................................................................ lappend cellConfigSpecs(-stretchwindow) - 0 # # Use a list to facilitate the handling of the command options # variable cmdOpts [list \ activate activatecell applysorting attrib bbox bodypath bodytag \ canceledediting cancelediting cellattrib cellbbox cellcget \ cellconfigure cellindex cellselection cget childcount childindex \ childkeys collapse collapseall columnattrib columncget columnconfigure \ columncount columnindex columnwidth config configcelllist configcells \ configcolumnlist configcolumns configrowlist configrows configure \ containing containingcell containingcolumn cornerlabelpath cornerpath \ curcellselection curselection depth delete deletecolumns \ descendantcount editcell editinfo editwinpath editwintag entrypath \ expand expandall expandedkeys fillcolumn finishediting formatinfo get \ getcells getcolumns getformatted getformattedcells \ getformattedcolumns getfullkeys getkeys hasattrib hascellattrib \ ................................................................................ # # The array maxIndentDepths holds the current max. # indentation depth for every tree style in use # variable maxIndentDepths # # Define the command mapTabs, which returns the string obtained by # replacing all \t characters in its argument with \\t, as well as # the commands strMap and isInteger, needed because the "string map" # and "string is" commands were not available in Tcl 8.0 and 8.1.0 # if {[catch {string map {} ""}] == 0} { interp alias {} ::tablelist::mapTabs {} string map {"\t" "\\t"} interp alias {} ::tablelist::strMap {} string map } else { proc mapTabs str { return [regsub -all "\t" $str "\\t"] } proc strMap {charMap str} { foreach {key val} $charMap { # # We will only need this for noncritical key and str values # regsub -all $key $str $val str } return $str } } if {[catch {string is integer "0"}] == 0} { interp alias {} ::tablelist::isInteger {} string is integer -strict } else { proc isInteger str { return [expr {[catch {format "%d" $str}] == 0}] } } # # Define the command genVirtualEvent, needed because the -data option of the # "event generate" command was not available in Tk versions earlier than 8.5 # if {[catch {event generate . <<__>> -data ""}] == 0} { proc genVirtualEvent {win event userData} { event generate $win $event -data $userData } } else { proc genVirtualEvent {win event userData} { event generate $win $event } } interp alias {} ::tablelist::configSubCmd \ {} ::tablelist::configureSubCmd interp alias {} ::tablelist::insertchildSubCmd \ {} ::tablelist::insertchildrenSubCmd } ................................................................................ labelClicked 0 arrowColList {} sortColList {} sortOrder "" editKey "" editRow -1 editCol -1 canceled 0 fmtKey "" fmtRow -1 fmtCol -1 prevCell "" prevCol -1 forceAdjust 0 fmtCmdFlagList {} ................................................................................ if {[llength $argList] != 0} { mwutil::wrongNumArgs "$win bodytag" } upvar ::tablelist::ns${win}::data data return $data(bodyTag) } #------------------------------------------------------------------------------ # tablelist::cancelededitingSubCmd #------------------------------------------------------------------------------ proc tablelist::cancelededitingSubCmd {win argList} { if {[llength $argList] != 0} { mwutil::wrongNumArgs "$win canceledediting" } upvar ::tablelist::ns${win}::data data return $data(canceled) } #------------------------------------------------------------------------------ # tablelist::canceleditingSubCmd #------------------------------------------------------------------------------ proc tablelist::canceleditingSubCmd {win argList} { if {[llength $argList] != 0} { mwutil::wrongNumArgs "$win cancelediting" ................................................................................ makeStripes $win showLineNumbersWhenIdle $win adjustElidedText $win redisplayVisibleItems $win updateColorsWhenIdle $win adjustSepsWhenIdle $win updateVScrlbarWhenIdle $win } return "" } #------------------------------------------------------------------------------ # tablelist::collapseallSubCmd ................................................................................ makeStripes $win showLineNumbersWhenIdle $win adjustElidedText $win redisplayVisibleItems $win updateColorsWhenIdle $win adjustSepsWhenIdle $win updateVScrlbarWhenIdle $win return "" } #------------------------------------------------------------------------------ # tablelist::columnattribSubCmd #------------------------------------------------------------------------------ proc tablelist::columnattribSubCmd {win argList} { ................................................................................ makeStripes $win showLineNumbersWhenIdle $win adjustElidedText $win redisplayVisibleItems $win updateColorsWhenIdle $win adjustSepsWhenIdle $win updateVScrlbarWhenIdle $win } return "" } #------------------------------------------------------------------------------ # tablelist::expandallSubCmd ................................................................................ makeStripes $win showLineNumbersWhenIdle $win adjustElidedText $win redisplayVisibleItems $win updateColorsWhenIdle $win adjustSepsWhenIdle $win updateVScrlbarWhenIdle $win return "" } #------------------------------------------------------------------------------ # tablelist::expandedkeysSubCmd #------------------------------------------------------------------------------ proc tablelist::expandedkeysSubCmd {win argList} { ................................................................................ upvar ::tablelist::ns${win}::data data set item [lindex $data(itemList) $row] set key [lindex $item end] set fullText [lindex $item $col] if {[lindex $data(fmtCmdFlagList) $col]} { set fullText [formatElem $win $key $row $col $fullText] } if {[string match "*\t*" $fullText]} { set fullText [mapTabs $fullText] } set pixels [lindex $data(colList) [expr {2*$col}]] if {$pixels == 0} { ;# convention: dynamic width if {$data($col-maxPixels) > 0 && $data($col-reqPixels) > $data($col-maxPixels)} { set pixels $data($col-maxPixels) } ................................................................................ if {[string compare $data(-selecttype) "row"] == 0} { foreach row [curSelection $win] { rowSelection $win set $row $row } } updateViewWhenIdle $win genVirtualEvent $win <<TablelistColHiddenStateChanged>> $colIdxList return "" } #------------------------------------------------------------------------------ # tablelist::togglerowhideSubCmd #------------------------------------------------------------------------------ proc tablelist::togglerowhideSubCmd {win argList} { ................................................................................ synchronize $win displayItems $win set first [lindex $argList 0] # # Toggle the value of the -hide option of the specified rows # set rowIdxList {} set count 0 if {$argCount == 1} { foreach elem $first { set row [rowIndex $win $elem 0 1] doRowConfig $row $win -hide [expr {![doRowCget $row $win -hide]}] incr count lappend rowIdxList $row } } else { set firstRow [rowIndex $win $first 0 1] set lastRow [rowIndex $win [lindex $argList 1] 0 1] for {set row $firstRow} {$row <= $lastRow} {incr row} { doRowConfig $row $win -hide [expr {![doRowCget $row $win -hide]}] incr count lappend rowIdxList $row } } if {$count != 0} { makeStripesWhenIdle $win showLineNumbersWhenIdle $win updateViewWhenIdle $win genVirtualEvent $win <<TablelistRowHiddenStateChanged>> $rowIdxList } return "" } #------------------------------------------------------------------------------ # tablelist::toplevelkeySubCmd ................................................................................ } if {$lastCol < $firstCol} { set tmp $firstCol set firstCol $lastCol set lastCol $tmp } set fromTextIdx [expr {$firstRow + 1}].0 set toTextIdx [expr {$lastRow + 1}].end # # Find the (partly) selected lines of the body text widget # in the text range specified by the two cell indices # set w $data(body) variable canElide variable elide set selRange [$w tag nextrange select $fromTextIdx $toTextIdx] while {[llength $selRange] != 0} { set selStart [lindex $selRange 0] set line [expr {int($selStart)}] set row [expr {$line - 1}] set key [lindex $data(keyList) $row] # # Deselect the relevant elements of the row # findTabs $win $line $firstCol $lastCol firstTabIdx lastTabIdx set textIdx1 $firstTabIdx for {set col $firstCol} {$col <= $lastCol} {incr col} { if {$data($col-hide) && !$canElide} { continue } set textIdx2 \ [$w search $elide "\t" $textIdx1+1c $lastTabIdx+1c]+1c $w tag remove select $textIdx1 $textIdx2 set textIdx1 $textIdx2 } set selRange \ [$w tag nextrange select "$selStart lineend" $toTextIdx] } updateColorsWhenIdle $win return "" } includes { ................................................................................ # set key [lindex $data(keyList) $row] if {[info exists data($key-selectable)]} { continue } # # Select the relevant elements of the row # findTabs $win $line $firstCol $lastCol firstTabIdx lastTabIdx set textIdx1 $firstTabIdx for {set col $firstCol} {$col <= $lastCol} {incr col} { if {$data($col-hide) && !$canElide} { continue } set textIdx2 \ [$w search $elide "\t" $textIdx1+1c $lastTabIdx+1c]+1c $w tag add select $textIdx1 $textIdx2 set textIdx1 $textIdx2 } } # # If the selection is exported and there are any selected # cells in the widget then make win the new owner of the ................................................................................ # Format the item # set key [lindex $item end] set dispItem [lrange $item 0 $data(lastCol)] if {$data(hasFmtCmds)} { set dispItem [formatItem $win $key $row $dispItem] } if {[string match "*\t*" $dispItem]} { set dispItem [mapTabs $dispItem] } set col 0 foreach text $dispItem {pixels alignment} $data(colList) { if {($data($col-hide) && !$canElide) || $pixels != 0} { incr col continue } getAuxData $win $key $col auxType auxWidth getIndentData $win $key $col indentWidth ................................................................................ if {$count != $data(itemCount)} { lappend data(freeKeyList) $key } foreach opt {-background -foreground -font} { if {[info exists data($key$opt)]} { unset data($key$opt) if {[string compare $opt "-font"] == 0} { incr data(rowTagRefCount) -1 } } } set isElided [info exists data($key-elide)] set isHidden [info exists data($key-hide)] if {$isElided && $isHidden} { unset data($key-elide) unset data($key-hide) ................................................................................ unset attribs($name) } for {set col 0} {$col < $data(colCount)} {incr col} { foreach opt {-background -foreground -font} { if {[info exists data($key,$col$opt)]} { unset data($key,$col$opt) if {[string compare $opt "-font"] == 0} { incr data(cellTagRefCount) -1 } } } foreach opt {-editable -editwindow -selectbackground -selectforeground -windowdestroy -windowupdate} { if {[info exists data($key,$col$opt)]} { unset data($key,$col$opt) } ................................................................................ # # Format the item # set dispItem [lrange $item 0 $data(lastCol)] if {$data(hasFmtCmds)} { set dispItem [formatItem $win $key $row $dispItem] } if {[string match "*\t*" $dispItem]} { set dispItem [mapTabs $dispItem] } if {$isEmpty} { set isEmpty 0 } else { $w insert $line.0 "\n" } if {$data(nonViewableRowCount) != 0} { ................................................................................ $w tag remove elidedRow $line.0 $w tag remove hiddenRow $line.0 } set multilineData {} set col 0 if {$data(hasColTags)} { set insertArgs {} foreach text $dispItem \ colFont $data(colFontList) \ colTags $data(colTagsList) \ {pixels alignment} $data(colList) { if {$data($col-hide) && !$canElide} { incr col continue } ................................................................................ # if {[llength $insertArgs] != 0} { eval [list $w insert $line.0] $insertArgs } } else { set insertStr "" foreach text $dispItem {pixels alignment} $data(colList) { if {$data($col-hide) && !$canElide} { incr col continue } # # Update the column width or clip the element if necessary ................................................................................ # # Check the column alignment # set alignment left if {[incr n] < $argCount} { set next [lindex $argList $n] if {[isInteger $next]} { incr n -1 } else { mwutil::fullOpt "alignment" $next $alignments } } incr count ................................................................................ # if {$last < $first} { set tmp $first set first $last set last $tmp } set fromTextIdx [expr {$first + 1}].0 set toTextIdx [expr {$last + 1}].end $data(body) tag remove select $fromTextIdx $toTextIdx updateColorsWhenIdle $win return "" } includes { set w $data(body) set line [expr {$first + 1}] set selRange [$w tag nextrange select $line.0 $line.end] return [expr {[llength $selRange] > 0}] } set { # # Swap the indices if necessary and adjust # the range to fit within the existing items # ................................................................................ variable elide for {set row $first; set line [expr {$first + 1}]} \ {$row <= $last} {set row $line; incr line} { # # Check whether the row is selectable # set key [lindex $data(keyList) $row] if {![info exists data($key-selectable)]} { $w tag add select $line.0 $line.end } } # # If the selection is exported and there are any selected # cells in the widget then make win the new owner of the # PRIMARY selection and register a callback to be invoked |