Tk Library Source Code

Check-in [bddf6d5624]
Login
Bounty program for improvements to Tcl and certain Tcl packages.

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

Overview
Comment: * scripts/scrollarea.tcl: Improved the handling of the case that the scrollbar lock prevented a scrollbar of a scrollarea widget from being unmapped.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: bddf6d5624103af6fd143abe09f9c82f34794919d13a82e91579646c9e245612
User & Date: csaba 2020-02-05 18:08:40
Context
2020-02-05
18:09
* scripts/wheelEvent.tcl: Creating mouse wheel event class bindings for the Tk core scrollbar widget on Windows and X11, which are missing on these platforms when using a Tk version earlier than 8.6. check-in: ff86f0ffea user: csaba tags: trunk
18:08
* scripts/scrollarea.tcl: Improved the handling of the case that the scrollbar lock prevented a scrollbar of a scrollarea widget from being unmapped. check-in: bddf6d5624 user: csaba tags: trunk
18:07
* CHANGES.txt: Updated to reflect the changes. check-in: 81baf657e5 user: csaba tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to modules/scrollutil/scripts/scrollarea.tcl.

662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
...
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
...
812
813
814
815
816
817
818















819
820
821
822
823
824
825
...
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
...
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888


889
























proc scrollutil::sa::onDynamicHScrollbarMap hsb {
    set top [winfo toplevel $hsb]
    if {![winfo ismapped $top]} {
	return ""
    }

    foreach {first last} [$hsb get] {}
    if {$first == 0 && $last == 1} {
	return ""
    }

    set textWidgetFound 0
    set sa [winfo parent $hsb]
    set widget [::$sa widget]
    set class [winfo class $widget]
    if {[string compare $class "Text"]  == 0 ||
	[string compare $class "Ctext"] == 0} {
	set textWidgetFound 1
    } elseif {[string compare $class "Scrollsync"] == 0} {
	foreach w [::$widget widgets] {
	    set class [winfo class $w]
	    if {[string compare $class "Text"]  == 0 ||
		[string compare $class "Ctext"] == 0} {
		set textWidgetFound 1
		break
	    }
	}
    }
    if {!$textWidgetFound} {
	return ""
    }

    #
    # Guard against a potential endless loop by making sure that
    # showing the horizontal scrollbar won't make the toplevel higher
    #
................................................................................
	}
	grid $win.hsb		   -row 2 -column 0 -columnspan 2 -sticky ew
    }
    set data(hsbManaged) 1

    if {[winfo ismapped $win]} {
	set data(hsbLocked) 1
	after $data(-lockinterval) \
	    [list scrollutil::sa::unlockScrollbar $win hsb]
    }
}

#------------------------------------------------------------------------------
# scrollutil::sa::hideHScrollbar
#------------------------------------------------------------------------------
proc scrollutil::sa::hideHScrollbar win {
................................................................................
    if {[string compare $data(-xscrollbarmode) "dynamic"] == 0} {
	foreach {first last} [$win.hsb get] {}
	if {$first == 0 && $last == 1} {
	    hideHScrollbar $win
	}
    }
}
















#------------------------------------------------------------------------------
# scrollutil::sa::showVScrollbar
#------------------------------------------------------------------------------
proc scrollutil::sa::showVScrollbar {win {redisplay 0}} {
    upvar ::scrollutil::ns${win}::data data
    if {$data(vsbManaged) && !$redisplay} {
................................................................................
	}
	grid $win.vsb		   -row 0 -rowspan 2 -column 2 -sticky ns
    }
    set data(vsbManaged) 1

    if {[winfo ismapped $win]} {
	set data(vsbLocked) 1
	after $data(-lockinterval) \
	    [list scrollutil::sa::unlockScrollbar $win vsb]
    }
}

#------------------------------------------------------------------------------
# scrollutil::sa::hideVScrollbar
#------------------------------------------------------------------------------
proc scrollutil::sa::hideVScrollbar win {
................................................................................
	if {$first == 0 && $last == 1} {
	    hideVScrollbar $win
	}
    }
}

#------------------------------------------------------------------------------
# scrollutil::sa::unlockScrollbar
#------------------------------------------------------------------------------
proc scrollutil::sa::unlockScrollbar {win sb} {
    if {[winfo exists $win] &&
	[string compare [winfo class $win] "Scrollarea"] == 0} {
	upvar ::scrollutil::ns${win}::data data
	set data(${sb}Locked) 0
    }


}






























|
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







|
<







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|
<







 







|

|



|
|
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
662
663
664
665
666
667
668
669




670
















671
672
673
674
675
676
677
...
755
756
757
758
759
760
761
762

763
764
765
766
767
768
769
...
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
...
829
830
831
832
833
834
835
836

837
838
839
840
841
842
843
...
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
proc scrollutil::sa::onDynamicHScrollbarMap hsb {
    set top [winfo toplevel $hsb]
    if {![winfo ismapped $top]} {
	return ""
    }

    foreach {first last} [$hsb get] {}
    if {($first == 0 && $last == 1) ||




	![containsTextWidget [winfo parent $hsb]]} {
















	return ""
    }

    #
    # Guard against a potential endless loop by making sure that
    # showing the horizontal scrollbar won't make the toplevel higher
    #
................................................................................
	}
	grid $win.hsb		   -row 2 -column 0 -columnspan 2 -sticky ew
    }
    set data(hsbManaged) 1

    if {[winfo ismapped $win]} {
	set data(hsbLocked) 1
	after $data(-lockinterval) [list scrollutil::sa::unlockHScrollbar $win]

    }
}

#------------------------------------------------------------------------------
# scrollutil::sa::hideHScrollbar
#------------------------------------------------------------------------------
proc scrollutil::sa::hideHScrollbar win {
................................................................................
    if {[string compare $data(-xscrollbarmode) "dynamic"] == 0} {
	foreach {first last} [$win.hsb get] {}
	if {$first == 0 && $last == 1} {
	    hideHScrollbar $win
	}
    }
}

#------------------------------------------------------------------------------
# scrollutil::sa::unlockHScrollbar
#------------------------------------------------------------------------------
proc scrollutil::sa::unlockHScrollbar win {
    if {[winfo exists $win] &&
	[string compare [winfo class $win] "Scrollarea"] == 0} {
	upvar ::scrollutil::ns${win}::data data
	set data(hsbLocked) 0

	if {$data(-lockinterval) <= 1 && ![containsTextWidget $win]} {
	    updateHScrollbar $win
	}
    }
}

#------------------------------------------------------------------------------
# scrollutil::sa::showVScrollbar
#------------------------------------------------------------------------------
proc scrollutil::sa::showVScrollbar {win {redisplay 0}} {
    upvar ::scrollutil::ns${win}::data data
    if {$data(vsbManaged) && !$redisplay} {
................................................................................
	}
	grid $win.vsb		   -row 0 -rowspan 2 -column 2 -sticky ns
    }
    set data(vsbManaged) 1

    if {[winfo ismapped $win]} {
	set data(vsbLocked) 1
	after $data(-lockinterval) [list scrollutil::sa::unlockVScrollbar $win]

    }
}

#------------------------------------------------------------------------------
# scrollutil::sa::hideVScrollbar
#------------------------------------------------------------------------------
proc scrollutil::sa::hideVScrollbar win {
................................................................................
	if {$first == 0 && $last == 1} {
	    hideVScrollbar $win
	}
    }
}

#------------------------------------------------------------------------------
# scrollutil::sa::unlockVScrollbar
#------------------------------------------------------------------------------
proc scrollutil::sa::unlockVScrollbar win {
    if {[winfo exists $win] &&
	[string compare [winfo class $win] "Scrollarea"] == 0} {
	upvar ::scrollutil::ns${win}::data data
	set data(vsbLocked) 0

	if {$data(-lockinterval) <= 1} {
	    updateVScrollbar $win
	}
    }
}

#------------------------------------------------------------------------------
# scrollutil::sa::containsTextWidget
#------------------------------------------------------------------------------
proc scrollutil::sa::containsTextWidget win {
    set widget [::$win widget]
    set class [winfo class $widget]
    if {[string compare $class "Text"]  == 0 ||
	[string compare $class "Ctext"] == 0} {
	return 1
    } elseif {[string compare $class "Scrollsync"] == 0} {
	foreach w [::$widget widgets] {
	    set class [winfo class $w]
	    if {[string compare $class "Text"]  == 0 ||
		[string compare $class "Ctext"] == 0} {
		return 1
	    }
	}
    }

    return 0
}