2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
|
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
|
-
+
|
}
}
#####################################
# GUI stuff
#####################################
# A little helper to make a scrolled window
# A little helper to make a window with scrollbars
# It returns the name of the scrolled window
proc Scroll {dir class w args} {
switch -- $dir {
both {
set scrollx 1
set scrolly 1
}
|
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
|
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
grid $w.sby -row 0 -column 1 -sticky ns
}
grid columnconfigure $w 0 -weight 1
grid rowconfigure $w 0 -weight 1
return $w.s
}
# Rearrange a dynamic grid to a specified number of columns
proc DynGridRearrange {w cols} {
# Go down columns first. Thus we must know how many rows there will be.
set children [grid slaves $w._dyn]
set rows [expr {([llength $children] + $cols - 1) / $cols}]
set row 0
set col 0
foreach child $children {
grid $child -row $row -column $col
grid columnconfigure $w._dyn $col -uniform a
incr row
if {$row >= $rows} {
incr col
set row 0
}
}
# Clear other columns from uniform in case we shrunk
if {$row != 0} {
incr col
}
for {} {$col < 15} {incr col} {
grid columnconfigure $w._dyn $col -uniform ""
}
# Recalculate
update idletasks
# Propagate Height
set height [winfo reqheight $w._dyn]
$w configure -width 100 -height $height
}
# Update dynamic grid on configure event
proc DynGridRedo {w} {
set maxW 0
set children [grid slaves $w._dyn]
foreach child $children {
set maxW [expr {max($maxW,[winfo reqwidth $child])}]
}
set fW [winfo width $w]
set cols [expr {max(1,$fW / $maxW)}]
# Rerrange if needed
lassign [grid size $w._dyn] mCols mRows
if {$mCols != $cols} {
DynGridRearrange $w $cols
}
}
# Ask for widget to have its children managed by dynGrid.
proc dynGridManage {w} {
# Limit its inital requirements
pack propagate $w 0
$w configure -width 100 -height 10
set children [winfo children $w]
# Add an inner frame
ttk::frame $w._dyn
lower $w._dyn
pack $w._dyn -fill both -expand 1
# Get all children managed
grid {*}$children -in $w._dyn -padx 3 -pady 3 -sticky w
# React
bind $w <Configure> "DynGridRedo $w"
}
################
# Align function
################
proc enableAlign {top} {
eval $::widgets($top,enableAlignCmd)
|