head	1.19;
access;
symbols
	core-8-5-9:1.18
	core-8-5-8:1.18
	macosx-cocoa-merge:1.19
	macosx-cocoa-premerge:1.19
	macosx-carbon-freeze:1.19
	core-8-5-7:1.18
	core-8-5-6:1.18
	core-8-6-b1:1.18
	core-8-6-a3:1.18
	core-8-5-5:1.18
	core-8-6-a2:1.18
	core-8-5-4:1.18
	core-8-5-3:1.18
	core-8-6-a1:1.18
	core-8-4-19:1.13.2.4
	core-8-5-branch:1.18.0.2
	core-8-5-2:1.18
	core-8-4-18:1.13.2.4
	core-8-5-1:1.18
	core-8-4-17:1.13.2.4
	core-8-5-0:1.18
	core-8-5-b3:1.17
	core-8-5-b2:1.15
	core-8-4-16:1.13.2.4
	core-8-5-b1:1.15
	core-stablilizer-merge:1.15
	core-stabilizer-branch:1.15.0.2
	core-stabilizer-merge:1.18
	core-8-4-15:1.13.2.4
	core-8-5-a6:1.15
	core-8-5-a5:1.15
	core-8-4-14:1.13.2.4
	core-8-5-a4:1.15
	core-8-4-13:1.13.2.4
	core-8-4-12:1.13.2.3
	core-8-4-11:1.13.2.2
	core-8-5-a3:1.13
	core-8-4-10:1.13.2.2
	core-8-4-9-branch:1.13.2.2.0.2
	core-8-5-a2:1.13
	core-8-4-9:1.13.2.2
	core-8-4-8:1.13.2.2
	core-8-4-7:1.13.2.2
	core-8-5-a1:1.13
	core-8-4-6:1.13.2.2
	core-8-4-5:1.13
	mistachkin-dev-branch:1.13.0.4
	core-8-4-4:1.13
	core-8-4-3:1.13
	core-8-4-branch:1.13.0.2
	core-8-4-2:1.13
	core-8-4-1:1.13
	core-8-3-5:1.11
	core-8-4-0:1.13
	macosx-8-4-merge-2002-08-31-trunk:1.13
	macosx-8-4-premerge-2002-08-31-branch:1.12.2.2
	macosx-8-4-premerge-2002-08-31-trunk:1.12
	macosx-8-4-merge-2002-08-30-branch:1.12.2.1
	macosx-8-4-merge-2002-08-30-trunk:1.12
	macosx-8-4-merge-2002-08-20-branch:1.12.2.1
	macosx-8-4-merge-2002-08-20-trunk:1.12
	core-8-4-b2:1.12
	core-8-4-b1:1.12
	macosx-premerge-6-9-02:1.12.2.1
	core-8-4-a4:1.12
	core-8-3-4:1.11
	macosx-8-4-branch:1.12.0.2
	macosx-8-4-branchpoint:1.12
	core-8-4-a3:1.12
	core-8-3-3:1.11
	dgp-privates-into-namespace:1.11.0.6
	tclpro-1-5-0:1.11
	core-8-4-win-speedup:1.11.0.4
	core-8-4-a2:1.11
	tclpro-1-4-1:1.11
	tclpro-1-4-0:1.11
	core-8-3-2:1.11
	ajuba-ajuba2-2-1-base:1.11
	ajuba-ajuba2-2-0:1.11
	core-8-4-a1:1.11
	core-8-3-1-branch:1.11.0.2
	core-8-3-1:1.11
	scriptics-sc-2-0-b5:1.11
	scriptics-sc-2-0-fixed:1.11
	scriptics-sc-2-0-b2:1.10
	scriptics-sc-2-0-b1:1.10
	core-8-3-0:1.10
	core-8-3-b2:1.9
	core-8-3-b1:1.8
	scriptics-sc-1-1:1.6
	scriptics-sc-1-1-b1:1.6
	core-8-2-3:1.6
	scriptics-sc-1-1-branch:1.6.0.8
	scriptics-sc-1-1-base:1.6
	scriptics-sc-1-0:1.6
	scriptics-sc-1-0-branch:1.6.0.6
	scriptics-sc-1-0-base:1.6
	core-8-2-2:1.6
	core-8-2-1:1.6
	scriptics-bc-1-0-b1:1.6
	core-8-2-1-branch:1.6.0.4
	scriptics-tclpro-1-3-0:1.6
	core-8-2-0:1.6
	core-8-2-b3-branch:1.6.0.2
	core-8-2-b3-base:1.6
	scriptics-tclpro-1-3-b4:1.5
	core-8-2-b2:1.5
	scriptics-tclpro-1-3-b3:1.5
	core-8-2-b1:1.5
	scriptics-tclpro-1-3-b2:1.5
	merge-to-mainline-5/21/99:1.5
	scriptics-tclpro-1-3-b2-branch:1.5.0.2
	core-8-1-1:1.5
	scriptics-tclpro-1-3-b1:1.5
	core-8-1-1-base:1.5
	core-8-1-0:1.5
	merge-to-mainline-4-29-99:1.5
	merge-to-mainline-4-23-99:1.5
	core-8-1-branch-old:1.1.0.4
	core-8-0-6-branch:1.4.0.6
	core-8-0-6-base:1.4
	core-8-0-5:1.4
	core-8-1-b3:1.1.4.4
	core-8-1-b2:1.1.4.3
	dev-8-1-stubs-branch:1.1.4.3.0.2
	dev-stubs-branch:1.4.0.4
	scriptics-tclpro-1-2:1.4
	scriptics-tclpro-1-2-b2:1.4
	core-8-1-merge-2/10/99:1.4
	core-8-0-5-branch:1.4.0.2
	core-8-0-5-base:1.4
	scriptics-tclpro-1-2-b1:1.4
	scriptics-tclpro-1-2-a1:1.4
	core-8-1-b1:1.1.4.3
	core-8-0-4:1.4
	core-8-1-a2:1.1.4.1
	core-8-0-2:1.1
	core-8-0-3:1.3;
locks; strict;
comment	@# @;


1.19
date	2008.12.28.23.43.14;	author dkf;	state Exp;
branches;
next	1.18;

1.18
date	2007.12.13.15.26.27;	author dgp;	state Exp;
branches;
next	1.17;

1.17
date	2007.10.30.19.56.58;	author hobbs;	state Exp;
branches;
next	1.16;

1.16
date	2007.10.30.01.57.54;	author hobbs;	state Exp;
branches;
next	1.15;

1.15
date	2005.09.10.14.53.20;	author das;	state Exp;
branches
	1.15.2.1;
next	1.14;

1.14
date	2005.07.25.09.06.00;	author dkf;	state Exp;
branches;
next	1.13;

1.13
date	2002.08.31.06.12.28;	author das;	state Exp;
branches
	1.13.2.1;
next	1.12;

1.12
date	2001.08.01.16.21.11;	author dgp;	state Exp;
branches
	1.12.2.1;
next	1.11;

1.11
date	2000.03.24.19.38.57;	author ericm;	state Exp;
branches
	1.11.4.1
	1.11.6.1;
next	1.10;

1.10
date	2000.02.10.08.52.50;	author hobbs;	state Exp;
branches;
next	1.9;

1.9
date	2000.01.06.02.22.24;	author hobbs;	state Exp;
branches;
next	1.8;

1.8
date	99.12.21.23.55.27;	author hobbs;	state Exp;
branches;
next	1.7;

1.7
date	99.09.02.17.02.52;	author hobbs;	state Exp;
branches;
next	1.6;

1.6
date	99.08.09.16.52.06;	author hobbs;	state Exp;
branches;
next	1.5;

1.5
date	99.04.16.01.51.26;	author stanton;	state Exp;
branches;
next	1.4;

1.4
date	98.10.10.00.30.36;	author rjohnson;	state Exp;
branches;
next	1.3;

1.3
date	98.09.14.18.23.23;	author stanton;	state Exp;
branches;
next	1.2;

1.2
date	98.06.27.18.06.39;	author welch;	state Exp;
branches;
next	1.1;

1.1
date	98.04.01.09.55.08;	author rjohnson;	state Exp;
branches
	1.1.4.1;
next	;

1.1.4.1
date	98.09.29.00.25.30;	author stanton;	state Exp;
branches;
next	1.1.4.2;

1.1.4.2
date	98.09.30.02.17.33;	author stanton;	state Exp;
branches;
next	1.1.4.3;

1.1.4.3
date	98.11.25.21.16.33;	author stanton;	state Exp;
branches;
next	1.1.4.4;

1.1.4.4
date	99.04.06.03.52.54;	author stanton;	state Exp;
branches;
next	;

1.11.4.1
date	2002.04.06.01.02.01;	author hobbs;	state Exp;
branches;
next	;

1.11.6.1
date	2001.02.28.23.29.56;	author dgp;	state Exp;
branches;
next	;

1.12.2.1
date	2001.10.15.09.22.00;	author wolfsuit;	state Exp;
branches;
next	1.12.2.2;

1.12.2.2
date	2002.08.30.18.18.13;	author das;	state Exp;
branches;
next	;

1.13.2.1
date	2004.02.16.23.09.25;	author wolfsuit;	state Exp;
branches;
next	1.13.2.2;

1.13.2.2
date	2004.02.17.07.17.17;	author das;	state Exp;
branches;
next	1.13.2.3;

1.13.2.3
date	2005.09.10.14.54.17;	author das;	state Exp;
branches;
next	1.13.2.4;

1.13.2.4
date	2006.01.25.18.21.41;	author dgp;	state Exp;
branches;
next	;

1.15.2.1
date	2007.11.01.16.37.20;	author dgp;	state Exp;
branches;
next	;


desc
@@


1.19
log
@Corrected mouse-wheel bindings for widgets. Now Shift-wheel always scrolls the
text widget horizontally on all platforms.
@
text
@# listbox.tcl --
#
# This file defines the default bindings for Tk listbox widgets
# and provides procedures that help in implementing those bindings.
#
# RCS: @@(#) $Id: listbox.tcl,v 1.18 2007/12/13 15:26:27 dgp Exp $
#
# Copyright (c) 1994 The Regents of the University of California.
# Copyright (c) 1994-1995 Sun Microsystems, Inc.
# Copyright (c) 1998 by Scriptics Corporation.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.

#--------------------------------------------------------------------------
# tk::Priv elements used in this file:
#
# afterId -		Token returned by "after" for autoscanning.
# listboxPrev -		The last element to be selected or deselected
#			during a selection operation.
# listboxSelection -	All of the items that were selected before the
#			current selection operation (such as a mouse
#			drag) started;  used to cancel an operation.
#--------------------------------------------------------------------------

#-------------------------------------------------------------------------
# The code below creates the default class bindings for listboxes.
#-------------------------------------------------------------------------

# Note: the check for existence of %W below is because this binding
# is sometimes invoked after a window has been deleted (e.g. because
# there is a double-click binding on the widget that deletes it).  Users
# can put "break"s in their bindings to avoid the error, but this check
# makes that unnecessary.

bind Listbox <1> {
    if {[winfo exists %W]} {
	tk::ListboxBeginSelect %W [%W index @@%x,%y] 1
    }
}

# Ignore double clicks so that users can define their own behaviors.
# Among other things, this prevents errors if the user deletes the
# listbox on a double click.

bind Listbox <Double-1> {
    # Empty script
}

bind Listbox <B1-Motion> {
    set tk::Priv(x) %x
    set tk::Priv(y) %y
    tk::ListboxMotion %W [%W index @@%x,%y]
}
bind Listbox <ButtonRelease-1> {
    tk::CancelRepeat
    %W activate @@%x,%y
}
bind Listbox <Shift-1> {
    tk::ListboxBeginExtend %W [%W index @@%x,%y]
}
bind Listbox <Control-1> {
    tk::ListboxBeginToggle %W [%W index @@%x,%y]
}
bind Listbox <B1-Leave> {
    set tk::Priv(x) %x
    set tk::Priv(y) %y
    tk::ListboxAutoScan %W
}
bind Listbox <B1-Enter> {
    tk::CancelRepeat
}

bind Listbox <Up> {
    tk::ListboxUpDown %W -1
}
bind Listbox <Shift-Up> {
    tk::ListboxExtendUpDown %W -1
}
bind Listbox <Down> {
    tk::ListboxUpDown %W 1
}
bind Listbox <Shift-Down> {
    tk::ListboxExtendUpDown %W 1
}
bind Listbox <Left> {
    %W xview scroll -1 units
}
bind Listbox <Control-Left> {
    %W xview scroll -1 pages
}
bind Listbox <Right> {
    %W xview scroll 1 units
}
bind Listbox <Control-Right> {
    %W xview scroll 1 pages
}
bind Listbox <Prior> {
    %W yview scroll -1 pages
    %W activate @@0,0
}
bind Listbox <Next> {
    %W yview scroll 1 pages
    %W activate @@0,0
}
bind Listbox <Control-Prior> {
    %W xview scroll -1 pages
}
bind Listbox <Control-Next> {
    %W xview scroll 1 pages
}
bind Listbox <Home> {
    %W xview moveto 0
}
bind Listbox <End> {
    %W xview moveto 1
}
bind Listbox <Control-Home> {
    %W activate 0
    %W see 0
    %W selection clear 0 end
    %W selection set 0
    event generate %W <<ListboxSelect>>
}
bind Listbox <Shift-Control-Home> {
    tk::ListboxDataExtend %W 0
}
bind Listbox <Control-End> {
    %W activate end
    %W see end
    %W selection clear 0 end
    %W selection set end
    event generate %W <<ListboxSelect>>
}
bind Listbox <Shift-Control-End> {
    tk::ListboxDataExtend %W [%W index end]
}
bind Listbox <<Copy>> {
    if {[selection own -displayof %W] eq "%W"} {
	clipboard clear -displayof %W
	clipboard append -displayof %W [selection get -displayof %W]
    }
}
bind Listbox <space> {
    tk::ListboxBeginSelect %W [%W index active]
}
bind Listbox <Select> {
    tk::ListboxBeginSelect %W [%W index active]
}
bind Listbox <Control-Shift-space> {
    tk::ListboxBeginExtend %W [%W index active]
}
bind Listbox <Shift-Select> {
    tk::ListboxBeginExtend %W [%W index active]
}
bind Listbox <Escape> {
    tk::ListboxCancel %W
}
bind Listbox <Control-slash> {
    tk::ListboxSelectAll %W
}
bind Listbox <Control-backslash> {
    if {[%W cget -selectmode] ne "browse"} {
	%W selection clear 0 end
	event generate %W <<ListboxSelect>>
    }
}

# Additional Tk bindings that aren't part of the Motif look and feel:

bind Listbox <2> {
    %W scan mark %x %y
}
bind Listbox <B2-Motion> {
    %W scan dragto %x %y
}

# The MouseWheel will typically only fire on Windows and Mac OS X.
# However, someone could use the "event generate" command to produce
# one on other platforms.

if {[tk windowingsystem] eq "aqua"} {
    bind Listbox <MouseWheel> {
        %W yview scroll [expr {- (%D)}] units
    }
    bind Listbox <Option-MouseWheel> {
        %W yview scroll [expr {-10 * (%D)}] units
    }
    bind Listbox <Shift-MouseWheel> {
        %W xview scroll [expr {- (%D)}] units
    }
    bind Listbox <Shift-Option-MouseWheel> {
        %W xview scroll [expr {-10 * (%D)}] units
    }
} else {
    bind Listbox <MouseWheel> {
        %W yview scroll [expr {- (%D / 120) * 4}] units
    }
    bind Listbox <Shift-MouseWheel> {
        %W xview scroll [expr {- (%D / 120) * 4}] units
    }
}

if {"x11" eq [tk windowingsystem]} {
    # Support for mousewheels on Linux/Unix commonly comes through mapping
    # the wheel to the extended buttons.  If you have a mousewheel, find
    # Linux configuration info at:
    #	http://www.inria.fr/koala/colas/mouse-wheel-scroll/
    bind Listbox <4> {
	if {!$tk_strictMotif} {
	    %W yview scroll -5 units
	}
    }
    bind Listbox <Shift-4> {
	if {!$tk_strictMotif} {
	    %W xview scroll -5 units
	}
    }
    bind Listbox <5> {
	if {!$tk_strictMotif} {
	    %W yview scroll 5 units
	}
    }
    bind Listbox <Shift-5> {
	if {!$tk_strictMotif} {
	    %W xview scroll 5 units
	}
    }
}

# ::tk::ListboxBeginSelect --
#
# This procedure is typically invoked on button-1 presses.  It begins
# the process of making a selection in the listbox.  Its exact behavior
# depends on the selection mode currently in effect for the listbox;
# see the Motif documentation for details.
#
# Arguments:
# w -		The listbox widget.
# el -		The element for the selection operation (typically the
#		one under the pointer).  Must be in numerical form.

proc ::tk::ListboxBeginSelect {w el {focus 1}} {
    variable ::tk::Priv
    if {[$w cget -selectmode] eq "multiple"} {
	if {[$w selection includes $el]} {
	    $w selection clear $el
	} else {
	    $w selection set $el
	}
    } else {
	$w selection clear 0 end
	$w selection set $el
	$w selection anchor $el
	set Priv(listboxSelection) {}
	set Priv(listboxPrev) $el
    }
    event generate $w <<ListboxSelect>>
    # check existence as ListboxSelect may destroy us
    if {$focus && [winfo exists $w] && [$w cget -state] eq "normal"} {
	focus $w
    }
}

# ::tk::ListboxMotion --
#
# This procedure is called to process mouse motion events while
# button 1 is down.  It may move or extend the selection, depending
# on the listbox's selection mode.
#
# Arguments:
# w -		The listbox widget.
# el -		The element under the pointer (must be a number).

proc ::tk::ListboxMotion {w el} {
    variable ::tk::Priv
    if {$el == $Priv(listboxPrev)} {
	return
    }
    set anchor [$w index anchor]
    switch [$w cget -selectmode] {
	browse {
	    $w selection clear 0 end
	    $w selection set $el
	    set Priv(listboxPrev) $el
	    event generate $w <<ListboxSelect>>
	}
	extended {
	    set i $Priv(listboxPrev)
	    if {$i eq ""} {
		set i $el
		$w selection set $el
	    }
	    if {[$w selection includes anchor]} {
		$w selection clear $i $el
		$w selection set anchor $el
	    } else {
		$w selection clear $i $el
		$w selection clear anchor $el
	    }
	    if {![info exists Priv(listboxSelection)]} {
		set Priv(listboxSelection) [$w curselection]
	    }
	    while {($i < $el) && ($i < $anchor)} {
		if {[lsearch $Priv(listboxSelection) $i] >= 0} {
		    $w selection set $i
		}
		incr i
	    }
	    while {($i > $el) && ($i > $anchor)} {
		if {[lsearch $Priv(listboxSelection) $i] >= 0} {
		    $w selection set $i
		}
		incr i -1
	    }
	    set Priv(listboxPrev) $el
	    event generate $w <<ListboxSelect>>
	}
    }
}

# ::tk::ListboxBeginExtend --
#
# This procedure is typically invoked on shift-button-1 presses.  It
# begins the process of extending a selection in the listbox.  Its
# exact behavior depends on the selection mode currently in effect
# for the listbox;  see the Motif documentation for details.
#
# Arguments:
# w -		The listbox widget.
# el -		The element for the selection operation (typically the
#		one under the pointer).  Must be in numerical form.

proc ::tk::ListboxBeginExtend {w el} {
    if {[$w cget -selectmode] eq "extended"} {
	if {[$w selection includes anchor]} {
	    ListboxMotion $w $el
	} else {
	    # No selection yet; simulate the begin-select operation.
	    ListboxBeginSelect $w $el
	}
    }
}

# ::tk::ListboxBeginToggle --
#
# This procedure is typically invoked on control-button-1 presses.  It
# begins the process of toggling a selection in the listbox.  Its
# exact behavior depends on the selection mode currently in effect
# for the listbox;  see the Motif documentation for details.
#
# Arguments:
# w -		The listbox widget.
# el -		The element for the selection operation (typically the
#		one under the pointer).  Must be in numerical form.

proc ::tk::ListboxBeginToggle {w el} {
    variable ::tk::Priv
    if {[$w cget -selectmode] eq "extended"} {
	set Priv(listboxSelection) [$w curselection]
	set Priv(listboxPrev) $el
	$w selection anchor $el
	if {[$w selection includes $el]} {
	    $w selection clear $el
	} else {
	    $w selection set $el
	}
	event generate $w <<ListboxSelect>>
    }
}

# ::tk::ListboxAutoScan --
# This procedure is invoked when the mouse leaves an entry window
# with button 1 down.  It scrolls the window up, down, left, or
# right, depending on where the mouse left the window, and reschedules
# itself as an "after" command so that the window continues to scroll until
# the mouse moves back into the window or the mouse button is released.
#
# Arguments:
# w -		The entry window.

proc ::tk::ListboxAutoScan {w} {
    variable ::tk::Priv
    if {![winfo exists $w]} return
    set x $Priv(x)
    set y $Priv(y)
    if {$y >= [winfo height $w]} {
	$w yview scroll 1 units
    } elseif {$y < 0} {
	$w yview scroll -1 units
    } elseif {$x >= [winfo width $w]} {
	$w xview scroll 2 units
    } elseif {$x < 0} {
	$w xview scroll -2 units
    } else {
	return
    }
    ListboxMotion $w [$w index @@$x,$y]
    set Priv(afterId) [after 50 [list tk::ListboxAutoScan $w]]
}

# ::tk::ListboxUpDown --
#
# Moves the location cursor (active element) up or down by one element,
# and changes the selection if we're in browse or extended selection
# mode.
#
# Arguments:
# w -		The listbox widget.
# amount -	+1 to move down one item, -1 to move back one item.

proc ::tk::ListboxUpDown {w amount} {
    variable ::tk::Priv
    $w activate [expr {[$w index active] + $amount}]
    $w see active
    switch [$w cget -selectmode] {
	browse {
	    $w selection clear 0 end
	    $w selection set active
	    event generate $w <<ListboxSelect>>
	}
	extended {
	    $w selection clear 0 end
	    $w selection set active
	    $w selection anchor active
	    set Priv(listboxPrev) [$w index active]
	    set Priv(listboxSelection) {}
	    event generate $w <<ListboxSelect>>
	}
    }
}

# ::tk::ListboxExtendUpDown --
#
# Does nothing unless we're in extended selection mode;  in this
# case it moves the location cursor (active element) up or down by
# one element, and extends the selection to that point.
#
# Arguments:
# w -		The listbox widget.
# amount -	+1 to move down one item, -1 to move back one item.

proc ::tk::ListboxExtendUpDown {w amount} {
    variable ::tk::Priv
    if {[$w cget -selectmode] ne "extended"} {
	return
    }
    set active [$w index active]
    if {![info exists Priv(listboxSelection)]} {
	$w selection set $active
	set Priv(listboxSelection) [$w curselection]
    }
    $w activate [expr {$active + $amount}]
    $w see active
    ListboxMotion $w [$w index active]
}

# ::tk::ListboxDataExtend
#
# This procedure is called for key-presses such as Shift-KEndData.
# If the selection mode isn't multiple or extend then it does nothing.
# Otherwise it moves the active element to el and, if we're in
# extended mode, extends the selection to that point.
#
# Arguments:
# w -		The listbox widget.
# el -		An integer element number.

proc ::tk::ListboxDataExtend {w el} {
    set mode [$w cget -selectmode]
    if {$mode eq "extended"} {
	$w activate $el
	$w see $el
        if {[$w selection includes anchor]} {
	    ListboxMotion $w $el
	}
    } elseif {$mode eq "multiple"} {
	$w activate $el
	$w see $el
    }
}

# ::tk::ListboxCancel
#
# This procedure is invoked to cancel an extended selection in
# progress.  If there is an extended selection in progress, it
# restores all of the items between the active one and the anchor
# to their previous selection state.
#
# Arguments:
# w -		The listbox widget.

proc ::tk::ListboxCancel w {
    variable ::tk::Priv
    if {[$w cget -selectmode] ne "extended"} {
	return
    }
    set first [$w index anchor]
    set last $Priv(listboxPrev)
    if {$last eq ""} {
	# Not actually doing any selection right now
	return
    }
    if {$first > $last} {
	set tmp $first
	set first $last
	set last $tmp
    }
    $w selection clear $first $last
    while {$first <= $last} {
	if {[lsearch $Priv(listboxSelection) $first] >= 0} {
	    $w selection set $first
	}
	incr first
    }
    event generate $w <<ListboxSelect>>
}

# ::tk::ListboxSelectAll
#
# This procedure is invoked to handle the "select all" operation.
# For single and browse mode, it just selects the active element.
# Otherwise it selects everything in the widget.
#
# Arguments:
# w -		The listbox widget.

proc ::tk::ListboxSelectAll w {
    set mode [$w cget -selectmode]
    if {$mode eq "single" || $mode eq "browse"} {
	$w selection clear 0 end
	$w selection set active
    } else {
	$w selection set 0 end
    }
    event generate $w <<ListboxSelect>>
}
@


1.18
log
@merge stable branch onto HEAD
@
text
@d6 1
a6 1
# RCS: @@(#) $Id: listbox.tcl,v 1.15.2.1 2007/11/01 16:37:20 dgp Exp $
d199 3
d214 5
d224 5
@


1.17
log
@	* library/listbox.tcl (::tk::ListboxBeginSelect): ignore
	-takefocus when considering focus on <1>, it is for tab focus.
@
text
@d6 1
a6 1
# RCS: @@(#) $Id: listbox.tcl,v 1.16 2007/10/30 01:57:54 hobbs Exp $
@


1.16
log
@	* tests/listbox.test, tests/panedwindow.test, tests/scrollbar.test:
	* library/bgerror.tcl, library/dialog.tcl, library/listbox.tcl:
	* library/msgbox.tcl, library/optMenu.tcl, library/tclIndex:
	* library/tkfbox.tcl, library/demos/floor.tcl, library/demos/rmt:
	* library/demos/tcolor, library/demos/text.tcl:
	* library/demos/twind.tcl, library/demos/widget: Buh-bye Motif look
	* library/ttk/fonts.tcl:    Update of Tk default look in 8.5
	* macosx/tkMacOSXDefault.h: Trims border sizes, cleaner X11 look
	* unix/tkUnixDefault.h:     with minor modifications for Win32/Aqua.
	* win/tkWinDefault.h:       Uses Tk*Font definitions throughout for
	* win/tkWinFont.c:          classic widgets. [Bug #1820344]
	* library/obsolete.tcl (::tk::classic::restore): This restores
	changes made to defaults in 8.5 using the 'option' command,
	segmented into logical groups.
@
text
@d6 1
a6 1
# RCS: @@(#) $Id: listbox.tcl,v 1.15 2005/09/10 14:53:20 das Exp $
d247 1
a247 3
    if {$focus && [winfo exists $w]
	&& [string is true -strict [$w cget -takefocus]]
	&& [$w cget -state] eq "normal"} {
@


1.15
log
@	* macosx/tkMacOSXMouseEvent.c (TkMacOSXProcessMouseEvent): check if
	process is in front on MouseDown, otherwise request process activation
	from BringWindowForward() via new isFrontProcess param.

	* macosx/tkMacOSXCarbonEvents.c (TkMacOSXInitCarbonEvents): register our
	event handler on the dispatcher target for all carbon events of interest
	to TkAqua; this replaces event processing directly from the event queue
	and thus allows to capture events that are syntesized by Carbon and sent
	directly to the dispatcher and not to the event queue.

	* macosx/tkMacOSXEvent.c: remove TkMacOSXCountAndProcessMacEvents(),
	rename ReceiveAndProcessEvent() to TkMacOSXReceiveAndProcessEvent().
	(TkMacOSXReceiveAndProcessEvent): remove tk event processing before
	sending events to the dispatcher, all events of interest are now
	processed in our dispatcher target event handler.

	* macosx/tkMacOSXNotify.c (CarbonEventsCheckProc): dispatch events
	directly via TkMacOSXReceiveAndProcessEvent(), but dispatch no more than
	four carbon events at one time to avoid starving other event sources.

	* macosx/tkMacOSXEvent.c: formatting cleanup, move XSync() to XStubs,
	* macosx/tkMacOSXEvent.h: removed obsolete kEventClassWish handling.
	* macosx/tkMacOSXXStubs.c

	* macosx/tkMacOSXEvent.h: declare macosx internal procs as MODULE_SCOPE.
	* macosx/tkMacOSXEvent.c:
	* macosx/tkMacOSXKeyEvent.c:
	* macosx/tkMacOSXMouseEvent.c:
	* macosx/tkMacOSXWindowEvent.c:

	* macosx/tkMacOSXButton.c: conditionalize all debug message printing to
	* macosx/tkMacOSXCursor.c: stderr via TK_MAC_DEBUG define.
	* macosx/tkMacOSXDebug.c:
	* macosx/tkMacOSXDebug.h:
	* macosx/tkMacOSXDialog.c:
	* macosx/tkMacOSXEvent.c:
	* macosx/tkMacOSXInit.c:
	* macosx/tkMacOSXKeyEvent.c:
	* macosx/tkMacOSXMenu.c:
	* macosx/tkMacOSXMenubutton.c:
	* macosx/tkMacOSXScale.c:
	* macosx/tkMacOSXWindowEvent.c:
	* macosx/tkMacOSXWm.c:

	* unix/configure.in: define TK_MAC_DEBUG on aqua when symbols enabled.
	* unix/configure: autoconf-2.59
	* unix/tkConfig.h.in: autoheader-2.59

	* library/listbox.tcl: synced aqua MouseWheel bindings with
	* library/scrlbar.tcl: core-8-4-branch.
	* library/text.tcl:

	* xlib/xcolors.c: fixed warning
@
text
@d6 1
a6 1
# RCS: @@(#) $Id: listbox.tcl,v 1.14 2005/07/25 09:06:00 dkf Exp $
d38 1
a38 1
	tk::ListboxBeginSelect %W [%W index @@%x,%y]
d230 1
a230 1
proc ::tk::ListboxBeginSelect {w el} {
d246 6
@


1.15.2.1
log
@merge updates from HEAD
@
text
@d6 1
a6 1
# RCS: @@(#) $Id: listbox.tcl,v 1.15 2005/09/10 14:53:20 das Exp $
d38 1
a38 1
	tk::ListboxBeginSelect %W [%W index @@%x,%y] 1
d230 1
a230 1
proc ::tk::ListboxBeginSelect {w el {focus 1}} {
a245 4
    # check existence as ListboxSelect may destroy us
    if {$focus && [winfo exists $w] && [$w cget -state] eq "normal"} {
	focus $w
    }
@


1.14
log
@Apply some of the changes suggested in [Patch 1237759]
@
text
@d6 1
a6 1
# RCS: @@(#) $Id: listbox.tcl,v 1.13 2002/08/31 06:12:28 das Exp $
d178 21
a198 6
# The MouseWheel will typically only fire on Windows.  However,
# someone could use the "event generate" command to produce one
# on other platforms.

bind Listbox <MouseWheel> {
    %W yview scroll [expr {- (%D / 120) * 4}] units
@


1.13
log
@	*** macosx-8-4-branch merged into the mainline [tcl patch #602770] ***

	* generic/tk.decls:
	* generic/tkInt.decls: added new "aqua" specific entries to the
	stubs tables. Changed all "unix" entries to "x11" to allow us to
	distinguish and build both "aqua" on MacOSX and "x11" on MacOSX.

	* generic/tk.h: added a #ifnded RESOURCE_INCLUDED so that tk.h can
	be passed to the resource compiler.

	* generic/tkCmds.c (Tk_TkObjCmd): added [tk windowingsystem]
	subcommand: returns "x11" when running on X11, "win32" on Windows,
	"classic" on MacOS9 and "aqua" on MacOSX Aqua (i.e. Carbon)

	* generic/tkFont.c (TkFontGetFirstTextLayout): new private function
	returning the first chunk of a Tk_TextLayout, i.e. until the first
	font change on the first line (or the whole first line if there is
	no such font change).

	* generic/tkMain.c: made Tcl_ThreadDataKey static

	* library/demos/puzzle.tcl: fixed button metrics for aqua

	* tests/cursor.test: check for presence of arrow cursor instead of
	heart cursor

	* xlib/xcolors.c: changed xColors static initialization to more
	standard C

	* macosx/Wish.pbproj/jingham.pbxuser (new):
	* macosx/Wish.pbproj/project.pbxproj (new): project for Apple's
	ProjectBuilder IDE.

	* macosx/Makefile (new): simple makefile for building the project
	from the command line via the ProjectBuilder tool 'pbxbuild'.

	* macosx/tkMacOSXAppInit.c (new): macosx specific AppInit looking
	for a AppMain.tcl file in its bundled Resources/Scripts folder. If
	present, argv[1] is set to that file and the Scripts folder is
	added to the auto_path. This allows tk apps to embed scripts within
	their bundle directory structure.

	* macosx/tkMacOSXInit.c (new): macosx adapted version of
	tkUnixInit.c: we initialize & cache the Carbon native encoding
	(e.g. 'macRoman') and try to find the tk script library files
	inside Tk packaged as a framework.

	* macosx/tkMacOSXNotify.c (new): new macosx specific merged
	Carbon/select-based notifier.

	* macosx/tkMacOSXEvent.c (new):
	* macosx/tkMacOSXEvent.h (new):
	* macosx/tkMacOSXKeyEvent.c (new):
	* macosx/tkMacOSXMouseEvent.c (new):
	* macosx/tkMacOSXWindowEvent.c (new): new macosx specific event
	handling functionality.

	* macosx/tkMacOSX.h (new):
	* macosx/tkMacOSXBitmap.c (new):
	* macosx/tkMacOSXButton.c (new):
	* macosx/tkMacOSXClipboard.c (new):
	* macosx/tkMacOSXColor.c (new):
	* macosx/tkMacOSXConfig.c (new):
	* macosx/tkMacOSXCursor.c (new):
	* macosx/tkMacOSXDefault.h (new):
	* macosx/tkMacOSXDialog.c (new):
	* macosx/tkMacOSXDraw.c (new):
	* macosx/tkMacOSXEmbed.c (new):
	* macosx/tkMacOSXFont.c (new):
	* macosx/tkMacOSXHLEvents.c (new):
	* macosx/tkMacOSXInt.h (new):
	* macosx/tkMacOSXKeyboard.c (new):
	* macosx/tkMacOSXMenu.c (new):
	* macosx/tkMacOSXMenubutton.c (new):
	* macosx/tkMacOSXMenus.c (new):
	* macosx/tkMacOSXPort.h (new):
	* macosx/tkMacOSXRegion.c (new):
	* macosx/tkMacOSXScale.c (new):
	* macosx/tkMacOSXScrlbr.c (new):
	* macosx/tkMacOSXSubwindows.c (new):
	* macosx/tkMacOSXTest.c (new):
	* macosx/tkMacOSXUtil.c (new):
	* macosx/tkMacOSXUtil.h (new):
	* macosx/tkMacOSXWm.c (new):
	* macosx/tkMacOSXWm.h (new):
	* macosx/tkMacOSXXStubs.c (new): macosx ports of classic mac Tk
	implementation in tk/mac.

	* macosx/tkMacOSXSend.c (new): only send to local interp
	implemented currently.

	* macosx/tkMacOSXDebug.h (new):
	* macosx/tkMacOSXDebug.c (new): new macosx specific functions for
	debugging MacOS events, regions, etc.

	* macosx/tkAboutDlg.r (new):
	* macosx/tkMacOSXApplication.r (new):
	* macosx/tkMacOSXCursors.r (new):
	* macosx/tkMacOSXLibrary.r (new):
	* macosx/tkMacOSXMenu.r (new):
	* macosx/tkMacOSXResource.r (new):
	* macosx/tkMacOSXXCursors.r (new):
	* macosx/tclets.r (new): sources for Rez resource compiler.

	* macosx/Wish.icns (new): Wish application icon.

	* generic/tk.h:
	* generic/default.h:
	* generic/tkBind.c:
	* generic/tkCmds.c:
	* generic/tkGrab.c:
	* generic/tkPointer.c:
	* generic/tkPort.h:
	* generic/tkSelect.c:
	* generic/tkStubLib.c:
	* generic/tkTest.c:
	* generic/tkText.c:
	* generic/tkWindow.c:
	* unix/tkUnix3d.c:
	* xlib/xgc.c:
	* xlib/X11/X.h:
	* xlib/X11/Xlib.h:
	* xlib/X11/Xutil.h: added #includes and #ifdefs for macosx

	* library/bgerror.tcl:
	* library/button.tcl:
	* library/console.tcl:
	* library/dialog.tcl:
	* library/entry.tcl:
	* library/listbox.tcl:
	* library/menu.tcl:
	* library/msgbox.tcl:
	* library/scrlbar.tcl:
	* library/spinbox.tcl:
	* library/text.tcl:
	* library/tk.tcl:
	* library/demos/menu.tcl:
	* library/demos/menubu.tcl:
	* library/demos/widget: check [tk windowingsystem] instead of
	and/or in addition to $tcl_platform(platform).

	* generic/tkInt.h:
	* mac/tkMacBitmap.c:
	* mac/tkMacWm.c: added missing CONSTification

	* generic/tkIntDecls.h:
	* generic/tkIntPlatDecls.h:
	* generic/tkIntXlibDecls.h:
	* generic/tkPlatDecls.h:
	* generic/tkStubInit.c: regen
@
text
@d6 1
a6 1
# RCS: @@(#) $Id$
d139 1
a139 1
    if {[string equal [selection own -displayof %W] "%W"]} {
d163 1
a163 1
    if {[string compare [%W cget -selectmode] "browse"]} {
d186 1
a186 1
if {[string equal "x11" [tk windowingsystem]]} {
d217 1
a217 1
    if {[string equal [$w cget -selectmode] "multiple"]} {
d258 1
a258 1
	    if {[string equal {} $i]} {
d303 1
a303 1
    if {[string equal [$w cget -selectmode] "extended"]} {
d327 1
a327 1
    if {[string equal [$w cget -selectmode] "extended"]} {
d413 1
a413 1
    if {[string compare [$w cget -selectmode] "extended"]} {
d439 1
a439 1
    if {[string equal $mode "extended"]} {
d445 1
a445 1
    } elseif {[string equal $mode "multiple"]} {
d463 1
a463 1
    if {[string compare [$w cget -selectmode] "extended"]} {
d468 1
a468 1
    if { [string equal $last ""] } {
d498 1
a498 1
    if {[string equal $mode "single"] || [string equal $mode "browse"]} {
@


1.13.2.1
log
@This gets the scroll wheel working for listboxes and text widgets for Mac OS
X.  It also changes the model to route scrollwheel events to the window under
the pointer, not the focus window on X (and only on X).  That is the correct
behavior for Mac OS X.
@
text
@d182 2
a183 9
if {[string equal [tk windowingsystem] "classic"]
	|| [string equal [tk windowingsystem] "aqua"]} {
    bind Listbox <MouseWheel> {
        %W yview scroll [expr {- (%D)}] units
    }
} else {
    bind Listbox <MouseWheel> {
        %W yview scroll [expr {- (%D / 120) * 4}] units
    }
@


1.13.2.2
log
@	* macosx/tkMacOSXMouseEvent.c: fixed modifiers for MouseWheel events.

	* library/listbox.tcl:
	* library/text.tcl:
	* library/scrlbar.tcl: on Mac OS, add bindings for MouseWheel with
	modifiers, according to platform convention:
	Option increases scrolling speed 10 fold; Space scrolls horizontally.

	* macosx/Wish.pbproj/project.pbxproj:
	* macosx/tkAboutDlg.r: changed year in copyright strings to 2004.
@
text
@d6 1
a6 1
# RCS: @@(#) $Id: listbox.tcl,v 1.13.2.1 2004/02/16 23:09:25 wolfsuit Exp $
a186 9
    bind Listbox <Option-MouseWheel> {
        %W yview scroll [expr {-10 * (%D)}] units
    }
    bind Listbox <Shift-MouseWheel> {
        %W xview scroll [expr {- (%D)}] units
    }
    bind Listbox <Shift-Option-MouseWheel> {
        %W xview scroll [expr {-10 * (%D)}] units
    }
@


1.13.2.3
log
@	* macosx/tkMacOSXMouseEvent.c (TkMacOSXProcessMouseEvent): check if
	process is in front on MouseDown, otherwise request process activation
	from BringWindowForward() via new isFrontProcess param.

	* macosx/tkMacOSXCarbonEvents.c (TkMacOSXInitCarbonEvents): register our
	event handler on the dispatcher target for all carbon events of interest
	to TkAqua; this replaces event processing directly from the event queue
	and thus allows to capture events that are syntesized by Carbon and sent
	directly to the dispatcher and not to the event queue.

	* macosx/tkMacOSXEvent.c: remove TkMacOSXCountAndProcessMacEvents(),
	rename ReceiveAndProcessEvent() to TkMacOSXReceiveAndProcessEvent().
	(TkMacOSXReceiveAndProcessEvent): remove tk event processing before
	sending events to the dispatcher, all events of interest are now
	processed in our dispatcher target event handler.

	* macosx/tkMacOSXNotify.c (CarbonEventsCheckProc): dispatch events
	directly via TkMacOSXReceiveAndProcessEvent(), but dispatch no more than
	four carbon events at one time to avoid starving other event sources.

	* macosx/tkMacOSXEvent.c: formatting cleanup, move XSync() to XStubs,
	* macosx/tkMacOSXEvent.h: removed obsolete kEventClassWish handling.
	* macosx/tkMacOSXXStubs.c

	* macosx/tkMacOSXButton.c: conditionalize all debug message printing to
	* macosx/tkMacOSXCursor.c: stderr via TK_MAC_DEBUG define.
	* macosx/tkMacOSXDebug.c:
	* macosx/tkMacOSXDebug.h:
	* macosx/tkMacOSXDialog.c:
	* macosx/tkMacOSXEvent.c:
	* macosx/tkMacOSXInit.c:
	* macosx/tkMacOSXKeyEvent.c:
	* macosx/tkMacOSXMenu.c:
	* macosx/tkMacOSXMenubutton.c:
	* macosx/tkMacOSXScale.c:
	* macosx/tkMacOSXWindowEvent.c:
	* macosx/tkMacOSXWm.c:

	* unix/configure.in: define TK_MAC_DEBUG on aqua when symbols enabled.
	* unix/configure: autoconf-2.13

	* library/listbox.tcl: corrected comments.
	* library/text.tcl:

	* xlib/xcolors.c: fixed warning
@
text
@d6 1
a6 1
# RCS: @@(#) $Id: listbox.tcl,v 1.13.2.2 2004/02/17 07:17:17 das Exp $
d178 3
a180 3
# The MouseWheel will typically only fire on Windows and Mac OS X.
# However, someone could use the "event generate" command to produce
# one on other platforms.
@


1.13.2.4
log
@        * library/bgerror.tcl:  Updates to use Tcl 8.4 features. [Patch 1237759]        * library/button.tcl:
        * library/choosedir.tcl:
        * library/clrpick.tcl:
        * library/comdlg.tcl:
        * library/console.tcl:
        * library/dialog.tcl:
        * library/entry.tcl:
        * library/focus.tcl:
        * library/listbox.tcl:
        * library/menu.tcl:
        * library/msgbox.tcl:
        * library/palette.tcl:
        * library/panedwindow.tcl:
        * library/safetk.tcl:
        * library/scale.tcl:
        * library/scrlbar.tcl:
        * library/spinbox.tcl:
        * library/tearoff.tcl:
        * library/text.tcl:
        * library/tk.tcl:
        * library/tkfbox.tcl:
        * library/xmfbox.tcl:
@
text
@d6 1
a6 1
# RCS: @@(#) $Id: listbox.tcl,v 1.13.2.3 2005/09/10 14:54:17 das Exp $
d139 1
a139 1
    if {[selection own -displayof %W] eq "%W"} {
d163 1
a163 1
    if {[%W cget -selectmode] ne "browse"} {
d181 3
a183 1
if {[tk windowingsystem] eq "classic" || [tk windowingsystem] eq "aqua"} {
d202 1
a202 1
if {"x11" eq [tk windowingsystem]} {
d233 1
a233 1
    if {[$w cget -selectmode] eq "multiple"} {
d274 1
a274 1
	    if {$i eq ""} {
d319 1
a319 1
    if {[$w cget -selectmode] eq "extended"} {
d343 1
a343 1
    if {[$w cget -selectmode] eq "extended"} {
d429 1
a429 1
    if {[$w cget -selectmode] ne "extended"} {
d455 1
a455 1
    if {$mode eq "extended"} {
d461 1
a461 1
    } elseif {$mode eq "multiple"} {
d479 1
a479 1
    if {[$w cget -selectmode] ne "extended"} {
d484 1
a484 1
    if { $last eq "" } {
d514 1
a514 1
    if {$mode eq "single" || $mode eq "browse"} {
@


1.12
log
@	Merged changes from feature branch dgp-privates-into-namespace,
	implementing TIP 44.  All Tk commands and variables matching
	tk[A-Z]* are now in the ::tk namespace.
@
text
@d6 1
a6 1
# RCS: @@(#) $Id: listbox.tcl,v 1.11 2000/03/24 19:38:57 ericm Exp $
d186 1
a186 1
if {[string equal "unix" $tcl_platform(platform)]} {
@


1.12.2.1
log
@First checkin of support for Tk on Mac OS X.
@
text
@d6 1
a6 1
# RCS: @@(#) $Id$
d186 1
a186 1
if {[string equal "x11" $tcl_platform(windowingsystem)]} {
@


1.12.2.2
log
@various project cleanups & enhancements
added macosx/Makefile to facilitate building from cli
added [tk windowingsystem] and removed $::tcl_plaform(windowingsystem)
changed all runtime library references to the above
removed duplicate entries in tk.decls & tkInt.decls
CONSTification and other small changes in macosx/ to remove compiler warnings
@
text
@d186 1
a186 1
if {[string equal "x11" [tk windowingsystem]]} {
@


1.11
log
@* tests/filebox.test:
* tests/choosedir.test: Updated tests.

* library/xmfbox.tcl: Updated to stash data array in
::tk::dialog::file namespace instead of in global namespace.

* library/tkfbox.tcl: Extended some functions to support creation
of a choosedir dialog, to allow greater code reuse between the two
dialogs.  Moved tkFDialog* functions into a namespace
(::tk::dialog::file).  Because these are private Tk functions (and
should thus not be used directly by users), this should not impact
anybody (the tk_getOpenFile and tk_getSaveFile commands still
exist at the global scope).

* library/tk.tcl:
* library/tclIndex: Updated function names for tkFDialog*
functions and choosedir functions.

* library/choosedir.tcl: New and improved implementation of
tk_chooseDirectory dialog.  Based on tk_getOpenFile dialog.

* library/listbox.tcl: (tkListboxCancel) Added a check for empty
string value for tkPriv(listboxPrev).  Without this check, it's
possible to get a stack trace under certain conditions. [Bug: 4373].
@
text
@d6 1
a6 1
# RCS: @@(#) $Id: listbox.tcl,v 1.10 2000/02/10 08:52:50 hobbs Exp $
d16 1
a16 1
# tkPriv elements used in this file:
d38 1
a38 1
	tkListboxBeginSelect %W [%W index @@%x,%y]
d51 3
a53 3
    set tkPriv(x) %x
    set tkPriv(y) %y
    tkListboxMotion %W [%W index @@%x,%y]
d56 1
a56 1
    tkCancelRepeat
d60 1
a60 1
    tkListboxBeginExtend %W [%W index @@%x,%y]
d63 1
a63 1
    tkListboxBeginToggle %W [%W index @@%x,%y]
d66 3
a68 3
    set tkPriv(x) %x
    set tkPriv(y) %y
    tkListboxAutoScan %W
d71 1
a71 1
    tkCancelRepeat
d75 1
a75 1
    tkListboxUpDown %W -1
d78 1
a78 1
    tkListboxExtendUpDown %W -1
d81 1
a81 1
    tkListboxUpDown %W 1
d84 1
a84 1
    tkListboxExtendUpDown %W 1
d126 1
a126 1
    tkListboxDataExtend %W 0
d136 1
a136 1
    tkListboxDataExtend %W [%W index end]
d145 1
a145 1
    tkListboxBeginSelect %W [%W index active]
d148 1
a148 1
    tkListboxBeginSelect %W [%W index active]
d151 1
a151 1
    tkListboxBeginExtend %W [%W index active]
d154 1
a154 1
    tkListboxBeginExtend %W [%W index active]
d157 1
a157 1
    tkListboxCancel %W
d160 1
a160 1
    tkListboxSelectAll %W
d203 1
a203 1
# tkListboxBeginSelect --
d215 2
a216 2
proc tkListboxBeginSelect {w el} {
    global tkPriv
d227 2
a228 2
	set tkPriv(listboxSelection) {}
	set tkPriv(listboxPrev) $el
d233 1
a233 1
# tkListboxMotion --
d243 3
a245 3
proc tkListboxMotion {w el} {
    global tkPriv
    if {$el == $tkPriv(listboxPrev)} {
d253 1
a253 1
	    set tkPriv(listboxPrev) $el
d257 1
a257 1
	    set i $tkPriv(listboxPrev)
d269 2
a270 2
	    if {![info exists tkPriv(listboxSelection)]} {
		set tkPriv(listboxSelection) [$w curselection]
d273 1
a273 1
		if {[lsearch $tkPriv(listboxSelection) $i] >= 0} {
d279 1
a279 1
		if {[lsearch $tkPriv(listboxSelection) $i] >= 0} {
d284 1
a284 1
	    set tkPriv(listboxPrev) $el
d290 1
a290 1
# tkListboxBeginExtend --
d302 1
a302 1
proc tkListboxBeginExtend {w el} {
d305 1
a305 1
	    tkListboxMotion $w $el
d308 1
a308 1
	    tkListboxBeginSelect $w $el
d313 1
a313 1
# tkListboxBeginToggle --
d325 2
a326 2
proc tkListboxBeginToggle {w el} {
    global tkPriv
d328 2
a329 2
	set tkPriv(listboxSelection) [$w curselection]
	set tkPriv(listboxPrev) $el
d340 1
a340 1
# tkListboxAutoScan --
d350 2
a351 2
proc tkListboxAutoScan {w} {
    global tkPriv
d353 2
a354 2
    set x $tkPriv(x)
    set y $tkPriv(y)
d366 2
a367 2
    tkListboxMotion $w [$w index @@$x,$y]
    set tkPriv(afterId) [after 50 [list tkListboxAutoScan $w]]
d370 1
a370 1
# tkListboxUpDown --
d380 2
a381 2
proc tkListboxUpDown {w amount} {
    global tkPriv
d394 2
a395 2
	    set tkPriv(listboxPrev) [$w index active]
	    set tkPriv(listboxSelection) {}
d401 1
a401 1
# tkListboxExtendUpDown --
d411 2
a412 1
proc tkListboxExtendUpDown {w amount} {
d417 1
a417 2
    if {![info exists tkPriv(listboxSelection)]} {
	global tkPriv
d419 1
a419 1
	set tkPriv(listboxSelection) [$w curselection]
d423 1
a423 1
    tkListboxMotion $w [$w index active]
d426 1
a426 1
# tkListboxDataExtend
d437 1
a437 1
proc tkListboxDataExtend {w el} {
d443 1
a443 1
	    tkListboxMotion $w $el
d451 1
a451 1
# tkListboxCancel
d461 2
a462 2
proc tkListboxCancel w {
    global tkPriv
d467 1
a467 1
    set last $tkPriv(listboxPrev)
d479 1
a479 1
	if {[lsearch $tkPriv(listboxSelection) $first] >= 0} {
d487 1
a487 1
# tkListboxSelectAll
d496 1
a496 1
proc tkListboxSelectAll w {
@


1.11.4.1
log
@update to head
@
text
@d6 1
a6 1
# RCS: @@(#) $Id: listbox.tcl,v 1.12 2001/08/01 16:21:11 dgp Exp $
d16 1
a16 1
# tk::Priv elements used in this file:
d38 1
a38 1
	tk::ListboxBeginSelect %W [%W index @@%x,%y]
d51 3
a53 3
    set tk::Priv(x) %x
    set tk::Priv(y) %y
    tk::ListboxMotion %W [%W index @@%x,%y]
d56 1
a56 1
    tk::CancelRepeat
d60 1
a60 1
    tk::ListboxBeginExtend %W [%W index @@%x,%y]
d63 1
a63 1
    tk::ListboxBeginToggle %W [%W index @@%x,%y]
d66 3
a68 3
    set tk::Priv(x) %x
    set tk::Priv(y) %y
    tk::ListboxAutoScan %W
d71 1
a71 1
    tk::CancelRepeat
d75 1
a75 1
    tk::ListboxUpDown %W -1
d78 1
a78 1
    tk::ListboxExtendUpDown %W -1
d81 1
a81 1
    tk::ListboxUpDown %W 1
d84 1
a84 1
    tk::ListboxExtendUpDown %W 1
d126 1
a126 1
    tk::ListboxDataExtend %W 0
d136 1
a136 1
    tk::ListboxDataExtend %W [%W index end]
d145 1
a145 1
    tk::ListboxBeginSelect %W [%W index active]
d148 1
a148 1
    tk::ListboxBeginSelect %W [%W index active]
d151 1
a151 1
    tk::ListboxBeginExtend %W [%W index active]
d154 1
a154 1
    tk::ListboxBeginExtend %W [%W index active]
d157 1
a157 1
    tk::ListboxCancel %W
d160 1
a160 1
    tk::ListboxSelectAll %W
d203 1
a203 1
# ::tk::ListboxBeginSelect --
d215 2
a216 2
proc ::tk::ListboxBeginSelect {w el} {
    variable ::tk::Priv
d227 2
a228 2
	set Priv(listboxSelection) {}
	set Priv(listboxPrev) $el
d233 1
a233 1
# ::tk::ListboxMotion --
d243 3
a245 3
proc ::tk::ListboxMotion {w el} {
    variable ::tk::Priv
    if {$el == $Priv(listboxPrev)} {
d253 1
a253 1
	    set Priv(listboxPrev) $el
d257 1
a257 1
	    set i $Priv(listboxPrev)
d269 2
a270 2
	    if {![info exists Priv(listboxSelection)]} {
		set Priv(listboxSelection) [$w curselection]
d273 1
a273 1
		if {[lsearch $Priv(listboxSelection) $i] >= 0} {
d279 1
a279 1
		if {[lsearch $Priv(listboxSelection) $i] >= 0} {
d284 1
a284 1
	    set Priv(listboxPrev) $el
d290 1
a290 1
# ::tk::ListboxBeginExtend --
d302 1
a302 1
proc ::tk::ListboxBeginExtend {w el} {
d305 1
a305 1
	    ListboxMotion $w $el
d308 1
a308 1
	    ListboxBeginSelect $w $el
d313 1
a313 1
# ::tk::ListboxBeginToggle --
d325 2
a326 2
proc ::tk::ListboxBeginToggle {w el} {
    variable ::tk::Priv
d328 2
a329 2
	set Priv(listboxSelection) [$w curselection]
	set Priv(listboxPrev) $el
d340 1
a340 1
# ::tk::ListboxAutoScan --
d350 2
a351 2
proc ::tk::ListboxAutoScan {w} {
    variable ::tk::Priv
d353 2
a354 2
    set x $Priv(x)
    set y $Priv(y)
d366 2
a367 2
    ListboxMotion $w [$w index @@$x,$y]
    set Priv(afterId) [after 50 [list tk::ListboxAutoScan $w]]
d370 1
a370 1
# ::tk::ListboxUpDown --
d380 2
a381 2
proc ::tk::ListboxUpDown {w amount} {
    variable ::tk::Priv
d394 2
a395 2
	    set Priv(listboxPrev) [$w index active]
	    set Priv(listboxSelection) {}
d401 1
a401 1
# ::tk::ListboxExtendUpDown --
d411 1
a411 2
proc ::tk::ListboxExtendUpDown {w amount} {
    variable ::tk::Priv
d416 2
a417 1
    if {![info exists Priv(listboxSelection)]} {
d419 1
a419 1
	set Priv(listboxSelection) [$w curselection]
d423 1
a423 1
    ListboxMotion $w [$w index active]
d426 1
a426 1
# ::tk::ListboxDataExtend
d437 1
a437 1
proc ::tk::ListboxDataExtend {w el} {
d443 1
a443 1
	    ListboxMotion $w $el
d451 1
a451 1
# ::tk::ListboxCancel
d461 2
a462 2
proc ::tk::ListboxCancel w {
    variable ::tk::Priv
d467 1
a467 1
    set last $Priv(listboxPrev)
d479 1
a479 1
	if {[lsearch $Priv(listboxSelection) $first] >= 0} {
d487 1
a487 1
# ::tk::ListboxSelectAll
d496 1
a496 1
proc ::tk::ListboxSelectAll w {
@


1.11.6.1
log
@2001-02-28  Don Porter  <dgp@@users.sourceforge.net>

        BRANCH dgp-privates-into-namespace:  Feature branch to move all
        of Tk's private commands and variable into the ::tk namespace
        and its children.

        * doc/tkvars.n:  Documented private variable tkPriv renamed tk::Priv.

        * generic/tkBind.c:
        * generic/tkMenu.c:
        * generic/tkTextDisp.c:
        * library/bgerror.tcl:
        * library/button.tcl:
        * library/choosedir.tcl:
        * library/clrpick.tcl:
        * library/comdlg.tcl:
        * library/console.tcl:
        * library/dialog.tcl:
        * library/entry.tcl:
        * library/focus.tcl:
        * library/listbox.tcl:
        * library/menu.tcl:
        * library/msgbox.tcl:
        * library/optMenu.tcl:
        * library/palette.tcl:
        * library/scale.tcl:
        * library/scrlbar.tcl:
        * library/spinbox.tcl:
        * library/tclIndex:
        * library/tearoff.tcl:
        * library/text.tcl:
        * library/tk.tcl:
        * library/tkfbox.tcl:
        * library/xmfbox.tcl:
        * mac/tkMacMenu.c:
        * tests/clrpick.test:
        * tests/filebox.test:
        * tests/macMenu.test:
        * tests/menu.test:
        * tests/menuDraw.test:
        * tests/msgbox.test:
        * tests/text.test:
        * tests/textDisp.test:
        * tests/unixMenu.test:
        * tests/winMenu.test:
        * tests/xmfbox.test:
        * unix/tkUnixDialog.c:  All Tk commands matching ::tk[A-Z]* and
        all Tk private variables in the global namespace were renamed to
        live in the namespace ::tk or one of its children.
@
text
@d6 1
a6 1
# RCS: @@(#) $Id: listbox.tcl,v 1.11 2000/03/24 19:38:57 ericm Exp $
d16 1
a16 1
# tk::Priv elements used in this file:
d38 1
a38 1
	tk::ListboxBeginSelect %W [%W index @@%x,%y]
d51 3
a53 3
    set tk::Priv(x) %x
    set tk::Priv(y) %y
    tk::ListboxMotion %W [%W index @@%x,%y]
d56 1
a56 1
    tk::CancelRepeat
d60 1
a60 1
    tk::ListboxBeginExtend %W [%W index @@%x,%y]
d63 1
a63 1
    tk::ListboxBeginToggle %W [%W index @@%x,%y]
d66 3
a68 3
    set tk::Priv(x) %x
    set tk::Priv(y) %y
    tk::ListboxAutoScan %W
d71 1
a71 1
    tk::CancelRepeat
d75 1
a75 1
    tk::ListboxUpDown %W -1
d78 1
a78 1
    tk::ListboxExtendUpDown %W -1
d81 1
a81 1
    tk::ListboxUpDown %W 1
d84 1
a84 1
    tk::ListboxExtendUpDown %W 1
d126 1
a126 1
    tk::ListboxDataExtend %W 0
d136 1
a136 1
    tk::ListboxDataExtend %W [%W index end]
d145 1
a145 1
    tk::ListboxBeginSelect %W [%W index active]
d148 1
a148 1
    tk::ListboxBeginSelect %W [%W index active]
d151 1
a151 1
    tk::ListboxBeginExtend %W [%W index active]
d154 1
a154 1
    tk::ListboxBeginExtend %W [%W index active]
d157 1
a157 1
    tk::ListboxCancel %W
d160 1
a160 1
    tk::ListboxSelectAll %W
d203 1
a203 1
# ::tk::ListboxBeginSelect --
d215 2
a216 2
proc ::tk::ListboxBeginSelect {w el} {
    variable ::tk::Priv
d227 2
a228 2
	set Priv(listboxSelection) {}
	set Priv(listboxPrev) $el
d233 1
a233 1
# ::tk::ListboxMotion --
d243 3
a245 3
proc ::tk::ListboxMotion {w el} {
    variable ::tk::Priv
    if {$el == $Priv(listboxPrev)} {
d253 1
a253 1
	    set Priv(listboxPrev) $el
d257 1
a257 1
	    set i $Priv(listboxPrev)
d269 2
a270 2
	    if {![info exists Priv(listboxSelection)]} {
		set Priv(listboxSelection) [$w curselection]
d273 1
a273 1
		if {[lsearch $Priv(listboxSelection) $i] >= 0} {
d279 1
a279 1
		if {[lsearch $Priv(listboxSelection) $i] >= 0} {
d284 1
a284 1
	    set Priv(listboxPrev) $el
d290 1
a290 1
# ::tk::ListboxBeginExtend --
d302 1
a302 1
proc ::tk::ListboxBeginExtend {w el} {
d305 1
a305 1
	    ListboxMotion $w $el
d308 1
a308 1
	    ListboxBeginSelect $w $el
d313 1
a313 1
# ::tk::ListboxBeginToggle --
d325 2
a326 2
proc ::tk::ListboxBeginToggle {w el} {
    variable ::tk::Priv
d328 2
a329 2
	set Priv(listboxSelection) [$w curselection]
	set Priv(listboxPrev) $el
d340 1
a340 1
# ::tk::ListboxAutoScan --
d350 2
a351 2
proc ::tk::ListboxAutoScan {w} {
    variable ::tk::Priv
d353 2
a354 2
    set x $Priv(x)
    set y $Priv(y)
d366 2
a367 2
    ListboxMotion $w [$w index @@$x,$y]
    set Priv(afterId) [after 50 [list tk::ListboxAutoScan $w]]
d370 1
a370 1
# ::tk::ListboxUpDown --
d380 2
a381 2
proc ::tk::ListboxUpDown {w amount} {
    variable ::tk::Priv
d394 2
a395 2
	    set Priv(listboxPrev) [$w index active]
	    set Priv(listboxSelection) {}
d401 1
a401 1
# ::tk::ListboxExtendUpDown --
d411 1
a411 2
proc ::tk::ListboxExtendUpDown {w amount} {
    variable ::tk::Priv
d416 2
a417 1
    if {![info exists Priv(listboxSelection)]} {
d419 1
a419 1
	set Priv(listboxSelection) [$w curselection]
d423 1
a423 1
    ListboxMotion $w [$w index active]
d426 1
a426 1
# ::tk::ListboxDataExtend
d437 1
a437 1
proc ::tk::ListboxDataExtend {w el} {
d443 1
a443 1
	    ListboxMotion $w $el
d451 1
a451 1
# ::tk::ListboxCancel
d461 2
a462 2
proc ::tk::ListboxCancel w {
    variable ::tk::Priv
d467 1
a467 1
    set last $Priv(listboxPrev)
d479 1
a479 1
	if {[lsearch $Priv(listboxSelection) $first] >= 0} {
d487 1
a487 1
# ::tk::ListboxSelectAll
d496 1
a496 1
proc ::tk::ListboxSelectAll w {
@


1.10
log
@	* library/listbox.tcl:
	* library/text.tcl: added support for <4> and <5> for mousewheel
	style scrolling on Unix for mice that map to these buttons.
@
text
@d6 1
a6 1
# RCS: @@(#) $Id: listbox.tcl,v 1.9 2000/01/06 02:22:24 hobbs Exp $
d468 4
@


1.9
log
@	* library/entry.tcl:
	* library/focus.tcl:
	* library/listbox.tcl:
	* library/scale.tcl:
	* library/scrlbar.tcl:
	* library/tearoff.tcl:
	* library/text.tcl:
	* library/tkfbox.tcl:
	* library/xmfbox.tcl: fixed unprotected arg parsing through eval/after
	[Bug: 3943]
@
text
@d6 1
a6 1
# RCS: @@(#) $Id: listbox.tcl,v 1.8 1999/12/21 23:55:27 hobbs Exp $
d184 17
@


1.8
log
@	* library/listbox.tcl: added extra checks for existence of
	tkPriv(listboxSelection) before it was used. [Bug: 3892]
@
text
@d6 1
a6 1
# RCS: @@(#) $Id: listbox.tcl,v 1.7 1999/09/02 17:02:52 hobbs Exp $
d350 1
a350 1
    set tkPriv(afterId) [after 50 tkListboxAutoScan $w]
@


1.7
log
@1999-09-01  Jeff Hobbs  <hobbs@@scriptics.com>

	* library/msgbox.tcl: changed the behavior of tk_messageBox on
	Unix to be more Windows like in handling of <Return> and the
	default button
	* library/button.tcl:
	* library/clrpick.tcl:
	* library/comdlg.tcl:
	* library/console.tcl:
	* library/dialog.tcl:
	* library/entry.tcl:
	* library/focus.tcl:
	* library/listbox.tcl:
	* library/menu.tcl:
	* library/msgbox.tcl:
	* library/palette.tcl:
	* library/safetk.tcl:
	* library/scale.tcl:
	* library/scrlbar.tcl:
	* library/tearoff.tcl:
	* library/text.tcl:
	* library/tk.tcl:
	* library/tkfbox.tcl:
	* library/xmfbox.tcl: updated commands to use [string] ops
	instead of expr equality operators
@
text
@d6 1
a6 1
# RCS: @@(#) $Id: listbox.tcl,v 1.6 1999/08/09 16:52:06 hobbs Exp $
d252 3
d398 7
a404 1
    $w activate [expr {[$w index active] + $amount}]
@


1.6
log
@1999-08-09  Jeff Hobbs  <hobbs@@scriptics.com>

	* library/button.tcl: cleaned up programming (config -> configure)
	and fixed Windows relief bug [Bug: 664]
	* library/entry.tcl: changed Entry C/C/P to not use global data
	(now uses tkPriv(data)) [Bug: 1475]
	* library/listbox.tcl: fixed extended mode script error [Bug: 866]
@
text
@d6 1
a6 1
# RCS: @@(#) $Id: listbox.tcl,v 1.5 1999/04/16 01:51:26 stanton Exp $
d139 1
a139 1
    if {![string compare [selection own -displayof %W] "%W"]} {
d165 1
a165 1
      event generate %W <<ListboxSelect>>
d200 1
a200 1
    if {![string compare [$w cget -selectmode] "multiple"]} {
d283 1
a283 1
    if {![string compare [$w cget -selectmode] "extended"]} {
d307 1
a307 1
    if {![string compare [$w cget -selectmode] "extended"]} {
d316 1
a316 1
      event generate $w <<ListboxSelect>>
d368 1
a368 1
          event generate $w <<ListboxSelect>>
d376 1
a376 1
          event generate $w <<ListboxSelect>>
d413 1
a413 1
    if {![string compare $mode "extended"]} {
d419 1
a419 1
    } elseif {![string compare $mode "multiple"]} {
d468 1
a468 1
    if {![string compare $mode "single"] || ![string compare $mode "browse"]} {
@


1.5
log
@* Merged 8.1 branch into the main trunk
@
text
@d6 1
a6 1
# RCS: @@(#) $Id$
d237 1
a237 1
          event generate $w <<ListboxSelect>>
d241 4
d265 1
a265 1
          event generate $w <<ListboxSelect>>
@


1.4
log
@
Added support for the MouseWheel event.
@
text
@d6 1
a6 1
# RCS: @@(#) $Id: listbox.tcl,v 1.3 1998/09/14 18:23:23 stanton Exp $
d123 1
d133 1
d139 1
a139 1
    if {[selection own -displayof %W] == "%W"} {
d163 1
a163 1
    if {[%W cget -selectmode] != "browse"} {
d165 1
d183 1
a183 1
    %W yview scroll [expr - (%D / 120) * 4] units
d200 1
a200 1
    if {[$w cget -selectmode]  == "multiple"} {
d213 1
d237 1
d261 1
d279 1
a279 1
    if {[$w cget -selectmode] == "extended"} {
a283 1

d303 1
a303 1
    if {[$w cget -selectmode] == "extended"} {
d312 1
d364 1
d372 1
d388 1
a388 1
    if {[$w cget -selectmode] != "extended"} {
d409 1
a409 1
    if {$mode == "extended"} {
d415 1
a415 1
    } elseif {$mode == "multiple"} {
d433 1
a433 1
    if {[$w cget -selectmode] != "extended"} {
d450 1
d464 1
a464 1
    if {($mode == "single") || ($mode == "browse")} {
d470 1
@


1.3
log
@Replaced SCCS strings, fixed binary files
@
text
@d6 1
a6 1
# RCS: @@(#) $Id$
d10 1
d173 8
@


1.2
log
@plugin updates
@
text
@d6 1
a6 1
# SCCS: @@(#) listbox.tcl 1.21 97/06/10 17:13:55
@


1.1
log
@Initial revision
@
text
@d36 1
a36 1
    if [winfo exists %W] {
d189 1
a189 1
	if [$w selection includes $el] {
d227 1
a227 1
	    if [$w selection includes anchor] {
d293 1
a293 1
	if [$w selection includes $el] {
d343 1
a343 1
    $w activate [expr [$w index active] + $amount]
d374 1
a374 1
    $w activate [expr [$w index active] + $amount]
d395 1
a395 1
        if [$w selection includes anchor] {
@


1.1.4.1
log
@initial tk8.1a2 version
@
text
@d6 1
a6 1
# SCCS: @@(#) listbox.tcl 1.22 97/12/03 15:28:59
d36 1
a36 1
    if {[winfo exists %W]} {
d189 1
a189 1
	if {[$w selection includes $el]} {
d227 1
a227 1
	    if {[$w selection includes anchor]} {
d293 1
a293 1
	if {[$w selection includes $el]} {
d343 1
a343 1
    $w activate [expr {[$w index active] + $amount}]
d374 1
a374 1
    $w activate [expr {[$w index active] + $amount}]
d395 1
a395 1
        if {[$w selection includes anchor]} {
@


1.1.4.2
log
@Merged 8.0.3 changes into 8.1
@
text
@d6 1
a6 1
# RCS: @@(#) $Id: listbox.tcl,v 1.3 1998/09/14 18:23:23 stanton Exp $
@


1.1.4.3
log
@* integrated tk8.0.4 changes.

* generic/tkBind.c: fixed deletion order bug where a crash would
result if a binding deleted "."
@
text
@d6 1
a6 1
# RCS: @@(#) $Id: listbox.tcl,v 1.1.4.2 1998/09/30 02:17:33 stanton Exp $
a9 1
# Copyright (c) 1998 by Scriptics Corporation.
a171 8
}

# The MouseWheel will typically only fire on Windows.  However,
# someone could use the "event generate" command to produce one
# on other platforms.

bind Listbox <MouseWheel> {
    %W yview scroll [expr - (%D / 120) * 4] units
@


1.1.4.4
log
@* library/bgerror.tcl:
* library/button.tcl:
* library/clrpick.tcl:
* library/console.tcl:
* library/dialog.tcl:
* library/entry.tcl:
* library/focus.tcl:
* library/listbox.tcl:
* library/menu.tcl:
* library/msgbox.tcl:
* library/palette.tcl:
* library/scale.tcl:
* library/scrlbar.tcl:
* library/tearoff.tcl:
* library/text.tcl:
* library/tk.tcl: Lots of minor performance improvements
contributed by Jeffrey Hobbs. [Bug: 1118]
@
text
@d6 1
a6 1
# RCS: @@(#) $Id$
a122 1
    event generate %W <<ListboxSelect>>
a131 1
    event generate %W <<ListboxSelect>>
d137 1
a137 1
    if {![string compare [selection own -displayof %W] "%W"]} {
d161 1
a161 1
    if {[string compare [%W cget -selectmode] "browse"]} {
a162 1
      event generate %W <<ListboxSelect>>
d180 1
a180 1
    %W yview scroll [expr {- (%D / 120) * 4}] units
d197 1
a197 1
    if {![string compare [$w cget -selectmode] "multiple"]} {
a209 1
    event generate $w <<ListboxSelect>>
a232 1
          event generate $w <<ListboxSelect>>
a255 1
          event generate $w <<ListboxSelect>>
d273 1
a273 1
    if {![string compare [$w cget -selectmode] "extended"]} {
d278 1
d298 1
a298 1
    if {![string compare [$w cget -selectmode] "extended"]} {
a306 1
      event generate $w <<ListboxSelect>>
a357 1
          event generate $w <<ListboxSelect>>
a364 1
          event generate $w <<ListboxSelect>>
d380 1
a380 1
    if {[string compare [$w cget -selectmode] "extended"]} {
d401 1
a401 1
    if {![string compare $mode "extended"]} {
d407 1
a407 1
    } elseif {![string compare $mode "multiple"]} {
d425 1
a425 1
    if {[string compare [$w cget -selectmode] "extended"]} {
a441 1
    event generate $w <<ListboxSelect>>
d455 1
a455 1
    if {![string compare $mode "single"] || ![string compare $mode "browse"]} {
a460 1
    event generate $w <<ListboxSelect>>
@


