34 set moveEntry(Text) ""
35 set moveEntry(List) {}
37 proc moveEntry_Clear {} {
39 set moveEntry(Text) ""
40 set moveEntry(List) {}
43 proc moveEntry_Complete {} {
45 set len [
llength $moveEntry(List)]
47 set move [
lindex $moveEntry(List) 0]
48 if {$move == "OK"} {
set move "O-O"}
49 if {$move == "OQ"} {
set move "O-O-O"}
55 proc moveEntry_Backspace {} {
57 set moveEntry(Text) [
string range $moveEntry(Text) 0 \
58 [
expr {[string length $moveEntry(Text)] - 2}]]
59 set moveEntry(List) [
sc_pos matchMoves $moveEntry(Text) $moveEntry(Coord)]
63 proc moveEntry_Char {ch} {
65 set oldMoveText $moveEntry(Text)
66 set oldMoveList $moveEntry(List)
67 append moveEntry(Text) $ch
68 set moveEntry(List) [
sc_pos matchMoves $moveEntry(Text) $moveEntry(Coord)]
69 set len [
llength $moveEntry(List)]
72 set moveEntry(Text) $oldMoveText
73 set moveEntry(List) $oldMoveList
74 }
elseif {$len == 1} {
79 set move [
string tolower [
lindex $moveEntry(List) 0]]
81 if {$moveEntry(AutoExpand) > 0 ||
82 ![
string compare [
string tolower $moveEntry(Text)] $move]} {
85 }
elseif {$len == 2} {
88 set first [
string tolower [
lindex $moveEntry(List) 0]]
89 set second [
string tolower [
lindex $moveEntry(List) 1]]
90 if {[
string equal $first $second]} {
91 set moveEntry(List) [list $moveEntry(Text)]
101 proc updateMainGame {} {
103 set gamePlayers(nameW) [
sc_game info white]
104 set gamePlayers(nameB) [
sc_game info black]
106 set gamePlayers(eloW) [
expr {$eloW == 0 ? "" : "($eloW)"}]
108 set gamePlayers(eloB) [
expr {$eloB == 0 ? "" : "($eloB)"}]
109 set gamePlayers(clockW) ""
110 set gamePlayers(clockB) ""
116 proc updateTitle {} {
118 set fname [
sc_base filename $::curr_db]
119 set fname [
file tail $fname]
120 append title "$fname ($::tr(game) "
126 if {[
string length $white] > 2 && [
string length $black] > 2} {
127 if {$fname == {[clipbase]} } {
set fname clipbase}
129 if {[
sc_game altered]} {
set altered "*"}
130 ::setTitle .main "($fname$altered): $white -- $black"
139 proc updateStatusBar {} {
140 if {! [
winfo exists .main]} {
return}
142 if {$::menuHelpMessage != ""} {
147 if {$::autoplayMode == 1} {
152 if {[
info exists ::playMode]} {
153 set pInfo [
eval "$::playMode info"]
154 if {[
llength $pInfo] != 4} {
164 set comment [
sc_pos getComment]
166 set ::gamePlayers(clockW) ""
167 set ::gamePlayers(clockB) ""
168 set clkExp {.*?\[%clk\s*(.*?)\s*\].*}
169 set prevCom [
sc_pos getPrevComment]
170 if {$toMove == "white"} {
171 regexp $clkExp $comment -> ::gamePlayers(clockB)
172 regexp $clkExp $prevCom -> ::gamePlayers(clockW)
174 regexp $clkExp $comment -> ::gamePlayers(clockW)
175 regexp $clkExp $prevCom -> ::gamePlayers(clockB)
179 if {[
info exists ::guessedAddMove]} {
180 set ::gameLastMove [
lindex $::guessedAddMove 1]
181 ::board::setInfoAlert .main.board [
lindex $::guessedAddMove 0] "\[click to change\]" "blue" ".main.menuaddchoice"
182 unset ::guessedAddMove
187 if {$moveEntry(Text) != ""} {
188 set msg "\[ $moveEntry(Text) \] "
189 foreach thisMove $moveEntry(List) {
190 append msg "$thisMove "
197 regsub -all {\[%.*\]} $comment {} comment
199 if {$comment != ""} {
207 set move [
sc_game info previousMoveNT]
209 regsub {K} $move "\u2654" move
210 regsub {Q} $move "\u2655" move
211 regsub {R} $move "\u2656" move
212 regsub {B} $move "\u2657" move
213 regsub {N} $move "\u2658" move
214 set number "[
sc_pos moveNumber]"
215 if {$toMove == "white"} {
219 append statusBar "Last move"
220 if {[
sc_var level] != 0} {
append statusBar " (var)"}
221 append statusBar ": $number.$move"
230 proc updateMainToolbar {} {
231 if {[
sc_pos isAt start]} {
233 catch { unset ::gameInfoBar(tb_BD_Start)}
236 set ::gameInfoBar(tb_BD_Start) "::move::Start"
240 catch { unset ::gameInfoBar(tb_BD_End)}
241 catch { unset ::gameInfoBar(tb_BD_Autoplay)}
244 set ::gameInfoBar(tb_BD_End) "::move::End"
245 set ::gameInfoBar(tb_BD_Autoplay) "startAutoplay"
248 if {[
sc_var level] == 0} {
249 catch { unset ::gameInfoBar(tb_BD_VarDelete)}
250 catch { unset ::gameInfoBar(tb_BD_VarPromote)}
251 catch { unset ::gameInfoBar(tb_BD_VarLeave)}
252 catch { unset ::gameInfoBar(tb_BD_BackToMainline)}
254 set ::gameInfoBar(tb_BD_VarDelete) { ::pgn::deleteVar }
255 set ::gameInfoBar(tb_BD_VarPromote) { ::pgn::mainVar }
256 set ::gameInfoBar(tb_BD_VarLeave) { ::move::ExitVar }
257 set ::gameInfoBar(tb_BD_BackToMainline) { while {[sc_var level] != 0} {::move::ExitVar} }
260 set ::gameInfoBar(tb_BD_SetupBoard) "setupBoard"
265 proc toggleRotateBoard {} {
275 proc toggleShowMaterial {} {
280 proc main_mousewheelHandler {direction} {
281 if {$direction < 0} {
292 proc getNextMoves { {num 4} } {
295 while { [
sc_game info nextMove] != "" && $count < $num} {
296 append tmp " [
sc_game info nextMove]"
307 if {$::autoplayMode == 1} {
return}
310 if {[
sc_var count] == 0} {
322 if {[
winfo exists $w]} {
return}
325 set numVars [
sc_var count]
331 set h [
expr $numVars + 1]
332 if { $h> 19} {
set h 19}
333 listbox $w.lbVar -selectmode browse -height $h -width 20
334 pack $w.lbVar -expand yes -fill both -side top
337 set move [
sc_game info nextMove]
339 set move "($::tr(empty))"
345 for {
set i 0} {$i < $numVars} {
incr i} {
346 set move [
::trans [
lindex $varList $i]]
348 set move "($::tr(empty))"
354 set str "[
expr {$i + 1}]: $move"
355 $w.lbVar insert end $str
357 $w.lbVar selection set 0
359 bind $w <Configure> "recordWinSize $w"
360 bind .variations <Return> {catch { event generate .variations <Right> } }
361 bind .variations <ButtonRelease-1> {catch { event generate .variations <Right> } }
362 bind .variations <Right> {
363 set cur [.variations.lbVar curselection]
366 sc_move forward; updateBoard -animate
368 sc_var moveInto [expr $cur - 1]; updateBoard -animate
371 bind .variations <Up> { set cur [.variations.lbVar curselection] ; .variations.lbVar selection clear $cur
372 set sel [expr $cur - 1]
373 if {$sel < 0} { set sel 0 }
374 .variations.lbVar selection set $sel ; .variations.lbVar see $sel}
375 bind .variations <Down> { set cur [.variations.lbVar curselection] ; .variations.lbVar selection clear $cur
376 set sel [expr $cur + 1]
377 if {$sel >= [.variations.lbVar index end]} { set sel end }
378 .variations.lbVar selection set $sel ; .variations.lbVar see $sel}
379 bind .variations <Left> { destroy .variations }
380 bind .variations <Escape> { catch { event generate .variations <Destroy> } }
382 bind .variations <Visibility> {
383 if { "%s" != "VisibilityUnobscured" } {
388 bind .variations <FocusOut> {
394 bind .variations <Destroy> { focus -force .main }
396 catch {
focus .variations}
409 proc updateBoard {args} {
417 proc updateGameInfo {} {
420 .main.gameInfo.text configure -state normal
421 .main.gameInfo.text delete 0.0 end
423 -material $gameInfo(showMaterial) \
424 -cfull $gameInfo(fullComment) \
425 -fen $gameInfo(showFEN) -tb $gameInfo(showTB)]
426 if {$gameInfo(wrap)} {
427 .main.gameInfo.text configure -wrap word
428 .main.gameInfo.text tag configure wrap -lmargin2 10
429 .main.gameInfo.text tag add wrap 1.0 end
431 .main.gameInfo.text configure -wrap none
433 .main.gameInfo.text configure -state disabled
437 set photosMinimized 0
438 proc togglePhotosSize {{toggle 1}} {
439 place forget .main.photoW
440 place forget .main.photoB
441 if {! $::gameInfo(photos)} {
return}
444 if {$toggle} {
set ::photosMinimized [
expr !$::photosMinimized]}
446 set distance [
expr {[image width photoB] + 2}]
447 if { $distance < 10 } {
set distance 82}
449 if {$::photosMinimized} {
450 place .main.photoW -in .main.gameInfo.text -x -17 -relx 1.0 -relheight 0.15 -width 15 -anchor ne
451 place .main.photoB -in .main.gameInfo.text -x -1 -relx 1.0 -relheight 0.15 -width 15 -anchor ne
453 place .main.photoW -in .main.gameInfo.text -x -$distance -relx 1.0 -relheight 1 -width [
image width photoW] -anchor ne
454 place .main.photoB -in .main.gameInfo.text -x -1 -relx 1.0 -relheight 1 -width [
image width photoB] -anchor ne
461 proc readPhotoFile {fname} {
465 if {! [regsub {\.spf$} $fname {.spi} spi]} {
471 if { [
file readable $spi]} {
472 set count [
array size ::unsafe::spffile]
474 set newcount [
array size ::unsafe::spffile]
475 if {[
expr $newcount - $count] > 0} {
476 ::splash::add "Found [
expr $newcount - $count] player photos in [
file tail $fname]"
477 ::splash::add "Loading information from index file [
file tail $spi]"
478 return [
expr $newcount - $count]
485 if { ![
file exists $spi] && ![
catch {open $spi w} fd_spi]} {
490 if {! [
file readable $fname]} {
return}
493 while {[
gets $fd line] >= 0} {
495 if { [regexp {^photo \"(.*)\" \{$} $line -> name] } {
496 set count [
expr $count + 1]
502 if {[regexp {.*\}.*} $line]} {break}
505 set size [
expr $end - $begin]
506 set ::unsafe::photobegin($trimname) $begin
507 set ::unsafe::photosize($trimname) $size
508 set ::unsafe::spffile($trimname) $fname
511 puts $fd_spi "set \"photobegin($trimname)\" $begin"
512 puts $fd_spi "set \"photosize($trimname)\" $size"
513 puts $fd_spi "set \"spffile($trimname)\" \"\$fname\""
517 if {$count > 0 && $writespi} {
518 ::splash::add "Found $count player photos in [
file tail $fname]"
519 ::splash::add "Index file [
file tail $spi] was generated succesfully"
521 if {$count > 0 && !$writespi} {
522 ::splash::add "Found $count player photos in [
file tail $fname]"
523 ::splash::add "Could not generate index file [
file tail $spi]"
524 ::splash::add "Use spf2spi script to generate [
file tail $spi] file "
527 if { $writespi } {
close $fd_spi}
534 proc trimString {data} {
535 set data [
string tolower $data]
536 set strindex [
string first "\ " $data]
537 set data [
string replace $data $strindex $strindex]
538 set strindex [
string first "\ " $data]
539 set data [
string replace $data $strindex $strindex]
545 proc getphoto {name} {
547 if {[
info exists ::unsafe::spffile($name)]} {
548 set fd [open $::unsafe::spffile($name)]
549 seek $fd $::unsafe::photobegin($name) start
550 set data [read $fd $::unsafe::photosize($name)]
557 proc loadPlayersPhoto {} {
558 set ::gamePlayers(photoW) {}
559 set ::gamePlayers(photoB) {}
560 image create photo photoW
561 image create photo photoB
564 set photodirs [list $::scidDataDir $::scidUserDir $::scidConfigDir [
file join $::scidShareDir "photos"]]
565 if {[
info exists ::scidPhotoDir]} {
lappend photodirs $::scidPhotoDir}
570 foreach dir $photodirs {
571 foreach photofile [glob -nocomplain -directory $dir "*.spf"] {
580 return [list $nImg $nFiles]
586 proc trimEngineName { engine } {
588 set spell_name [
sc_name retrievename $engine]
589 if {$spell_name != ""} {
set engine $spell_name}
591 set engine [
string tolower $engine]
593 if { [
string first "deep " $engine] == 0 } {
595 set engine [
string range $engine 5 end]
599 set strindex [
string first "\ " $engine]
600 set engine [
string replace $engine $strindex $strindex]
601 set strindex [
string first "\ " $engine]
602 set engine [
string replace $engine $strindex $strindex]
603 set strindex [
string first "," $engine]
604 set slen [
string len $engine]
605 if { $strindex == -1 && $slen > 2 } {
608 set slen [
string len $engine]
609 for {
set strindex $slen} {![
info exists ::unsafe::spffile([
string range $engine 0 $strindex])]\
610 && $strindex > 2 } {
set strindex [
expr {$strindex - 1}]} { }
611 set engine [
string range $engine 0 $strindex]
620 proc updatePlayerPhotos {{force ""}} {
621 foreach {name img} {nameW photoW nameB photoB} {
622 set spellname $::gamePlayers($name)
623 if {$::gamePlayers($img) != $spellname} {
624 set ::gamePlayers($img) $spellname
626 image create photo $img -data [
getphoto $spellname]
650 proc getPromoPiece {} {
658 if { [
sc_pos side] == "black" } {
set col "b"}
659 ttk::button $w.bq -image ${col}q45 -command "set ::result 2 ; destroy $w"
660 ttk::button $w.br -image ${col}r45 -command "set ::result 3 ; destroy $w"
661 ttk::button $w.bb -image ${col}b45 -command "set ::result 4 ; destroy $w"
662 ttk::button $w.bn -image ${col}n45 -command "set ::result 5 ; destroy $w"
663 pack $w.bq $w.br $w.bb $w.bn -side left
664 bind $w <Escape> "set ::result 2 ; destroy $w"
665 bind $w <Return> "set ::result 2 ; destroy $w"
682 proc confirmReplaceMove {} {
683 if {[
winfo exists $::reviewgame::window]} {
686 if {! $::askToReplaceMoves} {
690 option add *Dialog.msg.wrapLength 4i interactive
691 catch {
tk_dialog .dialog "Scid: $::tr(ReplaceMove)?" \
692 $::tr(ReplaceMoveMessage) "" 0 \
693 $::tr(ReplaceMove) $::tr(NewMainLine) \
694 $::tr(AddNewVar) $::tr(Cancel)} answer
695 option add *Dialog.msg.wrapLength 3i interactive
696 if {$answer == 0} {
return "replace"}
697 if {$answer == 1} {
return "mainline"}
698 if {$answer == 2} {
return "var"}
702 proc addNullMove {} {
706 proc addMove { sq1 sq2 {animate "-animate"}} {
709 if {$sq1 == "null" && $sq2 == "null"} {
set nullmove 1}
710 if {!$nullmove && [
sc_pos isLegal $sq1 $sq2] == 0} {
714 set k1 [
string tolower [
string index $board $sq1]]
715 set k2 [
string tolower [
string index $board $sq2]]
716 if {$k1 == "k" && $k2 == "k"} {
set nullmove 1}
else {
return}
719 if {[
sc_pos isCheck]} {
return}
727 proc addSanMove { {san} } {
728 set err [
catch {
sc_game SANtoUCI $san} moveUCI]
738 proc addMoveUCI {{moveUCI} {action ""} {animate "-animate"}} {
743 if { [
string length $moveUCI] == 4 && $sq1 != $sq2 && [
sc_pos isPromotion $sq1 $sq2] } {
745 2 {
set promoLetter "q"}
746 3 {
set promoLetter "r"}
747 4 {
set promoLetter "b"}
748 5 {
set promoLetter "n"}
749 default {
set promoLetter ""}
751 append moveUCI $promoLetter
754 if {! $::annotateMode} {
759 if {![
sc_pos isAt vend]} {
766 set replacedmove [
sc_game info previousMoveNT]
770 if {$replacedmove != ""} {
771 set ::guessedAddMove [list "Replaced Move $replacedmove"]
778 mainline {
set ::guessedAddMove [list "New Main Line"]}
779 var {
set ::guessedAddMove [list "New Variation"]}
780 replace {
set ::guessedAddMove [list "Replaced Main Line"]}
782 lappend ::guessedAddMove $moveUCI
786 if {($action == "mainline" || $action == "var") && ![
sc_pos isAt vend]} {
790 if {$moveUCI == "0000"} {
795 if {$action == "mainline"} {
800 set ::sergame::lastPlayerMoveUci "$moveUCI"
802 if {[
winfo exists .fics]} {
804 if { [
string length $moveUCI] == 5 } {
805 set promoletter [
string tolower [
string index $moveUCI end]]
813 if {$::novag::connected} {
817 set san [
sc_game info previous]
818 after idle [list ::utils::sound::AnnounceNewMove $san]
823 proc suggestMove {} {
824 if {! $::suggestMoves} {
return 0}
825 if {[
info exists ::playMode]} {
826 return [
eval "$::playMode suggestMove"]
828 if {$::fics::playing != 0} {
return 0}
838 proc enterSquare { square } {
839 global bestSq bestcolor selectedSq
840 if {$selectedSq == -1} {
843 set bestSq [
sc_pos bestSquare $square]
856 proc leaveSquare { square } {
857 global selectedSq bestSq
858 if {$selectedSq == -1} {
868 proc pressSquare { square } {
869 global selectedSq highcolor
874 if { [
winfo exists .calvarWin] } {
879 if {$selectedSq == -1} {
880 set selectedSq $square
883 set c [
string index [
sc_pos side] 0]
894 if {$square != $tmp} {
907 proc releaseSquare { w x y } {
908 if { [
winfo exists .calvarWin] } {
return}
910 global selectedSq bestSq
919 if {$square == $selectedSq} {
932 }
elseif {$selectedSq != -1} {
950 global selectedSq bestSq
974 proc addMarker {w x y} {
976 if {! [
info exists ::markStartSq]} {
981 set from $::markStartSq
984 if {$from == "" || $to == ""} {
return}
987 set cmd "$::markType,$to,$::markColor"
988 set cmd_erase "\[a-z\]*,$to,\[a-z\]*"
990 set cmd "arrow,$from,$to,$::markColor"
991 set cmd_erase "arrow,$from,$to,\[a-z\]*"
993 set oldComment [
sc_pos getComment]
994 regsub -all " *\\\[%draw $cmd\\\]" $oldComment "" newComment
995 if {$newComment == $oldComment} {
996 regsub -all " *\\\[%draw $cmd_erase\\\]" $oldComment "" newComment
997 append newComment " \[%draw $cmd\]"
1000 sc_pos setComment $newComment
1016 proc undoFeature {action} {
1017 if {$action == "save"} {
1019 }
elseif {$action == "undo"} {
1022 }
elseif {$action == "redo"} {
1025 }
elseif {$action == "undoAll"} {
1031 proc setPlayMode { callback } {
1032 set ::playMode "$callback"
1033 if {$::playMode == ""} { unset ::playMode}
1040 proc resizeMainBoard {} {
1041 if { $::autoResizeBoard } {
1043 set availw [
winfo width .fdockmain]
1044 set availh [
winfo height .fdockmain]
1045 if {$::showGameInfo} {
1046 set availh [
expr $availh - [
winfo height .main.gameInfo]]
1048 if { [
llength [
pack slaves .main.tb]] != 0 } {
1049 set availh [
expr $availh - [
winfo height .main.tb]]
1056 proc toggleGameInfo {} {
1057 if {$::showGameInfo} {
1058 grid .main.gameInfo -row 3 -column 0 -sticky news
1060 grid forget .main.gameInfo
1066 proc CreateMainBoard { {w} } {
1074 for {
set i 0} {$i < $::boardCoords} {
incr i} {
::board::coords $w.board}
1080 set ::gameInfoBar(tb_BD_Coords) "set ::boardCoords \[::board::coords $w.board\]"
1081 set ::gameInfoBar(tb_BD_Material) "set ::gameInfo(showMaterial) \[::board::toggleMaterial $w.board\]"
1083 menu .main.menuaddchoice -bg white -font font_Regular
1084 .main.menuaddchoice add command -label " Undo" -image tb_BD_Undo -compound left \
1085 -command {undoFeature undo}
1086 .main.menuaddchoice add command -label " $::tr(ReplaceMove)" -image tb_BD_Replace -compound left \
1087 -command {sc_game undo; addMoveUCI $::gameLastMove replace}
1088 .main.menuaddchoice add command -label " $::tr(NewMainLine)" -image tb_BD_NewMainline -compound left \
1089 -command {sc_game undo; addMoveUCI $::gameLastMove mainline}
1090 .main.menuaddchoice add command -label " $::tr(AddNewVar)" -image tb_BD_NewVar -compound left \
1091 -command {sc_game undo; addMoveUCI $::gameLastMove var}
1095 for {
set i 0} { $i < 64 } {
incr i} {
1099 ::board::bind $w.board $i <Control-ButtonPress-1> "addMarker $w.board %X %Y"
1100 ::board::bind $w.board $i <Control-ButtonRelease-1> "addMarker $w.board %X %Y"
1101 ::board::bind $w.board $i <B1-Motion> "::board::dragPiece $w.board %X %Y"
1102 ::board::bind $w.board $i <ButtonRelease-1> "releaseSquare $w.board %X %Y"
1106 foreach i {o q r n k O Q R B N K} {
1107 bind $w <$i> "moveEntry_Char [
string toupper $i]"
1108 bind $w <Alt-$i> { continue }
1111 foreach i {a b c d e f g h 1 2 3 4 5 6 7 8} {
1112 bind $w <Key-$i> "moveEntry_Char $i"
1113 bind $w <Alt-$i> { continue }
1116 bind $w <Control-BackSpace> backSquare
1117 bind $w <Control-Delete> backSquare
1118 bind $w <BackSpace> moveEntry_Backspace
1119 bind $w <Delete> moveEntry_Backspace
1120 bind $w <space> moveEntry_Complete
1121 bind $w <ButtonRelease> "focus $w"
1122 bind $w <Configure> {+::resizeMainBoard }
1123 bind $w <Return> { #TODO: improve this
1124 if {[winfo exists .analysisWin1] && $analysis(analyzeMode1)} {
1125 .analysisWin1.b1.move invoke
1132 grid $w.space -row 4 -column 0 -columnspan 3 -sticky nsew
1133 grid rowconfigure $w 3 -weight 0
1134 grid rowconfigure $w 4 -weight 1
1136 grid columnconfigure $w 0 -weight 1
1137 grid $w.board -row 2 -column 0 -sticky we
1145 proc CreateGameInfo {} {
1149 .main.gameInfo.text configure -width 20 -height 6 -fg black -bg white -wrap none -state disabled -cursor top_left_arrow -setgrid 1
1153 label .main.photoW -background white -image photoW -anchor ne
1154 label .main.photoB -background white -image photoB -anchor ne
1155 bind .main.photoW <ButtonPress-1> "togglePhotosSize"
1156 bind .main.photoB <ButtonPress-1> "togglePhotosSize"
1159 menu .main.gameInfo.menu -tearoff 0
1161 .main.gameInfo.menu add checkbutton -label GInfoHideNext \
1162 -variable gameInfo(hideNextMove) -offvalue 0 -onvalue 1 -command updateBoard
1164 .main.gameInfo.menu add checkbutton -label GInfoMaterial -variable gameInfo(showMaterial) -offvalue 0 -onvalue 1 \
1165 -command { toggleShowMaterial }
1167 .main.gameInfo.menu add checkbutton -label GInfoFEN \
1168 -variable gameInfo(showFEN) -offvalue 0 -onvalue 1 -command updateBoard
1170 .main.gameInfo.menu add checkbutton -label GInfoMarks \
1171 -variable gameInfo(showMarks) -offvalue 0 -onvalue 1 -command updateBoard
1173 .main.gameInfo.menu add checkbutton -label GInfoWrap \
1174 -variable gameInfo(wrap) -offvalue 0 -onvalue 1 -command updateBoard
1176 .main.gameInfo.menu add checkbutton -label GInfoFullComment \
1177 -variable gameInfo(fullComment) -offvalue 0 -onvalue 1 -command updateBoard
1179 .main.gameInfo.menu add checkbutton -label GInfoPhotos \
1180 -variable gameInfo(photos) -offvalue 0 -onvalue 1 \
1181 -command {togglePhotosSize 0}
1183 .main.gameInfo.menu add separator
1185 .main.gameInfo.menu add radiobutton -label GInfoTBNothing \
1186 -variable gameInfo(showTB) -value 0 -command updateBoard
1188 .main.gameInfo.menu add radiobutton -label GInfoTBResult \
1189 -variable gameInfo(showTB) -value 1 -command updateBoard
1191 .main.gameInfo.menu add radiobutton -label GInfoTBAll \
1192 -variable gameInfo(showTB) -value 2 -command updateBoard
1194 .main.gameInfo.menu add separator
1196 .main.gameInfo.menu add command -label GInfoDelete -command {
1197 sc_base gameflag [sc_base current] [sc_game number] invert del
1198 ::notify::DatabaseModified [sc_base current]
1201 bind .main.gameInfo.text <ButtonPress-$::MB3> {
1202 tk_popup .main.gameInfo.menu %X %Y
1209 proc setToolbarTooltips { tb } {
1211 newdb FileNew open FileOpen finder FileFinder
1212 save GameReplace closedb FileClose bkm FileBookmarks
1213 gprev GamePrev gnext GameNext
1214 newgame GameNew copy EditCopy paste EditPaste
1215 boardsearch SearchCurrent
1216 headersearch SearchHeader materialsearch SearchMaterial
1217 switcher WindowsSwitcher glist WindowsGList pgn WindowsPGN tmt WindowsTmt
1218 maint WindowsMaint eco WindowsECO tree WindowsTree crosstab ToolsCross
1219 engine ToolsAnalysis } {
1224 proc InitToolbar {{tb}} {
1225 ttk::frame $tb -relief raised -border 1
1226 ttk::button $tb.newdb -image tb_newdb -command ::file::New -padding {2 0}
1227 ttk::button .main.tb.open -image tb_open -command ::file::Open -padding {2 0}
1228 ttk::button .main.tb.save -image tb_save -padding {2 0} -command {
1229 if {[sc_game number] != 0} {
1232 # catch {.save.buttons.save invoke}
1238 ttk::button .main.tb.closedb -image tb_closedb -command ::file::Close -padding {2 0}
1239 ttk::button .main.tb.finder -image tb_finder -command ::file::finder::Open -padding {2 0}
1240 ttk::menubutton .main.tb.bkm -image tb_bkm -menu .main.tb.bkm.menu -padding {2 0}
1241 menu .main.tb.bkm.menu
1244 ttk::frame .main.tb.space1 -width 4
1245 ttk::button .main.tb.newgame -image tb_newgame -command ::game::Clear -padding {2 0}
1246 ttk::button .main.tb.copy -image tb_copy -command ::gameAddToClipbase -padding {2 0}
1247 ttk::button .main.tb.paste -image tb_paste \
1248 -command {catch {sc_clipbase paste}; updateBoard -pgn} -padding {2 0}
1249 ttk::frame .main.tb.space2 -width 4
1250 ttk::button .main.tb.gprev -image tb_gprev -command {::game::LoadNextPrev previous} -padding {2 0}
1251 ttk::button .main.tb.gnext -image tb_gnext -command {::game::LoadNextPrev next} -padding {2 0}
1252 ttk::frame .main.tb.space3 -width 4
1253 ttk::button .main.tb.boardsearch -image tb_boardsearch -command ::search::board -padding {2 0}
1254 ttk::button .main.tb.headersearch -image tb_headersearch -command ::search::header -padding {2 0}
1255 ttk::button .main.tb.materialsearch -image tb_materialsearch -command ::search::material -padding {2 0}
1256 ttk::frame .main.tb.space4 -width 4
1257 ttk::button .main.tb.switcher -image tb_switcher -command ::windows::switcher::Open -padding {2 0}
1258 ttk::button .main.tb.glist -image tb_glist -command ::windows::gamelist::Open -padding {2 0}
1259 ttk::button .main.tb.pgn -image tb_pgn -command ::pgn::OpenClose -padding {2 0}
1260 ttk::button .main.tb.tmt -image tb_tmt -command ::tourney::toggle -padding {2 0}
1261 ttk::button .main.tb.maint -image tb_maint -command ::maint::OpenClose -padding {2 0}
1262 ttk::button .main.tb.eco -image tb_eco -command ::windows::eco::OpenClose -padding {2 0}
1263 ttk::button .main.tb.tree -image tb_tree -command ::tree::make -padding {2 0}
1264 ttk::button .main.tb.crosstab -image tb_crosstab -command ::crosstab::OpenClose -padding {2 0}
1265 ttk::button .main.tb.engine -image tb_engine -command makeAnalysisWin -padding {2 0}
1266 ttk::button .main.tb.help -image tb_help -command {helpWindow Index} -padding {2 0}
1268 foreach i {newdb open save closedb finder bkm newgame copy paste gprev gnext \
1269 boardsearch headersearch materialsearch \
1270 switcher glist pgn tmt maint eco tree crosstab engine help} {
1271 .main.tb.$i configure -takefocus 0
1278 proc toggleToolbarButton { b i } {
1279 if { $::toolbar_temp($i) } {
1280 set ::toolbar_temp($i) 0
1281 $b.$i state !pressed
1283 set ::toolbar_temp($i) 1
1288 proc configToolbar {} {
1291 wm title $w "Scid: [
tr OptionsToolbar]"
1293 array set ::toolbar_temp [
array get ::toolbar_state]
1294 pack [ttk::frame $w.f] -side top -fill x
1297 foreach i {newdb open closedb finder save bkm row gprev gnext row newgame copy paste row boardsearch headersearch \
1298 materialsearch row switcher glist pgn tmt maint eco tree crosstab engine } {
1299 if { $i eq "row" } {
incr row
set col 0}
else {
1300 ttk::button $w.f.$i -image tb_$i -command "toggleToolbarButton $w.f $i"
1301 if { $::toolbar_temp($i) } { $w.f.$i state pressed}
1302 grid $w.f.$i -row $row -column $col -sticky news -padx 4 -pady "0 8"
1308 pack [ttk::frame $w.b] -side bottom -fill x
1310 foreach i [array names toolbar_temp] { set toolbar_temp($i) 1; .tbconfig.f.$i state pressed }
1313 foreach i [array names toolbar_temp] { set toolbar_temp($i) 0 ; .tbconfig.f.$i state !pressed }
1315 ttk::button $w.ok -text "OK" -command {
1316 array set ::toolbar_state [array get toolbar_temp]
1317 catch {grab release .tbconfig}
1321 ttk::button $w.cancel -text $::tr(Cancel) \
1322 -command "catch {grab release $w}; destroy $w"
1323 pack $w.cancel $w.ok -side right -padx 2 -pady "5 0"
1324 pack $w.on $w.off -side left -padx 2 -pady "5 0"
1328 proc redrawToolbar {} {
1329 foreach i [
winfo children .main.tb] {
pack forget $i}
1332 foreach i {newdb open closedb finder save bkm} {
1333 if {$::toolbar_state($i)} {
1334 set seen 1
set seenAny 1
1335 pack .main.tb.$i -side left -pady 1 -padx 0 -ipadx 0 -pady 0 -ipady 0
1338 if {$seen} {
pack .main.tb.space1 -side left}
1340 foreach i {gprev gnext} {
1341 if {$::toolbar_state($i)} {
1342 set seen 1
set seenAny 1
1343 pack .main.tb.$i -side left -pady 1 -padx 0 -ipadx 0 -pady 0 -ipady 0
1346 if {$seen} {
pack .main.tb.space2 -side left}
1348 foreach i {newgame copy paste} {
1349 if {$::toolbar_state($i)} {
1350 set seen 1
set seenAny 1
1351 pack .main.tb.$i -side left -pady 1 -padx 0 -ipadx 0 -pady 0 -ipady 0
1354 if {$seen} {
pack .main.tb.space3 -side left}
1356 foreach i {boardsearch headersearch materialsearch} {
1357 if {$::toolbar_state($i)} {
1358 set seen 1
set seenAny 1
1359 pack .main.tb.$i -side left -pady 1 -padx 0 -ipadx 0 -pady 0 -ipady 0
1362 if {$seen} {
pack .main.tb.space4 -side left}
1364 foreach i {switcher glist pgn tmt maint eco tree crosstab engine} {
1365 if {$::toolbar_state($i)} {
1366 set seen 1
set seenAny 1
1367 pack .main.tb.$i -side left -pady 1 -padx 0 -ipadx 0 -pady 0 -ipady 0
1371 grid .main.tb -row 0 -column 0 -columnspan 3 -sticky we
1373 grid forget .main.tb