summaryrefslogtreecommitdiff
path: root/itcl/iwidgets/generic/tabnotebook.itk
blob: 7e8be370cf06cfc4583bfa8c93e346920af7f3cd (plain)
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
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
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
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
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
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
#
# Tabnotebook Widget
# ----------------------------------------------------------------------
# The Tabnotebook command creates a new window (given by the pathName 
# argument) and makes it into a Tabnotebook widget. Additional options, 
# described above may be specified on the command line or in the option 
# database to configure aspects of the Tabnotebook such as its colors, 
# font, and text. The Tabnotebook command returns its pathName argument. 
# At the time this command is invoked, there must not exist a window 
# named pathName, but pathName's parent must exist.
# 
# A Tabnotebook is a widget that contains a set of tabbed pages. It 
# displays one page from the set as the selected page. A Tab displays 
# the label for the page to which it is attached and serves as a page 
# selector.   When a page's tab is selected, the page's contents are 
# displayed in the page area. The selected tab has a three-dimensional 
# effect to make it appear to float above the other tabs. The tabs are 
# displayed as a group along either the left, top, right, or bottom 
# edge. When first created a Tabnotebook has no pages. Pages may be 
# added or deleted using widget commands described below.
# 
# A special option may be provided to the Tabnotebook. The -auto 
# option specifies whether the Tabnotebook will automatically handle 
# the unpacking and packing of pages when pages are selected. A value 
# of true sig nifies that the notebook will automatically manage it. This 
# is the default value. A value of false signifies the notebook will not 
# perform automatic switching of pages.
# 
# ----------------------------------------------------------------------
#  AUTHOR: Bill W. Scott
#
#  CURRENT MAINTAINER: Chad Smith --> csmith@adc.com or itclguy@yahoo.com
#
#  @(#) $Id$
# ----------------------------------------------------------------------
#            Copyright (c) 1995 DSC Technologies Corporation
# ======================================================================
# Permission to use, copy, modify, distribute and license this software 
# and its documentation for any purpose, and without fee or written 
# agreement with DSC, is hereby granted, provided that the above copyright 
# notice appears in all copies and that both the copyright notice and 
# warranty disclaimer below appear in supporting documentation, and that 
# the names of DSC Technologies Corporation or DSC Communications 
# Corporation not be used in advertising or publicity pertaining to the 
# software without specific, written prior permission.
# 
# DSC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 
# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, AND NON-
# INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE
# AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, 
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. IN NO EVENT SHALL 
# DSC BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 
# ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 
# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTUOUS ACTION,
# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 
# SOFTWARE.
# ======================================================================

#
# Default resources.
#
option add *Tabnotebook.borderWidth 2 widgetDefault
option add *Tabnotebook.state normal widgetDefault
option add *Tabnotebook.disabledForeground #a3a3a3 widgetDefault
option add *Tabnotebook.scrollCommand {} widgetDefault
option add *Tabnotebook.equalTabs true widgetDefault
option add *Tabnotebook.font \
	-Adobe-Helvetica-Bold-R-Normal--*-120-*-*-*-*-*-* widgetDefault
option add *Tabnotebook.width 300 widgetDefault
option add *Tabnotebook.height 150 widgetDefault
option add *Tabnotebook.foreground Black widgetDefault
option add *Tabnotebook.background #d9d9d9 widgetDefault
option add *Tabnotebook.tabForeground Black widgetDefault
option add *Tabnotebook.tabBackground #d9d9d9 widgetDefault
option add *Tabnotebook.backdrop #d9d9d9 widgetDefault
option add *Tabnotebook.margin 4 widgetDefault
option add *Tabnotebook.tabBorders true widgetDefault
option add *Tabnotebook.bevelAmount 0 widgetDefault
option add *Tabnotebook.raiseSelect false widgetDefault
option add *Tabnotebook.auto true widgetDefault
option add *Tabnotebook.start 4 widgetDefault
option add *Tabnotebook.padX 4 widgetDefault
option add *Tabnotebook.padY 4 widgetDefault
option add *Tabnotebook.gap overlap widgetDefault
option add *Tabnotebook.angle 15 widgetDefault
option add *Tabnotebook.tabPos s widgetDefault

#
# Usual options.
#
itk::usual Tabnotebook {
    keep -backdrop -background -borderwidth -cursor -disabledforeground \
	 -font -foreground -tabbackground -tabforeground
}

# ------------------------------------------------------------------
#                            TABNOTEBOOK
# ------------------------------------------------------------------
itcl::class iwidgets::Tabnotebook {
    inherit itk::Widget
    
    constructor {args} {}
    destructor {}
    
    itk_option define -borderwidth borderWidth BorderWidth 2 
    itk_option define -state state State normal
    itk_option define \
	    -disabledforeground disabledForeground DisabledForeground #a3a3a3
    itk_option define -scrollcommand scrollCommand ScrollCommand {}
    itk_option define -equaltabs equalTabs EqualTabs true
    itk_option define -font font Font \
	    -Adobe-Helvetica-Bold-R-Normal--*-120-*-*-*-*-*-*
    itk_option define -width width Width 300
    itk_option define -height height Height 150
    itk_option define -foreground foreground Foreground Black
    itk_option define -background background Background  #d9d9d9
    itk_option define -tabforeground tabForeground TabForeground Black
    itk_option define -tabbackground tabBackground TabBackground #d9d9d9
    itk_option define -backdrop backdrop Backdrop #d9d9d9
    itk_option define -margin margin Margin 4 
    itk_option define -tabborders tabBorders TabBorders true 
    itk_option define -bevelamount bevelAmount BevelAmount 0 
    itk_option define -raiseselect raiseSelect RaiseSelect false 
    itk_option define -auto auto Auto true
    itk_option define -start start Start 4 
    itk_option define -padx padX PadX 4 
    itk_option define -pady padY PadY 4 
    itk_option define -gap gap Gap overlap 
    itk_option define -angle angle Angle 15 
    itk_option define -tabpos tabPos TabPos s 
    
    public method add { args }
    public method configure { args } 
    public method childsite { args }
    public method delete { args } 
    public method index { args } 
    public method insert { index args }
    public method prev { } 
    public method next { }
    public method pageconfigure { index args } 
    public method select { index } 
    public method view { args } 
    
    protected method _reconfigureTabset { } 
    protected method _canvasReconfigure { wid hgt }
    protected method _pageReconfigure { pageName page wid hgt }
    
    private method _getArgs { optList args }
    private method _redrawBorder { wid hgt } 
    private method _recomputeBorder { }
    private method _pack { tabPos } 
    private method _resize {newWidth_ newHeight_}
    
    private variable _canvasWidth 0       ;# currently tabnote canvas width
    private variable _canvasHeight 0      ;# currently tabnote canvas height
    private variable _nbOptList {}        ;# list of notebook options available
    private variable _tsOptList {}        ;# list of tabset options available
    
    private variable _tabPos s            ;# holds -tabPos, because of ordering
    
    private variable _borderRecompute false   ;# did we dirty border after cfg?
    private variable _tabsetReconfigure false ;# did we dirty tabsets after cfg?
    
}


# ----------------------------------------------------------------------
#                              CONSTRUCTOR
# ----------------------------------------------------------------------
itcl::body iwidgets::Tabnotebook::constructor {args} {
    # The following conditional added for SF ticket #514222.   csmith 9/5/02
    if {$::tk_version > 8.3} {
      component hull configure -borderwidth 0 -padx 0 -pady 0
    } else {
      component hull configure -borderwidth 0
    }

    #
    # Create the outermost canvas to maintain geometry.
    #
    itk_component add canvas {
	canvas $itk_interior.canvas -highlightthickness 0
    } {
	keep -cursor -background -width -height
    }
    bind $itk_component(canvas) <Configure> [itcl::code $this _resize %w %h]

    
    
    # .......................
    # Create the NOTEBOOK
    #
    itk_component add notebook {
	iwidgets::Notebook $itk_interior.canvas.notebook 
    } {
	keep -cursor -background 
    }
    
    #
    # Ouch, create a dummy page, go pageconfigure to get its options
    # and munge them into a list for later doling by pageconfigure
    #
    $itk_component(notebook) add
    set nbConfigList [$itk_component(notebook) pageconfigure 0]
    foreach config $nbConfigList {
	lappend _nbOptList [lindex $config 0]
    }
    $itk_component(notebook) delete 0
    
    # 
    # Create the tabset.
    #
    itk_component add tabset {
	iwidgets::Tabset $itk_interior.canvas.tabset \
		-command [itcl::code $this component notebook select]
    } {
	keep -cursor 
    }
    
    eval itk_initialize $args
    
    #
    # Ouch, create a dummy tab, go tabconfigure to get its options
    # and munge them into a list for later doling by pageconfigure
    #
    $itk_component(tabset) add
    set tsConfigList [$itk_component(tabset) tabconfigure 0]
    foreach config $tsConfigList {
	lappend _tsOptList [lindex $config 0]
    }
    $itk_component(tabset) delete 0
    
    bind $itk_component(tabset) <Configure> \
	    [itcl::code $this _reconfigureTabset]
    
    _pack $_tabPos
    $itk_component(hull) configure -width [cget -width] -height [cget -height]
}

proc ::iwidgets::tabnotebook {pathName args} {
    uplevel ::iwidgets::Tabnotebook $pathName $args
}


# -------------------------------------------------------------
# DESTRUCTOR: destroy the Tabnotebook
# -------------------------------------------------------------
itcl::body iwidgets::Tabnotebook::destructor {} {
}

# ----------------------------------------------------------------------
# OPTION -borderwidth
#
# Thickness of Notebook Border
# ----------------------------------------------------------------------
itcl::configbody iwidgets::Tabnotebook::borderwidth {
    if {$itk_option(-borderwidth) != {}} {
	#_recomputeBorder
	set _borderRecompute true
    }
}

# ----------------------------------------------------------------------
# OPTION -state
#
# State of the tabs in the tab notebook: normal or disabled
# ----------------------------------------------------------------------
itcl::configbody iwidgets::Tabnotebook::state {
    if {$itk_option(-state) != {}} {
	$itk_component(tabset) configure -state $itk_option(-state)
	#_reconfigureTabset
	set _tabsetReconfigure true
	
    }
}

# ----------------------------------------------------------------------
# OPTION -disabledforeground
#
# Specifies a foreground color to use for displaying a 
# tab's label when its state is disabled.
# ----------------------------------------------------------------------
itcl::configbody iwidgets::Tabnotebook::disabledforeground {
    
    if {$itk_option(-disabledforeground) != {}} {
	$itk_component(tabset) configure \
		-disabledforeground $itk_option(-disabledforeground)
	#_reconfigureTabset
	set _tabsetReconfigure true
    }
}

# ----------------------------------------------------------------------
# OPTION -scrollcommand
#
# Standard option. See options man pages.
# ----------------------------------------------------------------------
itcl::configbody iwidgets::Tabnotebook::scrollcommand {
    
    if {$itk_option(-scrollcommand) != {}} {
	$itk_component(notebook) \
		configure -scrollcommand $itk_option(-scrollcommand)
    }
}

# ----------------------------------------------------------------------
# OPTION -equaltabs
#
# Specifies whether to force tabs to be equal sized or not. 
# A value of true means constrain tabs to be equal sized. 
# A value of false allows each tab to size based on the text 
# label size. The value may have any of the forms accepted by 
# the Tcl_GetBoolean, such as true, false, 0, 1, yes, or no.
# ----------------------------------------------------------------------
itcl::configbody iwidgets::Tabnotebook::equaltabs {
    
    if {$itk_option(-equaltabs) != {}} {
	$itk_component(tabset) \
		configure -equaltabs $itk_option(-equaltabs)
	#_reconfigureTabset
	set _tabsetReconfigure true
    }
}

# ----------------------------------------------------------------------
# OPTION -font
#
# Font for tab labels when they are set to text (-label set)
# ----------------------------------------------------------------------
itcl::configbody iwidgets::Tabnotebook::font {
    
    if {$itk_option(-font) != {}} {
	$itk_component(tabset) configure -font $itk_option(-font)
	#_reconfigureTabset
	set _tabsetReconfigure true
    }
}

# ----------------------------------------------------------------------
# OPTION -width
#
# Width of the Tabnotebook
# ----------------------------------------------------------------------
itcl::configbody iwidgets::Tabnotebook::width {
    if {$itk_option(-width) != {}} {
	$itk_component(canvas) configure -width $itk_option(-width)
	#_recomputeBorder
	set _borderRecompute true
    }
}

# ----------------------------------------------------------------------
# OPTION -height
#
# Height of the Tabnotebook
# ----------------------------------------------------------------------
itcl::configbody iwidgets::Tabnotebook::height {
    if {$itk_option(-height) != {}} {
	$itk_component(canvas) configure -height $itk_option(-height)
	#_recomputeBorder
	set _borderRecompute true
    }
}

# ----------------------------------------------------------------------
# OPTION -foreground
#
# Specifies a foreground color to use for displaying a page 
# and its associated tab label (this is the selected state).
# ----------------------------------------------------------------------
itcl::configbody iwidgets::Tabnotebook::foreground {
    
    if {$itk_option(-foreground) != {}} {
	$itk_component(tabset) configure \
		-selectforeground $itk_option(-foreground)
    }
}

# ----------------------------------------------------------------------
# OPTION -background
#
# Specifies a background color to use for displaying a page 
# and its associated tab bg (this is the selected state).
# ----------------------------------------------------------------------
itcl::configbody iwidgets::Tabnotebook::background {
    
    if {$itk_option(-background) != {}} {
	$itk_component(tabset) configure \
		-selectbackground $itk_option(-background)
	#_recomputeBorder
	set _borderRecompute true
    }
}

# ----------------------------------------------------------------------
# OPTION -tabforeground
#
# Specifies a foreground color to use for displaying tab labels 
# when they are in their unselected state.
# ----------------------------------------------------------------------
itcl::configbody iwidgets::Tabnotebook::tabforeground {
    
    if {$itk_option(-tabforeground) != {}} {
	$itk_component(tabset) configure \
		-foreground $itk_option(-tabforeground)
    }
}

# ----------------------------------------------------------------------
# OPTION -tabbackground
#
# Specifies a background color to use for displaying tab backgrounds 
# when they are in their unselected state.
# ----------------------------------------------------------------------
itcl::configbody iwidgets::Tabnotebook::tabbackground {
    
    if {$itk_option(-tabbackground) != {}} {
	$itk_component(tabset) configure \
		-background $itk_option(-tabbackground)
    }
}

# ----------------------------------------------------------------------
# OPTION -backdrop
#
# Specifies a background color to use when filling in the 
# area behind the tabs.
# ----------------------------------------------------------------------
itcl::configbody iwidgets::Tabnotebook::backdrop {
    
    if {$itk_option(-backdrop) != {}} {
	$itk_component(tabset) configure \
		-backdrop $itk_option(-backdrop)
    }
}

# ----------------------------------------------------------------------
# OPTION -margin
#
# Sets the backdrop margin between tab edge and backdrop edge
# ----------------------------------------------------------------------
itcl::configbody iwidgets::Tabnotebook::margin {
    if {$itk_option(-margin) != {}} {
	$itk_component(tabset) configure -margin $itk_option(-margin)
    }
}

# ----------------------------------------------------------------------
# OPTION -tabborders
#
# Boolean that specifies whether to draw the borders of
# the unselected tabs (tabs in background)
# ----------------------------------------------------------------------
itcl::configbody iwidgets::Tabnotebook::tabborders {
    if {$itk_option(-tabborders) != {}} {
	$itk_component(tabset) \
		configure -tabborders $itk_option(-tabborders)
	#_reconfigureTabset
	set _tabsetReconfigure true
    }
}

# ----------------------------------------------------------------------
# OPTION -bevelamount
#
# Specifies pixel size of tab corners. 0 means no corners.
# ----------------------------------------------------------------------
itcl::configbody iwidgets::Tabnotebook::bevelamount {
    if {$itk_option(-bevelamount) != {}} {
	$itk_component(tabset) \
		configure -bevelamount $itk_option(-bevelamount)
	#_reconfigureTabset
	set _tabsetReconfigure true
    }
}

# ----------------------------------------------------------------------
# OPTION -raiseselect
#
# Sets whether to raise selected tabs
# ----------------------------------------------------------------------
itcl::configbody iwidgets::Tabnotebook::raiseselect {
    if {$itk_option(-raiseselect) != {}} {
	$itk_component(tabset) \
		configure -raiseselect $itk_option(-raiseselect)
	#_reconfigureTabset
	set _tabsetReconfigure true
    }
}

# ----------------------------------------------------------------------
# OPTION -auto
#
# Determines whether pages are automatically unpacked and
# packed when pages get selected.
# ----------------------------------------------------------------------
itcl::configbody iwidgets::Tabnotebook::auto {
    if {$itk_option(-auto) != {}} {
	$itk_component(notebook) configure -auto $itk_option(-auto)
    }
}

# ----------------------------------------------------------------------
# OPTION -start
# ----------------------------------------------------------------------
itcl::configbody iwidgets::Tabnotebook::start {
    
    if {$itk_option(-start) != {}} {
	$itk_component(tabset) configure \
		-start $itk_option(-start)
	#_reconfigureTabset
	set _tabsetReconfigure true
    }
}

# ----------------------------------------------------------------------
# OPTION -padx
#
# Specifies a non-negative value indicating how much extra space 
# to request for a tab around its label in the X-direction. 
# When computing how large a window it needs, the tab will add 
# this amount to the width it would normally need The tab will 
# end up with extra internal space to the left and right of its 
# text label. This value may have any of the forms acceptable 
# to Tk_GetPixels.
# ----------------------------------------------------------------------
itcl::configbody iwidgets::Tabnotebook::padx {
    
    if {$itk_option(-padx) != {}} {
	$itk_component(tabset) configure -padx $itk_option(-padx)
	#_reconfigureTabset
	set _tabsetReconfigure true
    }
}

# ----------------------------------------------------------------------
# OPTION -pady
#
# Specifies a non-negative value indicating how much extra space to 
# request for a tab around its label in the Y-direction. When computing 
# how large a window it needs, the tab will add this amount to the 
# height it would normally need The tab will end up with extra internal 
# space to the top and bot tom of its text label. This value may have 
# any of the forms acceptable to Tk_GetPixels.
# ----------------------------------------------------------------------
itcl::configbody iwidgets::Tabnotebook::pady {
    
    if {$itk_option(-pady) != {}} {
	$itk_component(tabset) configure -pady $itk_option(-pady)
	#_reconfigureTabset
	set _tabsetReconfigure true
    }
}

# ----------------------------------------------------------------------
# OPTION -gap
#
# Specifies the amount of pixel space to place between each tab. 
# Value may be any pixel offset value. In addition, a special keyword 
# 'overlap' can be used as the value to achieve a standard overlap of 
# tabs. This value may have any of the forms acceptable to Tk_GetPixels.
# ----------------------------------------------------------------------
itcl::configbody iwidgets::Tabnotebook::gap {
    
    if {$itk_option(-gap) != {}} {
	$itk_component(tabset) configure -gap $itk_option(-gap)
	#_reconfigureTabset
	set _tabsetReconfigure true
    }
}

# ----------------------------------------------------------------------
# OPTION -angle
#
# Specifes the angle of slope from the inner edge to the outer edge 
# of the tab. An angle of 0 specifies square tabs. Valid ranges are 
# 0 to 45 degrees inclusive. Default is 15 degrees. If tabPos is 
# e or w, this option is ignored.
# ----------------------------------------------------------------------
itcl::configbody iwidgets::Tabnotebook::angle {
    
    if {$itk_option(-angle) != {}} {
	$itk_component(tabset) configure -angle $itk_option(-angle)
	#_reconfigureTabset
	set _tabsetReconfigure true
    }
}

# ----------------------------------------------------------------------
# OPTION -tabpos
#
# Specifies the location of the set of tabs in relation to the 
# Notebook area. Must be n, s, e, or w.   Defaults to s.
# ----------------------------------------------------------------------
itcl::configbody iwidgets::Tabnotebook::tabpos {
    
    if {$itk_option(-tabpos) != {}} {
	set _tabPos $itk_option(-tabpos)
	$itk_component(tabset) configure \
		-tabpos $itk_option(-tabpos)
	pack forget $itk_component(canvas)
	pack forget $itk_component(tabset)
	pack forget $itk_component(notebook)
	_pack $_tabPos
    }
}

# -------------------------------------------------------------
# METHOD: configure ?<option>? ?<value> <option> <value>...?
#
# Acts as an addendum to the itk::Widget::configure method.
#
# Checks the _recomputeBorder flag and the _tabsetReconfigure to
# determine what work has been batched to after the configure
# -------------------------------------------------------------
itcl::body iwidgets::Tabnotebook::configure { args } {
    set result [eval itk::Archetype::configure $args]
    
    # check for flags then do update...
    if { $_borderRecompute == "true" } { 
	_recomputeBorder
	set _borderRecompute false
    }
    
    if { $_tabsetReconfigure == "true" } { 
	_reconfigureTabset
	set _tabsetReconfigure false
    }
    
    return $result
    
}

# -------------------------------------------------------------
# METHOD: add ?<option> <value>...?
#
# Creates a page and appends it to the list of pages.
# processes pageconfigure for the page added.
#
# Returns the page's childsite frame
# -------------------------------------------------------------
itcl::body iwidgets::Tabnotebook::add { args } {
    
    # The args list should be an even # of params, if not then
    # prob missing value for last item in args list. Signal error.
    set len [llength $args]
    if { [expr {$len % 2}] } {
	error "value for \"[lindex $args [expr {$len - 1}]]\" missing"
    }
    
    # pick out the notebook args
    set nbArgs [eval _getArgs [list $_nbOptList] $args]
    set pageName [eval $itk_component(notebook) add $nbArgs]
    
    # pick out the tabset args
    set tsArgs [eval _getArgs [list $_tsOptList] $args]
    eval $itk_component(tabset)   add $tsArgs
    
    set page [index end]
    bind $pageName <Configure> \
	    [itcl::code $this _pageReconfigure $pageName $page %w %h]
    return $pageName
}

# -------------------------------------------------------------
# METHOD: childsite ?<index>?
#
# If index is supplied, returns the child site widget 
# corresponding to the page index.  If called with no arguments,
# returns a list of all child sites
# -------------------------------------------------------------
itcl::body iwidgets::Tabnotebook::childsite { args } {
    return [eval $itk_component(notebook) childsite $args]
}

# -------------------------------------------------------------
# METHOD: delete <index1> ?<index2>?
#
# Deletes a page or range of pages from the notebook
# -------------------------------------------------------------
itcl::body iwidgets::Tabnotebook::delete { args } {
    eval $itk_component(notebook) delete $args
    eval $itk_component(tabset)   delete $args
}


# -------------------------------------------------------------
# METHOD: index <index>
#
# Given an index identifier returns the numeric index of the page
# -------------------------------------------------------------
itcl::body iwidgets::Tabnotebook::index { args } {
    return [eval $itk_component(notebook) index $args]
}

# -------------------------------------------------------------
# METHOD: insert <index> ?<option> <value>...?
#
# Inserts a page before a index. The before page may
# be specified as a label or a page position.
#
# Note that since we use eval to preserve the $args list,
# we must use list around $index to keep it together as a unit
#
# Returns the name of the page's child site
# -------------------------------------------------------------
itcl::body iwidgets::Tabnotebook::insert { index args } {
    
    # pick out the notebook args
    set nbArgs [eval _getArgs [list $_nbOptList] $args]
    set pageName [eval $itk_component(notebook) insert [list $index] $nbArgs]
    
    # pick out the tabset args
    set tsArgs [eval _getArgs [list $_tsOptList] $args]
    eval $itk_component(tabset)   insert [list $index] $tsArgs
    
    return $pageName
    
}

# -------------------------------------------------------------
# METHOD: prev
#
# Selects the previous page. Wraps at first back to last page.
# -------------------------------------------------------------
itcl::body iwidgets::Tabnotebook::prev { } {
    eval $itk_component(notebook) prev
    eval $itk_component(tabset)   prev
}

# -------------------------------------------------------------
# METHOD: next
#
# Selects the next page. Wraps at last back to first page.
# -------------------------------------------------------------
itcl::body iwidgets::Tabnotebook::next { } {
    eval $itk_component(notebook) next
    eval $itk_component(tabset)   next
}

# -------------------------------------------------------------
# METHOD: pageconfigure <index> ?<option> <value>...?
#
# Performs configure on a given page denoted by index.
# Index may be a page number or a pattern matching the label
# associated with a page.
# -------------------------------------------------------------
itcl::body iwidgets::Tabnotebook::pageconfigure { index args } {
    
    set nbArgs [eval _getArgs [list $_nbOptList] $args]
    set tsArgs [eval _getArgs [list $_tsOptList] $args]
    
    set len [llength $args]
    switch $len {
	0 {
	    # Here is the case where they just want to query options
	    set nbConfig \
		    [eval $itk_component(notebook) pageconfigure $index $nbArgs]
	    set tsConfig \
		    [eval $itk_component(tabset)   tabconfigure $index $tsArgs]
	    #
	    # BUG: this currently just concatenates a page and a tab's
	    # config lists together... We should bias to the Page
	    # since this is what we are using as primary when both??
	    #
	    # a pageconfigure index -background will return something like:
	    # -background background Background #9D008FF583C1 gray70 \
		    # -background background background white gray 70
	    #
	    return [concat $nbConfig $tsConfig]
	}
	1 {
	    # Here is the case where they are asking for only one
	    # one options value... need to figure out which one
	    # (page or tab) can service this. Then only return
	    # that one's result.
	    
	    if { [llength $nbArgs] != 0 } {
		return [eval $itk_component(notebook) \
			pageconfigure $index $nbArgs]
	    } elseif { [llength $tsArgs] != 0 } {
		return [eval $itk_component(tabset) \
			tabconfigure $index $tsArgs]
	    } else {
		error "unknown option \"$args\""
	    }
	    
	}
	default {
	    
	    # pick out the notebook args
	    set nbConfig \
		    [eval $itk_component(notebook) \
		    pageconfigure [list $index] $nbArgs]
	    
	    # pick out the tabset args
	    set tsConfig \
		    [eval $itk_component(tabset)   \
		    tabconfigure [list $index] $tsArgs]
	    
	    return ""
	    #return [concat $nbConfig $tsConfig]
	    
	}
    }
}

# -------------------------------------------------------------
# METHOD: select index
#
# Select a page by index
# -------------------------------------------------------------
itcl::body iwidgets::Tabnotebook::select { index } {
    $itk_component(notebook) select $index
    $itk_component(tabset)   select $index
}

# -------------------------------------------------------------
# METHOD: view
#
# Return the current page
#
#         view index
#
# Selects the page denoted by index to be current page
#
#	  view 'moveto' fraction
#
# Selects the page by using fraction amount
#
#	  view 'scroll' num what
#
# Selects the page by using num as indicator of next or
# previous
#
# -------------------------------------------------------------
itcl::body iwidgets::Tabnotebook::view { args } {
    eval $itk_component(notebook) view $args
    $itk_component(tabset) select [index select]
}

# -------------------------------------------------------------
# PRIVATE METHOD: _getArgs
#
# Given an optList returned from a configure on an object and
# given a candidate argument list, peruse throught the optList
# and build a new argument list with only those options found
# in optList.
#
# This is used by the add, insert, and pageconfigure methods.
# It is useful for a container kind of class like Tabnotebook
# to be smart about args it gets for its concept of a "page"
# which is actually a Notebook Page and a Tabset Tab.
#
# -------------------------------------------------------------
itcl::body iwidgets::Tabnotebook::_getArgs { optList args } {
    
    set len [llength $args]
    
    set retArgs {}
    
    for {set i 0} {$i < $len} {incr i} {
	# get the option for this pair
	set opt [lindex $args $i]
	
	# move ahead to the value
	incr i
	
	# option exists!
	if { [lsearch -exact $optList $opt] != -1} {
	    lappend retArgs $opt
	    if {$i < [llength $args]} {
		lappend retArgs [lindex $args $i]
	    }
	    # option does not exist
	}
    }
    
    return $retArgs
}

# -------------------------------------------------------------
# PROTECTED METHOD: _reconfigureTabset
#
# bound to the tabset reconfigure... We call our canvas 
# reconfigure as if the canvas resized, it then configures
# the tabset correctly.
# -------------------------------------------------------------
itcl::body iwidgets::Tabnotebook::_reconfigureTabset { } {
    _canvasReconfigure $_canvasWidth $_canvasHeight
    
}

# -------------------------------------------------------------
# PROTECTED METHOD: _canvasReconfigure
#
# bound to window Reconfigure event of the canvas
# keeps the tabset area stretched in its major dimension.
# -------------------------------------------------------------
itcl::body iwidgets::Tabnotebook::_canvasReconfigure { wid hgt } {
    
    if { $_tabPos == "n" || $_tabPos == "s" } {
	$itk_component(tabset) configure -width $wid
    } else {
	$itk_component(tabset) configure -height $hgt
    }
    
    set _canvasWidth $wid
    set _canvasHeight $hgt
    
    _redrawBorder $wid $hgt 
    
}

# -------------------------------------------------------------
# PRIVATE METHOD: _redrawBorder
#
# called by methods when the packing changes, borderwidths, etc.
# and height
# -------------------------------------------------------------
itcl::body iwidgets::Tabnotebook::_redrawBorder { wid hgt } {
    
    # Get the top of the Notebook area...
    
    set nbTop [winfo y $itk_component(notebook)]
    set canTop [expr {$nbTop - $itk_option(-borderwidth)}]
    
    $itk_component(canvas) delete BORDER
    if { $itk_option(-borderwidth) > 0 } {
	
	# For south, east, and west -- draw the top/north edge
	if { $_tabPos != "n" } {
	    $itk_component(canvas) create line \
		    [expr {floor(0 + ($itk_option(-borderwidth)/2.0))}] \
		    [expr {floor(0 + ($itk_option(-borderwidth)/2.0))}] \
		    $wid \
		    [expr {floor(0 + ($itk_option(-borderwidth)/2.0))}] \
		    -width $itk_option(-borderwidth) \
		    -fill [iwidgets::colors::topShadow $itk_option(-background)] \
		    -tags BORDER
	}
	
	# For north, east, and west -- draw the bottom/south edge
	if { $_tabPos != "s" } {
	    $itk_component(canvas) create line \
		    [expr {floor(0 + ($itk_option(-borderwidth)/2.0))}] \
		    [expr {floor($hgt - ($itk_option(-borderwidth)/2.0))}] \
		    [expr {floor($wid - ($itk_option(-borderwidth)/2.0))}] \
		    [expr {floor($hgt - ($itk_option(-borderwidth)/2.0))}] \
		    -width $itk_option(-borderwidth) \
		    -fill [iwidgets::colors::bottomShadow $itk_option(-background)] \
		    -tags BORDER
	} 
	
	# For north, south, and east -- draw the left/west edge
	if { $_tabPos != "w" } {
	    $itk_component(canvas) create line \
		    [expr {floor(0 + ($itk_option(-borderwidth)/2.0))}] \
		    0 \
		    [expr {floor(0 + ($itk_option(-borderwidth)/2.0))}] \
		    $hgt \
		    -width $itk_option(-borderwidth) \
		    -fill [iwidgets::colors::topShadow $itk_option(-background)] \
		    -tags BORDER
	}
	
	# For north, south, and west -- draw the right/east edge
	if { $_tabPos != "e" } {
	    $itk_component(canvas) create line \
		    [expr {floor($wid - ($itk_option(-borderwidth)/2.0))}] \
		    [expr {floor(0 + ($itk_option(-borderwidth)/2.0))}] \
		    [expr {floor($wid - ($itk_option(-borderwidth)/2.0))}] \
		    $hgt \
		    -width $itk_option(-borderwidth) \
		    -fill [iwidgets::colors::bottomShadow $itk_option(-background)] \
		    -tags BORDER
	}
    }
    
}

# -------------------------------------------------------------
# PRIVATE METHOD: _recomputeBorder
#
# Based on current width and height of our canvas, repacks
# the notebook with padding for borderwidth, and calls
# redraw border method 
# -------------------------------------------------------------
itcl::body iwidgets::Tabnotebook::_recomputeBorder { } {
    
    set wid [winfo width $itk_component(canvas)]
    set hgt [winfo height $itk_component(canvas)]
    
    _pack $_tabPos
    _redrawBorder $wid $hgt
}

# -------------------------------------------------------------
# PROTECTED METHOD: _pageReconfigure
#
# This method will eventually reconfigure the tab notebook's 
# notebook area to contain the resized child site
# -------------------------------------------------------------
itcl::body iwidgets::Tabnotebook::_pageReconfigure { pageName page wid hgt } {
}

# -------------------------------------------------------------
# PRIVATE METHOD: _pack
#
# This method packs the notebook and tabset correctly according
# to the current $tabPos
# -------------------------------------------------------------
itcl::body iwidgets::Tabnotebook::_pack { tabPos } {
    
    pack $itk_component(canvas) -fill both -expand yes 
    pack propagate $itk_component(canvas) no
    
    switch $tabPos {
	n {
	    # north
	    pack $itk_component(tabset) \
		    -anchor nw \
		    -fill x \
		    -expand no
	    pack $itk_component(notebook) \
		    -fill both \
		    -expand yes \
		    -padx $itk_option(-borderwidth) \
		    -pady $itk_option(-borderwidth) \
		    -side bottom 
	}
	s {
	    # south
	    pack $itk_component(notebook) \
		    -anchor nw \
		    -fill both \
		    -expand yes \
		    -padx $itk_option(-borderwidth) \
		    -pady $itk_option(-borderwidth)
	    
	    pack $itk_component(tabset) \
		    -side left \
		    -fill x \
		    -expand yes
	}
	w {
	    # west
	    pack $itk_component(tabset) \
		    -anchor nw \
		    -side left \
		    -fill y \
		    -expand no
	    pack $itk_component(notebook) \
		    -anchor nw \
		    -side left \
		    -fill both \
		    -expand yes \
		    -padx $itk_option(-borderwidth) \
		    -pady $itk_option(-borderwidth)
	    
	}
	e {
	    # east
	    pack $itk_component(notebook) \
		    -side left \
		    -anchor nw \
		    -fill both \
		    -expand yes \
		    -padx $itk_option(-borderwidth) \
		    -pady $itk_option(-borderwidth)
	    
	    pack $itk_component(tabset) \
		    -fill y \
		    -expand yes
	}
    }
    
    set wid [winfo width $itk_component(canvas)]
    set hgt [winfo height $itk_component(canvas)]
    
    _redrawBorder $wid $hgt
}



# -------------------------------------------------------------
# PRIVATE METHOD: _resize
#
# This method added by csmith, 5/1/01, to fix a bug with the
# geometry of the tabnotebook.  The hull component's geometry
# was not being updated properly on <Configure> events.
# -------------------------------------------------------------
itcl::body iwidgets::Tabnotebook::_resize {newWidth_ newHeight_} {
  _canvasReconfigure $newWidth_ $newHeight_

  # csmith: 9/14/01 - Commenting out the following code due to
  # SF ticket 461471, which is a dup of the original 452803. Since I
  # can't remember the exact problem surrounding the need to add
  # the _resize method, I'm going to do an undo here, leaving the
  # code for future reference if needed.  Should the original problem
  # arise again I will reinvestigate the need for _resize.
  #
  #  after idle \
  #    "$this component hull configure -width $newWidth_ -height $newHeight_"
}