#!/usr/bin
set pothome /mnt/dd3/ebook/tech/opengl/pot
source /mnt/dd3/ebook/tech/opengl/pot/tkheader.h
tk_bisque
wm geometry . 600x300$winX$winY
##############################################################################
# The following procedure creates a screen for chapter 1 of the tutorial.

wm title . "Chapter4 - Color"
. configure -background white
createframe .c4menubar 2 
# call procedure createframe and create a frame for the menus available
# in chapter3. we call this menu frame .c3menubar and give it a width
# of 2 units.
   
createtextwidget "-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1" blue white 0 0 nw


menubutton .c4menubar.menu -text "Concepts" -underline 0 \
-menu .c4menubar.menu.conceptMenu

# next we create a menubutton in this frame (.c4menubar) and call it
# .c4menubar.menu.  We also assign it some text - Concepts and 
# underline the letter C.

set m [	menu .c4menubar.menu.conceptMenu ]
# create an concept menu on the menubar .c3menubar.menu and add options to it

$m add command  -label "1 - Color Perception" \
	-command { catch {exec kill $pid}
        killprocess c4Process	
        displaytext "$pothome/CHAP4/TEXT_FILES/ColorPerception.txt"
        greentag .textdisplay 1.0 3.55
        redtag .textdisplay 5.0 5.55
        bluetag .textdisplay 8.0 8.55
}
$m add separator
$m add cascade -label "2 - OpenGL Color Types" -menu $m.colorMenu
set m2 [ menu $m.colorMenu ]
$m2 add command -label "2.1 - RGBA Color" \
		-command { catch {exec kill $pid}
               killprocess c4Process	
                 displaytext "$pothome/CHAP4/TEXT_FILES/RGBA.txt" 
                greentag .textdisplay 1.0 2.55
                redtag .textdisplay 4.0 4.55
                bluetag .textdisplay 7.0 7.55
                bluetag .textdisplay 30.0 30.55
                functag .textdisplay 44.43 44.52
                functag .textdisplay 45.0 45.10
                functag .textdisplay 45.14 45.25
}

$m2 add command -label "2.2 - Color-Index Mode" \
		-command { catch {exec kill $pid}
                 killprocess c4Process	
                displaytext "$pothome/CHAP4/TEXT_FILES/ColorIndex.txt"
                greentag .textdisplay 1.0 2.55
                redtag .textdisplay 4.0 4.55
                bluetag .textdisplay 7.0 7.55
                bluetag .textdisplay 16.0 16.55

 }
$m add separator
$m add cascade -label "3 - Specifying Color." -menu $m.specifyMenu
set m3 [menu $m.specifyMenu ]
$m3 add command -label "3.1 - RGBA MODE" \
	-command {catch {exec kill $pid}
        killprocess c4Process	
        displaytext "$pothome/CHAP4/TEXT_FILES/RGBASpecify.txt"
        greentag .textdisplay 1.0 2.55
        redtag .textdisplay 4.0 4.55
        bluetag .textdisplay 7.0 7.55
        functag .textdisplay 9.0 9.60
}
$m3 add separator
$m3 add command -label "3.2 - Color-Index Mode" \
	-command {catch {exec kill $pid}
         killprocess c4Process	
        displaytext "$pothome/CHAP4/TEXT_FILES/CIndexSpecify.txt"
        greentag .textdisplay 1.0 2.55
        redtag .textdisplay 4.0 4.55
        bluetag .textdisplay 7.0 7.55
        functag .textdisplay 9.29 9.39
        functag .textdisplay 15.0 15.14
        functag .textdisplay 17.11 17.26
}

$m add separator
$m add cascade -label "4 - Shading Model" -menu $m.shadeMenu
set m4 [menu $m.shadeMenu ]
$m4 add command -label "4.1 - A triangle " \
	-command {catch {exec kill $pid}
         killprocess c4Process	
        set pid [exec $pothome/CHAP4/PROG_FILES/Triangle.tk &]
        procfile $pid c4Process
        displaytext "$pothome/CHAP4/TEXT_FILES/Triangle.txt"
        greentag .textdisplay 1.0 2.55
        redtag .textdisplay 4.0 4.55
        bluetag .textdisplay 7.0 7.55
        functag .textdisplay 10.32 10.41
        functag .textdisplay 19.15 19.31
        
 }
$m4 add separator
$m4 add command -label "4.2 - A Psychedelic Broom" \
	-command {catch {exec kill $pid}
        killprocess c4Process	
        set pid [exec $pothome/CHAP4/PROG_FILES/broom.tk &]
        procfile $pid c4Process
        displaytext "$pothome/CHAP4/TEXT_FILES/broom.txt"
        greentag .textdisplay 1.0 3.55
        redtag .textdisplay 5.0 5.55
        bluetag .textdisplay 8.0 8.55
        functag .textdisplay 15.13 15.22
}

button .c4menubar.unpack -relief flat -text "Unpack" -underline 0 
		
button .c4menubar.pack -relief flat -text "Pack" -underline 0 


button .c4menubar.exit -relief flat -text "Exit" -underline 1 \
	-command {
		     catch { exec kill $pid }
                     killprocess c4Process	
                     catch { send main wm deiconify . }
		     exit}
pack .c4menubar.menu .c4menubar.unpack .c4menubar.pack  .c4menubar.exit -side left

bind .c4menubar.unpack <1> {
set cwd [ pwd ]
cd $pothome/CHAP4/PROG_FILES
catch { exec make >& /dev/tty }
cd $cwd


}
bind .c4menubar.pack <1> {
set cwd [ pwd ]
cd $pothome/CHAP4/PROG_FILES
catch { exec make clean  >& /dev/tty }
cd $cwd
}



displaytext  "$pothome/CHAP4/TEXT_FILES/Main.txt" 
greentag .textdisplay 1.0 2.55
redtag .textdisplay 4.0 4.55



#set $cmd {lappend pid_list [expr 1 * $pid]} 
#send Tutorial.tk {eval $cmd }
#send Tutorial.tk {lappend pid_list  [expr 1 * $pid] }
































































































