| 1 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 2 | # FILE : project.tcl |
|---|
| 3 | # PURPOSE : This file implement the comunication between the project and |
|---|
| 4 | # tolcon. Menu description is taken from |
|---|
| 5 | # http://mini.net/tcl/827.html, the implementation is in file |
|---|
| 6 | # prjmenu.tcl. |
|---|
| 7 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 8 | |
|---|
| 9 | package require bfunctions |
|---|
| 10 | package require btoplevel |
|---|
| 11 | package require fmenu |
|---|
| 12 | package require mdi |
|---|
| 13 | package require bodbc |
|---|
| 14 | |
|---|
| 15 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 16 | namespace eval ::project { |
|---|
| 17 | # |
|---|
| 18 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 19 | variable data |
|---|
| 20 | variable events |
|---|
| 21 | variable widgets |
|---|
| 22 | |
|---|
| 23 | array set projects {} |
|---|
| 24 | |
|---|
| 25 | array set data { |
|---|
| 26 | name "" |
|---|
| 27 | path "" |
|---|
| 28 | killing 0 |
|---|
| 29 | init 0 |
|---|
| 30 | tolconreq 0 |
|---|
| 31 | minmode withdraw |
|---|
| 32 | minforzed 0 |
|---|
| 33 | splashed 0 |
|---|
| 34 | oculto 0 |
|---|
| 35 | defaulthelpkey ""} |
|---|
| 36 | array set widgets { |
|---|
| 37 | children "" |
|---|
| 38 | children,types "" |
|---|
| 39 | children,type,default "" |
|---|
| 40 | children,saved "" |
|---|
| 41 | mainframe . |
|---|
| 42 | } |
|---|
| 43 | array set events {OnInitTcl "" OnInitTol "" OnExit ""} |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 48 | proc ::project::project { inf } { |
|---|
| 49 | # |
|---|
| 50 | # PURPOSE: Defines the projects & initializes the namespace variables. |
|---|
| 51 | # |
|---|
| 52 | # PARAMETERS: |
|---|
| 53 | # name : |
|---|
| 54 | # path : |
|---|
| 55 | # |
|---|
| 56 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 57 | variable data |
|---|
| 58 | variable widgets |
|---|
| 59 | variable projects |
|---|
| 60 | |
|---|
| 61 | # definition connection BODBC |
|---|
| 62 | set data(bodbc) [bodbc bodbcgestor] |
|---|
| 63 | #Tolcon_Trace "project.project : data(bodbc)=$data(bodbc)" |
|---|
| 64 | |
|---|
| 65 | set projects(Project,splash) "" |
|---|
| 66 | set projects(Project,names) "" |
|---|
| 67 | array set projects $inf |
|---|
| 68 | |
|---|
| 69 | array set events {OnInitTcl "" OnInitTol "" OnExit ""} |
|---|
| 70 | array unset widgets |
|---|
| 71 | array set data { |
|---|
| 72 | killing 0 |
|---|
| 73 | init 0 |
|---|
| 74 | tolconreq 0 |
|---|
| 75 | minmode withdraw |
|---|
| 76 | minforzed 0 |
|---|
| 77 | splashed 0 |
|---|
| 78 | defaulthelpkey "Tb4Mai"} |
|---|
| 79 | array set widgets { |
|---|
| 80 | children "" |
|---|
| 81 | children,types "" |
|---|
| 82 | children,type,default "" |
|---|
| 83 | children,saved "" |
|---|
| 84 | mainframe . |
|---|
| 85 | } |
|---|
| 86 | # hide the main window, the one containing the menu bar |
|---|
| 87 | wm withdraw . |
|---|
| 88 | if { [expr ! $data(oculto)] } { |
|---|
| 89 | splashWindow |
|---|
| 90 | } |
|---|
| 91 | } |
|---|
| 92 | |
|---|
| 93 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 94 | proc ::project::path { name } { |
|---|
| 95 | # |
|---|
| 96 | # PURPOSE: Returns the project path. |
|---|
| 97 | # |
|---|
| 98 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 99 | variable projects |
|---|
| 100 | return $projects($name,path) |
|---|
| 101 | } |
|---|
| 102 | |
|---|
| 103 | |
|---|
| 104 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 105 | proc ::project::init { } { |
|---|
| 106 | # |
|---|
| 107 | # PURPOSE: Starts the project. If there is no project, it starts tolcon. |
|---|
| 108 | # Could be started only once. |
|---|
| 109 | # |
|---|
| 110 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 111 | global tcl_platform |
|---|
| 112 | global toltk_images_path |
|---|
| 113 | variable data |
|---|
| 114 | variable widgets |
|---|
| 115 | variable projects |
|---|
| 116 | |
|---|
| 117 | if { $data(init) } return |
|---|
| 118 | startupResources |
|---|
| 119 | initWM |
|---|
| 120 | if { [info exists projects(Project,names)] && \ |
|---|
| 121 | [llength $projects(Project,names)] > 0 } { |
|---|
| 122 | load |
|---|
| 123 | } else { |
|---|
| 124 | UseTolCon |
|---|
| 125 | } |
|---|
| 126 | # Read .ini (paramters TolBase) |
|---|
| 127 | ::TolConsole::ReadIni |
|---|
| 128 | |
|---|
| 129 | # Gives a name for the application |
|---|
| 130 | set prjtitle "TOLBase" |
|---|
| 131 | if { [info exists projects(Project,title)] && $projects(Project,title) ne "" } { |
|---|
| 132 | set prjtitle $projects(Project,title) |
|---|
| 133 | } |
|---|
| 134 | wm title . $prjtitle |
|---|
| 135 | |
|---|
| 136 | #if { [TolConReq] } |
|---|
| 137 | #Creamos frame de trabajo |
|---|
| 138 | set widgets(mainmenu) [::project::CreateMdiMenu .main.mdi] |
|---|
| 139 | set widgets(mainframe) [frame .main] |
|---|
| 140 | set widgets(mainmdi) [mdi .main.mdi -mdimenu $widgets(mainmenu) \ |
|---|
| 141 | -relief sunken -bd 1] |
|---|
| 142 | pack $widgets(mainmenu) -fill x -side top |
|---|
| 143 | pack $widgets(mainframe) -fill both -expand yes -side bottom |
|---|
| 144 | pack $widgets(mainmdi) -fill both -expand yes -side bottom |
|---|
| 145 | bind . <Control-Tab> "[list $widgets(mainmdi) cicle]; break" |
|---|
| 146 | ::TolConsole::MainFrame $widgets(mainmdi) [TolConReq] |
|---|
| 147 | # |
|---|
| 148 | |
|---|
| 149 | if { [TolConReq] } { |
|---|
| 150 | ::TolConsole::MenuMDI |
|---|
| 151 | } |
|---|
| 152 | foreach prj $projects(Project,names) { |
|---|
| 153 | set prjname $projects(${prj},name) |
|---|
| 154 | if { [string length $prjname] } { eval ${prjname}::InitTcl } |
|---|
| 155 | } |
|---|
| 156 | $widgets(mainmenu) draw |
|---|
| 157 | |
|---|
| 158 | if { [string equal $tcl_platform(platform) "unix"] } { |
|---|
| 159 | wm iconbitmap . "@[file join $toltk_images_path bayes.xbm]" |
|---|
| 160 | } else { |
|---|
| 161 | wm iconbitmap . -default [file join $toltk_images_path bayes.ico] |
|---|
| 162 | } |
|---|
| 163 | if { [TolConReq] } { |
|---|
| 164 | ::TolInspector::Busy |
|---|
| 165 | } |
|---|
| 166 | # update |
|---|
| 167 | if { $projects(Project,path,root) ne "" } { |
|---|
| 168 | set initol 0 |
|---|
| 169 | set iniproject [ file join $projects(Project,path,root) "_iniproject.tol" ] |
|---|
| 170 | } else { |
|---|
| 171 | set initol $data(iniproject) |
|---|
| 172 | set iniproject "" |
|---|
| 173 | } |
|---|
| 174 | tol::initlibrary -initproject $initol -defaultpackages $data(defaultpackages) |
|---|
| 175 | if { $iniproject ne "" } { |
|---|
| 176 | # incluyo _iniproject.tol relativo a -project |
|---|
| 177 | tol::include $iniproject |
|---|
| 178 | } |
|---|
| 179 | foreach prj $projects(Project,names) { |
|---|
| 180 | set prjname $projects(${prj},name) |
|---|
| 181 | if { [string length $prjname] } { eval ${prjname}::InitTol } |
|---|
| 182 | } |
|---|
| 183 | #project::event InitTol |
|---|
| 184 | if { [TolConReq] } { |
|---|
| 185 | ::TolInspector::NotBusy |
|---|
| 186 | } |
|---|
| 187 | if { [expr ! $data(oculto)] } { |
|---|
| 188 | splashWindow |
|---|
| 189 | } |
|---|
| 190 | |
|---|
| 191 | set data(init) 1 |
|---|
| 192 | } |
|---|
| 193 | |
|---|
| 194 | |
|---|
| 195 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 196 | proc ::project::initWM { } { |
|---|
| 197 | # |
|---|
| 198 | # PURPOSE: Inits the events & protocols associated to toplevel. |
|---|
| 199 | # |
|---|
| 200 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 201 | variable data |
|---|
| 202 | |
|---|
| 203 | bind . <Map> "::project::mapMain %W" |
|---|
| 204 | bind . <Unmap> "::project::unmapMain %W" |
|---|
| 205 | # establezco los protocolos |
|---|
| 206 | wm protocol . WM_DELETE_WINDOW [list ::project::OnDelete] |
|---|
| 207 | bind . <Destroy> "::project::OnDestroy %W" |
|---|
| 208 | set defgeom "[winfo vrootw .]x[winfo vrooth .]+0+0" |
|---|
| 209 | wm state . normal |
|---|
| 210 | wm geometry . [set geom [::iniFile::Read Project topgeom $defgeom]] |
|---|
| 211 | puts "initWM: geometria: $geom" |
|---|
| 212 | if { [expr $project::data(oculto)] } { |
|---|
| 213 | wm iconify . |
|---|
| 214 | } else { |
|---|
| 215 | wm state . [::iniFile::ReadWMState ::iniFile::Read Project] |
|---|
| 216 | } |
|---|
| 217 | # update in order to . gets the geometry |
|---|
| 218 | update |
|---|
| 219 | showMain |
|---|
| 220 | } |
|---|
| 221 | |
|---|
| 222 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 223 | proc ::project::OnDelete {} { |
|---|
| 224 | # |
|---|
| 225 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 226 | variable data |
|---|
| 227 | |
|---|
| 228 | project::SetKilling |
|---|
| 229 | set answer [tk_messageBox -title [mc "Question"]\ |
|---|
| 230 | -message [mc "Are you sure you want to quit?"] \ |
|---|
| 231 | -type yesno -icon question] |
|---|
| 232 | if { [string compare $answer yes] == 0 } { |
|---|
| 233 | #::TolConsole::Exit |
|---|
| 234 | Exit |
|---|
| 235 | } |
|---|
| 236 | project::SetKilling 0 |
|---|
| 237 | } |
|---|
| 238 | |
|---|
| 239 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 240 | proc ::project::OnDestroy { w } { |
|---|
| 241 | # |
|---|
| 242 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 243 | variable data |
|---|
| 244 | |
|---|
| 245 | if {$w eq "."} { |
|---|
| 246 | ::iniFile::Write Project topgeom $data(geometry,main) |
|---|
| 247 | ::iniFile::Write Project wm,state $data(wm,state) |
|---|
| 248 | ::iniFile::CloseAll |
|---|
| 249 | } |
|---|
| 250 | } |
|---|
| 251 | |
|---|
| 252 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 253 | proc project::Exit { } { |
|---|
| 254 | # |
|---|
| 255 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 256 | variable data |
|---|
| 257 | if {[event Exit] ne "cancel"} { |
|---|
| 258 | update idletasks |
|---|
| 259 | set data(geometry,main) [wm geometry .] |
|---|
| 260 | set data(wm,state) [wm state .] |
|---|
| 261 | destroy . |
|---|
| 262 | } |
|---|
| 263 | } |
|---|
| 264 | |
|---|
| 265 | |
|---|
| 266 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 267 | proc ::project::mapMain { w } { |
|---|
| 268 | # |
|---|
| 269 | # PURPOSE: proc to handle <Map> event, normally it is triggered when the "." |
|---|
| 270 | # window is restored after having being minimized. |
|---|
| 271 | # |
|---|
| 272 | # PARAMETERS: |
|---|
| 273 | # w : |
|---|
| 274 | # |
|---|
| 275 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 276 | variable widgets |
|---|
| 277 | |
|---|
| 278 | if { [string compare $w .] } return |
|---|
| 279 | # restaurar descendientes |
|---|
| 280 | foreach c $widgets(children,saved) { |
|---|
| 281 | mapChild $c |
|---|
| 282 | } |
|---|
| 283 | set widgets(children,saved) "" |
|---|
| 284 | } |
|---|
| 285 | |
|---|
| 286 | |
|---|
| 287 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 288 | proc ::project::unmapMain { w } { |
|---|
| 289 | # |
|---|
| 290 | # PURPOSE: proc to handle <Unmap> event, normally it is triggered when the |
|---|
| 291 | # "." window is minimized. |
|---|
| 292 | # |
|---|
| 293 | # PARAMETERS: |
|---|
| 294 | # w : |
|---|
| 295 | # |
|---|
| 296 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 297 | variable widgets |
|---|
| 298 | |
|---|
| 299 | if { [string compare $w .] } return |
|---|
| 300 | # guardar informacion de descendientes mapeados |
|---|
| 301 | foreach c $widgets(children) { |
|---|
| 302 | if [winfo ismapped $c] { |
|---|
| 303 | lappend widgets(children,saved) $c |
|---|
| 304 | unmapChild $c |
|---|
| 305 | } |
|---|
| 306 | } |
|---|
| 307 | } |
|---|
| 308 | |
|---|
| 309 | |
|---|
| 310 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 311 | proc ::project::UseTolCon { } { |
|---|
| 312 | # |
|---|
| 313 | # PURPOSE: Loads the code for using tolcon. |
|---|
| 314 | # |
|---|
| 315 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 316 | global toltk_script_path |
|---|
| 317 | variable data |
|---|
| 318 | |
|---|
| 319 | set data(tolconreq) 1 |
|---|
| 320 | source [file join $toltk_script_path "tolbase.tcl"] |
|---|
| 321 | } |
|---|
| 322 | |
|---|
| 323 | |
|---|
| 324 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 325 | proc ::project::TolConReq { } { |
|---|
| 326 | # |
|---|
| 327 | # PURPOSE: Tells us if tolcon has being requested (project::UseTolCon). |
|---|
| 328 | # |
|---|
| 329 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 330 | variable data |
|---|
| 331 | |
|---|
| 332 | set data(tolconreq) |
|---|
| 333 | } |
|---|
| 334 | |
|---|
| 335 | |
|---|
| 336 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 337 | proc ::project::load {} { |
|---|
| 338 | # |
|---|
| 339 | # PURPOSE: Loads the given project. Looks for it in $toltk_library/$prj, if |
|---|
| 340 | # it is not found look as in development environment given by the |
|---|
| 341 | # alternative path $path (normally it will be |
|---|
| 342 | # $toltk_libray/../../../../entity) |
|---|
| 343 | # |
|---|
| 344 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 345 | variable data |
|---|
| 346 | variable projects |
|---|
| 347 | foreach prj $projects(Project,names) { |
|---|
| 348 | set prjname $projects(${prj},name) |
|---|
| 349 | if { [string length $prjname] } { |
|---|
| 350 | set init_file \ |
|---|
| 351 | [file join $projects(${prj},path) tcl $projects(${prj},name).tcl] |
|---|
| 352 | if { [file exists $init_file] } { |
|---|
| 353 | source $init_file |
|---|
| 354 | eval $projects(${prj},name)::$projects(${prj},name) |
|---|
| 355 | } else { |
|---|
| 356 | error "could not load project '$projects(${prj},name)': \ |
|---|
| 357 | $projects(${prj},name).tcl not found. $init_file" |
|---|
| 358 | } |
|---|
| 359 | } |
|---|
| 360 | } |
|---|
| 361 | } |
|---|
| 362 | |
|---|
| 363 | |
|---|
| 364 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 365 | proc ::project::OnInitTcl { ev } { |
|---|
| 366 | # |
|---|
| 367 | # PURPOSE: Sets the proc to be invoked after toltk had loaded all its tcl/tk |
|---|
| 368 | # components. |
|---|
| 369 | # |
|---|
| 370 | # PARAMETERS: |
|---|
| 371 | # ev : |
|---|
| 372 | # |
|---|
| 373 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 374 | variable events |
|---|
| 375 | |
|---|
| 376 | set events(OnInitTcl) $ev |
|---|
| 377 | } |
|---|
| 378 | |
|---|
| 379 | |
|---|
| 380 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 381 | proc ::project::OnInitTol { ev } { |
|---|
| 382 | # |
|---|
| 383 | # PURPOSE: Sets the proc to be invoked after toltk had loaded TOL. |
|---|
| 384 | # |
|---|
| 385 | # PARAMETERS: |
|---|
| 386 | # ev : |
|---|
| 387 | # |
|---|
| 388 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 389 | variable events |
|---|
| 390 | |
|---|
| 391 | set events(OnInitTol) $ev |
|---|
| 392 | } |
|---|
| 393 | |
|---|
| 394 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 395 | proc ::project::OnExit { ev } { |
|---|
| 396 | # |
|---|
| 397 | # PURPOSE: Sets the proc to be invoked before exiting. |
|---|
| 398 | # |
|---|
| 399 | # PARAMETERS: |
|---|
| 400 | # ev : |
|---|
| 401 | # |
|---|
| 402 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 403 | variable events |
|---|
| 404 | |
|---|
| 405 | set events(OnExit) $ev |
|---|
| 406 | } |
|---|
| 407 | |
|---|
| 408 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 409 | proc ::project::menu { desc } { |
|---|
| 410 | # |
|---|
| 411 | # PURPOSE: Defines the menu of the toplevel window. For now, the project menu |
|---|
| 412 | # excludes toltk menu. |
|---|
| 413 | # |
|---|
| 414 | # PARAMETERS: |
|---|
| 415 | # desc : |
|---|
| 416 | # |
|---|
| 417 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 418 | variable widgets |
|---|
| 419 | |
|---|
| 420 | prjmenu::create . $desc |
|---|
| 421 | # update |
|---|
| 422 | # set vrootw [winfo vrootw .] |
|---|
| 423 | #wm maxsize . $vrootw 1 |
|---|
| 424 | # wm geometry . [expr ${vrootw}-6]x1+0+0 |
|---|
| 425 | # poner un frame en . de dimension 0x0 y pedir [winfo rootx $f] |
|---|
| 426 | # y asi tener un aproximado de la altura de (main), sumarle 5 o 6. |
|---|
| 427 | # set widgets(dummyframe) [frame .dummy] |
|---|
| 428 | # pack $widgets(dummyframe) |
|---|
| 429 | # showMain |
|---|
| 430 | # wm resizable . 0 0 |
|---|
| 431 | } |
|---|
| 432 | |
|---|
| 433 | |
|---|
| 434 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 435 | proc ::project::showMain { } { |
|---|
| 436 | # |
|---|
| 437 | # PURPOSE: Shows the main window, the one having the menu bar. |
|---|
| 438 | # |
|---|
| 439 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 440 | if { [string equal [wm state .] "withdrawn"] } { |
|---|
| 441 | wm withdraw . |
|---|
| 442 | wm deiconify . |
|---|
| 443 | update |
|---|
| 444 | } |
|---|
| 445 | } |
|---|
| 446 | |
|---|
| 447 | |
|---|
| 448 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 449 | proc ::project::splashWindow { } { |
|---|
| 450 | # |
|---|
| 451 | # PURPOSE: Shows a splash window for the project if it is defined or the one |
|---|
| 452 | # found in images in tolcon. The image to show is splash.gif |
|---|
| 453 | # |
|---|
| 454 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 455 | variable data |
|---|
| 456 | variable projects |
|---|
| 457 | global toltk_library |
|---|
| 458 | |
|---|
| 459 | if { $data(splashed) } return |
|---|
| 460 | set w .__splashw |
|---|
| 461 | if { [winfo exists $w] } { |
|---|
| 462 | image delete [$w.l cget -image] |
|---|
| 463 | destroy $w |
|---|
| 464 | set data(splashed) 1 |
|---|
| 465 | } else { |
|---|
| 466 | set imgfile $projects(Project,splash) |
|---|
| 467 | if { $projects(Project,splash) eq "" } { |
|---|
| 468 | set imgfile [file join $toltk_library toltk images splash.gif] |
|---|
| 469 | } |
|---|
| 470 | if { [file exists $imgfile] } { |
|---|
| 471 | set img [image create photo -file $imgfile] |
|---|
| 472 | toplevel $w |
|---|
| 473 | wm withdraw $w |
|---|
| 474 | wm overrideredirect $w 1 |
|---|
| 475 | label $w.l -image $img -relief ridge -bd 2 |
|---|
| 476 | pack $w.l |
|---|
| 477 | update |
|---|
| 478 | wm geometry $w +[expr ([winfo vrootw .]-[winfo reqwidth $w])/2]+[expr ([winfo vrooth .]-[winfo reqheight $w])/2] |
|---|
| 479 | update |
|---|
| 480 | wm withdraw $w |
|---|
| 481 | wm deiconify $w |
|---|
| 482 | update |
|---|
| 483 | } else { |
|---|
| 484 | set data(splashed) 1 |
|---|
| 485 | } |
|---|
| 486 | } |
|---|
| 487 | } |
|---|
| 488 | |
|---|
| 489 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 490 | proc project::raiseSplash { } { |
|---|
| 491 | # |
|---|
| 492 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 493 | set w .__splashw |
|---|
| 494 | if { [winfo exists $w] } { |
|---|
| 495 | raise $w |
|---|
| 496 | } |
|---|
| 497 | } |
|---|
| 498 | |
|---|
| 499 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 500 | proc ::project::DisableMenu { m e } { |
|---|
| 501 | # |
|---|
| 502 | # PURPOSE: Disables an entry or menu inside a menu. |
|---|
| 503 | # |
|---|
| 504 | # PARAMETERS: |
|---|
| 505 | # m : menu |
|---|
| 506 | # e : entry or menu to disable |
|---|
| 507 | # |
|---|
| 508 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 509 | ::prjmenu::disable . $m $e |
|---|
| 510 | } |
|---|
| 511 | |
|---|
| 512 | |
|---|
| 513 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 514 | proc ::project::EnableMenu { m e } { |
|---|
| 515 | # |
|---|
| 516 | # PURPOSE: Enables an entry or menu inside a menu. |
|---|
| 517 | # |
|---|
| 518 | # PARAMETERS: |
|---|
| 519 | # m : menu |
|---|
| 520 | # e : entry or menu to enable |
|---|
| 521 | # |
|---|
| 522 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 523 | ::prjmenu::enable . $m $e |
|---|
| 524 | } |
|---|
| 525 | |
|---|
| 526 | |
|---|
| 527 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 528 | proc ::project::hasmenu { } { |
|---|
| 529 | # |
|---|
| 530 | # PURPOSE: Tells us if the toplevel has a menu defined. |
|---|
| 531 | # |
|---|
| 532 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 533 | string length [. cget -menu] |
|---|
| 534 | } |
|---|
| 535 | |
|---|
| 536 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 537 | proc ::project::raiseChild { w } { |
|---|
| 538 | # |
|---|
| 539 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 540 | if {[winfo ismapped $w]} { |
|---|
| 541 | raise $w |
|---|
| 542 | } else { |
|---|
| 543 | mapChild $w |
|---|
| 544 | } |
|---|
| 545 | } |
|---|
| 546 | |
|---|
| 547 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 548 | proc ::project::toggleChild { w } { |
|---|
| 549 | # |
|---|
| 550 | # PURPOSE: Changes the state of a registered child. |
|---|
| 551 | # |
|---|
| 552 | # PARAMETERS: |
|---|
| 553 | # w : |
|---|
| 554 | # |
|---|
| 555 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 556 | variable widgets |
|---|
| 557 | |
|---|
| 558 | puts toggleChild |
|---|
| 559 | |
|---|
| 560 | if {[winfo ismapped $w]} { |
|---|
| 561 | #unmapChild $w |
|---|
| 562 | #El usuario suele desmapear minimizando |
|---|
| 563 | #raise $w |
|---|
| 564 | puts "ismapped" |
|---|
| 565 | mapChild $w |
|---|
| 566 | } else { |
|---|
| 567 | mapChild $w |
|---|
| 568 | } |
|---|
| 569 | } |
|---|
| 570 | |
|---|
| 571 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 572 | proc ::project::mapChild { w } { |
|---|
| 573 | # |
|---|
| 574 | # PURPOSE: Map an unmaped & registered child window. The way of unmapping |
|---|
| 575 | # depend on minimizeMode defined. |
|---|
| 576 | # |
|---|
| 577 | # PARAMETERS: |
|---|
| 578 | # w : |
|---|
| 579 | # |
|---|
| 580 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 581 | variable widgets |
|---|
| 582 | if { [string equal [minimizeMode] "withdraw"] } { |
|---|
| 583 | wm withdraw $w |
|---|
| 584 | if ![info exists widgets(child,geometry,$w)] { |
|---|
| 585 | set widgets(child,geometry,$w) 800x600 |
|---|
| 586 | } |
|---|
| 587 | wm geometry $w $widgets(child,geometry,$w) |
|---|
| 588 | } |
|---|
| 589 | wm deiconify $w |
|---|
| 590 | } |
|---|
| 591 | |
|---|
| 592 | |
|---|
| 593 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 594 | proc ::project::unmapChild { w } { |
|---|
| 595 | # |
|---|
| 596 | # PURPOSE: Unmap a maped & registered child window. The way of unmapping |
|---|
| 597 | # depend on minimizeMode defined. |
|---|
| 598 | # |
|---|
| 599 | # PARAMETERS: |
|---|
| 600 | # w : |
|---|
| 601 | # |
|---|
| 602 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 603 | variable data |
|---|
| 604 | variable widgets |
|---|
| 605 | |
|---|
| 606 | set data(minforzed) 1 |
|---|
| 607 | if { [string equal [minimizeMode] "withdraw"] } { |
|---|
| 608 | set widgets(child,geometry,$w) [wm geometry $w] |
|---|
| 609 | wm withdraw $w |
|---|
| 610 | } else { |
|---|
| 611 | wm iconify $w |
|---|
| 612 | } |
|---|
| 613 | } |
|---|
| 614 | |
|---|
| 615 | |
|---|
| 616 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 617 | proc ::project::ExternalBottom { } { |
|---|
| 618 | # |
|---|
| 619 | # PURPOSE: Returns the external bottom y-coordinate of the toplevel window. |
|---|
| 620 | # This is only an approximate value. |
|---|
| 621 | # |
|---|
| 622 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 623 | global tcl_platform |
|---|
| 624 | variable widgets |
|---|
| 625 | |
|---|
| 626 | return [winfo rooty $widgets(mainframe)] |
|---|
| 627 | |
|---|
| 628 | if { [string equal $tcl_platform(platform) "unix"] } { |
|---|
| 629 | set extra 12 |
|---|
| 630 | } else { |
|---|
| 631 | set extra 5 |
|---|
| 632 | } |
|---|
| 633 | expr [winfo rooty $widgets(dummyframe)] + $extra |
|---|
| 634 | } |
|---|
| 635 | |
|---|
| 636 | |
|---|
| 637 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 638 | proc ::project::event { ev } { |
|---|
| 639 | # |
|---|
| 640 | # PURPOSE: Call an event. Valids events are: InitTcl, InitTol, Exit. |
|---|
| 641 | # |
|---|
| 642 | # PARAMETERS: |
|---|
| 643 | # ev : Event to call |
|---|
| 644 | # |
|---|
| 645 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 646 | variable events |
|---|
| 647 | |
|---|
| 648 | if {$events(On$ev) ne ""} { |
|---|
| 649 | eval $events(On$ev) |
|---|
| 650 | } |
|---|
| 651 | } |
|---|
| 652 | |
|---|
| 653 | |
|---|
| 654 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 655 | proc ::project::SetKilling {{what 1}} { |
|---|
| 656 | # |
|---|
| 657 | # PURPOSE: Signal the killing of the whole aplication. That way when the rest |
|---|
| 658 | # of its children know they should destroy in case the have provide |
|---|
| 659 | # WM_DELETE_WINDOW protocol. |
|---|
| 660 | # |
|---|
| 661 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 662 | variable data |
|---|
| 663 | set data(killing) $what |
|---|
| 664 | } |
|---|
| 665 | |
|---|
| 666 | |
|---|
| 667 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 668 | proc ::project::IsKilling { } { |
|---|
| 669 | # |
|---|
| 670 | # PURPOSE: Returns if Is the application destroying? |
|---|
| 671 | # |
|---|
| 672 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 673 | variable data |
|---|
| 674 | |
|---|
| 675 | set data(killing) |
|---|
| 676 | } |
|---|
| 677 | |
|---|
| 678 | |
|---|
| 679 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 680 | proc ::project::minimizeMode { args } { |
|---|
| 681 | # |
|---|
| 682 | # PURPOSE: sets/returns the minimize mode, could be: |
|---|
| 683 | # - withdraw |
|---|
| 684 | # - minimize |
|---|
| 685 | # |
|---|
| 686 | # PARAMETERS: |
|---|
| 687 | # args : |
|---|
| 688 | # |
|---|
| 689 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 690 | variable data |
|---|
| 691 | |
|---|
| 692 | switch [llength $args] { |
|---|
| 693 | 0 { set data(minmode) } |
|---|
| 694 | 1 { set data(minmode) [lindex $args 0] } |
|---|
| 695 | default { error "wrong # args: '$args'" } |
|---|
| 696 | } |
|---|
| 697 | } |
|---|
| 698 | |
|---|
| 699 | |
|---|
| 700 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 701 | proc ::project::postWindows { m } { |
|---|
| 702 | # |
|---|
| 703 | # PURPOSE: Proc to call when the menu Window is about to post. |
|---|
| 704 | # |
|---|
| 705 | # PARAMETERS: |
|---|
| 706 | # m : is the menu where to insert the entries. At least there will be one: |
|---|
| 707 | # "Tol Inspector". |
|---|
| 708 | # |
|---|
| 709 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 710 | variable widgets |
|---|
| 711 | |
|---|
| 712 | $m delete 0 end |
|---|
| 713 | foreach subm [winfo children $m] { |
|---|
| 714 | $subm delete 0 end |
|---|
| 715 | } |
|---|
| 716 | $m add command -label [mc "Minimize all"] -command "::project::minimizeAll" |
|---|
| 717 | $m add command -label [mc "Cascade"] -command "::project::cascade" |
|---|
| 718 | $m add command -label [mc "Tile Horizontal"] -command "::project::tileHorizontal" |
|---|
| 719 | $m add command -label [mc "Tile Vertical"] -command "::project::tileVertical" |
|---|
| 720 | $m add separator |
|---|
| 721 | foreach w $widgets(children,type,default) { |
|---|
| 722 | $m add command \ |
|---|
| 723 | -label $widgets(child,label,$w) -command "::project::raiseChild $w" |
|---|
| 724 | } |
|---|
| 725 | foreach t $widgets(children,types) { |
|---|
| 726 | if { [string compare $t "default"] } { |
|---|
| 727 | set subm $m.m[join $t _] |
|---|
| 728 | if { ![winfo exists $subm] } { |
|---|
| 729 | ::menu $subm -tearoff 0 |
|---|
| 730 | } |
|---|
| 731 | $m add cascade -label [mc $t] -menu $subm |
|---|
| 732 | foreach w $widgets(children,type,$t) { |
|---|
| 733 | $subm add command \ |
|---|
| 734 | -label $widgets(child,label,$w) -command "::project::raiseChild $w" |
|---|
| 735 | } |
|---|
| 736 | $subm add separator |
|---|
| 737 | $subm add command -label [mc "Close all"]\ |
|---|
| 738 | -command [list ::project::closeType $t] |
|---|
| 739 | } |
|---|
| 740 | } |
|---|
| 741 | } |
|---|
| 742 | |
|---|
| 743 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 744 | proc ::project::closeType {type} { |
|---|
| 745 | # |
|---|
| 746 | # PURPOSE: Closes all windows of a specified type |
|---|
| 747 | # |
|---|
| 748 | # PARAMETERS: |
|---|
| 749 | # type: Type of windows we want to close |
|---|
| 750 | # |
|---|
| 751 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 752 | variable widgets |
|---|
| 753 | |
|---|
| 754 | foreach d [lindex [$widgets(mainmdi) get_documents $type] 1] { |
|---|
| 755 | $d kill |
|---|
| 756 | } |
|---|
| 757 | } |
|---|
| 758 | |
|---|
| 759 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 760 | proc ::project::registerChild { w args } { |
|---|
| 761 | # |
|---|
| 762 | # PURPOSE: registers a toplevel to be handled by window menu |
|---|
| 763 | # |
|---|
| 764 | # PARAMETERS: |
|---|
| 765 | # w: |
|---|
| 766 | # args: |
|---|
| 767 | # |
|---|
| 768 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 769 | variable widgets |
|---|
| 770 | |
|---|
| 771 | if { [string compare [winfo toplevel $w] $w] } { |
|---|
| 772 | error "$w must be a toplevel" |
|---|
| 773 | } |
|---|
| 774 | array set options { |
|---|
| 775 | -type default |
|---|
| 776 | -killmode kill |
|---|
| 777 | } |
|---|
| 778 | set options(-label) [wm title $w] |
|---|
| 779 | # override defaults options |
|---|
| 780 | array set options $args |
|---|
| 781 | if { [lsearch $widgets(children) $w] != -1} { |
|---|
| 782 | error "window $w is already registered" |
|---|
| 783 | } |
|---|
| 784 | if { [info exists options(-varlabel)] } { |
|---|
| 785 | set varlabel $options(-varlabel) |
|---|
| 786 | upvar \#0 $varlabel label |
|---|
| 787 | trace variable $options(-varlabel) w \ |
|---|
| 788 | "::project::updateWindowDesc $w $varlabel; #" |
|---|
| 789 | set options(-label) $label |
|---|
| 790 | } |
|---|
| 791 | lappend widgets(children) $w |
|---|
| 792 | if { [lsearch $widgets(children,types) $options(-type)] == -1 } { |
|---|
| 793 | lappend widgets(children,types) $options(-type) |
|---|
| 794 | } |
|---|
| 795 | lappend widgets(children,type,$options(-type)) $w |
|---|
| 796 | set widgets(child,type,$w) $options(-type) |
|---|
| 797 | set widgets(child,killmode,$w) $options(-killmode) |
|---|
| 798 | set widgets(child,label,$w) $options(-label) |
|---|
| 799 | if { [string equal $options(-killmode) "hide"] } { |
|---|
| 800 | wm protocol $w WM_DELETE_WINDOW [list ::project::minimizeChild $w $w] |
|---|
| 801 | } |
|---|
| 802 | bind $w <Destroy> +[list ::project::deleteChildren %W $w] |
|---|
| 803 | bind $w <Unmap> "::project::minimizeChild %W $w" |
|---|
| 804 | } |
|---|
| 805 | |
|---|
| 806 | |
|---|
| 807 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 808 | proc ::project::updateWindowDesc { w varlabel } { |
|---|
| 809 | # |
|---|
| 810 | # PURPOSE: |
|---|
| 811 | # |
|---|
| 812 | # PARAMETERS: |
|---|
| 813 | # w : |
|---|
| 814 | # varlabel : |
|---|
| 815 | # |
|---|
| 816 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 817 | upvar \#0 $varlabel label |
|---|
| 818 | variable widgets |
|---|
| 819 | |
|---|
| 820 | set widgets(child,label,$w) $label |
|---|
| 821 | } |
|---|
| 822 | |
|---|
| 823 | |
|---|
| 824 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 825 | proc ::project::minimizeAll {} { |
|---|
| 826 | # |
|---|
| 827 | # PURPOSE: Minimizes all windows |
|---|
| 828 | # |
|---|
| 829 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 830 | variable widgets |
|---|
| 831 | foreach c $widgets(children) { |
|---|
| 832 | unmapChild $c |
|---|
| 833 | } |
|---|
| 834 | } |
|---|
| 835 | |
|---|
| 836 | |
|---|
| 837 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 838 | proc ::project::cascade {} { |
|---|
| 839 | # |
|---|
| 840 | # PURPOSE: |
|---|
| 841 | # |
|---|
| 842 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 843 | variable widgets |
|---|
| 844 | set x 0 |
|---|
| 845 | set y [ExternalBottom] |
|---|
| 846 | foreach c $widgets(children) { |
|---|
| 847 | wm geometry $c +$x+$y |
|---|
| 848 | mapChild $c |
|---|
| 849 | incr x 20 |
|---|
| 850 | incr y 20 |
|---|
| 851 | } |
|---|
| 852 | } |
|---|
| 853 | |
|---|
| 854 | |
|---|
| 855 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 856 | proc ::project::tileHorizontal {} { |
|---|
| 857 | # |
|---|
| 858 | # PURPOSE: |
|---|
| 859 | # |
|---|
| 860 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 861 | variable widgets |
|---|
| 862 | set widgets(children,tileVer) {} |
|---|
| 863 | foreach c $widgets(children) { |
|---|
| 864 | if [winfo ismapped $c] { |
|---|
| 865 | lappend widgets(children,tileVer) $c |
|---|
| 866 | } |
|---|
| 867 | } |
|---|
| 868 | set num [llength $widgets(children,tileVer)] |
|---|
| 869 | set y [ExternalBottom] |
|---|
| 870 | set tWidth [winfo vrootwidth .] |
|---|
| 871 | set tHeight [expr [winfo vrootheight .] - $y - 30] |
|---|
| 872 | |
|---|
| 873 | if $num { |
|---|
| 874 | set height [expr ($tHeight/$num)-6] |
|---|
| 875 | } |
|---|
| 876 | |
|---|
| 877 | foreach c $widgets(children,tileVer) { |
|---|
| 878 | wm geometry $c ${tWidth}x${height}+0+$y |
|---|
| 879 | incr y [expr $height + 6] |
|---|
| 880 | } |
|---|
| 881 | } |
|---|
| 882 | |
|---|
| 883 | |
|---|
| 884 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 885 | proc ::project::tileVertical {} { |
|---|
| 886 | # |
|---|
| 887 | # PURPOSE: |
|---|
| 888 | # |
|---|
| 889 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 890 | variable widgets |
|---|
| 891 | set widgets(children,tileHor) {} |
|---|
| 892 | foreach c $widgets(children) { |
|---|
| 893 | if [winfo ismapped $c] { |
|---|
| 894 | lappend widgets(children,tileHor) $c |
|---|
| 895 | } |
|---|
| 896 | } |
|---|
| 897 | set num [llength $widgets(children,tileHor)] |
|---|
| 898 | set x 0 |
|---|
| 899 | set y [ExternalBottom] |
|---|
| 900 | set tWidth [winfo vrootwidth .] |
|---|
| 901 | set tHeight [expr [winfo vrootheight .] - $y - 30] |
|---|
| 902 | |
|---|
| 903 | if $num { |
|---|
| 904 | set width [expr ($tWidth/$num)-6] |
|---|
| 905 | } |
|---|
| 906 | foreach c $widgets(children,tileHor) { |
|---|
| 907 | wm geometry $c ${width}x${tHeight}+$x+$y |
|---|
| 908 | incr x [expr $width + 6] |
|---|
| 909 | } |
|---|
| 910 | #Tolcon_Trace "tWidth: $tWidth, tHeight: $tHeight, mapped: $num, width: $width, x: $x, y: $y" |
|---|
| 911 | } |
|---|
| 912 | |
|---|
| 913 | |
|---|
| 914 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 915 | proc ::project::minimizeChild { w _w } { |
|---|
| 916 | # |
|---|
| 917 | # PURPOSE: This is invoked when w == _w is going to be minimized. Actually it |
|---|
| 918 | # is invoked for all of it's descendents. |
|---|
| 919 | # |
|---|
| 920 | # PARAMETERS: |
|---|
| 921 | # w : |
|---|
| 922 | # _w : |
|---|
| 923 | # |
|---|
| 924 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 925 | variable data |
|---|
| 926 | variable widgets |
|---|
| 927 | |
|---|
| 928 | if { [string compare $w $_w] } return |
|---|
| 929 | if { $data(minforzed) } { |
|---|
| 930 | set data(minforzed) 0 |
|---|
| 931 | return |
|---|
| 932 | } |
|---|
| 933 | if { [string equal [minimizeMode] "withdraw"] } { |
|---|
| 934 | set widgets(child,geometry,$w) [wm geometry $w] |
|---|
| 935 | wm withdraw $w |
|---|
| 936 | } |
|---|
| 937 | } |
|---|
| 938 | |
|---|
| 939 | |
|---|
| 940 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 941 | proc ::project::deleteChildren { w _w } { |
|---|
| 942 | # |
|---|
| 943 | # PURPOSE: handler to delete a child window registred by registerChild |
|---|
| 944 | # |
|---|
| 945 | # PARAMETERS: |
|---|
| 946 | # w : |
|---|
| 947 | # _w : |
|---|
| 948 | # |
|---|
| 949 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 950 | variable widgets |
|---|
| 951 | if { [string compare $w $_w] } return |
|---|
| 952 | if { [string equal $widgets(child,killmode,$w) kill] } { |
|---|
| 953 | # unregister $w |
|---|
| 954 | blremove widgets(children) $w |
|---|
| 955 | set type $widgets(child,type,$w) |
|---|
| 956 | blremove widgets(children,type,$type) $w |
|---|
| 957 | unset widgets(child,type,$w) |
|---|
| 958 | set type_found 0 |
|---|
| 959 | foreach i [array names widgets child,type,*] { |
|---|
| 960 | if {[string equal $type $widgets($i)]} { |
|---|
| 961 | set type_found 1 |
|---|
| 962 | break |
|---|
| 963 | } |
|---|
| 964 | } |
|---|
| 965 | if { !$type_found } { |
|---|
| 966 | blremove widgets(children,types) $type |
|---|
| 967 | } |
|---|
| 968 | unset widgets(child,killmode,$w) |
|---|
| 969 | unset widgets(child,label,$w) |
|---|
| 970 | # kill $w as requested in registerChild |
|---|
| 971 | #destroy $w |
|---|
| 972 | } else { |
|---|
| 973 | if { [IsKilling] } { |
|---|
| 974 | # . is going down |
|---|
| 975 | # destroy $w |
|---|
| 976 | } else { |
|---|
| 977 | if { [string equal [minimizeMode] "withdraw"] } { |
|---|
| 978 | set widgets(child,geometry,$w) [wm geometry $w] |
|---|
| 979 | wm withdraw $w |
|---|
| 980 | } else { |
|---|
| 981 | wm iconify $w |
|---|
| 982 | } |
|---|
| 983 | } |
|---|
| 984 | } |
|---|
| 985 | } |
|---|
| 986 | |
|---|
| 987 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 988 | proc ::project::CreateForm {args} { |
|---|
| 989 | # |
|---|
| 990 | # PURPOSE: Create form |
|---|
| 991 | # |
|---|
| 992 | # PARAMETERS: |
|---|
| 993 | # args : option-value pairs |
|---|
| 994 | # |
|---|
| 995 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 996 | variable widgets |
|---|
| 997 | # Default |
|---|
| 998 | |
|---|
| 999 | #set path {} |
|---|
| 1000 | array set opts [list \ |
|---|
| 1001 | -height 300 \ |
|---|
| 1002 | -width 300 \ |
|---|
| 1003 | -title {} \ |
|---|
| 1004 | -closecmd {} \ |
|---|
| 1005 | -iniconfig {} \ |
|---|
| 1006 | -type {} \ |
|---|
| 1007 | -unique 0 \ |
|---|
| 1008 | -modal 0 \ |
|---|
| 1009 | -x 0 \ |
|---|
| 1010 | -y 0 \ |
|---|
| 1011 | -state normal \ |
|---|
| 1012 | -resizable 1 \ |
|---|
| 1013 | -helpkey "Tb4Mai" |
|---|
| 1014 | ] |
|---|
| 1015 | |
|---|
| 1016 | array set opts $args |
|---|
| 1017 | |
|---|
| 1018 | if {([info exist opts(-geometry)]) && ([string length $opts(-geometry)])} { |
|---|
| 1019 | set opts(-state) normal |
|---|
| 1020 | set opts(-width) [lindex [split $opts(-geometry) x] 0] |
|---|
| 1021 | set restgeom [lindex [split $opts(-geometry) x] 1] |
|---|
| 1022 | set opts(-height) [lindex [split $restgeom +] 0] |
|---|
| 1023 | set opts(-x) [lindex [split $restgeom +] 1] |
|---|
| 1024 | set opts(-y) [lindex [split $restgeom +] 2] |
|---|
| 1025 | } |
|---|
| 1026 | #puts "Nombre: $w Lista: \n\ [array get opts]" |
|---|
| 1027 | set path [.main.mdi slave -title $opts(-title) -type $opts(-type) \ |
|---|
| 1028 | -width $opts(-width) -height $opts(-height) -modal $opts(-modal) \ |
|---|
| 1029 | -closecmd $opts(-closecmd) -iniconfig $opts(-iniconfig) \ |
|---|
| 1030 | -resizable $opts(-resizable) -x $opts(-x) -y $opts(-y) \ |
|---|
| 1031 | -state $opts(-state) -helpkey $opts(-helpkey) ] |
|---|
| 1032 | update |
|---|
| 1033 | return $path |
|---|
| 1034 | } |
|---|
| 1035 | |
|---|
| 1036 | |
|---|
| 1037 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1038 | proc ::project::SelectDoc { dw } { |
|---|
| 1039 | # |
|---|
| 1040 | # PURPOSE: selects a mdi document |
|---|
| 1041 | # |
|---|
| 1042 | # PARAMTERS: |
|---|
| 1043 | # dw: the document window to select |
|---|
| 1044 | # |
|---|
| 1045 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1046 | if { ([$dw cget -state] eq "minimized" ) || |
|---|
| 1047 | ([$dw cget -state] eq "withdrawn") } { |
|---|
| 1048 | $dw restore |
|---|
| 1049 | } else { |
|---|
| 1050 | $dw raise |
|---|
| 1051 | } |
|---|
| 1052 | } |
|---|
| 1053 | |
|---|
| 1054 | |
|---|
| 1055 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1056 | proc ::project::FillWindowMenu {mdi m} { |
|---|
| 1057 | # |
|---|
| 1058 | # PURPOSE: Rellena el menu window |
|---|
| 1059 | # |
|---|
| 1060 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1061 | |
|---|
| 1062 | $m delete 0 end |
|---|
| 1063 | foreach cw [winfo children $m] { |
|---|
| 1064 | destroy $cw |
|---|
| 1065 | } |
|---|
| 1066 | $m add command -label [mc "Tile across"] -underline 0 -command "$mdi arrange tile" |
|---|
| 1067 | $m add command -label [mc "Tile horizontally"] -underline 5 \ |
|---|
| 1068 | -command "$mdi arrange hor" |
|---|
| 1069 | $m add command -label [mc "Tile vertically"] -underline 5 -command "$mdi arrange ver" |
|---|
| 1070 | $m add command -label [mc "Cascade"] -underline 0 -command "$mdi arrange cascade" |
|---|
| 1071 | $m add separator |
|---|
| 1072 | $m add command -label [mc "Arrange icons"] -underline 0 -command "$mdi arrange icons" |
|---|
| 1073 | $m add command -label [mc "Minimize all"] -underline 0 -command "$mdi arrange min" |
|---|
| 1074 | foreach t [$mdi get_types] { |
|---|
| 1075 | $m add cascade -label $t -menu $m.sub$t |
|---|
| 1076 | ::menu $m.sub$t -tearoff 0 |
|---|
| 1077 | foreach d [lindex [$mdi get_documents $t] 1] { |
|---|
| 1078 | if {[$d cget -state] != "withdrawn"} { |
|---|
| 1079 | $m.sub$t add command -label [$d cget -title] -command "::project::SelectDoc $d " |
|---|
| 1080 | } |
|---|
| 1081 | } |
|---|
| 1082 | $m.sub$t add separator |
|---|
| 1083 | $m.sub$t add command -label [mc "Close all"] \ |
|---|
| 1084 | -command [list ::project::closeType $t] |
|---|
| 1085 | } |
|---|
| 1086 | foreach d [lindex [$mdi get_documents {}] 1] { |
|---|
| 1087 | if {[$d cget -state] != "withdrawn"} { |
|---|
| 1088 | $m add command -label [$d cget -title] -command "::project::SelectDoc $d" |
|---|
| 1089 | } |
|---|
| 1090 | } |
|---|
| 1091 | if {[$m index end] > 6} { |
|---|
| 1092 | $m insert 7 separator |
|---|
| 1093 | } |
|---|
| 1094 | } |
|---|
| 1095 | |
|---|
| 1096 | |
|---|
| 1097 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1098 | proc ::project::CreateMdiMenu { mdi } { |
|---|
| 1099 | # |
|---|
| 1100 | # PURPOSE: Crea un menu para mdi con las entradas basicas ayuda y ventanas |
|---|
| 1101 | # |
|---|
| 1102 | #///////////////////////////////////////////////////////////////////////////// |
|---|
| 1103 | set md [menudef create %AUTO%] |
|---|
| 1104 | |
|---|
| 1105 | set id [$md add root cascade -label [mc &Window] \ |
|---|
| 1106 | -postcommand [list ::project::FillWindowMenu $mdi %W]] |
|---|
| 1107 | set ::project::data(menuhook) $id |
|---|
| 1108 | $md add root separator |
|---|
| 1109 | |
|---|
| 1110 | set id [$md add root cascade -label [mc &Help]] |
|---|
| 1111 | set ::project::data(menuhookhelp) $id |
|---|
| 1112 | |
|---|
| 1113 | $md add $id command -label [mc "&About"]... \ |
|---|
| 1114 | -command "::TolConsole::AboutShow" |
|---|
| 1115 | $md add $id command -label [mc "&TolBase"] \ |
|---|
| 1116 | -command "::TolConsole::TolBaseHelp" |
|---|
| 1117 | mdimenu .mainmenu -definition $md |
|---|
| 1118 | return .mainmenu |
|---|
| 1119 | } |
|---|