This file is indexed.

/usr/share/tkgate/scripts/toolbar.tcl is in tkgate-data 2.0~b10-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
#   Copyright (C) 1987-2009 by Jeffery P. Hansen
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Last edit by hansen on Mon Feb 23 19:27:02 2009
#
#

# Toolbar y padding
set tbypad 0

set logo_w ""
set tbfile_w ""
set tech_w ""
set undo_w ""
set gateop_w ""
set simtools_w ""

namespace eval ToolBar {
  variable currentMode
  variable newMode
  variable enabledTools
  variable grabX 3
  variable grabY 12
  variable tbMiddle 30
  variable modeTools
  variable mbar_w

  #
  # These variable show the natural position of the tools.  One or more
  # may be hidden and thus not be actually be displayed, but when the tool
  # is unhidden it will be displayed according to the order shown here.
  #
  variable topTools {File Undo Edit SymEdit GateOp Zoom SymZoom BlockOp}
  variable bottomTools {Modes SimModes SymModes SymPort SymShift SymOpr LimModes SimControl SimAux GateProp Tech}
  variable windowTools {}

  array set modeTools {
    None {}
    All {File Undo Edit GateOp Zoom SymZoom Modes SymModes SimModes SymEdit SymPort SymShift SymOpr \
	     LimModes BlockOp GateProp Tech SimControl SimAux}
    Edit {File Undo Edit GateOp Zoom Modes BlockOp GateProp Tech}
    HdlEdit {File Undo Edit BlockOp}
    EditInterfaces {File Undo Edit Zoom LimModes BlockOp}
    Simulate {File Zoom SimModes SimControl SimAux}
    EditInterfaces.sym {File Undo SymEdit SymZoom SymModes SymPort SymShift SymOpr BlockOp}
  }


  #
  # This shows the actual state of a tool.  It is either the window the tool is in,
  # or "hidden" if the tool is not visible.
  #
  variable toolState
  variable toolWindow
  variable toolPos

  proc tbGrabber {w tool argv} {
    frame $w

    set dobind 1
    parseargs $argv {-dobind}

    frame $w.p1 -width 3
    frame $w.v1 -bd 1 -relief raised -width 2 -height 13
    frame $w.v2 -bd 1 -relief raised -width 2 -height 13
    frame $w.p2 -width 5

    pack $w.p1 -side left
    pack $w.v1 -side left -padx 0
    pack $w.v2 -side left -padx 0
    pack $w.p2 -side left

    if { $dobind } {
      foreach W [list $w $w.p1 $w.v1 $w.v2 $w.p2] {
	bind $W <B1-Motion> "ToolBar::setGrab $tool"
      }
    }
  }

  proc resetTechList {} {
    global gatesetech_w tech_w

    set L [gat_getTechList]

    Dropbox::flush $tech_w
    Dropbox::itemadd $tech_w $L

    #
    # Build menus for plain entry technology lists
    #
    set menu_list [list $gatesetech_w]
    foreach m $menu_list {
      catch {
	destroy $m
	menu $m  -tearoff 0 
	foreach mi $L {
	  $m add command -label $mi -command "gat_setTech $mi"
	}
      }
    }

    #
    # Build menus for radio button technology lists
    #
    set menu_list [list .pop_MIgate.settech .pop_gate.settech .pop_multi.settech]
    foreach m $menu_list {
      catch {
	destroy $m
	menu $m  -tearoff 0 
	foreach mi $L {
	  $m add radiobutton -variable pop_tech -value $mi -label $mi -command "gat_setTech $mi"
	}
      }
    }
  }

  proc tbSymModes {w args} {
    global bd tbr tbypad

    frame $w
    tbGrabber $w.grab SymModes $args
    pack $w.grab -side left -fill both

    foreach e {point line rect fillrect port select} {
      flatradiobutton $w.$e -image [gifI "symed_${e}.gif"]  -variable SymbolEdit::emode -value $e
      pack $w.$e -side left -pady $tbypad
      helpon $w.$e [m ho.symed.$e]
    }


    frame $w.vbar -bd 1 -relief sunken -width 2
    pack $w.vbar -side left -padx 1 -pady 2 -fill y
  }

  proc tbSymEdit {w args} {
    global bd tbr tbypad 

    frame $w
    tbGrabber $w.grab SymEdit $args
    pack $w.grab -side left -fill both

    toolbutton $w.cut		"edit_cut.gif"		SymbolEdit::cutRegion		""
    toolbutton $w.copy		"edit_copy.gif"		SymbolEdit::copyRegion		""
    toolbutton $w.paste 	"edit_paste.gif"	SymbolEdit::pasteRegion		""
    toolbutton $w.overlay	"edit_overlay.gif"	SymbolEdit::overlayRegion	""

    pack $w.cut $w.copy $w.paste $w.overlay -side left -pady $tbypad

    frame $w.vbar -bd 1 -relief sunken -width 2
    pack $w.vbar -side left -padx 1 -pady 2 -fill y
  }

  proc tbSymPort {w args} {
    global bd tbr tbypad 

    frame $w
    tbGrabber $w.grab SymPort $args
    pack $w.grab -side left -fill both

    toolbutton $w.clk		"symed_pcrot.gif"	Action::seCWRotPort		""
    toolbutton $w.cntr		"symed_pccrot.gif"	Action::seCCWRotPort		""
    pack $w.clk $w.cntr -side left -pady $tbypad

    frame $w.vbar -bd 1 -relief sunken -width 2
    pack $w.vbar -side left -padx 1 -pady 2 -fill y
  }

  proc tbSymShift {w args} {
    global bd tbr tbypad 

    frame $w
    tbGrabber $w.grab SymShift $args
    pack $w.grab -side left -fill both

    toolbutton $w.rshift	"arrow0.gif"		{ SymbolEdit::shiftBits 1 0 }	ho.symed.rshift
    toolbutton $w.lshift	"arrow180.gif"		{ SymbolEdit::shiftBits -1 0 }	ho.symed.lshift
    toolbutton $w.ushift	"arrow90.gif"		{ SymbolEdit::shiftBits 0 -1 }	ho.symed.ushift
    toolbutton $w.dshift	"arrow270.gif"		{ SymbolEdit::shiftBits 0 1  }	ho.symed.dshift
    toolbutton $w.cwrotate	"symed_cwrotate.gif"	{ SymbolEdit::rotateBits 1  }	ho.symed.cwrotate
    toolbutton $w.ccwrotate	"symed_ccwrotate.gif"	{ SymbolEdit::rotateBits -1  } 	ho.symed.ccwrotate

    pack $w.rshift $w.lshift $w.ushift $w.dshift $w.cwrotate $w.ccwrotate -side left -pady $tbypad

    frame $w.vbar -bd 1 -relief sunken -width 2
    pack $w.vbar -side left -padx 1 -pady 2 -fill y
  }

  proc tbSymOpr {w args} {
    global bd tbr tbypad 

    frame $w
    tbGrabber $w.grab SymOpr $args
    pack $w.grab -side left -fill both

    toolbutton $w.import	"symed_import.gif"	{ Action::importImage }		ho.symed.import
    toolbutton $w.export	"symed_export.gif"	{ Action::exportImage }		ho.symed.export
    toolbutton $w.autobold	"symed_autobold.gif"	{ SymbolEdit::boldBits }	ho.symed.autobold
#    toolbutton $w.resize	"symed_resize.gif"	{}				ho.symed.resize

    pack $w.import $w.export $w.autobold -side left -pady $tbypad

    frame $w.vbar -bd 1 -relief sunken -width 2
    pack $w.vbar -side left -padx 1 -pady 2 -fill y
  }

  proc tbSymZoom {w args} {
    global bd tbr tbypad 

    frame $w
    tbGrabber $w.grab SymEdit $args
    pack $w.grab -side left -fill both

    toolbutton $w.in		"zoom_in.gif"		{ SymbolEdit::zoom 1 }		""
    toolbutton $w.out 		"zoom_out.gif"		{ SymbolEdit::zoom -1 }		""
    pack $w.in $w.out -side left  -pady $tbypad

    frame $w.vbar -bd 1 -relief sunken -width 2
    pack $w.vbar -side left -padx 1 -pady 2 -fill y
  }

  proc tbFile {w args} {
    global bd tbr tbypad tbfile_w

    set tbfile_w $w
    frame $w
    tbGrabber $w.grab File $args
    pack $w.grab -side left -fill both

    toolbutton $w.new		"file_new.gif"		{clearAction File::new}		ho.new
    toolbutton $w.open		"file_open.gif"		{clearAction File::load}	ho.open
    toolbutton $w.lib		"file_lib.gif"		Action::loadLibrary		ho.library
    toolbutton $w.save		"file_save.gif"		Action::saveFile		ho.save
    toolbutton $w.saveas	"file_saveas.gif"	Action::saveAsFile		ho.saveas
    toolbutton $w.print		"file_print.gif"	{suspendAction PrintDlg::post}	ho.print
    frame $w.vbar -bd 1 -relief sunken -width 2

    pack $w.new $w.open $w.lib $w.save $w.saveas $w.print -side left -pady $tbypad
    pack $w.vbar -side left -padx 1 -pady 2 -fill y
  }

  proc tbEdit {w args} {
    global bd tbr tbypad

    frame $w
    tbGrabber $w.grab Edit $args
    pack $w.grab -side left -fill y

    toolbutton $w.cut	"edit_cut.gif"		Action::cutToBuf	ho.tool.cut
    toolbutton $w.copy	"edit_copy.gif"		Action::copyToBuf	ho.tool.copy
    toolbutton $w.paste "edit_paste.gif"	Action::yankFromBuf	ho.tool.paste
    toolbutton $w.find  "edit_find.gif"		Action::findObject	ho.tool.find

    frame $w.vbar -bd 1 -relief sunken -width 2

    pack $w.cut $w.copy $w.paste $w.find -side left -pady $tbypad
    pack $w.vbar -side left -padx 1 -pady 2 -fill y
  }

  proc tbGateOp {w args} {
    global bd tbr tbypad gateop_w


    set gateop_w $w
    frame $w
    tbGrabber $w.grab GateOp $args
    pack $w.grab -side left -fill y

    toolbutton $w.curRot	"rotation0.gif"		ToolBar::advanceRotation	ho.tool.currot
    updateRotation

    toolbutton $w.valgn		"edit_valgn.gif"	Action::vAlign			ho.tool.valgn
    toolbutton $w.halgn		"edit_halgn.gif"	Action::hAlign			ho.tool.halgn
    toolbutton $w.rotate	"edit_rotate.gif"	Action::rotate			ho.tool.rotate
    toolbutton $w.brotate	"edit_brotate.gif"	Action::backRotate		ho.tool.brotate

    frame $w.vbar -bd 1 -relief sunken -width 2

    pack $w.curRot $w.rotate $w.brotate $w.valgn $w.halgn -side left -pady $tbypad
    pack $w.vbar -side left -padx 1 -pady 2 -fill y
  }

  proc tbGateProp {w args} {
    global bd tbr tbypad gateprop_w

    set gateprop_w $w
    frame $w
    tbGrabber $w.grab GateProp $args
    pack $w.grab -side left -fill y

    toolbutton $w.addport	"addport.gif"		Action::addPort		ho.tool.addport
    toolbutton $w.anchor	"anchor.gif"		Action::anchor		ho.tool.anchor
    toolbutton $w.unanchor	"unanchor.gif"		Action::unAnchor	ho.tool.unanchor
    flatradiobutton $w.replicate -image [gifI "replicate.gif"] -variable tkg_replicateOn -value 1 -command Action::replicate
    toolbutton $w.delete	"delgate.gif"		Action::delete		ho.tool.delete

    pack $w.addport $w.anchor $w.unanchor $w.replicate $w.delete -anchor w -side left

    frame $w.vbar -bd 1 -relief sunken -width 2
    pack $w.vbar -side left -padx 1 -pady 2 -fill y

    helpon $w.replicate		[m ho.tool.replicate]
  }


  proc updateRotation args {
    global gateop_w rot

    catch {
      switch $rot {
	0 { $gateop_w.curRot configure -image [gifI rotation0.gif] }
	1 { $gateop_w.curRot configure -image [gifI rotation90.gif] }
	2 { $gateop_w.curRot configure -image [gifI rotation180.gif] }
	3 { $gateop_w.curRot configure -image [gifI rotation270.gif] }
      }
    }
  }

  proc advanceRotation args {
    global gateop_w rot
    switch $rot {
      0 { Action::rot90 }
      1 { Action::rot180 }
      2 { Action::rot270 }
      3 { Action::rot0 }
    }
  }

  proc tbSimModes {w args} {
    global bd tbr tbypad
    global tkg_defaultWType tkg_wtypeList

    frame $w
    tbGrabber $w.grab Modes $args
    pack $w.grab -side left -fill y

    #
    # Flat relief icon radio button are not supported until tck/tk 8.4, so use our own
    #
    flatradiobutton $w.mov -image [gifI "mov_curs.gif"]  -variable mode -value 1 -command Action::editMode
    flatradiobutton $w.scroll -image [gifI "scroll_curs.gif"]  -variable mode -value 3 -command Action::scrollMode

    pack $w.mov $w.scroll  -side left -pady  $tbypad 

    frame $w.vbar -bd 1 -relief sunken -width 2
    pack $w.vbar -side left -padx 1 -pady 2 -fill y

    helpon $w.mov [m ho.simmove]
    helpon $w.scroll [m ho.scroll]
 }

  proc tbModes {w args} {
    global bd tbr tbypad
    global tkg_defaultWType tkg_wtypeList

    frame $w
    tbGrabber $w.grab Modes $args
    pack $w.grab -side left -fill y

    #
    # Flat relief icon radio button are not supported until tck/tk 8.4, so use our own
    #
    flatradiobutton $w.mov -image [gifI "mov_curs.gif"]  -variable mode -value 1 -command Action::editMode
    flatradiobutton $w.cut -image [gifI "cut_curs.gif"]  -variable mode -value 0 -command Action::cutMode
    flatradiobutton $w.inv -image [gifI "inv_curs.gif"]  -variable mode -value 2 -command Action::invertMode
    flatradiobutton $w.scroll -image [gifI "scroll_curs.gif"]  -variable mode -value 3 -command Action::scrollMode
    flatradiobutton $w.siz -image [gifI "size_curs.gif"] -variable mode -value 9 -command Action::sizeMode

#    pack $w.mov $w.del $w.cut $w.inv $w.siz -side left -pady $tbypad -ipadx 2 -ipady 2
    pack $w.mov $w.cut $w.inv $w.scroll $w.siz -side left -pady $tbypad

    label $w.nbitsl -text "[m ibits] "
    bitsizeselector $w.nbitsv -variable tkg_bitWidth -width 3 -takefocus 0
    pack $w.nbitsl $w.nbitsv -side left -pady $tbypad

    label $w.typel -text "[m itype] "
    Dropbox::new $w.typev -variable tkg_defaultWType -value $tkg_defaultWType -width 7 -takefocus 0
    pack $w.typel $w.typev -side left -pady $tbypad
    Dropbox::itemadd $w.typev $tkg_wtypeList


    frame $w.pad
    pack $w.pad -side left -padx 2 -pady 2 

    frame $w.vbar -bd 1 -relief sunken -width 2
    pack $w.vbar -side left -padx 1 -pady 2 -fill y

    helpon $w.mov [m ho.move]
#    helpon $w.del [m ho.delgat]
    helpon $w.cut [m ho.cutw]
    helpon $w.inv [m ho.inv]
    helpon $w.siz [m ho.bitw]
    helpon $w.scroll [m ho.scroll]

    helpon $w.nbitsl [m ho.cmd.bitw]
    helpon $w.nbitsv [m ho.cmd.bitw]
  }

  proc tbLimModes {w args} {
    global bd tbr tbypad

    frame $w
    tbGrabber $w.grab Modes $args
    pack $w.grab -side left -fill y

    #
    # Flat relief icon radio button are not supported until tck/tk 8.4, so use our own
    #
    flatradiobutton $w.mov -image [gifI "mov_curs.gif"]  -variable mode -value 1 -command Action::editMode
    flatradiobutton $w.cut -image [gifI "cut_curs.gif"]  -variable mode -value 0 -command Action::cutMode
    flatradiobutton $w.siz -image [gifI "size_curs.gif"] -variable mode -value 9 -command Action::sizeMode

    pack $w.mov $w.cut $w.siz -side left -pady $tbypad

    label $w.nbitsl -text "[m ibits] "
    bitsizeselector $w.nbitsv -variable tkg_bitWidth -width 3 -takefocus 0
    pack $w.nbitsl $w.nbitsv -side left -pady $tbypad

    frame $w.pad
    pack $w.pad -side left -padx 2 -pady 2 

    frame $w.vbar -bd 1 -relief sunken -width 2
    pack $w.vbar -side left -padx 1 -pady 2 -fill y

    helpon $w.mov [m ho.move]
    helpon $w.cut [m ho.cutw]
    helpon $w.siz [m ho.bitw]

    helpon $w.nbitsl [m ho.cmd.bitw]
    helpon $w.nbitsv [m ho.cmd.bitw]
  }

  proc tbUndo {w args} {
    global bd tbr tbypad tbfile_w undo_w

    set undo_w $w
    frame $w
    tbGrabber $w.grab Undo $args
    pack $w.grab -side left -fill y

    label $w.back -image [gifI "back.gif"] -bd 1 -relief flat -takefocus 0
    label $w.forward -image [gifI "forward.gif"] -bd 1 -relief flat -takefocus 0
#    button $w.back -image [gifI "back.gif"] -bd 1 -relief flat -takefocus 0
#    button $w.forward -image [gifI "forward.gif"] -bd 1 -relief flat -takefocus 0

    pack $w.back $w.forward  -side left -pady  $tbypad -ipadx 1 -ipady 1

    frame $w.vbar -bd 1 -relief sunken -width 2
    pack $w.vbar -side left -padx 1 -pady 2 -fill y

    bind $w.back <Button-1> { %W configure  -relief sunken ;Undo::undoSelect; %W configure  -relief flat }
    bind $w.forward <Button-1>  { %W configure  -relief sunken ;Undo::redoSelect; %W configure  -relief flat }

    bind $w.back <Enter> "%W configure -relief raised"
    bind $w.back <Leave> "%W configure -relief flat"
    bind $w.forward <Enter> "%W configure -relief raised"
    bind $w.forward <Leave> "%W configure -relief flat"

    helpon $w.back [m ho.undo]
    helpon $w.forward [m ho.redo]
    
    set activebackground [option get . activeBackground UndoRedo]
    set normalbackground [$w.back cget -bg]

    bind $w.back <Enter> "+ %W configure -bg $activebackground"
    bind $w.back <Leave> "+ %W configure -bg $normalbackground"
    bind $w.forward <Enter> "+ %W configure -bg $activebackground"
    bind $w.forward <Leave> "+ %W configure -bg $normalbackground"
  }

  proc tbBlockOp {w args} {
    global bd tbr tbypad

    frame $w
    tbGrabber $w.grab BlockOp $args
    pack $w.grab -side left -fill y

    toolbutton $w.new		"blk_new.gif"		Action::blockNew	ho.mod.new
    toolbutton $w.del		"blk_delete.gif"	Action::blockDelete	ho.mod.del
    toolbutton $w.copy		"blk_copy.gif"		Action::blockCopy 	ho.mod.copy
    toolbutton $w.rename	"blk_rename.gif"	Action::blockRename	ho.mod.rename
    toolbutton $w.claim		"blk_claim.gif"		Action::blockClaim	ho.mod.claim
#    toolbutton $w.root		"blk_root.gif"		Action::blockSetRoot	ho.mod.setroot
    toolbutton $w.open		"blk_open.gif"		Action::openMod		ho.mod.open
    toolbutton $w.close		"blk_close.gif"		Action::closeMod	ho.mod.close

    pack $w.new $w.del $w.copy $w.rename $w.claim $w.open $w.close  -side left -pady  $tbypad

    frame $w.vbar -bd 1 -relief sunken -width 2
    pack $w.vbar -side left -padx 1 -pady 2 -fill y
  }

  proc tbZoom {w args} {
    global bd tbr tbypad

    frame $w
    tbGrabber $w.grab Zoom $args
    pack $w.grab -side left -fill y

    toolbutton $w.zoomin	"zoom_in.gif"		{ action ZoomIn { gat_zoom 1 } }	ho.tool.zoomin
    toolbutton $w.zoomout	"zoom_out.gif"		{ action ZoomOut { gat_zoom -1 } }	ho.tool.zoomout -state disabled
    pack $w.zoomin $w.zoomout  -side left -pady  $tbypad


    frame $w.vbar -bd 1 -relief sunken -width 2
    pack $w.vbar -side left -padx 1 -pady 2 -fill y
  }

  proc tbSimControl {w args} {
    global bd tbr tbypad simtools_w

    set simtools_w $w

    frame $w
    tbGrabber $w.grab SimControl $args
    pack $w.grab -side left -fill y

    toolbutton $w.simgo		"sim_go.gif"		tkg_simRun				ho.simgo
    toolbutton $w.simpause	"sim_pause.gif"		tkg_simStop				ho.simpause
    toolbutton $w.simstep	"sim_step.gif"		Simulator::stepEpoch			ho.simstep
    toolbutton $w.simclock	"sim_clock.gif"		tkg_simCycle				ho.simclock
    toolbutton $w.simstop	"sim_stop.gif"		{ gat_setMajorMode edit }		ho.simstop

    pack $w.simgo $w.simpause $w.simstep $w.simclock $w.simstop -side left -pady  $tbypad

    frame $w.vbar -bd 1 -relief sunken -width 2
    pack $w.vbar -side left -padx 1 -pady 2 -fill y
  }

  proc tbSimAux {w args} {
    global bd tbr tbypad

    frame $w
    tbGrabber $w.grab SimAux $args
    pack $w.grab -side left -fill y

    toolbutton $w.simbreak	"sim_break.gif"		Action::editBreakpoints			ho.simbreak
    toolbutton $w.simscript	"sim_script.gif"	Action::doSimScript			ho.simexec
    toolbutton $w.simload	"sim_load.gif"		Action::simLoadMem			ho.simload
    toolbutton $w.simdump	"sim_dump.gif"		Action::simDumpMem			ho.simdump
    toolbutton $w.simview	"sim_view.gif"		Action::simViewMem			ho.simview

    pack $w.simbreak $w.simscript $w.simload $w.simdump $w.simview -side left -pady  $tbypad
#    pack $w.simload $w.simdump -side left -pady  $tbypad

    frame $w.vbar -bd 1 -relief sunken -width 2
    pack $w.vbar -side left -padx 1 -pady 2 -fill y
  }

  proc tbLogo {w} {
    global bd tbr tbypad logo_w

    set logo_w $w
    label $logo_w -image [gifI "gatelogo.gif"] 
    helpon $logo_w [m ho.status.logo]

  }

  proc tbTech {w args} {
    global tkg_defaultTech tech_w tbr bd

    set tech_w $w.v
    frame $w
    tbGrabber $w.grab Tech $args
    pack $w.grab -side left -fill y

    label $w.l -text "[m b.tech]:" 
    Dropbox::new $w.v -variable tkg_defaultTech -value $tkg_defaultTech -width 14 -takefocus 0
    Dropbox::itemadd $w.v [gat_getTechList]

    pack $w.l $w.v -anchor w -side left

    frame $w.vbar -bd 1 -relief sunken -width 2
    pack $w.vbar -side left -padx 1 -pady 2 -fill y

    helpon $w.l [m ho.deftech]
  }

  #############################################################################
  #
  # Methods from here are used for controlling toobars
  #
  #############################################################################

  proc clearLocation {t} {
    variable windowTools
    variable topTools
    variable bottomTools

    set i [lsearch $topTools $t]
    if {$i >= 0 } { set topTools [lreplace $topTools $i $i] }
    set i [lsearch $bottomTools $t]
    if {$i >= 0 } { set bottomTools [lreplace $bottomTools $i $i] }
    set i [lsearch $windowTools $t]
    if {$i >= 0 } { set windowTools [lreplace $windowTools $i $i] }
  }

  proc seeToolDrop {t w x y} {
    variable toolWindow
    variable windowTools
    variable topTools
    variable bottomTools
    variable toolPos
    variable grabX
    variable grabY
    variable tbMiddle
    variable toolState

    #
    # If we drop the tool on the toolbar, then go figure out where to insert it,
    # otherwise make a new window for it.
    #
    if { [string range $w 0 4] == ".tbar" } {
      #
      # If the drop is on .tbar itself, use the y position to decide top or bottom
      # and add it to the end.  Otherwise figure out which window we dropped on
      # and where to insert it.
      #
      scan $w ".tbar.%\[^.\]" where
      set tbroot_x [winfo rootx .tbar.top]
      set tbroot_y [winfo rooty .tbar.top]

      if { [expr $y - $tbroot_y] > $tbMiddle } {
	set i 0
	foreach q $bottomTools {
	  if {!$toolState($q) } { 
	    incr i
	    continue
	  }
	  set mw .tbar.bottom.w$q
	  set mx [winfo rootx $mw]
	  set mwidth [winfo width $mw]
	  if { $x < [expr $mx + $mwidth/2] } {
	    break
	  }
	  incr i
	}
	set bottomTools [linsert $bottomTools $i $t]
      } else {
	set i 0
	foreach q $topTools {
	  if {!$toolState($q) } { 
	    incr i
	    continue
	  }
	  set mw .tbar.top.w$q
	  set mx [winfo rootx $mw]
	  set mwidth [winfo width $mw]
	  if { $x < [expr $mx + $mwidth/2] } {
	    break
	  }
	  incr i
	}
	set topTools [linsert $topTools $i $t]
      }
      show $t
    } else {
      clearLocation $t
      lappend windowTools $t
      set toolPos($t) +[expr $x - $grabX]+[expr $y - $grabY]
      show $t
    }
  }

  proc setGrab {t} {
    variable toolWindow
    variable toolState
    variable topTools
    variable bottomTools
    variable windowTools
    variable grabX
    variable grabY

    clearLocation $t

    set dw [Dragger::make -command "ToolBar::seeToolDrop $t" -absolute 1 -grabpoint [list $grabX $grabY] ]
    if { $dw != "" } {
      makeW $t $dw.w$t -dobind 0
      pack $dw.w$t
      set toolWindow($t) ""
      set toolState($t) 0
    }
  }

  proc hideEdit {} {
    pack forget .tbar.bottom.modes
    pack forget .tbar.bottom.tech
    pack forget .tbar.top.edit
    pack forget .tbar.top.undo
  }

  proc showEdit {} {
    pack .tbar.bottom.modes -side left -before .tbar.bottom.blockop
    pack .tbar.bottom.tech -side left -after .tbar.bottom.blockop
    pack .tbar.top.undo -side left -after .tbar.top.file
    pack .tbar.top.edit -side left -after .tbar.top.file
  }

  proc showSim {} {
    pack .tbar.bottom.simctl -side left
    pack .tbar.bottom.simaux -side left
  }

  proc hideSim {} {
    pack forget .tbar.bottom.simctl .tbar.bottom.simaux
  }


  #
  # make tool t be in window w
  #
  proc makeW {t w args} {
    variable toolWindow

    if { $t != $toolWindow($t) } {
      if { $toolWindow($t) != "" } {
	if { [string range  $toolWindow($t) 0 4] == ".tbar" } {
	  destroy $toolWindow($t)
	} else {
	  destroy .tb$t
	}
      }
      if { $w != "" } {
	eval "tb$t $w $args"
      }
      set toolWindow($t) $w
    }
  }

  #
  # swallow toolbar t
  #
  proc show {t} {
    variable topTools
    variable bottomTools
    variable windowTools
    variable toolWindow
    variable toolState
    variable toolPos

    #
    # If tool is already visible, don't do anything
    #
    if { $toolState($t) == 1 } {
      return
    }

    set after_w .tbar.top.pad
    foreach q $topTools {
      if {$t == $q } {
	set w .tbar.top.w$t
	makeW $t $w
	pack $w -after $after_w -side left
	set toolState($t) 1
	return
      }
      if { $toolState($q) == 1 } {
	set after_w .tbar.top.w$q
      }
    }

    set after_w .tbar.bottom.pad
    foreach q $bottomTools {
      if {$t == $q } {
	set w .tbar.bottom.w$t
	makeW $t $w
	pack $w -after $after_w -side left
	set toolState($t) 1
	return
      }
      if { $toolState($q) == 1 } {
	set after_w .tbar.bottom.w$q
      }
    }

    foreach q $windowTools {
      if {$t == $q } {
	set tw .tb$t
	toplevel $tw -cursor arrow -bd 2 -relief solid
	wm resizable $tw 0 0
	wm transient $tw .
	wm overrideredirect $tw 1
	wm geometry $tw $toolPos($t)


	set w $tw.w$t
	makeW $t $w

	pack $w -padx 1 -pady 1
	set toolState($t) 1
	return
      }
    }
  }

  #
  # remove a toolbar
  #
  proc hide {t} {
    variable toolWindow
    variable toolState
    #
    # If tool is already hidden, don't do anything
    #
    if { $toolState($t) == 0 } {
      return
    }

    set w $toolWindow($t)
    if { [string range $w 0 4] == ".tbar" } {
      pack forget $w
    } else {
      set rootw [winfo parent $w]
      destroy $rootw
      set toolWindow($t) ""
    }
    set toolState($t) 0
  }

  proc toolConfigure {t subw args} {
    variable toolWindow

    if { $toolWindow($t) == "" } {
      return
    }
    catch {
	eval "$toolWindow($t).$subw configure $args"
    }
  }

  #############################################################################
  #
  # Set the current toolbar mode.  Tools relevent to the mode will be displayed
  # and irrelevent tools will be hidden.
  #
  proc setMode {m} {
    variable modeTools
    variable newMode
    variable currentMode
    variable enabledTools

    if { $m == "EditInterfaces" && [info exists IPanel::data(itype)] &&  $IPanel::data(itype) == "symbol" } {
      set m EditInterfaces.sym
    }

    #
    # Hide tool groups that are in the current set but not in the new set
    #
    foreach item $modeTools($currentMode) {
      if {[lsearch $modeTools($m) $item] < 0 } {
	hide $item
      }
    }

    #
    # Show tool groups that are in the new set but not in the current set
    #
    set newMode $m
    foreach item $ToolBar::modeTools($ToolBar::newMode) {
      if {[lsearch $ToolBar::modeTools($ToolBar::currentMode) $item] < 0 \
	      && [lsearch $ToolBar::enabledTools $item] >= 0 } {
	ToolBar::show $item
      }
    }

    set currentMode $m
  }

  #############################################################################
  #
  # Update the list of enabled tools
  #
  proc updateEnabled {} {
    variable modeTools
    variable currentMode
    variable enabledTools
    global tkg_filetb tkg_edittb tkg_gateoptb tkg_undotb tkg_zoomtb tkg_modetb 
    global tkg_moduletb tkg_techtb tkg_simctltb tkg_simauxtb tkg_gateprop
    global tkg_symmodestb tkg_simmodestb tkg_symedittb tkg_zoomtb tkg_symporttb tkg_symshifttb tkg_symoprtb


    set newSet {}
    if {$tkg_filetb} { lappend newSet File }
    if {$tkg_edittb} { lappend newSet Edit }
    if {$tkg_gateoptb} { lappend newSet GateOp }
    if {$tkg_gateprop} { lappend newSet GateProp }
    if {$tkg_undotb} { lappend newSet Undo }
    if {$tkg_zoomtb} { lappend newSet Zoom }
    if {$tkg_modetb} { lappend newSet Modes LimModes }
    if {$tkg_moduletb} { lappend newSet BlockOp }
    if {$tkg_techtb} { lappend newSet Tech }
    if {$tkg_simctltb} { lappend newSet SimControl }
    if {$tkg_simauxtb} { lappend newSet SimAux } 

    if {$tkg_symmodestb} { lappend newSet SymModes } 
    if {$tkg_simmodestb} { lappend newSet SimModes } 
    if {$tkg_symedittb} { lappend newSet SymEdit } 
    if {$tkg_zoomtb} { lappend newSet SymZoom } 
    if {$tkg_symporttb} { lappend newSet SymPort } 
    if {$tkg_symshifttb} { lappend newSet SymShift } 
    if {$tkg_symoprtb} { lappend newSet SymOpr } 

    if { $enabledTools != $newSet } {
      foreach item $modeTools($currentMode) {
	if  {[lsearch $newSet $item] < 0 && [lsearch $enabledTools $item] >= 0} {
	  hide $item
	}
	if  {[lsearch $newSet $item] >= 0 && [lsearch $enabledTools $item] < 0} {
	  show $item
	}
      }

      set enabledTools $newSet
    }
  }

  proc init {} {
    variable topTools
    variable bottomTools
    variable toolWindow
    variable toolState
    variable modeTools
    variable currentMode
    variable enabledTools
    variable mbar_w
    global logo_w rot
    global gatesetech_w

    set currentMode None

    set enabledTools $modeTools(All)
    updateEnabled

    foreach t $modeTools(All) {
      set toolWindow($t) ""
      set toolState($t) 0
    }


    tbLogo .tbar.logo
    pack $logo_w -side right -ipadx 2 -ipady 2 -padx 5 -pady 5 -anchor n


    #
    # Menu setup
    #
    Menu::makeBar .tbar.m editor
    set mbar_w .tbar.m
    set gatesetech_w	$mbar_w.format.menu.settech
    KeyBinding::listener .tbar.m main -unmatchedcommand dobell
    focus $mbar_w

    frame .tbar.bar1 -bd 1 -relief sunken -height 2
    frame .tbar.top
    frame .tbar.bar2 -bd 1 -relief sunken -height 2
    frame .tbar.bottom

    pack .tbar.m -fill x
    pack .tbar.bar1 -fill x -padx 3 -pady 1
    pack .tbar.top -fill y -anchor w
    pack .tbar.bar2 -fill x -padx 3 -pady 1
    pack .tbar.bottom -fill y -anchor w
    frame .tbar.top.pad -height 25
    frame .tbar.bottom.pad -height 25
    pack .tbar.top.pad -padx 3 -side left
    pack .tbar.bottom.pad -padx 3 -side left

    trace variable rot w ToolBar::updateRotation
  }

  #############################################################################
  #
  # 
  #
  proc takeFocus {} {
    variable mbar_w

    focus $mbar_w
  }

  #############################################################################
  #
  # Set the editing tool (mode) to use.
  #
  proc selectTool {tool} {
    global mode simOn

    if { ! $simOn || $tool == 1 || $tool == 3} {
      set mode $tool
      gat_mode $tool
    }
  }

  #############################################################################
  #
  # Respond to a change in the mode.
  #
  proc modeChanged args {
    global mode tkg_batMode tkg_batRate tkg_bitWidth old_mode

    if { $mode == 1 && $tkg_batMode } {
      after $tkg_batRate gat_batInc
    }

    set old_mode $mode
  }

  proc simStateChange args {
    global simulatorState simtools_w

    set baseBg [$simtools_w cget -bg]

      if { $simulatorState == "stop" } {
	$simtools_w.simgo configure -relief flat -bg  $baseBg
	$simtools_w.simpause configure -relief sunken -bg "\#aaaacc"
      } else {
	$simtools_w.simgo configure -relief sunken -bg "\#aaaacc"
	$simtools_w.simpause configure -relief flat -bg $baseBg
      }
    }
}

trace variable mode w ToolBar::modeChanged
trace variable ::simulatorState w ToolBar::simStateChange