####################################################################################################
##     SciSCADA Toolbox
##     About.tcl
##     Developed by Zhe.Peng & Longhua.Ma
##     Email:pengzhe1113@gmail.com
##     Hangzhou, China
##     Sep.2006
####################################################################################################

set DIRE

set proc_temp main

set w .about
catch {destroy $w}
toplevel $w
wm title $w "SciSCADA:About"
wm state $w zoom 


canvas $w.c -width 1020 -height 758 -bg blue

####################### menu ###########################

	menu $w.menu -tearoff 0

	set mfile $w.menu.file
	menu $mfile -tearoff 0
	$w.menu add cascade -label "File" -menu $mfile -underline 0
	$mfile add command -label "Open" 
	$mfile add separator
	$mfile add command -label "Quit" -command exit

	set minterface $w.menu.interface
	menu $minterface -tearoff 0 
	$w.menu add cascade -label "Interface" -menu $minterface -underline 0
	
	$minterface add command -label "Main" -command {
	destroy $w
	ScilabEval " TCL_EvalFile('$DIRE/main.tcl')" 
	}
 
	$minterface add command -label "OPC" -command {
	destroy $w
	ScilabEval " TCL_EvalFile('$DIRE/opc.tcl')" 
	}
 
	$minterface add command -label "Modbus" -command {
	destroy $w
	ScilabEval " TCL_EvalFile('$DIRE/modbus.tcl')" 
	}

	$minterface add command -label "Ethernet" -command {
	destroy $w
	ScilabEval " TCL_EvalFile('$DIRE/ethernet.tcl')" 
	}

	$minterface add command -label "Mysql" -command {
	destroy $w
	ScilabEval " TCL_EvalFile('$DIRE/mysql.tcl')" 
	}

	$minterface add command -label "Serial" -command {
	destroy $w
	ScilabEval " TCL_EvalFile('$DIRE/serial.tcl')" 
	}


	set mapplication $w.menu.application
	menu $mapplication -tearoff 0 
	$w.menu add cascade -label "Application" -menu $mapplication -underline 0
	$mapplication add command -label "Intro to Tong Lu's water supply"  -command {
	destroy $w
	ScilabEval " TCL_EvalFile('$DIRE/application_about.tcl')" 
	}

	$mapplication add command -label "Main" -command {
	destroy $w
	ScilabEval " TCL_EvalFile('$DIRE/Application_main.tcl')" 
	}

	$mapplication add command -label "Networks" -command {
	destroy $w
	ScilabEval " TCL_EvalFile('$DIRE/application_net.tcl')" 
	}

	$mapplication add command -label "Data Acquisition" -command {
	destroy $w
	ScilabEval " TCL_EvalFile('$DIRE/application_acquision.tcl')" 
	}

	$mapplication add command -label "Data Monitor" -command {
	destroy $w
	ScilabEval " TCL_EvalFile('$DIRE/application_monitor.tcl')" 
	}

	

	set mhelp $w.menu.mhelp
	menu $mhelp -tearoff 0
	$w.menu add cascade -label "Help" -menu $mhelp -underline 0
	
	$mhelp add cascade -label "Source codes" -command {
	destroy $w
	ScilabEval " TCL_EvalFile('$DIRE/source.tcl')" 
	}
	


	
	$mhelp add command -label "Help" -command {
        set tmp [file join $DIRE index.htm]
        regsub -all "/" $tmp "\\" tmp
        exec $env(COMSPEC) /c $tmp &
	}
	
	
	$mhelp add command -label "About" -command {
	destroy $w
	ScilabEval " TCL_EvalFile('$DIRE/about.tcl')" 
	}
	 
	$w configure -menu $w.menu 
	

#######################Left frame###########################

frame $w.left -width 510 -height 704
pack $w.left -padx 0 -pady 0
pack propagate $w.left false

#######################Right frame###########################

frame $w.right -width 510 -height 704 
pack $w.right -padx 0 -pady 0 
pack propagate $w.right false


#######################Left.Top frame###########################

labelframe $w.left.top -width 510 -height 704 -text "FAQ"
pack $w.left.top -padx 0 -pady 0
pack propagate $w.left.top false


	
#######################Left.Top.Top frame###########################

frame $w.left.top.top -width 510 -height 100 -bg white
pack $w.left.top.top -padx 0 -pady 0
pack propagate $w.left.top.top false

	
	
#######################Left.Top.Buttom frame###########################

frame $w.left.top.buttom -width 510 -height 600
pack $w.left.top.buttom -padx 0 -pady 0
pack propagate $w.left.top.buttom false
	
#######################Left.top.buttom.left frame###########################

frame $w.left.top.buttom.left -width 180 -height 600
pack $w.left.top.buttom.left -padx 0 -pady 0
pack propagate $w.left.top.buttom.left false
	
listbox  $w.left.top.buttom.left.list -width 180 -height 700 
$w.left.top.buttom.left.list insert 0 "What is SCADA" "Why design SCADA toolbox" "What interface the toolbox support" "The innovation of the toolbox"

pack $w.left.top.buttom.left.list

#######################left.top.buttom.right frame###########################

frame $w.left.top.buttom.right -width 410 -height 600
pack $w.left.top.buttom.right -padx 0 -pady 0
pack propagate $w.left.top.buttom.right false


text $w.left.top.buttom.right.text -width 700 -height 558 -yscrollcommand "$w.left.top.buttom.right.yscroll set" -font {22}
scrollbar $w.left.top.buttom.right.yscroll -command "$w.left.top.buttom.right.text yview" -orient vertical
pack $w.left.top.buttom.right.yscroll -side right -fill y
	    		
pack $w.left.top.buttom.right.text -side left
	
#######################left.buttom  frame###########################

labelframe $w.left.buttom -width 510 -height 300 -text "important"
pack $w.left.buttom -padx 0 -pady 0
pack propagate $w.left.buttom false


#######################right.top frame###########################

labelframe $w.right.top -width 510 -height 400 -text "dd"
pack $w.right.top -padx 0 -pady 0
pack propagate $w.right.top false


#######################right.buttom frame###########################

labelframe $w.right.buttom -width 510 -height 300 -text "Author" -bg white
pack $w.right.buttom -padx 0 -pady 0
pack propagate $w.right.buttom false


#######################statusbar frame###########################

frame $w.statusbar -width 1020 -height 20 
pack $w.statusbar -padx 3 -pady 3
pack propagate $w.statusbar false
label $w.statusbar.time -text "Time:2006-7-7 18:45:34 | "
label $w.statusbar.mouse -text "  | "
label $w.statusbar.note -text " | "
label $w.statusbar.author -text "Designed by ZhePeng ZheJiang Univ. china"

pack $w.statusbar.time  $w.statusbar.mouse  $w.statusbar.note  $w.statusbar.author -side left

#######################packframe###########################

pack $w.left $w.right -side left
pack $w.left.top  $w.left.buttom -side top
pack $w.right.top  $w.right.buttom -side top
pack $w.left.top.top $w.left.top.buttom -side top
pack $w.left.top.buttom.left $w.left.top.buttom.right -side left


pack $w.statusbar -side bottom




#######################Pic Add###########################
catch {image delete faq}
image create photo faq -file [file join $DIRE "img" "faq.GIF"]
label $w.left.top.top.label -image faq -bd 0 -relief sunken
pack $w.left.top.top.label

catch {image delete frame_logo}
image create photo frame_logo -file [file join $DIRE "img" "frame_logo.GIF"]
label $w.right.top.label1 -image frame_logo -bd 0 -relief sunken
pack $w.right.top.label1

catch {image delete frame_pic}
image create photo frame_pic -file [file join $DIRE "img" "frame.GIF"]
label $w.right.top.label2 -image frame_pic -bd 0 -relief sunken
pack $w.right.top.label2


catch {image delete author}
image create photo author -file [file join $DIRE "img" "author.GIF"]
label $w.right.buttom.label -image author -bd 0 -relief sunken
pack $w.right.buttom.label -pady 30






bind $w.left.top.buttom.left.list <ButtonRelease-1> {
set file_name [$w.left.top.buttom.left.list get [$w.left.top.buttom.left.list curselection] ]
set file [file join $DIRE "faq" $file_name]
   		set id [open $file]
    		$w.left.top.buttom.right.text delete 1.0 end
    		$w.left.top.buttom.right.text insert 1.0 [read $id]
    		$w.left.top.buttom.right.text mark set insert 1.0
}

