5 set ::windows::eco::code ""
6 set ::windows::eco::count 0
7 set ::windows::eco::isOpen 0
9 proc ::windows::eco::OpenClose {} {
10 if {[
winfo exists .ecograph]} {
23 proc ::windows::eco::Refresh {{code "x"}} {
25 set graph $w.pane.graph
27 if {$code != "x"} {
set ::windows::eco::code $code}
28 if {! [
winfo exists $w]} {
29 set ::windows::eco::isOpen 1
32 bind $w <Escape> "destroy $w"
33 bind $w <F1> {helpWindow ECO}
34 bind $w <Destroy> {set ::windows::eco::isOpen 0}
35 text $w.title -relief flat -height 1 -width 1 -wrap word -font font_Bold
36 $w.title tag configure center -justify center
37 $w.title configure -cursor top_left_arrow
38 pack $w.title -side top -fill x
40 pack $w.b -side bottom -fill x
41 ttk::button $w.b.classify -textvar ::tr(ReclassifyGames) -command classifyAllGames
42 dialogbutton $w.b.help -textvar ::tr(Help) -command {helpWindow ECO}
43 dialogbutton $w.b.close -textvar ::tr(Close) -command "destroy $w"
44 pack $w.b.classify -side left -padx 5 -pady 5
49 pack $pane -side top -expand true -fill both
51 canvas $graph.c -width 500 -height 250 -selectforeground [ttk::style lookup . -foreground] -background [ttk::style lookup . -background]
52 pack $graph.c -side top -fill both -expand yes
53 text $text.text -height 12 -width 75 -wrap word -font font_Regular \
54 -background white -selectbackground lightBlue \
55 -yscroll "$text.ybar set" -xscroll "$text.xbar set"
56 $text.text tag configure bold -font font_Bold
57 $text.text tag configure indent -lmargin2 20
58 $text.text configure -cursor top_left_arrow
60 ttk::scrollbar $text.ybar -command "$text.text yview"
61 ttk::scrollbar $text.xbar -orient horizontal -command "$text.text xview"
62 grid $text.text -row 0 -column 0 -sticky nesw
63 grid $text.ybar -row 0 -column 1 -sticky nesw
65 grid rowconfig $text 0 -weight 1 -minsize 0
66 grid columnconfig $text 0 -weight 1 -minsize 0
68 foreach i {0 1 2 3 4 5 6 7 8 9 A B C D E a b c d e f g h i j k l m n o p
69 q r s t u v w x y z} {
70 bind $w <KeyPress-$i> "::windows::eco::KeyPress $i"
73 foreach i {Left Delete less BackSpace} {
74 bind $w <KeyPress-$i> {::windows::eco::KeyPress "<"}
77 bind $w <Home> {.ecograph.pane.text.text yview moveto 0}
78 bind $w <End> {.ecograph.pane.text.text yview moveto 1.0}
79 bind $w <Up> {.ecograph.pane.text.text yview scroll -1 units}
80 bind $w <Down> {.ecograph.pane.text.text yview scroll 1 units}
81 bind $w <Prior> {.ecograph.pane.text.text yview scroll -1 pages}
82 bind $w <Next> {.ecograph.pane.text.text yview scroll 1 pages}
84 bind $graph.c <1> { ::windows::eco::Select %x }
85 bind $graph.c <$::MB3> { ::windows::eco::KeyPress "<" }
87 bind $graph <Configure> {
88 ::utils::graph::configure eco -height [expr {[winfo height .ecograph.pane.graph.c] - 50} ]
89 ::utils::graph::configure eco -width [expr {[winfo width .ecograph.pane.graph.c] - 60} ]
90 ::utils::graph::redraw eco
93 ::utils::graph::configure eco -height [expr {[winfo height .ecograph.pane.graph.c] - 50} ]
94 ::utils::graph::configure eco -width [expr {[winfo width .ecograph.pane.graph.c] - 60} ]
95 ::utils::graph::redraw eco
99 -xmin 0.5 -xtick 1 -ytick 5 -font font_Small -canvas $graph.c
108 proc ::windows::eco::update {} {
110 set graph $w.pane.graph
111 set text $w.pane.text
113 set height [
expr {[winfo height $graph.c] - 50}]
114 set width [
expr {[winfo width $graph.c] - 60}]
116 set code $::windows::eco::code
118 set len [
string length $code]
121 set subcodes {A B C D E}
122 }
elseif {$len == 1 || $len == 2} {
123 set subcodes {0 1 2 3 4 5 6 7 8 9}
124 }
elseif {$len == 3} {
125 set subcodes {a b c d e f g h i j k l m n o p q r s t u v w x y z}
135 set ::curr_db [
sc_base current]
136 foreach i $subcodes {
137 set subcode "$code$i"
138 set stats [
sc_base stats $::curr_db eco $subcode]
139 set freq [
lindex $stats 0]
144 lappend wins [
lindex $stats 1]
146 lappend draws [
expr {[lindex $stats 1] + [lindex $stats 2] + [lindex $stats 4]}]
147 if {$freq > $maxfreq} {
set maxfreq $freq}
151 lappend xlabels [list $count $subcode]
154 if {$maxfreq > 20} {
set hline 10}
155 if {$maxfreq > 50} {
set hline 25}
156 if {$maxfreq > 100} {
set hline 50}
157 if {$maxfreq > 200} {
set hline 100}
158 if {$maxfreq > 500} {
set hline 250}
159 if {$maxfreq > 1000} {
set hline 500}
160 if {$maxfreq > 2000} {
set hline 1000}
161 if {$maxfreq > 5000} {
set hline 2500}
162 if {$maxfreq > 10000} {
set hline 5000}
163 if {$maxfreq > 20000} {
set hline 10000}
164 if {$maxfreq > 50000} {
set hline 25000}
165 if {$maxfreq > 100000} {
set hline 50000}
168 -xmin 0.5 -xtick 1 -ytick $hline -font font_Small -canvas $graph.c
170 -barwidth 0.8 -outline black -coords $data
172 -barwidth 0.8 -outline black -coords $draws
174 -barwidth 0.8 -outline black -coords $wins
177 -xlabels $xlabels -hline [list [list gray80 1 each $hline]]
179 $text.text configure -state normal
180 $text.text delete 1.0 end
181 set stats [
sc_base stats $::curr_db eco $code]
183 set section $::tr(ECOAllSections)
184 }
elseif {$len < 3} {
185 set section "$::tr(ECOSection) \"$code\""
187 set section "$::tr(ECOCode) \"$code\""
189 set header "<center><b>$::tr(ECOSummary) $section</b><br>"
190 append header "[
lindex $stats 0] $::tr(games): +[
lindex $stats 1] =[
lindex $stats 2] -[
lindex $stats 3] ([
lindex $stats 5]%)</center>\n\n"
192 $text.text configure -state disabled
193 $w.title configure -state normal
194 $w.title delete 1.0 end
195 $w.title insert end "$::tr(ECOFrequency) $section" center
196 $w.title configure -state disabled
197 set ::windows::eco::count $count
200 proc ::windows::eco::Select {xc} {
206 for {
set i 1} {$i <= $count} {
incr i} {
207 if {$x >= [
expr {$i - 0.4}] && $x <= [
expr {$i + 0.4}]} {
211 if {$selection == 0} {
return}
213 set len [
string length $code]
215 set code [
lindex {A B C D E} $selection]
216 }
elseif {$len == 1 || $len == 2} {
217 append code $selection
218 }
elseif {$len == 3} {
219 append code [
lindex {a b c d e f g h i j k l m n o p q r s t u v w x y z} $selection]
230 proc ::windows::eco::KeyPress {key} {
231 set code $::windows::eco::code
232 set len [
string length $code]
234 set ::windows::eco::code [
string range $code 0 [
expr {$len - 2}]]
239 set ::windows::eco::code ""
245 set key [
string toupper $key]
250 default {
set key ""}
252 }
elseif {$len == 1 || $len == 2} {
254 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 {
257 default {
set key ""}
259 }
elseif {$len == 3} {
260 set key [
string tolower $key]
262 a - b - c - d - e - f - g - h - i - j - k - l - m - n - o - p - q - r -
263 s - t - u - v - w - x - y - z {
266 default {
set key ""}
271 set ::windows::eco::code "$code$key"