figenc

[RADIOACTIVE] rsa and symmetric key encryption scripts and executables
git clone git://git.figbert.com/figenc.git
Log | Files | Refs | README

panedwindow.tcl (1920B)


      1 #
      2 # Bindings for ttk::panedwindow widget.
      3 #
      4 
      5 namespace eval ttk::panedwindow {
      6     variable State
      7     array set State {
      8 	pressed 0
      9     	pressX	-
     10 	pressY	-
     11 	sash 	-
     12 	sashPos -
     13     }
     14 }
     15 
     16 ## Bindings:
     17 #
     18 bind TPanedwindow <ButtonPress-1> 	{ ttk::panedwindow::Press %W %x %y }
     19 bind TPanedwindow <B1-Motion>		{ ttk::panedwindow::Drag %W %x %y }
     20 bind TPanedwindow <ButtonRelease-1> 	{ ttk::panedwindow::Release %W %x %y }
     21 
     22 bind TPanedwindow <Motion> 		{ ttk::panedwindow::SetCursor %W %x %y }
     23 bind TPanedwindow <Enter> 		{ ttk::panedwindow::SetCursor %W %x %y }
     24 bind TPanedwindow <Leave> 		{ ttk::panedwindow::ResetCursor %W }
     25 # See <<NOTE-PW-LEAVE-NOTIFYINFERIOR>>
     26 bind TPanedwindow <<EnteredChild>>	{ ttk::panedwindow::ResetCursor %W }
     27 
     28 ## Sash movement:
     29 #
     30 proc ttk::panedwindow::Press {w x y} {
     31     variable State
     32 
     33     set sash [$w identify $x $y]
     34     if {$sash eq ""} {
     35     	set State(pressed) 0
     36 	return
     37     }
     38     set State(pressed) 	1
     39     set State(pressX) 	$x
     40     set State(pressY) 	$y
     41     set State(sash) 	$sash
     42     set State(sashPos)	[$w sashpos $sash]
     43 }
     44 
     45 proc ttk::panedwindow::Drag {w x y} {
     46     variable State
     47     if {!$State(pressed)} { return }
     48     switch -- [$w cget -orient] {
     49     	horizontal 	{ set delta [expr {$x - $State(pressX)}] }
     50     	vertical 	{ set delta [expr {$y - $State(pressY)}] }
     51     }
     52     $w sashpos $State(sash) [expr {$State(sashPos) + $delta}]
     53 }
     54 
     55 proc ttk::panedwindow::Release {w x y} {
     56     variable State
     57     set State(pressed) 0
     58     SetCursor $w $x $y
     59 }
     60 
     61 ## Cursor management:
     62 #
     63 proc ttk::panedwindow::ResetCursor {w} {
     64     variable State
     65     if {!$State(pressed)} {
     66 	ttk::setCursor $w {}
     67     }
     68 }
     69 
     70 proc ttk::panedwindow::SetCursor {w x y} {
     71     set cursor ""
     72     if {[llength [$w identify $x $y]]} {
     73     	# Assume we're over a sash.
     74 	switch -- [$w cget -orient] {
     75 	    horizontal 	{ set cursor hresize }
     76 	    vertical 	{ set cursor vresize }
     77 	}
     78     }
     79     ttk::setCursor $w $cursor
     80 }
     81 
     82 #*EOF*