Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch tip-441 Excluding Merge-Ins
This is equivalent to a diff from 6543f30d to 9a244ba8
2016-01-22
| ||
09:21 | Implement TIP #441: Add -justify Configuration Option to the listbox Widget check-in: 12499582 user: jan.nijtmans tags: trunk | |
2016-01-20
| ||
22:03 | Fixed bug [9e606527af] - && instead of & used in generic/tkOption.c check-in: 36728caf user: fvogel tags: trunk | |
21:17 | Patch [960391] from Erik Leunissen (rebased to latest trunk) to improve listbox performance when selecting items in extended mode. Closed-Leaf check-in: 7144449a user: fvogel tags: bug-960391ffff | |
2016-01-18
| ||
18:45 | Removed unfinished test case committed by error in the previous commit. Closed-Leaf check-in: 9a244ba8 user: fvogel tags: tip-441 | |
18:43 | Reverted [5f396dacdc]. check-in: d1731afd user: fvogel tags: tip-441 | |
2016-01-16
| ||
15:22 | Rebased to latest trunk check-in: 83dfa2db user: fvogel tags: tip-441 | |
15:21 | Fixed bug [639558ac83] - Lots of listbox tests fail on Linux check-in: 6543f30d user: fvogel tags: trunk | |
2016-01-13
| ||
17:56 | TIP #438 (Ensure Line Metrics are Up-to-Date) accepted by vote check-in: 15b7aa7e user: fvogel tags: trunk | |
Changes to doc/listbox.n.
︙ | |||
13 14 15 16 17 18 19 | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | - - - + + + + | listbox \- Create and manipulate 'listbox' item list widgets .SH SYNOPSIS \fBlistbox\fR \fIpathName \fR?\fIoptions\fR? .SO \-background \-borderwidth \-cursor \-disabledforeground \-exportselection \-font \-foreground \-highlightbackground \-highlightcolor |
︙ |
Changes to generic/tkListbox.c.
︙ | |||
86 87 88 89 90 91 92 | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | - + - + - + + - + | GC selTextGC; /* For drawing selected text. */ int width; /* Desired width of window, in characters. */ int height; /* Desired height of window, in lines. */ int lineHeight; /* Number of pixels allocated for each line in * display. */ int topIndex; /* Index of top-most element visible in * window. */ |
︙ | |||
161 162 163 164 165 166 167 168 169 170 171 172 173 174 | 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | + | char *xScrollCmd; /* Command prefix for communicating with * horizontal scrollbar. NULL means no command * to issue. Malloc'ed. */ int state; /* Listbox state. */ Pixmap gray; /* Pixmap for displaying disabled text. */ int flags; /* Various flag bits: see below for * definitions. */ Tk_Justify justify; /* Justification. */ } Listbox; /* * How to encode the keys for the hash tables used to store what items are * selected and what the attributes are. */ |
︙ | |||
193 194 195 196 197 198 199 | 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | - + | * already been queued to redraw this window. * UPDATE_V_SCROLLBAR: Non-zero means vertical scrollbar needs to be * updated. * UPDATE_H_SCROLLBAR: Non-zero means horizontal scrollbar needs to * be updated. * GOT_FOCUS: Non-zero means this widget currently has the * input focus. |
︙ | |||
271 272 273 274 275 276 277 278 279 280 281 282 283 284 | 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | + + | Tk_Offset(Listbox, highlightBgColorPtr), 0, 0, 0}, {TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor", DEF_LISTBOX_HIGHLIGHT, -1, Tk_Offset(Listbox, highlightColorPtr), 0, 0, 0}, {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", "HighlightThickness", DEF_LISTBOX_HIGHLIGHT_WIDTH, -1, Tk_Offset(Listbox, highlightWidth), 0, 0, 0}, {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", DEF_LISTBOX_JUSTIFY, -1, Tk_Offset(Listbox, justify), 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_LISTBOX_RELIEF, -1, Tk_Offset(Listbox, relief), 0, 0, 0}, {TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground", DEF_LISTBOX_SELECT_COLOR, -1, Tk_Offset(Listbox, selBorder), 0, DEF_LISTBOX_SELECT_MONO, 0}, {TK_OPTION_PIXELS, "-selectborderwidth", "selectBorderWidth", "BorderWidth", DEF_LISTBOX_SELECT_BD, -1, |
︙ | |||
309 310 311 312 313 314 315 | 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | - + | DEF_LISTBOX_LIST_VARIABLE, -1, Tk_Offset(Listbox, listVarName), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0} }; /* * The itemAttrOptionSpecs table defines the valid configuration options for |
︙ | |||
336 337 338 339 340 341 342 | 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 | - + | NULL, -1, Tk_Offset(ItemAttr, selFgColor), TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT, DEF_LISTBOX_SELECT_FG_MONO, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0} }; /* |
︙ | |||
432 433 434 435 436 437 438 439 440 441 442 443 444 445 | 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 | + | static void ListboxWorldChanged(ClientData instanceData); static int NearestListboxElement(Listbox *listPtr, int y); static char * ListboxListVarProc(ClientData clientData, Tcl_Interp *interp, const char *name1, const char *name2, int flags); static void MigrateHashEntries(Tcl_HashTable *table, int first, int last, int offset); static int GetMaxOffset(Listbox *listPtr); /* * The structure below defines button class behavior by means of procedures * that can be invoked from generic window code. */ static const Tk_ClassProcs listboxClass = { |
︙ | |||
542 543 544 545 546 547 548 549 550 551 552 553 554 555 | 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 | + | listPtr->selTextGC = None; listPtr->fullLines = 1; listPtr->xScrollUnit = 1; listPtr->exportSelection = 1; listPtr->cursor = None; listPtr->state = STATE_NORMAL; listPtr->gray = None; listPtr->justify = TK_JUSTIFY_LEFT; /* * Keep a hold of the associated tkwin until we destroy the listbox, * otherwise Tk might free it while we still need it. */ Tcl_Preserve(listPtr->tkwin); |
︙ | |||
609 610 611 612 613 614 615 | 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 | - + | if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?"); return TCL_ERROR; } /* * Parse the command by looking up the second argument in the list of |
︙ | |||
1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 | 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 | + | static int ListboxBboxSubCmd( Tcl_Interp *interp, /* Pointer to the calling Tcl interpreter */ Listbox *listPtr, /* Information about the listbox */ int index) /* Index of the element to get bbox info on */ { register Tk_Window tkwin = listPtr->tkwin; int lastVisibleIndex; /* * Determine the index of the last visible item in the listbox. */ lastVisibleIndex = listPtr->topIndex + listPtr->fullLines |
︙ | |||
1107 1108 1109 1110 1111 1112 1113 | 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 | + + + - + + + + + + | return result; } stringRep = Tcl_GetStringFromObj(el, &stringLen); Tk_GetFontMetrics(listPtr->tkfont, &fm); pixelWidth = Tk_TextWidth(listPtr->tkfont, stringRep, stringLen); if (listPtr->justify == TK_JUSTIFY_LEFT) { x = (listPtr->inset + listPtr->selBorderWidth) - listPtr->xOffset; } else if (listPtr->justify == TK_JUSTIFY_RIGHT) { |
︙ | |||
1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 | 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 | + | Tk_3DBorder selectedBg; XGCValues gcValues; unsigned long mask; int left, right; /* Non-zero values here indicate that the left * or right edge of the listbox is * off-screen. */ Pixmap pixmap; int textWidth; listPtr->flags &= ~REDRAW_PENDING; if (listPtr->flags & LISTBOX_DELETED) { return; } if (listPtr->flags & MAXWIDTH_IS_STALE) { |
︙ | |||
2012 2013 2014 2015 2016 2017 2018 | 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 | - + | width+left+right, listPtr->selBorderWidth, 0, 0, 0, TK_RELIEF_RAISED); } prevSelected = 1; } else { /* * If there is an item attributes record for this item, draw |
︙ | |||
2052 2053 2054 2055 2056 2057 2058 2059 2060 | 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 | + + + + + + + + - - - - + + + + + + + + | } } /* * Draw the actual text of this item. */ Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &curElement); stringRep = Tcl_GetStringFromObj(curElement, &stringLen); textWidth = Tk_TextWidth(listPtr->tkfont, stringRep, stringLen); Tk_GetFontMetrics(listPtr->tkfont, &fm); y += fm.ascent + listPtr->selBorderWidth; if (listPtr->justify == TK_JUSTIFY_LEFT) { x = (listPtr->inset + listPtr->selBorderWidth) - listPtr->xOffset; } else if (listPtr->justify == TK_JUSTIFY_RIGHT) { |
︙ | |||
2454 2455 2456 2457 2458 2459 2460 | 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 | - + | ckfree(Tcl_GetHashValue(entry)); Tcl_DeleteHashEntry(entry); } /* * Check width of the element. We only have to check if widthChanged * has not already been set to 1, because we only need one maxWidth |
︙ | |||
2731 2732 2733 2734 2735 2736 2737 | 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 | + + - + + + | /* * The index didn't match any of the named indices; maybe it's an @x,y */ stringRep = Tcl_GetString(indexObj); if (stringRep[0] == '@') { /* |
︙ | |||
2840 2841 2842 2843 2844 2845 2846 | 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 | - + - - | * it off to an even multiple of xScrollUnit. * * Add half a scroll unit to do entry/text-like synchronization. [Bug * #225025] */ offset += listPtr->xScrollUnit / 2; |
︙ | |||
2883 2884 2885 2886 2887 2888 2889 | 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 | - + - - | register Listbox *listPtr, /* Information about widget. */ int x, /* X-coordinate to use for scan operation. */ int y) /* Y-coordinate to use for scan operation. */ { int newTopIndex, newOffset, maxIndex, maxOffset; maxIndex = listPtr->nElements - listPtr->fullLines; |
︙ | |||
3461 3462 3463 3464 3465 3466 3467 | 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 | - + | */ Tcl_DecrRefCount(oldListObj); } /* * If the list length has decreased, then we should clean up selection and |
︙ | |||
3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 | 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | Tcl_SetHashValue(entry, clientData); } } } return; } /* *---------------------------------------------------------------------- * * GetMaxOffset -- * * Passing in a listbox pointer, returns the maximum offset for the box, * i.e. the maximum possible horizontal scrolling value (in pixels). * * Results: * Listbox's maxOffset. * * Side effects: * None. * *---------------------------------------------------------------------- */ static int GetMaxOffset( register Listbox *listPtr) { int maxOffset; maxOffset = listPtr->maxWidth - (Tk_Width(listPtr->tkwin) - 2*listPtr->inset - 2*listPtr->selBorderWidth) + listPtr->xScrollUnit - 1; if (maxOffset < 0) { /* * Listbox is larger in width than its largest width item. */ maxOffset = 0; } maxOffset -= maxOffset % listPtr->xScrollUnit; return maxOffset; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to library/demos/states.tcl.
︙ | |||
14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | + + + + + + + + + + + | toplevel $w wm title $w "Listbox Demonstration (50 states)" wm iconname $w "states" positionWindow $w label $w.msg -font $font -wraplength 4i -justify left -text "A listbox containing the 50 states is displayed below, along with a scrollbar. You can scan the list either using the scrollbar or by scanning. To scan, press button 2 in the widget and drag up or down." pack $w.msg -side top labelframe $w.justif -text Justification foreach c {Left Center Right} { set lower [string tolower $c] radiobutton $w.justif.$lower -text $c -variable just \ -relief flat -value $lower -anchor w \ -command "$w.frame.list configure -justify \$just" \ -tristatevalue "multi" pack $w.justif.$lower -side left -pady 2 -fill x } pack $w.justif ## See Code / Dismiss buttons set btns [addSeeDismiss $w.buttons $w] pack $btns -side bottom -fill x frame $w.frame -borderwidth .5c pack $w.frame -side top -expand yes -fill y |
︙ |
Changes to macosx/tkMacOSXDefault.h.
︙ | |||
255 256 257 258 259 260 261 262 263 264 265 266 267 268 | 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | + | #define DEF_LISTBOX_EXPORT_SELECTION "1" #define DEF_LISTBOX_FONT "TkTextFont" #define DEF_LISTBOX_FG BLACK #define DEF_LISTBOX_HEIGHT "10" #define DEF_LISTBOX_HIGHLIGHT_BG NORMAL_BG #define DEF_LISTBOX_HIGHLIGHT BLACK #define DEF_LISTBOX_HIGHLIGHT_WIDTH "0" #define DEF_LISTBOX_JUSTIFY "left" #define DEF_LISTBOX_RELIEF "solid" #define DEF_LISTBOX_SCROLL_COMMAND "" #define DEF_LISTBOX_LIST_VARIABLE "" #define DEF_LISTBOX_SELECT_COLOR SELECT_BG #define DEF_LISTBOX_SELECT_MONO BLACK #define DEF_LISTBOX_SELECT_BD "0" #define DEF_LISTBOX_SELECT_FG_COLOR SELECT_FG |
︙ |
Changes to tests/listbox.test.
︙ | |||
200 201 202 203 204 205 206 207 208 209 210 211 212 213 | 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | + + + + + + + + + + + + + + + | } -returnCodes error -result {bad screen distance "bogus"} test listbox-1.31 {configuration options} -body { .l configure -highlightthickness -2 list [lindex [.l configure -highlightthickness] 4] [.l cget -highlightthickness] } -cleanup { .l configure -highlightthickness [lindex [.l configure -highlightthickness] 3] } -result {0 0} test listbox-1.32.1 {configuration options} -setup { set res {} } -body { .l configure -justify left set res [list [lindex [.l configure -justify] 4] [.l cget -justify]] .l configure -justify center lappend res [lindex [.l configure -justify] 4] [.l cget -justify] .l configure -justify right lappend res [lindex [.l configure -justify] 4] [.l cget -justify] } -cleanup { .l configure -justify [lindex [.l configure -justify] 3] } -result {left left center center right right} test listbox-1.32.2 {configuration options} -body { .l configure -justify bogus } -returnCodes error -result {bad justification "bogus": must be left, right, or center} test listbox-1.33 {configuration options} -body { .l configure -relief groove list [lindex [.l configure -relief] 4] [.l cget -relief] } -cleanup { .l configure -relief [lindex [.l configure -relief] 3] } -result {groove groove} test listbox-1.34 {configuration options} -body { |
︙ | |||
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 | 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 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + | } -result {-72 39 393 14} test listbox-3.18 {ListboxWidgetCmd procedure, "bbox" option, partial last line} -constraints { fonts } -body { mkPartial list [.partial.l bbox 3] [.partial.l bbox 4] } -result {{5 56 24 14} {5 73 23 14}} test listbox-3.18a {ListboxWidgetCmd procedure, "bbox" option, justified} -constraints { fonts } -setup { destroy .top.l .top unset -nocomplain res } -body { toplevel .top listbox .top.l -justify left .top.l insert end Item1 LongerItem2 MuchLongerItem3 pack .top.l update lappend res [.top.l bbox 0] [.top.l bbox 1] [.top.l bbox 2] .top.l configure -justify center lappend res [.top.l bbox 0] [.top.l bbox 1] [.top.l bbox 2] .top.l configure -justify right lappend res [.top.l bbox 0] [.top.l bbox 1] [.top.l bbox 2] } -cleanup { destroy .top.l .top unset -nocomplain res } -result [list \ {5 5 34 14} {5 22 74 14} {5 39 106 14} \ {58 5 34 14} {38 22 74 14} {22 39 106 14} \ {111 5 34 14} {71 22 74 14} {39 39 106 14} \ ] test listbox-3.18b {ListboxWidgetCmd procedure, "bbox" option, justified, non-default borderwidth} -setup { destroy .top.l .top unset -nocomplain lres res } -body { # This test checks whether all "x" values from bbox for different size # items with different justification settings are all positive or zero # This checks a bit the calculation of this x value with non-default # borders widths of the listbox toplevel .top listbox .top.l -justify left -borderwidth 17 -highlightthickness 19 -selectborderwidth 22 .top.l insert end Item1 LongerItem2 MuchLongerItem3 .top.l selection set 1 pack .top.l update lappend lres [.top.l bbox 0] [.top.l bbox 1] [.top.l bbox 2] .top.l configure -justify center lappend lres [.top.l bbox 0] [.top.l bbox 1] [.top.l bbox 2] .top.l configure -justify right lappend lres [.top.l bbox 0] [.top.l bbox 1] [.top.l bbox 2] set res 1 for {set i 0} {$i < [llength $lres]} {incr i 4} { set res [expr {$res * [expr {[lindex $lres $i] >= 0}] }] } set res } -cleanup { destroy .top.l .top unset -nocomplain lres res } -result {1} test listbox-3.19 {ListboxWidgetCmd procedure, "cget" option} -body { .l cget } -returnCodes error -result {wrong # args: should be ".l cget option"} test listbox-3.20 {ListboxWidgetCmd procedure, "cget" option} -body { .l cget a b } -returnCodes error -result {wrong # args: should be ".l cget option"} test listbox-3.21 {ListboxWidgetCmd procedure, "cget" option} -body { .l cget -gorp } -returnCodes error -result {unknown option "-gorp"} test listbox-3.22 {ListboxWidgetCmd procedure, "cget" option} -body { .l cget -setgrid } -result {0} test listbox-3.23 {ListboxWidgetCmd procedure, "configure" option} -body { llength [.l configure] |
︙ |
Changes to unix/tkUnixDefault.h.
︙ | |||
217 218 219 220 221 222 223 224 225 226 227 228 229 230 | 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | + | #define DEF_LISTBOX_EXPORT_SELECTION "1" #define DEF_LISTBOX_FONT "TkDefaultFont" #define DEF_LISTBOX_FG BLACK #define DEF_LISTBOX_HEIGHT "10" #define DEF_LISTBOX_HIGHLIGHT_BG NORMAL_BG #define DEF_LISTBOX_HIGHLIGHT BLACK #define DEF_LISTBOX_HIGHLIGHT_WIDTH "1" #define DEF_LISTBOX_JUSTIFY "left" #define DEF_LISTBOX_RELIEF "sunken" #define DEF_LISTBOX_SCROLL_COMMAND "" #define DEF_LISTBOX_LIST_VARIABLE "" #define DEF_LISTBOX_SELECT_COLOR SELECT_BG #define DEF_LISTBOX_SELECT_MONO BLACK #define DEF_LISTBOX_SELECT_BD "0" #define DEF_LISTBOX_SELECT_FG_COLOR BLACK |
︙ |
Changes to win/tkWinDefault.h.
︙ | |||
220 221 222 223 224 225 226 227 228 229 230 231 232 233 | 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | + | #define DEF_LISTBOX_EXPORT_SELECTION "1" #define DEF_LISTBOX_FONT "TkDefaultFont" #define DEF_LISTBOX_FG NORMAL_FG #define DEF_LISTBOX_HEIGHT "10" #define DEF_LISTBOX_HIGHLIGHT_BG NORMAL_BG #define DEF_LISTBOX_HIGHLIGHT HIGHLIGHT #define DEF_LISTBOX_HIGHLIGHT_WIDTH "1" #define DEF_LISTBOX_JUSTIFY "left" #define DEF_LISTBOX_RELIEF "sunken" #define DEF_LISTBOX_SCROLL_COMMAND "" #define DEF_LISTBOX_LIST_VARIABLE "" #define DEF_LISTBOX_SELECT_COLOR SELECT_BG #define DEF_LISTBOX_SELECT_MONO BLACK #define DEF_LISTBOX_SELECT_BD "0" #define DEF_LISTBOX_SELECT_FG_COLOR SELECT_FG |
︙ |