#!/usr/local/bin/wish -f
#
# 
#  Copyright (c) 1994 A & A Custom Software.
#  All rights reserved.
# 
#  Redistribution and use in source and binary forms, with or without
#  modification, are permitted provided that the following conditions
#  are met:
#  1. Redistributions of source code must retain the above copyright
#     notice, this list of conditions and the following disclaimer.
#  2. Redistributions in binary form must reproduce the above copyright
#     notice, this list of conditions and the following disclaimer in the
#     documentation and/or other materials provided with the distribution.
#  3. All advertising materials mentioning features or use of this software
#     must display the following acknowledgement:
#       This product includes software developed by A & A Custom Software 
#       and its contributors.
#  4. Neither the name of A & A Custom Software nor the names of its 
#     contributors may be used to endorse or promote products derived from this 
#     software without specific prior written permission.
# 
#  THIS SOFTWARE IS PROVIDED BY A & A CUSTOM SOFTWARE AND CONTRIBUTORS ``AS IS''
#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
#  ARE DISCLAIMED.  IN NO EVENT SHALL A & A CUSTOM SOFTWARE OR CONTRIBUTORS BE 
#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
#  POSSIBILITY OF SUCH DAMAGE.
# 
# $Id: tkflexfax,v 1.5 1994/05/21 03:30:19 andy Exp $ 
#
# Main for tkflexfax.
#

set auto_path "/usr/local/lib/tkflexfax $auto_path"

ut_mkFrame . {main {} {}}
ut_mkFrame .main {menubar {} {top fillx} docs {} {} cover {} {} schedule {} {}}
ut_mkLabel .main.docs {l_docs {"Documents to FAX"} {top frame n}}
scrollbar .main.docs.scr -relief sunken -command ".main.docs.bx yview"
listbox .main.docs.bx -yscroll ".main.docs.scr set" -relief sunken 
pack append .main.docs .main.docs.scr {left filly} \
    .main.docs.bx {right fill expand}

ut_mkLabel .main.cover {l_cover {"Cover Sheet Information"} {top frame n}}
ut_mkLabel .main.schedule {l_schedule {"Scheduling Information"} {top frame n}}

ut_mkFrame .main.cover {l {-relief flat} {left frame n}
			e {-relief flat} {right expand fill}}
ut_mkFrame .main.schedule {time {-relief flat} {top fillx expand}
			   retries {-relief flat} {top fillx expand}}

ut_mkLabel .main.cover.l {l_phone {"FAX Number:"} {}
			  l_name {"Name:"} {}
			  l_company {"Company:"} {}
			  l_location {"Location:"} {}
			  l_regard {"Regarding:"} {}
			  l_comments {"Comments:"} {}}

ut_mkEntry .main.cover.e {e_phone {-width 15} {} {}
			  e_name {-width 50} {} {}
			  e_company {-width 50} {} {}
			  e_location {-width 50} {} {}
			  e_regard {-width 50} {} {}}

text .main.cover.e.e_comments -relief sunken -border 1 -height 5 -width 48 \
    -wrap word -yscroll ".main.cover.e.scr set"
scrollbar .main.cover.e.scr -command ".main.cover.e.e_comments yview" \
    -relief sunken -border 1
pack append .main.cover.e .main.cover.e.scr {left filly} \
    .main.cover.e.e_comments {left}

# Set a temporary variable for readability
set time {.main.schedule.time} 

ut_mkLabel $time {l_time {"Transmit Time:    now  + "} {left}}
ut_mkEntry $time {e_hour {-width 3 -relief flat -state disabled} {left}}
ut_mkLabel $time {l_colon {":"} {left}}
ut_mkEntry $time {e_min {-width 3 -relief flat -state disabled} {left}}

set plus_attr {"+" -width 4 -command "incrEntry 1"}
set minus_attr {"-" -width 4 -command "incrEntry -1"}
ut_mkButton $time [list \
		  b_plus $plus_attr {left padx 3} \
		  b_minus $minus_attr {left padx 3}]

# Set a temporary variable for readability
set retries {.main.schedule.retries} 

ut_mkLabel $retries {l_try {"Maximum Retries:"} {left}}
ut_mkEntry $retries {e_try {-width 3 -relief flat -state disabled} {left}}

ut_mkRadio $time [list \
		 b_hour [list hour -var entry -val $time.e_hour] {left padx 3} \
		 b_min [list min -var entry -val $time.e_min] {left padx 3} \
		 b_try [list tries -var entry -val $retries.e_try] {left padx 3}]

# Set default schedule selection
set entry $time.e_hour

setEntryTraversal [winfo children .main.cover.e] 

menubutton .main.menubar.file -text {File} -menu .main.menubar.file.m -under 0
menu .main.menubar.file.m
.main.menubar.file.m add command -label {Browse for files to FAX} \
    -command {fileselect .fileselect .main.docs.bx} -under 0
.main.menubar.file.m add command -label {Enter file to FAX} \
    -command {ff_fileToFAX .main.docs.bx} -under 0
.main.menubar.file.m add command -label {Display Server Status} -under 0 \
    -command {qstatus .qtatus} -under 0
.main.menubar.file.m add command -label {Fax File(s)} \
    -command {faxit .main} -under 0
.main.menubar.file.m add separator
.main.menubar.file.m add command -label {Exit} -command {destroy .} -under 1 

menubutton .main.menubar.phone -text {Phone} -menu .main.menubar.phone.m \
    -under 0
menu .main.menubar.phone.m
.main.menubar.phone.m add command -label {List Numbers} \
    -command {rolodex .phone .main.cover.e} -under 0
.main.menubar.phone.m add command -label {Add a Number} \
    -command {update_rolodex .main.cover.e} -under 0
.main.menubar.phone.m add command -label {Delete a Number} \
    -command {delete_rolodex .main.cover.e} -under 0

menubutton .main.menubar.options -text {Options} -menu .main.menubar.options.m \
    -under 0
menu .main.menubar.options.m
.main.menubar.options.m add radio -label {196 line/inch} -variable resolution \
    -value " -m "
.main.menubar.options.m add radio -label {98 lines/inch} -variable resolution \
    -value " -l "
.main.menubar.options.m add separator 
.main.menubar.options.m add checkbutton -label {Notify when Complete} \
    -variable notify_complete -onvalue " -D " -offvalue {}
.main.menubar.options.m add checkbutton -label {Notify on Retry} \
    -variable notify_retry -onvalue " -R " -offvalue {}
.main.menubar.options.m add separator 
.main.menubar.options.m add checkbutton -label {Initiate Poll} -variable poll \
    -onvalue " -p " -offvalue {}
.main.menubar.options.m add separator 
.main.menubar.options.m add checkbutton -label {No Cover Page} -variable cover \
    -onvalue " -n " -offvalue {} 

pack .main.menubar.file .main.menubar.phone .main.menubar.options -side left
tk_menuBar .main.menubar .main.menubar.file .main.menubar.phone \
    .main.menubar.options
tk_bindForTraversal .

# Allow single element deletion from listbox
tk_listboxSingleSelect .main.docs.bx 
bind .main.docs.bx <B1-ButtonRelease> {%W delete [%W curselection]}

setGlobals .main
wm title . "tkFlexFax"
wm geometry . 480x515
wm minsize . 480 515
wm iconbitmap . @/usr/local/lib/tkflexfax/tkflexfax.xbm 
