#!/usr/bin/wish -f
# menu.tcl --
#
# This demonstration script creates a window with a bunch of menus
# and cascaded menus using menubars.
#
# RCS: @(#) $Id: menu.tcl,v 1.2 1998/09/14 18:23:29 stanton Exp $

set font "Arial"

global .w

set w .menu
catch {destroy $w}
toplevel $w
wm title $w "Latein lernen"
wm iconname $w "menu"
# positionWindow $w

label $w.question -font $font -wraplength 4i -justify center -width 50 -height 10
$w.question configure -text "Frage" -background "yellow" -foreground "red"
label $w.answer -font $font -wraplength 4i -justify center  -width 50 -height 10
$w.answer configure -text "Antwort" -foreground "yellow" -background "orange"

pack $w.question -side top
pack $w.answer -side bottom

set menustatus "    "
frame $w.statusBar
label $w.statusBar.label -background "green" -foreground "orangered" -textvariable menustatus -relief sunken -bd 1 -font "Helvetica 10" -anchor w
label $w.statusBar.counter -foreground "blue" -background "orange" -textvariable counter -relief raised -bd 1 -font "Helvetica 10" -anchor e
pack $w.statusBar.label -side left -padx 2 -expand yes -fill both
pack $w.statusBar.counter -side right -padx 2 -expand no -fill both
pack $w.statusBar -side bottom -fill x -pady 2

frame $w.buttons -background "ghostwhite"
pack $w.buttons -side bottom -fill x -pady 2m
button $w.buttons.gewusst -text "Gewusst!" -command "gewusst" -background "orangered"
button $w.buttons.nachgedacht -text "Nachgedacht!" -command "nachgedacht" -background "ghostwhite"
button $w.buttons.verloren -text "Verloren!" -command "verloren" -background "#FF6733"
pack $w.buttons.gewusst $w.buttons.nachgedacht $w.buttons.verloren -side right -expand 1

menu $w.menu -tearoff 0 -background "#FF8800" -foreground "orangered"

set m $w.menu.file
menu $m -tearoff 0
$w.menu add cascade -label "Latein" -menu $m -underline 0
$m add command -label "ffnen ..." -command datei_oeffnen
$m add separator
$m add command -label "beenden ..." -command exit

$w configure -menu $w.menu -background "orangered"

bind Menu <<MenuSelect>> {
    global $menustatus
    if {[catch {%W entrycget active -label} label]} {
	set label "    "
    }
    set menustatus $label
    set counter "Hallo"
    # pack $w.statusBar.counter
    update idletasks
}


# Sam Mr  2 20:18:27 MET 2002: alles heute, jetzt von GM wieder da:

proc datei_oeffnen { } {
  global fId
  set fId [ open "lektion73-w2-1.txt" r ]
  displayer_voc
}

proc displayer_voc { } {
  global fId
  global w
  set c ""
  set q ""
  global a
  set a ""
  while {$c != "-"} {
    set c [ read $fId 1 ]
    if {$c != "-"} { append q $c }
  }
  set c [ read $fId 1 ]
  set c [ read $fId 1 ]
  while {$c != "-" && $c != "\n" } {
    set c [ read $fId 1 ]
    append a $c
  }
  $w.question configure -text $q
  $w.answer configure -text ""
  puts -nonewline $q
  puts -nonewline ": "
}

proc gewusst { } {
  puts "Gewusst!"
  displayer_voc
}

proc verloren { } {
  puts "Verloren!"
  displayer_voc
}

proc nachgedacht { } {
  global a
  global w
  $w.answer configure -text $a
}

