#
# GDBToolBar
# ----------------------------------------------------------------------
# Implements a menu, toolbar, and status window for GDB
#
#   PUBLIC ATTRIBUTES:
#
#
#   METHODS:
#
#     config ....... used to change public attributes
#     insert ....... inserts text in the text widget
#     einsert ...... inserts error text in the text widget
#     command ...... run a command and print output
#
#     PRIVATE METHODS
#
#     previous ..... recalls the previous command
#     next ......... recalls the next command
#     last ......... recalls the last command in the history list
#     first ........ recalls the first command in the history list
#
#   X11 OPTION DATABASE ATTRIBUTES
#
#
# ----------------------------------------------------------------------
#   AUTHOR:  Martin M. Hunt	hunt@cygnus.com     
#            Cygnus Solutions   
#


itcl_class GDBToolBar {
  # ------------------------------------------------------------------
  #  CONSTRUCTOR - create new console window
  # ------------------------------------------------------------------
  constructor {config} {
    #
    #  Create a window with the same name as this object
    #
    set class [$this info class]
    @@rename $this $this-tmp-
    @@frame $this -class $class 
    @@rename $this $this-win-
    @@rename $this-tmp- $this
    build_win
  }

  # ------------------------------------------------------------------
  #  METHOD:  build_win - build the main toolbar window
  # ------------------------------------------------------------------
  method build_win {} {
    global GDBTK_IDE

    frame $this.t

    if {[pref get toolbar menu] == "1"} {
      menu $this.m -tearoff 0
      $this.m add cascade -menu $this.m.file -label "File" -underline 0
      set m [menu $this.m.file]
      $m add command -label Load -underline 0 -command {puts "Load"}
      $m add command -label Exec -underline 0 -command {puts "Exec"}
      $m add command -label Core -underline 0 -command {puts "Core"}
      $m add command -label Target -underline 0 -command {puts "Target"}
      $m add command -label Quit -underline 0 -command {gdb_cmd quit}
      
      $this.m add cascade -menu $this.m.opt -label "Options" -underline 0
      set m [menu $this.m.opt]
      $m add command -label Global -underline 1 -command {manage open globalpref}
      $m add command -label GDB -underline 0 -command {puts "set GDB options"}
      $m add command -label Toolbar -underline 0 -command {manage open toolpref}
      $m add command -label Source -underline 0 -command {manage open srcpref}
      $m add command -label Console -underline 0 -command {puts "set console options"}
      $m add command -label Register -underline 0 -command {manage open regpref}
      
      $this.m add cascade -menu $this.m.tools -label "Tools" -underline 0
      set m [menu $this.m.tools]
      $m add command -label Edit -underline 0 -command {SrcWin @@ edit}
      $m add command -label Build -underline 0 -command {puts "run vmake"}
      
      $this.m add cascade -menu $this.m.win -label "Windows" -underline 0
      set m [manage menu $this.m.win]
      
      $this.m add cascade -menu $this.m.help -label "Help" -underline 0
      set m [menu $this.m.help]
      $m add command -label About -underline 0 -command {manage open about}

      [winfo toplevel $this] configure -menu $this.m
    }

    if {[pref get toolbar icon] == "1"} {
      button $this.t.file -command {puts "file button"} \
	-image [image create photo -file [@@file join [pref get gdb ImageDir] file.gif]]
      button $this.t.opt -command {manage open pref} \
	-image [image create photo -file [@@file join [pref get gdb ImageDir] opt.gif]]
      button $this.t.con -command {manage open console} \
	-image [image create photo -file [@@file join [pref get gdb ImageDir] console.gif]]
      button $this.t.src -command {manage open src} \
	-image [image create photo -file [@@file join [pref get gdb ImageDir] src.gif]]
      button $this.t.reg -command {manage open reg} \
	-image [image create photo -file [@@file join [pref get gdb ImageDir] reg.gif]]
      button $this.t.stack -command {manage open stack} \
	-image [image create photo -file [@@file join [pref get gdb ImageDir] stack.gif]]
      button $this.t.edit -command {puts "edit button"} \
	-image [image create photo -file [@@file join [pref get gdb ImageDir] edit.gif]]
      button $this.t.build -command {puts "build button"} \
	-image [image create photo -file [@@file join [pref get gdb ImageDir] build.gif]]
      button $this.t.help -command {manage open about} \
	-image [image create photo -file [@@file join [pref get gdb ImageDir] help.gif]]
      
      bind $this.t.con <Button-3> "manage create console"
      bind $this.t.src <Button-3> "manage create src"
      bind $this.t.reg <Button-3> "manage create reg"
      bind $this.t.stack <Button-3> "manage create stack"

      balloon register $this.t.file "Load a new file"
      balloon register $this.t.opt "Edit user preferences"
      balloon register $this.t.con "open/show console window"
      balloon register $this.t.src "open/show source window"
      balloon register $this.t.reg "open/show register window"
      balloon register $this.t.stack "open/show stack window"
      balloon register $this.t.edit "edit file"
      balloon register $this.t.build "build project"
      balloon register $this.t.help "help"
      
      pack $this.t.file $this.t.opt $this.t.con $this.t.src $this.t.reg \
	$this.t.stack $this.t.edit $this.t.build $this.t.help  -side left
    }

    pack $this.t $this -fill both -expand true
  }

  # ------------------------------------------------------------------
  #  DESTRUCTOR - destroy window containing widget
  # ------------------------------------------------------------------
  destructor {
    set top [winfo toplevel $this]
    destroy $this
    destroy $top
  }

  # ------------------------------------------------------------------
  #  METHOD:  config - used to change public attributes
  # ------------------------------------------------------------------
  method config {config} {}
    
  # ------------------------------------------------------------------
  #  METHOD:  reconfig - used when preferences change
  # ------------------------------------------------------------------
  method reconfig {} {
    destroy $this.m $this.t
    build_win
  }
  
  #
  #  PROTECTED DATA
  #

}

