Tk Source Code

Check-in [3bb0cf88]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to tclconference@googlegroups.com
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Use GetMaxOffset when possible to reduce code duplication. The change in ListboxScanTo is not exactly equivalent but I believe the previous version was a bug.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tip-441
Files: files | file ages | folders
SHA1:3bb0cf8815b77f344d47171a70c294114e571125
User & Date: fvogel 2016-01-18 10:08:58
Context
2016-01-18
10:19
Documented what listbox-3.18b intends to test. check-in: eff8237f user: fvogel tags: tip-441
10:08
Use GetMaxOffset when possible to reduce code duplication. The change in ListboxScanTo is not exactly equivalent but I believe the previous version was a bug. check-in: 3bb0cf88 user: fvogel tags: tip-441
09:47
Fixed bug with the listbox justify patch: with large borders, when moving the horizontal scrollbar fully to the right the edge of the border could not be seen, one needed to push once on the right arrow of the scrollbar to see it. Test case:
package require Tk destroy .top toplevel .top listbox .top.l -justify right -borderwidth 17 -highlightthickness 19 -selectborderwidth 22 scrollbar .top.hs -command ".top.l xview" -orient horizontal .top.l configure -xscrollcommand ".top.hs set" set huge [concat "START -" [string repeat "Huge Item... " 20] "- END"] .top.l insert end $huge pack .top.l -expand 1 -fill both pack .top.hs -expand 1 -fill x
check-in: 5f396dac user: fvogel tags: tip-441
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tkListbox.c.

2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
....
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
     * 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;
    maxOffset = listPtr->maxWidth - (Tk_Width(listPtr->tkwin) -
	    2*listPtr->inset - 2*listPtr->selBorderWidth)
	    + listPtr->xScrollUnit - 1;
    if (offset > maxOffset) {
	offset = maxOffset;
    }
    if (offset < 0) {
	offset = 0;
    }
    offset -= offset % listPtr->xScrollUnit;
................................................................................
    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;
    maxOffset = listPtr->maxWidth + (listPtr->xScrollUnit - 1)
	    - (Tk_Width(listPtr->tkwin) - 2*listPtr->inset
	    - 2*listPtr->selBorderWidth - listPtr->xScrollUnit);

    /*
     * Compute new top line for screen by amplifying the difference between
     * the current position and the place where the scan started (the "mark"
     * position). If we run off the top or bottom of the list, then reset the
     * mark point so that the current position continues to correspond to the
     * edge of the window. This means that the picture will start dragging as







|
<
<







 







|
<
<







2883
2884
2885
2886
2887
2888
2889
2890


2891
2892
2893
2894
2895
2896
2897
....
2924
2925
2926
2927
2928
2929
2930
2931


2932
2933
2934
2935
2936
2937
2938
     * 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;
    maxOffset = GetMaxOffset(listPtr);


    if (offset > maxOffset) {
	offset = maxOffset;
    }
    if (offset < 0) {
	offset = 0;
    }
    offset -= offset % listPtr->xScrollUnit;
................................................................................
    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;
    maxOffset = GetMaxOffset(listPtr);



    /*
     * Compute new top line for screen by amplifying the difference between
     * the current position and the place where the scan started (the "mark"
     * position). If we run off the top or bottom of the list, then reset the
     * mark point so that the current position continues to correspond to the
     * edge of the window. This means that the picture will start dragging as