#!/usr/bin/env wish

# All code here is licensed under GPLv2.
# Copyright 0penrc (Toiletflusher, TechSalt.)

# set title
wm title . {Getting Started with Debian GNU/Linux}

# set window icon
image create photo icon -file [file dirname [file normalize [info script] ] ]/program-debian.png
wm iconphoto . icon

# set window on top
wm attributes . -topmost no -type dialog

# disable resizing
wm resizable . 0 0

# set fonts
set fontfamily {Tahoma}
set fontsize {8}

set fontfamilyheader {Tahoma}
set fontsizeheader {12}

font create mainfont -family $fontfamily -size $fontsize
font create smallfont -family $fontfamily -size 7
font create boldfont -family $fontfamily -size $fontsize -weight bold
font create headerfont -family $fontfamilyheader -size $fontsizeheader -weight bold

# set strings
set left_register_name {Subscribe Now}
set left_discover_name {Discover Debian}
set left_connect_name {Connect to the Internet}

set right_main_title {Getting Started}
set right_main_text {You can access all your programs by right clicking the desktop.}

set right_discover_title {Discover Debian GNU/Linux}
set right_discover_text {Debian GNU/Linux is easier to use, easier to manage, more compatible, and more powerful. The Discover Debian GNU/Linux tour highlights all the newest and coolest features.}

set right_register_title {Subscribe to mailing lists}
set right_register_text {Subscribe to Debian GNU/Linux mailing lists to receive news for:

• New software/packages
• Software/package updates
• The most relevant new software information}

set right_connect_title {Connect to the Internet}
set right_connect_text {• Read the latest news and financial information
• Visit Web sites around the world
• Get e-mail

We make it quick and simple for you to connect to the internet.
}

set startup_checkbox_name {Show this screen at startup.}
set exit_button_name {Exit}

proc getVariable {variable} {
        upvar $variable variableCont
        return $variableCont
}

#puts [getVariable right_main_title]

# set colors
set leftbg {#ffb0b0}
set leftseparator {#993333}
set headerbg {#993333}

# win32-style control colors
global backgroundColor
global lightShadowColor
global shadowColor
global lightColor
global foregroundColor
global windowColor

set backgroundColor {#d4d0c8}
set lightShadowColor {#808080}
set shadowColor {#404040}
set lightColor {#FFFFFF}
set foregroundColor {#000000}
set windowColor {#FFFFFF}


# center window and set size
set x_1 [ expr {([ winfo vrootwidth  . ] - 478 ) / 2 }]
set y_1 [ expr {([ winfo vrootheight . ] - 322 ) / 2 }]
wm geometry . 478x322+$x_1+$y_1

# create image
image create photo logo -file [file dirname [file normalize [info script] ] ]/logo-debian.png

# create logo canvas
canvas .logo -width 478 -height 93 -highlightthickness 0
.logo create image 0 0 -image logo -anchor nw

pack .logo

# create left side canvas
canvas .leftcanvas -width 179 -height 229 -highlightthickness 0 -background $leftbg
pack .leftcanvas -side left

# create left side lines
.leftcanvas create line 0 24 179 24 -fill $leftseparator
.leftcanvas create rectangle 0 0 179 24 -tags hovereffect-register -outline {}
.leftcanvas create line 0 49 179 49 -fill $leftseparator
.leftcanvas create rectangle 0 25 179 49 -tags hovereffect-discover -outline {}
.leftcanvas create line 0 74 179 74 -fill $leftseparator
.leftcanvas create rectangle 0 50 179 74 -tags hovereffect-connect -outline {}

# create left side text
.leftcanvas create text 10 12  -anchor w -font boldfont -underline 0 -text $left_register_name
.leftcanvas create text 10 37 -anchor w -font boldfont -underline 0 -text $left_discover_name
.leftcanvas create text 10 62 -anchor w -font boldfont -underline 0 -text $left_connect_name

# create right side canvas
canvas .rightcanvas -width 478 -height 229 -highlightthickness 0 -background white
pack .rightcanvas

# create right side bitmap
image create photo welcome -file [file dirname [file normalize [info script] ] ]/welcome-debian.png
.rightcanvas create image 17 71 -tags image -image welcome -anchor nw

# create right side corner bitmap
image create photo connect -file [file dirname [file normalize [info script] ] ]/connect-debian.png
image create photo discover -file [file dirname [file normalize [info script] ] ]/discover-debian.png
image create photo register -file [file dirname [file normalize [info script] ] ]/register-debian.png
.rightcanvas create image 299 229 -tags cornerimage -anchor se -state hidden

# create right side text
.rightcanvas create text 16 11  -anchor nw -fill $headerbg -font headerfont -tags header -text $right_main_title
.rightcanvas create text 16 37  -anchor nw -font mainfont -width 260 -tags text -text $right_main_text

# create exit button
.rightcanvas create rectangle 248 200 290 220 -outline {#808080} -fill white
.rightcanvas create text 270 211 -fill {#808080} -underline 0 -text $exit_button_name -font boldfont
.rightcanvas create rectangle 251 203 287 217 -tags stipple -outline {#2b2f37} -state hidden -outlinestipple @[file dirname [file normalize [info script] ] ]/stipple.xbm
#.rightcanvas create bitmap 251 203 -tags stipple -foreground {#2b2f37} -state hidden -anchor nw -bitmap @[file dirname [file normalize [info script] ] ]/stipple.xbm

# create exit button action
.rightcanvas create rectangle 248 200 290 220 -tags exit-action -outline {} -fill {}
.rightcanvas bind exit-action <Enter> {
	%W configure -cursor hand1
	%W itemconfig stipple -state normal
}

.rightcanvas bind exit-action <Leave> {
	%W configure -cursor left_ptr
	%W itemconfig stipple -state hidden
}

.rightcanvas bind exit-action <ButtonRelease-1> {
	exit
}

# create left side actions

# "Register Now" action
.leftcanvas create rectangle 0 0 179 24 -tags register -outline {}
.leftcanvas bind register <Enter> {
	%W configure -cursor hand1
	%W itemconfig hovereffect-register -fill white

	.rightcanvas itemconfig image -state hidden
	.rightcanvas itemconfig header -text [getVariable right_register_title]
	.rightcanvas itemconfig text -text [getVariable right_register_text]
	.rightcanvas itemconfig cornerimage -image register -state normal
}

.leftcanvas bind register <Leave> {
	%W configure -cursor left_ptr
	%W itemconfig hovereffect-register -fill {}

	.rightcanvas itemconfig image -state normal
	.rightcanvas itemconfig header -text [getVariable right_main_title]
	.rightcanvas itemconfig text -text [getVariable right_main_text]
	.rightcanvas itemconfig cornerimage -state hidden
}

.leftcanvas bind register <Button-1> {
	exec xmessage -nearmouse "This is a test." &
}

# "Discover Windows" action
.leftcanvas create rectangle 0 25 179 49 -tags discover -outline {}
.leftcanvas bind discover <Enter> {
	%W configure -cursor hand1
	%W itemconfig hovereffect-discover -fill white

	.rightcanvas itemconfig image -state hidden
	.rightcanvas itemconfig header -text [getVariable right_discover_title]
	.rightcanvas itemconfig text -text [getVariable right_discover_text]
	.rightcanvas itemconfig cornerimage -image discover -state normal
}

.leftcanvas bind discover <Leave> {
	%W configure -cursor left_ptr
	%W itemconfig hovereffect-discover -fill {}

	.rightcanvas itemconfig image -state normal
	.rightcanvas itemconfig header -text [getVariable right_main_title]
	.rightcanvas itemconfig text -text [getVariable right_main_text]
	.rightcanvas itemconfig cornerimage -state hidden
}

.leftcanvas bind discover <Button-1> {
	exec xmessage -nearmouse "This is a test." &
#	exec xterm
}

# "Connect to the Internet" action
.leftcanvas create rectangle 0 50 179 74 -tags connect -outline {}
.leftcanvas bind connect <Enter> {
	%W configure -cursor hand1
	%W itemconfig hovereffect-connect -fill white

	.rightcanvas itemconfig image -state hidden
	.rightcanvas itemconfig header -text [getVariable right_connect_title]
	.rightcanvas itemconfig text -text [getVariable right_connect_text]
	.rightcanvas itemconfig cornerimage -image connect -state normal
}

.leftcanvas bind connect <Leave> {
	%W configure -cursor left_ptr
	%W itemconfig hovereffect-connect -fill {}

	.rightcanvas itemconfig image -state normal
	.rightcanvas itemconfig header -text [getVariable right_main_title]
	.rightcanvas itemconfig text -text [getVariable right_main_text]
	.rightcanvas itemconfig cornerimage -state hidden
}

.leftcanvas bind connect <Button-1> {
	exec xmessage -nearmouse "This is a test." &
}

# startup checkbox
set x_checkbox {8}
set y_checkbox {210}

.leftcanvas create rectangle $x_checkbox $y_checkbox [expr {$x_checkbox + 13}] [expr {$y_checkbox + 13}] -fill $backgroundColor -outline {}

.leftcanvas create line $x_checkbox $y_checkbox [expr {$x_checkbox + 12}] $y_checkbox -fill $lightShadowColor
.leftcanvas create line $x_checkbox $y_checkbox $x_checkbox [expr {$y_checkbox + 12}] -fill $lightShadowColor

.leftcanvas create line [expr {$x_checkbox + 1}] [expr {$y_checkbox + 1}] [expr {$x_checkbox + 1}] [expr {$y_checkbox + 11}] -fill $shadowColor
.leftcanvas create line [expr {$x_checkbox + 1}] [expr {$y_checkbox + 1}] [expr {$x_checkbox + 11}] [expr {$y_checkbox + 1}] -fill $shadowColor

.leftcanvas create line [expr {$x_checkbox + 12}] $y_checkbox [expr {$x_checkbox + 12}] [expr {$y_checkbox + 13}] -fill $lightColor
#.leftcanvas create line 12 0 12 13 -fill $lightColor

.leftcanvas create line $x_checkbox [expr {$y_checkbox + 12}] [expr {$x_checkbox + 12}] [expr {$y_checkbox + 12}] -fill $lightColor

.leftcanvas create rectangle [expr {$x_checkbox + 2}] [expr {$y_checkbox + 2}] [expr {$x_checkbox + 10}] [expr {$y_checkbox + 10}] -fill $windowColor -outline $windowColor -tags cbBox
.leftcanvas create text [expr {$x_checkbox + 17}] [expr {$y_checkbox + 5}] -anchor w -underline 0 -font smallfont -text $startup_checkbox_name

.leftcanvas create rectangle [expr {$x_checkbox + 0}] [expr {$y_checkbox + 0}] [expr {$x_checkbox + 171}] [expr {$y_checkbox + 13}] -outline {} -tags "cbAction"

global Startup
set Startup {True}

.leftcanvas create bitmap [expr {$x_checkbox + 3}] [expr {$y_checkbox + 3}] -anchor nw -tags checkbox -foreground $foregroundColor -bitmap @[file dirname [file normalize [info script] ] ]/checkbox.xbm

.leftcanvas bind cbAction <ButtonPress-1> {
	#%W itemconfig cbBox -outline $backgroundColor -fill $backgroundColor
	%W itemconfig cbBox -outline [getVariable backgroundColor] -fill [getVariable backgroundColor]
}

.leftcanvas bind cbAction <ButtonRelease-1> {
	#%W itemconfig cbBox -outline $backgroundColor -fill $backgroundColor
	%W itemconfig cbBox -outline [getVariable windowColor] -fill [getVariable windowColor]
	if {$Startup == {True}} {
		%W itemconfig checkbox -state hidden
		set Startup {False}
	} else {
		%W itemconfig checkbox -state normal
		set Startup {True}
	}
}
