#!sqlwish -f
# -[Fri Oct  9 16:21:49 1992 by cxh]-

set auto_path "$tk_library/demos $auto_path"

# Set up the main window
wm title . "Ingres Browser:"
wm geometry . 200x200+10+10
wm minsize . 200 100

frame .menu -relief raised -borderwidth 1
frame .ent -borderwidth 10

# Setup some entry widgets
pack append .ent \
  [button .ent.b1 -text "Open Database" \
   -command opendbButton ] {top fillx} \
  [entry .ent.e1 -relief sunken] {top fillx} \
  [scrollbar .ent.s1 -relief sunken -orient horiz -command \
   ".ent.e1 view"] {top fillx} \
  [frame .ent.f1 -geometry 20x10] {top} \
  [button .ent.l2 -text "Command" \
   -command {commandButton "[eval .ent.e2 get]"} ] {top fillx} \
  [entry .ent.e2 -relief sunken] {top fillx} \
  [scrollbar .ent.s2 -relief sunken -orient horiz -command \
   ".ent.e2 view"] {top fillx} \
  [frame .ent.f2 -geometry 20x10] {top} 


.ent.e1 config -scroll ".ent.s1 set"
.ent.e1 insert 0 "dbdict"
.ent.e2 config -scroll ".ent.s2 set"
.ent.e2 insert end "select * from tables"

pack append . .menu {top fillx } .ent {top expand fill}
focus .ent.e1


# SelectButton
menubutton .menu.select -text "select" -menu .menu.select.m
menu .menu.select.m
.menu.select.m add command -label "Select all tables" \
  -command {commandButton "select * from tables"}
.menu.select.m add command -label "Select all columns" \
  -command {commandButton "select * from columns"}

# Database Button
menubutton .menu.database -text "database" -menu .menu.database.m
menu .menu.database.m
.menu.database.m add command -label "open microlab" \
  -command "SQLopendb microlab"
.menu.database.m add command -label "open" \
  -command {SQLopendb [eval .ent.e1 get]}
.menu.database.m add command -label "close database" -command "SQLclosedb"

# FILE Button
menubutton .menu.file -text File -menu .menu.file.m
menu .menu.file.m
.menu.file.m add command -label "Quit" -command "destroy ."
.menu.file.m add command -label "Clear text" -command ".txt.text delete 0 end"

pack append .menu .menu.file left .menu.database left .menu.select left

# Deal with the text area
#
#frame .txt
#pack append . .txt {bottom expand fill}
#
#scrollbar .txt.vscrollbar -command ".txt.text yview" -relief sunken
#scrollbar .hscrollbar -relief sunken -orient horizontal \
  # 	-command ".txt.text xview"
#
#text .txt.text -height 20 -width 16 \
#	-yscrollcommand ".txt.vscrollbar set"
#
#
#pack append .txt .txt.vscrollbar {left filly} .txt.text {left expand fill}
#pack append . .hscrollbar {top fillx}



# Position a dialog box at a reasonable place on the screen.

proc dpos w {
  wm geometry $w +300+300
}

proc opendbButton {} {
  SQLopendb [eval .ent.e1 get]
  .ent.b1 configure -text "Close Database" -command closedbButton
}

proc closedbButton {} {
  SQLclosedb
  .ent.b1 configure -text "Open Database" -command opendbButton
}

# Get the definitions of tableDef, columnDef and commandButton.
source tbldef.tcl


