Scid  4.6.5
board.tcl
Go to the documentation of this file.
1 ###
2 ### search/board.tcl: Board Search routines for Scid.
3 ###
4 
5 set searchInVars 0
6 set sBoardIgnoreCols 0
7 set sBoardSearchType Exact
8 
9 # ::search::board
10 # Opens the search window for the current board position.
11 #
12 proc ::search::board {{ref_base ""}} {
13  global searchInVars sBoardType sBoardIgnoreCols
14 
15  set w .sb
16  if {[winfo exists $w]} {
17  wm deiconify $w
18  raiseWin $w
19  return
20  }
21 
22  toplevel $w
23  wm title $w "Scid: $::tr(BoardSearch)"
24 
25  bind $w <Escape> "$w.b.cancel invoke"
26  bind $w <Return> "$w.b.search invoke"
27  bind $w <F1> { helpWindow Searches Board }
28 
29  pack [ttk::frame $w.refdb] -side top -fill x
30  CreateSelectDBWidget "$w.refdb" "refDatabaseB" "$ref_base"
32 
33  ttk::label $w.type -textvar ::tr(SearchType) -font font_Bold -anchor center
34  pack $w.type -side top -expand 1 -fill x
35  pack [ttk::frame $w.g] -side top -fill x
36  ttk::radiobutton $w.g.exact -textvar ::tr(SearchBoardExact) -variable sBoardSearchType -value Exact
37  ttk::radiobutton $w.g.pawns -textvar ::tr(SearchBoardPawns) -variable sBoardSearchType -value Pawns
38  ttk::radiobutton $w.g.files -textvar ::tr(SearchBoardFiles) -variable sBoardSearchType -value Fyles
39  ttk::radiobutton $w.g.material -textvar ::tr(SearchBoardAny) -variable sBoardSearchType -value Material
40  set row 0
41  foreach i {exact pawns files material} {
42  grid $w.g.$i -row $row -column 0 -sticky w
43  incr row
44  }
46 
49 
50  ### Progress bar:
51 
52  ttk::frame $w.fprogress
53  canvas $w.fprogress.progress -height 20 -width 300 -bg white -relief solid -border 1
54  $w.fprogress.progress create rectangle 0 0 0 0 -fill blue -outline blue -tags bar
55  $w.fprogress.progress create text 295 10 -anchor e -font font_Regular -tags time -fill black -text "0:00 / 0:00"
56  pack $w.fprogress.progress -side top -anchor center -expand 1 -pady 2
57 
58  ttk::frame $w.b2
59  pack $w.b2 -side top -fill x
60  ttk::frame $w.b
61  pack $w.b -side top -fill x
62  ttk::checkbutton $w.b2.vars -textvar ::tr(LookInVars) -onvalue 1 -offvalue 0 -variable searchInVars
63  ttk::checkbutton $w.b2.flip -textvar ::tr(IgnoreColors) -onvalue 1 -offvalue 0 -variable sBoardIgnoreCols
64 
65  dialogbutton $w.b.stop -textvar ::tr(Stop) -command progressBarCancel
66  $w.b.stop configure -state disabled
67 
68  dialogbutton $w.b.search -textvar ::tr(Search) -command {
69  .sb.b.stop configure -state normal
70  grab .sb.b.stop
71 
72  regexp {(\d+).*} $::refDatabaseB -> base
73  progressBarSet .sb.fprogress.progress 301 21
74  set str [sc_search board $::search::filter::operation $sBoardSearchType $searchInVars $sBoardIgnoreCols $base]
75 
76  grab release .sb.b.stop
77  .sb.b.stop configure -state disabled
78  #tk_messageBox -type ok -title $::tr(SearchResults) -message $str
79  .sb.status configure -text $str
80  ::notify::DatabaseModified $base dbfilter
81  }
82  dialogbutton $w.b.cancel -textvar ::tr(Close) -command "focus .; destroy $w"
83  pack $w.b2.vars $w.b2.flip -side left -pady 2 -padx 5
84  packbuttons right $w.b.cancel .sb.b.search .sb.b.stop
85  pack $w.fprogress -side top -fill x
86  ttk::label $w.status -text "" -width 1 -font font_Small -relief sunken -anchor w
87  pack $w.status -side bottom -fill x
88  wm resizable $w 0 0
90  focus $w.b.search
91 }