
### searchPlayerPrep:
#
# Search for games of a certain player with a selected color, copying
# all found games to the clipbase, then switch to the clipbase and open
# the tree window. Not completed yet.

set sColor White
set sPlayer ""
trace variable sPlayer w { updateMatchList .spprep.list p 9 }

proc searchPlayerPrep {} {
  global sColor sPlayer

  set w .spprep
  if {[winfo exists $w]} {
    wm deiconify $w
    raiseWin $w
    return
  }

  toplevel $w
  wm title $w "Scid: $::tr(HeaderSearch)"

  frame $w.c
  label $w.t1 -text "Prepare as:" -font font_Bold
  radiobutton $w.c.w -textvar ::tr(White) -variable sColor -value White
  radiobutton $w.c.b -textvar ::tr(Black) -variable sColor -value Black

  pack $w.t1 -side top
  pack $w.c -side top
  pack $w.c.w $w.c.b -side left

  addHorizontalRule $w
  label $w.p -text "Against:" -font font_Bold
  entry $w.e -width 40 -background white -relief sunken -textvar sPlayer
  text $w.list -height 9 -width 40 -relief sunken \
    -background grey90 -tabs {2c right 2.5c left} -wrap none
  for {set z 1} {$z <= 9} {incr z} {
    bind $w.e [format "<Alt-Key-%d>" $z] \
      [format "eval {if {\$nameMatchCount >= %d} { \
                         set sPlayer \$nameMatches(%d)}}" $z $z $z ]
  }

  pack $w.p $w.e -side top -padx 5
  label $w.m -textvar ::tr(NameEditMatches)
  pack $w.m $w.list -side top -padx 5

  frame $w.b
  addHorizontalRule $w
  pack $w.b -side top -fill x
  button $w.b.search -textvar ::tr(Search)
  button $w.b.close -textvar ::tr(Close) -command "focus .; destroy $w"
  pack $w.b.close $w.b.search -side right -padx 5 -pady 5

  canvas $w.progress -height 20 -width 300 -bg white -relief solid -border 1
  $w.progress create rectangle 0 0 0 0 -fill blue -outline blue -tags bar
  $w.progress create text 295 10 -anchor e -font font_Regular -tags time \
    -fill black -text "0:00 / 0:00"
  pack $w.progress -side bottom -pady 2

  wm resizable $w 0 0
  wm title $w "Scid: Player Preparation"
  bind $w <Escape> "$w.b.close invoke"
  bind $w <Return> "$w.b.search invoke"
  bind $w <F1> { helpWindow Searches }
  focus $w.e
}

#bind . <Control-P> searchPlayerPrep
