Unnamed Fossil Project

Check-in [6ce1f45125]
Login

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

Overview
Comment:initial version
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:6ce1f45125d586a0654f97208331fd8630e907f0
User & Date: arnulf 2013-09-14 20:51:48
Context
2013-09-14
20:52
fixes for treeview widget check-in: ce09562856 user: arnulf tags: trunk
20:51
initial version check-in: 6ce1f45125 user: arnulf tags: trunk
20:49
initial version check-in: 933694c7ea user: arnulf tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added library/ntkTTreeview.tcl.































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
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
698
699
700
701
702
703
#---------------------------------------------------------------------------
# ntkWidget ntkTTreeview.tcl --
#
# This file contains a ntkWidget treeview commands implementation
#
# this code is derived from the tile/ttk implementation written by
# Joe English
#
# Copyright (c) 2013 by Arnulf P. Wiedemann
#
# See the file "license.terms" for information on usage and redistribution of
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# @(#) $Id: ntkTTreeview.tcl
#--------------------------------------------------------------------------

namespace eval ::ntk {

::itcl::extendedclass treeview {
    inherit classes::widget classes::utils

    protected variable paned
    protected variable panedManagerSpec

    public option [list -orient orient Orient] -default vertical
    public option [list -height height Height] -default 0
    public option [list -width width Width] -default 0

    constructor {args} {}

    private method IsMapped {widget}
    private method PaneRequest {managerData index width height}
    private method PaneRemoved {managerData index}
    private method PanedPlaceSlaves {managerData}
    public method PanedInitialize {recordPtr}
    public method PanedCleanup {args}
    private method ShoveUp {index pos}
    private method ShoveDown {index pos}
    private method SashLayout {index}
    private method PlaceSashes {panedInfo width height}
    public method PanedPostConfigure {recordPtr mask}
    public method PanedConfigure {args}
    public method PanedGetLayout {theme recordPtr}
    private method ReqHeight {window}
    private method ReqWidth {window}
    public method PanedSize {recordPtr widthVar heightVar}
    private method DrawSash {index}
    public method PanedDisplay {}

    private method CreatePane {slaveWindow}
    private method DestroyPane {widget}
    private method ConfigurePane {pane slaveWindow args}
    private method AddPane {destIndex slaveWindow args}
    public method PanedAddCommand {args} 
    public method add {args}
    public method PanedForgetCommand {args} 
    public method PanedIdentify {args} 
    public method PanedInsertCommand {args} 
    public method PanedPaneCommand {args} 
    public method PanedPanesCommand {args} 
    public method PanedSashposCommand {args} 
}

#================================ constructor ============================
#     
#=========================================================================

::itcl::body treeview::constructor {args} {
#puts stderr "treeview::constructor!"
    dict set core optionTable -orient [dict create];
    dict set core optionTable -orient type string
    dict set core optionTable -orient clientData ""
    dict set core optionTable -orient typeMask [list readonlyOption styleChanged]

    dict set core optionTable -height [dict create];
    dict set core optionTable -height type int
    dict set core optionTable -height clientData ""
    dict set core optionTable -height typeMask geometryChanged

    dict set core optionTable -width [dict create];
    dict set core optionTable -width type int
    dict set core optionTable -width clientData ""
    dict set core optionTable -width typeMask geometryChanged

    set TreeviewCommands [dict create]
    dict set TreeviewCommands add PanedAddCommand
    dict set TreeviewCommands cget WidgetCget
    dict set TreeviewCommands configure WidgetConfigure
    dict set TreeviewCommands forget PanedForgetCommand
    dict set TreeviewCommands identify PanedIdentify
    dict set TreeviewCommands insert PanedInsertCommand
    dict set TreeviewCommands instate WidgetInState
    dict set TreeviewCommands pane PanedPaneCommand
    dict set TreeviewCommands panes PanedPanesCommand
    dict set TreeviewCommands sashpos PanedSashposCommand
    dict set TreeviewCommands state WidgetState

    set widgetSpec [dict create]
    dict set widgetSpec className "TTreeview"
    dict set widgetSpec commands $TreeviewCommands
    dict set widgetSpec initializeProc PanedInitialize
    dict set widgetSpec cleanupProc PanedCleanup
    dict set widgetSpec configureProc PanedConfigure
    dict set widgetSpec postConfigureProc PanedPostConfigure
    dict set widgetSpec getLayoutProc PanedGetLayout
    dict set widgetSpec sizeProc PanedSize
    dict set widgetSpec layoutProc WidgetDoLayout
    dict set widgetSpec displayProc PanedDisplay
    dict set core widgetSpec $widgetSpec
    
    set paned [dict create]
    dict set paned width 0
    dict set paned height 0
    set panedManagerSpec [dict create]

    WidgetInit $args

    dict set core takeFocus 1
}

#================================ IsMapped ============================
#
#=========================================================================

::itcl::body treeview::IsMapped {widget} {
puts stderr "IsMapped!$widget!"
    # FIXME !!! temporary
    return 1
}

#================================ PaneRequest ============================
# PaneRequest --
#     Only update pane request size if slave is currently unmapped.
#     Geometry requests from mapped slaves are not directly honored
#     in order to avoid unexpected pane resizes (esp. while the
#     user is dragging a sash [#1325286]).
#=========================================================================

::itcl::body treeview::PaneRequest {managerData index width height} {
puts stderr "PaneRequest"
    set pane [::ntk::classes::manager::SlaveData [dict get $managerData mgr] $index
    set slaveWindow [::ntk::classes::manager::SlaveWindow [dict get $managerData mgr] $index]
    if {[cget -orient] eq "horizontal"} {
        set horizontal 1
    } else {
        set horizontal 0
    }
    if {[IsMapped $slaveWindow]} {
        if {$horizontal} {
            dict set pane reqSize $width
        } else {
            dict set pane reqSize $height
        }
    }
    return 1
}

#================================ PaneRemove ============================
#     
#=========================================================================

::itcl::body treeview::PaneRemoved {managerData index} {
puts stderr "PaneRemoved"
    set pane [::ntk::classes::manager::SlaveData [dict get $managerData mgr] $index
    DestroyPane $pane
}

#================================ PanedPlaceSlaves ============================
#     
#=========================================================================

::itcl::body treeview::PanedPlaceSlaves {managerData} {
#puts stderr "PanedPlaceSlaves"
    PlaceSashes $managerData [dict get $core width] [dict get $core height]
    PlacePanes $managerData
}

#================================ PanedInitialize ============================
#     Initialization hooks.
#=========================================================================

::itcl::body treeview::PanedInitialize {recordPtr} {
#puts stderr "PanedInitialize!"

    dict set panedManagerSpec requestedSize PanedSize
    dict set panedManagerSpec placeSlaves PanedPlaceSlaves
    dict set panedManagerSpec slaveRequest PaneRequest
    dict set panedManagerSpec slaveRemoved PaneRemoved
    #
    # CreateEventHandler(pw->core.tkwin, PanedEventMask, PanedEventProc, recordPtr)
    dict set paned mgr [::ntk::classes::manager::CreateManager $panedManagerSpec $recordPtr [dict get $core tkwin]]
    dict set paned sashLayout 0
    dict set paned sashThickness 1
    dict set paned weight 0
}

#================================ PanedCleanup ============================
#     Cleanup hooks.
#=========================================================================

::itcl::body treeview::PanedCleanup {recordPtr} {
    dict set paned sashLayout ""
    ::ntk::classes::manager::DeleteManager [dict get $paned mgr]
    dict set paned mgr ""
}

#================================ PanedConfigure ============================
#     
#=========================================================================

::itcl::body treeview::PanedConfigure {recordPtr mask} {
#puts stderr "PanedConfigure!$mask!"
    CoreConfigure $mask
}

#================================ ShoveUp ============================
# ShoveUp --
#     Place sash i at specified position, recursively shoving
#     previous sashes upwards as needed, until hitting the top
#     of the window.  If that happens, shove back down.
# 
#     Returns: final position of sash i.
#=========================================================================

::itcl::body treeview::ShoveUp {index pos} {
puts stderr "ShoveUp!$i!$pos!"
    set pane [::ntk::classes::manager::SlaveData [dict get $paned mgr] $index]
    set sashThickness [dict get $paned sashThickness]

    if {$index == 0} {
        if {$pos < 0} {
            set pos 0
        }
    } else {
        set prevPane [::ntk::classes::manager::SlaveData [dict get $paned mgr] [expr {$index-1}]]
        if {$pos < [dict get $prevPane sashPos] + $sashThickness} {
            set pos [expr {[ShoveUp $panedInfo [expr {$index-1}] [expr {$pos - $sashThickness}]] + $sashThickness}]
        }
    }
    dict set pane sashPos $pos
    set mgr [dict get $paned mgr]
    ::ntk::classes::manager::SetSlaveData mgr $index $pane]
    dict set paned mgr $mgr
    return $pos
}

#================================ ShoveDown ============================
# ShoveDown --
#     Same as ShoveUp, but going in the opposite direction
#     and stopping at the sentinel sash.
#=========================================================================

::itcl::body treeview::ShoveDown {index pos} {
puts stderr "ShoveDown!$index!$pos!"
    set pane [::ntk::classes::manager::SlaveData [dict get $paned mgr] $index]
    set sashThickness [dict get $paned sashThickness]

    if {$index == [NumberSlaves [dict get $paned mgr]] - 1} {
        set pos [dict get $pane sashPos] ; # Sentinel value == master window size
    } else {
        set nextPane [::ntk::classes::manager::SlaveData [dict get $paned mgr] [expr {$index+1}]]
        if {$pos + $sashThickness > [dict get $nextPane sashPos]} {
            set pos [expr {[ShoveDown $panedInfo [expr {$index+1}] [expr {$pos + $sashThickness}]] - $sashThickness}]
        }
    }
    dict set paned sashPos $pos
    return $pos
}

#================================ PlaceSashes ============================
# PlaceSashes --
#     Set sash positions from pane request sizes and available space.
#     The sentinel sash position is set to the available space.
# 
#     Allocate pane->reqSize pixels to each pane, and distribute
#     the difference = available size - requested size according
#     to pane weight.
# 
#     If there's still some left over, squeeze panes from the bottom up
#     (This can happen if all weights are zero, or if one or more panes
#     are too small to absorb the required shrinkage).
# 
# Notes:
#     This doesn't distribute the remainder pixels as evenly as it could
#     when more than one pane has weight > 1.
#=========================================================================

::itcl::body treeview::PlaceSashes {panedInfo width height} {
#puts stderr "PlaceSashes!w!$width!h!$height!"
    set mgr [dict get $paned mgr]
    set nPanes [::ntk::classes::manager::NumberSlaves $mgr]
    set sashThickness [dict get $paned sashThickness]
    if {[cget -orient] eq "horizontal"} {
        set available $width
    } else {
        set available $height
    }
    set reqSize 0
    set totalWeight 0

    if {$nPanes == 0} {
       return
    }

    # Compute total required size and total available weight:

    set i 0
    while {$i < $nPanes} {
         set pane [::ntk::classes::manager::SlaveData $mgr $i]
         set reqSize [expr {$reqSize + [dict get $pane reqSize]}]
         set totalWeight [expr {$totalWeight + [dict get $pane weight] * ([dict get $pane reqSize] != 0)}];
	 incr i
    }
    # Compute difference to be redistributed:

    set difference [expr {$available - $reqSize - $sashThickness*($nPanes-1)}]
    if {$totalWeight != 0} {
        set delta [expr {$difference / $totalWeight}]
        set remainder [expr {$difference % $totalWeight}]
        if {$remainder < 0} {
            incr delta -1
            set remainder [expr {$remainder + $totalWeight}]
        }
     } else {
        set delta 0
	set remainder 0
     }
     # ASSERT: 0 <= remainder < totalWeight */

     # Place sashes:
     set pos 0
     set i 0
     while {$i < $nPanes} {
         set pane [::ntk::classes::manager::SlaveData $mgr $i]
         set weight [expr {[dict get $pane weight] * ([dict get $pane reqSize] != 0)}]
         set size [expr {[dict get $pane reqSize] + $delta * $weight}]

         if {$weight > $remainder} {
             set weight $remainder
         }
         set remainder [expr {$rmeainder - $weight}]
         set size [expr {$size + $weight}]

         if {$size < 0} {
             set size 0
         }

	 set pos [expr {$pos + $size}]
         dict set pane sashPos $pos
         ::ntk::classes::manager::SetSlaveData mgr $i $pane]
         dict set paned mgr $mgr
         set pos [expr {$pos + $sashThickness}]
	 incr i
    }

    # Handle emergency shrink/emergency stretch:
    # Set sentinel sash position to end of widget,
    # shove preceding sashes up.
    ShoveUp $pane [expr {$nPanes - 1}] $available
}

#================================ PanedPostConfigure ============================
#     Post-configuration hook.
#=========================================================================

::itcl::body treeview::PanedPostConfigure {recordPtr mask} {
#puts stderr "PanedPostConfigure!$mask!"
    if {[lsearch $mask "geometryChanged"]} {
        # User has changed -width or -height.
        # Recalculate sash positions based on requested size.
 
        set tkwin [dict get $core tkwin]
	set width [dict get $paned width]
	if {$width <= 0} {
            set width [dict get $core width]
	}
	set height [dict get $paned height]
	if {$height <= 0} {
            set height [dict get $core height]
	}
        PlaceSashes $paned $width $height
    }
}

#================================ PanedGetLayout ============================
# Layout management hooks.
#=========================================================================

::itcl::body treeview::PanedGetLayout {theme recordPtr} {
#puts stderr "PanedGetLayout!$theme!"
    set panedLayout [WidgetGetLayout $theme $recordPtr]

    if {$panedLayout ne ""} {
        if {[cget -orient] eq "horizontal"} {
            set  horizontal 1
        } else {
            set  horizontal 0
        }
	if {$horizontal} {
            set layoutName ".Vertical.Sash"
        } else {
            set layoutName ".Horizontal.Sash"
        }
        set sashLayout [::ntk::classes::layout::CreateSubLayout $theme $panedLayout $core $layoutName ""]

        if {$sashLayout ne ""} {
            ::ntk::classes::layout::LayoutSize $sashLayout 0 sashWidth sashHeight
	    if {$horizontal} {
                dict set paned sashThickness $sashWidth
            } else {
                dict set paned sashThickness $sashHeight
            }

            if {[dict get $paned sashLayout] ne ""} {
                dict set paned sashLayout ""
            }
            dict set paned sashLayout $sashLayout
        } else {
            return 0
        }
    }
#puts stderr "PanedGetLayout END"
    return $panedLayout
}

#================================ ReqHeight ============================
#
#=========================================================================

::itcl::body treeview::ReqHeight {window} {
# FIXME !!! temporary
    return 16
}

#================================ ReqWidth ============================
#
#=========================================================================

::itcl::body treeview::ReqWidth {window} {
# FIXME !!! temporary
    return 70
}

#================================ PanedSize ============================
# PanedSize --
#     Compute the requested size of the paned widget
#     from the individual pane request sizes.
# 
#     Used as the WidgetSpec sizeProc and the ManagerSpec sizeProc.
#=========================================================================

::itcl::body treeview::PanedSize {recordPtr widthVar heightVar} {
    upvar $widthVar width
    upvar $heightVar height
#puts stderr "PanedSize!"
    set nPanes [::ntk::classes::manager::NumberSlaves [dict get $paned mgr]]
    set nSashes [expr {$nPanes - 1}]
    set sashThickness [dict get $paned sashThickness]
#puts stderr "nPanes!$nPanes!$nSashes!$sashThickness!"
    set mywidth 0
    set myheight 0

    if {[cget -orient] eq "horizontal"} {
        set index 0
        while {$index < $nPanes} {
            set pane [::ntk::classes::manager::SlaveData [dict get $paned mgr] $index]
            set slaveWindow [::ntk::classes::manager::SlaveWindow [dict get $paned mgr] $index]

            if {$myheight < [ReqHeight $slaveWindow]} {
                set myheight [ReqHeight $slaveWindow]
            }
            set mywidth [expr {$mywidth + [dict get $pane reqSize]}]
            incr index
        }
        set mywidth [expr {$mywidth + $nSashes * $sashThickness}]
#puts stderr "mywidth!$mywidth!"
    } else {
        set index 0
        while {$index < $nPanes} {
            set pane [::ntk::classes::manager::SlaveData [dict get $paned mgr] $index]
            set slaveWindow [::ntk::classes::manager::SlaveWindow [dict get $paned mgr] $index]

            if {$mywidth < [ReqWidth $slaveWindow]} {
                set mywidth [ReqWidth $slaveWindow]
            }
            set mywidth [ReqWidth $slaveWindow]
            set myheight [expr {$myheight + [dict get $pane reqSize]}]
            incr index
        }
        set myheight [expr {$myheight + $nSashes * $sashThickness}]
    }

    if {[dict get $paned width] > 0} {
        set width [dict get $paned width]
    } else {
        set width $mywidth;
    }
    if {[dict get $paned height] > 0} {
        set height [dict get $paned height]
    } else {
        set height $myheight;
    }
puts stderr "PanedSize END!$width!$height!"
    return 1
}

#================================ SashLayout ============================
# SashLayout --
#     Place the sash sublayout after the specified pane,
#     in preparation for drawing.
#=========================================================================

::itcl::body treeview::SashLayout {index} {
#puts stderr "SashLayout!$index!"
#puts stderr "SashLayout!mgr!"
    set pane [::ntk::classes::manager::SlaveData [dict get $paned mgr] $index]
    set thickness [dict get $paned sashThickness]
    set height [dict get $core height]
    set width [dict get $core width]
    set sashPos [dict get $pane sashPos]

    if {[cget -orient] eq "horizontal"} {
        set box [list $sashPos 0 $thickness $height]
    } else {
        set box [list 0 $sashPos $width $thickness]
    }
    set sashLayout [dict get $paned sashLayout]
    ::ntk::classes::layout::PlaceLayout sashLayout [dict get $core state] $box
    dict set paned sashLayout $sashLayout
    return $sashLayout
}

#================================ DrawSash ============================
#     
#=========================================================================

::itcl::body treeview::DrawSash {index} {
puts stderr "DrawSash!$index!"
    ::ntk::classes::layout::DrawLayout [SashLayout $index] [dict get $core state]
}

#================================ PanedDisplay ============================
#     
#=========================================================================

::itcl::body treeview::PanedDisplay {} {
#puts stderr "PanedDisplay!"
    set nSashes [expr {[::ntk::classes::manager::NumberSlaves [dict get $paned mgr]] - 1}]
    WidgetDisplay
    set i 0
    while {$i < $nSashes} {
        DrawSash $i
        incr i
    }
}

#================================ CreatePane ============================
# CreatePane --
#     Create a new pane record.
#=========================================================================

::itcl::body treeview::CreatePane {slaveWindow} {
#puts stderr "CreatePane!$slaveWindow!"
    set mypane [dict create]
    if {[cget -orient] eq "horizontal"} {
        set reqSize [$slaveWindow cget -width]
    } else {
        set reqSize [$slaveWindow cget -height]
    }
    dict set mypane reqSize $reqSize
    dict set mypane sashPos 0
    dict set mypane weight 0
    return $mypane
}

#================================ DestroyPane ============================
# DestroyPane --
#     Free pane record.
#=========================================================================

::itcl::body treeview::DestroyPane {pane} {
puts stderr "DestroyPane!$pane!"
}

#================================ ConfigurePane ============================
# ConfigurePane --
#     Set pane options.
#=========================================================================

::itcl::body treeview::ConfigurePane {pane slaveWindow args} {
#puts stderr "ConfigurePane!$pane!"
    set mgr [dict get $paned mgr]
    set mask [list]
#    if (Tk_SetOptions(interp, (void*)pane, pw->paned.paneOptionTable,
#        objc, objv, slaveWindow, &savedOptions, &mask) != TCL_OK) {
#        return TCL_ERROR;
#    }

    # Sanity-check:
    if {[dict get $pane weight] < 0} {
#        Tk_RestoreSavedOptions(&savedOptions);
        return -code error "-weight must be nonnegative"
    }

    # Done.
#    Tk_FreeSavedOptions(&savedOptions);
    ::ntk::classes::manager::ManagerSizeChanged $mgr
    return 0
}

#================================ AddPane ============================
# 
#=========================================================================

::itcl::body treeview::AddPane {destIndex slaveWindow args} {
#puts stderr "AddPane!$destIndex!$slaveWindow!$args!"
#    if (!Ttk_Maintainable(interp, slaveWindow, pw->core.tkwin)) {
#        return TCL_ERROR;
#    }
    if {[::ntk::classes::manager::SlaveIndex [dict get $paned mgr] $slaveWindow] >= 0} {
        return -code error "$slaveWindow already added"
    }

    set pane [CreatePane $slaveWindow]
    if {[ConfigurePane $pane $slaveWindow $args] != 0} {
        DestroyPane $pane
        return
    }

    set mgr [dict get $paned mgr]
    ::ntk::classes::manager::InsertSlave mgr $destIndex $slaveWindow $pane
    dict set paned mgr $mgr
#puts stderr "AddPane end"
}

#================================ PanedAddCommand ============================
#     
#=========================================================================

::itcl::body treeview::PanedAddCommand {args} {
#puts stderr "PanedAddCommand!$args!"
    set slaveWindow [lindex $args 0]
    return [AddPane [::ntk::classes::manager::NumberSlaves [dict get $paned mgr]] $slaveWindow [lrange $args 1 end]]
}

#================================ add ============================
#     
#=========================================================================

::itcl::body treeview::add {args} {
#puts stderr "add!$args!"
    return [PanedAddCommand {*}$args]
}

#================================ PanedForgetCommand ============================
#     
#=========================================================================

::itcl::body treeview::PanedForgetCommand {args} {
puts stderr "PanedForgetCommand!$args!"
}

#================================ PanedIdentifyCommand ============================
#     
#=========================================================================

::itcl::body treeview::PanedIdentify {args} {
puts stderr "PanedIdentifyCommand!$args!"
}

#================================ PanedInsertCommand ============================
#     
#=========================================================================

::itcl::body treeview::PanedInsertCommand {args} {
puts stderr "PanedInsertCommand!$args!"
}

#================================ PanedPaneCommand ============================
#     
#=========================================================================

::itcl::body treeview::PanedPaneCommand {args} {
puts stderr "PanedPaneCommand!$args!"
}

#================================ PanedPanesCommand ============================
#     
#=========================================================================

::itcl::body treeview::PanedPanesCommand {args} {
puts stderr "PanedPanesCommand!$args!"
}

#================================ PanedSashposCommand ============================
#     
#=========================================================================

::itcl::body treeview::PanedSashposCommand {args} {
puts stderr "PanedSashposCommand!$args!"
}

} ; # end namespace ::ntk::classes