source: tol/tolbase/lib/toltk/tolbase.tcl @ 6d7779d

1941-docker-image-to-testdevel
Last change on this file since 6d7779d was 6d7779d, checked in by Jorge Pérez <josp.jorge@…>, 18 years ago

initial import

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@1 be4846ae-f051-483a-831f-b64e7d08527f

  • Property mode set to 100644
File size: 80.8 KB
RevLine 
[6d7779d]1#/////////////////////////////////////////////////////////////////////////////
2# FILE    : tolbase.tcl
3# PURPOSE : This file
4#/////////////////////////////////////////////////////////////////////////////
5
6#/////////////////////////////////////////////////////////////////////////////
7
8if { 0 } {
9# 
10#/////////////////////////////////////////////////////////////////////////////       
11  set toltk_script_path [file dirname [info script]]
12 
13  puts $toltk_script_path
14   
15  if { [lsearch $auto_path $toltk_library] == -1 } {
16    lappend auto_path $toltk_library
17  }
18  if { ![info exists blt_libPath] } {
19    set blt_libPath [file join $toltk_library blt]
20  }
21  if { ![info exists env(BLT_LIBRARY)] } {
22    set env(BLT_LIBRARY) [file join $toltk_library blt]
23  }
24  package require BWidget
25 
26  source [file join $toltk_script_path "prjmenu.tcl"]
27  source [file join $toltk_script_path "tolinspect.tcl"]
28  source [file join $toltk_script_path "toltable.tcl"]
29  source [file join $toltk_script_path "calendar.tcl"]
30  source [file join $toltk_script_path "editSelector.tcl"]
31  source [file join $toltk_script_path "selector.tcl"]
32  source [file join $toltk_script_path "bayesgraph.tcl"]
33  source [file join $toltk_script_path "sergraph.tcl"]
34  source [file join $toltk_script_path "autocorgraph.tcl"]
35  source [file join $toltk_script_path "graph.tcl"]
36  source [file join $toltk_script_path "BfString.tcl"]
37  source [file join $toltk_script_path "BfList.tcl"]
38  source [file join $toltk_script_path "newButtonDiag2.tcl"]
39  source [file join $toltk_script_path "newToolbarDiag.tcl"]
40} else {
41    if {$::tcl_platform(platform) eq "unix"} {
42        proc ::dnd {args} {}
43    } else {
44        package require tkdnd
45        source [file join $toltk_script_path "newButtonDiag2.tcl"]
46        source [file join $toltk_script_path "newToolbarDiag.tcl"]
47    }
48}
49
50global tcl_platform
51if { [string equal $tcl_platform(platform) "unix"] } {
52  source [file join $toltk_script_path "panedw.tcl"]
53} else {
54  source [file join $toltk_script_path "panedw.tcl"]
55}
56
57#source [file join $toltk_script_path "scrollw.tcl"]
58
59namespace eval ::TolConsole {
60  # widgets -> array with entries:
61  #   inspector -> toplevel containing inspector and tabs of info.
62  #   tabset    -> tabset containing: eval, output & info.
63  #   eval      -> text for evaluating.
64  #   output    -> text with the output.
65  #   info      -> text with info on inspector objects.
66  # data -> array with entries:
67  #   (path) -> directory of the last included file
68  #   (included) -> last included files
69  #   (font,eval)
70  #   (font,output)
71  #   (font,info)
72  #   (viewmode)
73  variable data
74  variable widgets
75  variable time     [clock clicks -milliseconds]
76  variable languages [list de German en English es Spanish fr French \
77    it Italian ja Japanese nl Dutch po Portuguese ru Russian sv Swedish \
78    zh Chinese]
79}
80
81
82#/////////////////////////////////////////////////////////////////////////////
83proc ::TolConsole::Create { w } {
84#
85# PURPOSE: Creates TolBase main windows (tol inspector + eval/output/info
86#          windows)
87# PARAMTERS:
88#  w: path of father the widget inspector
89#  name: name of widget inspector
90#
91# RETURN: path of widget inspector
92#
93#/////////////////////////////////////////////////////////////////////////////
94  variable widgets
95  variable data
96
97  # connection BODBC
98  set data(bodbc) [$::project::data(bodbc) connection \
99                     -name TolBase \
100                     -stdtolcon 1  \
101                     -stdtclcon 0  \
102                     -iniconfig TolBaseODBC \
103                     -savealias 1  \
104                     -saveuser  1]
105  Tolcon_Trace "TolConsole.Create : data(bodbc)=$data(bodbc)"
106
107  #Control de modo de visualizacion
108  #Frame
109
110  set path [::project::CreateForm \
111              -iniconfig ObjectInspector \
112              -title [mc {Inspector}] -width 700 -height 400 \
113              -helpkey "Tb4Ins"]
114  $path configure -closecmd "$path minimize; return 0"
115  set pathf [$path getframe]
116                                           
117  set pw1   [PanedWindow $pathf.pw -side right -pad 0 -width 4]
118  set pane1 [$pw1 add -weight $data(geometry,wtop)]
119  set pane2 [$pw1 add -weight $data(geometry,wbottom)]
120
121#  set widgets(pw)           $path
122  set widgets(pw)           $pw1
123  set widgets(panes,top)    $pane1
124  set widgets(panes,bottom) $pane2
125  # object inspector component
126
127  ::TolInspector::Create $pane1.ti \
128      -onselcmd ::TolConsole::OnInfo \
129      -wleft $data(geometry,wleft) \
130      -wright $data(geometry,wright)
131
132  ::TolInspector::OnBusy ::TolConsole::OnBusy
133
134  # tabset for eval, output & description
135  set widgets(tabset) $pane2.ts
136  set w_tabset [::blt::tabset $widgets(tabset) -side top -relief flat \
137                    -bd 0 -outerpad 0 -tier 2 -slant right -textside right \
138                    -highlightthickness 0]
139  set sw2 [ScrolledWindow $w_tabset.sw2 -auto both]
140  set sw3 [ScrolledWindow $w_tabset.sw3 -auto both]
141   
142  $w_tabset insert end \
143     Eval   -text "[mc Eval]   <Ctrl+A>" -selectbackground \#d9d9d9 -bg gray75 -pady 0\
144     Output -text "[mc Output] <Ctrl+O>" -selectbackground \#d9d9d9 -bg gray75 -pady 0\
145     Info   -text "[mc Info]   <Ctrl+I>" -selectbackground \#d9d9d9 -bg gray75 -pady 0
146
147  # OUTPUT CONSOLE COMPONENT 
148  set widgets(output) $sw2.out
149  set w_output [text $widgets(output) -wrap none -cursor ""\
150     -state disabled -font $data(font,output)]
151  $sw2 setwidget $w_output
152
153  # EVAL CONSOLE COMPONENT     
154  set feval $w_tabset.f 
155  CreateEvalWindow $feval
156
157  # configuro los mensajes del output
158  $w_output tag configure errorTag   -foreground $data(colorErr)
159  $w_output tag configure warningTag -foreground $data(colorWar)
160  set data(output,TAG,E) errorTag
161  set data(output,TAG,W) warningTag
162
163  set menu [::BayesText::MenuCreate $w_output]
164  # Añadimos la opción de recuperar la salida
165  $menu insert 0 separator
166  $menu insert 0 command -label [mc "Recover from log"] \
167                  -command [list ::TolConsole::Recover $w_output]
168  $menu insert 0 command -label [mc "Delete all"] \
169                  -command [list ::BayesText::DeleteAll $w_output]
170
171  # Habilitamos la opción de borrar
172  $menu entryconfigure [mc "Delete"] -state normal
173  bind $w_output <Delete>    [list ::BayesText::Delete $w_output]
174     
175  # INFO CONSOLE COMPONENT
176  set widgets(info) $sw3.info
177  set w_info [text $widgets(info) -wrap word -cursor ""\
178     -state disabled -font $data(font,info)]
179  $sw3 setwidget $w_info
180  ::BayesText::MenuCreate $w_info
181   
182  set def_font [$w_info cget -font]
183  if { [lsearch -exact [font names] fnBold] == -1 } {
184    if {[string length [lindex $def_font 1]]} {
185      font create fnBold -family [lindex $def_font 0] \
186            -size [lindex $def_font 1] -weight bold
187    } else {
188       font create fnBold -family [lindex $def_font 0] -size 10 -weight bold
189    }
190  }
191
192  # teclas acceso rapido solapas de Informacion
193  $path bind <Control-F4> +[list $path kill]
194 
195  bind $path <Control-KeyRelease> \
196      +[list ::TolConsole::OnControlKey %K %k]
197  $w_tabset tab configure Eval   -window $feval -fill both -padx 0
198  $w_tabset tab configure Output -window $sw2   -fill both -padx 0
199  $w_tabset tab configure Info   -window $sw3   -fill both -padx 0
200  pack $w_tabset -fill both -expand yes
201   
202  pack $pw1 -fill both -expand yes   
203  Configure
204 
205  bind . <Control-Key-k> +::tol::stop
206  bind Text <Control-Key-k> ""
207  return $path
208}
209
210#/////////////////////////////////////////////////////////////////////////////
211proc ::TolConsole::CreateEvalWindow {w} {
212#
213# PURPOSE: Creates eval window as widget w
214#
215#/////////////////////////////////////////////////////////////////////////////
216  variable widgets
217  variable data
218
219  set feval   [frame $w]
220  set sw1 [ScrolledWindow $feval.sw1 -auto both]
221  set widgets(eval) $sw1.eval
222
223  #Creamos text con resaltado TOL
224  set w_eval [::BayesText::CreateHLText $widgets(eval) tol \
225    -font $data(font,eval)]
226
227  set m [::BayesText::MenuCreate $w_eval]
228  # Añadimos la opcion de refrescar el resaltado en la ventana eval
229  $m insert 0 separator
230  $m insert 0 command -label [mc Refresh]   -accelerator F5\
231     -command [list ::BayesText::Refresh $w_eval]
232  $m insert 0 command -label [mc "Syntax Check"] -accelerator F7 \
233     -command [list ::BayesText::TolSyntaxCheck $w_eval]
234  $m insert 0 command -label [mc Decompile] -accelerator F8\
235     -command ::TolConsole::ClearConsole
236  $m insert 0 command -label [mc Compile]   -accelerator F9\
237     -command ::TolConsole::Compile
238
239  # Añadimos la opción de limpiar la ventana de eval
240  $m insert 0 separator
241  $m insert 0 command -label [mc "Delete all"] \
242     -command [list ::BayesText::DeleteAll $w_eval]
243  bind $w_eval <F9> "::TolConsole::Compile ; break"
244  bind $w_eval <F8> "::TolConsole::ClearConsole ; break"
245  bind $w_eval <F5> "::BayesText::Refresh $w_eval ; break"
246  bind $w_eval <F7> "::BayesText::TolSyntaxCheck $w_eval ; break"
247  bind $w_eval <F10> "::TolConsole::OpenEval ; break"
248 
249  ## 1) Create a horizontal toolbar frame...
250  set TF [::toolbar::ToolbarFrame $feval.toolbarFrame]
251    ## 2) Create a toolbar in this toolbar frame...
252    set tb1 [::toolbar::create $TF.tb1]
253    # add compile button
254    ::toolbar::addbutton $tb1 -image [::Bitmap::get "eval"] \
255      -statuswidget $widgets(sb,path) -tooltip "[mc Compile] (F9)"\
256      -command [list ::TolConsole::Compile]
257    # add decompile button
258    ::toolbar::addbutton $tb1 -image [::Bitmap::get "decom"] \
259      -statuswidget $widgets(sb,path) -tooltip "[mc Decompile] (F8)"\
260      -command [list ::TolConsole::ClearConsole]
261    # add syntax check button
262    ::toolbar::addbutton $tb1 -image [::Bitmap::get "syntaxcheck"] \
263      -statuswidget $widgets(sb,path) -tooltip "[mc Syntax Check] (F7)"\
264      -command [list ::BayesText::TolSyntaxCheck $w_eval]
265    #add Refresh button
266    ::toolbar::addbutton $tb1 -image [::Bitmap::get "refresh"] \
267      -statuswidget $widgets(sb,path) -tooltip "[mc Refresh] (F5)"\
268      -command [list ::BayesText::Refresh $w_eval]
269    #add History button
270    ::toolbar::addbutton $tb1 -image [::Bitmap::get "History"] \
271      -statuswidget $widgets(sb,path) -tooltip "[mc "Show history file"] (F10)"\
272      -command [list ::TolConsole::OpenEval]
273
274    ::toolbar::addseparator $tb1
275
276    ::toolbar::addbutton $tb1 -image [::Bitmap::get "delete"] \
277      -statuswidget $widgets(sb,path) \
278      -tooltip [mc "Delete all the messages of the window of output"] \
279      -command [list ::BayesText::DeleteAll $widgets(output)]
280
281    ## 4) Pack the toolbar inside the toolbar frame...
282    pack $tb1 -side left -fill y
283
284  ## 5) Pack the toolbar frame in our window...
285
286  # Si empacabamos la barra de botones debajo del editor de la ventana eval,
287  # cuando la ventana de Eval se hacía pequeña, la barra botones desaparecía
288  # Con la opción -before se evita esto
289
290  pack $sw1 -expand true -fill both -padx 0 -pady 0
291  pack $TF  -side top -fill both -padx 0 -pady 0 -before $sw1
292
293  $sw1 setwidget $w_eval
294}
295
296
297#/////////////////////////////////////////////////////////////////////////////
298proc ::TolConsole::OnControlKey {keysym keycode} {
299#
300# PURPOSE: Controla es uso de teclas rápidas para le ejecución de funciones
301#
302# PARAMETERS: keysym -> The keysym corresponding to the event,
303#                       substituted as a textual string
304#             keycode -> The keycode field from the event
305#
306#///////////////////////////////////////////////////////////////////////////
307  variable widgets
308  switch [string toupper $keysym] {
309    A { ShowWindow "eval"   }
310    O { ShowWindow "output" }
311    I { ShowWindow "info"   }
312  }
313}
314
315#///////////////////////////////////////////////////////////////////////////
316proc ::TolConsole::ShowWindow {win} {
317#///////////////////////////////////////////////////////////////////////////
318  variable widgets
319  #win can have values "eval" "output" "info"
320  switch -exact $win  {
321    "eval"   {
322      $widgets(tabset) select 0
323      $widgets(eval) mark set anchor insert
324    }
325    "output" {
326      $widgets(tabset) select 1
327    }
328    "info"   {
329      $widgets(tabset) select 2
330    }
331  }
332
333}
334
335#/////////////////////////////////////////////////////////////////////////////     
336proc ::TolConsole::Configure {} {
337# 
338#/////////////////////////////////////////////////////////////////////////////       
339  OptionsApplyDefDates
340}
341
342#/////////////////////////////////////////////////////////////////////////////
343  proc ::TolConsole::postIncluded {m {ord 0}} {
344#
345# PURPOSE: Fills a menu with the last included files from TolBase, according
346#          to information of 'data' variable.
347#
348# PARAMETERS:
349#   m  -> menu's path that will have the list of last included files
350#   ord -> flag that indicates if files must be shown sorted
351#
352#/////////////////////////////////////////////////////////////////////////////
353  variable data
354  $m delete 0 end
355  if $data(chIncluded) {
356    set data(included) [lrange $data(included) 0 [expr $data(numRecent)-1]]
357    if $ord {
358      set lst [lsort -ascii $data(included)]
359    } else {
360      set lst $data(included)
361    }
362    foreach w $lst {
363      #set w [lindex $w 0]
364      $m add command -label $w -command [list ::TolConsole::IncludeCmd $w]
365    }
366    if [llength $lst] {
367       $m add separator
368       $m add command -label [mc "Clear"]\
369             -command [list ::TolConsole::clearRecent]
370    }
371}
372}
373
374#/////////////////////////////////////////////////////////////////////////////
375  proc ::TolConsole::clearRecent {} {
376#
377# PURPOSE: Clears the list of last Recent files
378#
379#/////////////////////////////////////////////////////////////////////////////
380  variable data
381  set data(included) ""
382  ::iniFile::Write TolConsole recent       data(included)
383  ::iniFile::Flush
384}
385
386
387#/////////////////////////////////////////////////////////////////////////////
388  proc ::TolConsole::Format {value} {
389#
390# PURPOSE: Receives a value and if it's double, formats it according to
391#          the information of 'data' variable.
392#
393# PARAMETERS:
394#   value  -> value to format
395#
396# RETURN:  The value formated
397#
398#/////////////////////////////////////////////////////////////////////////////
399  variable data
400  set val $value
401  if [string is double -strict $value] {
402    if {$data(chExponential) &&
403       ![catch {expr log10($value) >= $data(numExponential)} result]} {
404      if $result {
405        if $data(chDecimals) {
406          set val [format %.$data(chDecimals)e $value]
407        } else {
408          set val [format %e $value]
409        }
410      } else  {
411        if $data(chDecimals) {
412          set val [format "%.$data(numDecimals)f" $value]
413        }
414      }
415    } else {
416      if $data(chDecimals) {
417        set val [format "%.$data(numDecimals)f" $value]
418      }
419    }
420  }
421  return $val
422}
423
424#/////////////////////////////////////////////////////////////////////////////     
425proc ::TolConsole::OnInfo { args } {
426# 
427#/////////////////////////////////////////////////////////////////////////////       
428  variable widgets
429 
430  set w_info $widgets(info)
431  set w_tabset $widgets(tabset)
432  $w_info configure -state normal
433  $w_info delete 1.0 end
434  switch [llength $args] {
435    0 {
436    }
437    1 {
438      #$w_info configure -wrap word
439      $w_info insert end [lindex $args 0]
440      $w_tabset select 2
441    }
442    default {
443      #$w_info configure -wrap none
444      foreach {icon grammar name value path desc} $args {}
445        foreach {prop val} [list "Grammar: " $grammar "Name: " $name "Value: " $value "Path: " $path] {
446        set idx_start [$w_info index "end -1 chars"]
447        $w_info insert end $prop
448        set idx_end   [$w_info index "end -1 chars"]
449        $w_info tag add tagLabel $idx_start $idx_end
450        if {[string equal $prop "Grammar: "]} {
451          $w_info image create end -image $icon
452          $w_info insert end "  "
453        }
454        $w_info insert end "$val\n"
455        $w_info tag add tagValue $idx_end [$w_info index "end -1 chars"]
456      }
457      $w_info tag configure tagLabel -font fnBold
458      $w_info tag configure tagValue -wrap none
459      if { [string length $desc] } {
460        set idx_start [$w_info index "end -1 chars"]
461        $w_info insert end "Description\n"
462        set idx_end [$w_info index "end -1 chars"]
463        $w_info tag add tagPropLabel $idx_start $idx_end
464        $w_info insert end $desc
465        $w_info tag add tagPropValue $idx_end [$w_info index "end -1 chars"]
466        $w_info tag configure tagPropLabel -font fnBold -underline 1
467        #$w_info tag configure tagPropValue -wrap word
468      }
469      $w_tabset select 2
470    }
471  }
472  $w_info configure -state disabled
473}
474
475#/////////////////////////////////////////////////////////////////////////////     
476proc ::TolConsole::Include {file} {
477# 
478#/////////////////////////////////////////////////////////////////////////////       
479  #::LoadStatus::Show $file
480
481  ::TolInspector::Busy
482  update
483  ::tol::include $file
484  ::TolInspector::UpdateFileRoot
485  ::TolInspector::NotBusy
486  #::LoadStatus::Hide
487}
488
489
490#/////////////////////////////////////////////////////////////////////////////
491proc ::TolConsole::Compile { } {
492#
493# PURPOSE: Compiles text of eval window. If any text is selected, then only
494#          selection is compiled, else all text is compiled.
495#
496#/////////////////////////////////////////////////////////////////////////////
497  variable widgets
498  set w_eval $widgets(eval)
499 
500  set tolexpr [::BayesText::GetSelectionOrAll $w_eval]
501  EvalExpr $tolexpr
502}
503
504#/////////////////////////////////////////////////////////////////////////////
505proc ::TolConsole::EvalExpr {tolexpr} {
506#
507# PURPOSE: Compiles a TOL expresion in TOL console
508#
509#/////////////////////////////////////////////////////////////////////////////
510  ::TolInspector::Busy
511  Tolcon_Trace "tolexpr = $tolexpr"
512  if { [string length $tolexpr] } {
513    ::tol::console eval $tolexpr
514    SaveEval $tolexpr
515  }
516  ::TolInspector::UpdateConsoleObj
517  ::TolInspector::NotBusy
518}
519
520#/////////////////////////////////////////////////////////////////////////////     
521proc ::TolConsole::SaveEval {txt} {
522# 
523#/////////////////////////////////////////////////////////////////////////////       
524  global home_path
525  set evalFile [file join $home_path "eval.tol"]
526
527  set texto ""
528  if { [file exists $evalFile] } {
529    set fd [open $evalFile r]
530    set texto [read -nonewline $fd]
531    close $fd
532  }
533  set fd [open $evalFile w]
534  set txt "// [::tol::date now {%W, %Y/%m/%d %h:%i:%s}]\n$txt\n\n"
535  puts -nonewline $fd $txt
536  puts -nonewline $fd $texto
537  close $fd
538}
539
540#/////////////////////////////////////////////////////////////////////////////     
541proc ::TolConsole::OpenEval {} {
542# 
543#/////////////////////////////////////////////////////////////////////////////       
544  global home_path
545  set evalFile [file join $home_path "eval.tol"]
546  if { ![file exists $evalFile] } {
547    set fd [open $evalFile w]
548    close $fd
549  }
550  ::Editor::Open $evalFile
551}
552
553#/////////////////////////////////////////////////////////////////////////////     
554proc ::TolConsole::OnConnect {alias user pass datasource} {
555# 
556#/////////////////////////////////////////////////////////////////////////////       
557  set name [GetUniqueName Real]
558  ::tol::console eval "Real $name = DBOpen(\"$alias\",\"$user\",\"$pass\");"
559  ::tol::console stack release $name
560}
561
562#/////////////////////////////////////////////////////////////////////////////     
563proc ::TolConsole::OnDisconnect {alias user pass datasource} {
564# 
565#/////////////////////////////////////////////////////////////////////////////       
566  set name [GetUniqueName Real]
567  ::tol::console eval "Real $name = DBClose(\"$alias\");"
568  ::tol::console stack release $name
569}
570
571#/////////////////////////////////////////////////////////////////////////////     
572proc ::TolConsole::DBConnect {} {
573# 
574#/////////////////////////////////////////////////////////////////////////////       
575  ::ODBCDialog::Create $::project::widgets(mainframe) "" "" "" \
576  ::TolConsole::OnConnect ::TolConsole::OnDisconnect
577}
578
579#/////////////////////////////////////////////////////////////////////////////     
580proc ::TolConsole::ClearConsole { } {
581# 
582#/////////////////////////////////////////////////////////////////////////////       
583  ::TolInspector::ClearConsoleObj
584  ::TolInspector::UpdateConsoleObj
585}
586
587#/////////////////////////////////////////////////////////////////////////////     
588proc ::TolConsole::OnBusy { state } {
589# 
590#/////////////////////////////////////////////////////////////////////////////       
591    variable widgets
592   
593    if { $state } {
594        $widgets(eval) configure -cursor watch
595        $widgets(tabset) configure -cursor watch
596       #  ::blt::busy hold .       
597    } else {
598        $widgets(eval) configure -cursor xterm
599        $widgets(tabset) configure -cursor ""
600      #  ::blt::busy release .     
601    }
602}
603
604
605#/////////////////////////////////////////////////////////////////////////////
606  proc ::TolConsole::ToEvalWindow { message } {
607#
608# PURPOSE: Writes a message in eval window and selects this tab (eval window)
609#
610# PARAMETERS:
611#   message -> Message to write in eval window
612#
613#/////////////////////////////////////////////////////////////////////////////
614  upvar \#0 ::TolConsole::widgets(tabset) w_tabset
615  upvar \#0 ::TolConsole::widgets(eval) w_eval
616
617  $w_eval insert end "$message\n"
618  $w_tabset select 0
619  $w_eval see end
620}
621
622#/////////////////////////////////////////////////////////////////////////////
623proc ::TolConsole::HciWriter { message } {
624# 
625#/////////////////////////////////////////////////////////////////////////////
626  variable widgets
627  variable data
628  variable time
629 
630  upvar \#0 ::TolConsole::widgets(tabset) w_tabset
631  upvar \#0 ::TolConsole::widgets(output) w_output
632  if $data(chWrite) {
633    $w_output configure -state normal
634    set tr_message [string trim $message]
635    # {<([^>]+)>([^<]+)</([^>]+)>}
636    if { [regexp -- {^<([^>]+)>(.+)</(.+)>} $tr_message -> start content end] } {
637      if {($start ne $end) || (($start ne "E") && ($start ne "W"))} {
638        $w_output insert end "$message"
639      } else {
640        set idx_start [$w_output index "end -1 char"]
641        $w_output insert end "$content\n"
642        set idx_end [$w_output index "end -1 char"]
643        $w_output tag add $data(output,TAG,$start) $idx_start $idx_end
644      }
645    } else {
646      $w_output insert end "$message"
647    }
648    $w_output configure -state disabled
649  }
650 
651  switch $data(updateType) {
652    always {
653      if $data(chWrite) {
654        $w_tabset select 1
655        $w_output see end     
656      }
657      update
658    }
659    each   {
660      set time_now [clock clicks -milliseconds]
661      set dif [expr $time_now - $time]
662      if { $dif >= $data(updateSec) } {
663        set time $time_now
664        if $data(chWrite) {
665          $w_tabset select 1
666          $w_output see end
667        }
668        update
669      }
670    }
671    never  { }
672  }
673}
674
675#/////////////////////////////////////////////////////////////////////////////
676proc ::Tol_HciWriter { message } {
677# 
678#/////////////////////////////////////////////////////////////////////////////
679  ::TolConsole::HciWriter $message
680}
681
682#/////////////////////////////////////////////////////////////////////////////
683proc ::TolConsole::Recover {editor} {
684# 
685#/////////////////////////////////////////////////////////////////////////////
686  set state [$editor cget -state]
687  $editor configure -state normal
688  $editor delete 1.0 end
689
690  set cmd "Text $nRes = PutDumpFile(\"\");"
691  ::tol::console eval $cmd
692  array set inf [TclInfoVar Text $nRes]
693  eval "set file $inf(CONTENT)"
694  ::tol::console stack release $nRes
695   
696  if { ![catch {set fd [open $file r] } msgerr] } {
697    $editor insert 1.0 [read -nonewline $fd]
698    #HciWriter [read -nonewline $fd]
699    close $fd
700  }
701  tk::TextSetCursor $editor end
702  $editor configure -state $state
703}
704
705#/////////////////////////////////////////////////////////////////////////////
706proc ::TolConsole::MainFrame { w {tolcon 1} } {
707# 
708#/////////////////////////////////////////////////////////////////////////////
709  variable widgets
710  variable data
711
712  #bind ::project::widgets(mainframe) <Destroy> +[list ::TolConsole::Exit]
713  bind . <Destroy> +[list ::TolConsole::Exit %W]
714
715  # Aqui deberiamos llamar a la inicializacion tcl del proyecto.
716  # solo si el proyecto ha puesto menus poner el de tolcon.
717  project::OnExit ::TolConsole::BeforeExit
718
719  #Creamos StatusBar antes de ButtonBar
720  set sb [::TolConsole::CreateStatusBar]
721  #Creamos ButtonBar
722  set bb [::TolConsole::CreateButtonBar $tolcon]
723  #Empacamos ButtonBar
724  #if { [lsearch {left right} $data(toolbars,side)] ne -1 } {
725  #  ::toolbar::SetOrientation $bb V
726  #}
727  if { $tolcon } {
728    #Creamos inspector+Ventanas
729    set widgets(inspector) [Create $w]
730    bind $widgets(inspector) <F6> "::TolConsole::ApplyViewMode ; break"
731    Tolcon_Trace "widgets(inspector): $widgets(inspector)"
732  } else {
733   # ::TolConsole::OptionsApplyDefDates
734  }
735 
736  # VISUALIZAMOS O NO EL INSPECTOR DE OBJETOS
737  ::TolConsole::ObjectInspectorShow
738 
739  project::raiseSplash
740  return $w
741}
742
743
744#/////////////////////////////////////////////////////////////////////////////
745proc ::TolConsole::RaiseInspector {} {
746#/////////////////////////////////////////////////////////////////////////////
747  $::project::widgets(mainmdi).slave1 restore
748  $::project::widgets(mainmdi).slave1 raise
749}
750
751
752#pedro-start
753#/////////////////////////////////////////////////////////////////////////////
754proc ::TolConsole::NewToolFrame { name { first 1 }} {
755#  Crea una nueva ToolFrame para Toolbars
756#/////////////////////////////////////////////////////////////////////////////
757  variable widgets
758  variable data
759 
760  switch $first {
761    1 {
762      set commandAux "toolbarFrame_${name}"
763      set newTFname $commandAux
764    }
765    2 {
766      set commandAux $name
767      set newTFname  $name
768    }
769    default {
770      set newTFname "toolbarFrame_${name}"
771      set commandAux $::project::widgets(mainframe).${newTFname}
772    }
773  }
774  # create a toolframe new 
775  Tolcon_Trace "ToolFrame sale-----> $commandAux"
776  set TF [::toolbar::ToolbarFrame $commandAux]
777  #Añadimos como objetivo de Drop (tkdnd)
778  dnd bindtarget $TF text/plain <Drop> "::TolConsole::TMotion %W %D $newTFname"
779  #empacamos
780  #pack $TF -side top -fill y
781  pack $TF -side $data(toolbars,side) \
782    -before $::project::widgets(mainmdi) \
783    -anchor nw -fill $data(toolbars,fill)
784  #añadimos Botones por defecto
785  #if { $first } {
786  #::TolConsole::NewToolBarB $TF $name
787  #}
788  switch $first {
789    1 {
790      ::TolConsole::NewToolBarB $commandAux $name
791    }
792    2 {
793      #
794    }
795    default {
796      ::TolConsole::NewToolBarB $TF $name
797    }
798  }
799  return $TF
800}
801
802
803#/////////////////////////////////////////////////////////////////////////////
804proc ::TolConsole::NewToolBarB { parentTF name { jump 0 } {Child 0} {ini 0}} {
805#  Crea una nueva toolbar para botones dentro del frame parentTF
806#  parentTF : Frame papa
807#  jump     : Opcion utilizada en caso de adopcion. (cambio de frame padre).
808#  loopyPath: Contiene los parametros de creacion de TODOS los botones
809#             de un toolbar, se recorre cuando jump es 1.
810#/////////////////////////////////////////////////////////////////////////////
811  variable widgets
812  variable data
813   
814  switch $ini {
815    1 {
816      set data(tolbase,original) 0
817      set newName $name
818      set largo   [string length $newName]
819      set newName [string range $newName 0 [expr $largo - 2]]
820      set newTb   [::toolbar::create "$parentTF.$newName"]
821    }
822    2 {
823      set newName [lindex [split $Child .] 3]
824      set largo   [string length $newName]
825      set newName [string range $newName 0 [expr $largo - 1]]
826      if {[winfo exists $parentTF.$newName]} {
827        set data(tolbase,original) 1
828        } else {
829        set data(tolbase,original) 0
830        set newTb   [::toolbar::create "$parentTF.$newName"]
831      }
832    }
833    default {
834      set data(tolbase,original) 0
835      set newName "tb_${name}"
836      set newTb [::toolbar::create "$parentTF.$newName"]
837    }
838  }
839 
840  #if { $ini } {
841  #  set newName $name
842  #  Tolcon_Trace "newName -> $newName"
843  #  set largo   [string length $newName]
844  #  set newName [string range $newName 0 [expr $largo - 2]]
845  #  set newTb   [::toolbar::create "$parentTF.$newName"]
846  #} else {
847  #  set newName "tb_${name}"
848  #  Tolcon_Trace "newName -> $newName"
849  #  set newTb [::toolbar::create "$parentTF.$newName"]
850  #}
851 
852  if { $jump } {
853    set test "\{"
854    foreach path $widgets(createScript,$Child) {
855      set Apic  [lindex $path 1]
856      set Ahelp [lindex $path 2]
857      set Acmd  [lindex $path 3]
858      if { [string index $Acmd 0] == $test } {
859        set largo  [string length $Acmd]
860        set newCmd [string range  $Acmd 1 [expr $largo - 2]]
861      } else {
862        set newCmd $Acmd
863      }
864      #creamos botones exactamente iguales y en el mismo orden sobre nuevo
865      #parent
866      if {$data(tolbase,original) == 0} {
867        ::TolConsole::NewButtonB $newTb $Apic $Ahelp $newCmd $parentTF
868      }
869     
870    }
871   Tolcon_Trace "/n COMPLETE DUMP ---> $widgets(createScript,$Child)"
872  }
873 
874 
875  #empacamos
876  if {$data(tolbase,original)} {
877    dnd bindsource $parentTF.$newName text/plain "return $parentTF.$newName"
878    pack $parentTF.$newName -side left -anchor w \
879              -fill x
880    return $parentTF.$newName
881  } else {
882    #Drag-n-Drop para mover a diferentes toolframes
883    dnd bindsource $newTb text/plain "return $newTb"
884    pack $newTb -side left -anchor w \
885              -fill x -in $parentTF
886    return $newTb
887  }
888}
889
890
891#/////////////////////////////////////////////////////////////////////////////
892proc ::TolConsole::NewButtonB { Tb pic help cmd parentTF} {
893#  --- Crea un nuevo boton en la toolbar parametro ---
894#
895#  pathToolbar : Ruta completa al toolbar padre que tendra el boton
896#  pic    : Imagen del Boton
897#  prueba : Introducir boton de prueba (llevar a 0 para no empacar
898#           dos botones por llamada.
899#  help   : Ayuda del Boton Custom
900#  cmd    :comando a ejecutar por el boton
901#/////////////////////////////////////////////////////////////////////////////
902  variable widgets
903  variable data
904
905  # imagen ?
906  if { $pic == "" } {
907    set pic index
908  }
909  # exists imagen ?
910  if {[catch {::Bitmap::get $pic}]} {
911    # no exists
912    Tolcon_Trace "La imagen asociada al comando no existe. \
913      No se mostrara el botón: imagen: $pic - comando: $help"
914  } else {
915    # exists
916    set but [::toolbar::addbutton $Tb -image [::Bitmap::get $pic] \
917      -tooltip [mc $help] -command $cmd]
918    #event add <<TMotion_1>> <Button1-Motion>
919    bind $but <<TMotion_1>> "dnd drag $Tb"
920    bind $but <ButtonPress-2> "::toolbar::ButtonMenu"
921    dnd bindsource $Tb text/plain "return $Tb"
922    #guardamos parametros del create del boton, si es el primer boton,
923    #iniciamos la matriz.
924    if { [info exists widgets(createScript,$Tb)] } {
925      lappend widgets(createScript,$Tb) "$Tb $pic [list $help] [list $cmd] $parentTF"
926    } else {
927      set     widgets(createScript,$Tb) "{$Tb $pic [list $help] [list $cmd] $parentTF}"
928    }
929    if { ![regexp "$Tb $pic [list $help] [list $cmd] $parentTF" "$data(tolbase,lsttoolbars)" ] } {
930      lappend data(tolbase,lsttoolbars) "$Tb $pic [list $help] [list $cmd] $parentTF"
931    }
932  }
933  return
934}
935
936
937#/////////////////////////////////////////////////////////////////////////////
938proc ::TolConsole::TMotion { targetTF newChild name} {
939#  Mueve Toolbar de un Frame a otro cuando ocurre un DND
940#/////////////////////////////////////////////////////////////////////////////
941  variable widgets
942  variable data
943  set test [winfo parent $newChild]
944
945  if { $targetTF != $test } {
946    pack forget $newChild
947
948    set data(tolbase,lsttoolbars) \
949      [lsub $data(tolbase,lsttoolbars) $widgets(createScript,$newChild)]
950     
951    if {$data(tolbase,ini)} {
952      ::TolConsole::NewToolBarB $targetTF $name 1 $newChild 2
953    } else {
954      ::TolConsole::NewToolBarB $targetTF $name 1 $newChild 2
955    }   
956  } else {
957    pack $newChild -in $targetTF -side left -anchor w \
958                -fill x
959  }
960 return
961}
962
963
964#/////////////////////////////////////////////////////////////////////////////
965proc ::TolConsole::CreateButtonBar { {tolcon 1} } {
966# 
967#/////////////////////////////////////////////////////////////////////////////
968  variable widgets
969  variable data
970 
971  set TF {}
972  if {![llength $data(tolbase,lsttoolbars)]} {
973    #Creamos ToolFrame Principal para botones por defecto.
974    set TF [set widgets(toolbar,main) [::TolConsole::NewToolFrame 0 0]]
975   
976    # 2) Separamos Botones en diferentes Toolframes
977    #Grupo Botones Inspector
978    set tb1 [::TolConsole::NewToolBarB $TF "tb1"]
979    #Show Inspector Window
980    ::TolConsole::NewButtonB $tb1 insobj [mc "TOL Inspector"] \
981      "$::project::widgets(mainmdi).slave1 restore; $::project::widgets(mainmdi).slave1 raise" $TF
982    #Show Eval Window
983    ::TolConsole::NewButtonB $tb1 evalwin [mc "Show Eval Window"] \
984    [list ::TolConsole::ShowWindow "eval"] $TF
985     #Show Output Window
986     ::TolConsole::NewButtonB $tb1 outputwin [mc "Show Output Window"] \
987     [list ::TolConsole::ShowWindow "output"] $TF
988     #Show Info
989     ::TolConsole::NewButtonB $tb1 infowin [mc "Show Info Window"] \
990     [list ::TolConsole::ShowWindow info] $TF
991       #Show ViewMode   
992     ::TolConsole::NewButtonB $tb1 changeview [mc "Change View Mode"] \
993     [list ::TolConsole::ApplyViewMode] $TF
994   
995    #Grupo Botones para Mostrar Acciones
996     set tbExe [::TolConsole::NewToolBarB $TF "tbExe"]
997     #New Editor Dialog
998     ::TolConsole::NewButtonB $tbExe newfile [mc "New TOL file"] \
999     [list ::Editor::New] $TF
1000     #Open TOL File
1001       ::TolConsole::NewButtonB $tbExe openfile [mc "Open TOL file"] \
1002     [list ::Editor::Open] $TF
1003     #New Table Dialog
1004     ::TolConsole::NewButtonB $tbExe newtable [mc "New Table"] \
1005     [list ::TolConsole::TableNew] $TF
1006     #Open Table Dialog
1007     ::TolConsole::NewButtonB $tbExe opentable [mc "Open Table"] \
1008     [list ::TolConsole::TableOpen] $TF
1009
1010     #New Project
1011     ::TolConsole::NewButtonB $tbExe newproject [mc "New Project"] \
1012     [list ::TolProject::New] $TF
1013     #Open Project
1014     ::TolConsole::NewButtonB $tbExe openprj [mc "Open Project"] \
1015     [list ::TolProject::Open] $TF
1016   
1017      #Grupo Botones para Herramientas
1018     set tbTool [::TolConsole::NewToolBarB $TF "tbTool"]
1019     #DB Connection
1020       ::TolConsole::NewButtonB $tbTool db [mc "Connection to database"] \
1021     [list $::project::data(bodbc) showdialog]  $TF
1022     #Function Search
1023       ::TolConsole::NewButtonB $tbTool funsearch [mc "Functions Search"] \
1024     [list ::funcSearch::Show] $TF
1025     #SQL
1026     ::TolConsole::NewButtonB $tbTool bysSql [mc "Bayes SQL"] \
1027     [list ::SQLTable::TableBayesSQL] $TF
1028     #Calendar
1029     ::TolConsole::NewButtonB $tbTool TimeSet [mc "Calendar Expert"] \
1030     [list ::CalendarTms::ViewTimeSet] $TF
1031     #Calendar
1032     ::TolConsole::NewButtonB $tbTool tools [mc Options] \
1033     [list ::TolConsole::OptionsCreate] $TF
1034   
1035      #Grupo Botones para Distribucion de Ventanas y Ayuda Visual
1036     set tbHelp [::TolConsole::NewToolBarB $TF "tbHelp"]
1037     #Cascade
1038     ::TolConsole::NewButtonB $tbHelp cascade [mc "Cascade"] \
1039     [list $::project::widgets(mainmdi) arrange cascade] $TF
1040       #Horizontal
1041     ::TolConsole::NewButtonB $tbHelp tilehor [mc "Tile Horizontal"] \
1042     [list $::project::widgets(mainmdi) arrange hor] $TF
1043       #Vertical
1044     ::TolConsole::NewButtonB $tbHelp tilever [mc "Tile Vertical"] \
1045     [list $::project::widgets(mainmdi) arrange ver] $TF
1046       #About
1047     ::TolConsole::NewButtonB $tbHelp about [mc "About"] \
1048       [list ::TolConsole::AboutShow] $TF
1049     set widgets(tb1,path) $tb1
1050     set widgets(tbExe,path) $tbExe
1051     set widgets(tbTool,path) $tbTool
1052     set widgets(tbHelp,path) $tbHelp
1053     set widgets(toolbar,frame) $TF
1054  } else {
1055    #aqui creamos las barras de botones que hemos recuperado del INI
1056    set tfgitb [::TolConsole::GlobalIniToolbarsButtons]
1057    set TF [set widgets(toolbar,main) [lindex $tfgitb 0]]
1058  }
1059  # toolbar by default, in order to add bellboys from the outside
1060  if {![string length $TF]} {
1061    # if not exists, create new
1062    set TF [::TolConsole::NewToolFrame 0 0]
1063  }
1064  set widgets(tbCustom,path) [::TolConsole::NewToolBarB $TF "tbCustom"]
1065  return
1066}
1067
1068
1069#/////////////////////////////////////////////////////////////////////////////
1070proc ::TolConsole::GlobalIniToolbarsButtons {} {
1071# 
1072#/////////////////////////////////////////////////////////////////////////////
1073  variable widgets
1074  variable data
1075 
1076  set data(tolbase,ini) 1
1077  set lstToolFrames {}
1078  set lstFrames {}
1079  set lstFrameBut {}
1080  set i 1
1081  foreach item $data(tolbase,lsttoolbars) {
1082    lappend lstFrameBut   $item
1083    lappend lstToolFrames [lindex $item 4]
1084    lappend lstFrames     [list [lindex $item 0] [lindex $item 4]]
1085    incr i
1086  }
1087  set lstFrames     [lsort -unique $lstFrames]
1088  set lstFrameBut   [lsort -unique $lstFrameBut]
1089  set lstToolFramesAux {}
1090  foreach it $lstToolFrames {
1091    puts $it
1092    if {!([lsearch -exact $lstToolFramesAux $it ] >= 0)} {
1093      lappend lstToolFramesAux $it
1094    }
1095  }
1096  set tfaux {}
1097  foreach toolFrame $lstToolFramesAux {
1098    set tfaux [::TolConsole::NewToolFrame "$toolFrame" 2]
1099  }
1100  set lstFramesAux {}
1101  foreach it $lstFrames {
1102    puts $it
1103    if {!([lsearch -exact $lstFramesAux $it ] >= 0)} {
1104      lappend lstFramesAux $it
1105    }
1106  }
1107  foreach toolBar $lstFrames {
1108    ::TolConsole::NewToolBarB  [lindex $toolBar 1] [lindex [split $toolBar .] 3] 0 0 1
1109  }
1110  foreach but $lstFrameBut {
1111    ::TolConsole::NewButtonB [lindex $but 0] [lindex $but 1] \
1112      [lindex $but 2] [lindex $but 3] [lindex $but 4]
1113  }
1114  return $tfaux
1115}
1116
1117
1118#/////////////////////////////////////////////////////////////////////////////
1119proc ::TolConsole::CreateStatusBar {} {
1120# 
1121#/////////////////////////////////////////////////////////////////////////////
1122  variable widgets
1123 
1124  set widgets(sb,path) [statusbar .sbar]
1125  .sbar add statTime -image [::Bitmap::get tinyclock]
1126  ::TolConsole::UpdateTime
1127if {0} {
1128  variable widgets
1129  # frame y label para barra de estado
1130  set widgets(sb,path) [set sf [frame $w.sb]]
1131  set widgets(sb,lInfo)   [label $sf.info   -anchor w -relief sunken]
1132  set widgets(sb,lTime)   [label $sf.cursor -anchor w -relief sunken]
1133  # empaquetamos los label de la barra de estado
1134  grid $w.sb.info   -row 0 -column 0 -sticky ew -padx 2
1135  grid $w.sb.cursor -row 0 -column 1 -sticky w  -padx 2
1136  grid columnconfigure $sf 0 -weight 1
1137  UpdateTime
1138  return $w.sb
1139}
1140}
1141
1142#/////////////////////////////////////////////////////////////////////////////
1143proc ::TolConsole::UpdateTime {} {
1144#
1145# PURPOSE: Updates time in status bar
1146#
1147#/////////////////////////////////////////////////////////////////////////////
1148  variable widgets
1149  $widgets(sb,path) itemconf statTime \
1150    -text [clock format [clock seconds] -format {%H:%M:%S }]
1151  after 1000 ::TolConsole::UpdateTime
1152if {0} {
1153  variable widgets
1154  $widgets(sb,lTime) configure\
1155      -text [clock format [clock seconds] -format {%H:%M:%S }]
1156  after 1000 ::TolConsole::UpdateTime
1157}
1158}
1159
1160
1161#/////////////////////////////////////////////////////////////////////////////
1162proc ::TolConsole::ApplyViewMode {{change 1}} {
1163#
1164# PURPOSE: Changes heights of inspector and eval/output/info windows
1165#
1166#/////////////////////////////////////////////////////////////////////////////
1167  variable data
1168  variable widgets
1169
1170  set state $data(viewmode)
1171  set states [list middle max min middle]
1172  if {$change} {
1173    set idx [lsearch -exact $states $state]
1174    set state [lindex $states [expr $idx+1]]
1175  }
1176  ::PanedWindow::MoveSash $widgets(pw) 1 y $state
1177  set data(viewmode) $state
1178}
1179
1180
1181#/////////////////////////////////////////////////////////////////////////////
1182  proc ::TolConsole::AboutShow {} {
1183#
1184# PURPOSE: Shows the function search dialog
1185#
1186#/////////////////////////////////////////////////////////////////////////////
1187  set path .__about
1188
1189  if ![winfo exist $path] {
1190    ::TolConsole::About $path
1191  }
1192  wm state $path normal
1193}
1194
1195#/////////////////////////////////////////////////////////////////////////////
1196  proc ::TolConsole::TolBaseHelp {} {
1197#
1198# PURPOSE: Shows the home page of help of Tolbase
1199#
1200#/////////////////////////////////////////////////////////////////////////////
1201  ShowHelp "Tb4Mai"
1202}
1203
1204
1205#/////////////////////////////////////////////////////////////////////////////
1206  proc ::TolConsole::About { w } {
1207#
1208# PURPOSE: Shows a dialog that shows information about TolBase and Bayes.
1209#
1210#/////////////////////////////////////////////////////////////////////////////
1211  global toltk_library
1212  global GuiVersionInfo
1213
1214  set imgfile [file join $toltk_library toltk images splash.gif]
1215  set img [image create photo -file $imgfile]
1216  toplevel $w
1217  wm title $w "[mc About] TOLBase"
1218  wm withdraw $w
1219  wm transient $w .
1220  wm iconbitmap $w [wm iconbitmap .]
1221  wm resizable $w 0 0
1222  label $w.lsplash -image $img -relief ridge -bd 2
1223  array set TolVersionInfo [::tol::info version]
1224  label $w.lversion -bg black -fg white -text \
1225    "[mc {TOL Version}]: $TolVersionInfo(major).$TolVersionInfo(minor).$TolVersionInfo(release) ($TolVersionInfo(comment))"
1226  label $w.laddress -bg black -fg white -text {
1227    Bayes Forecast: dynamic modelling of operations and markets
1228    Voice: (+34) 91.5327440; Fax: (+34) 91.5322636
1229    e-Mail: request@bayesinf.com; URL: http://www.tol-project.org
1230  }
1231 
1232  button $w.bc -text [mc Close] -command [list destroy $w]
1233  grid $w.lsplash
1234  grid $w.lversion -sticky "ew"
1235  grid $w.laddress -sticky "ew"
1236  grid $w.bc -padx 2 -pady 5 -sticky ns
1237  update
1238  # Aqui deberiamos invocar a un proc CenterWindow
1239  wm geometry $w +[expr ([winfo vrootw .]-[winfo reqwidth $w])/2]+[expr ([winfo vrooth .]-[winfo reqheight $w])/2]
1240  update
1241  wm withdraw $w
1242  wm deiconify $w
1243  update
1244}
1245
1246#/////////////////////////////////////////////////////////////////////////////     
1247proc ::TolConsole::IncludeCmd {{path ""} } {
1248# 
1249#/////////////////////////////////////////////////////////////////////////////       
1250  variable data
1251  set types {
1252    {{Tol Files}  {.tol .bst .bsi .bst .bdt}}
1253    {{Text Files}  {.txt}}
1254    {{All Files}  *}
1255  }
1256
1257  if {$path == ""} {
1258    if { [catch {tk_getOpenFile -filetypes $types \
1259                   -initialdir $data(path) \
1260                   -title "Source File"} fn] || [string match {} $fn] } {
1261      return
1262    }   
1263  } else  {
1264    set fn $path
1265  }
1266  UpdateListIncluded $fn
1267  Include $fn
1268   
1269
1270}
1271
1272#/////////////////////////////////////////////////////////////////////////////     
1273proc ::TolConsole::UpdateListIncluded {path} {
1274# 
1275#/////////////////////////////////////////////////////////////////////////////       
1276  variable data
1277  # guardamos el ultimo directorio abierto
1278  set data(path) [file dirname $path]
1279  if { [set idx [lsearch $data(included) $path]] == -1 } {
1280    set data(included) [linsert $data(included) 0 $path]
1281  } else {
1282    set ll ""
1283    lappend ll $path
1284    set i 0
1285    foreach f $data(included) {
1286      if  {$i != $idx} {
1287        lappend ll $f
1288      }
1289      incr i
1290    }
1291    set data(included) $ll
1292  }
1293  set data(included) [lrange $data(included) 0 [expr $data(numRecent)-1]]
1294}
1295
1296#/////////////////////////////////////////////////////////////////////////////
1297proc ::TolConsole::Exit { w } {
1298#
1299#/////////////////////////////////////////////////////////////////////////////
1300  variable data
1301  variable widgets
1302
1303  if {$w eq "."} {
1304    ProcessPendingTasks
1305   
1306    # Options project
1307    if {[info exists data(proc,OnOptionDestroy)] && \
1308            [string length $data(proc,OnOptionDestroy)]} {
1309      foreach f $data(proc,OnOptionDestroy) {
1310        $f
1311      }
1312    }
1313    WriteIni
1314  }
1315}
1316
1317#/////////////////////////////////////////////////////////////////////////////
1318proc ::TolConsole::BeforeExit { } {
1319#
1320#/////////////////////////////////////////////////////////////////////////////
1321  variable data
1322  variable widgets
1323
1324  # check all ...
1325  set okEdi ok
1326  set okETr ok
1327  set okTPr ok
1328  catch {set okEdi [::Editor::CheckAll]}
1329  catch {set okETa [::EditTable::CheckAll]}
1330  catch {set okTPr [::TolProject::CheckAll]}
1331
1332  if {[string eq $okEdi cancel] || [string eq $okETa cancel] || \
1333      [string eq $okTPr cancel]} {
1334    return cancel
1335  }
1336  # exit
1337  if { [info exists widgets(inspector)] } {
1338    foreach a {x y width height} {
1339      set data(geometry,$a) [winfo $a $widgets(inspector)]
1340    }
1341    set data(geometry,wtop) [winfo height $widgets(panes,top)]
1342    set data(geometry,wbottom) [winfo height $widgets(panes,bottom)]
1343    set data(geometry,wleft) [::TolInspector::GetWeight left]
1344    set data(geometry,wright) [::TolInspector::GetWeight right]
1345    set data(font,eval) [$widgets(eval) cget -font]
1346    set data(font,output) [$widgets(output) cget -font]
1347    set data(font,info) [$widgets(info) cget -font]
1348  }
1349  return "ok"
1350}
1351
1352#/////////////////////////////////////////////////////////////////////////////
1353proc ::TolConsole::ProcessPendingTasks {} {
1354#
1355#/////////////////////////////////////////////////////////////////////////////
1356  # para que este procedimiento?
1357  return
1358  foreach id [after info] {
1359    set aft_info [after info $id]
1360    after cancel $id
1361    eval [lindex $aft_info 0]
1362  }
1363}
1364
1365#///////////////////////////////////////////////////////////////////////////// 
1366proc ::TolConsole::OptionsCreate { {tabinit ""} } {
1367#
1368# PURPOSE: Create the dialog of options of TolBase
1369#
1370# PARAMETERS:
1371#   tabinit -> Tab where is focused the dialog when it's displayed (Optional).
1372#
1373#///////////////////////////////////////////////////////////////////////////// 
1374  variable widgets
1375  variable data
1376
1377  set path $widgets(inspector)
1378
1379  set dialog [Dialog $path.t -title [mc "TOLBase Options"]\
1380              -parent $path -default 0 -cancel 1 -modal local] 
1381  wm protocol $dialog WM_DELETE_WINDOW \
1382    [list ::TolConsole::OptionsDestroy $dialog]
1383  set w [$dialog getframe]
1384 
1385  wm resizable $dialog 0 0
1386  # TabSet TolBase
1387  set w_ts [::blt::tabset $w.ts -relief flat -highlightthickness 0 -bd 0 \
1388    -outerpad 0 -tier 2 -slant both -textside right -side left -rotate 90 ]
1389  #insertar tabset
1390  $w_ts insert end TolBase
1391  set f0 [frame $w_ts.f0] 
1392  $w_ts tab configure "TolBase" -text "TolBase" \
1393    -window $f0 -fill both -padx 0 -selectbackground \#d9d9d9 -bg gray75 
1394 
1395  # TabSet Options
1396  set w_tabset [::blt::tabset $f0.ts -relief flat -highlightthickness 0\
1397    -bd 0 -outerpad 0 -tier 2 -slant right -textside right ]
1398 
1399  $w_tabset insert end TOL Output Precision Paths Others
1400  set f1 [frame $w_tabset.f1]
1401  set f2 [frame $w_tabset.f2]
1402  set f3 [frame $w_tabset.f3]
1403  set f4 [frame $w_tabset.f4]
1404  set f5 [frame $w_tabset.f5]
1405
1406  $w_tabset tab configure "TOL" -text [mc "TOL"] -window $f1\
1407       -fill both -padx 0 -selectbackground \#d9d9d9 -bg gray75
1408  $w_tabset tab configure "Output" -text [mc "Output"] -window $f2\
1409       -fill both -padx 0 -selectbackground \#d9d9d9 -bg gray75
1410  $w_tabset tab configure "Precision" -text [mc "Precision"] -window $f3\
1411       -fill both -padx 0 -selectbackground \#d9d9d9 -bg gray75
1412  $w_tabset tab configure "Paths" -text [mc "Paths"] -window $f5\
1413       -fill both -padx 0 -selectbackground \#d9d9d9 -bg gray75
1414  $w_tabset tab configure "Others" -text [mc "Others"] -window $f4\
1415       -fill both -padx 0 -selectbackground \#d9d9d9 -bg gray75
1416
1417  OptionsGet
1418  OptionsCreateTOL        $f1
1419  OptionsCreateOutput     $f2
1420  OptionsCreatePrecision  $f3
1421  OptionsCreatePaths      $f5
1422  OptionsCreateOthers     $f4
1423 
1424  # Options project
1425  if {[info exists data(proc,OnOptionCreate)] && \
1426      [string length $data(proc,OnOptionCreate)]} {
1427    foreach f $data(proc,OnOptionCreate) {
1428      $f $w_ts
1429    }
1430  }
1431
1432  OptionsCheck
1433
1434  set w_bbox \
1435          [ButtonBox $w.bb -orient horizontal -spacing 10 -padx 0 -pady 0 \
1436          -homogeneous false]
1437  $w_bbox add -text [mc "Accept"] -relief link \
1438          -helptext [mc "Make the changes and leave the dialog"] \
1439          -image [::Bitmap::get accept] -compound left -padx 5 -pady 1 \
1440          -command [list ::TolConsole::OptionsOK $dialog]
1441  $w_bbox add -text [mc "Cancel"] -relief link \
1442          -helptext [mc "Leave the dialog without apply any change"] \
1443          -image [::Bitmap::get cancelx] -compound left -padx 5 -pady 1 \
1444          -command [list ::TolConsole::OptionsDestroy $dialog]
1445  $w_bbox add -text [mc "Apply"] -relief link \
1446          -helptext [mc "Make the changes without leave the dialog"] \
1447          -image [::Bitmap::get apply] -compound left -padx 5 -pady 1 \
1448          -command ::TolConsole::OptionsApply
1449
1450  pack $w_bbox   -side bottom -expand no  -fill x
1451  pack $w_tabset -side top    -expand yes -fill both
1452  pack $w_ts -expand yes -fill both ;#-sticky news
1453 
1454  if {!($tabinit eq "")} {
1455    switch -exact $tabinit  {
1456      "TOL" {
1457        $w_tabset select 0
1458      }
1459      "Output" {
1460        $w_tabset select 1
1461      }
1462      "Precision" {
1463        $w_tabset select 2
1464      }
1465      "Paths" {
1466        $w_tabset select 3
1467      }
1468      "Others" {
1469        $w_tabset select 4
1470      }     
1471    }
1472  }
1473  bind $dialog <F1> "ShowHelp Tb4Opc"
1474  $dialog draw
1475}
1476
1477
1478#///////////////////////////////////////////////////////////////////////////// 
1479proc ::TolConsole::OptionsCreateTOL {w} {
1480#
1481#///////////////////////////////////////////////////////////////////////////// 
1482  variable tmpOpt
1483
1484  #TitleFrame $w.tf1 -text [mc "--"]
1485  #set f1 [$w.tf1 getframe]
1486
1487  TitleFrame $w.tf2 -text [mc "Default dates"]
1488  set f2 [$w.tf2 getframe]
1489
1490  label $f2.lFirstDate -text [mc "First date"]:
1491  ::Objects::ChooseDateCreate ::TolConsole::tmpOpt(var,DefFirst) $f2.cFD
1492
1493  label $f2.lLastDate -text [mc "Last date"]:
1494  ::Objects::ChooseDateCreate ::TolConsole::tmpOpt(var,DefLast) $f2.cLD
1495
1496  frame $f2.f -width 25
1497
1498  grid $f2.f $f2.lFirstDate $f2.cFD $f2.lLastDate $f2.cLD -sticky nw -padx 2
1499  grid rowconfigure    $f2 0 -weight 1
1500  grid columnconfigure $f2 4 -weight 1
1501  grid columnconfigure $f2 2 -pad 10
1502 
1503
1504  #grid $w.tf1 -sticky news -padx 2
1505  grid $w.tf2 -sticky news -padx 2
1506     
1507  grid rowconfigure    $w 0 -weight 1
1508  grid rowconfigure    $w 1 -weight 3
1509  grid columnconfigure $w 0 -weight 1
1510
1511}
1512
1513#/////////////////////////////////////////////////////////////////////////////   
1514proc ::TolConsole::OptionsCreateOutput {w} {
1515# 
1516#/////////////////////////////////////////////////////////////////////////////   
1517  global toltk_options
1518  variable tmpOpt
1519
1520  TitleFrame $w.tf1 -text [mc "Write"]
1521  set f1 [$w.tf1 getframe]
1522
1523  checkbutton $f1.chWrite -text [mc "Write messages in output window"]\
1524      -variable ::TolConsole::tmpOpt(var,chWrite)
1525  label $f1.lColorErr -text [mc "Errors color"]:
1526  bcolor $f1.fColorErr -variable ::TolConsole::tmpOpt(var,colorErr)
1527  #::Objects::ColorCreate ::TolConsole::tmpOpt(var,colorErr) $f1.fColorErr
1528  label $f1.lColorWar -text [mc "Warnings color"]:
1529  ::Objects::ColorCreate ::TolConsole::tmpOpt(var,colorWar) $f1.fColorWar
1530
1531  frame $f1.f  -width 20
1532  grid $f1.f $f1.chWrite   -             -             -             -sticky nw -padx 2
1533  grid ^     $f1.lColorErr $f1.fColorErr $f1.lColorWar $f1.fColorWar -sticky nw -padx 2
1534
1535  grid rowconfigure    $f1 1 -weight 1
1536  grid columnconfigure $f1 4 -weight 1
1537  grid columnconfigure $f1 2 -pad 20
1538
1539
1540  TitleFrame $w.tf2 -text [mc "Update"]
1541  set f2 [$w.tf2 getframe]
1542
1543  label $f2.lUpdateType -text [mc "Update options"]:
1544  frame $f2.f1 -width 15
1545  radiobutton $f2.rbAlways -text [mc "Update always"]\
1546     -value always -highlightthickness 0 -pady 0\
1547     -variable ::TolConsole::tmpOpt(var,updateType)\
1548     -command ::TolConsole::OptionsCheckUpdateType
1549  radiobutton $f2.rbEach   -text [mc "Update each"]\
1550     -value each   -highlightthickness 0 -pady 0\
1551     -variable ::TolConsole::tmpOpt(var,updateType)\
1552     -command ::TolConsole::OptionsCheckUpdateType
1553  radiobutton $f2.rbNever -text [mc "Don't update until the end"]\
1554     -value never  -highlightthickness 0 -pady 0\
1555     -variable ::TolConsole::tmpOpt(var,updateType)\
1556     -command ::TolConsole::OptionsCheckUpdateType
1557  set tmpOpt(widget,updateSec) [SpinBox $f2.sbSeconds -justify right -width 4 \
1558      -editable 0 -range {0 2000 20} \
1559      -textvariable ::TolConsole::tmpOpt(var,updateSec)]
1560  label $f2.lSeconds -text [mc milliseconds]
1561
1562  frame $f2.f -width 20
1563  grid $f2.f $f2.lUpdateType -     -             -             -sticky nw -padx 2
1564  grid ^     $f2.f1  $f2.rbAlways  -             -             -sticky nw -padx 2
1565  grid ^     ^       $f2.rbEach    $f2.sbSeconds $f2.lSeconds  -sticky nw -padx 2
1566  grid ^     ^       $f2.rbNever   -             -             -sticky nw -padx 2
1567
1568  grid rowconfigure    $f2 3 -weight 1
1569  grid columnconfigure $f2 4 -weight 1
1570 
1571  grid $w.tf1 -sticky news -padx 2
1572  grid $w.tf2 -sticky news -padx 2
1573  grid rowconfigure    $w 1 -weight 1
1574  grid columnconfigure $w 0 -weight 1
1575}
1576
1577#/////////////////////////////////////////////////////////////////////////////     
1578proc ::TolConsole::OptionsCreatePrecision {w} {
1579# 
1580#/////////////////////////////////////////////////////////////////////////////     
1581  variable tmpOpt
1582
1583  TitleFrame $w.tf1 -text [mc "Precision"]
1584  set f1 [$w.tf1 getframe]
1585
1586  checkbutton $f1.chDecimals -text [mc "Reduce decimal digits to"]\
1587      -variable ::TolConsole::tmpOpt(var,chDecimals)\
1588      -command ::TolConsole::OptionsCheckDecimals
1589  set tmpOpt(widget,decimals) [SpinBox $f1.sbDecimals -justify right -width 4 \
1590      -editable 0 -range {0 10} \
1591      -textvariable ::TolConsole::tmpOpt(var,numDecimals)]
1592  label $f1.lDecimals -text [mc digits]
1593   
1594  checkbutton $f1.chExponential \
1595      -text [mc "Use exponential notation when number has more than"]\
1596      -variable ::TolConsole::tmpOpt(var,chExponential)\
1597      -command ::TolConsole::OptionsCheckExponential
1598  set tmpOpt(widget,exponential) [SpinBox $f1.sbExponential -justify right -width 4 \
1599      -editable 0 -range {0 10} \
1600      -textvariable ::TolConsole::tmpOpt(var,numExponential)]
1601  label $f1.lExponential -text [mc digits]
1602
1603  frame $f1.f -width 25
1604
1605  grid $f1.f $f1.chDecimals    $f1.sbDecimals    $f1.lDecimals    -sticky nw -padx 2
1606  grid ^     $f1.chExponential $f1.sbExponential $f1.lExponential -sticky nw -padx 2
1607  grid rowconfigure    $f1 1 -weight 1
1608  grid columnconfigure $f1 3 -weight 1     
1609 
1610  grid $w.tf1 -sticky news -padx 2
1611  #grid $w.tf2 -sticky news -padx 2
1612     
1613  grid rowconfigure    $w 0 -weight 1
1614  #grid rowconfigure    $w 1 -weight 2
1615  grid columnconfigure $w 0 -weight 1
1616}
1617
1618#/////////////////////////////////////////////////////////////////////////////     
1619proc ::TolConsole::OptionsCreatePaths {w} {
1620#
1621#/////////////////////////////////////////////////////////////////////////////       
1622  variable tmpOpt
1623
1624  TitleFrame $w.tf -text [mc "Paths"]
1625  set f [$w.tf getframe]
1626
1627  label $f.lPathBrowser   -text [mc "Browser path"]
1628  label $f.lPathPDFViewer -text [mc "PDF viewer path"]
1629  label $f.lPathHelp      -text [mc "Help path"]
1630  Entry $f.ePathBrowser   -state normal -width 30 \
1631    -textvariable ::TolConsole::tmpOpt(var,pathBrowser) \
1632    -helptext [mc pathexplanation]
1633  Entry $f.ePathPDFViewer -state normal -width 30 \
1634    -textvariable ::TolConsole::tmpOpt(var,pathPDFViewer)  \
1635    -helptext [mc pathexplanation]
1636  Entry $f.ePathHelp -state normal -width 30 \
1637    -textvariable ::TolConsole::tmpOpt(var,pathHelp) 
1638  Button $f.bPathBrowser -compound left -padx 10 \
1639    -height 16 -relief link \
1640    -helptext [mc "Search the program path"] \
1641    -image [Bitmap::get bopen] \
1642    -command {::TolConsole::OptionsCreatePath "Browser"}
1643  Button $f.bPathPDFViewer -compound left -padx 10 \
1644    -height 16 -relief link \
1645    -helptext [mc "Search the program path"] \
1646    -image [Bitmap::get bopen] \
1647    -command {::TolConsole::OptionsCreatePath "PDFViewer"}
1648  Button $f.bPathHelp -compound left -padx 10 \
1649    -height 16 -relief link \
1650    -helptext [mc "Search the folder"] \
1651    -image [Bitmap::get bopen] \
1652    -command  {set tmp [tk_chooseDirectory -initialdir $::TolConsole::tmpOpt(var,pathHelp) -mustexist 1]
1653               if {!($tmp eq "")} {
1654                 set ::TolConsole::tmpOpt(var,pathHelp) $tmp
1655               } }
1656
1657  grid $f.lPathBrowser   -row 0 -column 0 -sticky nw  -padx 5 -pady 5
1658  grid $f.lPathPDFViewer -row 1 -column 0 -sticky nw  -padx 5 -pady 5
1659  grid $f.lPathHelp      -row 2 -column 0 -sticky nw  -padx 5 -pady 5
1660  grid $f.ePathBrowser   -row 0 -column 1 -sticky new -padx 5 -pady 5
1661  grid $f.ePathPDFViewer -row 1 -column 1 -sticky new -padx 5 -pady 5
1662  grid $f.ePathHelp      -row 2 -column 1 -sticky new -padx 5 -pady 5
1663  grid $f.bPathBrowser   -row 0 -column 2 -sticky e   -padx 5 -pady 5
1664  grid $f.bPathPDFViewer -row 1 -column 2 -sticky e   -padx 5 -pady 5
1665  grid $f.bPathHelp      -row 2 -column 2 -sticky e   -padx 5 -pady 5
1666
1667  grid columnconfigure $f 1  -weight 1
1668  grid rowconfigure    $f 10 -weight 1
1669 
1670  grid $w.tf -sticky news
1671 
1672  grid columnconfigure $w 0 -weight 1
1673  grid rowconfigure    $w 0 -weight 1
1674}
1675
1676#/////////////////////////////////////////////////////////////////////////////     
1677proc ::TolConsole::OptionsCreatePath { type } {
1678#
1679# PURPOSE: Executes the command associated to the create path buttons:
1680#          Shows a dialog OpenFile with the directory and the appropriate
1681#          file type according to the operating system
1682#
1683# PARAMETERS: Type of path. Allowed values "Browser" "PDFViewer"
1684#
1685# TODO: For linux, to verify that the file is executable
1686#
1687#/////////////////////////////////////////////////////////////////////////////         
1688  variable tmpOpt
1689 
1690  if { $::tcl_platform(platform) == "windows" } {
1691    # get the "Program Files" directory
1692    set dirProgramFiles [registry get \
1693      {HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\SFC} \
1694      ProgramFilesDir]
1695    set txtExecFileType "\{\{\{[mc {Executable files} ]\} .exe\}\}"
1696    set commandFile "tk_getOpenFile \
1697      -initialdir [list $dirProgramFiles] -f $txtExecFileType"
1698  } else {  ;# linux
1699    set commandFile "tk_getOpenFile -initialdir \\"
1700  }
1701 
1702  #set ::TolConsole::tmpOpt(var,path$type) [eval $commandFile]
1703  set tmp [eval $commandFile]
1704  if { !($tmp eq "") } {
1705     set ::TolConsole::tmpOpt(var,path$type) $tmp
1706  } 
1707}
1708 
1709#/////////////////////////////////////////////////////////////////////////////     
1710proc ::TolConsole::OptionsCreateOthers {w} {
1711# 
1712#/////////////////////////////////////////////////////////////////////////////       
1713  variable tmpOpt
1714  variable languages
1715
1716  TitleFrame $w.tf1 -text [mc "General Options"]
1717  set f1 [$w.tf1 getframe]
1718
1719  label $f1.lRecent -text [mc "Number of last edited files"]
1720
1721  set tmpOpt(widget,recent) [SpinBox $f1.sbRecent -justify right -width 4 \
1722      -editable 0 -range {0 10} \
1723      -textvariable ::TolConsole::tmpOpt(var,numRecent)]
1724  label $f1.lFiles -text [mc files]
1725
1726  radiobutton $f1.rbOrdDate -text [mc "Order by date"]\
1727     -value date -highlightthickness 0 -pady 0\
1728     -variable ::TolConsole::tmpOpt(var,ordRecent)
1729  radiobutton $f1.rbOrdAsc   -text [mc "Order alphabetically"]\
1730     -value asc   -highlightthickness 0 -pady 0\
1731     -variable ::TolConsole::tmpOpt(var,ordRecent)
1732  radiobutton $f1.rbOrdDesc -text [mc "Order reverse alphabetically"]\
1733     -value desc  -highlightthickness 0 -pady 0\
1734     -variable ::TolConsole::tmpOpt(var,ordRecent)
1735   
1736  frame $f1.f -width 25
1737
1738  grid $f1.f $f1.lRecent   $f1.sbRecent $f1.lFiles -sticky nw -padx 2
1739  grid ^     $f1.rbOrdDate -            -          -sticky nw -padx 2
1740  grid ^     $f1.rbOrdAsc  -            -          -sticky nw -padx 2
1741  grid ^     $f1.rbOrdDesc -            -          -sticky nw -padx 2
1742
1743  grid rowconfigure    $f1 0 -weight 1
1744  grid rowconfigure    $f1 1 -weight 1
1745 
1746  grid rowconfigure    $f1 2 -weight 1
1747 
1748  grid columnconfigure $f1 3 -weight 1
1749  grid columnconfigure $f1 4 -weight 1
1750 
1751  TitleFrame $w.tf2 -text [mc "Language"]
1752  set f2 [$w.tf2 getframe]
1753
1754  label $f2.lLanguage -text [mc "Choose language"]:
1755  foreach {key value} $languages {
1756    lappend values [mc $value]
1757  }
1758
1759  ComboBox $f2.cbLanguages -width 12 -height 5 -editable false -justify right -values $values\
1760   -modifycmd   [list ::Objects::ComboUnTranslateDbl $f2.cbLanguages $languages\
1761       ::TolConsole::tmpOpt(var,language)]
1762  ::Objects::ComboSetIniDbl $f2.cbLanguages $languages ::TolConsole::tmpOpt(var,language)
1763 
1764
1765  label $f2.lLangExp -text ([mc "Language is set when you restart interface"])
1766  frame $f2.f -width 25
1767  grid $f2.f $f2.lLanguage $f2.cbLanguages -sticky nw -padx 2
1768  grid ^     $f2.lLangExp  -               -sticky nw -padx 2
1769  grid rowconfigure    $f2 1 -weight 1
1770  grid columnconfigure $f2 2 -weight 1
1771 
1772  TitleFrame $w.tf3 -text [mc "Object Inspector"]
1773  set f3 [$w.tf3 getframe]
1774  checkbutton $f3.chObjIns -text [mc "Show Object Inspector"]\
1775      -variable ::TolConsole::tmpOpt(var,chObjIns)
1776 
1777  label $f3.lObjIns -text ([mc "Object Inspector visualization is set when you restart interface"])
1778 
1779  grid $f3.chObjIns -sticky nw -padx 2
1780  grid $f3.lObjIns  -sticky nw -padx 2
1781  grid rowconfigure    $f3 1 -weight 1
1782  grid columnconfigure $f3 2 -weight 1
1783 
1784 
1785  grid $w.tf1 -sticky news -padx 2
1786  grid $w.tf2 -sticky news -padx 2
1787  grid $w.tf3 -sticky news -padx 2
1788     
1789  grid rowconfigure    $w 0 -weight 1
1790  grid rowconfigure    $w 1 -weight 1
1791  grid rowconfigure    $w 2 -weight 1
1792  grid columnconfigure $w 0 -weight 1
1793}
1794
1795#/////////////////////////////////////////////////////////////////////////////     
1796proc ::TolConsole::OptionsGet {} {
1797# 
1798#/////////////////////////////////////////////////////////////////////////////       
1799  variable data
1800  variable tmpOpt
1801  set tmpOpt(var,numRecent)      $data(numRecent)
1802  set tmpOpt(var,ordRecent)      $data(ordRecent)
1803  set tmpOpt(var,language)       $data(language)
1804  set tmpOpt(var,chDecimals)     $data(chDecimals)
1805  set tmpOpt(var,numDecimals)    $data(numDecimals)
1806  set tmpOpt(var,chExponential)  $data(chExponential)
1807  set tmpOpt(var,numExponential) $data(numExponential)
1808  set tmpOpt(var,DefFirst)       $data(DefFirst)
1809  set tmpOpt(var,DefLast)        $data(DefLast)
1810  set tmpOpt(var,colorErr)       $data(colorErr)
1811  set tmpOpt(var,colorWar)       $data(colorWar)
1812  set tmpOpt(var,chWrite)        $data(chWrite)
1813  set tmpOpt(var,updateType)     $data(updateType)
1814  set tmpOpt(var,updateSec)      $data(updateSec)
1815  set tmpOpt(var,showODBC)       $data(showODBC)
1816  set tmpOpt(var,pathBrowser)    $data(pathBrowser)
1817  set tmpOpt(var,pathPDFViewer)  $data(pathPDFViewer)
1818  set tmpOpt(var,pathHelp)       $data(pathHelp)
1819  set tmpOpt(var,chObjIns)       $data(chObjIns)
1820 
1821 
1822}
1823
1824#/////////////////////////////////////////////////////////////////////////////     
1825proc ::TolConsole::OptionsSet {} {
1826# 
1827#/////////////////////////////////////////////////////////////////////////////       
1828  variable data
1829  variable tmpOpt
1830   
1831  regsub -all var, [array names ::TolConsole::tmpOpt var,*] "" optNames
1832   
1833  foreach it $optNames {
1834    set data($it) $tmpOpt(var,$it)
1835  }
1836}
1837
1838#/////////////////////////////////////////////////////////////////////////////     
1839proc ::TolConsole::OptionsCheck {} {
1840# 
1841#/////////////////////////////////////////////////////////////////////////////       
1842  OptionsCheckUpdateType
1843  OptionsCheckDecimals
1844  OptionsCheckExponential
1845}
1846
1847#/////////////////////////////////////////////////////////////////////////////     
1848proc ::TolConsole::OptionsCheckDecimals {} {
1849# 
1850#/////////////////////////////////////////////////////////////////////////////       
1851  variable tmpOpt
1852  if {!$tmpOpt(var,chDecimals)} {
1853    $tmpOpt(widget,decimals) configure -state disabled
1854  } else  {
1855    $tmpOpt(widget,decimals) configure -state normal
1856  }
1857}
1858
1859#/////////////////////////////////////////////////////////////////////////////     
1860proc ::TolConsole::OptionsCheckExponential {} {
1861# 
1862#/////////////////////////////////////////////////////////////////////////////       
1863  variable tmpOpt
1864  if {!$tmpOpt(var,chExponential)} {
1865    $tmpOpt(widget,exponential) configure -state disabled
1866  } else  {
1867    $tmpOpt(widget,exponential) configure -state normal
1868  }
1869}
1870
1871#/////////////////////////////////////////////////////////////////////////////     
1872proc ::TolConsole::OptionsCheckUpdateType {} {
1873# 
1874#/////////////////////////////////////////////////////////////////////////////       
1875  variable tmpOpt
1876
1877  switch $tmpOpt(var,updateType) {
1878    always {
1879      $tmpOpt(widget,updateSec) configure -state disabled
1880    }
1881    each {
1882      $tmpOpt(widget,updateSec) configure -state normal
1883    }
1884    never {
1885      $tmpOpt(widget,updateSec) configure -state disabled
1886    }
1887  }
1888}
1889
1890#/////////////////////////////////////////////////////////////////////////////     
1891proc ::TolConsole::OptionsDestroy {dialog} {
1892# 
1893#/////////////////////////////////////////////////////////////////////////////       
1894  #variable data
1895  variable tmpOpt
1896
1897  array unset tmpOpt
1898  destroy $dialog
1899}
1900
1901#/////////////////////////////////////////////////////////////////////////////     
1902proc ::TolConsole::OptionsApply {} {
1903# 
1904#/////////////////////////////////////////////////////////////////////////////
1905  variable data
1906  # Apply
1907  OptionsSet
1908  OptionsApplyLanguage
1909  OptionsApplyDefDates
1910  OptionsApplyColors
1911  # Options project Apply
1912  if {[info exists data(proc,OnOptionApply)] && \
1913      [string length $data(proc,OnOptionApply)]} {
1914    foreach f $data(proc,OnOptionApply) {
1915      $f
1916    }
1917  }
1918  # Write INI
1919  WriteIni
1920}
1921
1922#/////////////////////////////////////////////////////////////////////////////     
1923proc ::TolConsole::OptionsApplyLanguage {} {
1924# 
1925#/////////////////////////////////////////////////////////////////////////////       
1926  global toltk_script_path
1927  variable data
1928
1929  ::tol::language $data(language)
1930  ::msgcat::mclocale $data(language)
1931  ::msgcat::mcload [file join $toltk_script_path msgs]
1932}
1933
1934#/////////////////////////////////////////////////////////////////////////////     
1935proc ::TolConsole::OptionsApplyDefDates {} {
1936# 
1937#/////////////////////////////////////////////////////////////////////////////       
1938  variable data
1939  set expr "Date PutDefaultDates([DateTol $data(DefFirst)],[DateTol $data(DefLast)]);"
1940  #Tolcon_Trace "$expr"
1941  ::tol::console eval $expr
1942}
1943
1944#/////////////////////////////////////////////////////////////////////////////     
1945proc ::TolConsole::OptionsApplyColors {} {
1946# 
1947#/////////////////////////////////////////////////////////////////////////////       
1948  variable data
1949  variable widgets
1950
1951  $widgets(output) tag configure errorTag   -foreground $data(colorErr)
1952  $widgets(output) tag configure warningTag -foreground $data(colorWar)
1953}
1954
1955#/////////////////////////////////////////////////////////////////////////////     
1956proc ::TolConsole::OptionsOK {dialog} {
1957# 
1958#/////////////////////////////////////////////////////////////////////////////       
1959  OptionsApply
1960  OptionsDestroy $dialog
1961}
1962
1963#/////////////////////////////////////////////////////////////////////////////
1964  proc ::TolConsole::ReadIni {} {
1965#
1966# PURPOSE: Reads general TolBase options from .ini file.
1967#
1968#/////////////////////////////////////////////////////////////////////////////
1969  global toltk_script_path
1970  global toltk_options
1971  variable data
1972  set rini ::iniFile::Read
1973 
1974  #inicializo variable necesaria para las toolbars
1975  set data(tolbase,lsttoolbars) [$rini TolConsole listtoolbars]
1976  if {![llength $data(tolbase,lsttoolbars)]} {
1977    set data(tolbase,lsttoolbars) {}
1978  }
1979   
1980  set data(path)           [$rini TolConsole path       $toltk_script_path]
1981  set data(included)       [$rini TolConsole recent     {}]
1982  set data(chIncluded)     [$rini TolConsole saveRecent 1]
1983  set data(numRecent)      [$rini TolConsole numRecent  8]
1984  set data(ordRecent)      [$rini TolConsole ordRecent  "date"]
1985  set data(tabRecent)      [$rini TolConsole tabRecent  {}]
1986  set data(prjRecent)      [$rini TolConsole prjRecent  {}]
1987  set data(incRecent)      [$rini TolConsole incRecent  {}]
1988  set data(ediRecent)      [$rini TolConsole ediRecent  {}] 
1989  set data(font,eval)      [$rini TolConsole evalFont   \
1990    $toltk_options(fonts,Fixed)]
1991  set data(font,output)    [$rini TolConsole outputFont \
1992    $toltk_options(fonts,Fixed)]
1993  set data(font,info)      [$rini TolConsole infoFont   \
1994    $toltk_options(fonts,Fixed)]
1995  set data(language)       [$rini TolConsole language   es]
1996  set data(chDecimals)     [$rini TolConsole redDecimals    0]
1997  set data(numDecimals)    [$rini TolConsole numDecimals    4]
1998  set data(chExponential)  [$rini TolConsole useExponential 0]
1999  set data(numExponential) [$rini TolConsole numExponential 8]
2000  set data(DefFirst)       [$rini TolConsole DefFirst [::tol::date first]]
2001  set data(DefLast)        [$rini TolConsole DefLast  [::tol::date last ]]
2002  set data(colorWar)       [$rini TolConsole colorWar blue]
2003  set data(colorErr)       [$rini TolConsole colorErr red]
2004  set data(chWrite)        [$rini TolConsole writeOutput 1]
2005  set data(updateType)     [$rini TolConsole updateType always]
2006  set data(updateSec)      [$rini TolConsole updateSec 200]
2007  set data(showODBC)       [$rini TolConsole ShowODBCDialog 0]
2008 
2009  # program paths
2010  set data(pathBrowser)   [$rini TolConsole pathBrowser {}]
2011  set data(pathPDFViewer) [$rini TolConsole pathPDFViewer {}]
2012  set data(pathHelp)      [$rini TolConsole pathHelp {}]
2013 
2014  # Object Inspector visualization
2015  set data(chObjIns)      [$rini TolConsole chObjIns {}]
2016 
2017  # geometry
2018
2019#  set data(geometry,x) [$rini TolConsole geometry:x -1]
2020#  set data(geometry,y) [$rini TolConsole geometry:y -1]
2021#  set data(geometry,width) [$rini TolConsole geometry:width -1]
2022#  set data(geometry,height) [$rini TolConsole geometry:height -1]
2023  set data(geometry,wtop)    [$rini TolConsole geometry:wtop 5]
2024  set data(geometry,wbottom) [$rini TolConsole geometry:wbottom 1]
2025  set data(geometry,wleft)   [$rini TolConsole geometry:wleft 3]
2026  set data(geometry,wright)  [$rini TolConsole geometry:wright 7]
2027  set data(viewmode)         [$rini TolConsole viewmode middle]
2028 
2029  #cargamos los parametros de las toolbars
2030  set data(toolbars,side) [$rini ToolBars side top]
2031  set data(toolbars,fill) [$rini ToolBars fill x]
2032  set data(toolbars,buttonbar,side) [$rini ToolBars buttonbar:side left]
2033  set data(toolbars,buttonbar,fill) [$rini ToolBars buttonbar:fill y]
2034 
2035  set data(tolbase,ini) 0
2036  set data(tolbase,original) 0
2037}
2038
2039#/////////////////////////////////////////////////////////////////////////////
2040proc ::TolConsole::WriteIni {} {
2041#
2042# PURPOSE: Writes general TolBase options to .ini file.
2043#
2044#/////////////////////////////////////////////////////////////////////////////
2045  variable data
2046  variable widgets
2047
2048  set wini ::iniFile::Write
2049  $wini TolConsole path           $data(path)
2050  $wini TolConsole recent         $data(included)
2051  $wini TolConsole saveRecent     $data(chIncluded)
2052  $wini TolConsole numRecent      $data(numRecent)
2053  $wini TolConsole ordRecent      $data(ordRecent)
2054  $wini TolConsole evalFont       $data(font,eval)
2055  $wini TolConsole outputFont     $data(font,output)
2056  $wini TolConsole infoFont       $data(font,info)
2057  $wini TolConsole language       $data(language)
2058  $wini TolConsole redDecimals    $data(chDecimals)
2059  $wini TolConsole numDecimals    $data(numDecimals)
2060  $wini TolConsole useExponential $data(chExponential)
2061  $wini TolConsole numExponential $data(numExponential)
2062  $wini TolConsole DefFirst       $data(DefFirst)
2063  $wini TolConsole DefLast        $data(DefLast)
2064  $wini TolConsole colorWar       $data(colorWar)
2065  $wini TolConsole colorErr       $data(colorErr)
2066  $wini TolConsole writeOutput    $data(chWrite)
2067  $wini TolConsole updateType     $data(updateType)
2068  $wini TolConsole updateSec      $data(updateSec)
2069  $wini TolConsole ShowODBCDialog $data(showODBC)
2070  $wini TolConsole tabRecent      $data(tabRecent)
2071  $wini TolConsole prjRecent      $data(prjRecent)
2072  $wini TolConsole incRecent      $data(incRecent)
2073  $wini TolConsole ediRecent      $data(ediRecent)
2074
2075  # program paths
2076  $wini TolConsole pathBrowser    $data(pathBrowser)
2077  $wini TolConsole pathPDFViewer  $data(pathPDFViewer)
2078  $wini TolConsole pathHelp       $data(pathHelp)
2079 
2080  # Object Inspector visualization
2081  $wini TolConsole chObjIns       $data(chObjIns)
2082 
2083  # geometry configuration
2084  #  $wini TolConsole geometry:x $data(geometry,x)
2085  #  $wini TolConsole geometry:y $data(geometry,y)
2086  #  $wini TolConsole geometry:width $data(geometry,width)
2087  #  $wini TolConsole geometry:height $data(geometry,height)
2088  $wini TolConsole geometry:wtop    $data(geometry,wtop)
2089  $wini TolConsole geometry:wbottom $data(geometry,wbottom)
2090  $wini TolConsole geometry:wleft   $data(geometry,wleft)
2091  $wini TolConsole geometry:wright  $data(geometry,wright)
2092  $wini TolConsole viewmode         $data(viewmode)
2093  #::iniFile::Flush
2094 
2095  # escribimos las opciones para las barra de botones
2096  if { [winfo exists ${::project::widgets(mainframe)}.toolbarFrame]} {
2097    set packopts [pack info ${::project::widgets(mainframe)}.toolbarFrame]
2098    array set packoptsarray $packopts
2099    $wini ToolBars side $packoptsarray(-side)
2100        $wini ToolBars fill $packoptsarray(-fill)
2101    #set packopts [pack info ${::project::widgets(mainframe)}.toolbarFrame.tb1]
2102    #array set packoptsarray $packopts
2103    #$wini ToolBars buttonbar:side $packoptsarray(-side)
2104        #$wini ToolBars buttonbar:fill $packoptsarray(-fill)
2105  }
2106 
2107  # escribimos las opciones de los documentos abiertos
2108  $::project::widgets(mainmdi) writeDocsIni
2109 
2110  # escribilos las barras de botones que tenemos creadas
2111  # clear the bars created by code
2112  if {[info exists widgets(tbCustom,path)]} {
2113    set lsttollbarsaux {}
2114    foreach ltb $data(tolbase,lsttoolbars) {
2115      if {![string eq $widgets(tbCustom,path) [lindex $ltb 0]]} {
2116        lappend lsttollbarsaux $ltb
2117      } 
2118    }
2119    $wini TolConsole listtoolbars  $lsttollbarsaux
2120  }
2121}
2122
2123#/////////////////////////////////////////////////////////////////////////////
2124  proc ::TolConsole::ODBCShow {} {
2125#
2126# PURPOSE: Show the connection ODBC dialog
2127#
2128#/////////////////////////////////////////////////////////////////////////////
2129  variable data
2130  if {$data(showODBC)} {
2131    set values [::ODBCDialog::ReadIni] 
2132    ::ODBCDialog::Create $::project::widgets(mainframe) \
2133      [lindex $values 0] [lindex $values 1] "" \
2134      ::TolConsole::OnConnect ::TolConsole::OnDisconnect
2135  }
2136}
2137
2138#/////////////////////////////////////////////////////////////////////////////
2139  proc ::TolConsole::ObjectInspectorShow {} {
2140#
2141# PURPOSE: Show Object inspector
2142#
2143#/////////////////////////////////////////////////////////////////////////////
2144  variable data
2145  if {$data(chObjIns) ne "" &&
2146      [string is boolean $data(chObjIns)] && !$data(chObjIns)} {
2147    $::TolConsole::widgets(inspector) withdraw
2148  }
2149}
2150
2151#/////////////////////////////////////////////////////////////////////////////
2152  proc ::TolConsole::GetGCFFile {} {
2153#
2154# PURPOSE: Obtain the GCFFile file of .ini and showed to message in the
2155#          window output
2156#
2157#/////////////////////////////////////////////////////////////////////////////
2158  # GCFFile
2159  set gcfFile [::iniFile::Read SeriesGraph GCFFile {}]
2160  if {[string length $gcfFile]} {
2161    ::tol::console eval "Text (GCFFile := \"$gcfFile\");"
2162    ::TolConsole::HciWriter "Text GCFFile = \"$gcfFile\"\n"
2163  }
2164}
2165
2166
2167#/////////////////////////////////////////////////////////////////////////////
2168  proc ::TolConsole::MenuMDI { } {
2169#
2170# PURPOSE: Crea un menu para mdi
2171#
2172#/////////////////////////////////////////////////////////////////////////////
2173  #cargo la lista de formularios
2174  set ::toolbar::data(toolbar,tolbase,lstcmd) {}
2175 
2176  set md [.mainmenu cget -definition]
2177  set hook $::project::data(menuhook)
2178  set hookhelp $::project::data(menuhookhelp)
2179
2180  set id [$md insert $hook cascade -label [mc &File]]
2181
2182  set cid [$md add $id cascade -label [mc &New] ]
2183  $md add $cid command -label [mc "TOL &file"] \
2184      -command "::Editor::New"
2185  $md add $cid command -label [mc "&Table"] \
2186      -command "::TolConsole::TableNew"
2187  $md add $cid command -label [mc "&Project"] \
2188      -command "::TolProject::New"
2189 
2190  set cid [$md add $id cascade -label [mc &Open] ]
2191  $md add $cid command -label [mc "TOL &file"] \
2192      -command "::Editor::Open"
2193  $md add $cid command -label [mc "&Table"] \
2194      -command "::TolConsole::TableOpen"
2195  $md add $cid command -label [mc "&Project"] \
2196      -command "::TolProject::Open"
2197 
2198  $md add $id command -label [mc &Include] -command "::TolConsole::IncludeCmd"
2199 
2200  $md add $id separator
2201 
2202  set cid [$md add $id cascade -label [mc "&Recent files"] ]
2203  $md add $cid cascade -label [mc "TOL &files"] \
2204      -postcommand "::Editor::postEdited %W"
2205  $md add $cid cascade -label [mc "&Tables"] \
2206      -postcommand "::TolConsole::TableRecent %W"
2207  $md add $cid cascade -label [mc "&Projects"] \
2208      -postcommand "::TolProject::postEdited %W"
2209  $md add $cid cascade -label [mc "&Included"] \
2210      -postcommand "::TolConsole::postIncluded %W"
2211
2212  $md add $id separator
2213 
2214  #$md add $id command -label [mc E&xit] -command "::project::Exit"
2215  #$md add $id command -label [mc E&xit] -command "::TolConsole::Exit"
2216  $md add $id command -label [mc E&xit] -command "::project::OnDelete"
2217
2218 
2219  set id [$md insert $hook cascade -label [mc &Tools]]
2220  set ::project::data(menu,tools) $id
2221   
2222  set cid [$md add $id cascade -label [mc "TOL &Editor"]]
2223  $md add $cid cascade -label [mc "&Recent files"] \
2224      -postcommand "::Editor::postEdited %W"
2225  $md add $cid command -label [mc "&New TOL file"] \
2226      -command "::Editor::New"
2227  $md add $cid command -label [mc "&Open TOL file"] \
2228      -command "::Editor::Open"
2229 
2230  set cid [$md add $id cascade -label [mc "TOL &Table Editor"]]
2231  $md add $cid cascade -label [mc "&Recent files"] \
2232      -postcommand "::TolConsole::TableRecent %W"
2233  $md add $cid command -label [mc "&New Table"] \
2234      -command "::TolConsole::TableNew"
2235  $md add $cid command -label [mc "&Open Table"] \
2236      -command "::TolConsole::TableOpen"
2237 
2238  set cid [$md add $id cascade -label [mc "TOL &Project Editor"]]
2239  $md add $cid cascade -label [mc "&Recent files"] \
2240      -postcommand "::TolProject::postEdited %W"
2241  $md add $cid command -label [mc "&New Project"] \
2242      -command "::TolProject::New"
2243  $md add $cid command -label [mc "&Open Project"] \
2244      -command "::TolProject::Open"
2245 
2246  $md add $id separator
2247  set cid [$md add $id cascade -label [mc "Analysis Tools"]]
2248  set cid2 [$md add $cid cascade -label [mc "ARIMA"]]
2249  $md add $cid2 command -label [mc "Draw ACF and PACF of ARIMA Models"] \
2250      -command "::drawArima::Show"
2251  $md add $id separator
2252 
2253  $md add $id command -label [mc "TOL Inspector"] \
2254    -command "$::project::widgets(mainmdi).slave1 restore; $::project::widgets(mainmdi).slave1 raise"
2255  $md add $id command -label [mc "&Functions Search"] \
2256      -command "::funcSearch::Show"
2257  $md add $id command -label [mc "&Calendar Expert"] \
2258      -command "::CalendarTms::ViewTimeSet"
2259  $md add $id command -label [mc "&Bayes SQL"] \
2260      -command "::SQLTable::TableBayesSQL"
2261 
2262  $md add $id separator
2263 
2264  $md add $id command -label [mc "C&onnection to database"] \
2265      -command "$::project::data(bodbc) showdialog"
2266
2267  $md add $id command -label [mc "&Options"] \
2268      -command "::TolConsole::OptionsCreate"
2269
2270  return $md
2271}
2272
2273#/////////////////////////////////////////////////////////////////////////////
2274  proc ::TolConsole::TableNew { } {
2275#
2276# PURPOSE: Creates a new table
2277#
2278#/////////////////////////////////////////////////////////////////////////////
2279  set tl [::project::CreateForm -type Tables \
2280            -width 400 -height 180 \
2281            -iniconfig Tables -helpkey "Tb4Edt"]
2282  set tlf [$tl getframe]
2283  # configuration
2284  btable $tlf.t -parent $tl \
2285                -posteditcmd [list ::TolConsole::TableRecentUpdate $tlf.t] \
2286                -iniconfig btable
2287  pack $tlf.t -fill both -expand yes
2288  $tl bind <Control-F4> [list $tl kill]
2289  #pedro
2290 
2291}
2292
2293#/////////////////////////////////////////////////////////////////////////////
2294  proc ::TolConsole::TableOpen { {path ""} } {
2295#
2296# PURPOSE: Opens a table
2297# PARAMETERS:
2298#   path   -> path of the file to be opened, if no file is given an Openfile
2299#             dialogs is shown
2300#
2301#/////////////////////////////////////////////////////////////////////////////
2302  set tl [::project::CreateForm -type Tables \
2303            -width 400 -height 180 \
2304            -iniconfig Tables -helpkey "Tb4Edt"]
2305  set tlf [$tl getframe]
2306  $tl configure -state withdrawn
2307  # configuration
2308  btable $tlf.t -parent $tl \
2309                -posteditcmd [list ::TolConsole::TableRecentUpdate $tlf.t] \
2310                -iniconfig btable
2311  if { $path == "" } {
2312    $tlf.t cmdOpen
2313    $tl configure -state normal
2314    if { [$tlf.t cget -path] == "" } {
2315      $tl kill
2316    } else {
2317      pack $tlf.t -fill both -expand yes
2318      $tl bind <Control-F4> [list $tl kill]
2319    }
2320  } else {
2321    $tlf.t configure -path $path
2322    $tl configure -state normal
2323    pack $tlf.t -fill both -expand yes
2324    $tl bind <Control-F4> [list $tl kill] 
2325  }
2326}
2327
2328#/////////////////////////////////////////////////////////////////////////////
2329  proc ::TolConsole::TableRecentUpdate { w args } {
2330#
2331# PURPOSE: Updates the last edited files when a table is closed
2332#
2333# PARAMETERS:
2334#   m   -> menu's path that will have the list of last table edited files
2335#   ord -> flag that indicates if files must be shown sorted
2336#
2337#/////////////////////////////////////////////////////////////////////////////
2338  variable data
2339
2340  set newfile [$w cget -path]
2341  set pos [lsearch $data(tabRecent) $newfile]
2342
2343  if { $pos == -1 } {
2344    set data(tabRecent) [linsert $data(tabRecent) 0 $newfile]
2345  } else {
2346    set data(tabRecent) [lreplace $data(tabRecent) $pos $pos]
2347    set data(tabRecent) [linsert $data(tabRecent) 0 $newfile]   
2348  }
2349  if { $data(numRecent) <= [llength $data(tabRecent)] } {
2350    set data(tabRecent) [lreplace $data(tabRecent) $data(numRecent) end]   
2351  }
2352}
2353
2354#/////////////////////////////////////////////////////////////////////////////
2355  proc ::TolConsole::TableRecent { m } {
2356#
2357# PURPOSE: Fills a menu with the last table edited files, according to the
2358#          information of 'options' variable.
2359#
2360# PARAMETERS:
2361#   m   -> menu's path that will have the list of last table edited files
2362#   ord -> flag that indicates if files must be shown sorted
2363#
2364#/////////////////////////////////////////////////////////////////////////////
2365  variable data
2366 
2367  set data(tabRecent) [lrange $data(tabRecent) 0 [expr $data(numRecent)-1]]
2368 
2369  $m delete 0 end
2370  if { $data(ordRecent) == "asc" } {
2371    set lst [lsort -ascii $data(tabRecent)]
2372  } elseif { $data(ordRecent) == "desc" } {
2373    set lst [lsort -ascii -decreasing $data(tabRecent)]
2374  } else {
2375    set lst $data(tabRecent)
2376  }
2377  foreach w $lst {
2378    $m add command -label $w -command [list ::TolConsole::TableOpen $w]
2379  }
2380  if [llength $lst] {
2381    $m add separator
2382    $m add command -label [mc "Clear"]\
2383          -command [list ::TolConsole::TableRecentClear]
2384  }
2385}
2386
2387#/////////////////////////////////////////////////////////////////////////////
2388  proc ::TolConsole::TableRecentClear { } {
2389#
2390# PURPOSE: Clears the list of last edited files
2391#
2392#/////////////////////////////////////////////////////////////////////////////
2393  variable data
2394  set data(tabRecent) ""
2395}
Note: See TracBrowser for help on using the repository browser.