#!/usr3/users/larson/BIN/pgtkm -f
###########################################################################
#         SEQUOIA 2000 TEXT REPOSITORY BROWSER
#             version 0.2 - DEMO version -
#                   Ray R. Larson
#
#  This file is the main routine for the demo version of the
#  Sequoia 2000 Text Repository Browser. It uses the PGTK
#  Postgres/Tk/Tcl interface developed by the author
#
#  * (c) Copyright 1992 Regents of the University of California.
#  * Permission to use, copy, modify, and distribute this
#  * software and its documentation for any purpose and without
#  * fee is hereby granted, provided that the above copyright
#  * notice appear in all copies.  The University of California
#  * makes no representations about the suitability of this
#  * software for any purpose.  It is provided "as is" without
#  * express or implied warranty.
#
###########################################################################

###########################################################################
#
#  Copyright Notice for Tcl/Tk:
#
#  * Copyright 1990 Regents of the University of California.
#  * Permission to use, copy, modify, and distribute this
#  * software and its documentation for any purpose and without
#  * fee is hereby granted, provided that the above copyright
#  * notice appear in all copies.  The University of California
#  * makes no representations about the suitability of this
#  * software for any purpose.  It is provided "as is" without
#  * express or implied warranty.
#
#############################################################################

# the following  path names need to be set to whatever local directory
# contains the pgtkm program and the s2k tcl programs
#  currently, they are set to the current working directory

#database - default set by pgtkm
global CURRENTDATABASE
PQsetdb "$CURRENTDATABASE"

global PGTK_PATH
set PGTK_PATH "/PGTcl/src"

global S2KPATH
set S2KPATH "/PGTcl/src"

global S2K_VERSION
set S2K_VERSION "v0.95 -- Pre-Release Version-- Oct. 1993"



proc S2Ksource {Filename} {
# note that this version reads the source files from Inversion Large Objs.

	global S2KPATH
	PQsource $S2KPATH/$Filename

#end S2Ksource
}


#-------------------------
# DEFINE GLOBAL VARIABLES
#-------------------------

# the following are filled in by dbinitproc code
global PGCLASS
global PGATTR
global PGDBS
global PGTYPES
global PGTYPELEN
global PGTYPEINDEX
global PGCLASSINDEX
global PGATTRLIST
global PGSYSATTRLIST
global PGUSERATTRLIST

global WINCOUNT
set WINCOUNT 0

global BIGFONT
# this may need to be set if the 25 point helvetica in not available (try 24)
set BIGFONT "*helvetica-medium-r-normal-*-180*"

# this is set to the command to run a postscript viewer for the
# appropriate machine
global PSCOMMAND
global PSPARAMS
#set PSCOMMAND "dxpsview"
#set PSPARAMS  " -geometry 760x1000+0+0 -xrm \"*watchPress:  on\" "
set PSCOMMAND "ghostview"


global WDBMAPFILE
# where is the map data file ?
set WDBMAPFILE "/map.data"

global MAP_ICONS_ON
set MAP_ICONS_ON 0

global POSTEDICONLIST
set POSTEDICONLIST {}

# this is used to track the last edited query
global PGLASTQUERY
set PGLASTQUERY "NO LAST QUERY "

# this is used to track the last edited search
global LASTSEARCH
set LASTSEARCH " NO LAST SEARCH "

global RANKVALS
global SEARCHRES1
global QUERYIDNUM


global TEMPFILENUM
set TEMPFILENUM 0

global TEMPFILES

global TEMPFILEPATH
#set TEMPFILEPATH /tmp/$env(USER)PGTKMWORK
set TEMPFILEPATH $env(HOME)/PGTKMWORK

global BITMAPPATH
#catch {exec mkdir /tmp/$env(USER)PGTKMWORK_BM} 
#set BITMAPPATH /tmp/$env(USER)PGTKMWORK_BM
catch {exec mkdir $env(HOME)/PGTKMWORK_BM} 
set BITMAPPATH $env(HOME)/PGTKMWORK_BM
# for the DB version copy out the bitmaps to BITMAPPATH
PQlocopy /PGTcl/bitmaps/w0.xbm $BITMAPPATH/w0.xbm
PQlocopy /PGTcl/bitmaps/w1.xbm $BITMAPPATH/w1.xbm
PQlocopy /PGTcl/bitmaps/w2.xbm $BITMAPPATH/w2.xbm
PQlocopy /PGTcl/bitmaps/w3.xbm $BITMAPPATH/w3.xbm
PQlocopy /PGTcl/bitmaps/w4.xbm $BITMAPPATH/w4.xbm
PQlocopy /PGTcl/bitmaps/w5.xbm $BITMAPPATH/w5.xbm
PQlocopy /PGTcl/bitmaps/w6.xbm $BITMAPPATH/w6.xbm
PQlocopy /PGTcl/bitmaps/SeqMed.xbm $BITMAPPATH/SeqMed.xbm
PQlocopy /PGTcl/bitmaps/mapicon.on $BITMAPPATH/mapicon.on
PQlocopy /PGTcl/bitmaps/mapicon.off $BITMAPPATH/mapicon.off

global PGQUERYLIST
set PGQUERYLIST {}

# *************************
# *************************


proc WaitWindow {inmsg} {
        catch {destroy .waitwin}
        toplevel        .waitwin -geometry 30x30+300+300
        wm positionfrom .waitwin user
        wm sizefrom     .waitwin program
        wm geometry     .waitwin +400+400
        wm title        .waitwin ""

	global S2K_VERSION
	set mess1 "Please wait while...\n\n"
	set mess2 "$inmsg\n\n"
	set messag "$mess1$mess2"


        message .waitwin.intr -font *times-medium-r-normal--*-180* -justify center -aspect 200  -text "$messag"

        pack append .waitwin .waitwin.intr {top fillx}
        bind .waitwin.intr <Any-Button> { destroy .waitwin}
        # make it appear now!
	tkwait visibility .waitwin.intr
        update
	# in case something happens -- make it go away eventually
        after 10000 {catch {destroy .waitwin}}

}


#-----------------------------------
# source code for S2K user interface
#-----------------------------------
S2Ksource intro.tcl
S2Ksource misc.tcl
S2Ksource dbinitprocs.tcl
S2Ksource dbforms.tcl
S2Ksource dbentries.tcl
S2Ksource dblists.tcl
S2Ksource dblists2.tcl
S2Ksource dblists3.tcl
S2Ksource dbquery.tcl
S2Ksource viewdoc.tcl
S2Ksource searchdocs.tcl

S2Ksource mainbrowse.tcl
S2Ksource mainpanel.tcl
S2Ksource browsedocnames.t
S2Ksource browseauthors.tc
S2Ksource browsekeywords.t
S2Ksource browsedocs.tcl
S2Ksource browsedoclist.tc
S2Ksource help.tcl
S2Ksource geobrowse.tcl
S2Ksource mapmenuicon.tcl
S2Ksource lolist.tcl
S2Ksource newlist3.tcl
S2Ksource lbtools.tcl
#S2Ksource cursors.tcl
S2Ksource icondefs.tcl


#----------------------------------
# Present the S2K User Interface
#----------------------------------

# change active-item behavior for color screens
if {[string compare [tk colormodel .] "monochrome"] != 0} {
     option add *Button.activeBackground LightSkyBlue1
     option add *Menubutton.activeBackground LightSkyBlue1
     option add *Menu.activeBackground LightSkyBlue1
     option add *ListBox.activeBackground LightSkyBlue1
}

IntroWindow

WaitWindow "Initializing database info"
puts stdout "Initializing...."

#  build the database utility arrays
dodbinit
catch {destroy .waitwin}

MainPanel
update

# end of s2k

