Scid  4.7.0
windows.tcl
Go to the documentation of this file.
1 ###
2 ### windows.tcl: part of Scid.
3 ### Copyright (C) 1999-2003 Shane Hudson.
4 ###
5 
6 
7 ########################################################################
8 ### Optional windows: all off initially.
9 
10 set treeWin 0
11 set pgnWin 0
12 set filterGraph 0
13 
14 ################################################################################
15 # Creates a toplevel window depending of the docking option
16 ################################################################################
17 proc createToplevel { {w} {closeto ""} } {
18  # Raise window if already exist
19  if { [winfo exists $w] } {
20  lassign [::win::isDocked $w] docked_nb w
21  if {$docked_nb ne ""} {
22  $docked_nb select $w
23  } else {
24  wm deiconify $w
25  }
26  return "already_exists"
27  }
28 
29  set f ".fdock[string range $w 1 end]"
30  frame $f -container 1
31  toplevel $w -use [ winfo id $f]
33 
34  # Set default width and height values, if they do not exists
35  if {![info exists ::winGeometry($f)]} {
36  set ::winGeometry($f) ""
37  }
38 
40 }
41 
42 ################################################################################
43 # In the case of a window closed without the context menu in docked mode, arrange for the tabs to be cleaned up
44 # This function is necessary only if does exists a "destroy" command for the win created with createToplevel
45 ################################################################################
46 proc createToplevelFinalize {w} {
47  bind $w <Destroy> "+if {\[string equal $w %W\]} {
48  cleanup_todo_remove $w
49  }"
50 }
51 proc cleanup_todo_remove { w } {
52  set dockw ".fdock[string range $w 1 end]"
53  set tab [::docking::find_tbn $dockw]
54  if {$tab != ""} {
55  $tab forget $dockw
57  }
58  after idle "if {[winfo exists $dockw]} { destroy $dockw }"
59  catch { focus .main}
60 }
61 
62 # recordWinSize:
63 # Records window width and height, for saving in options file.
64 #
65 proc recordWinSize {win} {
66  global winWidth winHeight winX winY
67  if {![winfo exists $win]} { return}
68  set temp [wm geometry $win]
69 
70  set suffix ""
71  set n [scan $temp "%dx%d+%d+%d" width height x y]
72  if {$n == 4} {
73  set winWidth${suffix}($win) $width
74  set winHeight${suffix}($win) $height
75  set winX${suffix}($win) $x
76  set winY${suffix}($win) $y
77  }
78 }
79 
80 proc setWinLocation {win} {
81  global winX winY
82  set suffix ""
83  if {[info exists winX${suffix}($win)] && [info exists winY${suffix}($win)] && \
84  [set winX${suffix}($win)] >= 0 && [set winY${suffix}($win)] >= 0} {
85  catch [list wm geometry $win "+[set winX${suffix}($win)]+[set winY${suffix}($win)]"]
86  }
87 }
88 
89 proc setWinSize {win} {
90  global winWidth winHeight
91  set suffix ""
92  if {[info exists winWidth${suffix}($win)] && [info exists winHeight${suffix}($win)] && \
93  [set winWidth${suffix}($win)] > 0 && [set winHeight${suffix}($win)] > 0 } {
94  catch [list wm geometry $win "[set winWidth${suffix}($win)]x[set winHeight${suffix}($win)]"]
95  }
96 }
97 
98 ###
99 ### End of file: windows.tcl
100 ###