Tcl-Tk-Tkwidget-treectrl

 view release on metacpan or  search on metacpan

demos/biglist.tcl  view on Meta::CPAN

	    $T item state forcolumn $I colItem openE
	    $T item state forcolumn $I colID openWE
	    $T item state forcolumn $I colParent openW
	    continue
	}

	# Citizen info
	if {[$T item tag expr $I info]} {
	    set w [NewWindow $T $parent]
	    $T item style set $I colItem styCitizen
	    $T item span $I colItem 3
	    $T item element configure $I colItem \
		elemWindow -window $w
	}
    }

    # Clear the styles of each item that is no longer visible on screen.
    foreach I $hidden {

	# Citizen info
	if {[$T item tag expr $I info]} {
	    # Add this window to the list of unused windows
	    set w [$T item element cget $I colItem elemWindow -window]
	    FreeWindow $T $w
	}
	$T item style set $I colItem "" colParent "" colID ""
    }
    return
}

proc DemoBigList::NewWindow {T I} {
    variable Priv

    # Check the list of unused windows
    if {[llength $Priv(freeWindows)]} {
	set w [lindex $Priv(freeWindows) 0]
	set Priv(freeWindows) [lrange $Priv(freeWindows) 1 end]
	if {$::clip} {
	    set f $w
	    set w [lindex [winfo children $f] 0]
	}

	if {$Priv(noise)} { dbwin "reuse window $w" }

    # No unused windows exist. Create a new one.
    } else {
	set id [incr Priv(nextWindowId)]
	if {$::clip} {
	    set f [frame $T.clip$id -background blue]
	    set w [frame $f.frame$id -background $Priv(bg)]
	} else {
	    set w [frame $T.frame$id -background $Priv(bg)]
	}
	# Name: label + entry
	label $w.label1 -text "Name:" -anchor w -background $Priv(bg)
	$::entryCmd $w.entry1 -width 24

	# Threat Level: label + menubutton
	label $w.label2 -text "Threat Level:" -anchor w -background $Priv(bg)
	if {$::tile} {
	    ttk::combobox $w.mb2 -values {Severe High Elevated Guarded Low} \
		-state readonly -width [string length "Elevated"]
	} else {
	    menubutton $w.mb2 -indicatoron yes -menu $w.mb2.m \
		-width [string length Elevated] -relief raised
	    menu $w.mb2.m -tearoff no
	    foreach label {Severe High Elevated Guarded Low} {
		$w.mb2.m add radiobutton -label $label \
		    -value $label \
		    -command [list $w.mb2 configure -text $label]
	    }
	}

	# Button
	set message \
	    "After abducting and probing these people over the last\n\
	    50 years, the only thing we've learned for certain is that\n\
	    one in ten just doesn't seem to mind."
	if {$::thisPlatform ne "windows"} {
	    set message [string map {\n ""} $message]
	}
	$::buttonCmd $w.b3 -text "Anal Probe Wizard..." -command [list tk_messageBox \
	    -parent . -message $message -title "Anal Probe 2.0"]

	grid $w.label1 -row 0 -column 0 -sticky w -padx {0 8}
	grid $w.entry1 -row 0 -column 1 -sticky w -pady 4
	grid $w.label2 -row 1 -column 0 -sticky w -padx {0 8}
	grid $w.mb2 -row 1 -column 1 -sticky w -pady 4
	grid $w.b3 -row 3 -column 0 -columnspan 2 -sticky we -pady {0 4}

	AddBindTag $w DemoBigListChildWindow
	AddBindTag $w TagIdentify

	if {$Priv(noise)} { dbwin "create window $w" }
    }

    # Tie the widgets to the global variables for this citizen
    $w.entry1 configure -textvariable ::DemoBigList::Priv(name,$I)
    $w.mb2 configure -textvariable ::DemoBigList::Priv(threat,$I)
    if {!$::tile} {
	foreach label {Severe High Elevated Guarded Low} {
	    $w.mb2.m entryconfigure $label -variable ::DemoBigList::Priv(threat,$I)
	}
    }
    if {$::clip} { return $f }
    return $w
}

proc DemoBigList::FreeWindow {T w} {
    variable Priv

    # Add the window to our list of free windows. DemoClear will actually
    # delete the window when the demo changes.
    lappend Priv(freeWindows) $w
    if {$Priv(noise)} { dbwin "free window $w" }
    return
}

proc DemoBigList::Button1 {w x y} {
    variable ::TreeCtrl::Priv
    focus $w



( run in 2.669 seconds using v1.01-cache-2.11-cpan-364913b4093 )