1 #########################################################################################
3 # IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
5 # By downloading, copying, installing or using the software you agree to this license.
6 # If you do not agree to this license, do not download, install,
7 # copy or use the software.
10 # Intel License Agreement
11 # For Open Source Computer Vision Library
13 # Copyright (C) 2000, Intel Corporation, all rights reserved.
14 # Third party copyrights are property of their respective owners.
16 # Redistribution and use in source and binary forms, with or without modification,
17 # are permitted provided that the following conditions are met:
19 # * Redistribution's of source code must retain the above copyright notice,
20 # this list of conditions and the following disclaimer.
22 # * Redistribution's in binary form must reproduce the above copyright notice,
23 # this list of conditions and the following disclaimer in the documentation
24 # and/or other materials provided with the distribution.
26 # * The name of Intel Corporation may not be used to endorse or promote products
27 # derived from this software without specific prior written permission.
29 # This software is provided by the copyright holders and contributors "as is" and
30 # any express or implied warranties, including, but not limited to, the implied
31 # warranties of merchantability and fitness for a particular purpose are disclaimed.
32 # In no event shall the Intel Corporation or contributors be liable for any direct,
33 # indirect, incidental, special, exemplary, or consequential damages
34 # (including, but not limited to, procurement of substitute goods or services;
35 # loss of use, data, or profits; or business interruption) however caused
36 # and on any theory of liability, whether in contract, strict liability,
37 # or tort (including negligence or otherwise) arising in any way out of
38 # the use of this software, even if advised of the possibility of such damage.
44 if {$tcl_platform(platform) == "windows"} {
45 set default_normal_bg SystemButtonFace
46 set default_normal_fg SystemButtonText
47 set default_light_bg SystemScrollbar
48 set default_dark_bg SystemDisabledText
49 set default_window_bg SystemWindow
50 set default_window_fg SystemWindowText
51 set default_select_bg SystemHighlight
52 set default_select_fg SystemHighlightText
54 set default_normal_bg #909090
55 set default_normal_fg #000000
56 set default_light_bg #000000
57 set default_dark_bg #303030
58 set default_window_bg #909090
59 set default_window_fg #000000
60 set default_select_bg #000080
61 set default_select_fg #ffffff
64 set defaults {default_normal_bg default_normal_fg default_light_bg default_dark_bg\
65 default_window_bg default_window_fg default_select_bg default_select_fg}
68 set EditorTextbg $default_window_bg
69 set EditorTextfg $default_window_fg
70 set EditorStringfg #00FF00
71 set EditorNumberfg #00FFFF
72 set EditorCommentfg #808080
73 set EditorKeywordfg #FFFF00
74 set EditorSelectbg $default_select_bg
75 set EditorSelectfg $default_select_fg
76 set EditorCursorbg $default_light_bg
79 set EditorTextfont "{Courier} 12 normal roman"
80 set EditorStringfont "{Courier} 12 normal roman"
81 set EditorNumberfont "{Courier} 12 normal roman"
82 set EditorCommentfont "{Courier} 12 normal italic"
83 set EditorKeywordfont "{Courier} 12 normal roman"
87 proc ClearColors {offset1 offset2 fedit} {
88 foreach i [$fedit tag names] {
89 #if {$i!="select"} then {
90 $fedit tag remove $i "0.0 + $offset1 chars" "0.0 + $offset2 chars"
95 namespace eval CVEnv {
100 variable inputdata ""
101 variable inputlist {}
121 variable savebefore 1
122 variable clearoutputbefore 1
123 variable clearerrorbefore 1
133 variable pagescount 0
139 proc CVEnv::leftpane {on} {
141 pack forget $CVEnv::nbrig
143 pack $CVEnv::nbrig -in $CVEnv::prig -fill both -expand yes -padx 1 -pady 1
144 pack $CVEnv::pwch -fill both -expand yes
146 pack forget $CVEnv::nbrig
147 pack forget $CVEnv::pwch
149 pack $CVEnv::nbrig -in $CVEnv::ptop -fill both -expand yes -padx 1 -pady 1
153 proc CVEnv::longmenu {on} {
155 .menubar.file entryconfig 2 -state active
156 .menubar.file entryconfig 4 -state active
157 .menubar.file entryconfig 5 -state active
159 .menubar insert 1 cascade -label "Edit" -menu .menubar.edit\
162 .menubar.file entryconfig 2 -state disabled
163 .menubar.file entryconfig 4 -state disabled
164 .menubar.file entryconfig 5 -state disabled
170 proc CVEnv::longstbar {on} {
172 pack $CVEnv::mainf.status.indf.f0 -side left -fill y -expand 1
174 pack forget $CVEnv::mainf.status.indf.f0
178 proc CVEnv::longbar {on} {
180 pack $CVEnv::tb.bbox1 -side left -anchor w
181 pack $CVEnv::tb.sep1 -side left -fill y -padx 4 -anchor w
182 pack $CVEnv::tb.bbox2 -side left -anchor w
183 pack $CVEnv::tb.sep2 -side left -fill y -padx 4 -anchor w
184 pack $CVEnv::tb.bbox3 -side left -anchor w
185 pack $CVEnv::tb.sep3 -side left -fill y -padx 4 -anchor w
187 pack forget $CVEnv::tb.sep3
188 pack forget $CVEnv::tb.bbox3
189 pack forget $CVEnv::tb.sep2
190 pack forget $CVEnv::tb.bbox2
191 pack forget $CVEnv::tb.sep1
192 pack forget $CVEnv::tb.bbox1
196 proc CVEnv::about {} {
197 set dlg [Dialog .aboutdlg -parent . -modal local \
199 -title "About CVEnv" \
203 $dlg add -name ok -width 5
205 set top [$dlg getframe]
207 image create photo original -file [file join $::image_path pictures/CVEnv.gif]
208 canvas $top.c -bd 2 -relief ridge -width 295 -height 195
209 $top.c create image 0 0 -anchor nw -image original
210 pack $top.c -side top -expand yes -fill x
212 set frame [frame $top.f -background white -bd 2 -relief ridge]
213 set lab [label $frame.lab1 -text \
214 "Program CVEnv v. 1.0 \nIntel corporation. 2000-2001 y." \
215 -background white -font {times 8}]
217 pack $frame -side top -expand yes -fill x -padx 2 -pady 2
223 proc CVEnv::modify_font {lbtypes lbcolors samf font} {
224 global EditorTextfont
225 global EditorStringfont
226 global EditorNumberfont
227 global EditorCommentfont
228 global EditorKeywordfont
230 set curtype [$lbtypes get [$lbtypes curselection]]
231 set curcolor [$lbcolors get [$lbcolors curselection]]
234 set name $curtype$curcolor$name
237 $samf.label configure -font $font
240 proc CVEnv::modify_fg {lbtypes lbcolors samf cbfgf cbbgf color} {
242 global EditorStringfg
243 global EditorNumberfg
244 global EditorCommentfg
245 global EditorKeywordfg
246 global EditorSelectfg
248 set curtype [$lbtypes get [$lbtypes curselection]]
249 set curcolor [$lbcolors get [$lbcolors curselection]]
252 set name $curtype$curcolor$name
255 $samf.label configure -fg $color
256 $cbfgf configure -entrybg $color -selectbackground $color -text ""
259 proc CVEnv::modify_bg {lbtypes lbcolors samf cbfgf cbbgf color} {
261 global EditorSelectbg
262 global EditorCursorbg
264 set curtype [$lbtypes get [$lbtypes curselection]]
265 set curcolor [$lbcolors get [$lbcolors curselection]]
268 set name $curtype$curcolor$name
271 $samf.label configure -bg $color
272 $samf configure -bg $color
273 $cbbgf configure -entrybg $color -selectbackground $color -text ""
276 proc getvar {name value} {
283 proc CVEnv::default_bg {lbtypes lbcolors samf cbfgf cbbgf} {
285 global default_normal_bg
286 global default_normal_fg
287 global default_light_bg
288 global default_dark_bg
289 global default_window_bg
290 global default_window_fg
291 global default_select_bg
292 global default_select_fg
294 set index [$cbbgf getvalue]
295 set name [lindex $defaults $index]
300 if [string compare $color ""] {
301 CVEnv::modify_bg $lbtypes $lbcolors $samf $cbfgf $cbbgf $color
305 proc CVEnv::default_fg {lbtypes lbcolors samf cbfgf cbbgf} {
307 global default_normal_bg
308 global default_normal_fg
309 global default_light_bg
310 global default_dark_bg
311 global default_window_bg
312 global default_window_fg
313 global default_select_bg
314 global default_select_fg
316 set index [$cbfgf getvalue]
317 set name [lindex $defaults $index]
322 if [string compare $color ""] {
323 CVEnv::modify_fg $lbtypes $lbcolors $samf $cbfgf $cbbgf $color
327 proc CVEnv::getconf {lbtypes lbcolors samf cbfgf cbbgf} {
330 global EditorStringfg
331 global EditorNumberfg
332 global EditorCommentfg
333 global EditorKeywordfg
334 global EditorSelectbg
335 global EditorSelectfg
336 global EditorCursorbg
337 global EditorTextfont
338 global EditorStringfont
339 global EditorNumberfont
340 global EditorCommentfont
341 global EditorKeywordfont
343 set curtype [$lbtypes get [$lbtypes curselection]]
344 set curcolor [$lbcolors get [$lbcolors curselection]]
346 if {([string compare $curcolor "Text"]) && ([string compare $curcolor "Select"])} {
347 if {([string compare $curcolor "Cursor"])} {
349 $cbbgf configure -state disabled
350 $cbfgf configure -state normal
353 set name $curtype$curcolor$name
356 if [string compare $tmp ""] {
357 CVEnv::modify_fg $lbtypes $lbcolors $samf $cbfgf $cbbgf $tmp
360 CVEnv::modify_bg $lbtypes $lbcolors $samf $cbfgf $cbbgf $EditorTextbg
363 set name $curtype$curcolor$name
367 CVEnv::modify_font $lbtypes $lbcolors $samf $tmp
371 $cbfgf configure -state disabled
372 $cbbgf configure -state normal
375 set name $curtype$curcolor$name
378 if [string compare $tmp ""] {
379 CVEnv::modify_bg $lbtypes $lbcolors $samf $cbfgf $cbbgf $tmp
382 CVEnv::modify_fg $lbtypes $lbcolors $samf $cbfgf $cbbgf $EditorTextfg
383 CVEnv::modify_font $lbtypes $lbcolors $samf $EditorTextfont
388 $cbbgf configure -state normal
389 $cbfgf configure -state normal
392 set name $curtype$curcolor$name
395 if [string compare $tmp ""] {
396 CVEnv::modify_bg $lbtypes $lbcolors $samf $cbfgf $cbbgf $tmp
400 set name $curtype$curcolor$name
403 if [string compare $tmp ""] {
404 CVEnv::modify_fg $lbtypes $lbcolors $samf $cbfgf $cbbgf $tmp
407 if {([string compare $curcolor "Select"])} {
409 set name $curtype$curcolor$name
413 CVEnv::modify_font $lbtypes $lbcolors $samf $tmp
415 CVEnv::modify_font $lbtypes $lbcolors $samf $EditorTextfont
420 proc CVEnv::custom_bg {lbtypes lbcolors samf cbfgf cbbgf} {
422 #set initialColor [$button cget -$name]
424 set color [tk_chooseColor -title "Choose a color" -parent .colordlg \
426 if [string compare $color ""] {
427 CVEnv::modify_bg $lbtypes $lbcolors $samf $cbfgf $cbbgf $color
432 proc CVEnv::custom_fg {lbtypes lbcolors samf cbfgf cbbgf} {
434 #set initialColor [$button cget -$name]
436 set color [tk_chooseColor -title "Choose a color" -parent .colordlg \
438 if [string compare $color ""] {
439 CVEnv::modify_fg $lbtypes $lbcolors $samf $cbfgf $cbbgf $color
444 proc CVEnv::colordialog {} {
445 set dlg [Dialog .colordlg -parent . -modal local \
447 -title "Colors configuration" \
451 #$dlg add -name reset -width 7 -text Reset
452 $dlg add -name ok -width 7
453 $dlg add -name cancel -width 7
455 set top [$dlg getframe]
457 set frame [frame $top.flef ]
458 set titlebox [TitleFrame $top.flef.titlebox -font {times 8} \
459 -side left -text Types]
460 set f [$titlebox getframe]
461 set sw [ScrolledWindow $f.sw -auto both]
462 set lbtypes [listbox $sw.lbtypes -width 21 -height 6 -exportselection no]
463 $lbtypes insert end "Editor"
464 $lbtypes selection set 0
466 $sw setwidget $sw.lbtypes
467 pack $sw.lbtypes -fill both -expand yes
468 pack $sw -side top -expand yes -fill both
469 pack $titlebox -side top
471 set framebox [TitleFrame $frame.framebox -font {times 8} \
472 -side left -text Sample]
473 set f [$framebox getframe]
475 set samf [frame $f.samf -width 148 -height 56 \
476 -bg white -bd 0 -relief flat \
477 -highlightthickness 1 -takefocus 0 \
478 -highlightbackground black \
479 -highlightcolor black]
481 set lab [label $samf.label \
482 -background white -foreground black \
483 -borderwidth 0 -takefocus 0 -highlightthickness 0 \
485 place $lab -relx 0.5 -rely 0.5 -anchor c
486 pack $samf -pady 4 -fill x
488 pack $framebox -side top
489 pack $frame -side left -expand yes -fill x -padx 2 -pady 2
492 set frame [frame $top.frig]
493 set tf [TitleFrame $top.frig.f -font {times 8} \
494 -side left -text Font]
497 #set _wfont [SelectFont $f.font -type toolbar]
498 set _wfont [SelectFont $f.font -type toolbar -command ""]
500 pack $_wfont -side left -anchor w
502 pack $tf -side top -fill x -expand yes
504 set titlebox [TitleFrame $top.frig.titlebox -font {times 8} \
505 -side left -text Colors]
506 set f [$titlebox getframe]
507 set sw [ScrolledWindow $f.sw -auto both]
508 set lbcolors [listbox $sw.lbcolors -width 41 -height 6 -exportselection no]
510 $lbcolors insert end Text
511 $lbcolors insert end String
512 $lbcolors insert end Number
513 $lbcolors insert end Comment
514 $lbcolors insert end Keyword
515 $lbcolors insert end Select
516 $lbcolors insert end Cursor
517 $lbcolors selection set 0
519 $sw setwidget $sw.lbcolors
520 pack $sw.lbcolors -fill both -expand yes
521 pack $sw -side top -expand yes -fill both
523 set lef [frame $f.flef -bd 2 -relief ridge]
524 set fontlab [label $lef.fontlab -text Foreground -font {times 8}]
525 pack $fontlab -side top -anchor nw
526 set fontcb [ComboBox $lef.fontcb -width 19 -editable no \
527 -values {default_normal_bg default_normal_fg default_light_bg default_dark_bg\
528 default_window_bg default_window_fg default_select_bg default_select_fg}]
530 pack $fontcb -side top
531 pack $lef -side left -fill x -expand yes
532 set rig [frame $f.frig -bd 2 -relief ridge]
533 set sizelab [label $rig.sizelab -text Background -font {times 8}]
534 pack $sizelab -side top -anchor nw
535 set sizecb [ComboBox $rig.fontcb -width 19 -editable no\
536 -values {default_normal_bg default_normal_fg default_light_bg default_dark_bg\
537 default_window_bg default_window_fg default_select_bg default_select_fg}]
539 $fontcb configure -modifycmd "CVEnv::default_fg $lbtypes $lbcolors $samf $fontcb $sizecb"
540 $fontcb bind <ButtonRelease-3> "CVEnv::custom_fg $lbtypes $lbcolors $samf $fontcb $sizecb"
541 $fontcb bind <ButtonRelease-2> "CVEnv::custom_fg $lbtypes $lbcolors $samf $fontcb $sizecb"
543 $sizecb configure -modifycmd "CVEnv::default_bg $lbtypes $lbcolors $samf $fontcb $sizecb"
544 $sizecb bind <ButtonRelease-3> "CVEnv::custom_bg $lbtypes $lbcolors $samf $fontcb $sizecb"
545 $sizecb bind <ButtonRelease-2> "CVEnv::custom_bg $lbtypes $lbcolors $samf $fontcb $sizecb"
547 bind $lbcolors <<ListboxSelect>> "CVEnv::getconf $lbtypes $lbcolors $samf $fontcb $sizecb"
548 CVEnv::getconf $lbtypes $lbcolors $samf $fontcb $sizecb
549 pack $sizecb -side top
550 pack $rig -side right -fill x -expand yes
551 pack $titlebox -side top
553 $_wfont configure -command "CVEnv::modify_font $lbtypes $lbcolors $samf \[$_wfont cget -font\]"
554 pack $frame -side left -expand yes -fill x -padx 2 -pady 2
562 for {set i 1} {$i <= $CVEnv::pagesnum} {incr i} {
563 set frame [$CVEnv::nbrig getframe p$i].sw.tx
565 $frame configure -wrap none -font $::EditorTextfont\
566 -bg $::EditorTextbg -selectbackground $::EditorSelectbg \
567 -fg $::EditorTextfg -selectforeground $::EditorSelectfg \
568 -insertbackground $::EditorCursorbg
570 $frame tag configure text -font $::EditorTextfont -foreground $::EditorTextfg
571 $frame tag configure string -font $::EditorStringfont -foreground $::EditorStringfg
572 $frame tag configure number -font $::EditorNumberfont -foreground $::EditorNumberfg
573 $frame tag configure comment -font $::EditorCommentfont -foreground $::EditorCommentfg
574 $frame tag configure keyword -font $::EditorKeywordfont -foreground $::EditorKeywordfg
581 proc CVEnv::confdialog {} {
582 set dlg [Dialog .confdlg -parent . -modal local \
584 -title "Configuration" \
588 $dlg add -name ok -width 7
589 $dlg add -name cancel -width 7
591 set top [$dlg getframe]
593 set frame [frame $top.flef ]
594 set titlebox [TitleFrame $top.flef.titlebox \
595 -side left -text "Before execute options"]
596 set f [$titlebox getframe]
597 set chk1 [checkbutton $f.chk1 -text "Save text" \
598 -variable CVEnv::savebefore]
599 pack $chk1 -side top -anchor nw
601 set chk2 [checkbutton $f.chk2 -text "Clear output page" \
602 -variable CVEnv::clearoutputbefore]
603 pack $chk2 -side top -anchor nw
605 set chk3 [checkbutton $f.chk3 -text "Clear error page" \
606 -variable CVEnv::clearerrorbefore]
607 pack $chk3 -side top -anchor nw
609 pack $titlebox -side top
610 pack $frame -side left -expand yes -fill x -padx 2 -pady 2
613 set frame [frame $top.frig]
614 pack $frame -side left -expand yes -fill x -padx 2 -pady 2
621 proc CVEnv::raiseeditor { } {
622 set CVEnv::curpage [$CVEnv::nbrig raise]
623 set CVEnv::curframe [$CVEnv::nbrig getframe $CVEnv::curpage].sw.tx
624 set pos [lsearch $CVEnv::pages $CVEnv::curpage]
625 set CVEnv::curfile [lindex $CVEnv::files $pos]
628 proc CVEnv::createeditor {page text} {
631 global EditorStringfg
632 global EditorNumberfg
633 global EditorCommentfg
634 global EditorKeywordfg
635 global EditorSelectbg
636 global EditorSelectfg
637 global EditorCursorbg
639 global EditorTextfont
640 global EditorStringfont
641 global EditorNumberfont
642 global EditorCommentfont
643 global EditorKeywordfont
645 set path [$CVEnv::nbrig insert end $page -text $text \
646 -leavecmd { set CVEnv::curln "--"
647 set CVEnv::curcol "--"} \
648 -raisecmd CVEnv::raiseeditor]
649 set sw [ScrolledWindow $path.sw -auto none]
651 set CVEnv::curframe [text $sw.tx -wrap none -font $EditorTextfont\
652 -bg $EditorTextbg -selectbackground $EditorSelectbg \
653 -fg $EditorTextfg -selectforeground $EditorSelectfg \
654 -insertbackground $EditorCursorbg]
657 pack $sw.tx -fill both -expand yes
658 pack $sw -side top -expand yes -fill both
660 $CVEnv::curframe tag configure text -font $EditorTextfont -foreground $EditorTextfg
661 $CVEnv::curframe tag configure string -font $EditorStringfont -foreground $EditorStringfg
662 $CVEnv::curframe tag configure number -font $EditorNumberfont -foreground $EditorNumberfg
663 $CVEnv::curframe tag configure comment -font $EditorCommentfont -foreground $EditorCommentfg
664 $CVEnv::curframe tag configure keyword -font $EditorKeywordfont -foreground $EditorKeywordfg
666 $CVEnv::curframe tag add normal 0.0 end
667 $CVEnv::curframe index 0.0
669 #-----------------------------------------------------------
670 bind $CVEnv::curframe <KeyPress> {
674 bind $CVEnv::curframe <KeyRelease> {
676 #set frame [$CVEnv::nbrig getframe $CVEnv::curpage]
677 set curindex [$CVEnv::curframe index insert]
678 set coordlist [split $curindex .]
679 set CVEnv::curln [lindex $coordlist 0]
680 set CVEnv::curcol [lindex $coordlist 1]
684 bind $CVEnv::curframe <ButtonRelease-1> {
685 #set frame [$CVEnv::nbrig getframe $CVEnv::curpage]
686 set curindex [$CVEnv::curframe index insert]
687 set coordlist [split $curindex .]
688 set CVEnv::curln [lindex $coordlist 0]
689 set CVEnv::curcol [lindex $coordlist 1]
690 $CVEnv::nbrig see $CVEnv::curpage
696 bind $CVEnv::curframe <FocusOut> {
697 set CVEnv::curln "--"
698 set CVEnv::curcol "--"
701 bind $CVEnv::curframe <F5> CVEnv::execute
703 #-----------------------------------------------------------
708 incr CVEnv::pagescount
711 set CVEnv::curpage p[expr $CVEnv::pagescount]
712 set CVEnv::curfile ""
713 lappend CVEnv::pages $CVEnv::curpage
714 lappend CVEnv::files $CVEnv::curfile
716 set text [format "/* %u */" $CVEnv::pagescount]
717 CVEnv::createeditor $CVEnv::curpage $text
719 if {$CVEnv::pagesnum == 1} {
725 $CVEnv::nbrig see [$CVEnv::nbrig pages end]
726 $CVEnv::nbrig raise [$CVEnv::nbrig pages end]
729 proc CVEnv::loadfile {name frame} {
730 set file [::open $name r]
733 $frame insert 0.0 [read $file]
740 proc CVEnv::open {parent} {
743 {"Text files" {.txt} }
747 set file [tk_getOpenFile -filetypes $types -parent $parent]
748 if [string compare $file ""] {
750 if [$CVEnv::tree exists $file] {
751 #set page [$CVEnv::tree itemcget $file -data]
752 set pos [lsearch $CVEnv::files $file]
753 set page [lindex $CVEnv::pages $pos]
754 $CVEnv::nbrig see $page
755 $CVEnv::nbrig raise $page
757 incr CVEnv::pagescount
760 set CVEnv::curfile $file
761 set text [lindex [split $file /] end]
762 set CVEnv::curpage p[expr $CVEnv::pagescount]
763 lappend CVEnv::files $CVEnv::curfile
764 lappend CVEnv::pages $CVEnv::curpage
766 CVEnv::createeditor $CVEnv::curpage $text
768 CVEnv::loadfile $file $CVEnv::curframe
770 if {$CVEnv::pagesnum == 1} {
776 $CVEnv::tree insert end files $file -text $file \
777 -image [image create photo -file [file join $::image_path pictures/file.gif]]
779 $CVEnv::nbrig see [$CVEnv::nbrig pages end]
780 $CVEnv::nbrig raise [$CVEnv::nbrig pages end]
785 proc CVEnv::save {} {
786 if {$CVEnv::curfile != ""} {
787 #set frame [ $CVEnv::nbrig getframe $CVEnv::curpage]
788 CVEnv::writefile $CVEnv::curfile $CVEnv::curframe
794 proc CVEnv::writefile {name frame} {
795 set file [::open $name w]
796 set tx [$frame get 1.0 "end-1 chars"]
802 proc CVEnv::saveas {parent} {
804 {"C source files" {.c} }
805 {"C header files" {.h} }
806 {"Text files" {.txt} }
810 set file [tk_getSaveFile -filetypes $types -parent $parent \
811 -initialfile Untitled -defaultextension ""]
812 if [string compare $file ""] {
814 if [$CVEnv::tree exists $file] {
815 #set page [$CVEnv::tree itemcget $file -data]
816 set pos [lsearch $CVEnv::files $file]
817 set page [lindex $CVEnv::pages $pos]
818 $CVEnv::nbrig see $page
819 $CVEnv::nbrig raise $page
822 set pos [lsearch $CVEnv::files $CVEnv::curfile]
823 set CVEnv::files [lreplace $CVEnv::files $pos $pos $file]
825 set text [lindex [split $file /] end]
826 $CVEnv::nbrig itemconfigure $CVEnv::curpage -text $text
827 #set frame [ $CVEnv::nbrig getframe $CVEnv::curpage]
828 CVEnv::writefile $file $CVEnv::curframe
830 if {$CVEnv::curfile != ""} {
831 set ind [$CVEnv::tree index $CVEnv::curfile]
832 $CVEnv::tree delete $CVEnv::curfile
833 $CVEnv::tree insert $ind files $file -text $file \
834 -image [image create photo -file [file join $::image_path pictures/file.gif]]
836 $CVEnv::tree insert end files $file -text $file \
837 -image [image create photo -file [file join $::image_path pictures/file.gif]]
840 set CVEnv::curfile $file
845 proc CVEnv::close {} {
847 set pos [lsearch $CVEnv::files $CVEnv::curfile]
848 set $CVEnv::files [lreplace $CVEnv::files $pos $pos]
849 set $CVEnv::pages [lreplace $CVEnv::pages $pos $pos]
851 $CVEnv::nbrig delete $CVEnv::curpage 1
853 if {$CVEnv::curfile != ""} {
854 set ind [$CVEnv::tree index $CVEnv::curfile]
855 $CVEnv::tree delete $CVEnv::curfile
858 set CVEnv::pagesnum [expr $CVEnv::pagesnum - 1]
860 if {$CVEnv::pagesnum == 0} {
864 set CVEnv::curfile ""
866 set page [$CVEnv::nbrig pages end]
868 set pos [lsearch $CVEnv::pages $CVEnv::curpage]
869 set CVEnv::curfile [lindex $CVEnv::files $pos]
871 $CVEnv::nbrig see $page
872 $CVEnv::nbrig raise $page
876 proc CVEnv::execute {} {
878 if {$CVEnv::savebefore == "1"} {
881 if {$CVEnv::curfile == ""} {
886 if {$CVEnv::clearoutputbefore == "1"} {
887 $CVEnv::outtx delete 0.0 end
890 if {$CVEnv::clearerrorbefore == "1"} {
891 $CVEnv::parsetx delete 0.0 end
894 pExecute $CVEnv::curfile
897 proc CVEnv::create { } {
901 ###################################################################
902 set top [toplevel .intro -relief raised -borderwidth 2]
904 wm overrideredirect $top 1
906 image create photo original -file [file join $::image_path pictures/CVEnv.gif]
907 canvas $top.c -bd 2 -relief ridge -width 295 -height 195
908 $top.c create image 0 0 -anchor nw -image original
909 pack $top.c -side top -expand yes -fill x
911 set frame [frame $top.f -background white -bd 2 -relief ridge]
912 set lab1 [label $frame.lab1 -text "Please wait for loading..." \
913 -background white -font {times 8}]
914 set lab2 [label $frame.lab2 -textvariable CVEnv::prgtext \
915 -background white -font {times 8} -width 35]
916 set prg [ProgressBar $frame.prg -width 50 -height 10 \
917 -background white -variable CVEnv::prgindic -maximum 7]
918 pack $lab1 $prg $lab2
919 pack $frame -side top -expand yes -fill x -padx 2 -pady 2
921 BWidget::place $top 0 0 center
924 ###################################################################
926 set CVEnv::prgtext "Loading font..."
931 set CVEnv::prgtext "Creating menu..."
937 {command "&New" {} "New document" {} -command CVEnv::new}
938 {command "&Open" {} "Open a document" {} -command "CVEnv::open ."}
939 {command "&Close" {} "Close the document" {} -state disable \
940 -command CVEnv::close}
942 {command "&Save" {} "Save the document" {} -state disable \
943 -command CVEnv::save}
944 {command "Save &As..." {} "Save the document as..." {} \
945 -state disable -command "CVEnv::saveas ."}
947 {command "E&xit" {} "Exit the program" {} -command exit}
950 {checkbutton "&Toolbar" {all view} "Show/hide toolbar" {} \
951 -variable CVEnv::showtb \
952 -command {$CVEnv::mainf showtoolbar 0 $CVEnv::showtb}
954 {checkbutton "&Statusbar" {all view} "Show/hide statusbar" {} \
955 -variable CVEnv::showstb \
957 if {$CVEnv::showstb} {
958 pack $CVEnv::mainf.botf -side bottom -fill x
960 pack forget $CVEnv::mainf.botf
964 {checkbutton "&File pane" {all view} "" {} \
965 -variable CVEnv::showlp \
966 -command {CVEnv::leftpane $CVEnv::showlp}
970 "&Options" all options 0 {
971 {command "&Configuration" {} "Enviroments settings" {} \
972 -command CVEnv::confdialog}
973 {command "&Appearance" {} "Colors & fonts setup" {} -command CVEnv::colordialog}
976 {command "&About CVEnv" {} "Display the program info" {} \
977 -command CVEnv::about}
981 #{checkbutton "&Execute pane" {all view} "" {} \
982 # -variable CVEnv::showbp \
983 # -command {CVEnv::bottompane $CVEnv::showbp}
987 set CVEnv::prgtext "Creating MainFrame..."
990 set CVEnv::mainf [MainFrame .mainf -menu $menu \
991 -textvariable CVEnv::statustext]
993 menu .menubar.edit -tearoff 0 -background $::default_normal_bg
994 MainFrame::_create_entries .mainf .menubar.edit \
995 $::default_normal_bg {\
996 {command "Cu&t" {} "Cut the selection" {} -command cut}
997 {command "&Copy" {} "Copy the selection" {} -command copy}
998 {command "&Paste" {} "Paste the clipboard" {} -command paste}
1000 {command "&Go to.." {} "Move to a specified place" {} -command paste}
1003 incr CVEnv::prgindic
1004 set CVEnv::prgtext "Creating toolbar..."
1007 #### toolbars creation
1008 set CVEnv::tb [$CVEnv::mainf addtoolbar]
1010 set bbox [ButtonBox $CVEnv::tb.bbox0 -spacing 0 -padx 1 -pady 1]
1011 $bbox add -image [image create photo -file [file join $::image_path pictures/new.gif]] \
1012 -highlightthickness 0 -takefocus 0 -relief link -borderwidth 2 \
1013 -padx 1 -pady 1 -helptext "Create a new file" -command CVEnv::new
1014 $bbox add -image [image create photo -file [file join $::image_path pictures/open.gif]] \
1015 -highlightthickness 0 -takefocus 0 -relief link -borderwidth 2 \
1016 -padx 1 -pady 1 -helptext "Open an existing file" -command "CVEnv::open ."
1017 pack $bbox -side left -anchor w
1019 set sep [Separator $CVEnv::tb.sep0 -orient vertical]
1020 pack $sep -side left -fill y -padx 4 -anchor w
1022 set bbox [ButtonBox $CVEnv::tb.bbox1 -spacing 0 -padx 1 -pady 1]
1023 $bbox add -image [image create photo -file [file join $::image_path pictures/save.gif]] \
1024 -highlightthickness 0 -takefocus 0 -relief link -borderwidth 2 \
1025 -padx 1 -pady 1 -helptext "Save file" -command CVEnv::save
1027 #$bbox.b2 configure -state active -relief link
1030 set sep [Separator $CVEnv::tb.sep1 -orient vertical]
1032 set bbox [ButtonBox $CVEnv::tb.bbox2 -spacing 0 -padx 1 -pady 1]
1033 $bbox add -image [image create photo -file [file join $::image_path pictures/cut.gif]] \
1034 -highlightthickness 0 -takefocus 0 -relief link -borderwidth 1 \
1035 -padx 1 -pady 1 -helptext "Cut (Ctrl-X)"
1036 $bbox add -image [image create photo -file [file join $::image_path pictures/copy.gif]] \
1037 -highlightthickness 0 -takefocus 0 -relief link -borderwidth 1 \
1038 -padx 1 -pady 1 -helptext "Copy (Ctrl-C)"
1039 $bbox add -image [image create photo -file [file join $::image_path pictures/paste.gif]] \
1040 -highlightthickness 0 -takefocus 0 -relief link -borderwidth 1 \
1041 -padx 1 -pady 1 -helptext "Paste (Ctrl-V)"
1043 set sep [Separator $CVEnv::tb.sep2 -orient vertical]
1045 set bbox [ButtonBox $CVEnv::tb.bbox3 -spacing 0 -padx 1 -pady 1]
1046 $bbox add -image [image create photo -file [file join $::image_path pictures/exec.gif]] \
1047 -highlightthickness 0 -takefocus 0 -relief link -borderwidth 1 \
1048 -padx 1 -pady 1 -helptext "Execute the script (F5)" \
1049 -command CVEnv::execute
1051 $bbox add -image [image create photo -file [file join $::image_path pictures/stop.gif]] \
1052 -highlightthickness 0 -takefocus 0 -relief link -borderwidth 1 \
1053 -padx 1 -pady 1 -helptext "Stop the execution (Shift-F5)"\
1056 set sep [Separator $CVEnv::tb.sep3 -orient vertical]
1058 $CVEnv::tb.bbox3.b1 configure -state disable -relief link
1060 incr CVEnv::prgindic
1061 set CVEnv::prgtext "Creating statusbar..."
1064 $CVEnv::mainf addindicator
1065 $CVEnv::mainf.status.indf.f0 configure -relief flat
1067 label $CVEnv::mainf.status.indf.f0.l0 -relief sunken -borderwidth 1 \
1068 -takefocus 0 -highlightthickness 0 -textvariable CVEnv::curfile
1069 pack $CVEnv::mainf.status.indf.f0.l0 -side left -fill y -expand 1
1071 label $CVEnv::mainf.status.indf.f0.l1 -relief flat -borderwidth 1 \
1072 -takefocus 0 -highlightthickness 0 -text "Ln"
1073 pack $CVEnv::mainf.status.indf.f0.l1 -side left -fill y -expand 1
1075 label $CVEnv::mainf.status.indf.f0.l2 -relief sunken -borderwidth 1 \
1076 -takefocus 0 -highlightthickness 0 -textvariable CVEnv::curln
1077 pack $CVEnv::mainf.status.indf.f0.l2 -side left -fill y -expand 1
1079 label $CVEnv::mainf.status.indf.f0.l3 -relief flat -borderwidth 1 \
1080 -takefocus 0 -highlightthickness 0 -text "Col"
1081 pack $CVEnv::mainf.status.indf.f0.l3 -side left -fill y -expand 1
1083 label $CVEnv::mainf.status.indf.f0.l4 -relief sunken -borderwidth 1 \
1084 -takefocus 0 -highlightthickness 0 -textvariable CVEnv::curcol
1085 pack $CVEnv::mainf.status.indf.f0.l4 -side left -fill y -expand 1
1086 pack forget $CVEnv::mainf.status.indf.f0
1088 set CVEnv::prgtext "Creating panes..."
1089 incr CVEnv::prgindic
1090 CVEnv::createpanes $CVEnv::mainf.frame
1092 set CVEnv::prgtext "Done"
1093 incr CVEnv::prgindic
1095 pack $CVEnv::mainf -fill both -expand yes
1098 unset CVEnv::prgindic
1099 unset CVEnv::prgtext
1104 proc CVEnv::treeclick {node} {
1105 set file [lindex $node 0]
1106 set data [$CVEnv::tree itemcget $file -data]
1108 if [string compare $data "Files"] {
1109 set pos [lsearch $CVEnv::files $file]
1110 set page [lindex $CVEnv::pages $pos]
1112 $CVEnv::nbrig see $page
1113 $CVEnv::nbrig raise $page
1117 proc CVEnv::gotoline { line } {
1118 $CVEnv::curframe see $line.0
1119 focus -force $CVEnv::curframe
1121 $CVEnv::curframe tag remove sel 0.0 $line.0
1122 $CVEnv::curframe tag add sel $line.0 [expr $line +1].0
1123 $CVEnv::curframe tag remove sel [expr $line +1].0 end
1127 proc CVEnv::createpanes { parent } {
1128 set CVEnv::pw [PanedWindow $parent.pw -side left]
1129 set CVEnv::ptop [$CVEnv::pw add]
1131 set CVEnv::pwch [PanedWindow $CVEnv::ptop.pw -side bottom]
1132 set plef [$CVEnv::pwch add]
1133 set CVEnv::prig [$CVEnv::pwch add]
1135 set CVEnv::nblef [NoteBook $plef.nb -side bottom]
1136 set files [$CVEnv::nblef insert end "files" -text "Files" \
1137 -image [image create photo -file [file join $::image_path pictures/file.gif]]]
1138 set sw [ScrolledWindow $files.sw \
1139 -relief sunken -borderwidth 2]
1140 set CVEnv::tree [Tree $sw.tree \
1141 -relief flat -borderwidth 0 -width 15 -highlightthickness 0\
1143 $sw setwidget $CVEnv::tree
1144 $CVEnv::tree insert end root files -text Files -data Files \
1145 -image [image create photo -file [file join $::image_path pictures/openfold.gif]]
1146 pack $sw -side top -expand yes -fill both
1147 #$CVEnv::nblef compute_size
1148 pack $CVEnv::nblef -fill both -expand yes -padx 1 -pady 1
1150 set CVEnv::nbrig [NoteBook $CVEnv::ptop.nb -side top]
1152 #$CVEnv::nbrig compute_size
1153 pack $CVEnv::nbrig -in $CVEnv::prig -fill both -expand yes -padx 1 -pady 1
1154 pack $CVEnv::pwch -fill both -expand yes
1156 set CVEnv::pbot [$CVEnv::pw add]
1157 set CVEnv::inputcb [Entry $CVEnv::pbot.combo \
1158 -textvariable CVEnv::inputvar \
1159 -helptext "Input box. In order to input data press Enter."\
1161 set CVEnv::inputdata $CVEnv::inputvar
1162 lappend CVEnv::inputlist $CVEnv::inputdata
1163 set CVEnv::curinput [lsearch -exact $CVEnv::inputlist $CVEnv::inputdata]
1164 $CVEnv::inputcb configure -fg #00FFFF
1167 pack $CVEnv::inputcb -fill x -side bottom
1169 bind $CVEnv::inputcb <KeyPress> {
1170 set CVEnv::inputdata ""
1171 $CVEnv::inputcb configure \
1172 -fg $::default_window_fg
1174 bind $CVEnv::inputcb <Up> {
1175 if {$CVEnv::curinput != 0} {
1176 set CVEnv::curinput [expr $CVEnv::curinput -1]
1177 set CVEnv::inputvar [lindex $CVEnv::inputlist $CVEnv::curinput]
1178 set CVEnv::inputdata $CVEnv::inputvar
1179 $CVEnv::inputcb configure \
1183 bind $CVEnv::inputcb <Down> {
1184 incr CVEnv::curinput
1185 set CVEnv::inputvar [lindex $CVEnv::inputlist $CVEnv::curinput]
1186 set CVEnv::inputdata $CVEnv::inputvar
1187 $CVEnv::inputcb configure \
1192 set CVEnv::nbbot [NoteBook $CVEnv::pbot.nb -side bottom]
1194 set parse [$CVEnv::nbbot insert end parse -text "Errors"]
1195 set sw [ScrolledWindow $parse.sw -auto vertical]
1196 set CVEnv::parsetx [text $sw.tx -wrap none]
1197 $sw setwidget $CVEnv::parsetx
1198 pack $CVEnv::parsetx -fill both -expand yes
1199 pack $sw -side top -expand yes -fill both
1201 bind $CVEnv::parsetx <Button-2> {
1202 set pos [$CVEnv::parsetx index @%x,%y]
1203 set listpos [split $pos "."]
1204 set line [lindex $listpos 0]
1206 set data [$CVEnv::parsetx get "insert linestart" "insert lineend"]
1207 set datalist [split $data " "]
1208 set file [lindex $datalist 2]
1209 set line [lindex [split [lindex $datalist 5] ":"] 0]
1211 if [string compare $file ""] {
1212 set pos [lsearch -exact $CVEnv::files $file]
1213 set page [lindex $CVEnv::pages $pos]
1214 if [string compare $page ""] {
1215 $CVEnv::nbrig see $page
1216 $CVEnv::nbrig raise $page
1217 CVEnv::gotoline $line
1221 bind $CVEnv::parsetx <Button-3> {
1222 set pos [$CVEnv::parsetx index @%x,%y]
1223 set listpos [split $pos "."]
1224 set line [lindex $listpos 0]
1226 set data [$CVEnv::parsetx get "insert linestart" "insert lineend"]
1227 set datalist [split $data " "]
1228 set file [lindex $datalist 2]
1229 set line [lindex [split [lindex $datalist 5] ":"] 0]
1231 if [string compare $file ""] {
1232 set pos [lsearch -exact $CVEnv::files $file]
1233 set page [lindex $CVEnv::pages $pos]
1234 if [string compare $page ""] {
1235 $CVEnv::nbrig see $page
1236 $CVEnv::nbrig raise $page
1237 CVEnv::gotoline $line
1242 set output [$CVEnv::nbbot insert end output -text "Output"]
1243 set sw [ScrolledWindow $output.sw -auto vertical]
1244 set CVEnv::outtx [text $sw.tx -wrap none]
1245 $sw setwidget $CVEnv::outtx
1246 pack $CVEnv::outtx -fill both -expand yes
1247 pack $sw -side top -expand yes -fill both
1249 bind $CVEnv::outtx <KeyPress> {$CVEnv::outtx configure -state disable}
1250 bind $CVEnv::outtx <KeyRelease> {$CVEnv::outtx configure -state normal}
1251 bind $CVEnv::outtx <Button-1> {$CVEnv::outtx configure -state normal}
1252 bind $CVEnv::parsetx <KeyPress> {$CVEnv::parsetx configure -state disable}
1253 bind $CVEnv::parsetx <KeyRelease> {$CVEnv::parsetx configure -state normal}
1254 bind $CVEnv::parsetx <Button-1> {$CVEnv::parsetx configure -state normal}
1256 #$CVEnv::nbbot compute_size
1257 pack $CVEnv::nbbot -fill both -expand yes -padx 1 -pady 1 -side top
1259 $CVEnv::tree bindText <Double-Button-1> "CVEnv::treeclick"
1260 #Tree::bindImage $path <Button-1> "$path selection set"
1263 pack $CVEnv::pw -fill both -expand yes
1266 proc CVEnv::update_font { newfont } {
1272 . configure -cursor watch
1273 if { $font != $newfont } {
1274 $_wfont configure -font $newfont
1275 $notebook configure -font $newfont
1278 . configure -cursor ""
1282 package require BWidget
1283 #option add *TitleFrame.l.font {helvetica 11 bold italic}
1289 BWidget::place . 640 480 center
1292 wm geometry . 640x480
1296 set ypw [expr $y0 + 360]
1297 set xpw [expr $x0 + 130]
1300 PanedWindow::_end_move_sash $CVEnv::pw $CVEnv::pw.sash \
1301 1 0 0x0FFFFFFF $ypw rooty height
1302 PanedWindow::_end_move_sash $CVEnv::pwch $CVEnv::pwch.sash \
1303 1 0 0x0FFFFFFF $xpw rootx width
1305 $CVEnv::nblef raise [$CVEnv::nblef page 0]
1306 $CVEnv::nbbot raise [$CVEnv::nbbot page 1]