1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458
|
itcl::class fvWinKeeper {
inherit itk::Toplevel
constructor {args} {}
destructor {}
private variable _namList ""
private variable _winList ""
private variable _typList ""
private variable _extList ""
private variable _objList ""
private variable _tmpWinList ""
private variable _tmpObjList ""
private variable _tmpTypList ""
public method register {win type fName extNum obj}
public method signoff {win}
public method intCheck {type}
public method setCursor { cursor }
public method actOn {win}
public method updateMacWindows { }
public method updateVisibility { }
public method updateDisplayDeviceStatus {}
private method _hide {}
private method _clean {}
private method _refresh {}
}
itcl::body fvWinKeeper::constructor {args} {
global isMac isWin
global env
global g_titleFont
global xpaFlag
wm geometry $itk_interior 1x1+0+0
wm overrideredirect $itk_interior 1
wm transient $itk_interior
tkwait visibility $itk_interior
if { ! $isMac } {
itk_component add mainMenu {
menu $itk_interior.menu -tearoff false -type tearoff -bd 0
}
wm attributes $itk_interior.menu -type normal
wm resizable $itk_interior.menu 0 0
wm title $itk_interior.menu "fv"
wm geometry $itk_interior.menu +0+0
set itk_interior $itk_component(mainMenu)
$itk_component(mainMenu) add command -label "New File..." \
-font g_titleFont \
-command createNewFITS
$itk_component(mainMenu) add command -label "Open File..." \
-font g_titleFont \
-command selFile
$itk_component(mainMenu) add command -label "SkyView..." \
-font g_titleFont \
-command {
global g_skyvflag
if ![info exists g_skyvflag ] {
set g_skyvflag 1
FVSkyview skyv
}
skyv getskyvfile
}
$itk_component(mainMenu) add command -label "Catalogs..." \
-font g_titleFont \
-command {
global g_skyvflag
if ![info exists g_skyvflag ] {
set g_skyvflag 1
FVSkyview skyv
}
skyv getskyvcat
}
$itk_component(mainMenu) add command -label "VizieR..." \
-font g_titleFont \
-command {
global g_vizier
if ![info exists g_vizier ] {
set g_vizier 1
FVVizier viz
}
viz selectVizier
}
if { [info exists env(FTOOLS)] || [info exists env(LHEASOFT)] } {
$itk_component(mainMenu) add command -label "Run Ftool..." \
-font g_titleFont \
-command {
set text_ "The \"Run Ftool\" option has been removed from fv.\nInstead, run the \"fgui\" task that is distributed with ftools.\n\n\nThe ftools software is available from\n\nhttp://heasarc.gsfc.nasa.gov/ftools"
if {$isWin } {
tk_messageBox -icon info -type ok \
-message $text_
} else {
if ![winfo exists .nomoreRunFtool] {
iwidgets::messagedialog .nomoreRunFtool -title "fv: \"Run Ftool\" disabled" \
-font g_titleFont \
-bitmap info \
-modality application
}
wm geom .nomoreRunFtool +[expr [winfo screenwidth .] / 3]+[expr [winfo screenheight .] / 2]
.nomoreRunFtool configure -text $text_
.nomoreRunFtool hide Cancel
.nomoreRunFtool activate
}
}
}
$itk_component(mainMenu) add command -label "Connect to Hera..." \
-font g_titleFont \
-command {
global g_vizier
set fvExecutable [info nameofexecutable]
if { [string tolower [file tail $fvExecutable]] != "fv" && \
[string tolower [file tail $fvExecutable]] != "fv.exe" } {
# this is NOT one-click or Windows
set fvExecutable "fv"
}
catch { exec $fvExecutable -mod hera & }
}
$itk_component(mainMenu) add separator
itk_component add displayFrame {
menu $itk_interior.df -tearoff false
}
$itk_component(displayFrame) add radiobutton \
-font g_titleFont \
-variable [itcl::scope ::fvPref::imgDisplayer] \
-selectcolor $fvPref::checkBBgColor \
-activeforeground black -activebackground $fvPref::globalBgColor \
-label "DS9" -command { fvPref save }
$itk_component(displayFrame) add radiobutton \
-font g_titleFont \
-variable [itcl::scope ::fvPref::imgDisplayer] \
-label "POW" -command { fvPref save } \
-selectcolor $fvPref::checkBBgColor \
-activeforeground black -activebackground $fvPref::globalBgColor
if { !$isWin } {
if { $xpaFlag == "NOT_AVAILABLE" } {
# $itk_component(displayFrame) entryconfigure 0 -state disabled
set ::fvPref::imgDisplayer "POW"
#fvPref save
}
} else {
$itk_component(displayFrame) entryconfigure 0 -state normal
}
$itk_component(mainMenu) add cascade \
-font g_titleFont \
-menu $itk_component(displayFrame) -label "Display Device"
$itk_component(mainMenu) add separator
$itk_component(mainMenu) add command -label "Hide All Windows" \
-font g_titleFont \
-command [itcl::code $this actOn all]
itk_component add summarymenu {
menu $itk_interior.sm -tearoff false
}
$itk_component(mainMenu) add cascade \
-font g_titleFont \
-menu $itk_component(summarymenu) -label "File Summary"
itk_component add headermenu {
menu $itk_interior.hm -tearoff false
}
$itk_component(mainMenu) add cascade \
-font g_titleFont \
-menu $itk_component(headermenu) -label "Header"
itk_component add tablemenu {
menu $itk_interior.tm -tearoff false
}
$itk_component(mainMenu) add cascade \
-font g_titleFont \
-menu $itk_component(tablemenu) -label "Table"
itk_component add itablemenu {
menu $itk_interior.itm -tearoff false
}
$itk_component(mainMenu) add cascade \
-font g_titleFont \
-menu $itk_component(itablemenu) -label "Image Table"
itk_component add vtablemenu {
menu $itk_interior.vtm -tearoff false
}
$itk_component(mainMenu) add cascade \
-font g_titleFont \
-menu $itk_component(vtablemenu) -label "Vector Table"
$itk_component(mainMenu) add separator
$itk_component(mainMenu) add command -label "Preference" \
-font g_titleFont \
-command {fvPref edit}
$itk_component(mainMenu) add separator
$itk_component(mainMenu) add command -label "Clipboard" \
-font g_titleFont \
-command {fvClipBoard toggleView}
$itk_component(mainMenu) add separator
$itk_component(mainMenu) add command -label "Help" \
-font g_titleFont \
-command {hhelp deskTopManager}
$itk_component(mainMenu) add command -label "Quit" \
-font g_titleFont \
-command "doMenuEvent <<Quit>> ."
} else {
set itk_component(summarymenu) .mbar.wind.sm
set itk_component(headermenu) .mbar.wind.hm
set itk_component(tablemenu) .mbar.wind.tm
set itk_component(vtablemenu) .mbar.wind.vtm
set itk_component(itablemenu) .mbar.wind.itm
}
wm protocol $itk_interior WM_DELETE_WINDOW [itcl::code $this _hide]
_refresh
}
itcl::body fvWinKeeper::destructor {} {
}
itcl::body fvWinKeeper::_clean {} {
$itk_component(summarymenu) delete 0 last
$itk_component(headermenu) delete 0 last
$itk_component(tablemenu) delete 0 last
$itk_component(vtablemenu) delete 0 last
$itk_component(itablemenu) delete 0 last
}
itcl::body fvWinKeeper::_refresh {} {
set hcount 0
set tcount 0
set vtcount 0
set itcount 0
set scount 0
for {set i 0} {$i < [llength $_winList]} {incr i} {
set win [lindex $_winList $i]
set type [lindex $_typList $i]
set name [lindex $_namList $i]
# starts with 0
set ext [expr [lindex $_extList $i] -1]
switch $type {
"Header" {
$itk_component(headermenu) add command -label ${name}\[$ext\] \
-font g_titleFont \
-command [itcl::code $this actOn $win]
incr hcount
}
"Table" {
$itk_component(tablemenu) add command -label ${name}\[$ext\] \
-font g_titleFont \
-command [itcl::code $this actOn $win]
incr tcount
}
"Vector Table" {
$itk_component(vtablemenu) add command -label ${name}\[$ext\] \
-font g_titleFont \
-command [itcl::code $this actOn $win]
incr vtcount
}
"Image Table" {
$itk_component(itablemenu) add command -label ${name}\[$ext\] \
-font g_titleFont \
-command [itcl::code $this actOn $win]
incr itcount
}
"Highlight" {
$itk_component(summarymenu) add command -label $name \
-font g_titleFont \
-command [itcl::code $this actOn $win]
incr scount
}
default {
error "Unknown type of window to manage: $type"
return
}
}
}
foreach {var menu} [list hcount header tcount table vtcount vtable \
itcount itable scount summary] {
if { [expr $$var] == 0 } {
$itk_component(${menu}menu) add command -label none \
-font g_titleFont \
-state disabled
}
}
}
itcl::body fvWinKeeper::updateMacWindows { } {
_clean
_refresh
}
itcl::body fvWinKeeper::actOn {win} {
if {$win == "all"} {
if {[llength $_winList ] == 0} {
set tmpwinlist ".fD"
} else {
set tmpwinlist $_winList
lappend tmpwinlist ".fD"
}
foreach w $tmpwinlist {
wm withdraw $w
}
} else {
if { [winfo viewable $win] == 1} {
wm withdraw $win
} else {
wm deiconify $win
}
}
}
itcl::body fvWinKeeper::setCursor { cursor } {
foreach w $_winList {
catch {$w configure -cursor $cursor}
}
$this configure -cursor $cursor
}
itcl::body fvWinKeeper::register {win type fName extNum obj} {
set _tmpWinList $_winList
set _tmpObjList $_objList
set _tmpTypList $_typList
catch {intCheck $type}
_clean
if { [lsearch $_winList $win] == -1} {
lappend _winList $win
lappend _namList $fName
lappend _typList $type
lappend _extList $extNum
lappend _objList $obj
}
_refresh
}
itcl::body fvWinKeeper::signoff {win} {
# if { ![winfo exists $itk_component(mainMenu)] } return
_clean
set idx [lsearch $_winList $win]
if { $idx !=-1} {
set _winList [lreplace $_winList $idx $idx]
set _typList [lreplace $_typList $idx $idx]
set _namList [lreplace $_namList $idx $idx]
set _extList [lreplace $_extList $idx $idx]
set _objList [lreplace $_objList $idx $idx]
}
_refresh
if { [llength $_winList]==0 } {
event generate . <<CheckExit>> -when tail
}
}
itcl::body fvWinKeeper::intCheck {t} {
switch $fvPref::winManagement {
"Keep" {
return
}
"Hide" {
for {set i 0} { $i< [llength $_tmpWinList]} {incr i} {
set win [lindex $_tmpWinList $i]
set tmpName [lindex $_tmpTypList $i]
if { $tmpName == $t } {
wm withdraw $win
}
}
}
"Close" {
for {set i 0} { $i< [llength $_tmpWinList]} {incr i} {
set win [lindex $_tmpWinList $i]
set tmpName [lindex $_tmpTypList $i]
if { $tmpName == $t } {
event generate $win <<CloseWindow>>
}
}
}
default {
puts "fv Error: unknown type of window handling"
}
}
}
itcl::body fvWinKeeper::updateDisplayDeviceStatus {} {
# Pan Chai: this function will not be called until XPA is available in Windows
global isWin
global env
if { $isWin } {
if { [info exists ::fvPref::ds9LibPath] && \
[string length ${::fvPref::ds9LibPath}] > 0 && \
[file exists ${::fvPref::ds9LibPath}/ds9.exe] && \
[info exists ::fvPref::xpaLibPath] && \
[string length ${::fvPref::xpaLibPath}] > 0 && \
[file exists ${::fvPref::xpaLibPath}] } {
$itk_component(displayFrame) entryconfigure 0 -state normal
set origPath $env(PATH)
set env(PATH) "$origPath;${::fvPref::ds9LibPath}"
} else {
#$itk_component(displayFrame) entryconfigure 0 -state disabled
}
if { [info exists ::fvPref::xpaLibPath] && [string length ${::fvPref::xpaLibPath}] > 0 && [file exists ${::fvPref::xpaLibPath}] } {
set origPath $env(PATH)
set env(PATH) "$origPath;${::fvPref::xpaLibPath}"
::powXPA::init
}
}
}
itcl::body fvWinKeeper::updateVisibility { } {
global isMac
if { !$isMac && $fvPref::ifUseManager } {
wm deiconify $itk_interior
if { ! [winfo ismapped $itk_component(mainMenu)] } {
$itk_component(mainMenu) post 0 0
}
} else {
wm withdraw $itk_interior
}
}
itcl::body fvWinKeeper::_hide { } {
global isMac
set fvPref::ifUseManager 0
updateVisibility
if { !$isMac && [llength $_winList]==0 } {
checkForExit
}
}
|