#!/bin/sh
#\
exec wish $0 $* &
#\
exit
#
# QCad Main Startup Window
#
#

tk scaling 1.0	;# I don't know what is up with tk and font servers.
				 # doesnt seem to like 100dpi screen resolutions
catch {source src.tcl}
Source ""

set win ""
set Logo [image create photo -file QSCad.gif]

pack [frame $win.cmd -bd 2 -relief raised] -side left -anc nw -fill y
pack [frame $win.logo -bd 1 -relief sunken] -side left -anc nw -fill both -expand 1
pack [canvas $win.logo.canvas -width 400 -height 300] -anc nw
set canvas $win.logo.canvas
$canvas create image 0 0 -image $Logo -anc nw
set oid [$canvas create line 0 0 0 0 -tag Top]

proc title {} {
	global canvas oid
	set colour 255
	set c2 0
	set i 0
	for {set x 0} {$x < 20} {incr x} {
		set Colour [format "%02x" $colour]
		set Colour2 [format "%02x" $c2]
		set id [$canvas create text  [expr $x + 60] [expr $x + 100] -text "QS Cad" -fill #0000${Colour} -font {Helvetica 80 bold} -anc nw -tags "Logo Logo$i"]
		$canvas lower $id $oid
		set oid $id
		incr colour -10
		if { $colour < 0 } {set colour 0}
		incr c2 10
		incr i
		update
	}
	after 500 anim
}



#pack [label $win.logo.logo -image $Logo -bg Black] -anc nw

set dx 2
set dy 2
proc anim {} {
	global canvas oid

	set colour 255
	set c2 0
	set rc 0
	for {set x 0} {$x < 100} {incr x} {
		foreach tag [$canvas find withtag Logo0] {
			set col [$canvas itemcget $tag -fill]
			scan $col "#%x" col
			set col [expr $col & 255]
			incr rc 2
			incr col -2
			$canvas itemconfig $tag -fill #[format "%02x" 0][format "%02x" $rc][format "%02x" $col]
		}
		update
	}
}

set n 0
foreach {text image} {"Visual Edit" Visual "Decal Edit" Decal "Schematic Cap" Sch "PCB Layout" Pcb "Part Edit" Part "Flow Chart" Flow} {
	incr n
	pack [button $win.cmd.b$n -text $text -command "Run $image" -font {Helvetica 10 normal}] -fill x -pady 1 -ipadx 2
}
pack [button $win.cmd.hlp -text Help  -command "helpText QSCad QSCad"] -fill x -pady 0 -ipadx 2
pack [button $win.cmd.cfg -text Config  -command Configure -font {Helvetica 10 normal}] -fill x -pady 0 -ipadx 2
pack [button $win.cmd.bsr -text -----  -command "Source {}" -font {Helvetica 4 normal}] -fill x -pady 0 -ipadx 2
pack [button $win.cmd.bqu -text Quit -command "destroy ."] -fill x -pady 0 -ipadx 2
pack [checkbutton $win.cmd.demo -text {Demo Mode} -variable Demo] -fill x -pady 2 -ipadx 2

set Demo 1

proc Run {what} {
	global Demo

	if {! $Demo } {
		set file [dbBrowse $what]
	} else {
		set file Demo
	}
	if { $file == "" } { return}
	[string tolower $what]Edit [file rootname $file] $what
}

update
after idle title
wm resizable . 0 0








